From 573f37b0fd7cd572889cdf2ce20623495e421f3f Mon Sep 17 00:00:00 2001 From: Mirko <48352201+Mirko-von-Leipzig@users.noreply.github.com> Date: Sat, 2 Nov 2024 19:14:47 +0200 Subject: [PATCH 01/10] chore: re-enable blocks_in_conditions lint (#539) Clippy issue https://github.com/rust-lang/rust-clippy/issues/12281 was fixed in v1.81. We now have MSRV of 1.82 allowing us to remove our workaround. More specifically, #[async_trait] was triggering this lint, and as of 1.81 no longer does. --- crates/block-producer/src/batch_builder/mod.rs | 6 ------ crates/block-producer/src/block_builder/mod.rs | 3 --- crates/block-producer/src/server/api.rs | 3 --- crates/block-producer/src/state_view/mod.rs | 6 ------ crates/block-producer/src/store/mod.rs | 6 ------ crates/rpc/src/server/api.rs | 3 --- crates/store/src/server/api.rs | 3 --- 7 files changed, 30 deletions(-) diff --git a/crates/block-producer/src/batch_builder/mod.rs b/crates/block-producer/src/batch_builder/mod.rs index 513321f7e..8151b1442 100644 --- a/crates/block-producer/src/batch_builder/mod.rs +++ b/crates/block-producer/src/batch_builder/mod.rs @@ -57,9 +57,6 @@ pub struct DefaultBatchBuilder { ready_batches: SharedRwVec, } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] impl DefaultBatchBuilder where S: Store, @@ -146,9 +143,6 @@ where } } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] #[async_trait] impl BatchBuilder for DefaultBatchBuilder where diff --git a/crates/block-producer/src/block_builder/mod.rs b/crates/block-producer/src/block_builder/mod.rs index 0522d1140..0d120801f 100644 --- a/crates/block-producer/src/block_builder/mod.rs +++ b/crates/block-producer/src/block_builder/mod.rs @@ -58,9 +58,6 @@ where } } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] #[async_trait] impl BlockBuilder for DefaultBlockBuilder where diff --git a/crates/block-producer/src/server/api.rs b/crates/block-producer/src/server/api.rs index 8a917242e..22405feda 100644 --- a/crates/block-producer/src/server/api.rs +++ b/crates/block-producer/src/server/api.rs @@ -28,9 +28,6 @@ impl BlockProducerApi { } } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] #[tonic::async_trait] impl api_server::Api for BlockProducerApi where diff --git a/crates/block-producer/src/state_view/mod.rs b/crates/block-producer/src/state_view/mod.rs index f0bcf1b93..7fb69faff 100644 --- a/crates/block-producer/src/state_view/mod.rs +++ b/crates/block-producer/src/state_view/mod.rs @@ -56,9 +56,6 @@ where } } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] #[async_trait] impl TransactionValidator for DefaultStateView where @@ -136,9 +133,6 @@ where } } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] #[async_trait] impl ApplyBlock for DefaultStateView where diff --git a/crates/block-producer/src/store/mod.rs b/crates/block-producer/src/store/mod.rs index 8c06005a1..57e4f88f7 100644 --- a/crates/block-producer/src/store/mod.rs +++ b/crates/block-producer/src/store/mod.rs @@ -165,9 +165,6 @@ impl DefaultStore { } } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] #[async_trait] impl ApplyBlock for DefaultStore { #[instrument(target = "miden-block-producer", skip_all, err)] @@ -185,9 +182,6 @@ impl ApplyBlock for DefaultStore { } } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] #[async_trait] impl Store for DefaultStore { #[instrument(target = "miden-block-producer", skip_all, err)] diff --git a/crates/rpc/src/server/api.rs b/crates/rpc/src/server/api.rs index 5c25bd480..56f97c788 100644 --- a/crates/rpc/src/server/api.rs +++ b/crates/rpc/src/server/api.rs @@ -56,9 +56,6 @@ impl RpcApi { } } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] #[tonic::async_trait] impl api_server::Api for RpcApi { #[instrument( diff --git a/crates/store/src/server/api.rs b/crates/store/src/server/api.rs index 51cb21ef4..bd741575c 100644 --- a/crates/store/src/server/api.rs +++ b/crates/store/src/server/api.rs @@ -50,9 +50,6 @@ pub struct StoreApi { pub(super) state: Arc, } -// FIXME: remove the allow when the upstream clippy issue is fixed: -// https://github.com/rust-lang/rust-clippy/issues/12281 -#[allow(clippy::blocks_in_conditions)] #[tonic::async_trait] impl api_server::Api for StoreApi { // CLIENT ENDPOINTS From 1a380357890ce5066c0b47579b30bf03e2e40fec Mon Sep 17 00:00:00 2001 From: Bobbin Threadbare Date: Mon, 4 Nov 2024 22:47:29 -0800 Subject: [PATCH 02/10] chore: point miden-vm dependency to crates.io versions (v0.11) --- Cargo.lock | 162 ++++++++++++++++--------------- Cargo.toml | 6 +- crates/block-producer/Cargo.toml | 2 +- crates/store/src/db/tests.rs | 50 ++++++---- 4 files changed, 119 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67049c24b..f3bdaec30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,9 +55,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -70,9 +70,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" [[package]] name = "arrayref" @@ -395,9 +395,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" dependencies = [ "jobserver", "libc", @@ -912,8 +912,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -964,9 +966,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "hashlink" @@ -1064,9 +1066,9 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ "hyper", "hyper-util", @@ -1146,7 +1148,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", ] [[package]] @@ -1284,9 +1286,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00419de735aac21d53b0de5ce2c03bd3627277cf471300f27ebc89f7d828047" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libredox" @@ -1401,8 +1403,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miden-air" -version = "0.10.5" -source = "git+https://github.com/0xPolygonMiden/miden-vm.git?branch=next#9f9cc63b709d8b7c83841d8e421701dcd33792bb" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea00ea451d1547978817a37c1904ff34f4a24de2c23f9b77b282a0bc570ac3f1" dependencies = [ "miden-core", "miden-thiserror", @@ -1412,8 +1415,9 @@ dependencies = [ [[package]] name = "miden-assembly" -version = "0.10.5" -source = "git+https://github.com/0xPolygonMiden/miden-vm.git?branch=next#9f9cc63b709d8b7c83841d8e421701dcd33792bb" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58925d5ab3d625b8e828267a64dd555b1fe37cd5a1d89d09224920d3255de5a9" dependencies = [ "aho-corasick", "lalrpop", @@ -1424,13 +1428,14 @@ dependencies = [ "rustc_version 0.4.1", "smallvec", "tracing", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] name = "miden-core" -version = "0.10.5" -source = "git+https://github.com/0xPolygonMiden/miden-vm.git?branch=next#9f9cc63b709d8b7c83841d8e421701dcd33792bb" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba2f0ffd0362c91c0eedba391a3c17a8047389e15020ec95b0d7e840375bf03" dependencies = [ "lock_api", "loom", @@ -1448,9 +1453,9 @@ dependencies = [ [[package]] name = "miden-crypto" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0ca714c8242f329b9ea6f1a5bf0e93f1490f348f982e3a606d91b884254308" +checksum = "f50a68deed96cde1f51eb623f75828e320f699e0d798f11592f8958ba8b512c3" dependencies = [ "blake3", "cc", @@ -1500,13 +1505,13 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e392e0a8c34b32671012b439de35fa8987bf14f0f8aac279b97f8b8cc6e263b" dependencies = [ - "unicode-width", + "unicode-width 0.1.14", ] [[package]] name = "miden-lib" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#b624d0810b1b3813f106aa38b796b9d62a39265d" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#ff3c5227c5962cc97cd44562f134b0a545be21cc" dependencies = [ "miden-assembly", "miden-objects", @@ -1542,7 +1547,7 @@ dependencies = [ "terminal_size", "textwrap", "trybuild", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -1702,8 +1707,9 @@ dependencies = [ [[package]] name = "miden-objects" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#b624d0810b1b3813f106aa38b796b9d62a39265d" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#ff3c5227c5962cc97cd44562f134b0a545be21cc" dependencies = [ + "getrandom", "miden-assembly", "miden-core", "miden-crypto", @@ -1715,8 +1721,9 @@ dependencies = [ [[package]] name = "miden-processor" -version = "0.10.6" -source = "git+https://github.com/0xPolygonMiden/miden-vm.git?branch=next#9f9cc63b709d8b7c83841d8e421701dcd33792bb" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e1a756be679bfe2bdb209b9f4f12b4b59e8cac7c9f884ad90535b32bbd75923" dependencies = [ "miden-air", "miden-core", @@ -1726,12 +1733,14 @@ dependencies = [ [[package]] name = "miden-prover" -version = "0.10.5" -source = "git+https://github.com/0xPolygonMiden/miden-vm.git?branch=next#9f9cc63b709d8b7c83841d8e421701dcd33792bb" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b6c2fc7ed9831493e1c18fb9d15a4b780ec624e9192f494ad3900c19bfe5b17" dependencies = [ "miden-air", "miden-processor", "tracing", + "winter-maybe-async", "winter-prover", ] @@ -1741,8 +1750,9 @@ version = "0.6.0" [[package]] name = "miden-stdlib" -version = "0.10.5" -source = "git+https://github.com/0xPolygonMiden/miden-vm.git?branch=next#9f9cc63b709d8b7c83841d8e421701dcd33792bb" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09948fda011d044273d1bbc56669da410ee3167f96bf1ad9885c946cfbed5757" dependencies = [ "miden-assembly", ] @@ -1770,7 +1780,7 @@ dependencies = [ [[package]] name = "miden-tx" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#b624d0810b1b3813f106aa38b796b9d62a39265d" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#ff3c5227c5962cc97cd44562f134b0a545be21cc" dependencies = [ "async-trait", "miden-assembly", @@ -1783,13 +1793,14 @@ dependencies = [ "rand_chacha", "regex", "walkdir", - "winter-maybe-async 0.10.1", + "winter-maybe-async", ] [[package]] name = "miden-verifier" -version = "0.10.5" -source = "git+https://github.com/0xPolygonMiden/miden-vm.git?branch=next#9f9cc63b709d8b7c83841d8e421701dcd33792bb" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "636b2eab9dc0a9fdd6d30d9ece3cf276b012e9ecbccd934d4c0befa07c84cfd0" dependencies = [ "miden-air", "miden-core", @@ -1814,7 +1825,7 @@ dependencies = [ "terminal_size", "textwrap", "thiserror", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -2530,9 +2541,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" dependencies = [ "bitflags", "errno", @@ -2803,9 +2814,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -2881,23 +2892,23 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", "unicode-linebreak", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] name = "thiserror" -version = "1.0.65" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.65" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ "proc-macro2", "quote", @@ -3340,6 +3351,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -3782,9 +3799,9 @@ dependencies = [ [[package]] name = "winter-air" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72f12b88ebb060b52c0e9aece9bb64a9fc38daf7ba689dd5ce63271b456c883" +checksum = "29bec0b06b741543f43e3a6677b95b200d4cad2daab76e6721e14345345bfd0e" dependencies = [ "libm", "winter-crypto", @@ -3795,9 +3812,9 @@ dependencies = [ [[package]] name = "winter-crypto" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00fbb724d2d9fbfd3aa16ea27f5e461d4fe1d74b0c9e0ed1bf79e9e2a955f4d5" +checksum = "163da45f1d4d65cac361b8df4835a6daa95b3399154e16eb0305c178c6f6c1f4" dependencies = [ "blake3", "sha3", @@ -3807,9 +3824,9 @@ dependencies = [ [[package]] name = "winter-fri" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab6077cf4c23c0411f591f4ba29378e27f26acb8cef3c51cadd93daaf6080b3" +checksum = "3b7b394670d68979a4cc21a37a95ef8ef350cf84be9256c53effe3052df50d26" dependencies = [ "winter-crypto", "winter-math", @@ -3818,24 +3835,13 @@ dependencies = [ [[package]] name = "winter-math" -version = "0.9.3" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0e685b3b872d82e58a86519294a814b7bc7a4d3cd2c93570a7d80c0c5a1aba" +checksum = "5a8ba832121679e79b004b0003018c85873956d742a39c348c247f680fe15e00" dependencies = [ "winter-utils", ] -[[package]] -name = "winter-maybe-async" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ce0f4161cdde50de809b3869c1cb083a09e92e949428ea28f04c0d64045875c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "winter-maybe-async" version = "0.10.1" @@ -3848,24 +3854,24 @@ dependencies = [ [[package]] name = "winter-prover" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17e3dbae97050f58e01ed4f12906e247841575a0518632e052941a1c37468df" +checksum = "2f55f0153d26691caaf969066a13a824bcf3c98719d71b0f569bf8dc40a06fb9" dependencies = [ "tracing", "winter-air", "winter-crypto", "winter-fri", "winter-math", - "winter-maybe-async 0.9.0", + "winter-maybe-async", "winter-utils", ] [[package]] name = "winter-rand-utils" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b827c901ab0c316d89812858ff451d60855c0a5c7ae734b098c62a28624181" +checksum = "4a7616d11fcc26552dada45c803a884ac97c253218835b83a2c63e1c2a988639" dependencies = [ "rand", "winter-utils", @@ -3873,18 +3879,18 @@ dependencies = [ [[package]] name = "winter-utils" -version = "0.9.3" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "961e81e9388877a25db1c034ba38253de2055f569633ae6a665d857a0556391b" +checksum = "76b116c8ade0172506f8bda32dc674cf6b230adc8516e5138a0173ae69158a4f" dependencies = [ "rayon", ] [[package]] name = "winter-verifier" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324002ade90f21e85599d51a232a80781efc8cb46f511f8bc89f9c5a4eb9cb65" +checksum = "2ae1648768f96f5e6321a48a5bff5cc3101d2e51b23a6a095c6c9c9e133ecb61" dependencies = [ "winter-air", "winter-crypto", @@ -3895,9 +3901,9 @@ dependencies = [ [[package]] name = "winterfell" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01151ac5fe2d783950743e8a110e0a2f26994f888b4cbe848699142cb3ea1e5b" +checksum = "39c8336dc6a035698780b8cc624f875e479bd6bf6e1846670f3ef4485c125882" dependencies = [ "winter-air", "winter-prover", diff --git a/Cargo.toml b/Cargo.toml index 9e0d53b99..bcd59f59d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ exclude = [".github/"] readme = "README.md" [workspace.dependencies] -miden-air = { git = "https://github.com/0xPolygonMiden/miden-vm.git", branch = "next" } +miden-air = { version = "0.11" } miden-lib = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" } miden-node-block-producer = { path = "crates/block-producer", version = "0.6" } miden-node-faucet = { path = "bin/faucet", version = "0.6" } @@ -36,8 +36,8 @@ miden-node-store = { path = "crates/store", version = "0.6" } miden-node-test-macro = { path = "crates/test-macro" } miden-node-utils = { path = "crates/utils", version = "0.6" } miden-objects = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" } -miden-processor = { git = "https://github.com/0xPolygonMiden/miden-vm.git", branch = "next" } -miden-stdlib = { git = "https://github.com/0xPolygonMiden/miden-vm.git", branch = "next", default-features = false } +miden-processor = { version = "0.11" } +miden-stdlib = { version = "0.11", default-features = false } miden-tx = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" } prost = { version = "0.13" } rand = { version = "0.8" } diff --git a/crates/block-producer/Cargo.toml b/crates/block-producer/Cargo.toml index 1d1476fdf..ea6f32116 100644 --- a/crates/block-producer/Cargo.toml +++ b/crates/block-producer/Cargo.toml @@ -43,4 +43,4 @@ miden-objects = { workspace = true, features = ["testing"] } miden-tx = { workspace = true, features = ["testing"] } rand_chacha = { version = "0.3", default-features = false } tokio = { workspace = true, features = ["test-util"] } -winterfell = { version = "0.9" } +winterfell = { version = "0.10" } diff --git a/crates/store/src/db/tests.rs b/crates/store/src/db/tests.rs index a79166003..a63f982f4 100644 --- a/crates/store/src/db/tests.rs +++ b/crates/store/src/db/tests.rs @@ -8,8 +8,8 @@ use miden_objects::{ ACCOUNT_ID_REGULAR_ACCOUNT_UPDATABLE_CODE_OFF_CHAIN, }, delta::AccountUpdateDetails, - Account, AccountCode, AccountDelta, AccountId, AccountStorage, AccountStorageDelta, - AccountVaultDelta, StorageSlot, + Account, AccountCode, AccountComponent, AccountDelta, AccountId, AccountStorage, + AccountStorageDelta, AccountType, AccountVaultDelta, StorageSlot, }, assets::{Asset, AssetVault, FungibleAsset, NonFungibleAsset, NonFungibleAssetDetails}, block::{BlockAccountUpdate, BlockNoteIndex, BlockNoteTree}, @@ -334,14 +334,6 @@ fn test_sql_public_account_details() { let non_fungible_faucet_id = AccountId::try_from(ACCOUNT_ID_NON_FUNGIBLE_FAUCET_ON_CHAIN).unwrap(); - let mut storage = AccountStorage::new( - std::iter::repeat(StorageSlot::Value(Word::default())).take(6).collect(), - ) - .unwrap(); - storage.set_item(1, num_to_word(1)).unwrap(); - storage.set_item(3, num_to_word(3)).unwrap(); - storage.set_item(5, num_to_word(5)).unwrap(); - let nft1 = Asset::NonFungible( NonFungibleAsset::new( &NonFungibleAssetDetails::new(non_fungible_faucet_id, vec![1, 2, 3]).unwrap(), @@ -349,6 +341,8 @@ fn test_sql_public_account_details() { .unwrap(), ); + let (code, storage) = mock_account_code_and_storage(account_id.account_type()); + let mut account = Account::from_parts( account_id, AssetVault::new(&[ @@ -357,7 +351,7 @@ fn test_sql_public_account_details() { ]) .unwrap(), storage, - mock_account_code(), + code, ZERO, ); @@ -983,12 +977,30 @@ fn insert_transactions(conn: &mut Connection) -> usize { count } -pub fn mock_account_code() -> AccountCode { - let account_code = "\ - export.account_procedure_1 - push.1.2 - add - end - "; - AccountCode::compile(account_code, TransactionKernel::assembler(), false).unwrap() +fn mock_account_code_and_storage(account_type: AccountType) -> (AccountCode, AccountStorage) { + let component_code = "\ + export.account_procedure_1 + push.1.2 + add + end + "; + + let component_storage = vec![ + StorageSlot::Value(Word::default()), + StorageSlot::Value(num_to_word(1)), + StorageSlot::Value(Word::default()), + StorageSlot::Value(num_to_word(3)), + StorageSlot::Value(Word::default()), + StorageSlot::Value(num_to_word(5)), + ]; + + let component = AccountComponent::compile( + component_code, + TransactionKernel::testing_assembler(), + component_storage, + ) + .unwrap() + .with_supported_type(account_type); + + Account::initialize_from_components(account_type, &[component]).unwrap() } From 8865f4c4e3bf58b7754f608f8fa9c9ec82e13d51 Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:01:27 +0500 Subject: [PATCH 03/10] refactor(node): improve `ApplyBlockError` variants in the store (#535) * refactor: improve `ApplyBlockErrors` variants * docs: update `CHANGELOG.md` * refactor: address review comments --- CHANGELOG.md | 1 + crates/store/src/db/mod.rs | 4 +- crates/store/src/db/sql.rs | 4 +- crates/store/src/errors.rs | 147 +++++++++++++++++++-------------- crates/store/src/server/api.rs | 3 +- crates/store/src/state.rs | 43 ++++++---- 6 files changed, 117 insertions(+), 85 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed2ecf837..8f5a7ef48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - [BREAKING] Migrated to v0.11 version of Miden VM (#528). - Reduce cloning in the store's `apply_block` (#532). - [BREAKING] Changed faucet storage type in the genesis to public. Using faucet from the genesis for faucet web app. Added support for faucet restarting without blockchain restarting (#517). +- [BREAKING] Improved `ApplyBlockError` in the store (#535). ## 0.5.1 (2024-09-12) diff --git a/crates/store/src/db/mod.rs b/crates/store/src/db/mod.rs index 6e04e67b1..45c462cf4 100644 --- a/crates/store/src/db/mod.rs +++ b/crates/store/src/db/mod.rs @@ -443,9 +443,7 @@ impl Db { )?; let _ = allow_acquire.send(()); - acquire_done - .blocking_recv() - .map_err(DatabaseError::ApplyBlockFailedClosedChannel)?; + acquire_done.blocking_recv()?; transaction.commit()?; diff --git a/crates/store/src/db/sql.rs b/crates/store/src/db/sql.rs index 9980f40dd..8320f0db4 100644 --- a/crates/store/src/db/sql.rs +++ b/crates/store/src/db/sql.rs @@ -254,7 +254,7 @@ pub fn upsert_accounts( debug_assert_eq!(account_id, u64::from(account.id())); if account.hash() != update.new_state_hash() { - return Err(DatabaseError::ApplyBlockFailedAccountHashesMismatch { + return Err(DatabaseError::AccountHashesMismatch { calculated: account.hash(), expected: update.new_state_hash(), }); @@ -1151,7 +1151,7 @@ fn apply_delta( let actual_hash = account.hash(); if &actual_hash != final_state_hash { - return Err(DatabaseError::ApplyBlockFailedAccountHashesMismatch { + return Err(DatabaseError::AccountHashesMismatch { calculated: actual_hash, expected: *final_state_hash, }); diff --git a/crates/store/src/errors.rs b/crates/store/src/errors.rs index 700c9d3c5..bb563c36a 100644 --- a/crates/store/src/errors.rs +++ b/crates/store/src/errors.rs @@ -37,50 +37,56 @@ pub enum NullifierTreeError { #[derive(Debug, Error)] pub enum DatabaseError { - #[error("Missing database connection: {0}")] - MissingDbConnection(#[from] PoolError), - #[error("SQLite error: {0}")] - SqliteError(#[from] rusqlite::Error), - #[error("SQLite error: {0}")] - FromSqlError(#[from] FromSqlError), - #[error("Hex parsing error: {0}")] - FromHexError(#[from] hex::FromHexError), - #[error("I/O error: {0}")] - IoError(#[from] io::Error), + // ERRORS WITH AUTOMATIC CONVERSIONS FROM NESTED ERROR TYPES + // --------------------------------------------------------------------------------------------- #[error("Account error: {0}")] AccountError(#[from] AccountError), - #[error("Block error: {0}")] - BlockError(#[from] BlockError), - #[error("Note error: {0}")] - NoteError(#[from] NoteError), - #[error("Migration error: {0}")] - MigrationError(#[from] rusqlite_migration::Error), #[error("Account delta error: {0}")] AccountDeltaError(#[from] AccountDeltaError), - #[error("SQLite pool interaction task failed: {0}")] - InteractError(String), + #[error("Block error: {0}")] + BlockError(#[from] BlockError), + #[error("Closed channel: {0}")] + ClosedChannel(#[from] RecvError), #[error("Deserialization of BLOB data from database failed: {0}")] DeserializationError(DeserializationError), - #[error("Invalid Felt: {0}")] - InvalidFelt(String), - #[error("Block applying was broken because of closed channel on state side: {0}")] - ApplyBlockFailedClosedChannel(RecvError), + #[error("Hex parsing error: {0}")] + FromHexError(#[from] hex::FromHexError), + #[error("SQLite error: {0}")] + FromSqlError(#[from] FromSqlError), + #[error("I/O error: {0}")] + IoError(#[from] io::Error), + #[error("Migration error: {0}")] + MigrationError(#[from] rusqlite_migration::Error), + #[error("Missing database connection: {0}")] + MissingDbConnection(#[from] PoolError), + #[error("Note error: {0}")] + NoteError(#[from] NoteError), + #[error("SQLite error: {0}")] + SqliteError(#[from] rusqlite::Error), + + // OTHER ERRORS + // --------------------------------------------------------------------------------------------- + #[error("Account hashes mismatch (expected {expected}, but calculated is {calculated})")] + AccountHashesMismatch { + expected: RpoDigest, + calculated: RpoDigest, + }, #[error("Account {0} not found in the database")] AccountNotFoundInDb(AccountId), #[error("Accounts {0:?} not found in the database")] AccountsNotFoundInDb(Vec), #[error("Account {0} is not on the chain")] AccountNotOnChain(AccountId), - #[error("Failed to apply block because of public account final hashes mismatch (expected {expected}, \ - but calculated is {calculated}")] - ApplyBlockFailedAccountHashesMismatch { - expected: RpoDigest, - calculated: RpoDigest, - }, #[error("Block {0} not found in the database")] BlockNotFoundInDb(BlockNumber), - #[error("Unsupported database version. There is no migration chain from/to this version. Remove database files \ - and try again.")] + #[error("SQLite pool interaction task failed: {0}")] + InteractError(String), + #[error("Invalid Felt: {0}")] + InvalidFelt(String), + #[error( + "Unsupported database version. There is no migration chain from/to this version. \ + Remove all database files and try again." + )] UnsupportedDatabaseVersion, } @@ -132,12 +138,17 @@ pub enum DatabaseSetupError { #[derive(Debug, Error)] pub enum GenesisError { + // ERRORS WITH AUTOMATIC CONVERSIONS FROM NESTED ERROR TYPES + // --------------------------------------------------------------------------------------------- #[error("Database error: {0}")] DatabaseError(#[from] DatabaseError), #[error("Block error: {0}")] BlockError(#[from] BlockError), #[error("Merkle error: {0}")] MerkleError(#[from] MerkleError), + + // OTHER ERRORS + // --------------------------------------------------------------------------------------------- #[error("Apply block failed: {0}")] ApplyBlockFailed(String), #[error("Failed to read genesis file \"{genesis_filepath}\": {error}")] @@ -145,58 +156,74 @@ pub enum GenesisError { genesis_filepath: String, error: io::Error, }, - #[error("Failed to deserialize genesis file: {0}")] - GenesisFileDeserializationError(DeserializationError), #[error("Block header in store doesn't match block header in genesis file. Expected {expected_genesis_header:?}, but store contained {block_header_in_store:?}")] GenesisBlockHeaderMismatch { expected_genesis_header: Box, block_header_in_store: Box, }, + #[error("Failed to deserialize genesis file: {0}")] + GenesisFileDeserializationError(DeserializationError), #[error("Retrieving genesis block header failed: {0}")] SelectBlockHeaderByBlockNumError(Box), } // ENDPOINT ERRORS // ================================================================================================= +#[derive(Error, Debug)] +pub enum InvalidBlockError { + #[error("Duplicated nullifiers {0:?}")] + DuplicatedNullifiers(Vec), + #[error("Invalid output note type: {0:?}")] + InvalidOutputNoteType(Box), + #[error("Invalid tx hash: expected {expected}, but got {actual}")] + InvalidTxHash { expected: RpoDigest, actual: RpoDigest }, + #[error("Received invalid account tree root")] + NewBlockInvalidAccountRoot, + #[error("New block number must be 1 greater than the current block number")] + NewBlockInvalidBlockNum, + #[error("New block chain root is not consistent with chain MMR")] + NewBlockInvalidChainRoot, + #[error("Received invalid note root")] + NewBlockInvalidNoteRoot, + #[error("Received invalid nullifier root")] + NewBlockInvalidNullifierRoot, + #[error("New block `prev_hash` must match the chain's tip")] + NewBlockInvalidPrevHash, +} #[derive(Error, Debug)] pub enum ApplyBlockError { + // ERRORS WITH AUTOMATIC CONVERSIONS FROM NESTED ERROR TYPES + // --------------------------------------------------------------------------------------------- #[error("Database error: {0}")] DatabaseError(#[from] DatabaseError), #[error("I/O error: {0}")] IoError(#[from] io::Error), #[error("Task join error: {0}")] TokioJoinError(#[from] tokio::task::JoinError), + #[error("Invalid block error: {0}")] + InvalidBlockError(#[from] InvalidBlockError), + + // OTHER ERRORS + // --------------------------------------------------------------------------------------------- + #[error("Block applying was cancelled because of closed channel on database side: {0}")] + ClosedChannel(RecvError), #[error("Concurrent write detected")] ConcurrentWrite, - #[error("New block number must be 1 greater than the current block number")] - NewBlockInvalidBlockNum, - #[error("New block `prev_hash` must match the chain's tip")] - NewBlockInvalidPrevHash, - #[error("New block chain root is not consistent with chain MMR")] - NewBlockInvalidChainRoot, - #[error("Received invalid account tree root")] - NewBlockInvalidAccountRoot, - #[error("Received invalid note root")] - NewBlockInvalidNoteRoot, - #[error("Received invalid nullifier root")] - NewBlockInvalidNullifierRoot, - #[error("Duplicated nullifiers {0:?}")] - DuplicatedNullifiers(Vec), - #[error("Block applying was broken because of closed channel on database side: {0}")] - BlockApplyingBrokenBecauseOfClosedChannel(RecvError), - #[error("Failed to create notes tree: {0}")] - FailedToCreateNoteTree(MerkleError), #[error("Database doesn't have any block header data")] DbBlockHeaderEmpty, - #[error("Failed to get MMR peaks for forest ({forest}): {error}")] - FailedToGetMmrPeaksForForest { forest: usize, error: MmrError }, - #[error("Failed to update nullifier tree: {0}")] - FailedToUpdateNullifierTree(NullifierTreeError), - #[error("Invalid output note type: {0:?}")] - InvalidOutputNoteType(OutputNote), - #[error("Invalid tx hash: expected {expected}, but got {actual}")] - InvalidTxHash { expected: RpoDigest, actual: RpoDigest }, + #[error("Database update task failed: {0}")] + DbUpdateTaskFailed(String), +} + +impl From for Status { + fn from(err: ApplyBlockError) -> Self { + match err { + ApplyBlockError::InvalidBlockError(_) => Status::invalid_argument(err.to_string()), + + _ => Status::internal(err.to_string()), + } + } } #[derive(Error, Debug)] @@ -209,10 +236,10 @@ pub enum GetBlockHeaderError { #[derive(Error, Debug)] pub enum GetBlockInputsError { - #[error("Database error: {0}")] - DatabaseError(#[from] DatabaseError), #[error("Account error: {0}")] AccountError(#[from] AccountError), + #[error("Database error: {0}")] + DatabaseError(#[from] DatabaseError), #[error("Database doesn't have any block header data")] DbBlockHeaderEmpty, #[error("Failed to get MMR peaks for forest ({forest}): {error}")] diff --git a/crates/store/src/server/api.rs b/crates/store/src/server/api.rs index bd741575c..3b6db4bd1 100644 --- a/crates/store/src/server/api.rs +++ b/crates/store/src/server/api.rs @@ -369,8 +369,7 @@ impl api_server::Api for StoreApi { nullifier_count = block.nullifiers().len(), ); - // TODO: Why the error is swallowed here? Fix or add a comment with explanation. - let _ = self.state.apply_block(block).await; + self.state.apply_block(block).await?; Ok(Response::new(ApplyBlockResponse {})) } diff --git a/crates/store/src/state.rs b/crates/store/src/state.rs index 3ff4c4197..174ac68e0 100644 --- a/crates/store/src/state.rs +++ b/crates/store/src/state.rs @@ -41,13 +41,13 @@ use crate::{ db::{Db, NoteRecord, NoteSyncUpdate, NullifierInfo, StateSyncUpdate}, errors::{ ApplyBlockError, DatabaseError, GetBlockHeaderError, GetBlockInputsError, - GetNoteInclusionProofError, NoteSyncError, StateInitializationError, StateSyncError, + GetNoteInclusionProofError, InvalidBlockError, NoteSyncError, StateInitializationError, + StateSyncError, }, nullifier_tree::NullifierTree, types::{AccountId, BlockNumber}, COMPONENT, }; - // STRUCTURES // ================================================================================================ @@ -173,10 +173,11 @@ impl State { let tx_hash = block.compute_tx_hash(); if header.tx_hash() != tx_hash { - return Err(ApplyBlockError::InvalidTxHash { + return Err(InvalidBlockError::InvalidTxHash { expected: tx_hash, actual: header.tx_hash(), - }); + } + .into()); } let block_num = header.block_num(); @@ -190,10 +191,10 @@ impl State { .ok_or(ApplyBlockError::DbBlockHeaderEmpty)?; if block_num != prev_block.block_num() + 1 { - return Err(ApplyBlockError::NewBlockInvalidBlockNum); + return Err(InvalidBlockError::NewBlockInvalidBlockNum.into()); } if header.prev_hash() != prev_block.hash() { - return Err(ApplyBlockError::NewBlockInvalidPrevHash); + return Err(InvalidBlockError::NewBlockInvalidPrevHash.into()); } let block_data = block.to_bytes(); @@ -227,7 +228,7 @@ impl State { .cloned() .collect(); if !duplicate_nullifiers.is_empty() { - return Err(ApplyBlockError::DuplicatedNullifiers(duplicate_nullifiers)); + return Err(InvalidBlockError::DuplicatedNullifiers(duplicate_nullifiers).into()); } // compute updates for the in-memory data structures @@ -235,7 +236,7 @@ impl State { // new_block.chain_root must be equal to the chain MMR root prior to the update let peaks = inner.chain_mmr.peaks(); if peaks.hash_peaks() != header.chain_root() { - return Err(ApplyBlockError::NewBlockInvalidChainRoot); + return Err(InvalidBlockError::NewBlockInvalidChainRoot.into()); } // compute update for nullifier tree @@ -244,7 +245,7 @@ impl State { ); if nullifier_tree_update.root() != header.nullifier_root() { - return Err(ApplyBlockError::NewBlockInvalidNullifierRoot); + return Err(InvalidBlockError::NewBlockInvalidNullifierRoot.into()); } // compute update for account tree @@ -258,7 +259,7 @@ impl State { ); if account_tree_update.root() != header.account_root() { - return Err(ApplyBlockError::NewBlockInvalidAccountRoot); + return Err(InvalidBlockError::NewBlockInvalidAccountRoot.into()); } ( @@ -272,7 +273,7 @@ impl State { // build note tree let note_tree = block.build_note_tree(); if note_tree.root() != header.note_root() { - return Err(ApplyBlockError::NewBlockInvalidNoteRoot); + return Err(InvalidBlockError::NewBlockInvalidNoteRoot.into()); } let notes = block @@ -281,7 +282,11 @@ impl State { let details = match note { OutputNote::Full(note) => Some(note.to_bytes()), OutputNote::Header(_) => None, - note => return Err(ApplyBlockError::InvalidOutputNoteType(note.clone())), + note => { + return Err(InvalidBlockError::InvalidOutputNoteType(Box::new( + note.clone(), + ))) + }, }; let merkle_path = note_tree.get_note_path(note_index); @@ -295,7 +300,7 @@ impl State { merkle_path, }) }) - .collect::, ApplyBlockError>>()?; + .collect::, InvalidBlockError>>()?; // Signals the transaction is ready to be committed, and the write lock can be acquired let (allow_acquire, acquired_allowed) = oneshot::channel::<()>(); @@ -313,9 +318,7 @@ impl State { ); // Wait for the message from the DB update task, that we ready to commit the DB transaction - acquired_allowed - .await - .map_err(ApplyBlockError::BlockApplyingBrokenBecauseOfClosedChannel)?; + acquired_allowed.await.map_err(ApplyBlockError::ClosedChannel)?; // Awaiting the block saving task to complete without errors block_save_task.await??; @@ -339,13 +342,17 @@ impl State { // Notify the DB update task that the write lock has been acquired, so it can commit // the DB transaction - let _ = inform_acquire_done.send(()); + inform_acquire_done + .send(()) + .map_err(|_| ApplyBlockError::DbUpdateTaskFailed("Receiver was dropped".into()))?; // TODO: shutdown #91 // Await for successful commit of the DB transaction. If the commit fails, we mustn't // change in-memory state, so we return a block applying error and don't proceed with // in-memory updates. - db_update_task.await??; + db_update_task + .await? + .map_err(|err| ApplyBlockError::DbUpdateTaskFailed(err.to_string()))?; // Update the in-memory data structures after successful commit of the DB transaction inner From abed5406e3a2cc8bd4943734c29858f962f95fa4 Mon Sep 17 00:00:00 2001 From: igamigo Date: Tue, 5 Nov 2024 17:53:05 -0300 Subject: [PATCH 04/10] fix: Return correct latest block number (#545) * Update state.rs * docs: Update expect() * chore: Lints --- crates/store/src/state.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/store/src/state.rs b/crates/store/src/state.rs index 174ac68e0..597219dac 100644 --- a/crates/store/src/state.rs +++ b/crates/store/src/state.rs @@ -99,7 +99,9 @@ struct InnerState { impl InnerState { /// Returns the latest block number. fn latest_block_num(&self) -> BlockNumber { - (self.chain_mmr.forest() + 1).try_into().expect("block number overflow") + (self.chain_mmr.forest() - 1) + .try_into() + .expect("chain_mmr always has, at least, the genesis block") } } From 6e6f1e210a5bc8182a7480a5445e440d62ec4a58 Mon Sep 17 00:00:00 2001 From: Bobbin Threadbare Date: Tue, 5 Nov 2024 13:19:56 -0800 Subject: [PATCH 05/10] chore: update to the latest versions of miden-base crates --- Cargo.lock | 10 +++++----- bin/node/Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3bdaec30..da702879d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -395,9 +395,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.34" +version = "1.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" +checksum = "0f57c4b4da2a9d619dd035f27316d7a426305b75be93d09e92f2b9229c34feaf" dependencies = [ "jobserver", "libc", @@ -1511,7 +1511,7 @@ dependencies = [ [[package]] name = "miden-lib" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#ff3c5227c5962cc97cd44562f134b0a545be21cc" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#804da570c00c4a6a2ef48598c05cb7f3a191f4c0" dependencies = [ "miden-assembly", "miden-objects", @@ -1707,7 +1707,7 @@ dependencies = [ [[package]] name = "miden-objects" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#ff3c5227c5962cc97cd44562f134b0a545be21cc" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#804da570c00c4a6a2ef48598c05cb7f3a191f4c0" dependencies = [ "getrandom", "miden-assembly", @@ -1780,7 +1780,7 @@ dependencies = [ [[package]] name = "miden-tx" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#ff3c5227c5962cc97cd44562f134b0a545be21cc" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#804da570c00c4a6a2ef48598c05cb7f3a191f4c0" dependencies = [ "async-trait", "miden-assembly", diff --git a/bin/node/Cargo.toml b/bin/node/Cargo.toml index b855cbe64..d2d9b5d91 100644 --- a/bin/node/Cargo.toml +++ b/bin/node/Cargo.toml @@ -14,7 +14,7 @@ repository.workspace = true [features] # Makes `make-genesis` subcommand run faster. Is only suitable for testing. # INFO: Make sure that all your components have matching features for them to function. -testing = ["miden-lib/testing"] +testing = ["miden-lib/testing", "miden-objects/testing"] tracing-forest = ["miden-node-block-producer/tracing-forest"] [dependencies] From 857b757799c7489aebee3573d156255edf2dcf55 Mon Sep 17 00:00:00 2001 From: Bobbin Threadbare Date: Tue, 5 Nov 2024 18:26:45 -0800 Subject: [PATCH 06/10] chore: update miden-base dependencies to crates.io versions --- Cargo.lock | 9 ++++++--- Cargo.toml | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da702879d..6dff0370d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1511,7 +1511,8 @@ dependencies = [ [[package]] name = "miden-lib" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#804da570c00c4a6a2ef48598c05cb7f3a191f4c0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816404c10b0799f12d3b53b3a9baa9af99fa340fe1a579e0919bba57718fa97a" dependencies = [ "miden-assembly", "miden-objects", @@ -1707,7 +1708,8 @@ dependencies = [ [[package]] name = "miden-objects" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#804da570c00c4a6a2ef48598c05cb7f3a191f4c0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a6f54dde939928e438488b36651485a0e80057025b7e30343d4340a524a1651" dependencies = [ "getrandom", "miden-assembly", @@ -1780,7 +1782,8 @@ dependencies = [ [[package]] name = "miden-tx" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#804da570c00c4a6a2ef48598c05cb7f3a191f4c0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d433744a3f02233ec53b151bfe88b7a008b4eae5dfd41bb38a9889eb67efaf7" dependencies = [ "async-trait", "miden-assembly", diff --git a/Cargo.toml b/Cargo.toml index bcd59f59d..ce5eb685e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ readme = "README.md" [workspace.dependencies] miden-air = { version = "0.11" } -miden-lib = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" } +miden-lib = { version = "0.6" } miden-node-block-producer = { path = "crates/block-producer", version = "0.6" } miden-node-faucet = { path = "bin/faucet", version = "0.6" } miden-node-proto = { path = "crates/proto", version = "0.6" } @@ -35,10 +35,10 @@ miden-node-rpc-proto = { path = "crates/rpc-proto", version = "0.6" } miden-node-store = { path = "crates/store", version = "0.6" } miden-node-test-macro = { path = "crates/test-macro" } miden-node-utils = { path = "crates/utils", version = "0.6" } -miden-objects = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" } +miden-objects = { version = "0.6"} miden-processor = { version = "0.11" } miden-stdlib = { version = "0.11", default-features = false } -miden-tx = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" } +miden-tx = { version = "0.6"} prost = { version = "0.13" } rand = { version = "0.8" } thiserror = { version = "1.0" } From f05a40c14856b4048ca944cac15508d81229e5bb Mon Sep 17 00:00:00 2001 From: Bobbin Threadbare Date: Tue, 5 Nov 2024 18:32:12 -0800 Subject: [PATCH 07/10] chore: update changelog --- CHANGELOG.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f5a7ef48..ed4c12a1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ # Changelog -## v0.6.0 (TBD) +## v0.6.0 (2024-11-05) + +### Enhancements + +- Added `GetAccountProofs` endpoint (#506). + +### Changes -- Added `AccountCode` as part of `GetAccountProofs` endpoint response (#521). - [BREAKING] Added `kernel_root` to block header's protobuf message definitions (#496). - [BREAKING] Renamed `off-chain` and `on-chain` to `private` and `public` respectively for the account storage modes (#489). - Optimized state synchronizations by removing unnecessary fetching and parsing of note details (#462). @@ -10,10 +15,10 @@ - Improve `--version` by adding build metadata (#495). - [BREAKING] Introduced additional limits for note/account number (#503). - [BREAKING] Removed support for basic wallets in genesis creation (#510). -- Added `GetAccountProofs` endpoint (#506). - Migrated faucet from actix-web to axum (#511). - Changed the `BlockWitness` to pass the inputs to the VM using only advice provider (#516). - [BREAKING] Improved store API errors (return "not found" instead of "internal error" status if requested account(s) not found) (#518). +- Added `AccountCode` as part of `GetAccountProofs` endpoint response (#521). - [BREAKING] Migrated to v0.11 version of Miden VM (#528). - Reduce cloning in the store's `apply_block` (#532). - [BREAKING] Changed faucet storage type in the genesis to public. Using faucet from the genesis for faucet web app. Added support for faucet restarting without blockchain restarting (#517). From 8329a776202bd4ff85e1121d0fae834af9a28e13 Mon Sep 17 00:00:00 2001 From: Varun Doshi <61531351+varun-doshi@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:18:39 +0530 Subject: [PATCH 08/10] chore: update deadpool-sqlite (#555) --- Cargo.lock | 16 ++++++++-------- crates/store/Cargo.toml | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6dff0370d..184a24b62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -619,9 +619,9 @@ dependencies = [ [[package]] name = "deadpool-sqlite" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f9cc6210316f8b7ced394e2a5d2833ce7097fb28afb5881299c61bc18e8e0e9" +checksum = "656f14fc1ab819c65f332045ea7cb38841bbe551f3b2bc7e3abefb559af4155c" dependencies = [ "deadpool", "deadpool-sync", @@ -1302,9 +1302,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.28.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c10584274047cb335c23d3e61bcef8e323adae7c5c8c760540f73610177fc3f" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" dependencies = [ "bindgen", "cc", @@ -2490,9 +2490,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rusqlite" -version = "0.31.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" +checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" dependencies = [ "bitflags", "fallible-iterator", @@ -2504,9 +2504,9 @@ dependencies = [ [[package]] name = "rusqlite_migration" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55709bc01054c69e2f1cefdc886642b5e6376a8db3c86f761be0c423eebf178b" +checksum = "923b42e802f7dc20a0a6b5e097ba7c83fe4289da07e49156fecf6af08aa9cd1c" dependencies = [ "log", "rusqlite", diff --git a/crates/store/Cargo.toml b/crates/store/Cargo.toml index bb9a63103..1337fcd86 100644 --- a/crates/store/Cargo.toml +++ b/crates/store/Cargo.toml @@ -12,7 +12,7 @@ homepage.workspace = true repository.workspace = true [dependencies] -deadpool-sqlite = { version = "0.8", features = ["rt_tokio_1"] } +deadpool-sqlite = { version = "0.9.0", features = ["rt_tokio_1"] } directories = { version = "5.0" } figment = { version = "0.10", features = ["toml", "env"] } hex = { version = "0.4" } @@ -21,7 +21,7 @@ miden-node-proto = { workspace = true } miden-node-utils = { workspace = true } miden-objects = { workspace = true } prost = { workspace = true } -rusqlite = { version = "0.31", features = ["array", "buildtime_bindgen", "bundled"] } +rusqlite = { version = "0.32.1", features = ["array", "buildtime_bindgen", "bundled"] } rusqlite_migration = { version = "1.0" } serde = { version = "1.0", features = ["derive"] } thiserror = { workspace = true } From 54095db301390347efab9d4f9412a55656783d12 Mon Sep 17 00:00:00 2001 From: Varun Doshi <61531351+varun-doshi@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:54:46 +0530 Subject: [PATCH 09/10] feat: https support in endpoint config (#556) Previously only http was supported. --- CHANGELOG.md | 1 + bin/node/src/config.rs | 9 ++++++--- crates/rpc/src/config.rs | 3 ++- crates/utils/src/config.rs | 27 +++++++++++++++++++++++++-- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed4c12a1b..ccb6505c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Enhancements - Added `GetAccountProofs` endpoint (#506). +- Support Https in endpoint configuration (#556). ### Changes diff --git a/bin/node/src/config.rs b/bin/node/src/config.rs index 173496764..8e44ad064 100644 --- a/bin/node/src/config.rs +++ b/bin/node/src/config.rs @@ -74,7 +74,7 @@ impl NodeConfig { mod tests { use figment::Jail; use miden_node_store::config::StoreConfig; - use miden_node_utils::config::{load_config, Endpoint}; + use miden_node_utils::config::{load_config, Endpoint, Protocol}; use super::NodeConfig; use crate::{ @@ -93,10 +93,10 @@ mod tests { verify_tx_proofs = true [rpc] - endpoint = { host = "127.0.0.1", port = 8080 } + endpoint = { host = "127.0.0.1", port = 8080, protocol = "Http" } [store] - endpoint = { host = "127.0.0.1", port = 8080 } + endpoint = { host = "127.0.0.1", port = 8080, protocol = "Https" } database_filepath = "local.sqlite3" genesis_filepath = "genesis.dat" blockstore_dir = "blocks" @@ -112,6 +112,7 @@ mod tests { endpoint: Endpoint { host: "127.0.0.1".to_string(), port: 8080, + protocol: Protocol::default() }, verify_tx_proofs: true }, @@ -119,12 +120,14 @@ mod tests { endpoint: Endpoint { host: "127.0.0.1".to_string(), port: 8080, + protocol: Protocol::Http }, }, store: StoreConfig { endpoint: Endpoint { host: "127.0.0.1".to_string(), port: 8080, + protocol: Protocol::Https }, database_filepath: "local.sqlite3".into(), genesis_filepath: "genesis.dat".into(), diff --git a/crates/rpc/src/config.rs b/crates/rpc/src/config.rs index 7cd6e6448..07dac0778 100644 --- a/crates/rpc/src/config.rs +++ b/crates/rpc/src/config.rs @@ -1,7 +1,7 @@ use std::fmt::{Display, Formatter}; use miden_node_utils::config::{ - Endpoint, DEFAULT_BLOCK_PRODUCER_PORT, DEFAULT_NODE_RPC_PORT, DEFAULT_STORE_PORT, + Endpoint, Protocol, DEFAULT_BLOCK_PRODUCER_PORT, DEFAULT_NODE_RPC_PORT, DEFAULT_STORE_PORT, }; use serde::{Deserialize, Serialize}; @@ -39,6 +39,7 @@ impl Default for RpcConfig { endpoint: Endpoint { host: "0.0.0.0".to_string(), port: DEFAULT_NODE_RPC_PORT, + protocol: Protocol::default(), }, store_url: Endpoint::localhost(DEFAULT_STORE_PORT).to_string(), block_producer_url: Endpoint::localhost(DEFAULT_BLOCK_PRODUCER_PORT).to_string(), diff --git a/crates/utils/src/config.rs b/crates/utils/src/config.rs index c350fd36b..5c70315df 100644 --- a/crates/utils/src/config.rs +++ b/crates/utils/src/config.rs @@ -17,6 +17,12 @@ pub const DEFAULT_BLOCK_PRODUCER_PORT: u16 = 48046; pub const DEFAULT_STORE_PORT: u16 = 28943; pub const DEFAULT_FAUCET_SERVER_PORT: u16 = 8080; +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize, Default)] +pub enum Protocol { + #[default] + Http, + Https, +} /// The `(host, port)` pair for the server's listening socket. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)] pub struct Endpoint { @@ -24,11 +30,18 @@ pub struct Endpoint { pub host: String, /// Port number used by the store. pub port: u16, + /// Protocol type: http or https. + #[serde(default)] + pub protocol: Protocol, } impl Endpoint { pub fn localhost(port: u16) -> Self { - Endpoint { host: "localhost".to_string(), port } + Endpoint { + host: "localhost".to_string(), + port, + protocol: Protocol::default(), + } } } @@ -41,7 +54,17 @@ impl ToSocketAddrs for Endpoint { impl Display for Endpoint { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.write_fmt(format_args!("http://{}:{}", self.host, self.port)) + let Endpoint { protocol, host, port } = self; + f.write_fmt(format_args!("{protocol}://{host}:{port}")) + } +} + +impl Display for Protocol { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + Protocol::Http => f.write_str("http"), + Protocol::Https => f.write_str("https"), + } } } From a686581c8ce36a9da3577471c3af0e4fd9fc8005 Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:02:19 +0500 Subject: [PATCH 10/10] chore: migrate code to the latest `miden-base` (#559) * refactor: remove unused dependencies, migrate code to the latest `next` of `miden-base` * chore: update `miden-base` * refactor: migrate to `assert_matches!` macro * chore: switch to the `next` branch of `miden-base` * refactor: add missed `assert_matches!` --- Cargo.lock | 123 ++++++++---------- Cargo.toml | 11 +- crates/block-producer/Cargo.toml | 5 +- .../src/batch_builder/tests/mod.rs | 9 +- .../src/block_builder/prover/tests.rs | 21 ++- .../block-producer/src/block_builder/tests.rs | 3 +- crates/block-producer/src/errors.rs | 26 ++-- .../src/state_view/tests/apply_block.rs | 15 ++- .../src/state_view/tests/verify_tx.rs | 51 +++++--- .../block-producer/src/txqueue/tests/mod.rs | 3 +- crates/proto/src/errors.rs | 4 +- crates/rpc/Cargo.toml | 9 -- crates/store/Cargo.toml | 9 +- crates/store/src/db/tests.rs | 61 ++++----- 14 files changed, 171 insertions(+), 179 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 184a24b62..0fd48b068 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,6 +129,12 @@ dependencies = [ "term", ] +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + [[package]] name = "async-stream" version = "0.3.6" @@ -390,7 +396,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -687,15 +693,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "directories" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs-next" version = "2.0.0" @@ -706,18 +703,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1490,7 +1475,7 @@ dependencies = [ "rand_chacha", "serde", "static-files", - "thiserror", + "thiserror 2.0.3", "tokio", "toml", "tonic", @@ -1510,14 +1495,14 @@ dependencies = [ [[package]] name = "miden-lib" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816404c10b0799f12d3b53b3a9baa9af99fa340fe1a579e0919bba57718fa97a" +version = "0.7.0" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#bc91c604862e2c6013b21eb989a3640d30cce25b" dependencies = [ "miden-assembly", "miden-objects", "miden-stdlib", "regex", + "walkdir", ] [[package]] @@ -1588,8 +1573,8 @@ dependencies = [ name = "miden-node-block-producer" version = "0.6.0" dependencies = [ + "assert_matches", "async-trait", - "figment", "itertools 0.13.0", "miden-air", "miden-lib", @@ -1602,13 +1587,11 @@ dependencies = [ "miden-tx", "rand_chacha", "serde", - "thiserror", + "thiserror 2.0.3", "tokio", "tokio-stream", - "toml", "tonic", "tracing", - "tracing-subscriber", "winterfell", ] @@ -1624,7 +1607,7 @@ dependencies = [ "prost", "prost-build", "protox", - "thiserror", + "thiserror 2.0.3", "tonic", "tonic-build", ] @@ -1633,49 +1616,37 @@ dependencies = [ name = "miden-node-rpc" version = "0.6.0" dependencies = [ - "directories", - "figment", - "hex", - "miden-node-block-producer", "miden-node-proto", - "miden-node-store", "miden-node-utils", "miden-objects", "miden-tx", - "prost", "serde", "tokio", "tokio-stream", - "toml", "tonic", "tonic-web", "tracing", - "tracing-subscriber", ] [[package]] name = "miden-node-store" version = "0.6.0" dependencies = [ + "assert_matches", "deadpool-sqlite", - "directories", - "figment", "hex", "miden-lib", "miden-node-proto", "miden-node-utils", "miden-objects", - "prost", "rusqlite", "rusqlite_migration", "serde", - "thiserror", + "thiserror 2.0.3", "tokio", "tokio-stream", - "toml", "tonic", "tracing", - "tracing-subscriber", ] [[package]] @@ -1696,7 +1667,7 @@ dependencies = [ "miden-objects", "rand", "serde", - "thiserror", + "thiserror 2.0.3", "tonic", "tracing", "tracing-forest", @@ -1707,9 +1678,8 @@ dependencies = [ [[package]] name = "miden-objects" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a6f54dde939928e438488b36651485a0e80057025b7e30343d4340a524a1651" +version = "0.7.0" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#bc91c604862e2c6013b21eb989a3640d30cce25b" dependencies = [ "getrandom", "miden-assembly", @@ -1718,6 +1688,7 @@ dependencies = [ "miden-processor", "miden-verifier", "rand", + "thiserror 2.0.3", "winter-rand-utils", ] @@ -1781,12 +1752,10 @@ dependencies = [ [[package]] name = "miden-tx" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d433744a3f02233ec53b151bfe88b7a008b4eae5dfd41bb38a9889eb67efaf7" +version = "0.7.0" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#bc91c604862e2c6013b21eb989a3640d30cce25b" dependencies = [ "async-trait", - "miden-assembly", "miden-lib", "miden-objects", "miden-processor", @@ -1794,8 +1763,6 @@ dependencies = [ "miden-verifier", "rand", "rand_chacha", - "regex", - "walkdir", "winter-maybe-async", ] @@ -1827,7 +1794,7 @@ dependencies = [ "supports-unicode", "terminal_size", "textwrap", - "thiserror", + "thiserror 1.0.68", "unicode-width 0.1.14", ] @@ -2042,12 +2009,6 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "overload" version = "0.1.1" @@ -2335,7 +2296,7 @@ dependencies = [ "prost-reflect", "prost-types", "protox-parse", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -2347,7 +2308,7 @@ dependencies = [ "logos", "miette", "prost-types", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -2441,7 +2402,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.68", ] [[package]] @@ -2904,7 +2865,16 @@ version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.68", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -2918,6 +2888,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -3240,7 +3221,7 @@ checksum = "ee40835db14ddd1e3ba414292272eddde9dad04d3d4b65509656414d1c42592f" dependencies = [ "chrono", "smallvec", - "thiserror", + "thiserror 1.0.68", "tracing", "tracing-subscriber", ] @@ -3882,9 +3863,9 @@ dependencies = [ [[package]] name = "winter-utils" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76b116c8ade0172506f8bda32dc674cf6b230adc8516e5138a0173ae69158a4f" +checksum = "1f948e71ffd482aa13d0ec3349047f81ecdb89f3b3287577973dcbf092a25fb4" dependencies = [ "rayon", ] @@ -3904,9 +3885,9 @@ dependencies = [ [[package]] name = "winterfell" -version = "0.10.1" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c8336dc6a035698780b8cc624f875e479bd6bf6e1846670f3ef4485c125882" +checksum = "bbf1ab01d2781f7d3f1bd5c12800905c5bbf62e06778672498be798006ac463a" dependencies = [ "winter-air", "winter-prover", diff --git a/Cargo.toml b/Cargo.toml index ce5eb685e..eb13182a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,23 +25,22 @@ exclude = [".github/"] readme = "README.md" [workspace.dependencies] +assert_matches = { version = "1.5" } miden-air = { version = "0.11" } -miden-lib = { version = "0.6" } +miden-lib = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" } miden-node-block-producer = { path = "crates/block-producer", version = "0.6" } -miden-node-faucet = { path = "bin/faucet", version = "0.6" } miden-node-proto = { path = "crates/proto", version = "0.6" } miden-node-rpc = { path = "crates/rpc", version = "0.6" } -miden-node-rpc-proto = { path = "crates/rpc-proto", version = "0.6" } miden-node-store = { path = "crates/store", version = "0.6" } miden-node-test-macro = { path = "crates/test-macro" } miden-node-utils = { path = "crates/utils", version = "0.6" } -miden-objects = { version = "0.6"} +miden-objects = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" } miden-processor = { version = "0.11" } miden-stdlib = { version = "0.11", default-features = false } -miden-tx = { version = "0.6"} +miden-tx = { git = "https://github.com/0xPolygonMiden/miden-base.git", branch = "next" } prost = { version = "0.13" } rand = { version = "0.8" } -thiserror = { version = "1.0" } +thiserror = { version = "2.0", default-features = false } tokio = { version = "1.40", features = ["rt-multi-thread"] } tokio-stream = { version = "0.1" } tonic = { version = "0.12" } diff --git a/crates/block-producer/Cargo.toml b/crates/block-producer/Cargo.toml index ea6f32116..9c9aeefc7 100644 --- a/crates/block-producer/Cargo.toml +++ b/crates/block-producer/Cargo.toml @@ -16,7 +16,6 @@ tracing-forest = ["miden-node-utils/tracing-forest"] [dependencies] async-trait = { version = "0.1" } -figment = { version = "0.10", features = ["toml", "env"] } itertools = { version = "0.13" } miden-lib = { workspace = true } miden-node-proto = { workspace = true } @@ -29,13 +28,11 @@ serde = { version = "1.0", features = ["derive"] } thiserror = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread", "net", "macros", "sync", "time"] } tokio-stream = { workspace = true, features = ["net"] } -toml = { version = "0.8" } tonic = { workspace = true } tracing = { workspace = true } -tracing-subscriber = { workspace = true } [dev-dependencies] -figment = { version = "0.10", features = ["toml", "env", "test"] } +assert_matches = { workspace = true} miden-air = { workspace = true } miden-lib = { workspace = true, features = ["testing"] } miden-node-test-macro = { path = "../test-macro" } diff --git a/crates/block-producer/src/batch_builder/tests/mod.rs b/crates/block-producer/src/batch_builder/tests/mod.rs index 1e0012f1c..46b63f703 100644 --- a/crates/block-producer/src/batch_builder/tests/mod.rs +++ b/crates/block-producer/src/batch_builder/tests/mod.rs @@ -1,5 +1,6 @@ use std::iter; +use assert_matches::assert_matches; use miden_objects::{crypto::merkle::Mmr, Digest}; use tokio::sync::RwLock; @@ -254,7 +255,7 @@ async fn test_block_builder_no_missing_notes() { .block_builder .build_block(&batch_builder.ready_batches.read().await) .await; - assert_eq!(build_block_result, Ok(())); + assert_matches!(build_block_result, Ok(())); } #[tokio::test] @@ -307,9 +308,11 @@ async fn test_block_builder_fails_if_notes_are_missing() { let mut expected_missing_notes = vec![notes[4].id(), notes[5].id()]; expected_missing_notes.sort(); - assert_eq!( + assert_matches!( build_block_result, - Err(BuildBlockError::UnauthenticatedNotesNotFound(expected_missing_notes)) + Err(BuildBlockError::UnauthenticatedNotesNotFound(actual_missing_notes)) => { + assert_eq!(actual_missing_notes, 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 3d776ffc6..56124065d 100644 --- a/crates/block-producer/src/block_builder/prover/tests.rs +++ b/crates/block-producer/src/block_builder/prover/tests.rs @@ -1,5 +1,6 @@ use std::{collections::BTreeMap, iter}; +use assert_matches::assert_matches; use miden_objects::{ accounts::{ account_id::testing::{ @@ -157,13 +158,17 @@ fn test_block_witness_validation_inconsistent_account_hashes() { let block_witness_result = BlockWitness::new(block_inputs_from_store, &batches); - assert_eq!( + assert_matches!( block_witness_result, Err(BuildBlockError::InconsistentAccountStateTransition( - account_id_1, - account_1_hash_store, - vec![account_1_hash_batches] - )) + account_id, + account_hash_store, + account_hash_batches + )) => { + assert_eq!(account_id, account_id_1); + assert_eq!(account_hash_store, account_1_hash_store); + assert_eq!(account_hash_batches, vec![account_1_hash_batches]); + } ); } @@ -668,9 +673,11 @@ fn test_block_witness_validation_inconsistent_nullifiers() { let block_witness_result = BlockWitness::new(block_inputs_from_store, &batches); - assert_eq!( + assert_matches!( block_witness_result, - Err(BuildBlockError::InconsistentNullifiers(vec![nullifier_1, nullifier_3])) + Err(BuildBlockError::InconsistentNullifiers(nullifiers)) => { + assert_eq!(nullifiers, vec![nullifier_1, nullifier_3]); + } ); } diff --git a/crates/block-producer/src/block_builder/tests.rs b/crates/block-producer/src/block_builder/tests.rs index c7c82629f..d8fbc3565 100644 --- a/crates/block-producer/src/block_builder/tests.rs +++ b/crates/block-producer/src/block_builder/tests.rs @@ -3,6 +3,7 @@ use std::sync::Arc; +use assert_matches::assert_matches; use miden_objects::{ accounts::{account_id::testing::ACCOUNT_ID_OFF_CHAIN_SENDER, AccountId}, Digest, Felt, @@ -78,5 +79,5 @@ async fn test_build_block_failure() { let result = block_builder.build_block(&Vec::new()).await; // Ensure that the store's `apply_block()` was called - assert!(matches!(result, Err(BuildBlockError::GetBlockInputsFailed(_)))); + assert_matches!(result, Err(BuildBlockError::GetBlockInputsFailed(_))); } diff --git a/crates/block-producer/src/errors.rs b/crates/block-producer/src/errors.rs index 717a29268..e31027a41 100644 --- a/crates/block-producer/src/errors.rs +++ b/crates/block-producer/src/errors.rs @@ -14,7 +14,7 @@ use thiserror::Error; // Transaction verification errors // ================================================================================================= -#[derive(Debug, PartialEq, Eq, Error)] +#[derive(Debug, Error)] pub enum VerifyTxError { /// Another transaction already consumed the notes with given nullifiers #[error("Input notes with given nullifiers were already consumed by another transaction")] @@ -52,7 +52,7 @@ pub enum VerifyTxError { // Transaction adding errors // ================================================================================================= -#[derive(Debug, PartialEq, Eq, Error)] +#[derive(Debug, Error)] pub enum AddTransactionError { #[error("Transaction verification failed: {0}")] VerificationFailed(#[from] VerifyTxError), @@ -66,18 +66,12 @@ pub enum AddTransactionError { /// These errors are returned from the batch builder to the transaction queue, instead of /// dropping the transactions, they are included into the error values, so that the transaction /// queue can re-queue them. -#[derive(Debug, PartialEq, Eq, Error)] +#[derive(Debug, Error)] pub enum BuildBatchError { - #[error( - "Too many input notes in the batch. Got: {0}, limit: {}", - MAX_INPUT_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 - )] + #[error("Too many notes created in the batch. Got: {0}, limit: {MAX_OUTPUT_NOTES_PER_BATCH}")] TooManyNotesCreated(usize, Vec), #[error( @@ -152,7 +146,7 @@ pub enum BlockProverError { // ================================================================================================= #[allow(clippy::enum_variant_names)] -#[derive(Debug, PartialEq, Eq, Error)] +#[derive(Debug, Error)] pub enum BlockInputsError { #[error("failed to parse protobuf message: {0}")] ConversionError(#[from] ConversionError), @@ -166,7 +160,7 @@ pub enum BlockInputsError { // ================================================================================================= #[allow(clippy::enum_variant_names)] -#[derive(Debug, PartialEq, Eq, Error)] +#[derive(Debug, Error)] pub enum NotePathsError { #[error("failed to parse protobuf message: {0}")] ConversionError(#[from] ConversionError), @@ -177,7 +171,7 @@ pub enum NotePathsError { // Block applying errors // ================================================================================================= -#[derive(Debug, PartialEq, Eq, Error)] +#[derive(Debug, Error)] pub enum ApplyBlockError { #[error("gRPC client failed with error: {0}")] GrpcClientError(String), @@ -186,7 +180,7 @@ pub enum ApplyBlockError { // Block building errors // ================================================================================================= -#[derive(Debug, PartialEq, Eq, Error)] +#[derive(Debug, Error)] pub enum BuildBlockError { #[error("failed to compute new block: {0}")] BlockProverFailed(#[from] BlockProverError), @@ -216,7 +210,7 @@ pub enum BuildBlockError { // Transaction inputs errors // ================================================================================================= -#[derive(Debug, PartialEq, Eq, Error)] +#[derive(Debug, Error)] pub enum TxInputsError { #[error("gRPC client failed with error: {0}")] GrpcClientError(String), diff --git a/crates/block-producer/src/state_view/tests/apply_block.rs b/crates/block-producer/src/state_view/tests/apply_block.rs index 9465ec951..b98371af5 100644 --- a/crates/block-producer/src/state_view/tests/apply_block.rs +++ b/crates/block-producer/src/state_view/tests/apply_block.rs @@ -7,6 +7,7 @@ use std::iter; +use assert_matches::assert_matches; use miden_objects::{accounts::delta::AccountUpdateDetails, block::BlockAccountUpdate}; use super::*; @@ -74,7 +75,9 @@ async fn test_apply_block_ab2() { // Verify transactions so it can be tracked in state view for tx in txs { let verify_tx_res = state_view.verify_tx(&tx).await; - assert_eq!(verify_tx_res, Ok(0)); + assert_matches!(verify_tx_res, Ok(block_height) => { + assert_eq!(block_height, 0); + }); } // All except the first account will go into the block. @@ -128,7 +131,9 @@ async fn test_apply_block_ab3() { // Verify transactions so it can be tracked in state view for tx in txs.clone() { let verify_tx_res = state_view.verify_tx(&tx).await; - assert_eq!(verify_tx_res, Ok(0)); + assert_matches!(verify_tx_res, Ok(block_height) => { + assert_eq!(block_height, 0); + }); } let block = MockBlockBuilder::new(&store) @@ -163,8 +168,10 @@ async fn test_apply_block_ab3() { .build(); let verify_tx_res = state_view.verify_tx(&tx_new).await; - assert_eq!( + assert_matches!( verify_tx_res, - Err(VerifyTxError::InputNotesAlreadyConsumed(txs[0].get_nullifiers().collect())) + Err(VerifyTxError::InputNotesAlreadyConsumed(nullifiers)) => { + assert_eq!(nullifiers, txs[0].get_nullifiers().collect::>()); + } ); } diff --git a/crates/block-producer/src/state_view/tests/verify_tx.rs b/crates/block-producer/src/state_view/tests/verify_tx.rs index c3f576193..d28a3cb9e 100644 --- a/crates/block-producer/src/state_view/tests/verify_tx.rs +++ b/crates/block-producer/src/state_view/tests/verify_tx.rs @@ -12,6 +12,7 @@ use std::iter; +use assert_matches::assert_matches; use miden_objects::notes::Note; use tokio::task::JoinSet; @@ -95,12 +96,17 @@ async fn test_verify_tx_vt1() { let verify_tx_result = state_view.verify_tx(&tx).await; - assert_eq!( + assert_matches!( verify_tx_result, Err(VerifyTxError::IncorrectAccountInitialHash { - tx_initial_account_hash: account.states[1], - current_account_hash: Some(account.states[0]), - }) + tx_initial_account_hash, + current_account_hash, + }) => { + assert_eq!(tx_initial_account_hash, account.states[1]); + assert_matches!(current_account_hash, Some(state) => { + assert_eq!(state, account.states[0]); + }); + } ); } @@ -152,9 +158,11 @@ async fn test_verify_tx_vt3() { let verify_tx_result = state_view.verify_tx(&tx).await; - assert_eq!( + assert_matches!( verify_tx_result, - Err(VerifyTxError::InputNotesAlreadyConsumed(vec![nullifier_in_store])) + Err(VerifyTxError::InputNotesAlreadyConsumed(nullifiers)) => { + assert_eq!(nullifiers, vec![nullifier_in_store]); + } ); } @@ -221,9 +229,11 @@ async fn test_verify_tx_vt5() { assert!(verify_tx1_result.is_ok()); let verify_tx2_result = state_view.verify_tx(&tx2).await; - assert_eq!( + assert_matches!( verify_tx2_result, - Err(VerifyTxError::InputNotesAlreadyConsumed(vec![nullifier_in_both_txs])) + Err(VerifyTxError::InputNotesAlreadyConsumed(nullifiers)) => { + assert_eq!(nullifiers, vec![nullifier_in_both_txs]); + } ); } @@ -250,16 +260,20 @@ async fn test_verify_tx_dangling_note_found_in_inflight_notes() { let tx1 = MockProvenTxBuilder::with_account_index(1).output_notes(output_notes).build(); let verify_tx1_result = state_view.verify_tx(&tx1).await; - assert_eq!(verify_tx1_result, Ok(0)); + assert_matches!(verify_tx1_result, Ok(block_height) => { + assert_eq!(block_height, 0); + }); let tx2 = MockProvenTxBuilder::with_account_index(2) .unauthenticated_notes(dangling_notes.clone()) .build(); let verify_tx2_result = state_view.verify_tx(&tx2).await; - assert_eq!( + assert_matches!( verify_tx2_result, - Ok(0), + Ok(block_height) => { + assert_eq!(block_height, 0); + }, "Dangling unauthenticated notes must be found in the in-flight notes after previous tx verification" ); } @@ -284,11 +298,11 @@ async fn test_verify_tx_stored_unauthenticated_notes() { let state_view = DefaultStateView::new(Arc::clone(&store), false); let verify_tx1_result = state_view.verify_tx(&tx1).await; - assert_eq!( + assert_matches!( verify_tx1_result, - Err(VerifyTxError::UnauthenticatedNotesNotFound( - dangling_notes.iter().map(Note::id).collect() - )), + Err(VerifyTxError::UnauthenticatedNotesNotFound(notes)) => { + assert_eq!(notes, dangling_notes.iter().map(Note::id).collect::>()); + }, "Dangling unauthenticated notes must not be found in the store by this moment" ); @@ -298,9 +312,10 @@ async fn test_verify_tx_stored_unauthenticated_notes() { store.apply_block(&block).await.unwrap(); let verify_tx1_result = state_view.verify_tx(&tx1).await; - assert_eq!( - verify_tx1_result, - Ok(0), + assert_matches!( + verify_tx1_result, Ok(block_height) => { + assert_eq!(block_height, 0); + }, "Dangling unauthenticated notes must be found in the store after block applying" ); } diff --git a/crates/block-producer/src/txqueue/tests/mod.rs b/crates/block-producer/src/txqueue/tests/mod.rs index 79ae32b21..f7b5ca6e3 100644 --- a/crates/block-producer/src/txqueue/tests/mod.rs +++ b/crates/block-producer/src/txqueue/tests/mod.rs @@ -1,3 +1,4 @@ +use assert_matches::assert_matches; use tokio::sync::mpsc::{self, error::TryRecvError}; use super::*; @@ -181,7 +182,7 @@ async fn test_tx_verify_failure() { .add_transaction(MockProvenTxBuilder::with_account_index(i).build()) .await; - assert!(matches!(r, Err(AddTransactionError::VerificationFailed(_)))); + assert_matches!(r, Err(AddTransactionError::VerificationFailed(_))); assert_eq!( Err(TryRecvError::Empty), receiver.try_recv(), diff --git a/crates/proto/src/errors.rs b/crates/proto/src/errors.rs index 7f06c7017..bf5967014 100644 --- a/crates/proto/src/errors.rs +++ b/crates/proto/src/errors.rs @@ -3,7 +3,7 @@ use std::{any::type_name, num::TryFromIntError}; use miden_objects::crypto::merkle::{SmtLeafError, SmtProofError}; use thiserror::Error; -#[derive(Debug, Clone, PartialEq, Error)] +#[derive(Debug, Error)] pub enum ConversionError { #[error("Hex error: {0}")] HexError(#[from] hex::FromHexError), @@ -28,8 +28,6 @@ pub enum ConversionError { }, } -impl Eq for ConversionError {} - pub trait MissingFieldHelper { fn missing_field(field_name: &'static str) -> ConversionError; } diff --git a/crates/rpc/Cargo.toml b/crates/rpc/Cargo.toml index 9ebf2cbcf..c8e8ab167 100644 --- a/crates/rpc/Cargo.toml +++ b/crates/rpc/Cargo.toml @@ -12,25 +12,16 @@ homepage.workspace = true repository.workspace = true [dependencies] -directories = { version = "5.0" } -figment = { version = "0.10", features = ["toml", "env"] } -hex = { version = "0.4" } -miden-node-block-producer = { workspace = true } miden-node-proto = { workspace = true } -miden-node-store = { workspace = true } miden-node-utils = { workspace = true } miden-objects = { workspace = true } miden-tx = { workspace = true } -prost = { workspace = true } serde = { version = "1.0", features = ["derive"] } tokio = { workspace = true, features = ["rt-multi-thread", "net", "macros"] } tokio-stream = { workspace = true, features = ["net"] } -toml = { version = "0.8" } tonic = { workspace = true } tonic-web = { version = "0.12" } tracing = { workspace = true } -tracing-subscriber = { workspace = true } [dev-dependencies] -figment = { version = "0.10", features = ["toml", "env", "test"] } miden-node-utils = { workspace = true, features = ["tracing-forest"] } diff --git a/crates/store/Cargo.toml b/crates/store/Cargo.toml index 1337fcd86..6ca51bb4b 100644 --- a/crates/store/Cargo.toml +++ b/crates/store/Cargo.toml @@ -13,26 +13,21 @@ repository.workspace = true [dependencies] deadpool-sqlite = { version = "0.9.0", features = ["rt_tokio_1"] } -directories = { version = "5.0" } -figment = { version = "0.10", features = ["toml", "env"] } hex = { version = "0.4" } miden-lib = { workspace = true } miden-node-proto = { workspace = true } miden-node-utils = { workspace = true } miden-objects = { workspace = true } -prost = { workspace = true } rusqlite = { version = "0.32.1", features = ["array", "buildtime_bindgen", "bundled"] } -rusqlite_migration = { version = "1.0" } +rusqlite_migration = { version = "1.3" } serde = { version = "1.0", features = ["derive"] } thiserror = { workspace = true } tokio = { workspace = true, features = ["fs", "net", "macros", "rt-multi-thread"] } tokio-stream = { workspace = true, features = ["net"] } -toml = { version = "0.8" } tonic = { workspace = true } tracing = { workspace = true } -tracing-subscriber = { workspace = true } [dev-dependencies] -figment = { version = "0.10", features = ["toml", "env", "test"] } +assert_matches = { workspace = true} miden-node-utils = { workspace = true, features = ["tracing-forest"] } miden-objects = { workspace = true, features = ["testing"] } diff --git a/crates/store/src/db/tests.rs b/crates/store/src/db/tests.rs index a63f982f4..9a4e3141b 100644 --- a/crates/store/src/db/tests.rs +++ b/crates/store/src/db/tests.rs @@ -1,21 +1,21 @@ +use assert_matches::assert_matches; use miden_lib::transaction::TransactionKernel; use miden_node_proto::domain::accounts::AccountSummary; use miden_objects::{ accounts::{ account_id::testing::{ ACCOUNT_ID_FUNGIBLE_FAUCET_ON_CHAIN, ACCOUNT_ID_NON_FUNGIBLE_FAUCET_ON_CHAIN, - ACCOUNT_ID_OFF_CHAIN_SENDER, ACCOUNT_ID_REGULAR_ACCOUNT_IMMUTABLE_CODE_ON_CHAIN, - ACCOUNT_ID_REGULAR_ACCOUNT_UPDATABLE_CODE_OFF_CHAIN, + ACCOUNT_ID_OFF_CHAIN_SENDER, ACCOUNT_ID_REGULAR_ACCOUNT_UPDATABLE_CODE_OFF_CHAIN, }, delta::AccountUpdateDetails, - Account, AccountCode, AccountComponent, AccountDelta, AccountId, AccountStorage, - AccountStorageDelta, AccountType, AccountVaultDelta, StorageSlot, + Account, AccountBuilder, AccountComponent, AccountDelta, AccountId, AccountStorageDelta, + AccountStorageMode, AccountType, AccountVaultDelta, StorageSlot, }, - assets::{Asset, AssetVault, FungibleAsset, NonFungibleAsset, NonFungibleAssetDetails}, + assets::{Asset, FungibleAsset, NonFungibleAsset, NonFungibleAssetDetails}, block::{BlockAccountUpdate, BlockNoteIndex, BlockNoteTree}, crypto::{hash::rpo::RpoDigest, merkle::MerklePath}, notes::{NoteExecutionHint, NoteId, NoteMetadata, NoteType, Nullifier}, - BlockHeader, Felt, FieldElement, Word, ONE, ZERO, + BlockHeader, Felt, FieldElement, Word, ZERO, }; use rusqlite::{vtab::array, Connection}; @@ -328,8 +328,6 @@ fn test_sql_public_account_details() { let block_num = 1; create_block(&mut conn, block_num); - let account_id = - AccountId::try_from(ACCOUNT_ID_REGULAR_ACCOUNT_IMMUTABLE_CODE_ON_CHAIN).unwrap(); let fungible_faucet_id = AccountId::try_from(ACCOUNT_ID_FUNGIBLE_FAUCET_ON_CHAIN).unwrap(); let non_fungible_faucet_id = AccountId::try_from(ACCOUNT_ID_NON_FUNGIBLE_FAUCET_ON_CHAIN).unwrap(); @@ -341,18 +339,10 @@ fn test_sql_public_account_details() { .unwrap(), ); - let (code, storage) = mock_account_code_and_storage(account_id.account_type()); - - let mut account = Account::from_parts( - account_id, - AssetVault::new(&[ - Asset::Fungible(FungibleAsset::new(fungible_faucet_id, 150).unwrap()), - nft1, - ]) - .unwrap(), - storage, - code, - ZERO, + let mut account = mock_account_code_and_storage( + AccountType::RegularAccountImmutableCode, + AccountStorageMode::Public, + [Asset::Fungible(FungibleAsset::new(fungible_faucet_id, 150).unwrap()), nft1], ); // test querying empty table @@ -363,7 +353,7 @@ fn test_sql_public_account_details() { let inserted = sql::upsert_accounts( &transaction, &[BlockAccountUpdate::new( - account_id, + account.id(), account.hash(), AccountUpdateDetails::New(account.clone()), vec![], @@ -395,7 +385,7 @@ fn test_sql_public_account_details() { let vault_delta = AccountVaultDelta::from_iters([nft2], [nft1]); - let delta = AccountDelta::new(storage_delta, vault_delta, Some(ONE)).unwrap(); + let delta = AccountDelta::new(storage_delta, vault_delta, Some(Felt::new(2))).unwrap(); account.apply_delta(&delta).unwrap(); @@ -403,7 +393,7 @@ fn test_sql_public_account_details() { let inserted = sql::upsert_accounts( &transaction, &[BlockAccountUpdate::new( - account_id, + account.id(), account.hash(), AccountUpdateDetails::Delta(delta.clone()), vec![], @@ -427,12 +417,14 @@ fn test_sql_public_account_details() { assert_eq!(account_read.nonce(), account.nonce()); // Cleared item was not serialized, check it and apply delta only with clear item second time: - assert_eq!(account_read.storage().get_item(3), Ok(RpoDigest::default())); + assert_matches!(account_read.storage().get_item(3), Ok(digest) => { + assert_eq!(digest, RpoDigest::default()); + }); let storage_delta = AccountStorageDelta::from_iters([3], [], []); account_read .apply_delta( - &AccountDelta::new(storage_delta, AccountVaultDelta::default(), Some(Felt::new(2))) + &AccountDelta::new(storage_delta, AccountVaultDelta::default(), Some(Felt::new(3))) .unwrap(), ) .unwrap(); @@ -456,7 +448,7 @@ fn test_sql_public_account_details() { let inserted = sql::upsert_accounts( &transaction, &[BlockAccountUpdate::new( - account_id, + account.id(), account.hash(), AccountUpdateDetails::Delta(delta2.clone()), vec![], @@ -480,7 +472,7 @@ fn test_sql_public_account_details() { assert_eq!(account_read.nonce(), account.nonce()); let read_deltas = - sql::select_account_deltas(&mut conn, account_id.into(), 0, block_num + 1).unwrap(); + sql::select_account_deltas(&mut conn, account.id().into(), 0, block_num + 1).unwrap(); assert_eq!(read_deltas, vec![delta, delta2]); } @@ -977,7 +969,11 @@ fn insert_transactions(conn: &mut Connection) -> usize { count } -fn mock_account_code_and_storage(account_type: AccountType) -> (AccountCode, AccountStorage) { +fn mock_account_code_and_storage( + account_type: AccountType, + storage_mode: AccountStorageMode, + assets: impl IntoIterator, +) -> Account { let component_code = "\ export.account_procedure_1 push.1.2 @@ -1002,5 +998,12 @@ fn mock_account_code_and_storage(account_type: AccountType) -> (AccountCode, Acc .unwrap() .with_supported_type(account_type); - Account::initialize_from_components(account_type, &[component]).unwrap() + AccountBuilder::new() + .init_seed([0; 32]) + .account_type(account_type) + .storage_mode(storage_mode) + .with_assets(assets) + .with_component(component) + .build_existing() + .unwrap() }