diff --git a/Cargo.lock b/Cargo.lock index e6455ee7b2..c7eabef5a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -684,6 +684,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bindgen" version = "0.72.1" @@ -1575,7 +1584,7 @@ dependencies = [ "futures-core", "futures-sink", "nanorand", - "spin", + "spin 0.9.8", ] [[package]] @@ -2615,6 +2624,24 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +[[package]] +name = "miden-agglayer" +version = "0.14.0-alpha.1" +dependencies = [ + "fs-err", + "miden-assembly 0.21.1", + "miden-core 0.21.1", + "miden-core-lib 0.21.2", + "miden-crypto 0.22.3", + "miden-protocol", + "miden-standards", + "miden-utils-sync 0.21.2", + "primitive-types", + "regex", + "thiserror 2.0.18", + "walkdir", +] + [[package]] name = "miden-agglayer" version = "0.14.0-alpha.1" @@ -2622,16 +2649,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e492a6044cf8875a64d7eec130d260f2eda1c783795261f00d5d52837ed027bd" dependencies = [ "fs-err", - "miden-assembly", - "miden-core", - "miden-core-lib", - "miden-crypto", + "miden-assembly 0.20.6", + "miden-core 0.20.6", + "miden-core-lib 0.20.6", + "miden-crypto 0.19.8", "miden-protocol", "miden-standards", - "miden-utils-sync", + "miden-utils-sync 0.20.6", "primitive-types", "regex", - "thiserror", + "thiserror 2.0.18", "walkdir", ] @@ -2641,26 +2668,53 @@ version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cca9632323bd4e32ae5b21b101ed417a646f5d72196b1bf3f1ca889a148322a" dependencies = [ - "miden-core", - "miden-utils-indexing", - "thiserror", + "miden-core 0.20.6", + "miden-utils-indexing 0.20.6", + "thiserror 2.0.18", "winter-air", "winter-prover", ] +[[package]] +name = "miden-air" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8aa2b3bc95d9eece8b47edbc6621b5742e212b359ff6b82ebb813b3d9b28985" +dependencies = [ + "miden-core 0.21.1", + "miden-crypto 0.22.3", + "miden-utils-indexing 0.21.2", + "thiserror 2.0.18", + "tracing", +] + [[package]] name = "miden-assembly" version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2395b2917aea613a285d3425d1ca07e6c45442e2b34febdea2081db555df62fc" +dependencies = [ + "log", + "miden-assembly-syntax 0.20.6", + "miden-core 0.20.6", + "miden-mast-package 0.20.6", + "smallvec", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-assembly" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0204034c9424d52669677eeacd408cd59483d7a87a66489ad9ae716b5bda9a6e" dependencies = [ "env_logger", "log", - "miden-assembly-syntax", - "miden-core", - "miden-mast-package", + "miden-assembly-syntax 0.21.1", + "miden-core 0.21.1", + "miden-mast-package 0.21.1", "smallvec", - "thiserror", + "thiserror 2.0.18", ] [[package]] @@ -2668,15 +2722,37 @@ name = "miden-assembly-syntax" version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f9bed037d137f209b9e7b28811ec78c0536b3f9259d6f4ceb5823c87513b346" +dependencies = [ + "aho-corasick", + "lalrpop", + "lalrpop-util", + "log", + "miden-core 0.20.6", + "miden-debug-types 0.20.6", + "miden-utils-diagnostics 0.20.6", + "midenc-hir-type", + "proptest", + "regex", + "rustc_version 0.4.1", + "semver 1.0.27", + "smallvec", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-assembly-syntax" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a73ed7c463e68374f6eb595b6286f8d5d116a97004eeaee39e89cdc694dd5be1" dependencies = [ "aho-corasick", "env_logger", "lalrpop", "lalrpop-util", "log", - "miden-core", - "miden-debug-types", - "miden-utils-diagnostics", + "miden-core 0.21.1", + "miden-debug-types 0.21.1", + "miden-utils-diagnostics 0.21.2", "midenc-hir-type", "proptest", "proptest-derive", @@ -2684,7 +2760,15 @@ dependencies = [ "rustc_version 0.4.1", "semver 1.0.27", "smallvec", - "thiserror", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-block-prover" +version = "0.14.0-alpha.1" +dependencies = [ + "miden-protocol", + "thiserror 2.0.18", ] [[package]] @@ -2694,7 +2778,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9564dfb23c529aad68369845b6897a6f62bacdeab7c00db432a5f16670764d4" dependencies = [ "miden-protocol", - "thiserror", + "thiserror 2.0.18", ] [[package]] @@ -2707,11 +2791,11 @@ dependencies = [ "futures", "getrandom 0.3.4", "hex", - "miden-mast-package", - "miden-node-proto-build", + "miden-debug", + "miden-node-proto-build 0.14.0-alpha.1", "miden-note-transport-proto-build", "miden-protocol", - "miden-remote-prover-client", + "miden-remote-prover-client 0.14.0-alpha.1", "miden-standards", "miden-testing", "miden-tx", @@ -2721,7 +2805,7 @@ dependencies = [ "rand", "serde", "serde_json", - "thiserror", + "thiserror 2.0.18", "tokio", "tonic", "tonic-health", @@ -2762,13 +2846,14 @@ dependencies = [ "figment", "miden-client", "miden-client-sqlite-store", + "miden-debug", "miette", "predicates", "rand", "regex", "serde", "serial_test", - "thiserror", + "thiserror 2.0.18", "tokio", "toml 0.9.12+spec-1.1.0", "tracing", @@ -2811,7 +2896,7 @@ dependencies = [ "miden-standards", "rusqlite", "rusqlite_migration", - "thiserror", + "thiserror 2.0.18", "tokio", ] @@ -2843,7 +2928,7 @@ dependencies = [ "rand", "serde", "serde-wasm-bindgen", - "thiserror", + "thiserror 2.0.18", "tracing", "tracing-subscriber", "tracing-wasm", @@ -2860,20 +2945,39 @@ checksum = "8714aa5f86c59e647b7417126b32adc4ef618f835964464f5425549df76b6d03" dependencies = [ "derive_more", "itertools 0.14.0", - "miden-crypto", - "miden-debug-types", + "miden-crypto 0.19.8", + "miden-debug-types 0.20.6", "miden-formatting", - "miden-utils-core-derive", - "miden-utils-indexing", + "miden-utils-core-derive 0.20.6", + "miden-utils-indexing 0.20.6", "num-derive", "num-traits", - "proptest", - "proptest-derive", - "thiserror", + "thiserror 2.0.18", "winter-math", "winter-utils", ] +[[package]] +name = "miden-core" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f53957feff616a43cd4ad5be9efeaeb7c3adfb589115e67a19eaf518f5c5e53a" +dependencies = [ + "derive_more", + "itertools 0.14.0", + "miden-crypto 0.22.3", + "miden-debug-types 0.21.1", + "miden-formatting", + "miden-utils-core-derive 0.21.2", + "miden-utils-indexing 0.21.2", + "miden-utils-sync 0.21.2", + "num-derive", + "num-traits", + "proptest", + "proptest-derive", + "thiserror 2.0.18", +] + [[package]] name = "miden-core-lib" version = "0.20.6" @@ -2882,13 +2986,29 @@ checksum = "1bb16a4d39202c59a7964d3585cd5af21a46a759ff6452cb5f20723ed5af4362" dependencies = [ "env_logger", "fs-err", - "miden-assembly", - "miden-core", - "miden-crypto", - "miden-processor", - "miden-utils-sync", + "miden-assembly 0.20.6", + "miden-core 0.20.6", + "miden-crypto 0.19.8", + "miden-processor 0.20.6", + "miden-utils-sync 0.20.6", "sha2", - "thiserror", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-core-lib" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa496b3a7546c0022e8d5a92d88726907e380074f1fb634859b5e2094270dacf" +dependencies = [ + "env_logger", + "fs-err", + "miden-assembly 0.21.1", + "miden-core 0.21.1", + "miden-crypto 0.22.3", + "miden-processor 0.21.1", + "miden-utils-sync 0.21.2", + "thiserror 2.0.18", ] [[package]] @@ -2907,7 +3027,7 @@ dependencies = [ "hashbrown 0.16.1", "hkdf", "k256", - "miden-crypto-derive", + "miden-crypto-derive 0.19.8", "num", "num-complex", "rand", @@ -2918,13 +3038,62 @@ dependencies = [ "sha2", "sha3", "subtle", - "thiserror", + "thiserror 2.0.18", "winter-crypto", "winter-math", "winter-utils", "x25519-dalek", ] +[[package]] +name = "miden-crypto" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cfbecd3d91ece4489b78ca2ea67b31a7b635164285c1a828b7386d691c7ec72" +dependencies = [ + "blake3", + "cc", + "chacha20poly1305", + "curve25519-dalek", + "ed25519-dalek", + "flume", + "glob", + "hashbrown 0.16.1", + "hkdf", + "k256", + "miden-crypto-derive 0.22.4", + "miden-field", + "miden-serde-utils", + "num", + "num-complex", + "p3-air", + "p3-blake3", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-goldilocks", + "p3-keccak", + "p3-matrix", + "p3-maybe-rayon", + "p3-merkle-tree", + "p3-miden-air", + "p3-miden-fri", + "p3-miden-prover", + "p3-symmetric", + "p3-util", + "rand", + "rand_chacha", + "rand_core 0.9.5", + "rand_hc", + "rayon", + "sha2", + "sha3", + "subtle", + "thiserror 2.0.18", + "x25519-dalek", +] + [[package]] name = "miden-crypto-derive" version = "0.19.8" @@ -2935,6 +3104,54 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "miden-crypto-derive" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "207828f24e358b4e1e0641c37802816b8730816ff92ddb4d271ef3a00f8696bb" +dependencies = [ + "quote", + "syn 2.0.117", +] + +[[package]] +name = "miden-debug" +version = "0.4.6" +dependencies = [ + "clap", + "futures", + "glob", + "log", + "miden-assembly 0.21.1", + "miden-assembly-syntax 0.21.1", + "miden-core 0.21.1", + "miden-crypto 0.22.3", + "miden-debug-dap", + "miden-debug-types 0.21.1", + "miden-mast-package 0.21.1", + "miden-processor 0.21.1", + "miden-protocol", + "miden-thiserror", + "miden-tx", + "num-traits", + "rustc-demangle", + "serde", + "serde_json", + "smallvec", + "tokio", + "tokio-util", + "toml 0.8.23", +] + +[[package]] +name = "miden-debug-dap" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "thiserror 1.0.69", +] + [[package]] name = "miden-debug-types" version = "0.20.6" @@ -2942,15 +3159,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd1494f102ad5b9fa43e391d2601186dc601f41ab7dcd8a23ecca9bf3ef930f4" dependencies = [ "memchr", - "miden-crypto", + "miden-crypto 0.19.8", "miden-formatting", "miden-miette", - "miden-utils-indexing", - "miden-utils-sync", + "miden-utils-indexing 0.20.6", + "miden-utils-sync 0.20.6", "paste", "serde", "serde_spanned 1.0.4", - "thiserror", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-debug-types" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d76def09875650d6d2ea568015ae99c892aa34c3393a0c3ba43891c8c4bd5ba" +dependencies = [ + "memchr", + "miden-crypto 0.22.3", + "miden-formatting", + "miden-miette", + "miden-utils-indexing 0.21.2", + "miden-utils-sync 0.21.2", + "paste", + "serde", + "serde_spanned 1.0.4", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-field" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f821a07c16cfa6e500d5a56d05c11523984e3cd562cfc80ef657e4264d708067" +dependencies = [ + "miden-serde-utils", + "num-bigint", + "p3-challenger", + "p3-field", + "p3-goldilocks", + "paste", + "rand", + "serde", + "thiserror 2.0.18", ] [[package]] @@ -2984,7 +3236,7 @@ version = "0.14.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31cc8f0fe3aad1112d0c23321b4533f88871d1a8238a7a36fc55789a4b19a9b5" dependencies = [ - "miden-crypto", + "miden-crypto 0.19.8", "miden-protocol", "rayon", "rocksdb", @@ -2998,9 +3250,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "692185bfbe0ecdb28bf623f1f8c88282cd6727ba081a28e23b301bdde1b45be4" dependencies = [ "derive_more", - "miden-assembly-syntax", - "miden-core", - "thiserror", + "miden-assembly-syntax 0.20.6", + "miden-core 0.20.6", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-mast-package" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e23d0cf5de7df1273c14614fef84cb5fb464f2f0f354018228b0355ecbcb4206" +dependencies = [ + "derive_more", + "miden-assembly-syntax 0.21.1", + "miden-core 0.21.1", + "miden-debug-types 0.21.1", + "thiserror 2.0.18", ] [[package]] @@ -3021,7 +3286,7 @@ dependencies = [ "rustc_version 0.2.3", "rustversion", "serde_json", - "spin", + "spin 0.9.8", "strip-ansi-escapes", "supports-color", "supports-hyperlinks", @@ -3029,7 +3294,7 @@ dependencies = [ "syn 2.0.117", "terminal_size 0.3.0", "textwrap", - "thiserror", + "thiserror 2.0.18", "trybuild", "unicode-width 0.1.14", ] @@ -3055,14 +3320,14 @@ dependencies = [ "futures", "itertools 0.14.0", "miden-node-proto", - "miden-node-proto-build", + "miden-node-proto-build 0.14.0-alpha.4", "miden-node-utils", "miden-protocol", - "miden-remote-prover-client", + "miden-remote-prover-client 0.14.0-alpha.4", "miden-standards", - "miden-tx-batch-prover", + "miden-tx-batch-prover 0.14.0-alpha.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand", - "thiserror", + "thiserror 2.0.18", "tokio", "tokio-stream", "tonic", @@ -3083,7 +3348,7 @@ dependencies = [ "deadpool-sync", "diesel", "miden-protocol", - "thiserror", + "thiserror 2.0.18", "tracing", ] @@ -3113,10 +3378,10 @@ dependencies = [ "miden-node-proto", "miden-node-utils", "miden-protocol", - "miden-remote-prover-client", + "miden-remote-prover-client 0.14.0-alpha.4", "miden-standards", "miden-tx", - "thiserror", + "thiserror 2.0.18", "tokio", "tokio-stream", "tokio-util", @@ -3137,20 +3402,31 @@ dependencies = [ "hex", "http 1.4.0", "miden-node-grpc-error-macro", - "miden-node-proto-build", + "miden-node-proto-build 0.14.0-alpha.4", "miden-node-rocksdb-cxx-linkage-fix", "miden-node-utils", "miden-protocol", "miden-standards", "miette", "prost", - "thiserror", + "thiserror 2.0.18", "tonic", "tonic-prost", "tonic-prost-build", "url", ] +[[package]] +name = "miden-node-proto-build" +version = "0.14.0-alpha.1" +dependencies = [ + "build-rs", + "fs-err", + "miette", + "protox", + "tonic-prost-build", +] + [[package]] name = "miden-node-proto-build" version = "0.14.0-alpha.4" @@ -3181,12 +3457,12 @@ dependencies = [ "http 1.4.0", "mediatype", "miden-node-proto", - "miden-node-proto-build", + "miden-node-proto-build 0.14.0-alpha.4", "miden-node-utils", "miden-protocol", "miden-tx", "semver 1.0.27", - "thiserror", + "thiserror 2.0.18", "tokio", "tokio-stream", "tonic", @@ -3215,23 +3491,23 @@ dependencies = [ "hex", "indexmap", "libsqlite3-sys", - "miden-agglayer", - "miden-block-prover", - "miden-crypto", + "miden-agglayer 0.14.0-alpha.1 (registry+https://github.com/rust-lang/crates.io-index)", + "miden-block-prover 0.14.0-alpha.1 (registry+https://github.com/rust-lang/crates.io-index)", + "miden-crypto 0.19.8", "miden-large-smt-backend-rocksdb", "miden-node-db", "miden-node-proto", - "miden-node-proto-build", + "miden-node-proto-build 0.14.0-alpha.4", "miden-node-rocksdb-cxx-linkage-fix", "miden-node-utils", "miden-protocol", - "miden-remote-prover-client", + "miden-remote-prover-client 0.14.0-alpha.4", "miden-standards", "pretty_assertions", "rand", "rand_chacha", "serde", - "thiserror", + "thiserror 2.0.18", "tokio", "tokio-stream", "toml 1.0.4+spec-1.1.0", @@ -3260,7 +3536,7 @@ dependencies = [ "opentelemetry-otlp", "opentelemetry_sdk", "rand", - "thiserror", + "thiserror 2.0.18", "tokio", "tonic", "tower-http", @@ -3285,11 +3561,11 @@ dependencies = [ "diesel_migrations", "miden-node-db", "miden-node-proto", - "miden-node-proto-build", + "miden-node-proto-build 0.14.0-alpha.4", "miden-node-utils", "miden-protocol", "miden-tx", - "thiserror", + "thiserror 2.0.18", "tokio", "tokio-stream", "tonic", @@ -3317,37 +3593,54 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e09f7916b1e7505f74a50985a185fdea4c0ceb8f854a34c90db28e3f7da7ab6" dependencies = [ "itertools 0.14.0", - "miden-air", - "miden-core", - "miden-debug-types", - "miden-utils-diagnostics", - "miden-utils-indexing", + "miden-air 0.20.6", + "miden-core 0.20.6", + "miden-debug-types 0.20.6", + "miden-utils-diagnostics 0.20.6", + "miden-utils-indexing 0.20.6", "paste", "rayon", - "thiserror", + "thiserror 2.0.18", "tokio", "tracing", "winter-prover", ] +[[package]] +name = "miden-processor" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e173de74f1085c66aa269c817f3340c33d5f03221ce9bdf1fff3cf53d910016e" +dependencies = [ + "itertools 0.14.0", + "miden-air 0.21.2", + "miden-core 0.21.1", + "miden-debug-types 0.21.1", + "miden-utils-diagnostics 0.21.2", + "miden-utils-indexing 0.21.2", + "paste", + "rayon", + "thiserror 2.0.18", + "tokio", + "tracing", +] + [[package]] name = "miden-protocol" version = "0.14.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a88effeac994eb55b8dc4f93fbfd71a5d916dfaba1099896e27a0ee42c488c1" dependencies = [ "bech32", "fs-err", "getrandom 0.3.4", - "miden-assembly", - "miden-assembly-syntax", - "miden-core", - "miden-core-lib", - "miden-crypto", - "miden-mast-package", - "miden-processor", + "miden-assembly 0.21.1", + "miden-assembly-syntax 0.21.1", + "miden-core 0.21.1", + "miden-core-lib 0.21.2", + "miden-crypto 0.22.3", + "miden-mast-package 0.21.1", + "miden-processor 0.21.1", "miden-protocol-macros", - "miden-utils-sync", + "miden-utils-sync 0.21.2", "miden-verifier", "rand", "rand_chacha", @@ -3355,17 +3648,14 @@ dependencies = [ "regex", "semver 1.0.27", "serde", - "thiserror", - "toml 0.9.12+spec-1.1.0", + "thiserror 2.0.18", + "toml 1.0.4+spec-1.1.0", "walkdir", - "winter-rand-utils", ] [[package]] name = "miden-protocol-macros" version = "0.14.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb28b730005e5f8b08d615ea9216f8cab77b3a7439fa54d5e39d2ec43ef53a3" dependencies = [ "proc-macro2", "quote", @@ -3374,16 +3664,39 @@ dependencies = [ [[package]] name = "miden-prover" -version = "0.20.6" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d45e30526be72b8af0fd1d8b24c9cba8ac1187ca335dcee38b8e5e20234e7698" +checksum = "d0fe4c03cc2a5c0404596f10c076e8e265d87fb7a9c5fbe21b15bc12874f7855" dependencies = [ - "miden-air", - "miden-debug-types", - "miden-processor", + "bincode", + "miden-air 0.21.2", + "miden-core 0.21.1", + "miden-crypto 0.22.3", + "miden-debug-types 0.21.1", + "miden-processor 0.21.1", + "serde", + "tokio", "tracing", - "winter-maybe-async", - "winter-prover", +] + +[[package]] +name = "miden-remote-prover-client" +version = "0.14.0-alpha.1" +dependencies = [ + "build-rs", + "fs-err", + "getrandom 0.4.2", + "miden-node-proto-build 0.14.0-alpha.1", + "miden-protocol", + "miden-tx", + "miette", + "prost", + "thiserror 2.0.18", + "tokio", + "tonic", + "tonic-prost", + "tonic-prost-build", + "tonic-web-wasm-client", ] [[package]] @@ -3395,12 +3708,12 @@ dependencies = [ "build-rs", "fs-err", "getrandom 0.4.2", - "miden-node-proto-build", + "miden-node-proto-build 0.14.0-alpha.4", "miden-protocol", "miden-tx", "miette", "prost", - "thiserror", + "thiserror 2.0.18", "tokio", "tonic", "tonic-prost", @@ -3408,60 +3721,91 @@ dependencies = [ "tonic-web-wasm-client", ] +[[package]] +name = "miden-serde-utils" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fe74c2e7d8a8b8758e067de10665816928222c1d0561d95c12ac4bcaefc2a2a" +dependencies = [ + "p3-field", + "p3-goldilocks", +] + [[package]] name = "miden-standards" version = "0.14.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cef036bbfec29acba92751a13d05844bbcf080140201097b419c9ad1927e367" dependencies = [ "fs-err", - "miden-assembly", - "miden-core", - "miden-core-lib", - "miden-processor", + "miden-assembly 0.21.1", + "miden-core 0.21.1", + "miden-core-lib 0.21.2", + "miden-processor 0.21.1", "miden-protocol", "rand", "regex", - "thiserror", + "thiserror 2.0.18", "walkdir", ] [[package]] name = "miden-testing" version = "0.14.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e980777d0f7e6069942b14d4e7cb3d4d137b323ddfa15722a3bd21e9d13fdd2e" dependencies = [ "anyhow", "itertools 0.14.0", - "miden-agglayer", - "miden-assembly", - "miden-block-prover", - "miden-core-lib", - "miden-crypto", - "miden-processor", + "miden-agglayer 0.14.0-alpha.1", + "miden-assembly 0.21.1", + "miden-block-prover 0.14.0-alpha.1", + "miden-core-lib 0.21.2", + "miden-crypto 0.22.3", + "miden-processor 0.21.1", "miden-protocol", "miden-standards", "miden-tx", - "miden-tx-batch-prover", + "miden-tx-batch-prover 0.14.0-alpha.1", "rand", "rand_chacha", - "thiserror", - "winterfell", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-thiserror" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "183ff8de338956ecfde3a38573241eb7a6f3d44d73866c210e5629c07fa00253" +dependencies = [ + "miden-thiserror-impl", +] + +[[package]] +name = "miden-thiserror-impl" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee4176a0f2e7d29d2a8ee7e60b6deb14ce67a20e94c3e2c7275cdb8804e1862" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", ] [[package]] name = "miden-tx" version = "0.14.0-alpha.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c67e0df9adcf29c9111df65acf408ae05952b8bc6569f571963676f97668d83f" dependencies = [ - "miden-processor", + "miden-processor 0.21.1", "miden-protocol", "miden-prover", "miden-standards", "miden-verifier", - "thiserror", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-tx-batch-prover" +version = "0.14.0-alpha.1" +dependencies = [ + "miden-protocol", + "miden-tx", ] [[package]] @@ -3485,14 +3829,38 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "miden-utils-core-derive" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad5c364abe484d43d171afc320e7560db37ece00fe625569068c1053ed186540" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "miden-utils-diagnostics" version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52658f6dc091c1c78e8b35ee3e7ff3dad53051971a3c514e461f581333758fe7" dependencies = [ - "miden-crypto", - "miden-debug-types", + "miden-crypto 0.19.8", + "miden-debug-types 0.20.6", + "miden-miette", + "paste", + "tracing", +] + +[[package]] +name = "miden-utils-diagnostics" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "467d8eafd735ab1e0db7bf6a6a8b5bcf4c31a56c0cd7f80cba1932d4bb984b12" +dependencies = [ + "miden-crypto 0.22.3", + "miden-debug-types 0.21.1", "miden-miette", "paste", "tracing", @@ -3504,7 +3872,17 @@ version = "0.20.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eeff7bcb7875b222424bdfb657a7cf21a55e036aa7558ebe1f5d2e413b440d0d" dependencies = [ - "thiserror", + "thiserror 2.0.18", +] + +[[package]] +name = "miden-utils-indexing" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc42cfa3aef68d21238b3ce4c2db00a1278f8075ef492c23c035ab6c75774790" +dependencies = [ + "miden-crypto 0.22.3", + "thiserror 2.0.18", ] [[package]] @@ -3518,17 +3896,30 @@ dependencies = [ "parking_lot", ] +[[package]] +name = "miden-utils-sync" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e09bb239449e63e9a81f9b4ca5db1762327f44fb50777527fdba6fdbcab890" +dependencies = [ + "lock_api", + "loom", + "once_cell", + "parking_lot", +] + [[package]] name = "miden-verifier" -version = "0.20.6" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13816663794beb15c8a4721c15252eb21f3b3233525684f60c7888837a98ff4" +checksum = "fbb4d3120e2c9cce41b5dac7507cd86154951938b9effbc322c57983065bfa4a" dependencies = [ - "miden-air", - "miden-core", - "thiserror", + "bincode", + "miden-air 0.21.2", + "miden-core 0.21.1", + "miden-crypto 0.22.3", + "thiserror 2.0.18", "tracing", - "winter-verifier", ] [[package]] @@ -3539,7 +3930,7 @@ checksum = "9d4cfab04baffdda3fb9eafa5f873604059b89a1699aa95e4f1057397a69f0b5" dependencies = [ "miden-formatting", "smallvec", - "thiserror", + "thiserror 2.0.18", ] [[package]] @@ -3835,7 +4226,7 @@ dependencies = [ "futures-sink", "js-sys", "pin-project-lite", - "thiserror", + "thiserror 2.0.18", "tracing", ] @@ -3850,7 +4241,7 @@ dependencies = [ "opentelemetry-proto", "opentelemetry_sdk", "prost", - "thiserror", + "thiserror 2.0.18", "tokio", "tonic", ] @@ -3880,7 +4271,7 @@ dependencies = [ "opentelemetry", "percent-encoding", "rand", - "thiserror", + "thiserror 2.0.18", "tokio", "tokio-stream", ] @@ -3903,6 +4294,338 @@ version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d211803b9b6b570f68772237e415a029d5a50c65d382910b879fb19d3271f94d" +[[package]] +name = "p3-air" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0141a56ed9924ce0265e7e91cd29bbcd230262744b7a7f0c448bfbf212f73182" +dependencies = [ + "p3-field", + "p3-matrix", +] + +[[package]] +name = "p3-blake3" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006330bae15fdda0d460e73e03e7ebf06e8848dfda8355f9d568a7fed7c37719" +dependencies = [ + "blake3", + "p3-symmetric", + "p3-util", +] + +[[package]] +name = "p3-challenger" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20e42ba74a49c08c6e99f74cd9b343bfa31aa5721fea55079b18e3fd65f1dcbc" +dependencies = [ + "p3-field", + "p3-maybe-rayon", + "p3-monty-31", + "p3-symmetric", + "p3-util", + "tracing", +] + +[[package]] +name = "p3-commit" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "498211e7b9a0f8366b410b4a9283ae82ff2fc91f473b1c5816aa6e90e74b125d" +dependencies = [ + "itertools 0.14.0", + "p3-challenger", + "p3-dft", + "p3-field", + "p3-matrix", + "p3-util", + "serde", +] + +[[package]] +name = "p3-dft" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e63fa5eb1bd12a240089e72ae3fe10350944d9c166d00a3bfd2a1794db65cf5c" +dependencies = [ + "itertools 0.14.0", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "spin 0.10.0", + "tracing", +] + +[[package]] +name = "p3-field" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ebfdb6ef992ae64e9e8f449ac46516ffa584f11afbdf9ee244288c2a633cdf4" +dependencies = [ + "itertools 0.14.0", + "num-bigint", + "p3-maybe-rayon", + "p3-util", + "paste", + "rand", + "serde", + "tracing", +] + +[[package]] +name = "p3-goldilocks" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64716244b5612622d4e78a4f48b74f6d3bb7b4085b7b6b25364b1dfca7198c66" +dependencies = [ + "num-bigint", + "p3-challenger", + "p3-dft", + "p3-field", + "p3-mds", + "p3-poseidon2", + "p3-symmetric", + "p3-util", + "paste", + "rand", + "serde", +] + +[[package]] +name = "p3-interpolation" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d877565a94a527c89459fc8ccb0eb58769d8c86456575d1315a1651bd24616d" +dependencies = [ + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", +] + +[[package]] +name = "p3-keccak" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57334537d10316e0f1cda622f0a5b3239f219a5dcd2a95ea87e41e00df6a92" +dependencies = [ + "p3-field", + "p3-symmetric", + "p3-util", + "tiny-keccak", +] + +[[package]] +name = "p3-matrix" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5542f96504dae8100c91398fb1e3f5ec669eb9c73d9e0b018a93b5fe32bad230" +dependencies = [ + "itertools 0.14.0", + "p3-field", + "p3-maybe-rayon", + "p3-util", + "rand", + "serde", + "tracing", + "transpose", +] + +[[package]] +name = "p3-maybe-rayon" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e5669ca75645f99cd001e9d0289a4eeff2bc2cd9dc3c6c3aaf22643966e83df" +dependencies = [ + "rayon", +] + +[[package]] +name = "p3-mds" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038763af23df9da653065867fd85b38626079031576c86fd537097e5be6a0da0" +dependencies = [ + "p3-dft", + "p3-field", + "p3-symmetric", + "p3-util", + "rand", +] + +[[package]] +name = "p3-merkle-tree" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d93625a3041effddc72ee2511c919f710b7f91fd0f9931ab8a70aeba586fd6e" +dependencies = [ + "itertools 0.14.0", + "p3-commit", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-symmetric", + "p3-util", + "rand", + "serde", + "thiserror 2.0.18", + "tracing", +] + +[[package]] +name = "p3-miden-air" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45a88e6ee9c92ff6c0b64f1ec0d61eda72fb432bda45337d876c46bd43748508" +dependencies = [ + "p3-air", + "p3-field", + "p3-matrix", +] + +[[package]] +name = "p3-miden-fri" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e282998bc1d12dceaa0ed8979fa507b8369d663fa377da695d578f5f3a035935" +dependencies = [ + "itertools 0.14.0", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-interpolation", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "rand", + "serde", + "tracing", +] + +[[package]] +name = "p3-miden-prover" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05a61c10cc2d6a73e192ac34a9884e4f26bd877f3eaea441d7b7ebfdffdf6c7" +dependencies = [ + "itertools 0.14.0", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-interpolation", + "p3-matrix", + "p3-maybe-rayon", + "p3-miden-air", + "p3-miden-uni-stark", + "p3-util", + "serde", + "tracing", +] + +[[package]] +name = "p3-miden-uni-stark" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a78b6a5b5f6bdc55439d343d2a0a2a8e7cb6544b03296f54d2214a84e91e130" +dependencies = [ + "itertools 0.14.0", + "p3-air", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-uni-stark", + "p3-util", + "serde", + "thiserror 2.0.18", + "tracing", +] + +[[package]] +name = "p3-monty-31" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a981d60da3d8cbf8561014e2c186068578405fd69098fa75b43d4afb364a47" +dependencies = [ + "itertools 0.14.0", + "num-bigint", + "p3-dft", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-mds", + "p3-poseidon2", + "p3-symmetric", + "p3-util", + "paste", + "rand", + "serde", + "spin 0.10.0", + "tracing", + "transpose", +] + +[[package]] +name = "p3-poseidon2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903b73e4f9a7781a18561c74dc169cf03333497b57a8dd02aaeb130c0f386599" +dependencies = [ + "p3-field", + "p3-mds", + "p3-symmetric", + "p3-util", + "rand", +] + +[[package]] +name = "p3-symmetric" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cd788f04e86dd5c35dd87cad29eefdb6371d2fd5f7664451382eeacae3c3ed0" +dependencies = [ + "itertools 0.14.0", + "p3-field", + "serde", +] + +[[package]] +name = "p3-uni-stark" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68d409704a8cbdb6c77f6b83a05c6b16a3c8a2c00d880146fa34181977a0d3ac" +dependencies = [ + "itertools 0.14.0", + "p3-air", + "p3-challenger", + "p3-commit", + "p3-dft", + "p3-field", + "p3-matrix", + "p3-maybe-rayon", + "p3-util", + "serde", + "thiserror 2.0.18", + "tracing", +] + +[[package]] +name = "p3-util" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "663b16021930bc600ecada915c6c3965730a3b9d6a6c23434ccf70bfc29d6881" +dependencies = [ + "rayon", + "serde", +] + [[package]] name = "parking_lot" version = "0.12.5" @@ -4280,7 +5003,7 @@ dependencies = [ "prost-reflect", "prost-types", "protox-parse", - "thiserror", + "thiserror 2.0.18", ] [[package]] @@ -4292,7 +5015,7 @@ dependencies = [ "logos", "miette", "prost-types", - "thiserror", + "thiserror 2.0.18", ] [[package]] @@ -4438,7 +5161,7 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.17", "libredox", - "thiserror", + "thiserror 2.0.18", ] [[package]] @@ -4517,7 +5240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8a1f2315036ef6b1fbacd1972e8ee7688030b0a2121edfc2a6550febd41574d" dependencies = [ "hashbrown 0.16.1", - "thiserror", + "thiserror 2.0.18", ] [[package]] @@ -5019,6 +5742,15 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spin" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591" +dependencies = [ + "lock_api", +] + [[package]] name = "spki" version = "0.7.3" @@ -5053,6 +5785,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + [[package]] name = "string_cache" version = "0.8.9" @@ -5238,13 +5976,33 @@ dependencies = [ "unicode-width 0.2.2", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.18", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", ] [[package]] @@ -5298,6 +6056,15 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinystr" version = "0.8.2" @@ -5386,6 +6153,7 @@ version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ + "indexmap", "serde", "serde_spanned 0.6.9", "toml_datetime 0.6.11", @@ -5615,7 +6383,7 @@ dependencies = [ "httparse", "js-sys", "pin-project", - "thiserror", + "thiserror 2.0.18", "tonic", "tower-service", "wasm-bindgen", @@ -5714,7 +6482,7 @@ checksum = "f09cb459317a3811f76644334473239d696cd8efc606963ae7d1c308cead3b74" dependencies = [ "chrono", "smallvec", - "thiserror", + "thiserror 2.0.18", "tracing", "tracing-subscriber", ] @@ -5788,6 +6556,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +dependencies = [ + "num-integer", + "strength_reduce", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -6557,48 +7335,11 @@ dependencies = [ "winter-utils", ] -[[package]] -name = "winter-rand-utils" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4ff3b651754a7bd216f959764d0a5ab6f4b551c9a3a08fb9ccecbed594b614a" -dependencies = [ - "rand", - "winter-utils", -] - [[package]] name = "winter-utils" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9951263ef5317740cd0f49e618db00c72fabb70b75756ea26c4d5efe462c04dd" -dependencies = [ - "rayon", -] - -[[package]] -name = "winter-verifier" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0425ea81f8f703a1021810216da12003175c7974a584660856224df04b2e2fdb" -dependencies = [ - "winter-air", - "winter-crypto", - "winter-fri", - "winter-math", - "winter-utils", -] - -[[package]] -name = "winterfell" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f824ddd5aec8ca6a54307f20c115485a8a919ea94dd26d496d856ca6185f4f" -dependencies = [ - "winter-air", - "winter-prover", - "winter-verifier", -] [[package]] name = "wit-bindgen" diff --git a/Cargo.toml b/Cargo.toml index 51d2d7e7d9..55d4622554 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,13 +44,16 @@ miden-tx = { default-features = false, version = "=0.14.0-alpha.1" } miden-node-block-producer = { version = "=0.14.0-alpha.4" } miden-node-ntx-builder = { version = "=0.14.0-alpha.4" } miden-node-proto = { version = "=0.14.0-alpha.4" } -miden-node-proto-build = { default-features = false, version = "=0.14.0-alpha.4" } +miden-node-proto-build = { default-features = false, path = "../node/proto", version = "=0.14.0-alpha.1" } miden-node-rpc = { version = "=0.14.0-alpha.4" } miden-node-store = { version = "=0.14.0-alpha.4" } miden-node-utils = { version = "=0.14.0-alpha.4" } miden-node-validator = { version = "=0.14.0-alpha.4" } miden-note-transport-proto-build = { default-features = false, version = "0.2" } -miden-remote-prover-client = { default-features = false, features = ["tx-prover"], version = "=0.14.0-alpha.4" } +miden-remote-prover-client = { default-features = false, features = ["tx-prover"], path = "../node/crates/remote-prover-client" } + +# Miden debug dependency +miden-debug = { default-features = false, features = ["dap", "std"], path = "../miden-debug" } # External dependencies anyhow = { default-features = false, version = "1.0" } @@ -76,3 +79,9 @@ module_name_repetitions = "allow" # Many triggers, and is a stylistic choice must_use_candidate = "allow" # This marks many fn's which isn't helpful. should_panic_without_expect = "allow" # We don't care about the specific panic message. # End of pedantic lints. + +[patch.crates-io] +miden-protocol = { path = "../protocol/crates/miden-protocol" } +miden-standards = { path = "../protocol/crates/miden-standards" } +miden-testing = { path = "../protocol/crates/miden-testing" } +miden-tx = { path = "../protocol/crates/miden-tx" } diff --git a/bin/miden-cli/Cargo.toml b/bin/miden-cli/Cargo.toml index 6958911ede..59398e3e8a 100644 --- a/bin/miden-cli/Cargo.toml +++ b/bin/miden-cli/Cargo.toml @@ -16,10 +16,14 @@ version.workspace = true name = "miden-client" path = "src/main.rs" +[features] +dap = ["miden-client/dap", "dep:miden-debug"] + [dependencies] # Workspace dependencies miden-client = { features = ["tonic"], workspace = true } miden-client-sqlite-store = { workspace = true } +miden-debug = { optional = true, workspace = true } # External dependencies clap = { features = ["derive"], version = "4.5" } diff --git a/bin/miden-cli/src/commands/account.rs b/bin/miden-cli/src/commands/account.rs index f0e7cfe426..5a0b934f36 100644 --- a/bin/miden-cli/src/commands/account.rs +++ b/bin/miden-cli/src/commands/account.rs @@ -115,7 +115,7 @@ async fn list_accounts(client: Client) -> Result<(), CliError> { acc.id().to_hex(), account_type_display_name(&acc.id())?, acc.id().storage_mode().to_string(), - acc.nonce().as_int().to_string(), + acc.nonce().as_canonical_u64().to_string(), status, ]); } @@ -172,11 +172,7 @@ pub async fn show_account( }, Asset::NonFungible(non_fungible_asset) => { // TODO: Display non-fungible assets more clearly. - ( - "Non Fungible Asset", - non_fungible_asset.faucet_id_prefix().to_hex(), - 1.0.to_string(), - ) + ("Non Fungible Asset", non_fungible_asset.faucet_id().to_hex(), 1.0.to_string()) }, }; table.add_row(vec![asset_type, &faucet, &amount.clone()]); @@ -263,7 +259,10 @@ async fn print_summary_table( Cell::new("Storage Root"), Cell::new(account.storage().to_commitment().to_string()), ]); - table.add_row(vec![Cell::new("Nonce"), Cell::new(account.nonce().as_int().to_string())]); + table.add_row(vec![ + Cell::new("Nonce"), + Cell::new(account.nonce().as_canonical_u64().to_string()), + ]); println!("{table}\n"); Ok(()) diff --git a/bin/miden-cli/src/commands/exec.rs b/bin/miden-cli/src/commands/exec.rs index 6d55beef01..c38efe8e70 100644 --- a/bin/miden-cli/src/commands/exec.rs +++ b/bin/miden-cli/src/commands/exec.rs @@ -47,6 +47,12 @@ pub struct ExecCmd { /// Print the output stack grouped into words #[arg(long, default_value_t = false)] hex_words: bool, + + /// Start a DAP debug adapter server on the given address (e.g. "127.0.0.1:4711") + /// and wait for a DAP client to connect before executing. + #[cfg(feature = "dap")] + #[arg(long = "start-debug-adapter")] + start_debug_adapter: Option, } impl ExecCmd { @@ -87,6 +93,21 @@ impl ExecCmd { let tx_script = client.code_builder().compile_tx_script(&program)?; + #[cfg(feature = "dap")] + let result = if let Some(ref addr) = self.start_debug_adapter { + miden_debug::DapConfig::set_global(miden_debug::DapConfig { + listen_addr: addr.clone(), + }); + client + .execute_program_with_dap(account_id, tx_script, advice_inputs, BTreeSet::new()) + .await + } else { + client + .execute_program(account_id, tx_script, advice_inputs, BTreeSet::new()) + .await + }; + + #[cfg(not(feature = "dap"))] let result = client .execute_program(account_id, tx_script, advice_inputs, BTreeSet::new()) .await; diff --git a/bin/miden-cli/src/commands/new_account.rs b/bin/miden-cli/src/commands/new_account.rs index e98d6d9302..ce08f5f95e 100644 --- a/bin/miden-cli/src/commands/new_account.rs +++ b/bin/miden-cli/src/commands/new_account.rs @@ -96,6 +96,9 @@ pub struct NewWalletCmd { /// authentication transaction. #[arg(long, default_value_t = false)] pub deploy: bool, + /// Seed local-only state so the wallet can be created and used for execution without a node. + #[arg(long, default_value_t = false)] + pub offline: bool, } impl NewWalletCmd { @@ -124,6 +127,7 @@ impl NewWalletCmd { &package_paths, self.init_storage_data_path.clone(), self.deploy, + self.offline, ) .await?; @@ -191,6 +195,9 @@ pub struct NewAccountCmd { /// authentication transaction. #[arg(long, default_value_t = false)] pub deploy: bool, + /// Seed local-only state so the account can be created and used for execution without a node. + #[arg(long, default_value_t = false)] + pub offline: bool, } impl NewAccountCmd { @@ -207,6 +214,7 @@ impl NewAccountCmd { &self.packages, self.init_storage_data_path.clone(), self.deploy, + self.offline, ) .await?; @@ -354,6 +362,7 @@ async fn create_client_account( package_paths: &[PathBuf], init_storage_data_path: Option, deploy: bool, + offline: bool, ) -> Result { if package_paths.is_empty() { return Err(CliError::InvalidArgument(format!( @@ -362,6 +371,12 @@ async fn create_client_account( ", client_binary_name().display()))); } + if deploy && offline { + return Err(CliError::InvalidArgument( + "`--offline` cannot be combined with `--deploy`".to_string(), + )); + } + // Load the component templates and initialization storage data. let cli_config = CliConfig::load()?; @@ -390,10 +405,10 @@ async fn create_client_account( None } else { debug!("Adding default Falcon auth component"); - let kp = AuthSecretKey::new_falcon512_rpo_with_rng(client.rng()); + let kp = AuthSecretKey::new_falcon512_poseidon2_with_rng(client.rng()); builder = builder.with_auth_component(AuthSingleSig::new( kp.public_key().to_commitment(), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )); Some(kp) }; @@ -416,6 +431,11 @@ async fn create_client_account( println!("Using custom authentication component from package (no key generated)."); } + if offline { + client.prepare_offline_bootstrap().await?; + println!("Offline mode seeded default RPC limits and a synthetic genesis header."); + } + client.add_account(&account, false).await?; if deploy { diff --git a/bin/miden-cli/src/commands/new_transactions.rs b/bin/miden-cli/src/commands/new_transactions.rs index 761eae2a7d..21aa5fd20b 100644 --- a/bin/miden-cli/src/commands/new_transactions.rs +++ b/bin/miden-cli/src/commands/new_transactions.rs @@ -15,7 +15,6 @@ use miden_client::store::NoteRecordError; use miden_client::transaction::{ ExecutedTransaction, InputNote, - OutputNote, PaymentNoteDescription, SwapTransactionData, TransactionRequest, @@ -401,7 +400,7 @@ async fn execute_transaction( let output_notes = executed_transaction .output_notes() .iter() - .map(OutputNote::id) + .map(miden_client::transaction::RawOutputNote::id) .collect::>(); println!("Proving transaction..."); @@ -514,18 +513,10 @@ fn print_transaction_details(executed_tx: &ExecutedTransaction) -> Result<(), Cl for (asset, action) in account_delta.vault().non_fungible().iter() { match action { NonFungibleDeltaAction::Add => { - table.add_row(vec![ - "Non Fungible Asset", - &asset.faucet_id_prefix().to_hex(), - "1", - ]); + table.add_row(vec!["Non Fungible Asset", &asset.faucet_id().to_hex(), "1"]); }, NonFungibleDeltaAction::Remove => { - table.add_row(vec![ - "Non Fungible Asset", - &asset.faucet_id_prefix().to_hex(), - "-1", - ]); + table.add_row(vec!["Non Fungible Asset", &asset.faucet_id().to_hex(), "-1"]); }, } } diff --git a/bin/miden-cli/src/commands/notes.rs b/bin/miden-cli/src/commands/notes.rs index 2653fde989..415908fd7c 100644 --- a/bin/miden-cli/src/commands/notes.rs +++ b/bin/miden-cli/src/commands/notes.rs @@ -267,11 +267,9 @@ async fn show_note( let (faucet, amount) = faucet_details_map.format_fungible_asset(fungible_asset)?; ("Fungible Asset", faucet, amount) }, - Asset::NonFungible(non_fungible_asset) => ( - "Non Fungible Asset", - non_fungible_asset.faucet_id_prefix().to_hex(), - 1.0.to_string(), - ), + Asset::NonFungible(non_fungible_asset) => { + ("Non Fungible Asset", non_fungible_asset.faucet_id().to_hex(), 1.0.to_string()) + }, }; table.add_row(vec![asset_type, &faucet, &amount.clone()]); } diff --git a/bin/miden-cli/tests/cli.rs b/bin/miden-cli/tests/cli.rs index 579cdbb978..36e9802f8f 100644 --- a/bin/miden-cli/tests/cli.rs +++ b/bin/miden-cli/tests/cli.rs @@ -33,7 +33,7 @@ use miden_client::testing::common::{ execute_tx_and_sync, insert_new_wallet, }; -use miden_client::transaction::{OutputNote, TransactionRequestBuilder}; +use miden_client::transaction::{RawOutputNote, TransactionRequestBuilder}; use miden_client::utils::Serializable; use miden_client::{self, Client, DebugMode, Felt}; use miden_client_cli::MIDEN_DIR; @@ -714,7 +714,7 @@ async fn debug_mode_outputs_logs() -> Result<()> { // Send transaction and wait for it to be committed client.sync_state().await?; let transaction_request = TransactionRequestBuilder::new() - .own_output_notes(vec![OutputNote::Full(note.clone())]) + .own_output_notes(vec![RawOutputNote::Full(note.clone())]) .build()?; execute_tx_and_sync(&mut client, account.id(), transaction_request).await?; @@ -906,7 +906,7 @@ async fn new_wallet_with_deploy_flag() -> Result<()> { // Verify that the nonce is non-zero (account was deployed) // By convention, a nonce of 0 indicates an undeployed account assert!( - nonce.as_int() > 0, + nonce.as_canonical_u64() > 0, "Account nonce should be non-zero after deployment, but got: {nonce}" ); @@ -1320,7 +1320,7 @@ fn create_account_with_acl_auth() { // Create init storage data file for acl-auth with a test public key let init_storage_data_toml = r#" "miden::standards::auth::singlesig_acl::pub_key" = "0x0000000000000000000000000000000000000000000000000000000000000001" - "miden::standards::auth::singlesig_acl::scheme" = "Falcon512Rpo" + "miden::standards::auth::singlesig_acl::scheme" = "Falcon512Poseidon2" "miden::standards::auth::singlesig_acl::config.num_tracked_procs" = "1" "miden::standards::auth::singlesig_acl::config.allow_unauthorized_output_notes" = "0" "miden::standards::auth::singlesig_acl::config.allow_unauthorized_input_notes" = "0" diff --git a/crates/rust-client/Cargo.toml b/crates/rust-client/Cargo.toml index ba205cf2f3..9271f1d9c4 100644 --- a/crates/rust-client/Cargo.toml +++ b/crates/rust-client/Cargo.toml @@ -35,11 +35,12 @@ std = [ "tonic/transport", ] testing = ["dep:miden-testing", "dep:uuid", "miden-protocol/testing", "miden-standards/testing", "miden-tx/testing"] +dap = ["dep:miden-debug"] tonic = [] [dependencies] # Miden dependencies -miden-mast-package = { default-features = false, version = "0.20" } +miden-debug = { optional = true, workspace = true } miden-protocol = { workspace = true } miden-remote-prover-client = { default-features = false, features = ["tx-prover"], workspace = true } miden-standards = { workspace = true } diff --git a/crates/rust-client/src/account/account_reader.rs b/crates/rust-client/src/account/account_reader.rs index 17198cebbd..85ae3a12eb 100644 --- a/crates/rust-client/src/account/account_reader.rs +++ b/crates/rust-client/src/account/account_reader.rs @@ -119,7 +119,7 @@ impl AccountReader { /// To load the entire vault, use /// [`Client::get_account_vault`](crate::Client::get_account_vault). pub async fn get_balance(&self, faucet_id: AccountId) -> Result { - if let Some(vault_key) = AssetVaultKey::from_account_id(faucet_id) + if let Some(vault_key) = AssetVaultKey::new_fungible(faucet_id) && let Some((Asset::Fungible(fungible_asset), _)) = self.store.get_account_asset(self.account_id, vault_key).await? { diff --git a/crates/rust-client/src/account/mod.rs b/crates/rust-client/src/account/mod.rs index 61ed7e96f1..7fbf786fa8 100644 --- a/crates/rust-client/src/account/mod.rs +++ b/crates/rust-client/src/account/mod.rs @@ -189,7 +189,7 @@ impl Client { return Err(ClientError::AccountAlreadyTracked(account.id())); } - if tracked_account.nonce().as_int() > account.nonce().as_int() { + if tracked_account.nonce().as_canonical_u64() > account.nonce().as_canonical_u64() { // If the new account is older than the one being tracked, return an error return Err(ClientError::AccountNonceTooLow); } @@ -422,9 +422,10 @@ pub fn build_wallet_id( let auth_scheme = public_key.auth_scheme(); let auth_component = match auth_scheme { - AuthSchemeId::Falcon512Rpo => { + AuthSchemeId::Falcon512Poseidon2 => { let auth_component: AccountComponent = - AuthSingleSig::new(public_key.to_commitment(), AuthSchemeId::Falcon512Rpo).into(); + AuthSingleSig::new(public_key.to_commitment(), AuthSchemeId::Falcon512Poseidon2) + .into(); auth_component }, AuthSchemeId::EcdsaK256Keccak => { diff --git a/crates/rust-client/src/builder.rs b/crates/rust-client/src/builder.rs index 030080e2ca..7278d5ab14 100644 --- a/crates/rust-client/src/builder.rs +++ b/crates/rust-client/src/builder.rs @@ -468,6 +468,7 @@ where exec_options: ExecutionOptions::new( Some(MAX_TX_EXECUTION_CYCLES), MIN_TX_EXECUTION_CYCLES, + ExecutionOptions::DEFAULT_CORE_TRACE_FRAGMENT_SIZE, false, self.in_debug_mode.into(), ) diff --git a/crates/rust-client/src/errors.rs b/crates/rust-client/src/errors.rs index b463912a29..fd2cdf4c1c 100644 --- a/crates/rust-client/src/errors.rs +++ b/crates/rust-client/src/errors.rs @@ -18,7 +18,8 @@ use miden_standards::account::interface::AccountInterfaceError; // ================================================================================================ pub use miden_standards::errors::CodeBuilderError; pub use miden_tx::AuthenticationError; -use miden_tx::utils::{DeserializationError, HexParseError}; +use miden_tx::utils::HexParseError; +use miden_tx::utils::serde::DeserializationError; use miden_tx::{NoteCheckerError, TransactionExecutorError, TransactionProverError}; use thiserror::Error; diff --git a/crates/rust-client/src/keystore/fs_keystore.rs b/crates/rust-client/src/keystore/fs_keystore.rs index ae21d52eab..585f4ef91e 100644 --- a/crates/rust-client/src/keystore/fs_keystore.rs +++ b/crates/rust-client/src/keystore/fs_keystore.rs @@ -13,8 +13,8 @@ use miden_protocol::account::AccountId; use miden_protocol::account::auth::{AuthSecretKey, PublicKey, PublicKeyCommitment, Signature}; use miden_tx::AuthenticationError; use miden_tx::auth::{SigningInputs, TransactionAuthenticator}; +use miden_tx::utils::serde::{Deserializable, Serializable}; use miden_tx::utils::sync::RwLock; -use miden_tx::utils::{Deserializable, Serializable}; use serde::{Deserialize, Serialize}; use super::{KeyStoreError, Keystore}; diff --git a/crates/rust-client/src/lib.rs b/crates/rust-client/src/lib.rs index 0913448c1a..dff7ff9cc2 100644 --- a/crates/rust-client/src/lib.rs +++ b/crates/rust-client/src/lib.rs @@ -135,7 +135,7 @@ mod test_utils; pub mod errors; -pub use miden_protocol::utils::{Deserializable, Serializable, SliceReader}; +pub use miden_protocol::utils::serde::{Deserializable, Serializable, SliceReader}; // RE-EXPORTS // ================================================================================================ @@ -212,7 +212,7 @@ pub mod auth { pub use crate::account::component::AuthScheme; - pub const RPO_FALCON_SCHEME_ID: AuthSchemeId = AuthSchemeId::Falcon512Rpo; + pub const RPO_FALCON_SCHEME_ID: AuthSchemeId = AuthSchemeId::Falcon512Poseidon2; pub const ECDSA_K256_KECCAK_SCHEME_ID: AuthSchemeId = AuthSchemeId::EcdsaK256Keccak; } @@ -226,9 +226,13 @@ pub mod block { /// the `miden_standards` crate. pub mod crypto { pub mod rpo_falcon512 { - pub use miden_protocol::crypto::dsa::falcon512_rpo::{PublicKey, SecretKey, Signature}; + pub use miden_protocol::crypto::dsa::falcon512_poseidon2::{ + PublicKey, + SecretKey, + Signature, + }; } - pub use miden_protocol::crypto::hash::blake::{Blake3_160, Blake3Digest}; + pub use miden_protocol::crypto::hash::blake::{Blake3_192, Blake3Digest}; pub use miden_protocol::crypto::hash::rpo::Rpo256; pub use miden_protocol::crypto::merkle::mmr::{ Forest, @@ -272,8 +276,6 @@ pub mod address { /// Provides types for working with the virtual machine within the Miden network. pub mod vm { - // TODO: Remove this re-export once miden-protocol exposes PackageKind/ProcedureExport. - pub use miden_mast_package::{PackageKind, ProcedureExport}; pub use miden_protocol::vm::{ AdviceInputs, AdviceMap, @@ -281,7 +283,9 @@ pub mod vm { MastArtifact, Package, PackageExport, + PackageKind, PackageManifest, + ProcedureExport, Program, QualifiedProcedureName, Section, @@ -299,7 +303,6 @@ pub use miden_protocol::{ MIN_TX_EXECUTION_CYCLES, ONE, PrettyPrint, - StarkField, Word, ZERO, }; diff --git a/crates/rust-client/src/note_transport/errors.rs b/crates/rust-client/src/note_transport/errors.rs index 147e131bc8..7b2c8e7d6d 100644 --- a/crates/rust-client/src/note_transport/errors.rs +++ b/crates/rust-client/src/note_transport/errors.rs @@ -2,7 +2,7 @@ use alloc::boxed::Box; use alloc::string::String; use core::error::Error; -use miden_protocol::utils::DeserializationError; +use miden_protocol::utils::serde::DeserializationError; use thiserror::Error; #[derive(Debug, Error)] diff --git a/crates/rust-client/src/note_transport/grpc.rs b/crates/rust-client/src/note_transport/grpc.rs index e6eaaa9926..123c1d297b 100644 --- a/crates/rust-client/src/note_transport/grpc.rs +++ b/crates/rust-client/src/note_transport/grpc.rs @@ -6,7 +6,7 @@ use core::task::{Context, Poll}; use futures::Stream; use miden_protocol::note::{NoteHeader, NoteTag}; -use miden_protocol::utils::{Deserializable, Serializable}; +use miden_protocol::utils::serde::{Deserializable, Serializable}; use miden_tx::utils::sync::RwLock; use tonic::{Request, Streaming}; use tonic_health::pb::HealthCheckRequest; diff --git a/crates/rust-client/src/note_transport/mod.rs b/crates/rust-client/src/note_transport/mod.rs index f2ee091623..89d60d705c 100644 --- a/crates/rust-client/src/note_transport/mod.rs +++ b/crates/rust-client/src/note_transport/mod.rs @@ -10,9 +10,15 @@ use alloc::vec::Vec; use futures::Stream; use miden_protocol::address::Address; use miden_protocol::note::{Note, NoteDetails, NoteFile, NoteHeader, NoteTag}; -use miden_protocol::utils::Serializable; +use miden_protocol::utils::serde::Serializable; use miden_tx::auth::TransactionAuthenticator; -use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, SliceReader}; +use miden_tx::utils::serde::{ + ByteReader, + ByteWriter, + Deserializable, + DeserializationError, + SliceReader, +}; pub use self::errors::NoteTransportError; use crate::{Client, ClientError}; diff --git a/crates/rust-client/src/rpc/domain/account.rs b/crates/rust-client/src/rpc/domain/account.rs index 76146c772a..e4f5db5bd9 100644 --- a/crates/rust-client/src/rpc/domain/account.rs +++ b/crates/rust-client/src/rpc/domain/account.rs @@ -22,7 +22,8 @@ use miden_protocol::block::BlockNumber; use miden_protocol::block::account_tree::AccountWitness; use miden_protocol::crypto::merkle::SparseMerklePath; use miden_protocol::crypto::merkle::smt::SmtProof; -use miden_tx::utils::{Deserializable, Serializable, ToHex}; +use miden_tx::utils::ToHex; +use miden_tx::utils::serde::{Deserializable, Serializable}; use thiserror::Error; use crate::alloc::borrow::ToOwned; @@ -487,15 +488,7 @@ impl TryFrom for AccountVaultDetails { let assets = value .assets .into_iter() - .map(|asset| { - let native_digest: Word = asset - .asset - .ok_or(proto::rpc::AccountVaultDetails::missing_field(stringify!(assets)))? - .try_into()?; - native_digest - .try_into() - .map_err(|_| RpcError::DeserializationError("asset".to_string())) - }) + .map(TryInto::try_into) .collect::, RpcError>>()?; Ok(Self { too_many_assets, assets }) @@ -686,15 +679,15 @@ impl From for Vec(&self, target: &mut W) { + fn write_into(&self, target: &mut W) { target.write(&self.0); } } impl Deserializable for AccountStorageRequirements { - fn read_from( + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { Ok(AccountStorageRequirements(source.read()?)) } } diff --git a/crates/rust-client/src/rpc/domain/account_vault.rs b/crates/rust-client/src/rpc/domain/account_vault.rs index 40f11e5f6e..e3605a5143 100644 --- a/crates/rust-client/src/rpc/domain/account_vault.rs +++ b/crates/rust-client/src/rpc/domain/account_vault.rs @@ -4,7 +4,6 @@ use alloc::vec::Vec; use miden_protocol::Word; use miden_protocol::asset::{Asset, AssetVaultKey}; use miden_protocol::block::BlockNumber; -use miden_protocol::errors::AssetError; use crate::rpc::domain::MissingFieldHelper; use crate::rpc::{RpcError, generated as proto}; @@ -74,12 +73,17 @@ impl TryFrom for Asset { type Error = RpcError; fn try_from(value: proto::primitives::Asset) -> Result { - let word: Word = value - .asset - .ok_or(proto::rpc::SyncAccountVaultResponse::missing_field(stringify!(asset)))? + let key: Word = value + .key + .ok_or(proto::rpc::SyncAccountVaultResponse::missing_field(stringify!(key)))? .try_into()?; - word.try_into() - .map_err(|e: AssetError| RpcError::InvalidResponse(e.to_string())) + let value: Word = value + .value + .ok_or(proto::rpc::SyncAccountVaultResponse::missing_field(stringify!(value)))? + .try_into()?; + + Asset::from_key_value_words(key, value) + .map_err(|e| RpcError::InvalidResponse(e.to_string())) } } @@ -95,7 +99,8 @@ impl TryFrom for AccountVaultUpdate { .vault_key .ok_or(proto::rpc::SyncAccountVaultResponse::missing_field(stringify!(vault_key)))? .try_into()?; - let vault_key = AssetVaultKey::new_unchecked(vault_key_inner); + let vault_key = AssetVaultKey::try_from(vault_key_inner) + .map_err(|e| RpcError::InvalidResponse(e.to_string()))?; Ok(Self { block_num: block_num.into(), diff --git a/crates/rust-client/src/rpc/domain/block.rs b/crates/rust-client/src/rpc/domain/block.rs index 9059ee7c08..fcb109536c 100644 --- a/crates/rust-client/src/rpc/domain/block.rs +++ b/crates/rust-client/src/rpc/domain/block.rs @@ -1,6 +1,6 @@ use miden_protocol::block::{BlockHeader, BlockNumber, FeeParameters}; use miden_protocol::crypto::dsa::ecdsa_k256_keccak; -use miden_protocol::utils::{Deserializable, Serializable}; +use miden_protocol::utils::serde::{Deserializable, Serializable}; use crate::rpc::domain::MissingFieldHelper; use crate::rpc::errors::RpcConversionError; diff --git a/crates/rust-client/src/rpc/domain/digest.rs b/crates/rust-client/src/rpc/domain/digest.rs index b05e3f04cb..dd0cb2f8a7 100644 --- a/crates/rust-client/src/rpc/domain/digest.rs +++ b/crates/rust-client/src/rpc/domain/digest.rs @@ -4,7 +4,7 @@ use core::fmt::{self, Debug, Display, Formatter}; use hex::ToHex; use miden_protocol::account::StorageMapKey; use miden_protocol::note::NoteId; -use miden_protocol::{Felt, StarkField, Word}; +use miden_protocol::{Felt, Word}; use crate::rpc::errors::RpcConversionError; use crate::rpc::generated as proto; @@ -62,10 +62,10 @@ impl ToHex for proto::primitives::Digest { impl From for proto::primitives::Digest { fn from(value: Word) -> Self { Self { - d0: value[0].as_int(), - d1: value[1].as_int(), - d2: value[2].as_int(), - d3: value[3].as_int(), + d0: value[0].as_canonical_u64(), + d1: value[1].as_canonical_u64(), + d2: value[2].as_canonical_u64(), + d3: value[3].as_canonical_u64(), } } } @@ -95,10 +95,7 @@ impl TryFrom for [Felt; 4] { type Error = RpcConversionError; fn try_from(value: proto::primitives::Digest) -> Result { - if [value.d0, value.d1, value.d2, value.d3] - .iter() - .all(|v| *v < ::MODULUS) - { + if [value.d0, value.d1, value.d2, value.d3].iter().all(|v| *v < Felt::ORDER) { Ok([ Felt::new(value.d0), Felt::new(value.d1), diff --git a/crates/rust-client/src/rpc/domain/limits.rs b/crates/rust-client/src/rpc/domain/limits.rs index 22d4c81946..e00416f0aa 100644 --- a/crates/rust-client/src/rpc/domain/limits.rs +++ b/crates/rust-client/src/rpc/domain/limits.rs @@ -3,7 +3,13 @@ use core::convert::TryFrom; -use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; +use miden_tx::utils::serde::{ + ByteReader, + ByteWriter, + Deserializable, + DeserializationError, + Serializable, +}; use crate::rpc::RpcEndpoint; use crate::rpc::errors::RpcConversionError; diff --git a/crates/rust-client/src/rpc/domain/note.rs b/crates/rust-client/src/rpc/domain/note.rs index 587560b39f..882034c607 100644 --- a/crates/rust-client/src/rpc/domain/note.rs +++ b/crates/rust-client/src/rpc/domain/note.rs @@ -15,7 +15,7 @@ use miden_protocol::note::{ NoteType, }; use miden_protocol::{MastForest, MastNodeId, Word}; -use miden_tx::utils::Deserializable; +use miden_tx::utils::serde::Deserializable; use super::{MissingFieldHelper, RpcConversionError}; use crate::rpc::{RpcError, generated as proto}; @@ -62,7 +62,7 @@ impl TryFrom for NoteMetadata { impl From for proto::note::NoteMetadata { fn from(value: NoteMetadata) -> Self { - use miden_tx::utils::Serializable; + use miden_tx::utils::serde::Serializable; proto::note::NoteMetadata { sender: Some(value.sender().into()), note_type: value.note_type() as i32, diff --git a/crates/rust-client/src/rpc/errors/mod.rs b/crates/rust-client/src/rpc/errors/mod.rs index a01ca2808d..82f8880e9b 100644 --- a/crates/rust-client/src/rpc/errors/mod.rs +++ b/crates/rust-client/src/rpc/errors/mod.rs @@ -8,7 +8,7 @@ use miden_protocol::account::AccountId; use miden_protocol::crypto::merkle::MerkleError; use miden_protocol::errors::NoteError; use miden_protocol::note::NoteId; -use miden_protocol::utils::DeserializationError; +use miden_protocol::utils::serde::DeserializationError; use thiserror::Error; use super::RpcEndpoint; diff --git a/crates/rust-client/src/rpc/mod.rs b/crates/rust-client/src/rpc/mod.rs index 93c8e72eb1..64d03fd37e 100644 --- a/crates/rust-client/src/rpc/mod.rs +++ b/crates/rust-client/src/rpc/mod.rs @@ -300,7 +300,7 @@ pub trait NodeRpcClient: Send + Sync { if let FetchedAccount::Public(account, _) = response { let account = *account; // We should only return an account if it's newer, otherwise we ignore it - if account.nonce().as_int() > local_account.nonce().as_int() { + if account.nonce().as_canonical_u64() > local_account.nonce().as_canonical_u64() { public_accounts.push(account); } } diff --git a/crates/rust-client/src/rpc/tonic_client/mod.rs b/crates/rust-client/src/rpc/tonic_client/mod.rs index 60aee4f72e..ff230b0a0a 100644 --- a/crates/rust-client/src/rpc/tonic_client/mod.rs +++ b/crates/rust-client/src/rpc/tonic_client/mod.rs @@ -13,13 +13,13 @@ use miden_protocol::address::NetworkId; use miden_protocol::block::account_tree::AccountWitness; use miden_protocol::block::{BlockHeader, BlockNumber, ProvenBlock}; use miden_protocol::crypto::merkle::MerklePath; -use miden_protocol::crypto::merkle::mmr::{Forest, MmrProof}; +use miden_protocol::crypto::merkle::mmr::{Forest, MmrPath, MmrProof}; use miden_protocol::crypto::merkle::smt::SmtProof; use miden_protocol::note::{NoteId, NoteScript, NoteTag, Nullifier}; use miden_protocol::transaction::{ProvenTransaction, TransactionInputs}; -use miden_protocol::utils::Deserializable; +use miden_protocol::utils::serde::Deserializable; use miden_protocol::{EMPTY_WORD, Word}; -use miden_tx::utils::Serializable; +use miden_tx::utils::serde::Serializable; use miden_tx::utils::sync::RwLock; use tonic::Status; use tracing::info; @@ -447,11 +447,14 @@ impl NodeRpcClient for GrpcClient { .ok_or(RpcError::ExpectedDataMissing("MmrPath".into()))? .try_into()?; - Some(MmrProof { - forest: Forest::new(usize::try_from(forest).expect("u64 should fit in usize")), - position: block_header.block_num().as_usize(), - merkle_path, - }) + Some(MmrProof::new( + MmrPath::new( + Forest::new(usize::try_from(forest).expect("u64 should fit in usize")), + block_header.block_num().as_usize(), + merkle_path, + ), + block_header.commitment(), + )) } else { None }; diff --git a/crates/rust-client/src/settings/mod.rs b/crates/rust-client/src/settings/mod.rs index e75fd3c91f..2b16454144 100644 --- a/crates/rust-client/src/settings/mod.rs +++ b/crates/rust-client/src/settings/mod.rs @@ -4,7 +4,7 @@ use alloc::string::String; use alloc::vec::Vec; -use miden_tx::utils::{Deserializable, Serializable}; +use miden_tx::utils::serde::{Deserializable, Serializable}; use super::Client; use crate::errors::ClientError; diff --git a/crates/rust-client/src/store/errors.rs b/crates/rust-client/src/store/errors.rs index 7c9ffac934..f60f144316 100644 --- a/crates/rust-client/src/store/errors.rs +++ b/crates/rust-client/src/store/errors.rs @@ -16,7 +16,8 @@ use miden_protocol::errors::{ StorageMapError, TransactionScriptError, }; -use miden_protocol::utils::{DeserializationError, HexParseError}; +use miden_protocol::utils::HexParseError; +use miden_protocol::utils::serde::DeserializationError; use miden_protocol::{Word, WordError}; use miden_tx::DataStoreError; use thiserror::Error; diff --git a/crates/rust-client/src/store/mod.rs b/crates/rust-client/src/store/mod.rs index 210a8f47d1..104be6621a 100644 --- a/crates/rust-client/src/store/mod.rs +++ b/crates/rust-client/src/store/mod.rs @@ -46,7 +46,7 @@ use miden_protocol::crypto::merkle::mmr::{Forest, InOrderIndex, MmrPeaks, Partia use miden_protocol::errors::AccountError; use miden_protocol::note::{NoteId, NoteScript, NoteTag, Nullifier}; use miden_protocol::transaction::TransactionId; -use miden_tx::utils::{Deserializable, Serializable}; +use miden_tx::utils::serde::{Deserializable, Serializable}; use crate::note_transport::{NOTE_TRANSPORT_CURSOR_STORE_SETTING, NoteTransportCursor}; use crate::rpc::{RPC_LIMITS_STORE_SETTING, RpcLimits}; diff --git a/crates/rust-client/src/store/note_record/input_note_record/mod.rs b/crates/rust-client/src/store/note_record/input_note_record/mod.rs index 88ce76bb91..07eee62b15 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/mod.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/mod.rs @@ -14,7 +14,7 @@ use miden_protocol::note::{ Nullifier, }; use miden_protocol::transaction::{InputNote, TransactionId}; -use miden_protocol::utils::{ +use miden_protocol::utils::serde::{ ByteReader, ByteWriter, Deserializable, diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/committed.rs b/crates/rust-client/src/store/note_record/input_note_record/states/committed.rs index 1cdb0dbea3..a70b2da0ce 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/committed.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/committed.rs @@ -106,18 +106,18 @@ impl NoteStateHandler for CommittedNoteState { } } -impl miden_tx::utils::Serializable for CommittedNoteState { - fn write_into(&self, target: &mut W) { +impl miden_tx::utils::serde::Serializable for CommittedNoteState { + fn write_into(&self, target: &mut W) { self.metadata.write_into(target); self.inclusion_proof.write_into(target); self.block_note_root.write_into(target); } } -impl miden_tx::utils::Deserializable for CommittedNoteState { - fn read_from( +impl miden_tx::utils::serde::Deserializable for CommittedNoteState { + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let metadata = NoteMetadata::read_from(source)?; let inclusion_proof = NoteInclusionProof::read_from(source)?; let block_note_root = Word::read_from(source)?; diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/consumed_authenticated_local.rs b/crates/rust-client/src/store/note_record/input_note_record/states/consumed_authenticated_local.rs index 5f9723a69f..0e9caf1c5e 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/consumed_authenticated_local.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/consumed_authenticated_local.rs @@ -80,8 +80,8 @@ impl NoteStateHandler for ConsumedAuthenticatedLocalNoteState { } } -impl miden_tx::utils::Serializable for ConsumedAuthenticatedLocalNoteState { - fn write_into(&self, target: &mut W) { +impl miden_tx::utils::serde::Serializable for ConsumedAuthenticatedLocalNoteState { + fn write_into(&self, target: &mut W) { self.metadata.write_into(target); self.inclusion_proof.write_into(target); self.block_note_root.write_into(target); @@ -90,10 +90,10 @@ impl miden_tx::utils::Serializable for ConsumedAuthenticatedLocalNoteState { } } -impl miden_tx::utils::Deserializable for ConsumedAuthenticatedLocalNoteState { - fn read_from( +impl miden_tx::utils::serde::Deserializable for ConsumedAuthenticatedLocalNoteState { + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let metadata = NoteMetadata::read_from(source)?; let inclusion_proof = NoteInclusionProof::read_from(source)?; let block_note_root = Word::read_from(source)?; diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/consumed_external.rs b/crates/rust-client/src/store/note_record/input_note_record/states/consumed_external.rs index 3bd108aeac..8d145f7d0c 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/consumed_external.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/consumed_external.rs @@ -70,16 +70,16 @@ impl NoteStateHandler for ConsumedExternalNoteState { } } -impl miden_tx::utils::Serializable for ConsumedExternalNoteState { - fn write_into(&self, target: &mut W) { +impl miden_tx::utils::serde::Serializable for ConsumedExternalNoteState { + fn write_into(&self, target: &mut W) { self.nullifier_block_height.write_into(target); } } -impl miden_tx::utils::Deserializable for ConsumedExternalNoteState { - fn read_from( +impl miden_tx::utils::serde::Deserializable for ConsumedExternalNoteState { + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let nullifier_block_height = BlockNumber::read_from(source)?; Ok(ConsumedExternalNoteState { nullifier_block_height }) } diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/consumed_unauthenticated_local.rs b/crates/rust-client/src/store/note_record/input_note_record/states/consumed_unauthenticated_local.rs index 35e2413061..e97f0bccf2 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/consumed_unauthenticated_local.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/consumed_unauthenticated_local.rs @@ -75,18 +75,18 @@ impl NoteStateHandler for ConsumedUnauthenticatedLocalNoteState { } } -impl miden_tx::utils::Serializable for ConsumedUnauthenticatedLocalNoteState { - fn write_into(&self, target: &mut W) { +impl miden_tx::utils::serde::Serializable for ConsumedUnauthenticatedLocalNoteState { + fn write_into(&self, target: &mut W) { self.metadata.write_into(target); self.nullifier_block_height.write_into(target); self.submission_data.write_into(target); } } -impl miden_tx::utils::Deserializable for ConsumedUnauthenticatedLocalNoteState { - fn read_from( +impl miden_tx::utils::serde::Deserializable for ConsumedUnauthenticatedLocalNoteState { + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let metadata = NoteMetadata::read_from(source)?; let nullifier_block_height = BlockNumber::read_from(source)?; let submission_data = NoteSubmissionData::read_from(source)?; diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/expected.rs b/crates/rust-client/src/store/note_record/input_note_record/states/expected.rs index 00ed45c899..3da5d855f3 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/expected.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/expected.rs @@ -107,18 +107,18 @@ impl NoteStateHandler for ExpectedNoteState { } } -impl miden_tx::utils::Serializable for ExpectedNoteState { - fn write_into(&self, target: &mut W) { +impl miden_tx::utils::serde::Serializable for ExpectedNoteState { + fn write_into(&self, target: &mut W) { self.metadata.write_into(target); self.after_block_num.write_into(target); self.tag.write_into(target); } } -impl miden_tx::utils::Deserializable for ExpectedNoteState { - fn read_from( +impl miden_tx::utils::serde::Deserializable for ExpectedNoteState { + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let metadata = Option::::read_from(source)?; let after_block_num = BlockNumber::read_from(source)?; let tag = Option::::read_from(source)?; diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/invalid.rs b/crates/rust-client/src/store/note_record/input_note_record/states/invalid.rs index a33b36399b..5c1c6478d7 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/invalid.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/invalid.rs @@ -102,18 +102,18 @@ impl NoteStateHandler for InvalidNoteState { } } -impl miden_tx::utils::Serializable for InvalidNoteState { - fn write_into(&self, target: &mut W) { +impl miden_tx::utils::serde::Serializable for InvalidNoteState { + fn write_into(&self, target: &mut W) { self.metadata.write_into(target); self.invalid_inclusion_proof.write_into(target); self.block_note_root.write_into(target); } } -impl miden_tx::utils::Deserializable for InvalidNoteState { - fn read_from( +impl miden_tx::utils::serde::Deserializable for InvalidNoteState { + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let metadata = NoteMetadata::read_from(source)?; let invalid_inclusion_proof = NoteInclusionProof::read_from(source)?; let block_note_root = Word::read_from(source)?; diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/mod.rs b/crates/rust-client/src/store/note_record/input_note_record/states/mod.rs index 1a37be9fe1..99f96ec97f 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/mod.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/mod.rs @@ -6,7 +6,7 @@ use miden_protocol::account::AccountId; use miden_protocol::block::{BlockHeader, BlockNumber}; use miden_protocol::note::{NoteId, NoteInclusionProof, NoteMetadata}; use miden_protocol::transaction::TransactionId; -pub use miden_tx::utils::{ +pub use miden_tx::utils::serde::{ ByteReader, ByteWriter, Deserializable, diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/processing_authenticated.rs b/crates/rust-client/src/store/note_record/input_note_record/states/processing_authenticated.rs index 4aff46c0e4..0178f3b4f6 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/processing_authenticated.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/processing_authenticated.rs @@ -103,8 +103,8 @@ impl NoteStateHandler for ProcessingAuthenticatedNoteState { } } -impl miden_tx::utils::Serializable for ProcessingAuthenticatedNoteState { - fn write_into(&self, target: &mut W) { +impl miden_tx::utils::serde::Serializable for ProcessingAuthenticatedNoteState { + fn write_into(&self, target: &mut W) { self.metadata.write_into(target); self.inclusion_proof.write_into(target); self.block_note_root.write_into(target); @@ -112,10 +112,10 @@ impl miden_tx::utils::Serializable for ProcessingAuthenticatedNoteState { } } -impl miden_tx::utils::Deserializable for ProcessingAuthenticatedNoteState { - fn read_from( +impl miden_tx::utils::serde::Deserializable for ProcessingAuthenticatedNoteState { + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let metadata = NoteMetadata::read_from(source)?; let inclusion_proof = NoteInclusionProof::read_from(source)?; let block_note_root = Word::read_from(source)?; diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/processing_unauthenticated.rs b/crates/rust-client/src/store/note_record/input_note_record/states/processing_unauthenticated.rs index f5b1fab7e0..072a374dd2 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/processing_unauthenticated.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/processing_unauthenticated.rs @@ -92,18 +92,18 @@ impl NoteStateHandler for ProcessingUnauthenticatedNoteState { } } -impl miden_tx::utils::Serializable for ProcessingUnauthenticatedNoteState { - fn write_into(&self, target: &mut W) { +impl miden_tx::utils::serde::Serializable for ProcessingUnauthenticatedNoteState { + fn write_into(&self, target: &mut W) { self.metadata.write_into(target); self.after_block_num.write_into(target); self.submission_data.write_into(target); } } -impl miden_tx::utils::Deserializable for ProcessingUnauthenticatedNoteState { - fn read_from( +impl miden_tx::utils::serde::Deserializable for ProcessingUnauthenticatedNoteState { + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let metadata = NoteMetadata::read_from(source)?; let after_block_num = BlockNumber::read_from(source)?; let submission_data = NoteSubmissionData::read_from(source)?; diff --git a/crates/rust-client/src/store/note_record/input_note_record/states/unverified.rs b/crates/rust-client/src/store/note_record/input_note_record/states/unverified.rs index 6b6ccd02a8..9417878468 100644 --- a/crates/rust-client/src/store/note_record/input_note_record/states/unverified.rs +++ b/crates/rust-client/src/store/note_record/input_note_record/states/unverified.rs @@ -123,17 +123,17 @@ impl NoteStateHandler for UnverifiedNoteState { } } -impl miden_tx::utils::Serializable for UnverifiedNoteState { - fn write_into(&self, target: &mut W) { +impl miden_tx::utils::serde::Serializable for UnverifiedNoteState { + fn write_into(&self, target: &mut W) { self.metadata.write_into(target); self.inclusion_proof.write_into(target); } } -impl miden_tx::utils::Deserializable for UnverifiedNoteState { - fn read_from( +impl miden_tx::utils::serde::Deserializable for UnverifiedNoteState { + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let metadata = NoteMetadata::read_from(source)?; let inclusion_proof = NoteInclusionProof::read_from(source)?; Ok(UnverifiedNoteState { metadata, inclusion_proof }) diff --git a/crates/rust-client/src/store/note_record/output_note_record/mod.rs b/crates/rust-client/src/store/note_record/output_note_record/mod.rs index 0857802c3e..cdce1382fa 100644 --- a/crates/rust-client/src/store/note_record/output_note_record/mod.rs +++ b/crates/rust-client/src/store/note_record/output_note_record/mod.rs @@ -15,8 +15,14 @@ use miden_protocol::note::{ Nullifier, PartialNote, }; -use miden_protocol::transaction::OutputNote; -use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; +use miden_protocol::transaction::RawOutputNote; +use miden_tx::utils::serde::{ + ByteReader, + ByteWriter, + Deserializable, + DeserializationError, + Serializable, +}; use super::NoteRecordError; @@ -185,20 +191,16 @@ impl OutputNoteRecord { } } - /// [`OutputNote`] can always be turned into an [`OutputNoteRecord`] when they're either - /// [`OutputNote::Full`] or [`OutputNote::Partial`] and always fail the conversion if it's - /// [`OutputNote::Header`]. This also mean that `output_note.try_from()` can also be used as a - /// way to filter the full and partial output notes. + /// [`RawOutputNote`] can always be turned into an [`OutputNoteRecord`]. pub fn try_from_output_note( - output_note: OutputNote, + output_note: RawOutputNote, expected_height: BlockNumber, ) -> Result { match output_note { - OutputNote::Full(note) => Ok(Self::from_full_note(note, expected_height)), - OutputNote::Partial(partial_note) => Ok(Self::from_partial_note(&partial_note, expected_height)), - OutputNote::Header(_) => Err(NoteRecordError::ConversionError( - "Cannot transform a Header output note into an OutputNoteRecord: not enough information".to_string(), - )), + RawOutputNote::Full(note) => Ok(Self::from_full_note(note, expected_height)), + RawOutputNote::Partial(partial_note) => { + Ok(Self::from_partial_note(&partial_note, expected_height)) + }, } } } diff --git a/crates/rust-client/src/store/smt_forest.rs b/crates/rust-client/src/store/smt_forest.rs index 204e3707cc..c9d612df2c 100644 --- a/crates/rust-client/src/store/smt_forest.rs +++ b/crates/rust-client/src/store/smt_forest.rs @@ -59,7 +59,7 @@ impl AccountSmtForest { return Err(MerkleError::UntrackedKey(vault_key_word).into()); } - let asset = Asset::try_from(asset_word)?; + let asset = Asset::from_key_value(vault_key, asset_word)?; let witness = AssetWitness::new(proof)?; Ok((asset, witness)) } @@ -158,7 +158,7 @@ impl AccountSmtForest { let entries: Vec<(Word, Word)> = new_assets .map(|asset| { let key: Word = asset.vault_key().into(); - let value: Word = asset.into(); + let value = asset.to_value_word(); (key, value) }) .chain(removed_vault_keys.map(|key| (key.into(), EMPTY_WORD))) @@ -193,7 +193,7 @@ impl AccountSmtForest { pub fn insert_asset_nodes(&mut self, vault: &AssetVault) -> Result<(), StoreError> { let smt = Smt::with_entries(vault.assets().map(|asset| { let key: Word = asset.vault_key().into(); - let value: Word = asset.into(); + let value = asset.to_value_word(); (key, value) })) .map_err(StoreError::from)?; diff --git a/crates/rust-client/src/sync/block_header.rs b/crates/rust-client/src/sync/block_header.rs index ea10433c17..5e435903ba 100644 --- a/crates/rust-client/src/sync/block_header.rs +++ b/crates/rust-client/src/sync/block_header.rs @@ -2,15 +2,23 @@ use alloc::sync::Arc; use alloc::vec::Vec; use miden_protocol::Word; -use miden_protocol::block::{BlockHeader, BlockNumber}; +use miden_protocol::account::AccountId; +use miden_protocol::block::account_tree::AccountTree; +use miden_protocol::block::nullifier_tree::NullifierTree; +use miden_protocol::block::{BlockHeader, BlockNoteTree, BlockNumber, Blockchain, FeeParameters}; +use miden_protocol::crypto::dsa::ecdsa_k256_keccak::SecretKey; use miden_protocol::crypto::merkle::MerklePath; use miden_protocol::crypto::merkle::mmr::{Forest, InOrderIndex, MmrPeaks, PartialMmr}; +use miden_protocol::crypto::merkle::smt::Smt; +use miden_protocol::transaction::{OrderedTransactionHeaders, TransactionKernel}; use tracing::warn; use crate::rpc::NodeRpcClient; use crate::store::{BlockRelevance, StoreError}; use crate::{Client, ClientError}; +const OFFLINE_NATIVE_ASSET_FAUCET_ID: u128 = 0xab00_0000_0000_cd20_0000_ac00_0000_de00; + /// Network information management methods. impl Client { /// Retrieves a block header by its block number from the store. @@ -43,6 +51,30 @@ impl Client { Ok(()) } + /// Seeds the local client state needed to create accounts and execute programs without a node. + /// + /// This stores default RPC limits and inserts a synthetic genesis header if one is not + /// already present in the store. The synthetic header is only intended for local-only + /// execution and debugging. + pub async fn prepare_offline_bootstrap(&mut self) -> Result<(), ClientError> { + let limits = self.store.get_rpc_limits().await?.unwrap_or_default(); + self.store.set_rpc_limits(limits).await?; + self.rpc_api.set_rpc_limits(limits).await; + + if let Some((genesis, _)) = self.store.get_block_header_by_num(BlockNumber::GENESIS).await? + { + self.rpc_api.set_genesis_commitment(genesis.commitment()).await?; + return Ok(()); + } + + let genesis = synthetic_offline_genesis_header(); + let blank_mmr_peaks = MmrPeaks::new(Forest::empty(), vec![]) + .expect("Blank MmrPeaks should not fail to instantiate"); + self.store.insert_block_header(&genesis, blank_mmr_peaks, false).await?; + self.rpc_api.set_genesis_commitment(genesis.commitment()).await?; + Ok(()) + } + /// Fetches from the store the current view of the chain's [`PartialMmr`]. pub async fn get_current_partial_mmr(&self) -> Result { self.store.get_current_partial_mmr().await.map_err(Into::into) @@ -85,6 +117,30 @@ impl Client { } } +fn synthetic_offline_genesis_header() -> BlockHeader { + let native_asset_id = AccountId::try_from(OFFLINE_NATIVE_ASSET_FAUCET_ID) + .expect("offline native asset faucet ID should be valid"); + let fee_parameters = + FeeParameters::new(native_asset_id, 500).expect("offline fee params should be valid"); + let validator_key = SecretKey::new().public_key(); + let transactions = OrderedTransactionHeaders::new_unchecked(Vec::new()); + + BlockHeader::new( + 0, + Word::empty(), + BlockNumber::GENESIS, + Blockchain::new().commitment(), + AccountTree::::default().root(), + NullifierTree::::default().root(), + BlockNoteTree::empty().root(), + transactions.commitment(), + TransactionKernel.to_commitment(), + validator_key, + fee_parameters, + 0, + ) +} + // UTILS // -------------------------------------------------------------------------------------------- @@ -126,7 +182,7 @@ pub(crate) async fn fetch_block_header( // Trim merkle path to keep nodes relevant to our current PartialMmr since the node's MMR // might be of a forest arbitrarily higher let path_nodes = adjust_merkle_path_for_forest( - &mmr_proof.merkle_path, + mmr_proof.merkle_path(), block_num, current_partial_mmr.forest(), ); @@ -142,12 +198,18 @@ pub(crate) async fn fetch_block_header( #[cfg(test)] mod tests { - use miden_protocol::block::BlockNumber; + use alloc::vec::Vec; + + use miden_protocol::block::account_tree::AccountTree; + use miden_protocol::block::nullifier_tree::NullifierTree; + use miden_protocol::block::{BlockNoteTree, BlockNumber, Blockchain}; use miden_protocol::crypto::merkle::MerklePath; use miden_protocol::crypto::merkle::mmr::{Forest, InOrderIndex, Mmr, PartialMmr}; + use miden_protocol::crypto::merkle::smt::Smt; + use miden_protocol::transaction::{OrderedTransactionHeaders, TransactionKernel}; use miden_protocol::{Felt, Word}; - use super::adjust_merkle_path_for_forest; + use super::{adjust_merkle_path_for_forest, synthetic_offline_genesis_header}; fn word(n: u64) -> Word { Word::new([Felt::new(n), Felt::new(0), Felt::new(0), Felt::new(0)]) @@ -181,7 +243,7 @@ mod tests { let proof = mmr.open_at(leaf_pos, large_forest).expect("valid proof"); let adjusted_nodes = - adjust_merkle_path_for_forest(&proof.merkle_path, block_num, small_forest); + adjust_merkle_path_for_forest(proof.merkle_path(), block_num, small_forest); let adjusted_path = MerklePath::new(adjusted_nodes.iter().map(|(_, n)| *n).collect()); let peaks = mmr.peaks_at(small_forest).unwrap(); @@ -243,13 +305,30 @@ mod tests { let next_sibling = idx.sibling(); let rightmost = InOrderIndex::from_leaf_pos(small_leaves - 1); assert!(next_sibling <= rightmost); - assert!(proof.merkle_path.depth() as usize > expected_depth); + assert!(proof.merkle_path().depth() as usize > expected_depth); let adjusted = adjust_merkle_path_for_forest( - &proof.merkle_path, + proof.merkle_path(), BlockNumber::from(u32::try_from(leaf_pos).unwrap()), small_forest, ); assert_eq!(adjusted.len(), expected_depth); } + + #[test] + fn synthetic_offline_genesis_header_matches_empty_chain_state() { + let genesis = synthetic_offline_genesis_header(); + + assert_eq!(genesis.block_num(), BlockNumber::GENESIS); + assert_eq!(genesis.prev_block_commitment(), Word::empty()); + assert_eq!(genesis.chain_commitment(), Blockchain::new().commitment()); + assert_eq!(genesis.account_root(), AccountTree::::default().root()); + assert_eq!(genesis.nullifier_root(), NullifierTree::::default().root()); + assert_eq!(genesis.note_root(), BlockNoteTree::empty().root()); + assert_eq!( + genesis.tx_commitment(), + OrderedTransactionHeaders::new_unchecked(Vec::new()).commitment() + ); + assert_eq!(genesis.tx_kernel_commitment(), TransactionKernel.to_commitment()); + } } diff --git a/crates/rust-client/src/sync/mod.rs b/crates/rust-client/src/sync/mod.rs index 0ac105b2f8..da0e2107ff 100644 --- a/crates/rust-client/src/sync/mod.rs +++ b/crates/rust-client/src/sync/mod.rs @@ -64,7 +64,7 @@ use miden_protocol::block::BlockNumber; use miden_protocol::note::NoteId; use miden_protocol::transaction::TransactionId; use miden_tx::auth::TransactionAuthenticator; -use miden_tx::utils::{Deserializable, DeserializationError, Serializable}; +use miden_tx::utils::serde::{Deserializable, DeserializationError, Serializable}; use tracing::{debug, info}; use crate::store::{NoteFilter, TransactionFilter}; @@ -286,7 +286,7 @@ impl SyncSummary { } impl Serializable for SyncSummary { - fn write_into(&self, target: &mut W) { + fn write_into(&self, target: &mut W) { self.block_num.write_into(target); self.new_public_notes.write_into(target); self.committed_notes.write_into(target); @@ -298,7 +298,7 @@ impl Serializable for SyncSummary { } impl Deserializable for SyncSummary { - fn read_from( + fn read_from( source: &mut R, ) -> Result { let block_num = BlockNumber::read_from(source)?; diff --git a/crates/rust-client/src/sync/tag.rs b/crates/rust-client/src/sync/tag.rs index bfc3b08668..1e24ff194d 100644 --- a/crates/rust-client/src/sync/tag.rs +++ b/crates/rust-client/src/sync/tag.rs @@ -3,7 +3,13 @@ use alloc::vec::Vec; use miden_protocol::account::{Account, AccountId}; use miden_protocol::note::{NoteId, NoteTag}; -use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; +use miden_tx::utils::serde::{ + ByteReader, + ByteWriter, + Deserializable, + DeserializationError, + Serializable, +}; use tracing::warn; use crate::Client; diff --git a/crates/rust-client/src/test_utils/common.rs b/crates/rust-client/src/test_utils/common.rs index 0d5400d287..a0a00fda52 100644 --- a/crates/rust-client/src/test_utils/common.rs +++ b/crates/rust-client/src/test_utils/common.rs @@ -14,7 +14,7 @@ use miden_protocol::account::{Account, AccountComponentMetadata, AccountId, Acco use miden_protocol::asset::{FungibleAsset, TokenSymbol}; use miden_protocol::note::NoteType; use miden_protocol::testing::account_id::ACCOUNT_ID_REGULAR_PRIVATE_ACCOUNT_UPDATABLE_CODE; -use miden_protocol::transaction::{OutputNote, TransactionId}; +use miden_protocol::transaction::{RawOutputNote, TransactionId}; use miden_standards::account::auth::AuthSingleSig; use miden_standards::code_builder::CodeBuilder; use rand::RngCore; @@ -77,11 +77,11 @@ pub async fn insert_new_wallet_with_seed( auth_scheme: AuthSchemeId, ) -> Result<(Account, AuthSecretKey), ClientError> { let (key_pair, auth_component) = match auth_scheme { - AuthSchemeId::Falcon512Rpo => { - let key_pair = AuthSecretKey::new_falcon512_rpo(); + AuthSchemeId::Falcon512Poseidon2 => { + let key_pair = AuthSecretKey::new_falcon512_poseidon2(); let auth_component = AuthSingleSig::new( key_pair.public_key().to_commitment(), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, ); (key_pair, auth_component) }, @@ -125,11 +125,11 @@ pub async fn insert_new_fungible_faucet( auth_scheme: AuthSchemeId, ) -> Result<(Account, AuthSecretKey), ClientError> { let (key_pair, auth_component) = match auth_scheme { - AuthSchemeId::Falcon512Rpo => { - let key_pair = AuthSecretKey::new_falcon512_rpo(); + AuthSchemeId::Falcon512Poseidon2 => { + let key_pair = AuthSecretKey::new_falcon512_poseidon2(); let auth_component = AuthSingleSig::new( key_pair.public_key().to_commitment(), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, ); (key_pair, auth_component) }, @@ -153,8 +153,7 @@ pub async fn insert_new_fungible_faucet( client.rng().fill_bytes(&mut init_seed); let symbol = TokenSymbol::new("TEST").unwrap(); - let max_supply = Felt::try_from(9_999_999_u64.to_le_bytes().as_slice()) - .expect("u64 can be safely converted to a field element"); + let max_supply = Felt::new(9_999_999); let account = AccountBuilder::new(init_seed) .account_type(AccountType::FungibleFaucet) @@ -491,7 +490,7 @@ pub fn mint_multiple_fungible_asset( let notes = target_id .iter() .map(|account_id| { - OutputNote::Full( + RawOutputNote::Full( P2idNote::create( asset.faucet_id(), *account_id, @@ -503,7 +502,7 @@ pub fn mint_multiple_fungible_asset( .unwrap(), ) }) - .collect::>(); + .collect::>(); TransactionRequestBuilder::new().own_output_notes(notes).build().unwrap() } @@ -576,14 +575,14 @@ pub async fn insert_account_with_custom_component( let custom_component = AccountComponent::new( component_code, storage_slots, - AccountComponentMetadata::new("miden::testing::custom_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::custom_component", AccountType::all()), ) .map_err(ClientError::AccountError)?; let mut init_seed = [0u8; 32]; client.rng().fill_bytes(&mut init_seed); - let key_pair = AuthSecretKey::new_falcon512_rpo_with_rng(client.rng()); + let key_pair = AuthSecretKey::new_falcon512_poseidon2_with_rng(client.rng()); let pub_key = key_pair.public_key(); let account = AccountBuilder::new(init_seed) @@ -591,7 +590,7 @@ pub async fn insert_account_with_custom_component( .storage_mode(storage_mode) .with_auth_component(AuthSingleSig::new( pub_key.to_commitment(), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(BasicWallet) .with_component(custom_component) diff --git a/crates/rust-client/src/test_utils/mock.rs b/crates/rust-client/src/test_utils/mock.rs index 738946beec..1bbb29e78d 100644 --- a/crates/rust-client/src/test_utils/mock.rs +++ b/crates/rust-client/src/test_utils/mock.rs @@ -378,7 +378,7 @@ impl NodeRpcClient for MockRpcApi { Ok(NoteSyncInfo { chain_tip: self.get_chain_tip_block_num(), block_header: next_block, - mmr_path: self.get_mmr().open(block_num.as_usize()).unwrap().merkle_path, + mmr_path: self.get_mmr().open(block_num.as_usize()).unwrap().merkle_path().clone(), notes, }) } diff --git a/crates/rust-client/src/test_utils/note_transport.rs b/crates/rust-client/src/test_utils/note_transport.rs index 11cd753a3a..92f468bf94 100644 --- a/crates/rust-client/src/test_utils/note_transport.rs +++ b/crates/rust-client/src/test_utils/note_transport.rs @@ -8,8 +8,14 @@ use core::task::{Context, Poll}; use chrono::Utc; use futures::Stream; use miden_protocol::note::{NoteHeader, NoteTag}; +use miden_tx::utils::serde::{ + ByteReader, + ByteWriter, + Deserializable, + DeserializationError, + Serializable, +}; use miden_tx::utils::sync::RwLock; -use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; use crate::note_transport::{ NoteInfo, diff --git a/crates/rust-client/src/transaction/mod.rs b/crates/rust-client/src/transaction/mod.rs index 96522ea2a2..3e394ba57e 100644 --- a/crates/rust-client/src/transaction/mod.rs +++ b/crates/rust-client/src/transaction/mod.rs @@ -1,5 +1,6 @@ //! Provides APIs for creating, executing, proving, and submitting transactions to the Miden //! network. +#![allow(clippy::mutable_key_type)] //! //! ## Overview //! @@ -130,6 +131,8 @@ pub use miden_protocol::transaction::{ OutputNote, OutputNotes, ProvenTransaction, + RawOutputNote, + RawOutputNotes, TransactionArgs, TransactionId, TransactionInputs, @@ -488,6 +491,50 @@ where .await?) } + /// Executes the provided transaction script with a DAP debug adapter listening for + /// connections, allowing interactive debugging via any DAP-compatible client. + #[cfg(feature = "dap")] + pub async fn execute_program_with_dap( + &mut self, + account_id: AccountId, + tx_script: TransactionScript, + advice_inputs: AdviceInputs, + foreign_accounts: BTreeSet, + ) -> Result<[Felt; 16], ClientError> { + let (fpi_block_number, foreign_account_inputs) = + self.retrieve_foreign_account_inputs(foreign_accounts).await?; + + let block_ref = if let Some(block_number) = fpi_block_number { + block_number + } else { + self.get_sync_height().await? + }; + + let account_record = self + .store + .get_account(account_id) + .await? + .ok_or(ClientError::AccountDataNotFound(account_id))?; + + let account: Account = account_record.try_into()?; + + let data_store = ClientDataStore::new(self.store.clone()); + + data_store.register_foreign_account_inputs(foreign_account_inputs.iter().cloned()); + + // Ensure code is loaded on MAST store + data_store.mast_store().load_account_code(account.code()); + + for fpi_account in &foreign_account_inputs { + data_store.mast_store().load_account_code(fpi_account.code()); + } + + Ok(self + .build_dap_executor(&data_store)? + .execute_tx_view_script(account_id, block_ref, tx_script, advice_inputs) + .await?) + } + // HELPERS // -------------------------------------------------------------------------------------------- @@ -746,6 +793,26 @@ where Ok(executor) } + + /// Creates a transaction executor configured for DAP (Debug Adapter Protocol) debugging. + #[cfg(feature = "dap")] + pub(crate) fn build_dap_executor<'store, 'auth, STORE: DataStore + Sync>( + &'auth self, + data_store: &'store STORE, + ) -> Result< + TransactionExecutor<'store, 'auth, STORE, AUTH, miden_debug::DapExecutor>, + TransactionExecutorError, + > { + let mut executor = TransactionExecutor::new(data_store) + .with_program_executor::() + .with_options(self.exec_options)?; + if let Some(authenticator) = self.authenticator.as_deref() { + executor = executor.with_authenticator(authenticator); + } + executor = executor.with_source_manager(self.source_manager.clone()); + + Ok(executor) + } } // HELPERS @@ -757,7 +824,7 @@ where /// notes wouldn't be included. fn get_outgoing_assets( transaction_request: &TransactionRequest, -) -> (BTreeMap, BTreeSet) { +) -> (BTreeMap, BTreeMap) { // Get own notes assets let mut own_notes_assets = match transaction_request.script_template() { Some(TransactionScriptTemplate::SendNotes(notes)) => notes @@ -789,10 +856,10 @@ fn validate_basic_account_request( account: &Account, ) -> Result<(), ClientError> { // Get outgoing assets - let (fungible_balance_map, non_fungible_set) = get_outgoing_assets(transaction_request); + let (fungible_balance_map, non_fungible_assets) = get_outgoing_assets(transaction_request); // Get incoming assets - let (incoming_fungible_balance_map, incoming_non_fungible_balance_set) = + let (incoming_fungible_balance_map, incoming_non_fungible_assets) = transaction_request.incoming_assets(); // Check if the account balance plus incoming assets is greater than or equal to the @@ -810,22 +877,20 @@ fn validate_basic_account_request( // Check if the account balance plus incoming assets is greater than or equal to the // outgoing non fungible assets - for non_fungible in non_fungible_set { + for non_fungible in non_fungible_assets.into_values() { match account.vault().has_non_fungible_asset(non_fungible) { Ok(true) => (), Ok(false) => { // Check if the non fungible asset is in the incoming assets - if !incoming_non_fungible_balance_set.contains(&non_fungible) { + if !incoming_non_fungible_assets.contains_key(&non_fungible.to_key_word()) { return Err(ClientError::AssetError( - AssetError::NonFungibleFaucetIdTypeMismatch( - non_fungible.faucet_id_prefix(), - ), + AssetError::NonFungibleFaucetIdTypeMismatch(non_fungible.faucet_id()), )); } }, _ => { return Err(ClientError::AssetError(AssetError::NonFungibleFaucetIdTypeMismatch( - non_fungible.faucet_id_prefix(), + non_fungible.faucet_id(), ))); }, } @@ -834,14 +899,14 @@ fn validate_basic_account_request( Ok(()) } -/// Extracts notes from [`OutputNotes`]. +/// Extracts notes from [`RawOutputNotes`]. /// Used for: /// - Checking the relevance of notes to save them as input notes. /// - Validate hashes versus expected output notes after a transaction is executed. -pub fn notes_from_output(output_notes: &OutputNotes) -> impl Iterator { +pub fn notes_from_output(output_notes: &RawOutputNotes) -> impl Iterator { output_notes.iter().filter_map(|n| match n { - OutputNote::Full(n) => Some(n), - OutputNote::Header(_) | OutputNote::Partial(_) => None, + RawOutputNote::Full(n) => Some(n), + RawOutputNote::Partial(_) => None, }) } diff --git a/crates/rust-client/src/transaction/prover.rs b/crates/rust-client/src/transaction/prover.rs index 91dd4a8c5c..30fa4b187f 100644 --- a/crates/rust-client/src/transaction/prover.rs +++ b/crates/rust-client/src/transaction/prover.rs @@ -20,7 +20,7 @@ impl TransactionProver for LocalTransactionProver { &self, witness: TransactionInputs, ) -> Result { - LocalTransactionProver::prove(self, witness) + LocalTransactionProver::prove(self, witness).await } } diff --git a/crates/rust-client/src/transaction/record.rs b/crates/rust-client/src/transaction/record.rs index 469ba4b73f..0c5403cfb6 100644 --- a/crates/rust-client/src/transaction/record.rs +++ b/crates/rust-client/src/transaction/record.rs @@ -6,7 +6,13 @@ use miden_protocol::Word; use miden_protocol::account::AccountId; use miden_protocol::block::BlockNumber; use miden_protocol::transaction::{OutputNotes, TransactionId, TransactionScript}; -use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; +use miden_tx::utils::serde::{ + ByteReader, + ByteWriter, + Deserializable, + DeserializationError, + Serializable, +}; // TRANSACTION RECORD // ================================================================================================ diff --git a/crates/rust-client/src/transaction/request/builder.rs b/crates/rust-client/src/transaction/request/builder.rs index 277b7ef331..2b933a4f4b 100644 --- a/crates/rust-client/src/transaction/request/builder.rs +++ b/crates/rust-client/src/transaction/request/builder.rs @@ -19,7 +19,7 @@ use miden_protocol::note::{ NoteType, PartialNote, }; -use miden_protocol::transaction::{OutputNote, TransactionScript}; +use miden_protocol::transaction::{RawOutputNote, TransactionScript}; use miden_protocol::vm::AdviceMap; use miden_protocol::{Felt, Word}; use miden_standards::note::{P2idNote, P2ideNote, P2ideNoteStorage, SwapNote}; @@ -51,7 +51,7 @@ pub struct TransactionRequestBuilder { input_notes_args: Vec<(NoteId, Option)>, /// Notes to be created by the transaction. This includes both full and partial output notes. /// The transaction script will be generated based on these notes. - own_output_notes: Vec, + own_output_notes: Vec, /// A map of recipients of the output notes expected to be generated by the transaction. expected_output_recipients: BTreeMap, /// A map of details and tags of notes we expect to be created as part of future transactions @@ -128,9 +128,9 @@ impl TransactionRequestBuilder { /// If a transaction script template is already set (e.g. by calling `with_custom_script`), the /// [`TransactionRequestBuilder::build`] method will return an error. #[must_use] - pub fn own_output_notes(mut self, notes: impl IntoIterator) -> Self { + pub fn own_output_notes(mut self, notes: impl IntoIterator) -> Self { for note in notes { - if let OutputNote::Full(note) = ¬e { + if let RawOutputNote::Full(note) = ¬e { self.expected_output_recipients .insert(note.recipient().digest(), note.recipient().clone()); } @@ -297,7 +297,7 @@ impl TransactionRequestBuilder { rng, )?; - self.own_output_notes(vec![OutputNote::Full(created_note)]).build() + self.own_output_notes(vec![RawOutputNote::Full(created_note)]).build() } /// Consumes the builder and returns a [`TransactionRequest`] for a transaction to send a P2ID @@ -327,7 +327,7 @@ impl TransactionRequestBuilder { let created_note = payment_data.into_note(note_type, rng)?; - self.own_output_notes(vec![OutputNote::Full(created_note)]).build() + self.own_output_notes(vec![RawOutputNote::Full(created_note)]).build() } /// Consumes the builder and returns a [`TransactionRequest`] for a transaction to send a SWAP @@ -364,7 +364,7 @@ impl TransactionRequestBuilder { let payback_tag = NoteTag::with_account_target(swap_data.account_id()); self.expected_future_notes(vec![(payback_note_details, payback_tag)]) - .own_output_notes(vec![OutputNote::Full(created_note)]) + .own_output_notes(vec![RawOutputNote::Full(created_note)]) .build() } @@ -405,11 +405,10 @@ impl TransactionRequestBuilder { .own_output_notes .into_iter() .map(|note| match note { - OutputNote::Header(_) => Err(TransactionRequestError::InvalidNoteVariant), - OutputNote::Partial(note) => Ok(note), - OutputNote::Full(note) => Ok(note.into()), + RawOutputNote::Partial(note) => note, + RawOutputNote::Full(note) => note.into(), }) - .collect::, _>>()?; + .collect::>(); Some(TransactionScriptTemplate::SendNotes(partial_notes)) }, diff --git a/crates/rust-client/src/transaction/request/foreign.rs b/crates/rust-client/src/transaction/request/foreign.rs index 52ce281e9a..a38d20f54a 100644 --- a/crates/rust-client/src/transaction/request/foreign.rs +++ b/crates/rust-client/src/transaction/request/foreign.rs @@ -12,7 +12,7 @@ use miden_protocol::account::{ }; use miden_protocol::asset::{AssetVault, PartialVault}; use miden_protocol::transaction::AccountInputs; -use miden_tx::utils::{Deserializable, DeserializationError, Serializable}; +use miden_tx::utils::serde::{Deserializable, DeserializationError, Serializable}; use super::TransactionRequestError; use crate::rpc::domain::account::{ @@ -96,7 +96,7 @@ impl PartialOrd for ForeignAccount { } impl Serializable for ForeignAccount { - fn write_into(&self, target: &mut W) { + fn write_into(&self, target: &mut W) { match self { ForeignAccount::Public(account_id, storage_requirements) => { target.write(0u8); @@ -112,9 +112,9 @@ impl Serializable for ForeignAccount { } impl Deserializable for ForeignAccount { - fn read_from( + fn read_from( source: &mut R, - ) -> Result { + ) -> Result { let account_type: u8 = source.read_u8()?; match account_type { 0 => { diff --git a/crates/rust-client/src/transaction/request/mod.rs b/crates/rust-client/src/transaction/request/mod.rs index a5debe5c3e..4407707149 100644 --- a/crates/rust-client/src/transaction/request/mod.rs +++ b/crates/rust-client/src/transaction/request/mod.rs @@ -1,4 +1,5 @@ //! Contains structures and functions related to transaction creation. +#![allow(clippy::mutable_key_type)] use alloc::boxed::Box; use alloc::collections::{BTreeMap, BTreeSet}; @@ -24,7 +25,13 @@ use miden_protocol::vm::AdviceMap; use miden_standards::account::interface::{AccountInterface, AccountInterfaceError}; use miden_standards::code_builder::CodeBuilder; use miden_standards::errors::CodeBuilderError; -use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; +use miden_tx::utils::serde::{ + ByteReader, + ByteWriter, + Deserializable, + DeserializationError, + Serializable, +}; use thiserror::Error; mod builder; @@ -118,7 +125,7 @@ impl TransactionRequest { } /// Returns the assets held by the transaction's input notes. - pub fn incoming_assets(&self) -> (BTreeMap, BTreeSet) { + pub fn incoming_assets(&self) -> (BTreeMap, BTreeMap) { collect_assets(self.input_notes.iter().flat_map(|note| note.assets().iter())) } @@ -394,9 +401,9 @@ impl Deserializable for TransactionRequest { /// Accumulates fungible totals and collectable non-fungible assets from an iterator of assets. pub(crate) fn collect_assets<'a>( assets: impl Iterator, -) -> (BTreeMap, BTreeSet) { +) -> (BTreeMap, BTreeMap) { let mut fungible_balance_map = BTreeMap::new(); - let mut non_fungible_set = BTreeSet::new(); + let mut non_fungible_assets = BTreeMap::new(); assets.for_each(|asset| match asset { Asset::Fungible(fungible) => { @@ -406,11 +413,11 @@ pub(crate) fn collect_assets<'a>( .or_insert(fungible.amount()); }, Asset::NonFungible(non_fungible) => { - non_fungible_set.insert(*non_fungible); + non_fungible_assets.insert(non_fungible.to_key_word(), *non_fungible); }, }); - (fungible_balance_map, non_fungible_set) + (fungible_balance_map, non_fungible_assets) } impl Default for TransactionRequestBuilder { @@ -503,12 +510,12 @@ mod tests { ACCOUNT_ID_REGULAR_PUBLIC_ACCOUNT_IMMUTABLE_CODE, ACCOUNT_ID_SENDER, }; - use miden_protocol::transaction::OutputNote; + use miden_protocol::transaction::RawOutputNote; use miden_protocol::{EMPTY_WORD, Felt, Word}; use miden_standards::account::auth::AuthSingleSig; use miden_standards::note::P2idNote; use miden_standards::testing::account_component::MockAccountComponent; - use miden_tx::utils::{Deserializable, Serializable}; + use miden_tx::utils::serde::{Deserializable, Serializable}; use super::{TransactionRequest, TransactionRequestBuilder}; use crate::rpc::domain::account::AccountStorageRequirements; @@ -517,8 +524,11 @@ mod tests { #[test] fn transaction_request_serialization() { assert_transaction_request_serialization_with(|| { - AuthSingleSig::new(PublicKeyCommitment::from(EMPTY_WORD), AuthScheme::Falcon512Rpo) - .into() + AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthScheme::Falcon512Poseidon2, + ) + .into() }); } @@ -588,8 +598,8 @@ mod tests { ForeignAccount::private(&account).unwrap(), ]) .own_output_notes(vec![ - OutputNote::Full(notes.pop().unwrap()), - OutputNote::Partial(notes.pop().unwrap().into()), + RawOutputNote::Full(notes.pop().unwrap()), + RawOutputNote::Partial(notes.pop().unwrap().into()), ]) .script_arg(rng.draw_word()) .auth_arg(rng.draw_word()) diff --git a/crates/rust-client/src/transaction/result.rs b/crates/rust-client/src/transaction/result.rs index 7cffbb41ba..a6e4e57b4c 100644 --- a/crates/rust-client/src/transaction/result.rs +++ b/crates/rust-client/src/transaction/result.rs @@ -7,12 +7,18 @@ use miden_protocol::transaction::{ ExecutedTransaction, InputNote, InputNotes, - OutputNotes, + RawOutputNotes, TransactionArgs, TransactionId, TransactionInputs, }; -use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; +use miden_tx::utils::serde::{ + ByteReader, + ByteWriter, + Deserializable, + DeserializationError, + Serializable, +}; use crate::ClientError; @@ -50,7 +56,7 @@ impl TransactionResult { } /// Returns the output notes that were generated as a result of the transaction execution. - pub fn created_notes(&self) -> &OutputNotes { + pub fn created_notes(&self) -> &RawOutputNotes { self.transaction.output_notes() } diff --git a/crates/rust-client/src/transaction/store_update.rs b/crates/rust-client/src/transaction/store_update.rs index 170f89f23d..c9b448203c 100644 --- a/crates/rust-client/src/transaction/store_update.rs +++ b/crates/rust-client/src/transaction/store_update.rs @@ -3,7 +3,13 @@ use alloc::vec::Vec; use miden_protocol::block::BlockNumber; use miden_protocol::note::{NoteDetails, NoteTag}; use miden_protocol::transaction::ExecutedTransaction; -use miden_tx::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; +use miden_tx::utils::serde::{ + ByteReader, + ByteWriter, + Deserializable, + DeserializationError, + Serializable, +}; use crate::note::NoteUpdateTracker; use crate::sync::NoteTagRecord; diff --git a/crates/rust-client/src/utils.rs b/crates/rust-client/src/utils.rs index b94d21010f..3f31d78cbd 100644 --- a/crates/rust-client/src/utils.rs +++ b/crates/rust-client/src/utils.rs @@ -6,17 +6,15 @@ use alloc::vec::Vec; use core::num::ParseIntError; use miden_standards::account::faucets::BasicFungibleFaucet; -pub use miden_tx::utils::sync::{LazyLock, RwLock, RwLockReadGuard, RwLockWriteGuard}; -pub use miden_tx::utils::{ +pub use miden_tx::utils::serde::{ ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable, - ToHex, - bytes_to_hex_string, - hex_to_bytes, }; +pub use miden_tx::utils::sync::{LazyLock, RwLock, RwLockReadGuard, RwLockWriteGuard}; +pub use miden_tx::utils::{ToHex, bytes_to_hex_string, hex_to_bytes}; use crate::alloc::borrow::ToOwned; diff --git a/crates/sqlite-store/src/account/accounts.rs b/crates/sqlite-store/src/account/accounts.rs index 9e69a112ba..9df1c3f4ea 100644 --- a/crates/sqlite-store/src/account/accounts.rs +++ b/crates/sqlite-store/src/account/accounts.rs @@ -319,7 +319,7 @@ impl SqliteStore { Self::insert_account_code(&tx, account.code())?; let account_id = account.id(); - let nonce = account.nonce().as_int(); + let nonce = account.nonce().as_canonical_u64(); Self::insert_storage_slots(&tx, account_id, nonce, account.storage().slots().iter())?; @@ -495,7 +495,7 @@ impl SqliteStore { Self::write_storage_delta( tx, account_id, - final_account_state.nonce().as_int(), + final_account_state.nonce().as_canonical_u64(), &updated_storage_slots, delta, )?; @@ -591,7 +591,7 @@ impl SqliteStore { ) -> Result<(), StoreError> { let account_id = new_account_state.id(); let account_id_hex = account_id.to_hex(); - let nonce = new_account_state.nonce().as_int(); + let nonce = new_account_state.nonce().as_canonical_u64(); let nonce_val = u64_to_value(nonce); // Insert and register account state in the SMT forest (handles old root cleanup) @@ -792,7 +792,7 @@ impl SqliteStore { let code_commitment = account.code_commitment().to_string(); let storage_commitment = account.storage_commitment().to_string(); let vault_root = account.vault_root().to_string(); - let nonce = u64_to_value(account.nonce().as_int()); + let nonce = u64_to_value(account.nonce().as_canonical_u64()); let commitment = account.to_commitment().to_string(); let account_seed = account_seed.map(|seed| seed.to_bytes()); diff --git a/crates/sqlite-store/src/account/helpers.rs b/crates/sqlite-store/src/account/helpers.rs index 75fc7069e7..2f79aba9ea 100644 --- a/crates/sqlite-store/src/account/helpers.rs +++ b/crates/sqlite-store/src/account/helpers.rs @@ -164,19 +164,22 @@ pub(crate) fn query_vault_assets( conn: &Connection, account_id: AccountId, ) -> Result, StoreError> { - const VAULT_QUERY: &str = "SELECT asset FROM latest_account_assets WHERE account_id = ?"; + const VAULT_QUERY: &str = + "SELECT vault_key, asset FROM latest_account_assets WHERE account_id = ?"; conn.prepare(VAULT_QUERY) .into_store_error()? .query_map(params![account_id.to_hex()], |row| { - let asset: String = row.get(0)?; - Ok(asset) + let vault_key: String = row.get(0)?; + let asset: String = row.get(1)?; + Ok((vault_key, asset)) }) .into_store_error()? .map(|result| { - let asset_str: String = result.into_store_error()?; - let word = Word::try_from(asset_str)?; - Ok(Asset::try_from(word)?) + let (vault_key_str, asset_str) = result.into_store_error()?; + let vault_key = Word::try_from(vault_key_str)?; + let asset_value = Word::try_from(asset_str)?; + Ok(Asset::from_key_value_words(vault_key, asset_value)?) }) .collect::, StoreError>>() } diff --git a/crates/sqlite-store/src/account/tests.rs b/crates/sqlite-store/src/account/tests.rs index 7e4726d6fb..a238b53815 100644 --- a/crates/sqlite-store/src/account/tests.rs +++ b/crates/sqlite-store/src/account/tests.rs @@ -51,12 +51,15 @@ async fn account_code_insertion_no_duplicates() -> anyhow::Result<()> { let account_component = AccountComponent::new( component_code, vec![], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account_code = AccountCode::from_components( &[ - AuthSingleSig::new(PublicKeyCommitment::from(EMPTY_WORD), AuthSchemeId::Falcon512Rpo) - .into(), + AuthSingleSig::new( + PublicKeyCommitment::from(EMPTY_WORD), + AuthSchemeId::Falcon512Poseidon2, + ) + .into(), account_component, ], AccountType::RegularAccountUpdatableCode, @@ -108,7 +111,7 @@ async fn apply_account_delta_additions() -> anyhow::Result<()> { StorageSlot::with_empty_value(value_slot_name.clone()), StorageSlot::with_empty_map(map_slot_name.clone()), ], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; // Create and insert an account @@ -116,7 +119,7 @@ async fn apply_account_delta_additions() -> anyhow::Result<()> { .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .build()?; @@ -137,7 +140,7 @@ async fn apply_account_delta_additions() -> anyhow::Result<()> { FungibleAsset::new(AccountId::try_from(ACCOUNT_ID_PUBLIC_FUNGIBLE_FAUCET)?, 100)? .into(), NonFungibleAsset::new(&NonFungibleAssetDetails::new( - AccountId::try_from(ACCOUNT_ID_PUBLIC_NON_FUNGIBLE_FAUCET)?.prefix(), + AccountId::try_from(ACCOUNT_ID_PUBLIC_NON_FUNGIBLE_FAUCET)?, NON_FUNGIBLE_ASSET_DATA.into(), )?)? .into(), @@ -203,14 +206,14 @@ async fn apply_account_delta_removals() -> anyhow::Result<()> { StorageSlot::with_value(value_slot_name.clone(), [ZERO, ZERO, ZERO, ONE].into()), StorageSlot::with_map(map_slot_name.clone(), dummy_map), ], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; // Create and insert an account let assets: Vec = vec![ FungibleAsset::new(AccountId::try_from(ACCOUNT_ID_PUBLIC_FUNGIBLE_FAUCET)?, 100)?.into(), NonFungibleAsset::new(&NonFungibleAssetDetails::new( - AccountId::try_from(ACCOUNT_ID_PUBLIC_NON_FUNGIBLE_FAUCET)?.prefix(), + AccountId::try_from(ACCOUNT_ID_PUBLIC_NON_FUNGIBLE_FAUCET)?, NON_FUNGIBLE_ASSET_DATA.into(), )?)? .into(), @@ -219,7 +222,7 @@ async fn apply_account_delta_removals() -> anyhow::Result<()> { .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .with_assets(assets.clone()) @@ -304,14 +307,14 @@ async fn get_account_storage_item_success() -> anyhow::Result<()> { let dummy_component = AccountComponent::new( basic_wallet_library(), vec![StorageSlot::with_value(value_slot_name.clone(), test_value.into())], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .build_existing()?; @@ -337,14 +340,14 @@ async fn get_account_storage_item_not_found() -> anyhow::Result<()> { let dummy_component = AccountComponent::new( basic_wallet_library(), vec![StorageSlot::with_empty_value(value_slot_name)], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .build_existing()?; @@ -378,14 +381,14 @@ async fn get_account_map_item_success() -> anyhow::Result<()> { let dummy_component = AccountComponent::new( basic_wallet_library(), vec![StorageSlot::with_map(map_slot_name.clone(), storage_map)], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .build_existing()?; @@ -412,14 +415,14 @@ async fn get_account_map_item_value_slot_error() -> anyhow::Result<()> { let dummy_component = AccountComponent::new( basic_wallet_library(), vec![StorageSlot::with_empty_value(value_slot_name.clone())], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .build_existing()?; @@ -443,14 +446,14 @@ async fn get_account_code() -> anyhow::Result<()> { let dummy_component = AccountComponent::new( basic_wallet_library(), vec![], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .build_existing()?; @@ -496,14 +499,14 @@ async fn account_reader_nonce_and_status() -> anyhow::Result<()> { let dummy_component = AccountComponent::new( basic_wallet_library(), vec![], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .build()?; @@ -572,14 +575,14 @@ async fn account_reader_storage_access() -> anyhow::Result<()> { let dummy_component = AccountComponent::new( basic_wallet_library(), vec![StorageSlot::with_value(value_slot_name.clone(), test_value.into())], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .build_existing()?; @@ -609,14 +612,14 @@ async fn account_reader_addresses_access() -> anyhow::Result<()> { let dummy_component = AccountComponent::new( basic_wallet_library(), vec![], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(dummy_component) .build_existing()?; @@ -708,14 +711,14 @@ async fn setup_account_with_map( let component = AccountComponent::new( basic_wallet_library(), vec![StorageSlot::with_map(map_slot_name.clone(), map)], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(component) .build()?; @@ -876,7 +879,7 @@ async fn undo_account_state_restores_previous_latest() -> anyhow::Result<()> { .interact_with_connection(move |conn| SqliteStore::get_account_header(conn, account_id)) .await? .expect("account should still exist after undo"); - assert_eq!(header.nonce().as_int(), 0); + assert_eq!(header.nonce().as_canonical_u64(), 0); assert_eq!(header.to_commitment(), initial_commitment); Ok(()) @@ -904,14 +907,14 @@ async fn undo_account_state_deletes_account_entirely() -> anyhow::Result<()> { let component = AccountComponent::new( basic_wallet_library(), vec![StorageSlot::with_map(map_slot_name.clone(), map)], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; let account = AccountBuilder::new([0; 32]) .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(component) .with_assets(vec![ @@ -1097,7 +1100,7 @@ async fn undo_after_update_account_state_does_not_resurrect_removed_entries() -> let component = AccountComponent::new( basic_wallet_library(), vec![StorageSlot::with_map(map_slot_name.clone(), initial_map)], - AccountComponentMetadata::new("miden::testing::dummy_component").with_supports_all_types(), + AccountComponentMetadata::new("miden::testing::dummy_component", AccountType::all()), )?; // Build with build() at nonce 0 — no initial assets @@ -1105,7 +1108,7 @@ async fn undo_after_update_account_state_does_not_resurrect_removed_entries() -> .account_type(AccountType::RegularAccountImmutableCode) .with_auth_component(AuthSingleSig::new( PublicKeyCommitment::from(EMPTY_WORD), - AuthSchemeId::Falcon512Rpo, + AuthSchemeId::Falcon512Poseidon2, )) .with_component(component) .build()?; @@ -1116,7 +1119,7 @@ async fn undo_after_update_account_state_does_not_resurrect_removed_entries() -> // Step 1+2: Apply delta at nonce 1 adding assets X and Y let asset_x = FungibleAsset::new(faucet_id, 100)?; let asset_y = NonFungibleAsset::new(&NonFungibleAssetDetails::new( - nf_faucet_id.prefix(), + nf_faucet_id, NON_FUNGIBLE_ASSET_DATA.into(), )?)?; @@ -1162,7 +1165,7 @@ async fn undo_after_update_account_state_does_not_resurrect_removed_entries() -> let mut account_updated = account_nonce1.clone(); account_updated.apply_delta(&delta_remove)?; - let updated_nonce = account_updated.nonce().as_int(); + let updated_nonce = account_updated.nonce().as_canonical_u64(); // Call update_account_state with the updated state let smt_forest = store.smt_forest.clone(); @@ -1190,10 +1193,8 @@ async fn undo_after_update_account_state_does_not_resurrect_removed_entries() -> [Felt::new(999), ZERO, ZERO, ZERO].into(), )?; - let asset_z = NonFungibleAsset::new(&NonFungibleAssetDetails::new( - nf_faucet_id.prefix(), - vec![5, 6, 7, 8], - )?)?; + let asset_z = + NonFungibleAsset::new(&NonFungibleAssetDetails::new(nf_faucet_id, vec![5, 6, 7, 8])?)?; let vault_delta_next = AccountVaultDelta::from_iters(vec![asset_z.into()], []); let delta_next = AccountDelta::new(account_id, storage_delta_next, vault_delta_next, ONE)?; @@ -1263,7 +1264,7 @@ async fn undo_after_update_account_state_does_not_resurrect_removed_entries() -> .interact_with_connection(move |conn| SqliteStore::get_account_header(conn, account_id)) .await? .expect("account should exist"); - assert_eq!(header.nonce().as_int(), updated_nonce); + assert_eq!(header.nonce().as_canonical_u64(), updated_nonce); Ok(()) } @@ -1291,7 +1292,7 @@ async fn get_account_header_by_commitment_returns_historical() -> anyhow::Result }) .await? .expect("Initial commitment should exist in historical"); - assert_eq!(header.nonce().as_int(), 0); + assert_eq!(header.nonce().as_canonical_u64(), 0); assert_eq!(header.to_commitment(), initial_commitment); // Look up the post-delta commitment — should find the nonce-1 state in historical @@ -1302,7 +1303,7 @@ async fn get_account_header_by_commitment_returns_historical() -> anyhow::Result }) .await? .expect("Post-delta commitment should exist in historical"); - assert_eq!(header.nonce().as_int(), 1); + assert_eq!(header.nonce().as_canonical_u64(), 1); assert_eq!(header.to_commitment(), post_delta_commitment); Ok(()) diff --git a/crates/sqlite-store/src/account/vault.rs b/crates/sqlite-store/src/account/vault.rs index 2ffc3c02c1..052ad520f0 100644 --- a/crates/sqlite-store/src/account/vault.rs +++ b/crates/sqlite-store/src/account/vault.rs @@ -34,25 +34,27 @@ impl SqliteStore { .map(|(faucet_id, _)| Value::Text(faucet_id.prefix().to_hex())) .collect::>(); - const QUERY: &str = "SELECT asset FROM latest_account_assets WHERE account_id = ? AND faucet_id_prefix IN rarray(?)"; + const QUERY: &str = "SELECT vault_key, asset FROM latest_account_assets WHERE account_id = ? AND faucet_id_prefix IN rarray(?)"; Ok(conn .prepare(QUERY) .into_store_error()? .query_map(params![account_id.to_hex(), Rc::new(fungible_faucet_prefixes)], |row| { - let asset: String = row.get(0)?; - Ok(asset) + let vault_key: String = row.get(0)?; + let asset: String = row.get(1)?; + Ok((vault_key, asset)) }) .into_store_error()? .map(|result| { - let asset_str: String = result.into_store_error()?; - let word = Word::try_from(asset_str)?; - Ok(Asset::try_from(word)?) + let (vault_key_str, asset_str) = result.into_store_error()?; + let vault_key = Word::try_from(vault_key_str)?; + let asset_value = Word::try_from(asset_str)?; + Ok(Asset::from_key_value_words(vault_key, asset_value)?) }) .collect::, StoreError>>()? .into_iter() // SAFETY: all retrieved assets should be fungible - .map(|asset| (asset.faucet_id_prefix(), asset.unwrap_fungible())) + .map(|asset| (asset.faucet_id().prefix(), asset.unwrap_fungible())) .collect()) } @@ -93,8 +95,8 @@ impl SqliteStore { for asset in assets { let vault_key_word: Word = asset.vault_key().into(); let vault_key_hex = vault_key_word.to_hex(); - let faucet_prefix_hex = asset.faucet_id_prefix().to_hex(); - let asset_hex = Word::from(asset).to_hex(); + let faucet_prefix_hex = asset.faucet_id().prefix().to_hex(); + let asset_hex = asset.to_value_word().to_hex(); latest_stmt .execute(params![&account_id_hex, &vault_key_hex, &faucet_prefix_hex, &asset_hex]) @@ -128,7 +130,7 @@ impl SqliteStore { mut updated_fungible_assets: BTreeMap, delta: &AccountDelta, ) -> Result<(), StoreError> { - let nonce = final_account_state.nonce().as_int(); + let nonce = final_account_state.nonce().as_canonical_u64(); let account_id_hex = account_id.to_hex(); let nonce_val = u64_to_value(nonce); @@ -238,7 +240,7 @@ impl SqliteStore { tx.prepare_cached(HISTORICAL_TOMBSTONE_QUERY).into_store_error()?; for vault_key in removed_vault_keys { let vault_key_word: Word = (*vault_key).into(); - let faucet_prefix_hex = vault_key.faucet_id_prefix().to_hex(); + let faucet_prefix_hex = vault_key.faucet_id().prefix().to_hex(); tombstone_stmt .execute(params![ account_id_hex, @@ -274,8 +276,8 @@ impl SqliteStore { for asset in updated_assets { let vault_key_word: Word = asset.vault_key().into(); let vault_key_hex = vault_key_word.to_hex(); - let faucet_prefix_hex = asset.faucet_id_prefix().to_hex(); - let asset_hex = Word::from(*asset).to_hex(); + let faucet_prefix_hex = asset.faucet_id().prefix().to_hex(); + let asset_hex = asset.to_value_word().to_hex(); latest_stmt .execute(params![account_id_hex, &vault_key_hex, &faucet_prefix_hex, &asset_hex]) diff --git a/crates/sqlite-store/src/chain_data.rs b/crates/sqlite-store/src/chain_data.rs index 415bbf588a..eb45ae7067 100644 --- a/crates/sqlite-store/src/chain_data.rs +++ b/crates/sqlite-store/src/chain_data.rs @@ -481,7 +481,7 @@ mod test { let proof = mmr.open(block_num).expect("valid proof"); let mut idx = InOrderIndex::from_leaf_pos(block_num); - for node in proof.merkle_path.nodes() { + for node in proof.merkle_path().nodes() { tracked_nodes.insert(idx.sibling(), *node); idx = idx.parent(); } @@ -566,7 +566,7 @@ mod test { for block_num in tracked_blocks { let partial_proof = partial_mmr.open(block_num).expect("partial mmr query succeeds"); assert!(partial_proof.is_some()); - assert_eq!(partial_proof.unwrap(), mmr.open(block_num).unwrap()); + assert_eq!(partial_proof.unwrap(), *mmr.open(block_num).unwrap().path()); } } } diff --git a/crates/sqlite-store/src/db_management/utils.rs b/crates/sqlite-store/src/db_management/utils.rs index 06d6d4ab86..a3530acf98 100644 --- a/crates/sqlite-store/src/db_management/utils.rs +++ b/crates/sqlite-store/src/db_management/utils.rs @@ -2,7 +2,7 @@ use std::string::String; use std::sync::LazyLock; use std::vec::Vec; -use miden_client::crypto::{Blake3_160, Blake3Digest}; +use miden_client::crypto::{Blake3_192, Blake3Digest}; use miden_client::store::StoreError; use rusqlite::types::FromSql; use rusqlite::{Connection, OptionalExtension, Result, ToSql, Transaction, params}; @@ -57,7 +57,7 @@ macro_rules! insert_sql { // MIGRATIONS // ================================================================================================ -type Hash = Blake3Digest<20>; +type Hash = Blake3Digest<24>; const MIGRATION_SCRIPTS: [&str; 1] = [include_str!("../store.sql")]; static MIGRATION_HASHES: LazyLock> = LazyLock::new(compute_migration_hashes); @@ -111,8 +111,8 @@ fn compute_migration_hashes() -> Vec { MIGRATION_SCRIPTS .iter() .map(|sql| { - let script_hash = Blake3_160::hash(preprocess_sql(sql).as_bytes()); - accumulator = Blake3_160::merge(&[accumulator, script_hash]); + let script_hash = Blake3_192::hash(preprocess_sql(sql).as_bytes()); + accumulator = Blake3_192::merge(&[accumulator, script_hash]); accumulator }) .collect() diff --git a/crates/sqlite-store/src/transaction.rs b/crates/sqlite-store/src/transaction.rs index 9054a6517a..b83fecf7fc 100644 --- a/crates/sqlite-store/src/transaction.rs +++ b/crates/sqlite-store/src/transaction.rs @@ -9,6 +9,7 @@ use miden_client::Word; use miden_client::note::ToInputNoteCommitments; use miden_client::store::{AccountSmtForest, StoreError, TransactionFilter}; use miden_client::transaction::{ + OutputNotes, TransactionDetails, TransactionId, TransactionRecord, @@ -132,14 +133,23 @@ impl SqliteStore { .map(|x| x.nullifier().as_word()) .collect(); - let output_notes = executed_transaction.output_notes(); + let output_notes = OutputNotes::new( + executed_transaction + .output_notes() + .iter() + .map(|note| { + note.to_output_note().map_err(|err| StoreError::ParsingError(err.to_string())) + }) + .collect::, _>>()?, + ) + .map_err(|err| StoreError::ParsingError(err.to_string()))?; let details = TransactionDetails { account_id: executed_transaction.account_id(), init_account_state: executed_transaction.initial_account().initial_commitment(), final_account_state: executed_transaction.final_account().to_commitment(), input_note_nullifiers: nullifiers, - output_notes: output_notes.clone(), + output_notes, block_num: executed_transaction.block_header().block_num(), submission_height: tx_update.submission_height(), expiration_block_num: executed_transaction.expiration_block_num(),