diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bbb3df8f..d8f36a013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Optimized state synchronizations by removing unnecessary fetching and parsing of note details (#462). - [BREAKING] Changed `GetAccountDetailsResponse` field to `details` (#481). - Improve `--version` by adding build metadata (#495). +- [BREAKING] Introduced additional limits for note/account number (#503). ## 0.5.1 (2024-09-12) diff --git a/Cargo.lock b/Cargo.lock index 9a42d2ea9..432510cf6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -388,9 +388,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", @@ -414,15 +414,15 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "8f43644eed690f5374f1af436ecd6aea01cd201f6fbdf0178adaf6907afb2cec" dependencies = [ "async-trait", "axum-core", @@ -440,16 +440,16 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 1.0.1", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", ] [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" dependencies = [ "async-trait", "bytes", @@ -460,7 +460,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", ] @@ -605,9 +605,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "bytestring" @@ -652,9 +652,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.20" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45bcde016d64c21da4be18b655631e5ab6d3107607e71a73a9f53eb48aae23fb" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" dependencies = [ "jobserver", "libc", @@ -713,9 +713,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -723,9 +723,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -735,9 +735,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -1119,9 +1119,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide", @@ -1238,18 +1238,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "getset" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f636605b743120a8d32ed92fc27b6cde1a769f8f936c065151eb66f88ded513c" -dependencies = [ - "proc-macro-error2", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "gimli" version = "0.31.0" @@ -1435,9 +1423,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -1448,7 +1436,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -1649,9 +1636,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libloading" @@ -1732,18 +1719,18 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "logos" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1ceb190eb9bdeecdd8f1ad6a71d6d632a50905948771718741b5461fb01e13" +checksum = "1c6b6e02facda28ca5fb8dbe4b152496ba3b1bd5a4b40bb2b1b2d8ad74e0f39b" dependencies = [ "logos-derive", ] [[package]] name = "logos-codegen" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90be66cb7bd40cb5cc2e9cfaf2d1133b04a3d93b72344267715010a466e0915a" +checksum = "b32eb6b5f26efacd015b000bfc562186472cd9b34bdba3f6b264e2a052676d10" dependencies = [ "beef", "fnv", @@ -1756,9 +1743,9 @@ dependencies = [ [[package]] name = "logos-derive" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45154231e8e96586b39494029e58f12f8ffcb5ecf80333a603a13aa205ea8cbd" +checksum = "3e5d0c5463c911ef55624739fc353238b4e310f0144be1f875dc42fec6bfd5ec" dependencies = [ "logos-codegen", ] @@ -1849,9 +1836,9 @@ dependencies = [ [[package]] name = "miden-crypto" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a69f8362ca496a79c88cf8e5b9b349bf9c6ed49fa867d0548e670afc1f3fca5" +checksum = "825fc5d2e4c951f45da54da2d0d23071918d966133f85dbc219694e0b9a1e141" dependencies = [ "blake3", "cc", @@ -1904,11 +1891,12 @@ dependencies = [ [[package]] name = "miden-lib" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#c1fe049db8c512d14b749a5a2e3b22001fd10b5a" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#c146bfd13484cbfd10b51d24845686b85b57fa21" dependencies = [ "miden-assembly", "miden-objects", "miden-stdlib", + "regex", ] [[package]] @@ -2097,7 +2085,7 @@ dependencies = [ [[package]] name = "miden-objects" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#c1fe049db8c512d14b749a5a2e3b22001fd10b5a" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#c146bfd13484cbfd10b51d24845686b85b57fa21" dependencies = [ "miden-assembly", "miden-core", @@ -2168,7 +2156,7 @@ dependencies = [ [[package]] name = "miden-tx" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#c1fe049db8c512d14b749a5a2e3b22001fd10b5a" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#c146bfd13484cbfd10b51d24845686b85b57fa21" dependencies = [ "miden-lib", "miden-objects", @@ -2568,9 +2556,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "powerfmt" @@ -2603,28 +2591,6 @@ dependencies = [ "syn", ] -[[package]] -name = "proc-macro-error-attr2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" -dependencies = [ - "proc-macro2", - "quote", -] - -[[package]] -name = "proc-macro-error2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" -dependencies = [ - "proc-macro-error-attr2", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -2669,9 +2635,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2ecbe40f08db5c006b5764a2645f7f3f141ce756412ac9e1dd6087e6d32995" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" dependencies = [ "bytes", "prost-derive", @@ -2679,9 +2645,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8650aabb6c35b860610e9cff5dc1af886c9e25073b7b1712a68972af4281302" +checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", "heck", @@ -2700,9 +2666,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", "itertools 0.13.0", @@ -2726,9 +2692,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60caa6738c7369b940c3d49246a8d1749323674c65cb13010134f5c9bad5b519" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" dependencies = [ "prost", ] @@ -2836,9 +2802,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" dependencies = [ "bitflags", ] @@ -3074,9 +3040,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -3320,18 +3286,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -3481,9 +3447,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap 2.5.0", "serde", @@ -3494,9 +3460,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", @@ -3516,7 +3482,7 @@ dependencies = [ "socket2", "tokio", "tokio-stream", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -3524,22 +3490,23 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4ee8877250136bd7e3d2331632810a4df4ea5e004656990d8d66d2f5ee8a67" +checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" dependencies = [ "prettyplease", "proc-macro2", "prost-build", + "prost-types", "quote", "syn", ] [[package]] name = "tonic-web" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b904b18f914fe88913a9f0d750065b39c9c497e4b2aa05148f2c29a724145541" +checksum = "5299dd20801ad736dccb4a5ea0da7376e59cd98f213bf1c3d478cf53f4834b58" dependencies = [ "base64", "bytes", @@ -3575,6 +3542,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-http" version = "0.5.2" @@ -3771,15 +3752,15 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "url" @@ -3812,14 +3793,13 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "9.0.0" +version = "9.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c32e7318e93a9ac53693b6caccfb05ff22e04a44c7cf8a279051f24c09da286f" +checksum = "349ed9e45296a581f455bc18039878f409992999bc1d5da12a6800eb18c8752f" dependencies = [ "anyhow", "cargo_metadata", "derive_builder", - "getset", "regex", "rustc_version 0.4.1", "rustversion", @@ -3828,9 +3808,9 @@ dependencies = [ [[package]] name = "vergen-gitcl" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bbdc9746577cb4767f218d320ee0b623d415e8130332f8f562b910b61cc2c4e" +checksum = "2a3a7f91caabecefc3c249fd864b11d4abe315c166fbdb568964421bccfd2b7a" dependencies = [ "anyhow", "derive_builder", @@ -3842,13 +3822,12 @@ dependencies = [ [[package]] name = "vergen-lib" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e06bee42361e43b60f363bad49d63798d0f42fb1768091812270eca00c784720" +checksum = "229eaddb0050920816cf051e619affaf18caa3dd512de8de5839ccbc8e53abb0" dependencies = [ "anyhow", "derive_builder", - "getset", "rustversion", ] @@ -4221,9 +4200,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -4266,9 +4245,9 @@ dependencies = [ [[package]] name = "winter-math" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "004f85bb051ce986ec0b9a2bd90aaf81b83e3c67464becfdf7db31f14c1019ba" +checksum = "5b0e685b3b872d82e58a86519294a814b7bc7a4d3cd2c93570a7d80c0c5a1aba" dependencies = [ "winter-utils", ] @@ -4321,9 +4300,9 @@ dependencies = [ [[package]] name = "winter-utils" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d71ec2c97685c7e7460a30e27f955d26b8426e7c2db0ddb55a6e0537141f53" +checksum = "961e81e9388877a25db1c034ba38253de2055f569633ae6a665d857a0556391b" dependencies = [ "rayon", ] diff --git a/crates/block-producer/src/batch_builder/batch.rs b/crates/block-producer/src/batch_builder/batch.rs index 8ab314e3b..e8a13fb36 100644 --- a/crates/block-producer/src/batch_builder/batch.rs +++ b/crates/block-producer/src/batch_builder/batch.rs @@ -10,7 +10,8 @@ use miden_objects::{ crypto::hash::blake::{Blake3Digest, Blake3_256}, notes::{NoteHeader, NoteId, Nullifier}, transaction::{InputNoteCommitment, OutputNote, TransactionId}, - AccountDeltaError, Digest, MAX_NOTES_PER_BATCH, + AccountDeltaError, Digest, MAX_ACCOUNTS_PER_BATCH, MAX_INPUT_NOTES_PER_BATCH, + MAX_OUTPUT_NOTES_PER_BATCH, }; use tracing::instrument; @@ -118,6 +119,10 @@ impl TransactionBatch { } } + if updated_accounts.len() > MAX_ACCOUNTS_PER_BATCH { + return Err(BuildBatchError::TooManyAccountsInBatch(txs)); + } + // Populate batch produced nullifiers and match output notes with corresponding // unauthenticated input notes in the same batch, which are removed from the unauthenticated // input notes set. @@ -150,9 +155,13 @@ impl TransactionBatch { input_notes.push(input_note) } + if input_notes.len() > MAX_INPUT_NOTES_PER_BATCH { + return Err(BuildBatchError::TooManyInputNotes(input_notes.len(), txs)); + } + let output_notes = output_notes.into_notes(); - if output_notes.len() > MAX_NOTES_PER_BATCH { + if output_notes.len() > MAX_OUTPUT_NOTES_PER_BATCH { return Err(BuildBatchError::TooManyNotesCreated(output_notes.len(), txs)); } diff --git a/crates/block-producer/src/batch_builder/tests/mod.rs b/crates/block-producer/src/batch_builder/tests/mod.rs index 651897fa8..1e0012f1c 100644 --- a/crates/block-producer/src/batch_builder/tests/mod.rs +++ b/crates/block-producer/src/batch_builder/tests/mod.rs @@ -303,12 +303,13 @@ async fn test_block_builder_fails_if_notes_are_missing() { let batch = TransactionBatch::new(txs.clone(), Default::default()).unwrap(); let build_block_result = batch_builder.block_builder.build_block(&[batch]).await; + + let mut expected_missing_notes = vec![notes[4].id(), notes[5].id()]; + expected_missing_notes.sort(); + assert_eq!( build_block_result, - Err(BuildBlockError::UnauthenticatedNotesNotFound(vec![ - notes[4].id(), - notes[5].id() - ])) + Err(BuildBlockError::UnauthenticatedNotesNotFound(expected_missing_notes)) ); } diff --git a/crates/block-producer/src/block_builder/prover/tests.rs b/crates/block-producer/src/block_builder/prover/tests.rs index 96959f4a8..09f98d787 100644 --- a/crates/block-producer/src/block_builder/prover/tests.rs +++ b/crates/block-producer/src/block_builder/prover/tests.rs @@ -43,7 +43,7 @@ fn test_block_witness_validation_inconsistent_account_ids() { let account_id_3 = AccountId::new_unchecked(Felt::new(ACCOUNT_ID_OFF_CHAIN_SENDER + 2)); let block_inputs_from_store: BlockInputs = { - let block_header = BlockHeader::mock(0, None, None, &[]); + let block_header = BlockHeader::mock(0, None, None, &[], Default::default()); let chain_peaks = MmrPeaks::new(0, Vec::new()).unwrap(); let accounts = BTreeMap::from_iter(vec![ @@ -107,7 +107,7 @@ fn test_block_witness_validation_inconsistent_account_hashes() { Digest::new([Felt::new(4u64), Felt::new(3u64), Felt::new(2u64), Felt::new(1u64)]); let block_inputs_from_store: BlockInputs = { - let block_header = BlockHeader::mock(0, None, None, &[]); + let block_header = BlockHeader::mock(0, None, None, &[], Default::default()); let chain_peaks = MmrPeaks::new(0, Vec::new()).unwrap(); let accounts = BTreeMap::from_iter(vec![ @@ -206,7 +206,7 @@ fn test_block_witness_multiple_batches_per_account() { )]); let block_inputs_from_store: BlockInputs = { - let block_header = BlockHeader::mock(0, None, None, &[]); + let block_header = BlockHeader::mock(0, None, None, &[], Default::default()); let chain_peaks = MmrPeaks::new(0, Vec::new()).unwrap(); let x_witness = AccountWitness { @@ -623,7 +623,7 @@ fn test_block_witness_validation_inconsistent_nullifiers() { Nullifier::from([101_u32.into(), 102_u32.into(), 103_u32.into(), 104_u32.into()]); let block_inputs_from_store: BlockInputs = { - let block_header = BlockHeader::mock(0, None, None, &[]); + let block_header = BlockHeader::mock(0, None, None, &[], Default::default()); let chain_peaks = MmrPeaks::new(0, Vec::new()).unwrap(); let accounts = batches diff --git a/crates/block-producer/src/errors.rs b/crates/block-producer/src/errors.rs index 6b32dc549..717a29268 100644 --- a/crates/block-producer/src/errors.rs +++ b/crates/block-producer/src/errors.rs @@ -5,7 +5,8 @@ use miden_objects::{ crypto::merkle::{MerkleError, MmrError}, notes::{NoteId, Nullifier}, transaction::{ProvenTransaction, TransactionId}, - AccountDeltaError, Digest, TransactionInputError, MAX_BATCHES_PER_BLOCK, MAX_NOTES_PER_BATCH, + AccountDeltaError, Digest, TransactionInputError, MAX_ACCOUNTS_PER_BATCH, + MAX_BATCHES_PER_BLOCK, MAX_INPUT_NOTES_PER_BATCH, MAX_OUTPUT_NOTES_PER_BATCH, }; use miden_processor::ExecutionError; use thiserror::Error; @@ -67,9 +68,25 @@ pub enum AddTransactionError { /// queue can re-queue them. #[derive(Debug, PartialEq, Eq, Error)] pub enum BuildBatchError { - #[error("Too many notes in the batch. Got: {0}, max: {}", MAX_NOTES_PER_BATCH)] + #[error( + "Too many input notes in the batch. Got: {0}, limit: {}", + MAX_INPUT_NOTES_PER_BATCH + )] + TooManyInputNotes(usize, Vec), + + #[error( + "Too many notes created in the batch. Got: {0}, limit: {}", + MAX_OUTPUT_NOTES_PER_BATCH + )] TooManyNotesCreated(usize, Vec), + #[error( + "Too many account updates in the batch. Got: {}, limit: {}", + .0.len(), + MAX_ACCOUNTS_PER_BATCH + )] + TooManyAccountsInBatch(Vec), + #[error("Failed to create notes SMT: {0}")] NotesSmtError(MerkleError, Vec), @@ -104,7 +121,9 @@ pub enum BuildBatchError { impl BuildBatchError { pub fn into_transactions(self) -> Vec { match self { + BuildBatchError::TooManyInputNotes(_, txs) => txs, BuildBatchError::TooManyNotesCreated(_, txs) => txs, + BuildBatchError::TooManyAccountsInBatch(txs) => txs, BuildBatchError::NotesSmtError(_, txs) => txs, BuildBatchError::NotePathsError(_, txs) => txs, BuildBatchError::DuplicateUnauthenticatedNote(_, txs) => txs, diff --git a/crates/block-producer/src/server/mod.rs b/crates/block-producer/src/server/mod.rs index 46a19f925..e81471804 100644 --- a/crates/block-producer/src/server/mod.rs +++ b/crates/block-producer/src/server/mod.rs @@ -28,9 +28,11 @@ type Api = api::BlockProducerApi< >; /// Represents an initialized block-producer component where the RPC connection is open, -/// but not yet actively responding to requests. Separating the connection binding -/// from the server spawning allows the caller to connect other components to the -/// store without resorting to sleeps or other mechanisms to spawn dependent components. +/// but not yet actively responding to requests. +/// +/// Separating the connection binding from the server spawning allows the caller to connect other +/// components to the store without resorting to sleeps or other mechanisms to spawn dependent +/// components. pub struct BlockProducer { api_service: api_server::ApiServer, listener: TcpListener, diff --git a/crates/block-producer/src/txqueue/mod.rs b/crates/block-producer/src/txqueue/mod.rs index a4c10d4e8..5f5f724c5 100644 --- a/crates/block-producer/src/txqueue/mod.rs +++ b/crates/block-producer/src/txqueue/mod.rs @@ -1,7 +1,7 @@ use std::{sync::Arc, time::Duration}; use async_trait::async_trait; -use miden_objects::MAX_NOTES_PER_BATCH; +use miden_objects::MAX_OUTPUT_NOTES_PER_BATCH; use tokio::{sync::RwLock, time}; use tracing::{debug, info, info_span, instrument, Instrument}; @@ -99,17 +99,19 @@ where while !txs.is_empty() { let mut batch = Vec::with_capacity(self.options.batch_size); - let mut notes_in_batch = 0; + let mut output_notes_in_batch = 0; while let Some(tx) = txs.pop() { - notes_in_batch += tx.output_notes().num_notes(); + output_notes_in_batch += tx.output_notes().num_notes(); debug_assert!( - tx.output_notes().num_notes() <= MAX_NOTES_PER_BATCH, + tx.output_notes().num_notes() <= MAX_OUTPUT_NOTES_PER_BATCH, "Sanity check, the number of output notes of a single transaction must never be larger than the batch maximum", ); - if notes_in_batch > MAX_NOTES_PER_BATCH || batch.len() == self.options.batch_size { + if output_notes_in_batch > MAX_OUTPUT_NOTES_PER_BATCH + || batch.len() == self.options.batch_size + { // Batch would be too big in number of notes or transactions. Push the tx back // to the list of available transactions and forward the current batch. txs.push(tx); diff --git a/crates/proto/build.rs b/crates/proto/build.rs index e08074c4a..5f9c13384 100644 --- a/crates/proto/build.rs +++ b/crates/proto/build.rs @@ -59,7 +59,7 @@ fn main() -> miette::Result<()> { .file_descriptor_set_path(&file_descriptor_path) .skip_protoc_run() .out_dir(&dst_dir) - .compile_with_config(prost_config, protos, includes) + .compile_protos_with_config(prost_config, protos, includes) .into_diagnostic()?; generate_mod_rs(&dst_dir).into_diagnostic()?; diff --git a/crates/proto/src/generated/block_producer.rs b/crates/proto/src/generated/block_producer.rs index 362af881b..fefbd4351 100644 --- a/crates/proto/src/generated/block_producer.rs +++ b/crates/proto/src/generated/block_producer.rs @@ -1,7 +1,13 @@ // This file is @generated by prost-build. /// Generated client implementations. pub mod api_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; use tonic::codegen::http::Uri; #[derive(Debug, Clone)] @@ -97,8 +103,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -117,7 +122,13 @@ pub mod api_client { } /// Generated server implementations. pub mod api_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with ApiServer. #[async_trait] @@ -258,17 +269,19 @@ pub mod api_server { } _ => { Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", tonic::Code::Unimplemented as i32) - .header( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ) - .body(empty_body()) - .unwrap(), - ) + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) }) } } diff --git a/crates/proto/src/generated/rpc.rs b/crates/proto/src/generated/rpc.rs index 3f35dceb2..d1840c5f3 100644 --- a/crates/proto/src/generated/rpc.rs +++ b/crates/proto/src/generated/rpc.rs @@ -1,7 +1,13 @@ // This file is @generated by prost-build. /// Generated client implementations. pub mod api_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; use tonic::codegen::http::Uri; #[derive(Debug, Clone)] @@ -97,8 +103,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -121,8 +126,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -148,8 +152,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -174,8 +177,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -201,8 +203,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -225,8 +226,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -250,8 +250,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -274,8 +273,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -299,8 +297,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -321,8 +318,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -336,7 +332,13 @@ pub mod api_client { } /// Generated server implementations. pub mod api_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with ApiServer. #[async_trait] @@ -978,17 +980,19 @@ pub mod api_server { } _ => { Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", tonic::Code::Unimplemented as i32) - .header( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ) - .body(empty_body()) - .unwrap(), - ) + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) }) } } diff --git a/crates/proto/src/generated/store.rs b/crates/proto/src/generated/store.rs index 6d32c3219..66c49e9d9 100644 --- a/crates/proto/src/generated/store.rs +++ b/crates/proto/src/generated/store.rs @@ -1,7 +1,13 @@ // This file is @generated by prost-build. /// Generated client implementations. pub mod api_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; use tonic::codegen::http::Uri; #[derive(Debug, Clone)] @@ -95,8 +101,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -119,8 +124,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -145,8 +149,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -172,8 +175,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -199,8 +201,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -226,8 +227,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -253,8 +253,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -280,8 +279,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -304,8 +302,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -329,8 +326,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -353,8 +349,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -378,8 +373,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -400,8 +394,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -424,8 +417,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -446,8 +438,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -468,8 +459,7 @@ pub mod api_client { .ready() .await .map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, + tonic::Status::unknown( format!("Service was not ready: {}", e.into()), ) })?; @@ -483,7 +473,13 @@ pub mod api_client { } /// Generated server implementations. pub mod api_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with ApiServer. #[async_trait] @@ -1456,17 +1452,19 @@ pub mod api_server { } _ => { Box::pin(async move { - Ok( - http::Response::builder() - .status(200) - .header("grpc-status", tonic::Code::Unimplemented as i32) - .header( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ) - .body(empty_body()) - .unwrap(), - ) + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) }) } } diff --git a/crates/rpc/src/server/mod.rs b/crates/rpc/src/server/mod.rs index 9745f7378..dcef246b7 100644 --- a/crates/rpc/src/server/mod.rs +++ b/crates/rpc/src/server/mod.rs @@ -11,10 +11,12 @@ use crate::{config::RpcConfig, COMPONENT}; mod api; -/// Represents an initialized rpc component where the RPC connection is open, -/// but not yet actively responding to requests. Separating the connection binding -/// from the server spawning allows the caller to connect other components to the -/// store without resorting to sleeps or other mechanisms to spawn dependent components. +/// Represents an initialized rpc component where the RPC connection is open, but not yet actively +/// responding to requests. +/// +/// Separating the connection binding from the server spawning allows the caller to connect other +/// components to the store without resorting to sleeps or other mechanisms to spawn dependent +/// components. pub struct Rpc { api_service: api_server::ApiServer, listener: TcpListener, diff --git a/crates/store/src/server/mod.rs b/crates/store/src/server/mod.rs index 0c912193b..f73c9e9fe 100644 --- a/crates/store/src/server/mod.rs +++ b/crates/store/src/server/mod.rs @@ -10,10 +10,12 @@ use crate::{blocks::BlockStore, config::StoreConfig, db::Db, state::State, COMPO mod api; -/// Represents an initialized store component where the RPC connection is open, -/// but not yet actively responding to requests. Separating the connection binding -/// from the server spawning allows the caller to connect other components to the -/// store without resorting to sleeps or other mechanisms to spawn dependent components. +/// Represents an initialized store component where the RPC connection is open, but not yet actively +/// responding to requests. +/// +/// Separating the connection binding from the server spawning allows the caller to connect other +/// components to the store without resorting to sleeps or other mechanisms to spawn dependent +/// components. pub struct Store { api_service: api_server::ApiServer, listener: TcpListener,