From 09d29b60890e69a6683936f3bfc92ea342fbef1e Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Wed, 15 Jan 2025 07:08:28 +0200 Subject: [PATCH 01/13] update risc0 --- Cargo.lock | 96 +-- Cargo.toml | 15 +- crates/core/Cargo.toml | 1 + crates/zeth/Cargo.toml | 2 +- guests/reth-ethereum/Cargo.lock | 1069 +++++++++++++++++++++++++++--- guests/reth-ethereum/Cargo.toml | 13 +- guests/reth-optimism/Cargo.lock | 1071 ++++++++++++++++++++++++++++--- guests/reth-optimism/Cargo.toml | 11 +- 8 files changed, 2024 insertions(+), 254 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b05da8e..79890841 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,7 +300,7 @@ dependencies = [ "derive_more 1.0.0", "foldhash", "getrandom", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "hex-literal", "indexmap 2.6.0", "itoa", @@ -1205,8 +1205,9 @@ dependencies = [ [[package]] name = "bonsai-sdk" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa98bac2c125e6f7d5f73fd5bc99d3cf1c633993b4c603a973731e0b358e3e9c" dependencies = [ "duplicate", "maybe-async", @@ -2407,13 +2408,14 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", "foldhash", + "rayon", "serde", ] @@ -2664,7 +2666,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "serde", ] @@ -2865,7 +2867,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.0", + "hashbrown 0.15.2", ] [[package]] @@ -4563,8 +4565,9 @@ dependencies = [ [[package]] name = "risc0-binfmt" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "421b1d25e39b0a7c0bbb5bf662824bc102ef97b0ca1ddca7bfe142378e4e9127" dependencies = [ "anyhow", "borsh", @@ -4577,8 +4580,9 @@ dependencies = [ [[package]] name = "risc0-build" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21f1cd28e2ff0d478d7714d710efd739d9876cbf81dab145a57bc8582433b028" dependencies = [ "anyhow", "cargo_metadata", @@ -4595,8 +4599,9 @@ dependencies = [ [[package]] name = "risc0-build-kernel" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a63e1e7e2bb775b3e4e656c2cefaee417f7b0e32a67a481098da7ddd434e216b" dependencies = [ "cc", "directories", @@ -4609,12 +4614,14 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3806bfd8212934741033e424b5eafa86c67c660c7ba98e9492e0762e57afc21e" dependencies = [ "anyhow", "bytemuck", "cfg-if", + "keccak", "paste", "rayon", "risc0-binfmt", @@ -4629,8 +4636,9 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak-sys" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afcc5a9a32865043a2bb9a3c59bb425dc7f86a887f44b0602da1495a9d85534" dependencies = [ "cc", "cust", @@ -4644,8 +4652,9 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ea982a66c4f3337366454afc9d3c80eb3333c95ae94570ddc4c6c0fe53cf9f4" dependencies = [ "anyhow", "bytemuck", @@ -4669,8 +4678,9 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion-sys" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb152d44fe4458f1137b8a7fe7abe35ac81f55e198733450af7365bab418989" dependencies = [ "glob", "risc0-build-kernel", @@ -4681,8 +4691,9 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32b112b4bc86b35b6706fb7959a0bcfb8954ac9d040ad7f7aa88c8a054af1f" dependencies = [ "anyhow", "auto_ops", @@ -4714,8 +4725,9 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im-sys" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89a811905f9eeed92ca1e2d11d1d3bba3315e05e842ceaa70ace6b37a154e1c9" dependencies = [ "glob", "risc0-build-kernel", @@ -4726,8 +4738,9 @@ dependencies = [ [[package]] name = "risc0-core" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa498c93c2ec128b410639df28796bd7e0a20cac95fadb39595fb6cb3147fc0" dependencies = [ "bytemuck", "nvtx", @@ -4737,8 +4750,9 @@ dependencies = [ [[package]] name = "risc0-groth16" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e194641f6f14397da30b4627889113c0033b3ff2a6dfb4a4ba1962d24033dbc" dependencies = [ "anyhow", "ark-bn254", @@ -4761,8 +4775,9 @@ dependencies = [ [[package]] name = "risc0-sys" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d68b8b0aa5ee99718fb73a5349d94eca88584a3373e4f5ca61256e09e9b6d46" dependencies = [ "anyhow", "cust", @@ -4772,8 +4787,9 @@ dependencies = [ [[package]] name = "risc0-zkp" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f9973ed2591391c8d90bc5ff3102512879274102c6f12d63b0a20b1c132286a" dependencies = [ "anyhow", "blake2", @@ -4802,8 +4818,9 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61d800cb93c9f711b9f78a9e3ea09b396d279134281529a5032dafbbc713ede6" dependencies = [ "addr2line 0.22.0", "anyhow", @@ -4845,10 +4862,12 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2127f726a7d6ecf76c53110d3b6070c08a40111c5ef7e8c0fb58c40c4618244" dependencies = [ "bytemuck", + "cfg-if", "getrandom", "libm", "stability", @@ -4862,7 +4881,7 @@ checksum = "b11a153aec4a6ab60795f8ebe2923c597b16b05bb1504377451e705ef1a45323" dependencies = [ "bytecheck", "bytes", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "indexmap 2.6.0", "munge", "ptr_meta", @@ -6551,6 +6570,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "anyhow", + "hashbrown 0.15.2", "k256", "pot", "reth-chainspec", diff --git a/Cargo.toml b/Cargo.toml index 60afc797..7c673e02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,20 +18,16 @@ opt-level = 3 # RISC Zero [workspace.dependencies.bonsai-sdk] -git = "https://github.com/risc0/risc0" -rev = "8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" features = ["non_blocking"] [workspace.dependencies.risc0-build] -git = "https://github.com/risc0/risc0" -rev = "8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" features = ["unstable"] [workspace.dependencies.risc0-zkvm] -git = "https://github.com/risc0/risc0" -rev = "8801e2e3cd030acea2f03f01bd91f37e47e79e23" -default-features = false -features = ["bonsai"] +version = "1.2.1-rc.1" +features = ["unstable"] # External [workspace.dependencies] @@ -92,12 +88,13 @@ bincode = "1.3.3" bytemuck = "1.19.0" clap = { version = "4.0", features = ["derive"] } env_logger = "0.11.5" +hashbrown = { version = "0.15.2", features = ["rayon"] } k256 = { version = "0.13.3", features = ["serde", "pem"] } log = "0.4.22" flate2 = "1.0.34" once_cell = "1.20.2" pot = "3.0.1" -rkyv = "0.8.9" +rkyv = { version = "0.8.9", features = ["hashbrown-0_15"] } serde = { version = "1.0.210", features = ["derive"] } serde_json = { version = "1.0.128", features = ["alloc"] } serde_with = "3.11.0" diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 73f78caa..89ac1141 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -8,6 +8,7 @@ anyhow.workspace = true alloy-consensus.workspace = true alloy-primitives.workspace = true alloy-rlp.workspace = true +hashbrown.workspace = true k256.workspace = true pot.workspace = true rkyv.workspace = true diff --git a/crates/zeth/Cargo.toml b/crates/zeth/Cargo.toml index 30babcc6..d4a73224 100644 --- a/crates/zeth/Cargo.toml +++ b/crates/zeth/Cargo.toml @@ -8,7 +8,7 @@ workspace = true [dependencies.risc0-zkvm] workspace = true -features = ["std", "client", "unstable"] +features = ["client"] [dependencies.zeth-guests] workspace = true diff --git a/guests/reth-ethereum/Cargo.lock b/guests/reth-ethereum/Cargo.lock index f7bf3b7c..930c3007 100644 --- a/guests/reth-ethereum/Cargo.lock +++ b/guests/reth-ethereum/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "ahash" version = "0.8.11" @@ -23,6 +38,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "alloy-chains" version = "0.1.43" @@ -142,7 +163,7 @@ dependencies = [ "derive_more", "foldhash", "getrandom", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "hex-literal", "indexmap 2.6.0", "itoa", @@ -177,7 +198,7 @@ checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -233,7 +254,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -244,12 +265,12 @@ checksum = "6672337f19d837b9f7073c45853aeb528ed9f7dd6a4154ce683e9e5cb7794014" dependencies = [ "alloy-sol-macro-input", "const-hex", - "heck", + "heck 0.5.0", "indexmap 2.6.0", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "syn-solidity", "tiny-keccak", ] @@ -262,10 +283,10 @@ checksum = "0dff37dd20bfb118b777c96eda83b2067f4226d2644c5cfa00187b3bc01770ba" dependencies = [ "const-hex", "dunce", - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "syn-solidity", ] @@ -586,7 +607,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -595,6 +616,21 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + [[package]] name = "base16ct" version = "0.2.0" @@ -619,6 +655,15 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -698,6 +743,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "bonsai-sdk" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa98bac2c125e6f7d5f73fd5bc99d3cf1c633993b4c603a973731e0b358e3e9c" +dependencies = [ + "duplicate", + "maybe-async", + "reqwest", + "serde", + "thiserror 1.0.65", +] + [[package]] name = "borsh" version = "1.5.1" @@ -718,7 +776,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "syn_derive", ] @@ -754,7 +812,7 @@ checksum = "523363cbe1df49b68215efdf500b103ac3b0fb4836aed6d15689a076eadb8fff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -774,7 +832,7 @@ checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -806,6 +864,38 @@ dependencies = [ "serde", ] +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.23", + "serde", + "serde_json", + "thiserror 1.0.65", +] + [[package]] name = "cc" version = "1.1.31" @@ -839,7 +929,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -995,7 +1085,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1006,7 +1096,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1059,7 +1149,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "unicode-xid", ] @@ -1084,6 +1174,33 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[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 = "docker-generate" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf673e0848ef09fa4aeeba78e681cf651c0c7d35f76ee38cec8e55bc32fa111" + [[package]] name = "downcast-rs" version = "1.2.1" @@ -1096,6 +1213,16 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" +[[package]] +name = "duplicate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de78e66ac9061e030587b2a2e75cc88f22304913c907b11307bca737141230cb" +dependencies = [ + "heck 0.4.1", + "proc-macro-error", +] + [[package]] name = "dyn-clone" version = "1.0.17" @@ -1174,7 +1301,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1262,7 +1389,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1286,12 +1413,28 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + [[package]] name = "futures-core" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + [[package]] name = "futures-macro" version = "0.3.31" @@ -1300,9 +1443,15 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + [[package]] name = "futures-task" version = "0.3.31" @@ -1316,8 +1465,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", + "futures-io", "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -1341,10 +1493,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + [[package]] name = "glob" version = "0.3.1" @@ -1389,14 +1549,23 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ + "allocator-api2", + "equivalent", "foldhash", + "rayon", "serde", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -1433,6 +1602,102 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" + +[[package]] +name = "hyper" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.61" @@ -1516,10 +1781,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "serde", ] +[[package]] +name = "ipnet" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" + [[package]] name = "itertools" version = "0.10.5" @@ -1597,6 +1868,29 @@ dependencies = [ "sha3-asm", ] +[[package]] +name = "lazy-regex" +version = "3.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60c7310b93682b36b98fa7ea4de998d3463ccbebd94d935d6b48ba5b6ffa7126" +dependencies = [ + "lazy-regex-proc_macros", + "once_cell", + "regex", +] + +[[package]] +name = "lazy-regex-proc_macros" +version = "3.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ba01db5ef81e17eb10a5e0f2109d1b3a3e29bac3070fdbd7d156bf7dbd206a1" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "syn 2.0.96", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -1618,6 +1912,16 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1649,6 +1953,17 @@ dependencies = [ "libc", ] +[[package]] +name = "maybe-async" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", +] + [[package]] name = "memchr" version = "2.7.4" @@ -1689,7 +2004,33 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.85", + "syn 2.0.96", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.52.0", ] [[package]] @@ -1730,7 +2071,7 @@ checksum = "1bb5c1d8184f13f7d0ccbeeca0def2f9a181bce2624302793005f5ca8aa62e5e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1840,7 +2181,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1865,6 +2206,15 @@ dependencies = [ "malloc_buf", ] +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.20.2" @@ -1904,6 +2254,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "parity-scale-codec" version = "3.6.12" @@ -1959,7 +2315,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.65", "ucd-trie", ] @@ -2052,6 +2408,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", + "syn 1.0.109", "version_check", ] @@ -2085,14 +2442,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -2117,6 +2474,29 @@ dependencies = [ "unarray", ] +[[package]] +name = "prost" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" +dependencies = [ + "anyhow", + "itertools 0.13.0", + "proc-macro2", + "quote", + "syn 2.0.96", +] + [[package]] name = "ptr_meta" version = "0.3.0" @@ -2134,7 +2514,7 @@ checksum = "ca414edb151b4c8d125c12566ab0d74dc9cdba36fb80eb7b848c15f495fd32d1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -2144,27 +2524,79 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] -name = "quote" -version = "1.0.37" +name = "quinn" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ - "proc-macro2", + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.11", + "tokio", + "tracing", ] [[package]] -name = "radium" -version = "0.7.0" +name = "quinn-proto" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" +dependencies = [ + "bytes", + "getrandom", + "rand", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.11", + "tinyvec", + "tracing", + "web-time", +] [[package]] -name = "rancor" -version = "0.1.0" +name = "quinn-udp" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf5f7161924b9d1cea0e4cabc97c372cea92b5f927fc13c6bca67157a0ad947" +checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" dependencies = [ - "ptr_meta", + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.59.0", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rancor" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf5f7161924b9d1cea0e4cabc97c372cea92b5f927fc13c6bca67157a0ad947" +dependencies = [ + "ptr_meta", ] [[package]] @@ -2227,6 +2659,17 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror 1.0.65", +] + [[package]] name = "regex" version = "1.11.1" @@ -2265,6 +2708,52 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "reqwest" +version = "0.12.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pemfile", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-util", + "tower", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots", + "windows-registry", +] + [[package]] name = "reth-chainspec" version = "1.1.0" @@ -2308,7 +2797,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -2477,7 +2966,7 @@ source = "git+https://github.com/risc0/reth?branch=p1.1.0_zstd#760183fd601f61a3f dependencies = [ "serde", "serde_json", - "thiserror", + "thiserror 1.0.65", ] [[package]] @@ -2498,7 +2987,7 @@ dependencies = [ "alloy-rlp", "enr", "serde_with", - "thiserror", + "thiserror 1.0.65", "url", ] @@ -2561,7 +3050,7 @@ dependencies = [ "modular-bitfield", "reth-codecs", "serde", - "thiserror", + "thiserror 1.0.65", ] [[package]] @@ -2750,6 +3239,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -2771,8 +3275,9 @@ dependencies = [ [[package]] name = "risc0-binfmt" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "421b1d25e39b0a7c0bbb5bf662824bc102ef97b0ca1ddca7bfe142378e4e9127" dependencies = [ "anyhow", "borsh", @@ -2783,10 +3288,30 @@ dependencies = [ "tracing", ] +[[package]] +name = "risc0-build" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21f1cd28e2ff0d478d7714d710efd739d9876cbf81dab145a57bc8582433b028" +dependencies = [ + "anyhow", + "cargo_metadata", + "dirs", + "docker-generate", + "hex", + "risc0-binfmt", + "risc0-zkp", + "risc0-zkvm-platform", + "serde", + "serde_json", + "tempfile", +] + [[package]] name = "risc0-circuit-keccak" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3806bfd8212934741033e424b5eafa86c67c660c7ba98e9492e0762e57afc21e" dependencies = [ "anyhow", "bytemuck", @@ -2800,8 +3325,9 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ea982a66c4f3337366454afc9d3c80eb3333c95ae94570ddc4c6c0fe53cf9f4" dependencies = [ "anyhow", "bytemuck", @@ -2814,8 +3340,9 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32b112b4bc86b35b6706fb7959a0bcfb8954ac9d040ad7f7aa88c8a054af1f" dependencies = [ "anyhow", "metal", @@ -2829,8 +3356,9 @@ dependencies = [ [[package]] name = "risc0-core" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa498c93c2ec128b410639df28796bd7e0a20cac95fadb39595fb6cb3147fc0" dependencies = [ "bytemuck", "rand_core", @@ -2838,8 +3366,9 @@ dependencies = [ [[package]] name = "risc0-groth16" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e194641f6f14397da30b4627889113c0033b3ff2a6dfb4a4ba1962d24033dbc" dependencies = [ "anyhow", "ark-bn254", @@ -2858,8 +3387,9 @@ dependencies = [ [[package]] name = "risc0-zkp" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f9973ed2591391c8d90bc5ff3102512879274102c6f12d63b0a20b1c132286a" dependencies = [ "anyhow", "blake2", @@ -2881,15 +3411,22 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61d800cb93c9f711b9f78a9e3ea09b396d279134281529a5032dafbbc713ede6" dependencies = [ "anyhow", + "bincode", + "bonsai-sdk", "borsh", "bytemuck", + "bytes", "getrandom", "hex", + "lazy-regex", + "prost", "risc0-binfmt", + "risc0-build", "risc0-circuit-keccak", "risc0-circuit-recursion", "risc0-circuit-rv32im", @@ -2902,15 +3439,18 @@ dependencies = [ "serde", "sha2", "stability", + "tempfile", "tracing", ] [[package]] name = "risc0-zkvm-platform" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2127f726a7d6ecf76c53110d3b6070c08a40111c5ef7e8c0fb58c40c4618244" dependencies = [ "bytemuck", + "cfg-if", "getrandom", "libm", "stability", @@ -2924,7 +3464,7 @@ checksum = "b11a153aec4a6ab60795f8ebe2923c597b16b05bb1504377451e705ef1a45323" dependencies = [ "bytecheck", "bytes", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "indexmap 2.6.0", "munge", "ptr_meta", @@ -2943,7 +3483,7 @@ checksum = "beb382a4d9f53bd5c0be86b10d8179c3f8a14c30bf774ff77096ed6581e35981" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3006,6 +3546,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "rustc-hash" version = "2.0.0" @@ -3052,6 +3598,49 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.23.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +dependencies = [ + "web-time", +] + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.18" @@ -3130,6 +3719,9 @@ name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +dependencies = [ + "serde", +] [[package]] name = "semver-parser" @@ -3157,7 +3749,7 @@ checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3173,6 +3765,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "serde_with" version = "3.11.0" @@ -3200,7 +3804,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3215,8 +3819,8 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" -source = "git+https://github.com/risc0/RustCrypto-hashes?tag=sha2-v0.10.6-risczero.0#7fd6900c4f637bd15ee2642dfa77110f8f1ad065" +version = "0.10.8" +source = "git+https://github.com/risc0/RustCrypto-hashes?tag=sha2-v0.10.8-risczero.0#244dc3b08788f7a4ccce14c66896ae3b4f24c166" dependencies = [ "cfg-if", "cpufeatures", @@ -3283,6 +3887,16 @@ dependencies = [ "serde", ] +[[package]] +name = "socket2" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "spin" version = "0.9.8" @@ -3309,7 +3923,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3339,11 +3953,11 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3378,9 +3992,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -3396,7 +4010,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3408,7 +4022,16 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", ] [[package]] @@ -3436,7 +4059,16 @@ version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.65", +] + +[[package]] +name = "thiserror" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +dependencies = [ + "thiserror-impl 2.0.11", ] [[package]] @@ -3447,7 +4079,18 @@ checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", ] [[package]] @@ -3513,10 +4156,9 @@ dependencies = [ [[package]] name = "tiny-keccak" version = "2.0.2" -source = "git+https://github.com/risc0/tiny-keccak?rev=01e787dcb9b8a5d21857af37c4d51a4028a03fc4#01e787dcb9b8a5d21857af37c4d51a4028a03fc4" +source = "git+https://github.com/risc0/tiny-keccak?tag=tiny-keccak/v2.0.2-risczero.0#8fcc866dc94dcec3e79c3b2bc8fbc51b22f2d5e1" dependencies = [ "crunchy", - "risc0-zkvm", ] [[package]] @@ -3534,6 +4176,44 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokio" +version = "1.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml_datetime" version = "0.6.8" @@ -3551,6 +4231,33 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.40" @@ -3571,7 +4278,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3593,6 +4300,12 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.17.0" @@ -3656,6 +4369,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.2" @@ -3694,6 +4413,15 @@ dependencies = [ "libc", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -3722,10 +4450,22 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.95" @@ -3744,7 +4484,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3755,13 +4495,94 @@ version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "windows-core" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -3770,7 +4591,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -3779,7 +4600,22 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -3788,28 +4624,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -3822,24 +4676,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -3882,7 +4760,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3902,7 +4780,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3913,6 +4791,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "anyhow", + "hashbrown 0.15.2", "k256", "pot", "reth-chainspec", @@ -3921,7 +4800,7 @@ dependencies = [ "reth-storage-errors", "rkyv", "serde", - "thiserror", + "thiserror 1.0.65", "tiny-keccak", ] diff --git a/guests/reth-ethereum/Cargo.toml b/guests/reth-ethereum/Cargo.toml index 8b33eb70..8be0ba0c 100644 --- a/guests/reth-ethereum/Cargo.toml +++ b/guests/reth-ethereum/Cargo.toml @@ -15,14 +15,11 @@ codegen-units = 1 opt-level = 3 [dependencies.risc0-zkvm] -git = "https://github.com/risc0/risc0" -rev = "8801e2e3cd030acea2f03f01bd91f37e47e79e23" -default-features = false -features = ["std", "unstable"] +version = "1.2.1-rc.1" +features = ["unstable"] [dependencies.risc0-zkvm-platform] -git = "https://github.com/risc0/risc0" -rev = "8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" features = ["sys-getenv"] [dependencies.zeth-core] @@ -40,5 +37,5 @@ c-kzg = { version = "=1.0.3", features = ["risc0-ffi"] } c-kzg = { git = "https://github.com/risc0/c-kzg-4844.git", branch = "p1.0.3" } crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.5-risczero.0" } k256 = { git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.1" } -sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.6-risczero.0" } -tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", rev = "01e787dcb9b8a5d21857af37c4d51a4028a03fc4" } +sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" } +tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", tag = "tiny-keccak/v2.0.2-risczero.0" } diff --git a/guests/reth-optimism/Cargo.lock b/guests/reth-optimism/Cargo.lock index 0f25a72b..72fccf23 100644 --- a/guests/reth-optimism/Cargo.lock +++ b/guests/reth-optimism/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "ahash" version = "0.8.11" @@ -23,6 +38,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "alloy-chains" version = "0.1.43" @@ -130,7 +151,7 @@ dependencies = [ "derive_more", "foldhash", "getrandom", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "hex-literal", "indexmap 2.6.0", "itoa", @@ -165,7 +186,7 @@ checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -221,7 +242,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -232,12 +253,12 @@ checksum = "9ed5047c9a241df94327879c2b0729155b58b941eae7805a7ada2e19436e6b39" dependencies = [ "alloy-sol-macro-input", "const-hex", - "heck", + "heck 0.5.0", "indexmap 2.6.0", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "syn-solidity", "tiny-keccak", ] @@ -250,10 +271,10 @@ checksum = "5dee02a81f529c415082235129f0df8b8e60aa1601b9c9298ffe54d75f57210b" dependencies = [ "const-hex", "dunce", - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "syn-solidity", ] @@ -562,7 +583,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -571,6 +592,21 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + [[package]] name = "base16ct" version = "0.2.0" @@ -595,6 +631,15 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -674,6 +719,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "bonsai-sdk" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa98bac2c125e6f7d5f73fd5bc99d3cf1c633993b4c603a973731e0b358e3e9c" +dependencies = [ + "duplicate", + "maybe-async", + "reqwest", + "serde", + "thiserror 1.0.65", +] + [[package]] name = "borsh" version = "1.5.1" @@ -694,7 +752,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "syn_derive", ] @@ -730,7 +788,7 @@ checksum = "523363cbe1df49b68215efdf500b103ac3b0fb4836aed6d15689a076eadb8fff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -750,7 +808,7 @@ checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -782,6 +840,38 @@ dependencies = [ "serde", ] +[[package]] +name = "camino" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.23", + "serde", + "serde_json", + "thiserror 1.0.65", +] + [[package]] name = "cc" version = "1.1.31" @@ -815,7 +905,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -971,7 +1061,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -982,7 +1072,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1035,7 +1125,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "unicode-xid", ] @@ -1060,6 +1150,33 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[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 = "docker-generate" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf673e0848ef09fa4aeeba78e681cf651c0c7d35f76ee38cec8e55bc32fa111" + [[package]] name = "downcast-rs" version = "1.2.1" @@ -1072,6 +1189,16 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" +[[package]] +name = "duplicate" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de78e66ac9061e030587b2a2e75cc88f22304913c907b11307bca737141230cb" +dependencies = [ + "heck 0.4.1", + "proc-macro-error", +] + [[package]] name = "dyn-clone" version = "1.0.17" @@ -1150,7 +1277,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1238,7 +1365,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1262,12 +1389,28 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + [[package]] name = "futures-core" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + [[package]] name = "futures-macro" version = "0.3.31" @@ -1276,9 +1419,15 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + [[package]] name = "futures-task" version = "0.3.31" @@ -1292,8 +1441,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", + "futures-io", "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -1317,10 +1469,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + [[package]] name = "glob" version = "0.3.1" @@ -1365,14 +1525,23 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ + "allocator-api2", + "equivalent", "foldhash", + "rayon", "serde", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -1409,6 +1578,102 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" + +[[package]] +name = "hyper" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.61" @@ -1492,10 +1757,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "serde", ] +[[package]] +name = "ipnet" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" + [[package]] name = "itertools" version = "0.10.5" @@ -1573,6 +1844,29 @@ dependencies = [ "sha3-asm", ] +[[package]] +name = "lazy-regex" +version = "3.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60c7310b93682b36b98fa7ea4de998d3463ccbebd94d935d6b48ba5b6ffa7126" +dependencies = [ + "lazy-regex-proc_macros", + "once_cell", + "regex", +] + +[[package]] +name = "lazy-regex-proc_macros" +version = "3.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ba01db5ef81e17eb10a5e0f2109d1b3a3e29bac3070fdbd7d156bf7dbd206a1" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "syn 2.0.96", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -1594,6 +1888,16 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1625,6 +1929,17 @@ dependencies = [ "libc", ] +[[package]] +name = "maybe-async" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", +] + [[package]] name = "memchr" version = "2.7.4" @@ -1665,7 +1980,33 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.85", + "syn 2.0.96", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.52.0", ] [[package]] @@ -1706,7 +2047,7 @@ checksum = "1bb5c1d8184f13f7d0ccbeeca0def2f9a181bce2624302793005f5ca8aa62e5e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1816,7 +2157,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -1841,6 +2182,15 @@ dependencies = [ "malloc_buf", ] +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.20.2" @@ -1880,6 +2230,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "p256" version = "0.13.2" @@ -1947,7 +2303,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.65", "ucd-trie", ] @@ -2049,6 +2405,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", + "syn 1.0.109", "version_check", ] @@ -2082,14 +2439,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -2114,6 +2471,29 @@ dependencies = [ "unarray", ] +[[package]] +name = "prost" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" +dependencies = [ + "anyhow", + "itertools 0.13.0", + "proc-macro2", + "quote", + "syn 2.0.96", +] + [[package]] name = "ptr_meta" version = "0.3.0" @@ -2131,7 +2511,7 @@ checksum = "ca414edb151b4c8d125c12566ab0d74dc9cdba36fb80eb7b848c15f495fd32d1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -2141,27 +2521,79 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] -name = "quote" -version = "1.0.37" +name = "quinn" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ - "proc-macro2", + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.11", + "tokio", + "tracing", ] [[package]] -name = "radium" -version = "0.7.0" +name = "quinn-proto" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" +dependencies = [ + "bytes", + "getrandom", + "rand", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.11", + "tinyvec", + "tracing", + "web-time", +] [[package]] -name = "rancor" -version = "0.1.0" +name = "quinn-udp" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf5f7161924b9d1cea0e4cabc97c372cea92b5f927fc13c6bca67157a0ad947" +checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" dependencies = [ - "ptr_meta", + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.59.0", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rancor" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf5f7161924b9d1cea0e4cabc97c372cea92b5f927fc13c6bca67157a0ad947" +dependencies = [ + "ptr_meta", ] [[package]] @@ -2224,6 +2656,17 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror 1.0.65", +] + [[package]] name = "regex" version = "1.11.1" @@ -2262,6 +2705,52 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "reqwest" +version = "0.12.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pemfile", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-util", + "tower", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots", + "windows-registry", +] + [[package]] name = "reth-chainspec" version = "1.1.0" @@ -2307,7 +2796,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -2444,7 +2933,7 @@ source = "git+https://github.com/risc0/reth?branch=p1.1.0_zstd#760183fd601f61a3f dependencies = [ "serde", "serde_json", - "thiserror", + "thiserror 1.0.65", ] [[package]] @@ -2465,7 +2954,7 @@ dependencies = [ "alloy-rlp", "enr", "serde_with", - "thiserror", + "thiserror 1.0.65", "url", ] @@ -2524,7 +3013,7 @@ dependencies = [ "reth-revm", "revm", "revm-primitives", - "thiserror", + "thiserror 1.0.65", "tracing", ] @@ -2600,7 +3089,7 @@ dependencies = [ "modular-bitfield", "reth-codecs", "serde", - "thiserror", + "thiserror 1.0.65", ] [[package]] @@ -2790,6 +3279,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -2811,8 +3315,9 @@ dependencies = [ [[package]] name = "risc0-binfmt" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "421b1d25e39b0a7c0bbb5bf662824bc102ef97b0ca1ddca7bfe142378e4e9127" dependencies = [ "anyhow", "borsh", @@ -2823,10 +3328,30 @@ dependencies = [ "tracing", ] +[[package]] +name = "risc0-build" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21f1cd28e2ff0d478d7714d710efd739d9876cbf81dab145a57bc8582433b028" +dependencies = [ + "anyhow", + "cargo_metadata", + "dirs", + "docker-generate", + "hex", + "risc0-binfmt", + "risc0-zkp", + "risc0-zkvm-platform", + "serde", + "serde_json", + "tempfile", +] + [[package]] name = "risc0-circuit-keccak" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3806bfd8212934741033e424b5eafa86c67c660c7ba98e9492e0762e57afc21e" dependencies = [ "anyhow", "bytemuck", @@ -2840,8 +3365,9 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ea982a66c4f3337366454afc9d3c80eb3333c95ae94570ddc4c6c0fe53cf9f4" dependencies = [ "anyhow", "bytemuck", @@ -2854,8 +3380,9 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32b112b4bc86b35b6706fb7959a0bcfb8954ac9d040ad7f7aa88c8a054af1f" dependencies = [ "anyhow", "metal", @@ -2869,8 +3396,9 @@ dependencies = [ [[package]] name = "risc0-core" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa498c93c2ec128b410639df28796bd7e0a20cac95fadb39595fb6cb3147fc0" dependencies = [ "bytemuck", "rand_core", @@ -2878,8 +3406,9 @@ dependencies = [ [[package]] name = "risc0-groth16" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e194641f6f14397da30b4627889113c0033b3ff2a6dfb4a4ba1962d24033dbc" dependencies = [ "anyhow", "ark-bn254", @@ -2898,8 +3427,9 @@ dependencies = [ [[package]] name = "risc0-zkp" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f9973ed2591391c8d90bc5ff3102512879274102c6f12d63b0a20b1c132286a" dependencies = [ "anyhow", "blake2", @@ -2921,15 +3451,22 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61d800cb93c9f711b9f78a9e3ea09b396d279134281529a5032dafbbc713ede6" dependencies = [ "anyhow", + "bincode", + "bonsai-sdk", "borsh", "bytemuck", + "bytes", "getrandom", "hex", + "lazy-regex", + "prost", "risc0-binfmt", + "risc0-build", "risc0-circuit-keccak", "risc0-circuit-recursion", "risc0-circuit-rv32im", @@ -2942,15 +3479,18 @@ dependencies = [ "serde", "sha2", "stability", + "tempfile", "tracing", ] [[package]] name = "risc0-zkvm-platform" -version = "1.3.0-alpha.1" -source = "git+https://github.com/risc0/risc0?rev=8801e2e3cd030acea2f03f01bd91f37e47e79e23#8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2127f726a7d6ecf76c53110d3b6070c08a40111c5ef7e8c0fb58c40c4618244" dependencies = [ "bytemuck", + "cfg-if", "getrandom", "libm", "stability", @@ -2964,7 +3504,7 @@ checksum = "b11a153aec4a6ab60795f8ebe2923c597b16b05bb1504377451e705ef1a45323" dependencies = [ "bytecheck", "bytes", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "indexmap 2.6.0", "munge", "ptr_meta", @@ -2983,7 +3523,7 @@ checksum = "beb382a4d9f53bd5c0be86b10d8179c3f8a14c30bf774ff77096ed6581e35981" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3046,6 +3586,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "rustc-hash" version = "2.0.0" @@ -3092,6 +3638,49 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.23.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +dependencies = [ + "web-time", +] + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.18" @@ -3170,6 +3759,9 @@ name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +dependencies = [ + "serde", +] [[package]] name = "semver-parser" @@ -3197,7 +3789,7 @@ checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3213,6 +3805,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "serde_with" version = "3.11.0" @@ -3240,7 +3844,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3255,8 +3859,8 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" -source = "git+https://github.com/risc0/RustCrypto-hashes?tag=sha2-v0.10.6-risczero.0#7fd6900c4f637bd15ee2642dfa77110f8f1ad065" +version = "0.10.8" +source = "git+https://github.com/risc0/RustCrypto-hashes?tag=sha2-v0.10.8-risczero.0#244dc3b08788f7a4ccce14c66896ae3b4f24c166" dependencies = [ "cfg-if", "cpufeatures", @@ -3323,6 +3927,16 @@ dependencies = [ "serde", ] +[[package]] +name = "socket2" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "spin" version = "0.9.8" @@ -3349,7 +3963,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3379,11 +3993,11 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3418,9 +4032,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.85" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -3436,7 +4050,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3448,7 +4062,16 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", ] [[package]] @@ -3476,7 +4099,16 @@ version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.65", +] + +[[package]] +name = "thiserror" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +dependencies = [ + "thiserror-impl 2.0.11", ] [[package]] @@ -3487,7 +4119,18 @@ checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", ] [[package]] @@ -3553,10 +4196,9 @@ dependencies = [ [[package]] name = "tiny-keccak" version = "2.0.2" -source = "git+https://github.com/risc0/tiny-keccak?rev=01e787dcb9b8a5d21857af37c4d51a4028a03fc4#01e787dcb9b8a5d21857af37c4d51a4028a03fc4" +source = "git+https://github.com/risc0/tiny-keccak?tag=tiny-keccak/v2.0.2-risczero.0#8fcc866dc94dcec3e79c3b2bc8fbc51b22f2d5e1" dependencies = [ "crunchy", - "risc0-zkvm", ] [[package]] @@ -3574,6 +4216,44 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokio" +version = "1.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml_datetime" version = "0.6.8" @@ -3591,6 +4271,33 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.40" @@ -3611,7 +4318,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3633,6 +4340,12 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.17.0" @@ -3696,6 +4409,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.2" @@ -3734,6 +4453,15 @@ dependencies = [ "libc", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -3762,10 +4490,22 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.95" @@ -3784,7 +4524,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3795,13 +4535,94 @@ version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "windows-core" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -3810,7 +4631,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -3819,7 +4640,22 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -3828,28 +4664,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -3862,24 +4716,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -3922,7 +4800,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3942,7 +4820,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.85", + "syn 2.0.96", ] [[package]] @@ -3953,6 +4831,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "anyhow", + "hashbrown 0.15.2", "k256", "pot", "reth-chainspec", @@ -3961,7 +4840,7 @@ dependencies = [ "reth-storage-errors", "rkyv", "serde", - "thiserror", + "thiserror 1.0.65", "tiny-keccak", ] diff --git a/guests/reth-optimism/Cargo.toml b/guests/reth-optimism/Cargo.toml index 6b981d83..9794634b 100644 --- a/guests/reth-optimism/Cargo.toml +++ b/guests/reth-optimism/Cargo.toml @@ -15,14 +15,11 @@ codegen-units = 1 opt-level = 3 [dependencies.risc0-zkvm] -git = "https://github.com/risc0/risc0" -rev = "8801e2e3cd030acea2f03f01bd91f37e47e79e23" -default-features = false +version = "1.2.1-rc.1" features = ["std", "unstable"] [dependencies.risc0-zkvm-platform] -git = "https://github.com/risc0/risc0" -rev = "8801e2e3cd030acea2f03f01bd91f37e47e79e23" +version = "1.2.1-rc.1" features = ["sys-getenv"] [dependencies.zeth-core] @@ -40,5 +37,5 @@ c-kzg = { version = "=1.0.3", features = ["risc0-ffi"] } c-kzg = { git = "https://github.com/risc0/c-kzg-4844.git", branch = "p1.0.3" } crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.5-risczero.0" } k256 = { git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.1" } -sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.6-risczero.0" } -tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", rev = "01e787dcb9b8a5d21857af37c4d51a4028a03fc4" } +sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" } +tiny-keccak = { git = "https://github.com/risc0/tiny-keccak", tag = "tiny-keccak/v2.0.2-risczero.0" } From 788371ce9768dfa843736ea3e4eb4f20fd594407 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Wed, 15 Jan 2025 07:15:01 +0200 Subject: [PATCH 02/13] patch homestead sigs --- crates/core-ethereum/src/lib.rs | 13 ++++++++++--- crates/core/src/stateless/engine.rs | 2 ++ crates/preflight/src/client.rs | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/core-ethereum/src/lib.rs b/crates/core-ethereum/src/lib.rs index e5ed95e6..73a0b8e6 100644 --- a/crates/core-ethereum/src/lib.rs +++ b/crates/core-ethereum/src/lib.rs @@ -18,7 +18,7 @@ use crate::chain_spec::{DEV, HOLESKY, MAINNET, SEPOLIA}; use anyhow::Context; use k256::ecdsa::signature::hazmat::PrehashVerifier; use k256::ecdsa::VerifyingKey; -use reth_chainspec::{ChainSpec, NamedChain}; +use reth_chainspec::{ChainSpec, EthereumHardforks, NamedChain}; use reth_consensus::Consensus; use reth_ethereum_consensus::EthBeaconConsensus; use reth_evm::execute::{ @@ -126,8 +126,15 @@ where let vk = &signers[i]; let sig = tx.signature(); - sig.to_k256() - .and_then(|sig| vk.verify_prehash(tx.signature_hash().as_slice(), &sig)) + let sig = if !chain_spec.is_homestead_active_at_block(block.number) { + sig.normalize_s() + .map(|s| s.to_k256()) + .unwrap_or_else(|| sig.to_k256()) + } else { + sig.to_k256() + }; + + sig.and_then(|sig| vk.verify_prehash(tx.signature_hash().as_slice(), &sig)) .with_context(|| format!("invalid signature for tx {i}"))?; senders.push(Address::from_public_key(vk)) diff --git a/crates/core/src/stateless/engine.rs b/crates/core/src/stateless/engine.rs index 878d00df..e216791e 100644 --- a/crates/core/src/stateless/engine.rs +++ b/crates/core/src/stateless/engine.rs @@ -154,6 +154,7 @@ impl StatelessClientEngine StatelessClientEngine Date: Wed, 15 Jan 2025 07:30:56 +0200 Subject: [PATCH 03/13] patch trie db --- crates/core/src/stateless/initialize.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/core/src/stateless/initialize.rs b/crates/core/src/stateless/initialize.rs index 5bd42ddd..51a16a71 100644 --- a/crates/core/src/stateless/initialize.rs +++ b/crates/core/src/stateless/initialize.rs @@ -64,6 +64,23 @@ impl InitializationStrategy for TrieDbInitia .map(|bytes| (keccak(&bytes).into(), Bytecode::new_raw(bytes))) .collect(); + // Verify account data in db + for (address, StorageEntry { storage_trie, .. }) in storage_tries.iter() { + // load the account from the state trie + let state_account = state_trie.get_rlp::(&keccak(address))?; + + // check that the account storage root matches the storage trie root of the input + let storage_root = state_account.map_or(EMPTY_ROOT_HASH, |a| a.storage_root); + if storage_root != storage_trie.hash() { + bail!( + "Invalid storage trie for {}: expected {}, got {}", + address, + storage_root, + storage_trie.hash() + ) + } + } + // prepare block hash history let mut block_hashes: HashMap = HashMap::with_capacity_and_hasher(ancestor_headers.len() + 1, Default::default()); From 2babce83f5320ba89ca96e582952f25a44d674e1 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Wed, 15 Jan 2025 07:36:56 +0200 Subject: [PATCH 04/13] revert to MemDB --- guests/reth-ethereum/src/main.rs | 6 +++--- guests/reth-optimism/src/main.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/guests/reth-ethereum/src/main.rs b/guests/reth-ethereum/src/main.rs index 2db0d6a5..9cfe50e3 100644 --- a/guests/reth-ethereum/src/main.rs +++ b/guests/reth-ethereum/src/main.rs @@ -13,7 +13,7 @@ // limitations under the License. use risc0_zkvm::guest::env; -use zeth_core::db::trie::TrieDB; +use zeth_core::db::memory::MemoryDB; use zeth_core::stateless::client::StatelessClient; use zeth_core_ethereum::{RethCoreDriver, RethStatelessClient}; @@ -28,7 +28,7 @@ fn main() { let stateless_client_data_pot = env::read_frame(); env::log("Deserializing input data"); let stateless_client_data = - >::data_from_parts( + >::data_from_parts( &stateless_client_data_rkyv, &stateless_client_data_pot, ) @@ -41,7 +41,7 @@ fn main() { let chain_id = stateless_client_data.chain as u64; // Build the block env::log("Validating blocks"); - let engine = >::validate( + let engine = >::validate( stateless_client_data, ) .expect("block validation failed"); diff --git a/guests/reth-optimism/src/main.rs b/guests/reth-optimism/src/main.rs index e86f9c36..68eb7200 100644 --- a/guests/reth-optimism/src/main.rs +++ b/guests/reth-optimism/src/main.rs @@ -13,7 +13,7 @@ // limitations under the License. use risc0_zkvm::guest::env; -use zeth_core::db::trie::TrieDB; +use zeth_core::db::memory::MemoryDB; use zeth_core::stateless::client::StatelessClient; use zeth_core_optimism::{OpRethCoreDriver, OpRethStatelessClient}; @@ -28,7 +28,7 @@ fn main() { let stateless_client_data_pot = env::read_frame(); env::log("Deserializing input data"); let stateless_client_data = - >::data_from_parts( + >::data_from_parts( &stateless_client_data_rkyv, &stateless_client_data_pot, ) @@ -41,7 +41,7 @@ fn main() { let chain_id = stateless_client_data.chain as u64; // Build the block env::log("Validating blocks"); - let engine = >::validate( + let engine = >::validate( stateless_client_data, ) .expect("block validation failed"); From fa55f28d72b69f5b411f8c221a4d9f6b0c6fb3f3 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Wed, 15 Jan 2025 07:52:05 +0200 Subject: [PATCH 05/13] feat: hashbrown perf --- Cargo.toml | 2 +- crates/core/src/db/trie.rs | 7 +++-- crates/core/src/lib.rs | 1 + crates/core/src/map.rs | 40 +++++++++++++++++++++++++ crates/core/src/stateless/data.rs | 7 +++-- crates/core/src/stateless/finalize.rs | 7 +++-- crates/core/src/stateless/initialize.rs | 9 +++--- crates/preflight/src/client.rs | 5 ++-- crates/preflight/src/trie.rs | 3 +- 9 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 crates/core/src/map.rs diff --git a/Cargo.toml b/Cargo.toml index 7c673e02..dfa020c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ alloy = { version = "0.4.2", features = ["full"] } alloy-chains = "0.1.38" alloy-consensus = "0.4.2" alloy-genesis = "0.4.2" -alloy-primitives = { version = "0.8.8", default-features = false, features = ["k256"] } +alloy-primitives = { version = "0.8.8", default-features = false, features = ["k256", "map-hashbrown"] } alloy-rlp = "0.3.8" op-alloy-consensus = "0.4.0" op-alloy-network = "0.4.0" diff --git a/crates/core/src/db/trie.rs b/crates/core/src/db/trie.rs index 7398b0c0..2d9f93ad 100644 --- a/crates/core/src/db/trie.rs +++ b/crates/core/src/db/trie.rs @@ -13,6 +13,7 @@ // limitations under the License. use crate::keccak::keccak; +use crate::map::NoMapHasher; use crate::mpt::MptNode; use crate::rescue::Recoverable; use crate::stateless::data::StorageEntry; @@ -27,9 +28,9 @@ use reth_storage_errors::provider::ProviderError; #[derive(Default)] pub struct TrieDB { pub accounts: MptNode, - pub storage: HashMap, - pub contracts: HashMap, - pub block_hashes: HashMap, + pub storage: HashMap, + pub contracts: HashMap, + pub block_hashes: HashMap, } impl Recoverable for TrieDB { diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 2916eb9c..a1e34ceb 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -15,6 +15,7 @@ pub mod db; pub mod driver; pub mod keccak; +pub mod map; pub mod mpt; pub mod rescue; pub mod stateless; diff --git a/crates/core/src/map.rs b/crates/core/src/map.rs new file mode 100644 index 00000000..b7938d51 --- /dev/null +++ b/crates/core/src/map.rs @@ -0,0 +1,40 @@ +// Copyright 2025 RISC Zero, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::hash::{BuildHasher, Hasher}; + +#[derive(Clone, Default)] +pub struct NoMapHasher; + +impl BuildHasher for NoMapHasher { + type Hasher = NoHasher; + + fn build_hasher(&self) -> Self::Hasher { + NoHasher::default() + } +} + +#[derive(Default)] +pub struct NoHasher([u8; 8]); + +impl Hasher for NoHasher { + fn finish(&self) -> u64 { + u64::from_be_bytes(self.0) + } + + fn write(&mut self, bytes: &[u8]) { + let l = std::cmp::min(8, bytes.len()); + self.0[..l].copy_from_slice(&bytes[..l]); + } +} diff --git a/crates/core/src/stateless/data.rs b/crates/core/src/stateless/data.rs index 910693ae..54015ad9 100644 --- a/crates/core/src/stateless/data.rs +++ b/crates/core/src/stateless/data.rs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::map::NoMapHasher; use crate::mpt::MptNode; use alloy_primitives::map::HashMap; use alloy_primitives::{Address, Bytes, U256}; @@ -92,7 +93,7 @@ pub struct _StatelessClientData { /// State trie of the parent block. pub state_trie: MptNode, /// Maps each address with its storage trie and the used storage slots. - pub storage_tries: HashMap, + pub storage_tries: HashMap, /// The code for each account pub contracts: Vec, /// Immediate parent header @@ -129,7 +130,7 @@ pub struct StatelessClientData { pub state_trie: MptNode, /// Maps each address with its storage trie and the used storage slots. #[rkyv(with = rkyv::with::MapKV)] - pub storage_tries: HashMap, + pub storage_tries: HashMap, /// The code for each account #[rkyv(with = rkyv::with::Map)] pub contracts: Vec, @@ -166,7 +167,7 @@ pub struct RkyvStatelessClientData { pub state_trie: MptNode, /// Maps each address with its storage trie and the used storage slots. #[rkyv(with = rkyv::with::MapKV)] - pub storage_tries: HashMap, + pub storage_tries: HashMap, /// The code for each account #[rkyv(with = rkyv::with::Map)] pub contracts: Vec, diff --git a/crates/core/src/stateless/finalize.rs b/crates/core/src/stateless/finalize.rs index 1310b529..a7567442 100644 --- a/crates/core/src/stateless/finalize.rs +++ b/crates/core/src/stateless/finalize.rs @@ -17,6 +17,7 @@ use crate::db::trie::TrieDB; use crate::db::update::{into_plain_state, Update}; use crate::driver::CoreDriver; use crate::keccak::keccak; +use crate::map::NoMapHasher; use crate::mpt::MptNode; use crate::stateless::data::StorageEntry; use alloy_consensus::Account; @@ -30,7 +31,7 @@ pub trait FinalizationStrategy { fn finalize_state( block: &mut Driver::Block, state_trie: &mut MptNode, - storage_tries: &mut HashMap, + storage_tries: &mut HashMap, parent_header: &mut Driver::Header, db: Option<&mut Database>, bundle_state: BundleState, @@ -44,7 +45,7 @@ impl FinalizationStrategy for TrieDbFinaliza fn finalize_state( block: &mut Driver::Block, _state_trie: &mut MptNode, - _storage_tries: &mut HashMap, + _storage_tries: &mut HashMap, parent_header: &mut Driver::Header, db: Option<&mut TrieDB>, bundle_state: BundleState, @@ -89,7 +90,7 @@ impl FinalizationStrategy for MemoryDbFina fn finalize_state( block: &mut Driver::Block, state_trie: &mut MptNode, - storage_tries: &mut HashMap, + storage_tries: &mut HashMap, parent_header: &mut Driver::Header, db: Option<&mut MemoryDB>, bundle_state: BundleState, diff --git a/crates/core/src/stateless/initialize.rs b/crates/core/src/stateless/initialize.rs index 51a16a71..78c18cdb 100644 --- a/crates/core/src/stateless/initialize.rs +++ b/crates/core/src/stateless/initialize.rs @@ -16,6 +16,7 @@ use crate::db::memory::MemoryDB; use crate::db::trie::TrieDB; use crate::driver::CoreDriver; use crate::keccak::keccak; +use crate::map::NoMapHasher; use crate::mpt::MptNode; use crate::stateless::data::StorageEntry; use alloy_consensus::constants::EMPTY_ROOT_HASH; @@ -32,7 +33,7 @@ use std::default::Default; pub trait InitializationStrategy { fn initialize_database( state_trie: &mut MptNode, - storage_tries: &mut HashMap, + storage_tries: &mut HashMap, contracts: &mut Vec, parent_header: &mut Driver::Header, ancestor_headers: &mut Vec, @@ -44,7 +45,7 @@ pub struct TrieDbInitializationStrategy; impl InitializationStrategy for TrieDbInitializationStrategy { fn initialize_database( state_trie: &mut MptNode, - storage_tries: &mut HashMap, + storage_tries: &mut HashMap, contracts: &mut Vec, parent_header: &mut Driver::Header, ancestor_headers: &mut Vec, @@ -82,7 +83,7 @@ impl InitializationStrategy for TrieDbInitia } // prepare block hash history - let mut block_hashes: HashMap = + let mut block_hashes: HashMap = HashMap::with_capacity_and_hasher(ancestor_headers.len() + 1, Default::default()); block_hashes.insert( Driver::block_number(parent_header), @@ -127,7 +128,7 @@ impl InitializationStrategy { fn initialize_database( state_trie: &mut MptNode, - storage_tries: &mut HashMap, + storage_tries: &mut HashMap, contracts: &mut Vec, parent_header: &mut Driver::Header, ancestor_headers: &mut Vec, diff --git a/crates/preflight/src/client.rs b/crates/preflight/src/client.rs index 82e8823b..80ee28bf 100644 --- a/crates/preflight/src/client.rs +++ b/crates/preflight/src/client.rs @@ -20,7 +20,7 @@ use crate::provider::{new_provider, Provider}; use crate::trie::extend_proof_tries; use alloy::network::Network; use alloy::primitives::map::HashMap; -use alloy::primitives::Bytes; +use alloy::primitives::{Address, Bytes}; use anyhow::Context; use log::{debug, info, warn}; use std::cell::RefCell; @@ -29,6 +29,7 @@ use std::path::PathBuf; use std::rc::Rc; use zeth_core::db::update::into_plain_state; use zeth_core::driver::CoreDriver; +use zeth_core::map::NoMapHasher; use zeth_core::mpt::{ parse_proof, resolve_nodes_in_place, shorten_node_path, MptNode, MptNodeReference, }; @@ -168,7 +169,7 @@ where let core_parent_header = P::derive_header(data.parent_header.clone()); let mut state_trie = MptNode::from(R::state_root(&core_parent_header)); - let mut storage_tries = Default::default(); + let mut storage_tries = HashMap::::default(); let mut contracts: Vec = Default::default(); let mut ancestor_headers: Vec = Default::default(); diff --git a/crates/preflight/src/trie.rs b/crates/preflight/src/trie.rs index 47d84a38..04356baf 100644 --- a/crates/preflight/src/trie.rs +++ b/crates/preflight/src/trie.rs @@ -19,6 +19,7 @@ use anyhow::Context; use std::collections::VecDeque; use std::iter; use zeth_core::keccak::keccak; +use zeth_core::map::NoMapHasher; use zeth_core::mpt::{ is_not_included, mpt_from_proof, parse_proof, prefix_nibs, resolve_nodes, resolve_nodes_in_place, shorten_node_path, MptNode, MptNodeData, MptNodeReference, @@ -29,7 +30,7 @@ pub type TrieOrphan = (B256, B256); pub type OrphanPair = (Vec, Vec<(Address, TrieOrphan)>); pub fn extend_proof_tries( state_trie: &mut MptNode, - storage_tries: &mut HashMap, + storage_tries: &mut HashMap, initialization_proofs: HashMap, finalization_proofs: HashMap, ) -> anyhow::Result { From e410346bde7bedd14454cdc76f570bc2416627d0 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Wed, 15 Jan 2025 09:49:55 +0200 Subject: [PATCH 06/13] fix batching changeset updates --- crates/core/src/db/memory.rs | 25 +++++-------------------- crates/core/src/stateless/finalize.rs | 9 ++++++++- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/crates/core/src/db/memory.rs b/crates/core/src/db/memory.rs index 3982293c..07aa8cf4 100644 --- a/crates/core/src/db/memory.rs +++ b/crates/core/src/db/memory.rs @@ -15,9 +15,7 @@ use crate::db::unreachable::UnreachableDB; use crate::db::update::Update; use crate::rescue::Recoverable; -use alloy_primitives::map::HashSet; use alloy_primitives::{B256, U256}; -use reth_primitives::revm_primitives::AccountInfo; use reth_revm::db::states::{PlainStorageChangeset, StateChangeset}; use reth_revm::db::{AccountState, CacheDB}; @@ -32,22 +30,12 @@ impl Recoverable for CacheDB { impl Update for CacheDB { fn apply_changeset(&mut self, changeset: StateChangeset) -> anyhow::Result<()> { // Update accounts in state trie - let mut was_destroyed = HashSet::new(); for (address, account_info) in changeset.accounts { let db_account = self.accounts.get_mut(&address).unwrap(); - let Some(info) = account_info else { - db_account.storage.clear(); - db_account.account_state = AccountState::NotExisting; - db_account.info = AccountInfo::default(); - was_destroyed.insert(address); - continue; - }; - if info.code_hash != db_account.info.code_hash { - db_account.info = info; - } else { - db_account.info.balance = info.balance; - db_account.info.nonce = info.nonce; - } + // Reset the account state + db_account.account_state = AccountState::None; + // Update account info + db_account.info = account_info.unwrap_or_default(); } // Update account storages for PlainStorageChangeset { @@ -56,13 +44,10 @@ impl Update for CacheDB { storage, } in changeset.storage { - if was_destroyed.contains(&address) { - continue; - } let db_account = self.accounts.get_mut(&address).unwrap(); + db_account.account_state = AccountState::None; if wipe_storage { db_account.storage.clear(); - db_account.account_state = AccountState::StorageCleared; } for (key, val) in storage { db_account.storage.insert(key, val); diff --git a/crates/core/src/stateless/finalize.rs b/crates/core/src/stateless/finalize.rs index a7567442..474c2dd8 100644 --- a/crates/core/src/stateless/finalize.rs +++ b/crates/core/src/stateless/finalize.rs @@ -191,7 +191,14 @@ impl FinalizationStrategy for MemoryDbFina // Validate final state trie let header = Driver::block_header(block); - assert_eq!(Driver::state_root(header), state_trie.hash()); + if Driver::state_root(header) != state_trie.hash() { + bail!( + "Invalid state root (expected {:?}, got {:?}) at block #{}", + state_trie.hash(), + Driver::state_root(header), + Driver::block_number(header) + ); + } // Update the database if available if with_further_updates { From ca0b317ba3e1c3906687c950702822f31e12ab90 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Wed, 15 Jan 2025 09:53:47 +0200 Subject: [PATCH 07/13] downgrade journal mismatch to warning message --- crates/preflight/src/lib.rs | 4 ++-- crates/zeth/src/lib.rs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/preflight/src/lib.rs b/crates/preflight/src/lib.rs index 915f2c48..ad15aae6 100644 --- a/crates/preflight/src/lib.rs +++ b/crates/preflight/src/lib.rs @@ -18,7 +18,7 @@ use crate::provider::new_provider; use alloy::network::Network; use alloy::primitives::B256; use anyhow::Context; -use log::{info, warn}; +use log::{error, info, warn}; use provider::query::BlockQuery; use reth_chainspec::NamedChain; use std::path::PathBuf; @@ -166,7 +166,7 @@ where ); if final_difficulty.is_zero() { - warn!("Expecting a proof with a final chain difficulty value of zero in the journal.") + error!("Expecting a proof with a final chain difficulty value of zero in the journal.") } let journal = [ chain.to_be_bytes().as_slice(), diff --git a/crates/zeth/src/lib.rs b/crates/zeth/src/lib.rs index a2c9dd6e..3f2e6042 100644 --- a/crates/zeth/src/lib.rs +++ b/crates/zeth/src/lib.rs @@ -17,7 +17,7 @@ use crate::executor::build_executor_env; use alloy::network::Network; use alloy::primitives::B256; use clap::Parser; -use log::{error, info}; +use log::{error, info, warn}; use reth_chainspec::NamedChain; use risc0_zkvm::{default_executor, default_prover, is_dev_mode, ProverOpts, Receipt}; use std::fs::File; @@ -192,7 +192,9 @@ where session_info.journal.bytes }; // sanity check - assert_eq!(expected_journal, computed_journal); + if expected_journal != computed_journal { + warn!("Journal mismatch.") + } Ok(()) } From 64f79a6f52ee838d102d3206513efc097cbcf663 Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Wed, 15 Jan 2025 10:00:42 +0200 Subject: [PATCH 08/13] copyright years --- crates/core-ethereum/src/lib.rs | 2 +- crates/core/src/db/memory.rs | 2 +- crates/core/src/db/trie.rs | 2 +- crates/core/src/lib.rs | 2 +- crates/core/src/stateless/data.rs | 2 +- crates/core/src/stateless/engine.rs | 2 +- crates/core/src/stateless/finalize.rs | 2 +- crates/core/src/stateless/initialize.rs | 2 +- crates/preflight/src/client.rs | 2 +- crates/preflight/src/lib.rs | 2 +- crates/preflight/src/trie.rs | 2 +- crates/zeth/src/lib.rs | 2 +- guests/reth-ethereum/src/main.rs | 2 +- guests/reth-optimism/src/main.rs | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/core-ethereum/src/lib.rs b/crates/core-ethereum/src/lib.rs index 73a0b8e6..e1ca01d8 100644 --- a/crates/core-ethereum/src/lib.rs +++ b/crates/core-ethereum/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/core/src/db/memory.rs b/crates/core/src/db/memory.rs index 07aa8cf4..56d599d1 100644 --- a/crates/core/src/db/memory.rs +++ b/crates/core/src/db/memory.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/core/src/db/trie.rs b/crates/core/src/db/trie.rs index 2d9f93ad..5a0836c7 100644 --- a/crates/core/src/db/trie.rs +++ b/crates/core/src/db/trie.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index a1e34ceb..b9a8fd4f 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/core/src/stateless/data.rs b/crates/core/src/stateless/data.rs index 54015ad9..3f4be5ce 100644 --- a/crates/core/src/stateless/data.rs +++ b/crates/core/src/stateless/data.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/core/src/stateless/engine.rs b/crates/core/src/stateless/engine.rs index e216791e..9eb300ee 100644 --- a/crates/core/src/stateless/engine.rs +++ b/crates/core/src/stateless/engine.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/core/src/stateless/finalize.rs b/crates/core/src/stateless/finalize.rs index 474c2dd8..34ef1856 100644 --- a/crates/core/src/stateless/finalize.rs +++ b/crates/core/src/stateless/finalize.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/core/src/stateless/initialize.rs b/crates/core/src/stateless/initialize.rs index 78c18cdb..5b974f33 100644 --- a/crates/core/src/stateless/initialize.rs +++ b/crates/core/src/stateless/initialize.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/preflight/src/client.rs b/crates/preflight/src/client.rs index 80ee28bf..e0ddd4fe 100644 --- a/crates/preflight/src/client.rs +++ b/crates/preflight/src/client.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/preflight/src/lib.rs b/crates/preflight/src/lib.rs index ad15aae6..bcf82a41 100644 --- a/crates/preflight/src/lib.rs +++ b/crates/preflight/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/preflight/src/trie.rs b/crates/preflight/src/trie.rs index 04356baf..b4ed4938 100644 --- a/crates/preflight/src/trie.rs +++ b/crates/preflight/src/trie.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/crates/zeth/src/lib.rs b/crates/zeth/src/lib.rs index 3f2e6042..9a61968c 100644 --- a/crates/zeth/src/lib.rs +++ b/crates/zeth/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/guests/reth-ethereum/src/main.rs b/guests/reth-ethereum/src/main.rs index 9cfe50e3..38bbeb46 100644 --- a/guests/reth-ethereum/src/main.rs +++ b/guests/reth-ethereum/src/main.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/guests/reth-optimism/src/main.rs b/guests/reth-optimism/src/main.rs index 68eb7200..fd78a7c5 100644 --- a/guests/reth-optimism/src/main.rs +++ b/guests/reth-optimism/src/main.rs @@ -1,4 +1,4 @@ -// Copyright 2024 RISC Zero, Inc. +// Copyright 2024, 2025 RISC Zero, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From 75620704210d5243f2f19939f45ac3c1111e256f Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Wed, 15 Jan 2025 10:01:47 +0200 Subject: [PATCH 09/13] todo nit --- guests/reth-ethereum/src/main.rs | 1 - guests/reth-optimism/src/main.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/guests/reth-ethereum/src/main.rs b/guests/reth-ethereum/src/main.rs index 38bbeb46..630abccf 100644 --- a/guests/reth-ethereum/src/main.rs +++ b/guests/reth-ethereum/src/main.rs @@ -23,7 +23,6 @@ pub extern "C" fn __ctzsi2(x: u32) -> usize { } fn main() { - // todo: load up revm with hashbrown feat let stateless_client_data_rkyv = env::read_frame(); let stateless_client_data_pot = env::read_frame(); env::log("Deserializing input data"); diff --git a/guests/reth-optimism/src/main.rs b/guests/reth-optimism/src/main.rs index fd78a7c5..198c5f64 100644 --- a/guests/reth-optimism/src/main.rs +++ b/guests/reth-optimism/src/main.rs @@ -23,7 +23,6 @@ pub extern "C" fn __ctzsi2(x: u32) -> usize { } fn main() { - // todo: load up revm with hashbrown feat let stateless_client_data_rkyv = env::read_frame(); let stateless_client_data_pot = env::read_frame(); env::log("Deserializing input data"); From 8270a7bddd432afc97e2093d9bc82c0e30446c1f Mon Sep 17 00:00:00 2001 From: Rami Khalil Date: Wed, 15 Jan 2025 10:06:15 +0200 Subject: [PATCH 10/13] readme nit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 902d5b3f..47b94e9b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ By using reth to run the block execution process within the zkVM, we obtain a ZK ## Status -Zeth uses version 1.1.3 of the RISC Zero zkVM and version 1.1.0 of reth (backed by revm 14.0.3), but its other components are not audited for use in production. +Zeth uses version `1.2.1-rc.1` of the RISC Zero zkVM and version 1.1.0 of reth (backed by revm 14.0.3), but its other components are not audited for use in production. ## Prerequisites 1. [rust](https://www.rust-lang.org/tools/install) From b80e9c6a40d7788e7c809d999eb4db659c3fcbad Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 15 Jan 2025 23:26:24 +0100 Subject: [PATCH 11/13] migrate to steel-trie --- Cargo.lock | 165 ++- Cargo.toml | 4 +- bin/benchmark/src/main.rs | 11 +- crates/core/Cargo.toml | 3 +- crates/core/src/db/trie.rs | 11 +- crates/core/src/keccak.rs | 32 - crates/core/src/lib.rs | 1 - crates/core/src/mpt.rs | 1411 ++--------------------- crates/core/src/stateless/data.rs | 9 +- crates/core/src/stateless/finalize.rs | 40 +- crates/core/src/stateless/initialize.rs | 21 +- crates/preflight/Cargo.toml | 1 + crates/preflight/src/client.rs | 181 +-- crates/preflight/src/db.rs | 114 +- crates/preflight/src/lib.rs | 3 +- crates/preflight/src/provider/query.rs | 25 + crates/preflight/src/trie.rs | 297 ----- crates/zeth/src/lib.rs | 5 +- guests/reth-ethereum/Cargo.lock | 88 +- guests/reth-optimism/Cargo.lock | 88 +- 20 files changed, 554 insertions(+), 1956 deletions(-) delete mode 100644 crates/core/src/keccak.rs delete mode 100644 crates/preflight/src/trie.rs diff --git a/Cargo.lock b/Cargo.lock index 79890841..90fc815c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -142,7 +142,7 @@ dependencies = [ "alloy-transport", "futures", "futures-util", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -249,7 +249,7 @@ dependencies = [ "alloy-sol-types", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", "tracing", ] @@ -271,7 +271,7 @@ dependencies = [ "async-trait", "auto_impl", "futures-utils-wasm", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -289,9 +289,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.8" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f35429a652765189c1c5092870d8360ee7b7769b09b06d89ebaefd34676446" +checksum = "788bb18e8f61d5d9340b52143f27771daf7e1dccbaf2741621d2493f9debf52e" dependencies = [ "alloy-rlp", "bytes", @@ -301,7 +301,6 @@ dependencies = [ "foldhash", "getrandom", "hashbrown 0.15.2", - "hex-literal", "indexmap 2.6.0", "itoa", "k256", @@ -347,7 +346,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", "tokio", "tracing", "url", @@ -374,9 +373,9 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.8" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26154390b1d205a4a7ac7352aa2eb4f81f391399d4e2f546fb81a2f8bb383f62" +checksum = "f542548a609dca89fcd72b3b9f355928cf844d4363c5eed9c5273a3dd225e097" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -385,9 +384,9 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.8" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" +checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" dependencies = [ "proc-macro2", "quote", @@ -487,7 +486,7 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -503,7 +502,7 @@ dependencies = [ "async-trait", "k256", "rand", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -591,7 +590,7 @@ dependencies = [ "futures-utils-wasm", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", "tokio", "tower 0.5.1", "tracing", @@ -659,7 +658,23 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more 1.0.0", - "nybbles", + "nybbles 0.2.1", + "serde", + "smallvec", + "tracing", +] + +[[package]] +name = "alloy-trie" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6917c79e837aa7b77b7a6dae9f89cbe15313ac161c4d3cfaf8909ef21f3d22d8" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "arrayvec", + "derive_more 1.0.0", + "nybbles 0.3.4", "serde", "smallvec", "tracing", @@ -992,6 +1007,9 @@ name = "arrayvec" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +dependencies = [ + "serde", +] [[package]] name = "async-stream" @@ -1213,7 +1231,7 @@ dependencies = [ "maybe-async", "reqwest", "serde", - "thiserror", + "thiserror 1.0.64", "tokio", ] @@ -1355,7 +1373,7 @@ dependencies = [ "semver 1.0.22", "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -1442,9 +1460,9 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "const-hex" -version = "1.11.3" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba00838774b4ab0233e355d26710fbfc8327a05c017f6dc4873f876d1f79f78" +checksum = "4b0485bab839b018a8f1723fc5391819fea5f8f0f32288ef8a735fd096b6160c" dependencies = [ "cfg-if", "cpufeatures", @@ -1888,7 +1906,7 @@ dependencies = [ "futures", "rand", "reqwest", - "thiserror", + "thiserror 1.0.64", "tokio", ] @@ -2149,9 +2167,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "foreign-types" @@ -2721,6 +2739,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" @@ -3225,6 +3252,19 @@ dependencies = [ "smallvec", ] +[[package]] +name = "nybbles" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8983bb634df7248924ee0c4c3a749609b5abcb082c28fffe3254b3eb3602b307" +dependencies = [ + "alloy-rlp", + "const-hex", + "proptest", + "serde", + "smallvec", +] + [[package]] name = "objc" version = "0.2.7" @@ -3447,7 +3487,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.64", "ucd-trie", ] @@ -3736,7 +3776,7 @@ dependencies = [ "rustc-hash", "rustls", "socket2", - "thiserror", + "thiserror 1.0.64", "tokio", "tracing", ] @@ -3753,7 +3793,7 @@ dependencies = [ "rustc-hash", "rustls", "slab", - "thiserror", + "thiserror 1.0.64", "tinyvec", "tracing", ] @@ -3884,7 +3924,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -3988,7 +4028,7 @@ dependencies = [ "alloy-eips", "alloy-genesis", "alloy-primitives", - "alloy-trie", + "alloy-trie 0.6.0", "auto_impl", "derive_more 1.0.0", "once_cell", @@ -4009,7 +4049,7 @@ dependencies = [ "alloy-eips", "alloy-genesis", "alloy-primitives", - "alloy-trie", + "alloy-trie 0.6.0", "bytes", "modular-bitfield", "op-alloy-consensus", @@ -4166,7 +4206,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more 1.0.0", - "nybbles", + "nybbles 0.2.1", "reth-consensus", "reth-prune-types", "reth-storage-errors", @@ -4193,7 +4233,7 @@ source = "git+https://github.com/risc0/reth?branch=p1.1.0_zstd#760183fd601f61a3f dependencies = [ "serde", "serde_json", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -4214,7 +4254,7 @@ dependencies = [ "alloy-rlp", "enr", "serde_with", - "thiserror", + "thiserror 1.0.64", "url", ] @@ -4273,7 +4313,7 @@ dependencies = [ "reth-revm", "revm", "revm-primitives", - "thiserror", + "thiserror 1.0.64", "tracing", ] @@ -4349,7 +4389,7 @@ dependencies = [ "modular-bitfield", "reth-codecs", "serde", - "thiserror", + "thiserror 1.0.64", ] [[package]] @@ -4453,11 +4493,11 @@ dependencies = [ "alloy-genesis", "alloy-primitives", "alloy-rlp", - "alloy-trie", + "alloy-trie 0.6.0", "bytes", "derive_more 1.0.0", "itertools 0.13.0", - "nybbles", + "nybbles 0.2.1", "reth-codecs", "reth-primitives-traits", "revm-primitives", @@ -5001,9 +5041,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" dependencies = [ "rand", ] @@ -5474,6 +5514,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "steel-trie" +version = "0.1.0" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-trie 0.7.8", + "arrayvec", + "bincode", + "itertools 0.14.0", + "rkyv", + "serde", + "thiserror 2.0.11", +] + [[package]] name = "strsim" version = "0.10.0" @@ -5613,7 +5668,16 @@ version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.64", +] + +[[package]] +name = "thiserror" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +dependencies = [ + "thiserror-impl 2.0.11", ] [[package]] @@ -5627,6 +5691,17 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "thiserror-impl" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "thiserror-impl-no-std" version = "2.0.2" @@ -5935,7 +6010,7 @@ dependencies = [ "rustls", "rustls-pki-types", "sha1", - "thiserror", + "thiserror 1.0.64", "utf-8", ] @@ -6465,7 +6540,7 @@ dependencies = [ "pharos", "rustc_version 0.4.1", "send_wrapper", - "thiserror", + "thiserror 1.0.64", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -6579,8 +6654,7 @@ dependencies = [ "reth-storage-errors", "rkyv", "serde", - "thiserror", - "tiny-keccak", + "steel-trie", ] [[package]] @@ -6663,6 +6737,7 @@ dependencies = [ "anyhow", "async-trait", "flate2", + "itertools 0.14.0", "k256", "log", "pot", @@ -6717,11 +6792,11 @@ name = "zeth-testeth" version = "0.1.0" dependencies = [ "alloy", - "alloy-trie", + "alloy-trie 0.6.0", "anyhow", "env_logger", "log", - "nybbles", + "nybbles 0.2.1", "reth-chainspec", "reth-primitives", "reth-revm", @@ -6749,7 +6824,7 @@ dependencies = [ "flate2", "indexmap 2.6.0", "memchr", - "thiserror", + "thiserror 1.0.64", "zopfli", ] diff --git a/Cargo.toml b/Cargo.toml index dfa020c0..56aa2b54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,6 +80,7 @@ zeth-guests = { path = "guests" } zeth-preflight = { path = "crates/preflight" } zeth-preflight-ethereum = { path = "crates/preflight-ethereum" } zeth-preflight-optimism = { path = "crates/preflight-optimism" } +steel-trie = { path = "../scratch/dev/wwelz/steel-trie", features = ["orphan", "rkyv", "rlp_serialize", "serde"] } # Others anyhow = "1.0.89" @@ -89,6 +90,7 @@ bytemuck = "1.19.0" clap = { version = "4.0", features = ["derive"] } env_logger = "0.11.5" hashbrown = { version = "0.15.2", features = ["rayon"] } +itertools = "0.14" k256 = { version = "0.13.3", features = ["serde", "pem"] } log = "0.4.22" flate2 = "1.0.34" @@ -98,7 +100,5 @@ rkyv = { version = "0.8.9", features = ["hashbrown-0_15"] } serde = { version = "1.0.210", features = ["derive"] } serde_json = { version = "1.0.128", features = ["alloc"] } serde_with = "3.11.0" -thiserror = "1.0.64" -tiny-keccak = "2.0.2" tokio = { version = "1.41.0", features = ["full"] } tracing = { version = "0.1.40", features = ["log"] } diff --git a/bin/benchmark/src/main.rs b/bin/benchmark/src/main.rs index 104375e0..4f9763c0 100644 --- a/bin/benchmark/src/main.rs +++ b/bin/benchmark/src/main.rs @@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -use alloy::primitives::U256; +use alloy::primitives::{keccak256, U256}; use alloy_chains::NamedChain; use clap::Parser; use std::process::Command; use tracing::{error, info}; use zeth::cli::ProveArgs; -use zeth_core::keccak::keccak; #[derive(clap::Parser, Debug, Clone)] #[command(name = "zeth-benchmark")] @@ -57,7 +56,7 @@ fn main() { let build_args = &cli.prove_args.run_args.build_args; let chain_id = build_args.chain.or(cli.chain_id).unwrap(); // generate sequence of starting block numbers to benchmark - let seed = keccak( + let seed = keccak256( [ (chain_id as u64).to_be_bytes(), build_args.block_number.to_be_bytes(), @@ -70,9 +69,9 @@ fn main() { let block_numbers = (0..cli.sample_count) .map(|i| { build_args.block_number - + U256::from_be_bytes(keccak( - [seed.as_slice(), i.to_be_bytes().as_slice()].concat(), - )) + + U256::from_be_bytes( + keccak256([seed.as_slice(), i.to_be_bytes().as_slice()].concat()).0, + ) .reduce_mod(U256::from(cli.sample_range)) .to::() }) diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 89ac1141..0d5a25e4 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -13,8 +13,7 @@ k256.workspace = true pot.workspace = true rkyv.workspace = true serde.workspace = true -thiserror.workspace = true -tiny-keccak.workspace = true +steel-trie.workspace = true reth-chainspec.workspace = true reth-primitives.workspace = true diff --git a/crates/core/src/db/trie.rs b/crates/core/src/db/trie.rs index 5a0836c7..bfb22564 100644 --- a/crates/core/src/db/trie.rs +++ b/crates/core/src/db/trie.rs @@ -12,14 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::keccak::keccak; use crate::map::NoMapHasher; use crate::mpt::MptNode; use crate::rescue::Recoverable; use crate::stateless::data::StorageEntry; use alloy_consensus::Account; use alloy_primitives::map::HashMap; -use alloy_primitives::{Address, B256, U256}; +use alloy_primitives::{keccak256, Address, B256, U256}; use reth_primitives::revm_primitives::db::Database; use reth_primitives::revm_primitives::{AccountInfo, Bytecode}; use reth_revm::DatabaseRef; @@ -27,7 +26,7 @@ use reth_storage_errors::provider::ProviderError; #[derive(Default)] pub struct TrieDB { - pub accounts: MptNode, + pub accounts: MptNode, pub storage: HashMap, pub contracts: HashMap, pub block_hashes: HashMap, @@ -45,8 +44,7 @@ impl DatabaseRef for TrieDB { fn basic_ref(&self, address: Address) -> Result, Self::Error> { Ok(self .accounts - .get_rlp::(&keccak(address)) - .unwrap() + .get_rlp(keccak256(address))? .map(|acc| AccountInfo { balance: acc.balance, nonce: acc.nonce, @@ -63,8 +61,7 @@ impl DatabaseRef for TrieDB { let entry = self.storage.get(&address).unwrap(); Ok(entry .storage_trie - .get_rlp(&keccak(index.to_be_bytes::<32>())) - .unwrap() + .get_rlp(keccak256(index.to_be_bytes::<32>()))? .unwrap_or_default()) } diff --git a/crates/core/src/keccak.rs b/crates/core/src/keccak.rs deleted file mode 100644 index 482f86c3..00000000 --- a/crates/core/src/keccak.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023, 2024 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use tiny_keccak::{Hasher, Keccak}; - -/// Computes the Keccak-256 hash of the provided data. -/// -/// This function is a thin wrapper around the Keccak256 hashing algorithm -/// and is optimized for performance. -/// -/// # TODO -/// - Consider switching the return type to `B256` for consistency with other parts of the -/// codebase. -#[inline] -pub fn keccak(data: impl AsRef<[u8]>) -> [u8; 32] { - let mut hasher = Keccak::v256(); - hasher.update(data.as_ref()); - let mut output = [0; 32]; - hasher.finalize(&mut output); - output -} diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index b9a8fd4f..111855aa 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -14,7 +14,6 @@ pub mod db; pub mod driver; -pub mod keccak; pub mod map; pub mod mpt; pub mod rescue; diff --git a/crates/core/src/mpt.rs b/crates/core/src/mpt.rs index 144024ba..e29bee49 100644 --- a/crates/core/src/mpt.rs +++ b/crates/core/src/mpt.rs @@ -1,1379 +1,114 @@ -// Copyright 2023, 2024 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -extern crate alloc; - -use alloc::boxed::Box; -use core::{ - cell::RefCell, - cmp, - fmt::{Debug, Write}, - iter, mem, -}; - -use alloy_primitives::bytes::Buf; -use alloy_primitives::map::HashMap; -use alloy_primitives::{b256, B256}; +use alloy_primitives::map::B256Set; +use alloy_primitives::{B256, U256}; use alloy_rlp::{Decodable, Encodable}; -use anyhow::{bail, Context}; use serde::{Deserialize, Serialize}; -use thiserror::Error as ThisError; - -use crate::keccak::keccak; - -/// Root hash of an empty trie. -pub const EMPTY_ROOT: B256 = - b256!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); +use std::borrow::Borrow; +use std::marker::PhantomData; +use std::ops::{Deref, DerefMut}; +use steel_trie::{orphan, CachedTrie}; -/// Represents the root node of a sparse Merkle Patricia Trie. -/// -/// The "sparse" nature of this trie allows for truncation of certain unneeded parts, -/// representing them by their node hash. This design choice is particularly useful for -/// optimizing storage. However, operations targeting a truncated part will fail and -/// return an error. Another distinction of this implementation is that branches cannot -/// store values, aligning with the construction of MPTs in Ethereum. #[derive( - Clone, Debug, - Default, - PartialEq, - Eq, - Ord, - PartialOrd, - Serialize, - Deserialize, - rkyv::Archive, - rkyv::Serialize, - rkyv::Deserialize, -)] -#[rkyv(bytecheck( - bounds( - __C: rkyv::validation::ArchiveContext, - __C::Error: rkyv::rancor::Source, - ) -))] -#[rkyv(serialize_bounds( - __S: rkyv::ser::Writer + rkyv::ser::Allocator, - __S::Error: rkyv::rancor::Source, -))] -#[rkyv(deserialize_bounds( - __D::Error: rkyv::rancor::Source -))] -pub struct MptNode { - /// The type and data of the node. - #[rkyv(omit_bounds)] - pub data: MptNodeData, - /// Cache for a previously computed reference of this node. This is skipped during - /// serialization. - #[serde(skip)] - #[rkyv(with = rkyv::with::Skip)] - cached_reference: RefCell>, -} - -/// Represents custom error types for the sparse Merkle Patricia Trie (MPT). -/// -/// These errors cover various scenarios that can occur during trie operations, such as -/// encountering unresolved nodes, finding values in branches where they shouldn't be, and -/// issues related to RLP (Recursive Length Prefix) encoding and decoding. -#[derive(Debug, ThisError)] -pub enum Error { - /// Triggered when an operation reaches an unresolved node. The associated `B256` - /// value provides details about the unresolved node. - #[error("reached an unresolved node: {0:?}")] - NodeNotResolved(B256), - /// Occurs when a value is unexpectedly found in a branch node. - #[error("branch node with value")] - ValueInBranch, - /// Represents errors related to the RLP encoding and decoding using the `alloy_rlp` - /// library. - #[error("RLP error")] - Rlp(#[from] alloy_rlp::Error), -} - -impl From for MptNode { - fn from(digest: B256) -> Self { - match digest { - EMPTY_ROOT | B256::ZERO => MptNode::default(), - _ => MptNodeData::Digest(digest).into(), - } - } -} - -/// Represents the various types of data that can be stored within a node in the sparse -/// Merkle Patricia Trie (MPT). -/// -/// Each node in the trie can be of one of several types, each with its own specific data -/// structure. This enum provides a clear and type-safe way to represent the data -/// associated with each node type. -#[derive( Clone, - Debug, - Default, - PartialEq, Eq, - Ord, - PartialOrd, - Serialize, + PartialEq, Deserialize, + Serialize, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, )] -#[rkyv(bytecheck( - bounds( - __C: rkyv::validation::ArchiveContext, - ) -))] -#[rkyv(serialize_bounds( - __S: rkyv::ser::Writer + rkyv::ser::Allocator, - __S::Error: rkyv::rancor::Source, -))] -#[rkyv(deserialize_bounds( - __D::Error: rkyv::rancor::Source -))] -pub enum MptNodeData { - /// Represents an empty trie node. - #[default] - Null, - /// A node that can have up to 16 children. Each child is an optional boxed [MptNode]. - Branch( - // #[rkyv(with = rkyv::with::Map>>)] - #[rkyv(omit_bounds)] [Option>; 16], - ), - /// A leaf node that contains a key and a value, both represented as byte vectors. - Leaf(Vec, Vec), - /// A node that has exactly one child and is used to represent a shared prefix of - /// several keys. - Extension( - Vec, - // #[rkyv(with = Box)] - #[rkyv(omit_bounds)] Box, - ), - /// Represents a sub-trie by its hash, allowing for efficient storage of large - /// sub-tries without storing their entire content. - Digest(#[rkyv(with = B256Def)] B256), -} - -#[derive(Clone, Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] -#[rkyv(remote = B256)] -#[rkyv(archived = ArchivedB256)] -pub struct B256Def(pub [u8; 32]); - -impl From for B256 { - fn from(value: B256Def) -> Self { - B256::new(value.0) - } -} - -/// Represents the ways in which one node can reference another node inside the sparse -/// Merkle Patricia Trie (MPT). -/// -/// Nodes in the MPT can reference other nodes either directly through their byte -/// representation or indirectly through a hash of their encoding. This enum provides a -/// clear and type-safe way to represent these references. -#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)] -pub enum MptNodeReference { - /// Represents a direct reference to another node using its byte encoding. Typically - /// used for short encodings that are less than 32 bytes in length. - Bytes(Vec), - /// Represents an indirect reference to another node using the Keccak hash of its long - /// encoding. Used for encodings that are not less than 32 bytes in length. - Digest(B256), +pub struct MptNode { + inner: CachedTrie, + phantom_data: PhantomData, } -impl MptNodeReference { - pub fn as_digest(&self) -> Self { - match self { - MptNodeReference::Digest(d) => MptNodeReference::Digest(*d), - MptNodeReference::Bytes(b) => MptNodeReference::Digest(keccak(b).into()), - } - } - - pub fn digest(&self) -> B256 { - let MptNodeReference::Digest(d) = self.as_digest() else { - unreachable!() - }; - d - } -} - -/// Provides a conversion from [MptNodeData] to [MptNode]. -/// -/// This implementation allows for conversion from [MptNodeData] to [MptNode], -/// initializing the `data` field with the provided value and setting the -/// `cached_reference` field to `None`. -impl From for MptNode { - fn from(value: MptNodeData) -> Self { +impl Default for MptNode { + fn default() -> Self { Self { - data: value, - cached_reference: RefCell::new(None), - } - } -} - -/// Provides encoding functionalities for the `MptNode` type. -/// -/// This implementation allows for the serialization of an [MptNode] into its RLP-encoded -/// form. The encoding is done based on the type of node data ([MptNodeData]) it holds. -impl Encodable for MptNode { - /// Encodes the node into the provided `out` buffer. - /// - /// The encoding is done using the Recursive Length Prefix (RLP) encoding scheme. The - /// method handles different node data types and encodes them accordingly. - #[inline] - fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { - match &self.data { - MptNodeData::Null => { - out.put_u8(alloy_rlp::EMPTY_STRING_CODE); - } - MptNodeData::Branch(nodes) => { - alloy_rlp::Header { - list: true, - payload_length: self.payload_length(), - } - .encode(out); - nodes.iter().for_each(|child| match child { - Some(node) => node.reference_encode(out), - None => out.put_u8(alloy_rlp::EMPTY_STRING_CODE), - }); - // in the MPT reference, branches have values so always add empty value - out.put_u8(alloy_rlp::EMPTY_STRING_CODE); - } - MptNodeData::Leaf(prefix, value) => { - alloy_rlp::Header { - list: true, - payload_length: self.payload_length(), - } - .encode(out); - prefix.as_slice().encode(out); - value.as_slice().encode(out); - } - MptNodeData::Extension(prefix, node) => { - alloy_rlp::Header { - list: true, - payload_length: self.payload_length(), - } - .encode(out); - prefix.as_slice().encode(out); - node.reference_encode(out); - } - MptNodeData::Digest(digest) => { - digest.encode(out); - } + inner: CachedTrie::default(), + phantom_data: PhantomData, } } - - /// Returns the length of the encoded node in bytes. - /// - /// This method calculates the length of the RLP-encoded node. It's useful for - /// determining the size requirements for storage or transmission. - #[inline] - fn length(&self) -> usize { - let payload_length = self.payload_length(); - payload_length + alloy_rlp::length_of_length(payload_length) - } } -/// Provides decoding functionalities for the [MptNode] type. -/// -/// This implementation allows for the deserialization of an RLP-encoded [MptNode] back -/// into its original form. The decoding is done based on the prototype of the RLP data, -/// ensuring that the node is reconstructed accurately. -/// -impl Decodable for MptNode { - /// Decodes an RLP-encoded node from the provided `rlp` buffer. - /// - /// The method handles different RLP prototypes and reconstructs the `MptNode` based - /// on the encoded data. If the RLP data does not match any known prototype or if - /// there's an error during decoding, an error is returned. - fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - if buf.is_empty() { - return Ok(MptNodeData::Null.into()); - } - match rlp_parse_head(buf)? { - (0, _) => Ok(MptNodeData::Null.into()), - (2, true) => { - let path = Vec::from(alloy_rlp::Header::decode_bytes(buf, false)?); - let prefix = path[0]; - if (prefix & (2 << 4)) == 0 { - let node = MptNode::decode(buf)?; - Ok(MptNodeData::Extension(path, Box::new(node)).into()) - } else { - let header = alloy_rlp::Header::decode(buf)?; - let value = Vec::from(&buf[..header.payload_length]); - buf.advance(header.payload_length); - Ok(MptNodeData::Leaf(path, value).into()) - } - } - (17, true) => { - let mut node_list = Vec::with_capacity(16); - for _ in 0..16 { - match *buf.first().ok_or(alloy_rlp::Error::InputTooShort)? { - alloy_rlp::EMPTY_STRING_CODE => { - buf.advance(1); - node_list.push(None); - } - _ => node_list.push(Some(Box::new(MptNode::decode(buf)?))), - } - } - let value: Vec = Vec::from(alloy_rlp::Header::decode_bytes(buf, false)?); - if value.is_empty() { - Ok(MptNodeData::Branch(node_list.try_into().unwrap()).into()) - } else { - Err(alloy_rlp::Error::Custom("branch node with value")) - } - } - (32, false) => { - if buf.length() < 32 { - Err(alloy_rlp::Error::InputTooShort) - } else { - let bytes: [u8; 32] = (&buf[0..32]).try_into().unwrap(); - buf.advance(32); - Ok(MptNodeData::Digest(B256::from(bytes)).into()) - } - } - _ => Err(alloy_rlp::Error::Custom("bad node encoding")), - } - } -} - -fn rlp_parse_head(buf: &mut &[u8]) -> alloy_rlp::Result<(usize, bool)> { - let head = alloy_rlp::Header::decode(buf)?; - let mut result = 0; - if head.list { - let mut buf = &buf[0..head.payload_length]; - while !buf.is_empty() { - let item_head = alloy_rlp::Header::decode(&mut buf)?; - buf.advance(item_head.payload_length); - result += 1; - } - } else { - result = head.payload_length; - } - Ok((result, head.list)) -} - -/// Represents a node in the sparse Merkle Patricia Trie (MPT). -/// -/// The [MptNode] type encapsulates the data and functionalities associated with a node in -/// the MPT. It provides methods for manipulating the trie, such as inserting, deleting, -/// and retrieving values, as well as utility methods for encoding, decoding, and -/// debugging. -impl MptNode { - /// Clears the trie, replacing its data with an empty node, [MptNodeData::Null]. - /// - /// This method effectively removes all key-value pairs from the trie. - #[inline] - pub fn clear(&mut self) { - self.data = MptNodeData::Null; - self.invalidate_ref_cache(); - } - - /// Retrieves the underlying data of the node. - /// - /// This method provides a reference to the node's data, allowing for inspection and - /// manipulation. - #[inline] - pub fn as_data(&self) -> &MptNodeData { - &self.data - } - - /// Retrieves the underlying data of the node. - /// - /// This method provides a reference to the node's data, allowing for inspection and - /// manipulation. - #[inline] - pub fn as_data_mut(&mut self) -> &mut MptNodeData { - &mut self.data - } - - #[inline] - pub fn is_reference_cached(&self) -> bool { - self.cached_reference.borrow().is_some() - } - - /// Retrieves the [MptNodeReference] reference of the node when it's referenced inside - /// another node. - /// - /// This method provides a way to obtain a compact representation of the node for - /// storage or transmission purposes. - #[inline] - pub fn reference(&self) -> MptNodeReference { - self.cached_reference - .borrow_mut() - .get_or_insert_with(|| self.calc_reference()) - .clone() - } - - /// Computes and returns the 256-bit hash of the node. - /// - /// This method provides a unique identifier for the node based on its content. - #[inline] - pub fn hash(&self) -> B256 { - match self.data { - MptNodeData::Null => EMPTY_ROOT, - _ => match self - .cached_reference - .borrow_mut() - .get_or_insert_with(|| self.calc_reference()) - { - MptNodeReference::Digest(digest) => *digest, - MptNodeReference::Bytes(bytes) => keccak(bytes).into(), - }, - } - } - - /// Encodes the [MptNodeReference] of this node into the `out` buffer. - fn reference_encode(&self, out: &mut dyn alloy_rlp::BufMut) { - match self - .cached_reference - .borrow_mut() - .get_or_insert_with(|| self.calc_reference()) - { - // if the reference is an RLP-encoded byte slice, copy it directly - MptNodeReference::Bytes(bytes) => out.put_slice(bytes), - // if the reference is a digest, RLP-encode it with its fixed known length - MptNodeReference::Digest(digest) => { - out.put_u8(alloy_rlp::EMPTY_STRING_CODE + 32); - out.put_slice(digest.as_slice()); - } - } - } - - /// Returns the length of the encoded [MptNodeReference] of this node. - fn reference_length(&self) -> usize { - match self - .cached_reference - .borrow_mut() - .get_or_insert_with(|| self.calc_reference()) - { - MptNodeReference::Bytes(bytes) => bytes.len(), - MptNodeReference::Digest(_) => 1 + 32, - } - } - - fn calc_reference(&self) -> MptNodeReference { - match &self.data { - MptNodeData::Null => MptNodeReference::Bytes(vec![alloy_rlp::EMPTY_STRING_CODE]), - MptNodeData::Digest(digest) => MptNodeReference::Digest(*digest), - _ => { - let encoded = alloy_rlp::encode(self); - if encoded.len() < 32 { - MptNodeReference::Bytes(encoded) - } else { - MptNodeReference::Digest(keccak(encoded).into()) - } - } - } - } - - /// Determines if the trie is empty. - /// - /// This method checks if the node represents an empty trie, i.e., it doesn't contain - /// any key-value pairs. - #[inline] - pub fn is_empty(&self) -> bool { - matches!(&self.data, MptNodeData::Null) - } - - /// Determines if the node represents a digest. - /// - /// A digest is a compact representation of a sub-trie, represented by its hash. - #[inline] - pub fn is_digest(&self) -> bool { - matches!(&self.data, MptNodeData::Digest(_)) - } - - /// Retrieves the nibbles corresponding to the node's prefix. - /// - /// Nibbles are half-bytes, and in the context of the MPT, they represent parts of - /// keys. - #[inline] - pub fn nibs(&self) -> Vec { - match &self.data { - MptNodeData::Null | MptNodeData::Branch(_) | MptNodeData::Digest(_) => vec![], - MptNodeData::Leaf(prefix, _) | MptNodeData::Extension(prefix, _) => prefix_nibs(prefix), - } - } - - /// Retrieves the value associated with a given key in the trie. - /// - /// If the key is not present in the trie, this method returns `None`. Otherwise, it - /// returns a reference to the associated value. If [None] is returned, the key is - /// provably not in the trie. - #[inline] - pub fn get(&self, key: &[u8]) -> Result, Error> { - self.get_internal(&to_nibs(key)) - } - - /// Retrieves the RLP-decoded value corresponding to the key. - /// - /// If the key is not present in the trie, this method returns `None`. Otherwise, it - /// returns the RLP-decoded value. - #[inline] - pub fn get_rlp(&self, key: &[u8]) -> Result, Error> { - match self.get(key)? { - Some(mut bytes) => Ok(Some(T::decode(&mut bytes)?)), +impl MptNode { + pub fn get_rlp(&self, key: impl AsRef<[u8]>) -> alloy_rlp::Result> { + match self.inner.get(key) { None => Ok(None), + Some(mut bytes) => Ok(Some(T::decode(&mut bytes)?)), } } - fn get_internal(&self, key_nibs: &[u8]) -> Result, Error> { - match &self.data { - MptNodeData::Null => Ok(None), - MptNodeData::Branch(nodes) => { - if let Some((i, tail)) = key_nibs.split_first() { - match nodes[*i as usize] { - Some(ref node) => node.get_internal(tail), - None => Ok(None), - } - } else { - Ok(None) - } - } - MptNodeData::Leaf(prefix, value) => { - if prefix_nibs(prefix) == key_nibs { - Ok(Some(value)) - } else { - Ok(None) - } - } - MptNodeData::Extension(prefix, node) => { - if let Some(tail) = key_nibs.strip_prefix(prefix_nibs(prefix).as_slice()) { - node.get_internal(tail) - } else { - Ok(None) - } - } - MptNodeData::Digest(digest) => Err(Error::NodeNotResolved(*digest)), - } - } - - /// Removes a key from the trie. - /// - /// This method attempts to remove a key-value pair from the trie. If the key is - /// present, it returns `true`. Otherwise, it returns `false`. - #[inline] - pub fn delete(&mut self, key: &[u8]) -> Result { - self.delete_internal(&to_nibs(key)) - } - - fn delete_internal(&mut self, key_nibs: &[u8]) -> Result { - match &mut self.data { - MptNodeData::Null => return Ok(false), - MptNodeData::Branch(children) => { - if let Some((i, tail)) = key_nibs.split_first() { - let child = &mut children[*i as usize]; - match child { - Some(node) => { - if !node.delete_internal(tail)? { - return Ok(false); - } - // if the node is now empty, remove it - if node.is_empty() { - *child = None; - } - } - None => return Ok(false), - } - } else { - return Err(Error::ValueInBranch); - } - - let mut remaining = children.iter_mut().enumerate().filter(|(_, n)| n.is_some()); - // there will always be at least one remaining node - let (index, node) = remaining.next().unwrap(); - // if there is only exactly one node left, we need to convert the branch - if remaining.next().is_none() { - let mut orphan = node.take().unwrap(); - match &mut orphan.data { - // if the orphan is a leaf, prepend the corresponding nib to it - MptNodeData::Leaf(prefix, orphan_value) => { - let new_nibs: Vec<_> = - iter::once(index as u8).chain(prefix_nibs(prefix)).collect(); - self.data = MptNodeData::Leaf( - to_encoded_path(&new_nibs, true), - mem::take(orphan_value), - ); - } - // if the orphan is an extension, prepend the corresponding nib to it - MptNodeData::Extension(prefix, orphan_child) => { - let new_nibs: Vec<_> = - iter::once(index as u8).chain(prefix_nibs(prefix)).collect(); - self.data = MptNodeData::Extension( - to_encoded_path(&new_nibs, false), - mem::take(orphan_child), - ); - } - // if the orphan is a branch, convert to an extension - MptNodeData::Branch(_) => { - self.data = MptNodeData::Extension( - to_encoded_path(&[index as u8], false), - orphan, - ); - } - MptNodeData::Digest(digest) => { - return Err(Error::NodeNotResolved(*digest)); - } - MptNodeData::Null => unreachable!(), - } - } - } - MptNodeData::Leaf(prefix, _) => { - if prefix_nibs(prefix) != key_nibs { - return Ok(false); - } - self.data = MptNodeData::Null; - } - MptNodeData::Extension(prefix, child) => { - let mut self_nibs = prefix_nibs(prefix); - if let Some(tail) = key_nibs.strip_prefix(self_nibs.as_slice()) { - if !child.delete_internal(tail)? { - return Ok(false); - } - } else { - return Ok(false); - } - - // an extension can only point to a branch or a digest; since it's sub trie was - // modified, we need to make sure that this property still holds - match &mut child.data { - // if the child is empty, remove the extension - MptNodeData::Null => { - self.data = MptNodeData::Null; - } - // for a leaf, replace the extension with the extended leaf - MptNodeData::Leaf(prefix, value) => { - self_nibs.extend(prefix_nibs(prefix)); - self.data = - MptNodeData::Leaf(to_encoded_path(&self_nibs, true), mem::take(value)); - } - // for an extension, replace the extension with the extended extension - MptNodeData::Extension(prefix, node) => { - self_nibs.extend(prefix_nibs(prefix)); - self.data = MptNodeData::Extension( - to_encoded_path(&self_nibs, false), - mem::take(node), - ); - } - // for a branch, the extension is still correct - MptNodeData::Branch(_) => {} - // if the child were a digest an early return should have been hit - MptNodeData::Digest(_) => unreachable!(), - } - } - MptNodeData::Digest(digest) => return Err(Error::NodeNotResolved(*digest)), + pub fn insert_rlp(&mut self, key: K, value: V) + where + K: AsRef<[u8]>, + V: Borrow, + { + self.inner.insert(key, alloy_rlp::encode(value.borrow())); + } + + /// Tries to resolve the potential removal orphan corresponding to `key` from the given + /// post-removal proof. If the orphan cannot be resolved from the proof alone, the `key` + /// corresponding to the unresolved path is added to `unresolvable`. + pub fn resolve_orphan( + &mut self, + key: K, + post_state_proof: impl IntoIterator, + unresolvable: &mut B256Set, + ) -> alloy_rlp::Result<()> + where + K: AsRef<[u8]>, + N: AsRef<[u8]>, + { + match self.inner.resolve_orphan(key, post_state_proof) { + Ok(_) => {} + Err(orphan::Error::Unresolvable(nibbles)) => { + // convert the unresolvable nibbles into B256 with zero padding + let key = B256::from(U256::from_le_slice(&nibbles.pack())); + unresolvable.insert(key); + } + Err(orphan::Error::RlpError(err)) => return Err(err), }; - self.invalidate_ref_cache(); - Ok(true) - } - - /// Inserts a key-value pair into the trie. - /// - /// This method attempts to insert a new key-value pair into the trie. If the - /// insertion is successful, it returns `true`. If the key already exists, it updates - /// the value and returns `false`. - #[inline] - pub fn insert(&mut self, key: &[u8], value: Vec) -> Result { - if value.is_empty() { - panic!("value must not be empty"); - } - self.insert_internal(&to_nibs(key), value) + Ok(()) } - /// Inserts an RLP-encoded value into the trie. - /// - /// This method inserts a value that's been encoded using RLP into the trie. #[inline] - pub fn insert_rlp(&mut self, key: &[u8], value: impl Encodable) -> Result { - self.insert_internal(&to_nibs(key), alloy_rlp::encode(value)) - } - - fn insert_internal(&mut self, key_nibs: &[u8], value: Vec) -> Result { - match &mut self.data { - MptNodeData::Null => { - self.data = MptNodeData::Leaf(to_encoded_path(key_nibs, true), value); - } - MptNodeData::Branch(children) => { - if let Some((i, tail)) = key_nibs.split_first() { - let child = &mut children[*i as usize]; - match child { - Some(node) => { - if !node.insert_internal(tail, value)? { - return Ok(false); - } - } - // if the corresponding child is empty, insert a new leaf - None => { - *child = Some(Box::new( - MptNodeData::Leaf(to_encoded_path(tail, true), value).into(), - )); - } - } - } else { - return Err(Error::ValueInBranch); - } + pub fn from_digest(digest: B256) -> Self { + if digest == B256::ZERO { + Self::default() + } else { + Self { + inner: CachedTrie::from_digest(digest), + phantom_data: PhantomData, } - MptNodeData::Leaf(prefix, old_value) => { - let self_nibs = prefix_nibs(prefix); - let common_len = lcp(&self_nibs, key_nibs); - if common_len == self_nibs.len() && common_len == key_nibs.len() { - // if self_nibs == key_nibs, update the value if it is different - if old_value == &value { - return Ok(false); - } - *old_value = value; - } else if common_len == self_nibs.len() || common_len == key_nibs.len() { - return Err(Error::ValueInBranch); - } else { - let split_point = common_len + 1; - // otherwise, create a branch with two children - let mut children: [Option>; 16] = Default::default(); - - children[self_nibs[common_len] as usize] = Some(Box::new( - MptNodeData::Leaf( - to_encoded_path(&self_nibs[split_point..], true), - mem::take(old_value), - ) - .into(), - )); - children[key_nibs[common_len] as usize] = Some(Box::new( - MptNodeData::Leaf(to_encoded_path(&key_nibs[split_point..], true), value) - .into(), - )); - - let branch = MptNodeData::Branch(children); - if common_len > 0 { - // create parent extension for new branch - self.data = MptNodeData::Extension( - to_encoded_path(&self_nibs[..common_len], false), - Box::new(branch.into()), - ); - } else { - self.data = branch; - } - } - } - MptNodeData::Extension(prefix, existing_child) => { - let self_nibs = prefix_nibs(prefix); - let common_len = lcp(&self_nibs, key_nibs); - if common_len == self_nibs.len() { - // traverse down for update - if !existing_child.insert_internal(&key_nibs[common_len..], value)? { - return Ok(false); - } - } else if common_len == key_nibs.len() { - return Err(Error::ValueInBranch); - } else { - let split_point = common_len + 1; - // otherwise, create a branch with two children - let mut children: [Option>; 16] = Default::default(); - - children[self_nibs[common_len] as usize] = if split_point < self_nibs.len() { - Some(Box::new( - MptNodeData::Extension( - to_encoded_path(&self_nibs[split_point..], false), - mem::take(existing_child), - ) - .into(), - )) - } else { - Some(mem::take(existing_child)) - }; - children[key_nibs[common_len] as usize] = Some(Box::new( - MptNodeData::Leaf(to_encoded_path(&key_nibs[split_point..], true), value) - .into(), - )); - - let branch = MptNodeData::Branch(children); - if common_len > 0 { - // Create parent extension for new branch - self.data = MptNodeData::Extension( - to_encoded_path(&self_nibs[..common_len], false), - Box::new(branch.into()), - ); - } else { - self.data = branch; - } - } - } - MptNodeData::Digest(digest) => return Err(Error::NodeNotResolved(*digest)), - }; - - self.invalidate_ref_cache(); - Ok(true) - } - - fn invalidate_ref_cache(&mut self) { - self.cached_reference.borrow_mut().take(); - } - - /// Returns the number of traversable nodes in the trie. - /// - /// This method provides a count of all the nodes that can be traversed within the - /// trie. - pub fn size(&self) -> usize { - match self.as_data() { - MptNodeData::Null => 0, - MptNodeData::Branch(children) => { - children.iter().flatten().map(|n| n.size()).sum::() + 1 - } - MptNodeData::Leaf(_, _) => 1, - MptNodeData::Extension(_, child) => child.size() + 1, - MptNodeData::Digest(_) => 0, - } - } - - /// Formats the trie as a string list, where each line corresponds to a trie leaf. - /// - /// This method is primarily used for debugging purposes, providing a visual - /// representation of the trie's structure. - pub fn debug_rlp(&self) -> Vec { - // convert the nibs to hex - let nibs: String = self.nibs().iter().fold(String::new(), |mut output, n| { - let _ = write!(output, "{:x}", n); - output - }); - - match self.as_data() { - MptNodeData::Null => vec![format!("{:?}", MptNodeData::Null)], - MptNodeData::Branch(children) => children - .iter() - .enumerate() - .flat_map(|(i, child)| { - match child { - Some(node) => node.debug_rlp::(), - None => vec!["None".to_string()], - } - .into_iter() - .map(move |s| format!("{:x} {}", i, s)) - }) - .collect(), - MptNodeData::Leaf(_, data) => { - vec![format!( - "{} -> {:?}", - nibs, - T::decode(&mut &data[..]).unwrap() - )] - } - MptNodeData::Extension(_, node) => node - .debug_rlp::() - .into_iter() - .map(|s| format!("{} {}", nibs, s)) - .collect(), - MptNodeData::Digest(digest) => vec![format!("#{:#}", digest)], - } - } - - /// Returns the length of the RLP payload of the node. - fn payload_length(&self) -> usize { - match &self.data { - MptNodeData::Null => 0, - MptNodeData::Branch(nodes) => { - 1 + nodes - .iter() - .map(|child| child.as_ref().map_or(1, |node| node.reference_length())) - .sum::() - } - MptNodeData::Leaf(prefix, value) => { - prefix.as_slice().length() + value.as_slice().length() - } - MptNodeData::Extension(prefix, node) => { - prefix.as_slice().length() + node.reference_length() - } - MptNodeData::Digest(_) => 32, } } -} - -/// Converts a byte slice into a vector of nibbles. -/// -/// A nibble is 4 bits or half of an 8-bit byte. This function takes each byte from the -/// input slice, splits it into two nibbles, and appends them to the resulting vector. -pub fn to_nibs(slice: &[u8]) -> Vec { - let mut result = Vec::with_capacity(2 * slice.len()); - for byte in slice { - result.push(byte >> 4); - result.push(byte & 0xf); - } - result -} - -/// Encodes a slice of nibbles into a vector of bytes, with an additional prefix to -/// indicate the type of node (leaf or extension). -/// -/// The function starts by determining the type of node based on the `is_leaf` parameter. -/// If the node is a leaf, the prefix is set to `0x20`. If the length of the nibbles is -/// odd, the prefix is adjusted and the first nibble is incorporated into it. -/// -/// The remaining nibbles are then combined into bytes, with each pair of nibbles forming -/// a single byte. The resulting vector starts with the prefix, followed by the encoded -/// bytes. -pub fn to_encoded_path(mut nibs: &[u8], is_leaf: bool) -> Vec { - let mut prefix = (is_leaf as u8) * 0x20; - if nibs.len() % 2 != 0 { - prefix += 0x10 + nibs[0]; - nibs = &nibs[1..]; - } - iter::once(prefix) - .chain(nibs.chunks_exact(2).map(|byte| (byte[0] << 4) + byte[1])) - .collect() -} - -/// Returns the length of the common prefix. -fn lcp(a: &[u8], b: &[u8]) -> usize { - for (i, (a, b)) in iter::zip(a, b).enumerate() { - if a != b { - return i; - } - } - cmp::min(a.len(), b.len()) -} - -pub fn prefix_nibs(prefix: &[u8]) -> Vec { - let (extension, tail) = prefix.split_first().unwrap(); - // the first bit of the first nibble denotes the parity - let is_odd = extension & (1 << 4) != 0; - let mut result = Vec::with_capacity(2 * tail.len() + is_odd as usize); - // for odd lengths, the second nibble contains the first element - if is_odd { - result.push(extension & 0xf); - } - for nib in tail { - result.push(nib >> 4); - result.push(nib & 0xf); - } - result -} - -/// Parses proof bytes into a vector of MPT nodes. -pub fn parse_proof(proof: &[impl AsRef<[u8]>]) -> anyhow::Result> { - proof - .iter() - // .filter(|proof| !proof.as_ref().is_empty()) // this is a sign of a malformed proof - .map(|buf| MptNode::decode(&mut buf.as_ref())) - .collect::, _>>() - .context("parse_proof") -} - -/// Creates a Merkle Patricia trie from an EIP-1186 proof. -pub fn mpt_from_proof(proof_nodes: &[MptNode]) -> anyhow::Result { - let mut next: Option = None; - for (i, node) in proof_nodes.iter().enumerate().rev() { - // there is nothing to replace for the last node - let Some(replacement) = next else { - next = Some(node.clone()); - continue; - }; - - // find the child that references the next node - let replacement_digest = replacement.reference().digest(); - let resolved: MptNode = match node.as_data().clone() { - MptNodeData::Branch(mut children) => { - children.iter_mut().flatten().for_each(|c| { - if c.reference().digest() == replacement_digest { - *c = Box::new(replacement.clone()); - } - }); - if children.iter_mut().all(|child| match child { - None => !replacement.is_empty(), - Some(node) => node.reference().digest() != replacement_digest, - }) { - bail!("branch node {} does not reference the successor", i); - } - MptNodeData::Branch(children).into() - } - MptNodeData::Extension(prefix, child) => { - if child.reference().digest() != replacement_digest { - bail!("extension node {} does not reference the successor", i); - } - MptNodeData::Extension(prefix, Box::new(replacement)).into() - } - MptNodeData::Null | MptNodeData::Leaf(_, _) | MptNodeData::Digest(_) => { - bail!("node {} has no children to replace", i); - } - }; - - next = Some(resolved); + #[inline] + pub fn from_rlp_nodes>( + nodes: impl IntoIterator, + ) -> alloy_rlp::Result { + Ok(Self { + inner: CachedTrie::from_rlp_nodes(nodes)?, + phantom_data: PhantomData, + }) } - - // the last node in the proof should be the root - Ok(next.unwrap_or_default()) } -/// Verifies that the given proof is a valid proof of exclusion for the given key. -pub fn is_not_included(key: &[u8], proof_nodes: &[MptNode]) -> anyhow::Result { - let proof_trie = mpt_from_proof(proof_nodes).context("invalid trie")?; - // for valid proofs, the get must not fail - let value = proof_trie.get(key).context("invalid trie")?; - - Ok(value.is_none()) -} +impl Deref for MptNode { + type Target = CachedTrie; -/// Creates a new MPT trie where all the digests contained in `node_store` are resolved. -pub fn resolve_nodes(root: &MptNode, node_store: &HashMap) -> MptNode { - let trie = match root.as_data() { - MptNodeData::Null | MptNodeData::Leaf(_, _) => root.clone(), - MptNodeData::Branch(children) => { - let children: Vec<_> = children - .iter() - .map(|child| { - child - .as_ref() - .map(|node| Box::new(resolve_nodes(node, node_store))) - }) - .collect(); - MptNodeData::Branch(children.try_into().unwrap()).into() - } - MptNodeData::Extension(prefix, target) => { - MptNodeData::Extension(prefix.clone(), Box::new(resolve_nodes(target, node_store))) - .into() - } - MptNodeData::Digest(digest) => { - if let Some(node) = node_store.get(&MptNodeReference::Digest(*digest)) { - resolve_nodes(node, node_store) - } else { - root.clone() - } - } - }; - // the root hash must not change - debug_assert_eq!(root.hash(), trie.hash()); - - trie -} - -/// Creates a new MPT trie where all the digests contained in `node_store` are resolved. -pub fn resolve_nodes_in_place(root: &mut MptNode, node_store: &HashMap) { - let starting_hash = root.hash(); - let replacement = match root.as_data_mut() { - MptNodeData::Null | MptNodeData::Leaf(_, _) => None, - MptNodeData::Branch(children) => { - for child in children.iter_mut().flatten() { - resolve_nodes_in_place(child, node_store); - } - None - } - MptNodeData::Extension(_, target) => { - resolve_nodes_in_place(target, node_store); - None - } - MptNodeData::Digest(digest) => node_store.get(&MptNodeReference::Digest(*digest)), - }; - if let Some(data) = replacement { - root.data = data.data.clone(); - root.invalidate_ref_cache(); - resolve_nodes_in_place(root, node_store); + #[inline] + fn deref(&self) -> &Self::Target { + &self.inner } - // the root hash must not change - debug_assert_eq!(root.hash(), starting_hash); -} - -/// Returns a list of all possible nodes that can be created by shortening the path of the -/// given node. -/// When nodes in an MPT are deleted, leaves or extensions may be extended. To still be -/// able to identify the original nodes, we create all shortened versions of the node. -pub fn shorten_node_path(node: &MptNode) -> Vec { - let mut res = Vec::new(); - let nibs = node.nibs(); - match node.as_data() { - MptNodeData::Null | MptNodeData::Branch(_) => {} - MptNodeData::Leaf(_, value) => { - for i in 0..=nibs.len() { - res.push(MptNodeData::Leaf(to_encoded_path(&nibs[i..], true), value.clone()).into()) - } - } - MptNodeData::Extension(_, child) => { - for i in 0..=nibs.len() { - res.push( - MptNodeData::Extension(to_encoded_path(&nibs[i..], false), child.clone()) - .into(), - ) - } - } - MptNodeData::Digest(_) => unreachable!(), - }; - res } -#[cfg(test)] -mod tests { - use alloy_primitives::hex; - - use super::*; - - #[test] - pub fn test_trie_pointer_no_keccak() { - let cases = [ - ("do", "verb"), - ("dog", "puppy"), - ("doge", "coin"), - ("horse", "stallion"), - ]; - for (k, v) in cases { - let node: MptNode = - MptNodeData::Leaf(k.as_bytes().to_vec(), v.as_bytes().to_vec()).into(); - assert!( - matches!(node.reference(),MptNodeReference::Bytes(bytes) if bytes == alloy_rlp::encode(&node)) - ); - } - } - - #[test] - pub fn test_to_encoded_path() { - // extension node with an even path length - let nibbles = vec![0x0a, 0x0b, 0x0c, 0x0d]; - assert_eq!(to_encoded_path(&nibbles, false), vec![0x00, 0xab, 0xcd]); - // extension node with an odd path length - let nibbles = vec![0x0a, 0x0b, 0x0c]; - assert_eq!(to_encoded_path(&nibbles, false), vec![0x1a, 0xbc]); - // leaf node with an even path length - let nibbles = vec![0x0a, 0x0b, 0x0c, 0x0d]; - assert_eq!(to_encoded_path(&nibbles, true), vec![0x20, 0xab, 0xcd]); - // leaf node with an odd path length - let nibbles = vec![0x0a, 0x0b, 0x0c]; - assert_eq!(to_encoded_path(&nibbles, true), vec![0x3a, 0xbc]); - } - - #[test] - pub fn test_lcp() { - let cases = [ - (vec![], vec![], 0), - (vec![0xa], vec![0xa], 1), - (vec![0xa, 0xb], vec![0xa, 0xc], 1), - (vec![0xa, 0xb], vec![0xa, 0xb], 2), - (vec![0xa, 0xb], vec![0xa, 0xb, 0xc], 2), - (vec![0xa, 0xb, 0xc], vec![0xa, 0xb, 0xc], 3), - (vec![0xa, 0xb, 0xc], vec![0xa, 0xb, 0xc, 0xd], 3), - (vec![0xa, 0xb, 0xc, 0xd], vec![0xa, 0xb, 0xc, 0xd], 4), - ]; - for (a, b, cpl) in cases { - assert_eq!(lcp(&a, &b), cpl) - } - } - - #[test] - pub fn test_empty() { - let trie = MptNode::default(); - - assert!(trie.is_empty()); - assert_eq!(trie.reference(), MptNodeReference::Bytes(vec![0x80])); - let expected = hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); - assert_eq!(expected, trie.hash().0); - - // test RLP encoding - let mut out = Vec::new(); - trie.encode(&mut out); - assert_eq!(out, vec![0x80]); - assert_eq!(trie.length(), out.len()); - let decoded = MptNode::decode(&mut out.as_slice()).unwrap(); - assert_eq!(trie.hash(), decoded.hash()); - } - - #[test] - pub fn test_empty_key() { - let mut trie = MptNode::default(); - - trie.insert(&[], b"empty".to_vec()).unwrap(); - assert_eq!(trie.get(&[]).unwrap(), Some(b"empty".as_ref())); - assert!(trie.delete(&[]).unwrap()); - } - - #[test] - pub fn test_clear() { - let mut trie = MptNode::default(); - trie.insert(b"dog", b"puppy".to_vec()).unwrap(); - assert!(!trie.is_empty()); - assert_ne!(trie.hash(), EMPTY_ROOT); - - trie.clear(); - assert!(trie.is_empty()); - assert_eq!(trie.hash(), EMPTY_ROOT); - } - - #[test] - pub fn test_tiny() { - // trie consisting of an extension, a branch and two leafs - let mut trie = MptNode::default(); - trie.insert_rlp(b"a", 0u8).unwrap(); - trie.insert_rlp(b"b", 1u8).unwrap(); - - assert!(!trie.is_empty()); - let exp_rlp = hex!("d816d680c3208180c220018080808080808080808080808080"); - assert_eq!(trie.reference(), MptNodeReference::Bytes(exp_rlp.to_vec())); - let exp_hash = hex!("6fbf23d6ec055dd143ff50d558559770005ff44ae1d41276f1bd83affab6dd3b"); - assert_eq!(trie.hash().0, exp_hash); - - // test RLP encoding - let mut out = Vec::new(); - trie.encode(&mut out); - assert_eq!(out, exp_rlp.to_vec()); - assert_eq!(trie.length(), out.len()); - let decoded = MptNode::decode(&mut out.as_slice()).unwrap(); - assert_eq!(trie.hash(), decoded.hash()); - } - - #[test] - pub fn test_partial() { - let mut trie = MptNode::default(); - trie.insert_rlp(b"aa", 0u8).unwrap(); - trie.insert_rlp(b"ab", 1u8).unwrap(); - trie.insert_rlp(b"ba", 2u8).unwrap(); - - let exp_hash = trie.hash(); - - // replace one node with its digest - let MptNodeData::Extension(_, node) = &mut trie.data else { - panic!("extension expected") - }; - **node = MptNodeData::Digest(node.hash()).into(); - assert!(node.is_digest()); - - let out = alloy_rlp::encode(&trie); - let trie = MptNode::decode(&mut out.as_slice()).unwrap(); - assert_eq!(trie.hash(), exp_hash); - - // lookups should fail - trie.get(b"aa").unwrap_err(); - trie.get(b"a0").unwrap_err(); - } - - #[test] - pub fn test_branch_value() { - let mut trie = MptNode::default(); - trie.insert(b"do", b"verb".to_vec()).unwrap(); - // leads to a branch with value which is not supported - trie.insert(b"dog", b"puppy".to_vec()).unwrap_err(); - } - - #[test] - pub fn test_insert() { - let mut trie = MptNode::default(); - let vals = vec![ - ("painting", "place"), - ("guest", "ship"), - ("mud", "leave"), - ("paper", "call"), - ("gate", "boast"), - ("tongue", "gain"), - ("baseball", "wait"), - ("tale", "lie"), - ("mood", "cope"), - ("menu", "fear"), - ]; - for (key, val) in &vals { - assert!(trie - .insert(key.as_bytes(), val.as_bytes().to_vec()) - .unwrap()); - } - - let expected = hex!("2bab6cdf91a23ebf3af683728ea02403a98346f99ed668eec572d55c70a4b08f"); - assert_eq!(expected, trie.hash().0); - - for (key, value) in &vals { - assert_eq!(trie.get(key.as_bytes()).unwrap(), Some(value.as_bytes())); - } - - // check inserting duplicate keys - assert!(trie.insert(vals[0].0.as_bytes(), b"new".to_vec()).unwrap()); - assert!(!trie.insert(vals[0].0.as_bytes(), b"new".to_vec()).unwrap()); - - // try RLP roundtrip - let out = alloy_rlp::encode(&trie); - let decoded = MptNode::decode(&mut out.as_slice()).unwrap(); - assert_eq!(trie.hash(), decoded.hash()); - } - - #[test] - pub fn test_keccak_trie() { - const N: usize = 512; - - // insert - let mut trie = MptNode::default(); - for i in 0..N { - assert!(trie.insert_rlp(&keccak(i.to_be_bytes()), i).unwrap()); - - // check hash against trie build in reverse - let mut reference = MptNode::default(); - for j in (0..=i).rev() { - reference.insert_rlp(&keccak(j.to_be_bytes()), j).unwrap(); - } - assert_eq!(trie.hash(), reference.hash()); - } - - let expected = hex!("7310027edebdd1f7c950a7fb3413d551e85dff150d45aca4198c2f6315f9b4a7"); - assert_eq!(trie.hash().0, expected); - - // get - for i in 0..N { - assert_eq!(trie.get_rlp(&keccak(i.to_be_bytes())).unwrap(), Some(i)); - assert!(trie.get(&keccak((i + N).to_be_bytes())).unwrap().is_none()); - } - - // delete - for i in 0..N { - assert!(trie.delete(&keccak(i.to_be_bytes())).unwrap()); - - let mut reference = MptNode::default(); - for j in ((i + 1)..N).rev() { - reference.insert_rlp(&keccak(j.to_be_bytes()), j).unwrap(); - } - assert_eq!(trie.hash(), reference.hash()); - } - assert!(trie.is_empty()); - } - - #[test] - pub fn test_index_trie() { - const N: usize = 512; - - // insert - let mut trie = MptNode::default(); - for i in 0..N { - assert!(trie.insert_rlp(&alloy_rlp::encode(i), i).unwrap()); - - // check hash against trie build in reverse - let mut reference = MptNode::default(); - for j in (0..=i).rev() { - reference.insert_rlp(&alloy_rlp::encode(j), j).unwrap(); - } - assert_eq!(trie.hash(), reference.hash()); - - // try RLP roundtrip - let out = alloy_rlp::encode(&trie); - let decoded = MptNode::decode(&mut out.as_slice()).unwrap(); - assert_eq!(trie.hash(), decoded.hash()); - } - - // get - for i in 0..N { - assert_eq!(trie.get_rlp(&alloy_rlp::encode(i)).unwrap(), Some(i)); - assert!(trie.get(&alloy_rlp::encode(i + N)).unwrap().is_none()); - } - - // delete - for i in 0..N { - assert!(trie.delete(&alloy_rlp::encode(i)).unwrap()); - - let mut reference = MptNode::default(); - for j in ((i + 1)..N).rev() { - reference.insert_rlp(&alloy_rlp::encode(j), j).unwrap(); - } - assert_eq!(trie.hash(), reference.hash()); - } - assert!(trie.is_empty()); +impl DerefMut for MptNode { + #[inline] + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner } } diff --git a/crates/core/src/stateless/data.rs b/crates/core/src/stateless/data.rs index 3f4be5ce..e6054a2e 100644 --- a/crates/core/src/stateless/data.rs +++ b/crates/core/src/stateless/data.rs @@ -14,6 +14,7 @@ use crate::map::NoMapHasher; use crate::mpt::MptNode; +use alloy_consensus::Account; use alloy_primitives::map::HashMap; use alloy_primitives::{Address, Bytes, U256}; use k256::ecdsa::VerifyingKey; @@ -41,7 +42,7 @@ use serde::{Deserialize, Serialize}; rkyv::Deserialize, )] pub struct StorageEntry { - pub storage_trie: MptNode, + pub storage_trie: MptNode, #[rkyv(with = rkyv::with::Map)] pub slots: Vec, } @@ -91,7 +92,7 @@ pub struct _StatelessClientData { /// List of public keys for transaction signatures pub signers: Vec>, /// State trie of the parent block. - pub state_trie: MptNode, + pub state_trie: MptNode, /// Maps each address with its storage trie and the used storage slots. pub storage_tries: HashMap, /// The code for each account @@ -127,7 +128,7 @@ pub struct StatelessClientData { #[rkyv(with = rkyv::with::Map>)] pub signers: Vec>, /// State trie of the parent block. - pub state_trie: MptNode, + pub state_trie: MptNode, /// Maps each address with its storage trie and the used storage slots. #[rkyv(with = rkyv::with::MapKV)] pub storage_tries: HashMap, @@ -164,7 +165,7 @@ pub struct RkyvStatelessClientData { #[rkyv(with = rkyv::with::Map>)] pub signers: Vec>, /// State trie of the parent block. - pub state_trie: MptNode, + pub state_trie: MptNode, /// Maps each address with its storage trie and the used storage slots. #[rkyv(with = rkyv::with::MapKV)] pub storage_tries: HashMap, diff --git a/crates/core/src/stateless/finalize.rs b/crates/core/src/stateless/finalize.rs index 34ef1856..f66bac4d 100644 --- a/crates/core/src/stateless/finalize.rs +++ b/crates/core/src/stateless/finalize.rs @@ -16,11 +16,11 @@ use crate::db::memory::MemoryDB; use crate::db::trie::TrieDB; use crate::db::update::{into_plain_state, Update}; use crate::driver::CoreDriver; -use crate::keccak::keccak; use crate::map::NoMapHasher; use crate::mpt::MptNode; use crate::stateless::data::StorageEntry; use alloy_consensus::Account; +use alloy_primitives::keccak256; use alloy_primitives::map::HashMap; use alloy_primitives::{Address, U256}; use anyhow::{bail, Context}; @@ -30,7 +30,7 @@ use reth_revm::db::BundleState; pub trait FinalizationStrategy { fn finalize_state( block: &mut Driver::Block, - state_trie: &mut MptNode, + state_trie: &mut MptNode, storage_tries: &mut HashMap, parent_header: &mut Driver::Header, db: Option<&mut Database>, @@ -44,7 +44,7 @@ pub struct TrieDbFinalizationStrategy; impl FinalizationStrategy for TrieDbFinalizationStrategy { fn finalize_state( block: &mut Driver::Block, - _state_trie: &mut MptNode, + _state_trie: &mut MptNode, _storage_tries: &mut HashMap, parent_header: &mut Driver::Header, db: Option<&mut TrieDB>, @@ -89,7 +89,7 @@ pub struct MemoryDbFinalizationStrategy; impl FinalizationStrategy for MemoryDbFinalizationStrategy { fn finalize_state( block: &mut Driver::Block, - state_trie: &mut MptNode, + state_trie: &mut MptNode, storage_tries: &mut HashMap, parent_header: &mut Driver::Header, db: Option<&mut MemoryDB>, @@ -124,32 +124,28 @@ impl FinalizationStrategy for MemoryDbFina // apply all new storage entries for the current account (address) let mut deletions = Vec::with_capacity(storage_change.storage.len()); for (key, value) in &storage_change.storage { - let storage_trie_index = keccak(key.to_be_bytes::<32>()); + let storage_trie_index = keccak256(key.to_be_bytes::<32>()); if value.is_zero() { deletions.push(storage_trie_index); } else { - storage_trie - .insert_rlp(&storage_trie_index, value) - .context("storage_trie.insert_rlp")?; + storage_trie.insert_rlp(storage_trie_index, value); } } // Apply deferred storage trie deletions for storage_trie_index in deletions { - storage_trie - .delete(&storage_trie_index) - .context("storage_trie.delete")?; + storage_trie.remove(storage_trie_index); } } // Apply account info + storage changes let mut deletions = Vec::with_capacity(accounts.len()); for (address, account_info) in accounts { - let state_trie_index = keccak(address); + let state_trie_index = keccak256(address); if account_info.is_none() { deletions.push(state_trie_index); continue; } let storage_root = { - let StorageEntry { storage_trie, .. } = storage_tries.get(address).unwrap(); + let StorageEntry { storage_trie, .. } = storage_tries.get_mut(address).unwrap(); storage_trie.hash() }; @@ -160,32 +156,26 @@ impl FinalizationStrategy for MemoryDbFina storage_root, code_hash: info.code_hash, }; - state_trie - .insert_rlp(&state_trie_index, state_account) - .context("state_trie.insert_rlp")?; + state_trie.insert_rlp(state_trie_index, state_account); } // Apply deferred state trie deletions for state_trie_index in deletions { - state_trie - .delete(&state_trie_index) - .context("state_trie.delete")?; + state_trie.remove(state_trie_index); } // Apply account storage only changes for (address, StorageEntry { storage_trie, .. }) in storage_tries { - if storage_trie.is_reference_cached() { + if storage_trie.is_cached() { continue; } - let state_trie_index = keccak(address); + let state_trie_index = keccak256(address); let mut state_account = state_trie - .get_rlp::(&state_trie_index) + .get_rlp(state_trie_index) .context("state_trie.get_rlp")? .unwrap_or_default(); let new_storage_root = storage_trie.hash(); if state_account.storage_root != new_storage_root { state_account.storage_root = storage_trie.hash(); - state_trie - .insert_rlp(&state_trie_index, state_account) - .context("state_trie.insert_rlp (2)")?; + state_trie.insert_rlp(state_trie_index, state_account); } } diff --git a/crates/core/src/stateless/initialize.rs b/crates/core/src/stateless/initialize.rs index 5b974f33..64c4f573 100644 --- a/crates/core/src/stateless/initialize.rs +++ b/crates/core/src/stateless/initialize.rs @@ -15,14 +15,13 @@ use crate::db::memory::MemoryDB; use crate::db::trie::TrieDB; use crate::driver::CoreDriver; -use crate::keccak::keccak; use crate::map::NoMapHasher; use crate::mpt::MptNode; use crate::stateless::data::StorageEntry; use alloy_consensus::constants::EMPTY_ROOT_HASH; use alloy_consensus::Account; use alloy_primitives::map::HashMap; -use alloy_primitives::{Address, Bytes, B256, U256}; +use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; use anyhow::{bail, ensure}; use core::mem::take; use reth_primitives::revm_primitives::Bytecode; @@ -32,7 +31,7 @@ use std::default::Default; pub trait InitializationStrategy { fn initialize_database( - state_trie: &mut MptNode, + state_trie: &mut MptNode, storage_tries: &mut HashMap, contracts: &mut Vec, parent_header: &mut Driver::Header, @@ -44,7 +43,7 @@ pub struct TrieDbInitializationStrategy; impl InitializationStrategy for TrieDbInitializationStrategy { fn initialize_database( - state_trie: &mut MptNode, + state_trie: &mut MptNode, storage_tries: &mut HashMap, contracts: &mut Vec, parent_header: &mut Driver::Header, @@ -62,13 +61,13 @@ impl InitializationStrategy for TrieDbInitia // hash all the contract code let contracts = take(contracts) .into_iter() - .map(|bytes| (keccak(&bytes).into(), Bytecode::new_raw(bytes))) + .map(|bytes| (keccak256(&bytes), Bytecode::new_raw(bytes))) .collect(); // Verify account data in db - for (address, StorageEntry { storage_trie, .. }) in storage_tries.iter() { + for (address, StorageEntry { storage_trie, .. }) in storage_tries.iter_mut() { // load the account from the state trie - let state_account = state_trie.get_rlp::(&keccak(address))?; + let state_account = state_trie.get_rlp(keccak256(address))?; // check that the account storage root matches the storage trie root of the input let storage_root = state_account.map_or(EMPTY_ROOT_HASH, |a| a.storage_root); @@ -127,7 +126,7 @@ impl InitializationStrategy for MemoryDbInitializationStrategy { fn initialize_database( - state_trie: &mut MptNode, + state_trie: &mut MptNode, storage_tries: &mut HashMap, contracts: &mut Vec, parent_header: &mut Driver::Header, @@ -145,7 +144,7 @@ impl InitializationStrategy // hash all the contract code let contracts = take(contracts) .into_iter() - .map(|bytes| (keccak(&bytes).into(), Bytecode::new_raw(bytes))) + .map(|bytes| (keccak256(&bytes), Bytecode::new_raw(bytes))) .collect(); // Load account data into db @@ -163,7 +162,7 @@ impl InitializationStrategy let slots = take(slots); // load the account from the state trie - let state_account = state_trie.get_rlp::(&keccak(address))?; + let state_account = state_trie.get_rlp(keccak256(address))?; // check that the account storage root matches the storage trie root of the input let storage_root = state_account.map_or(EMPTY_ROOT_HASH, |a| a.storage_root); @@ -184,7 +183,7 @@ impl InitializationStrategy HashMap::with_capacity_and_hasher(slots.len(), Default::default()); for slot in slots { let value: U256 = storage_trie - .get_rlp(&keccak(slot.to_be_bytes::<32>()))? + .get_rlp(keccak256(slot.to_be_bytes::<32>()))? .unwrap_or_default(); storage.insert(slot, value); } diff --git a/crates/preflight/Cargo.toml b/crates/preflight/Cargo.toml index f621f604..503f2089 100644 --- a/crates/preflight/Cargo.toml +++ b/crates/preflight/Cargo.toml @@ -11,6 +11,7 @@ alloy.workspace = true anyhow.workspace = true async-trait.workspace = true flate2.workspace = true +itertools.workspace = true k256.workspace = true log.workspace = true pot.workspace = true diff --git a/crates/preflight/src/client.rs b/crates/preflight/src/client.rs index e0ddd4fe..d3d4fbde 100644 --- a/crates/preflight/src/client.rs +++ b/crates/preflight/src/client.rs @@ -17,11 +17,12 @@ use crate::driver::PreflightDriver; use crate::provider::db::ProviderDB; use crate::provider::query::{BlockQuery, UncleQuery}; use crate::provider::{new_provider, Provider}; -use crate::trie::extend_proof_tries; use alloy::network::Network; -use alloy::primitives::map::HashMap; -use alloy::primitives::{Address, Bytes}; +use alloy::primitives::map::{B256Set, HashMap, HashSet}; +use alloy::primitives::{keccak256, Bytes, U256}; +use alloy::rpc::types::EIP1186StorageProof; use anyhow::Context; +use itertools::Itertools; use log::{debug, info, warn}; use std::cell::RefCell; use std::iter::zip; @@ -29,10 +30,7 @@ use std::path::PathBuf; use std::rc::Rc; use zeth_core::db::update::into_plain_state; use zeth_core::driver::CoreDriver; -use zeth_core::map::NoMapHasher; -use zeth_core::mpt::{ - parse_proof, resolve_nodes_in_place, shorten_node_path, MptNode, MptNodeReference, -}; +use zeth_core::mpt::MptNode; use zeth_core::rescue::Wrapper; use zeth_core::stateless::data::{StatelessClientData, StorageEntry}; use zeth_core::stateless::engine::StatelessClientEngine; @@ -165,12 +163,12 @@ where Some(preflight_db), ); - let block_count = data.blocks.len(); + let block_count = data.blocks.len() as u64; let core_parent_header = P::derive_header(data.parent_header.clone()); - let mut state_trie = MptNode::from(R::state_root(&core_parent_header)); - let mut storage_tries = HashMap::::default(); - let mut contracts: Vec = Default::default(); + let mut state_trie = MptNode::from_digest(R::state_root(&core_parent_header)); + let mut storage_tries = HashMap::default(); + let mut contracts: HashSet = HashSet::default(); let mut ancestor_headers: Vec = Default::default(); for num_blocks in 1..=block_count { @@ -191,10 +189,6 @@ where info!("Saving provider cache ..."); preflight_db.save_provider()?; - // info!("Sanity check ..."); - // preflight_db.sanity_check(state_changeset)?; - // preflight_db.save_provider()?; - // Gather inclusion proofs for the initial and final state info!("Gathering initial proofs ..."); let initial_proofs = preflight_db.get_initial_proofs()?; @@ -224,74 +218,101 @@ where // collect the code of the used contracts let initial_db = preflight_db.inner.db.db.borrow(); for code in initial_db.contracts.values() { - contracts.push(code.bytes().clone()); + contracts.insert(code.bytes().clone()); } drop(initial_db); info!("Collected contracts: {}", contracts.len()); - // construct the sparse MPTs from the inclusion proofs - info!( - "Extending tries from {} initialization and {} finalization proofs ...", - initial_proofs.len(), - latest_proofs.len() - ); - let (state_orphans, storage_orphans) = extend_proof_tries( - &mut state_trie, - &mut storage_tries, - initial_proofs, - latest_proofs, - ) - .context("failed to extend proof tries")?; - // resolve potential orphans - let orphan_resolves = - preflight_db.resolve_orphans(block_count as u64, &state_orphans, &storage_orphans); - info!( - "Using {} proofs to resolve {} state and {} storage orphans.", - orphan_resolves.len(), - state_orphans.len(), - storage_orphans.len() - ); - for account_proof in orphan_resolves { - let node_store = parse_proof(&account_proof.account_proof)? + info!("Constructing tries from state proofs..."); + + // build the state trie from the initial account proofs + let account_proofs = initial_proofs + .values() + .flat_map(|proof| &proof.account_proof); + state_trie + .hydrate_from_rlp(account_proofs) + .context("invalid account proof")?; + + // build the storage entries from the initial storage proofs + for (address, proof) in initial_proofs { + let mut storage_trie = MptNode::from_digest(proof.storage_hash); + storage_trie + .hydrate_from_rlp(proof.storage_proof.iter().flat_map(|p| &p.proof)) + .with_context(|| format!("invalid storage proof for {}", address))?; + // collect all the unique storage slots + let slots = proof + .storage_proof .iter() - .flat_map(|n| { - vec![vec![n.clone()], shorten_node_path(n)] - .into_iter() - .flatten() - }) - .map(|n| (n.reference().as_digest(), n)) - .collect(); - resolve_nodes_in_place(&mut state_trie, &node_store); - // resolve storage orphans - if let Some(StorageEntry { storage_trie, .. }) = - storage_tries.get_mut(&account_proof.address) - { - for storage_proof in account_proof.storage_proof { - let node_store: HashMap = - parse_proof(&storage_proof.proof)? - .iter() - .flat_map(|n| { - vec![vec![n.clone()], shorten_node_path(n)] - .into_iter() - .flatten() - }) - .map(|n| (n.reference().as_digest(), n)) - .collect(); - for k in node_store.keys() { - let digest = k.digest(); - if storage_orphans - .iter() - .any(|(a, (_, d))| a == &account_proof.address && &digest == d) - { - info!( - "Resolved storage node {digest} for account {}", - account_proof.address - ); - } - } - resolve_nodes_in_place(storage_trie, &node_store); + .map(|p| p.key.0.into()) + .unique() + .collect::>(); + + storage_tries.insert( + address, + StorageEntry { + storage_trie, + slots, + }, + ); + } + + info!("Extending tries from post-state proofs..."); + + let mut unresolvable_state_keys = B256Set::default(); + + for (address, account_proof) in latest_proofs { + let db_key = keccak256(address); + + // if the key was inserted, extend with the inclusion proof + if state_trie.get(db_key).is_none() { + state_trie + .hydrate_from_rlp(account_proof.account_proof) + .with_context(|| format!("invalid account proof for {}", address))?; + continue; + } + + // otherwise, prepare trie for the removal of that key + state_trie + .resolve_orphan( + db_key, + account_proof.account_proof, + &mut unresolvable_state_keys, + ) + .with_context(|| format!("failed to resolve orphan for {}", address))?; + + let mut unresolvable_storage_keys = B256Set::default(); + + let storage_trie = &mut storage_tries.get_mut(&address).unwrap().storage_trie; + for EIP1186StorageProof { key, proof, .. } in account_proof.storage_proof { + let db_key = keccak256(key.0); + // if the key was inserted, extend with the inclusion proof + if storage_trie.get(db_key).is_none() { + storage_trie.hydrate_from_rlp(proof)?; + } else { + // otherwise, prepare trie for the removal of that key + storage_trie + .resolve_orphan(db_key, proof, &mut unresolvable_storage_keys) + .with_context(|| { + format!("failed to resolve orphan for {}@{}", key.0, address) + })?; } } + + // if orphans could not be resolved, use a range query to get that missing info + if !unresolvable_storage_keys.is_empty() { + let proof = preflight_db + .get_next_slot_proofs(block_count, address, unresolvable_storage_keys) + .with_context(|| format!("failed to get next slot for {}", address))?; + storage_trie + .hydrate_from_rlp(proof.storage_proof.iter().flat_map(|p| &p.proof))?; + } + } + + for state_key in unresolvable_state_keys { + let proof = preflight_db.get_next_account_proof(block_count, state_key)?; + state_trie + .hydrate_from_rlp(proof.account_proof) + .context("failed to get next account")? } info!("Saving provider cache ..."); @@ -312,10 +333,10 @@ where // Report stats info!("State trie: {} nodes", state_trie.size()); - let storage_nodes: u64 = storage_tries + let storage_nodes = storage_tries .values() - .map(|e| e.storage_trie.size() as u64) - .sum(); + .map(|e| e.storage_trie.size()) + .sum::(); info!( "Storage tries: {storage_nodes} total nodes over {} accounts", storage_tries.len() @@ -339,7 +360,7 @@ where signers, state_trie, storage_tries, - contracts, + contracts: contracts.into_iter().collect(), parent_header: P::derive_header(data.parent_header), ancestor_headers, total_difficulty: data.total_difficulty, diff --git a/crates/preflight/src/db.rs b/crates/preflight/src/db.rs index 56e18e68..9a21277a 100644 --- a/crates/preflight/src/db.rs +++ b/crates/preflight/src/db.rs @@ -16,17 +16,18 @@ use crate::driver::PreflightDriver; use crate::provider::db::ProviderDB; use crate::provider::get_proofs; use crate::provider::query::{AccountRangeQuery, BlockQuery, ProofQuery, StorageRangeQuery}; -use crate::trie::TrieOrphan; use alloy::network::Network; use alloy::primitives::map::HashMap; use alloy::primitives::{Address, B256, U256}; use alloy::rpc::types::EIP1186AccountProofResponse; -use log::{error, warn}; +use anyhow::Context; +use log::error; use reth_primitives::revm_primitives::{Account, AccountInfo, Bytecode}; use reth_revm::db::states::StateChangeset; use reth_revm::db::CacheDB; use reth_revm::{Database, DatabaseCommit, DatabaseRef}; use std::cell::{Ref, RefCell}; +use std::collections::BTreeSet; use std::marker::PhantomData; use std::ops::DerefMut; use zeth_core::db::update::Update; @@ -251,87 +252,66 @@ impl> PreflightDB { Ok(headers) } - pub fn resolve_orphans( + /// Fetches the EIP-1186 proof for the next account after a given key. + /// + /// This method retrieves an [EIP1186AccountProofResponse] for the account whose address, when + /// hashed, lexicographically follows the provided `start` key. The proof is generated for the + /// block `block_count` after the currently configured block in the provider. + pub fn get_next_account_proof( &mut self, block_count: u64, - state_orphans: &[TrieOrphan], - storage_orphans: &[(Address, TrieOrphan)], - ) -> Vec { - let state_resolves = self.resolve_state_orphans(state_orphans, block_count); - let storage_resolves = self.resolve_storage_orphans(storage_orphans, block_count); - state_resolves.into_iter().chain(storage_resolves).collect() - } - - pub fn resolve_state_orphans( - &mut self, - state_orphans: &[TrieOrphan], - block_count: u64, - ) -> Vec { + start: B256, + ) -> anyhow::Result { let initial_db = self.inner.db.db.borrow_mut(); let provider_db = initial_db.db.borrow_db(); let mut provider = provider_db.provider.borrow_mut(); - let mut result = Vec::new(); let block_no = initial_db.db.borrow_db().block_no + block_count - 1; - for (start, digest) in state_orphans { - if let Ok(next_account) = provider.get_next_account(&AccountRangeQuery { + + let address = provider + .get_next_account(&AccountRangeQuery::new(block_no, start)) + .context("debug_storageRangeAt call failed")?; + + provider + .get_proof(&ProofQuery { block_no, - start: *start, - max_results: 1, - no_code: true, - no_storage: true, - incompletes: false, - }) { - if let Ok(proof) = provider.get_proof(&ProofQuery { - block_no, - address: next_account, - indices: Default::default(), - }) { - result.push(proof); - continue; - } - continue; - } - warn!("state orphan {digest} not found"); - } - result + address, + indices: BTreeSet::default(), + }) + .context("eth_getProof call failed") } - pub fn resolve_storage_orphans( + /// Fetches EIP-1186 proofs for the next storage slots of a given account. + /// + /// This method retrieves an [EIP1186AccountProofResponse] for multiple storage slots of a given + /// account. For each `B256` key provided in the `starts` iterator, the method finds the next + /// storage slot whose hashed index lexicographically follows the given key. The proofs are + /// generated for the block `block_count` after the currently configured block in the provider. + pub fn get_next_slot_proofs( &mut self, - storage_orphans: &[(Address, TrieOrphan)], block_count: u64, - ) -> Vec { + address: Address, + starts: impl IntoIterator, + ) -> anyhow::Result { let initial_db = self.inner.db.db.borrow_mut(); let provider_db = initial_db.db.borrow_db(); let mut provider = provider_db.provider.borrow_mut(); - let mut result = Vec::new(); let block_no = initial_db.db.borrow_db().block_no + block_count - 1; - for (address, (start, digest)) in storage_orphans { - // if let Ok(val) = provider.get_preimage(&PreimageQuery { digest: *digest }) { - // continue; - // } - if let Ok(next_slot) = provider.get_next_slot(&StorageRangeQuery { - block_no, - tx_index: 0, - address: *address, - start: *start, - max_results: 1, - }) { - if let Ok(proof) = provider.get_proof(&ProofQuery { - block_no, - address: *address, - indices: vec![next_slot] - .into_iter() - .map(|x| x.to_be_bytes().into()) - .collect(), - }) { - result.push(proof); - continue; - } - } - warn!("storage orphan {address}/{digest} not found"); + + let mut indices = BTreeSet::new(); + for start in starts { + let slot = provider + .get_next_slot(&StorageRangeQuery::new(block_no, address, start)) + .context("debug_accountRange call failed")?; + indices.insert(B256::from(slot)); } - result + + provider + .get_proof(&ProofQuery { + block_no, + address, + indices, + }) + .context("eth_getProof call failed") } } diff --git a/crates/preflight/src/lib.rs b/crates/preflight/src/lib.rs index bcf82a41..15995606 100644 --- a/crates/preflight/src/lib.rs +++ b/crates/preflight/src/lib.rs @@ -34,7 +34,6 @@ pub mod client; pub mod db; pub mod driver; pub mod provider; -pub mod trie; #[derive(Debug, Default, Clone)] pub struct Witness { @@ -90,7 +89,7 @@ where block_number: u64, block_count: u64, ) -> anyhow::Result { - // Fetch all of the initial data + // Fetch all the initial data let preflight_data: StatelessClientData = spawn_blocking(move || { ::preflight( chain_id, diff --git a/crates/preflight/src/provider/query.rs b/crates/preflight/src/provider/query.rs index eeaf8152..0307fafd 100644 --- a/crates/preflight/src/provider/query.rs +++ b/crates/preflight/src/provider/query.rs @@ -62,6 +62,19 @@ pub struct AccountRangeQuery { pub incompletes: bool, } +impl AccountRangeQuery { + pub fn new(block_no: u64, start: B256) -> Self { + Self { + block_no, + start, + max_results: 1, + no_code: true, + no_storage: true, + incompletes: true, + } + } +} + #[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct AccountRangeQueryResponse { @@ -91,6 +104,18 @@ pub struct StorageRangeQuery { pub max_results: u64, } +impl StorageRangeQuery { + pub fn new(block_no: u64, address: Address, start: B256) -> Self { + Self { + block_no, + tx_index: 0, + address, + start, + max_results: 1, + } + } +} + #[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct StorageRangeQueryResponse { diff --git a/crates/preflight/src/trie.rs b/crates/preflight/src/trie.rs deleted file mode 100644 index b4ed4938..00000000 --- a/crates/preflight/src/trie.rs +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright 2024, 2025 RISC Zero, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use alloy::primitives::map::HashMap; -use alloy::primitives::{Address, B256, U256}; -use alloy::rpc::types::EIP1186AccountProofResponse; -use anyhow::Context; -use std::collections::VecDeque; -use std::iter; -use zeth_core::keccak::keccak; -use zeth_core::map::NoMapHasher; -use zeth_core::mpt::{ - is_not_included, mpt_from_proof, parse_proof, prefix_nibs, resolve_nodes, - resolve_nodes_in_place, shorten_node_path, MptNode, MptNodeData, MptNodeReference, -}; -use zeth_core::stateless::data::StorageEntry; - -pub type TrieOrphan = (B256, B256); -pub type OrphanPair = (Vec, Vec<(Address, TrieOrphan)>); -pub fn extend_proof_tries( - state_trie: &mut MptNode, - storage_tries: &mut HashMap, - initialization_proofs: HashMap, - finalization_proofs: HashMap, -) -> anyhow::Result { - // collected orphan data - let mut state_orphans = Vec::new(); - let mut storage_orphans = Vec::new(); - // storage for encountered trie data - let mut state_nodes = HashMap::default(); - for (address, initialization_proof) in initialization_proofs { - // Create individual nodes from proof - let proof_nodes = parse_proof(&initialization_proof.account_proof) - .context("invalid account_proof encoding")?; - // Ensure the trie is consistent - mpt_from_proof(&proof_nodes).context("invalid account_proof")?; - // Insert each node into the trie data store - proof_nodes.into_iter().for_each(|node| { - assert_eq!(node.size(), 1); - state_nodes.insert(node.reference(), node); - }); - // insert inaccessible storage trie - if let alloy::primitives::map::Entry::Vacant(e) = storage_tries.entry(address) { - e.insert(StorageEntry { - storage_trie: initialization_proof.storage_hash.into(), - slots: vec![], - }); - } - // storage for encountered storage trie data - let mut storage_nodes = HashMap::default(); - for storage_proof in &initialization_proof.storage_proof { - let proof_nodes = parse_proof(&storage_proof.proof) - .context("extend_proof_tries/parse storage proof")?; - mpt_from_proof(&proof_nodes).with_context(|| { - format!("extend_proof_tries/ mpt from storage proof: {initialization_proof:?}") - })?; - // Load storage entry - let storage_entry = storage_tries.get_mut(&address).unwrap(); - let storage_key = U256::from_be_bytes(storage_proof.key.0 .0); - // Push the storage key if new - if !storage_entry.slots.contains(&storage_key) { - storage_entry.slots.push(storage_key); - } - // Load storage trie nodes into store - proof_nodes.into_iter().for_each(|node| { - storage_nodes.insert(node.reference(), node); - }); - } - - // ensure that trie orphans are loaded - let finalization_proof = finalization_proofs - .get(&address) - .with_context(|| format!("missing finalization proof for address {}", &address))?; - if let Some(state_orphan) = - add_orphaned_nodes(address, &finalization_proof.account_proof, &mut state_nodes) - .with_context(|| format!("failed to add orphaned nodes for address {}", &address))? - { - state_orphans.push(state_orphan); - } - - let mut potential_storage_orphans = Vec::new(); - for storage_proof in &finalization_proof.storage_proof { - if let Some(storage_orphan) = add_orphaned_nodes( - storage_proof.key.0, - &storage_proof.proof, - &mut storage_nodes, - ) - .context("failed to add orphaned nodes")? - { - potential_storage_orphans.push(storage_orphan); - } - } - - let storage_entry = storage_tries.get_mut(&address).unwrap(); - // Load up newly found storage nodes - resolve_nodes_in_place(&mut storage_entry.storage_trie, &storage_nodes); - // validate storage orphans - for (prefix, digest) in potential_storage_orphans { - if let Some(node) = storage_nodes.get(&MptNodeReference::Digest(digest)) { - if !node.is_digest() { - // this orphan node has been resolved - continue; - } - } - // defer node resolution - storage_orphans.push((address, (prefix, digest))); - } - } - // Load up newly found state nodes - resolve_nodes_in_place(state_trie, &state_nodes); - let state_orphans = state_orphans - .into_iter() - .filter(|o| { - state_nodes - .get(&MptNodeReference::Digest(o.1)) - .map(|n| !n.is_digest()) - .unwrap_or_default() - }) - .collect(); - - Ok((state_orphans, storage_orphans)) -} - -pub fn proofs_to_tries( - state_root: B256, - initialization_proofs: HashMap, - finalization_proofs: HashMap, -) -> anyhow::Result<(MptNode, HashMap)> { - // if no addresses are provided, return the trie only consisting of the state root - if initialization_proofs.is_empty() { - return Ok((state_root.into(), HashMap::default())); - } - - let mut storage: HashMap = - HashMap::with_capacity_and_hasher(initialization_proofs.len(), Default::default()); - - let mut state_nodes = HashMap::default(); - let mut state_root_node = MptNode::default(); - for (address, initialization_proof) in initialization_proofs { - let proof_nodes = parse_proof(&initialization_proof.account_proof) - .context("invalid account_proof encoding")?; - mpt_from_proof(&proof_nodes).context("invalid account_proof")?; - - // the first node in the proof is the root - if let Some(node) = proof_nodes.first() { - state_root_node = node.clone(); - } - - proof_nodes.into_iter().for_each(|node| { - state_nodes.insert(node.reference(), node); - }); - - let finalization_proof = finalization_proofs - .get(&address) - .with_context(|| format!("missing finalization proof for address {:#}", &address))?; - - // assure that addresses can be deleted from the state trie - add_orphaned_nodes(address, &finalization_proof.account_proof, &mut state_nodes)?; - - // if no slots are provided, return the trie only consisting of the storage root - if initialization_proof.storage_proof.is_empty() { - storage.insert( - address, - StorageEntry { - storage_trie: initialization_proof.storage_hash.into(), - slots: vec![], - }, - ); - continue; - } - - let mut storage_nodes = HashMap::default(); - let mut storage_root_node = MptNode::default(); - for storage_proof in &initialization_proof.storage_proof { - let proof_nodes = parse_proof(&storage_proof.proof).context("proofs_to_tries")?; - mpt_from_proof(&proof_nodes).context("invalid storage_proof")?; - - // the first node in the proof is the root - if let Some(node) = proof_nodes.first() { - storage_root_node = node.clone(); - } - - proof_nodes.into_iter().for_each(|node| { - storage_nodes.insert(node.reference(), node); - }); - } - - // assure that slots can be deleted from the storage trie - for storage_proof in &finalization_proof.storage_proof { - add_orphaned_nodes( - storage_proof.key.0, - &storage_proof.proof, - &mut storage_nodes, - )?; - } - // create the storage trie, from all the relevant nodes - let storage_trie = resolve_nodes(&storage_root_node, &storage_nodes); - assert_eq!(storage_trie.hash(), initialization_proof.storage_hash); - - // convert the slots to a vector of U256 - let slots = initialization_proof - .storage_proof - .iter() - .map(|p| U256::from_be_bytes(p.key.0 .0)) - .collect(); - storage.insert( - address, - StorageEntry { - storage_trie, - slots, - }, - ); - } - let state_trie = resolve_nodes(&state_root_node, &state_nodes); - assert_eq!(state_trie.hash(), state_root); - - Ok((state_trie, storage)) -} - -/// Adds all the nodes of non-inclusion proofs to the nodes. -pub fn add_orphaned_nodes( - key: impl AsRef<[u8]>, - proof: &[impl AsRef<[u8]>], - nodes_by_reference: &mut HashMap, -) -> anyhow::Result> { - if !proof.is_empty() { - let proof_nodes = parse_proof(proof).context("invalid proof encoding")?; - let offset = keccak(key); - if is_not_included(&offset, &proof_nodes)? { - // extract inferrable orphans - let node = proof_nodes.last().unwrap(); - shorten_node_path(node).into_iter().for_each(|node| { - nodes_by_reference.insert(node.reference().as_digest(), node); - }); - if let MptNodeData::Extension(_, target) = node.as_data() { - return Ok(Some(( - nibbles_to_digest(&proof_nodes_nibbles(&proof_nodes)), - target.hash(), - ))); - } - } - } - Ok(None) -} - -pub fn proof_nodes_nibbles(proof_nodes: &[MptNode]) -> Vec { - let mut nibbles = VecDeque::new(); - let mut last_child = proof_nodes.last().unwrap().reference().as_digest(); - for node in proof_nodes.iter().rev() { - match node.as_data() { - MptNodeData::Branch(children) => { - for (i, child) in children.iter().enumerate() { - if let Some(child) = child { - if child.reference().as_digest() == last_child { - nibbles.push_front(i as u8); - break; - } - } - } - } - MptNodeData::Leaf(prefix, _) | MptNodeData::Extension(prefix, _) => { - prefix_nibs(prefix) - .into_iter() - .rev() - .for_each(|n| nibbles.push_front(n)); - } - MptNodeData::Null | MptNodeData::Digest(_) => unreachable!(), - } - last_child = node.reference(); - } - nibbles.into() -} - -pub fn nibbles_to_digest(nibbles: &[u8]) -> B256 { - let padding = 64 - nibbles.len(); - let padded: Vec<_> = nibbles - .iter() - .copied() - .chain(iter::repeat(0u8).take(padding)) - .collect(); - let bytes: Vec<_> = padded - .chunks_exact(2) - .map(|byte| (byte[0] << 4) + byte[1]) - .collect(); - B256::from_slice(&bytes) -} diff --git a/crates/zeth/src/lib.rs b/crates/zeth/src/lib.rs index 9a61968c..7c485579 100644 --- a/crates/zeth/src/lib.rs +++ b/crates/zeth/src/lib.rs @@ -15,7 +15,7 @@ use crate::cli::Cli; use crate::executor::build_executor_env; use alloy::network::Network; -use alloy::primitives::B256; +use alloy::primitives::{keccak256, B256}; use clap::Parser; use log::{error, info, warn}; use reth_chainspec::NamedChain; @@ -25,7 +25,6 @@ use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use tokio::task::spawn_blocking; use zeth_core::driver::CoreDriver; -use zeth_core::keccak::keccak; use zeth_core::rescue::Recoverable; use zeth_preflight::driver::PreflightDriver; use zeth_preflight::BlockBuilder; @@ -214,7 +213,7 @@ pub fn proof_file_name( prover_opts.as_slice(), ] .concat(); - let file_name = B256::from(keccak(data)); + let file_name = keccak256(data); format!("risc0-{version}-{file_name}.{suffix}") } diff --git a/guests/reth-ethereum/Cargo.lock b/guests/reth-ethereum/Cargo.lock index 930c3007..1b60ddbf 100644 --- a/guests/reth-ethereum/Cargo.lock +++ b/guests/reth-ethereum/Cargo.lock @@ -152,9 +152,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.8" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f35429a652765189c1c5092870d8360ee7b7769b09b06d89ebaefd34676446" +checksum = "788bb18e8f61d5d9340b52143f27771daf7e1dccbaf2741621d2493f9debf52e" dependencies = [ "alloy-rlp", "bytes", @@ -164,7 +164,6 @@ dependencies = [ "foldhash", "getrandom", "hashbrown 0.15.2", - "hex-literal", "indexmap 2.6.0", "itoa", "k256", @@ -322,7 +321,23 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more", - "nybbles", + "nybbles 0.2.1", + "serde", + "smallvec", + "tracing", +] + +[[package]] +name = "alloy-trie" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6917c79e837aa7b77b7a6dae9f89cbe15313ac161c4d3cfaf8909ef21f3d22d8" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "arrayvec", + "derive_more", + "nybbles 0.3.4", "serde", "smallvec", "tracing", @@ -588,6 +603,9 @@ name = "arrayvec" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +dependencies = [ + "serde", +] [[package]] name = "aurora-engine-modexp" @@ -934,9 +952,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586" +checksum = "4b0485bab839b018a8f1723fc5391819fea5f8f0f32288ef8a735fd096b6160c" dependencies = [ "cfg-if", "cpufeatures", @@ -1367,9 +1385,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "foreign-types" @@ -1809,6 +1827,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -2197,6 +2224,19 @@ dependencies = [ "smallvec", ] +[[package]] +name = "nybbles" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8983bb634df7248924ee0c4c3a749609b5abcb082c28fffe3254b3eb3602b307" +dependencies = [ + "alloy-rlp", + "const-hex", + "proptest", + "serde", + "smallvec", +] + [[package]] name = "objc" version = "0.2.7" @@ -2763,7 +2803,7 @@ dependencies = [ "alloy-eips", "alloy-genesis", "alloy-primitives", - "alloy-trie", + "alloy-trie 0.6.0", "auto_impl", "derive_more", "once_cell", @@ -2783,7 +2823,7 @@ dependencies = [ "alloy-eips", "alloy-genesis", "alloy-primitives", - "alloy-trie", + "alloy-trie 0.6.0", "bytes", "modular-bitfield", "reth-codecs-derive", @@ -2939,7 +2979,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more", - "nybbles", + "nybbles 0.2.1", "reth-consensus", "reth-prune-types", "reth-storage-errors", @@ -3154,11 +3194,11 @@ dependencies = [ "alloy-genesis", "alloy-primitives", "alloy-rlp", - "alloy-trie", + "alloy-trie 0.6.0", "bytes", "derive_more", "itertools 0.13.0", - "nybbles", + "nybbles 0.2.1", "reth-codecs", "reth-primitives-traits", "revm-primitives", @@ -3554,9 +3594,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" dependencies = [ "rand", ] @@ -3932,6 +3972,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "steel-trie" +version = "0.1.0" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-trie 0.7.8", + "arrayvec", + "bincode", + "itertools 0.14.0", + "rkyv", + "serde", + "thiserror 2.0.11", +] + [[package]] name = "strsim" version = "0.11.1" @@ -4800,8 +4855,7 @@ dependencies = [ "reth-storage-errors", "rkyv", "serde", - "thiserror 1.0.65", - "tiny-keccak", + "steel-trie", ] [[package]] diff --git a/guests/reth-optimism/Cargo.lock b/guests/reth-optimism/Cargo.lock index 72fccf23..f65ea7b5 100644 --- a/guests/reth-optimism/Cargo.lock +++ b/guests/reth-optimism/Cargo.lock @@ -140,9 +140,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.8" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f35429a652765189c1c5092870d8360ee7b7769b09b06d89ebaefd34676446" +checksum = "788bb18e8f61d5d9340b52143f27771daf7e1dccbaf2741621d2493f9debf52e" dependencies = [ "alloy-rlp", "bytes", @@ -152,7 +152,6 @@ dependencies = [ "foldhash", "getrandom", "hashbrown 0.15.2", - "hex-literal", "indexmap 2.6.0", "itoa", "k256", @@ -298,7 +297,23 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more", - "nybbles", + "nybbles 0.2.1", + "serde", + "smallvec", + "tracing", +] + +[[package]] +name = "alloy-trie" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6917c79e837aa7b77b7a6dae9f89cbe15313ac161c4d3cfaf8909ef21f3d22d8" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "arrayvec", + "derive_more", + "nybbles 0.3.4", "serde", "smallvec", "tracing", @@ -564,6 +579,9 @@ name = "arrayvec" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +dependencies = [ + "serde", +] [[package]] name = "aurora-engine-modexp" @@ -910,9 +928,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586" +checksum = "4b0485bab839b018a8f1723fc5391819fea5f8f0f32288ef8a735fd096b6160c" dependencies = [ "cfg-if", "cpufeatures", @@ -1343,9 +1361,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "foreign-types" @@ -1785,6 +1803,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -2173,6 +2200,19 @@ dependencies = [ "smallvec", ] +[[package]] +name = "nybbles" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8983bb634df7248924ee0c4c3a749609b5abcb082c28fffe3254b3eb3602b307" +dependencies = [ + "alloy-rlp", + "const-hex", + "proptest", + "serde", + "smallvec", +] + [[package]] name = "objc" version = "0.2.7" @@ -2760,7 +2800,7 @@ dependencies = [ "alloy-eips", "alloy-genesis", "alloy-primitives", - "alloy-trie", + "alloy-trie 0.6.0", "auto_impl", "derive_more", "once_cell", @@ -2781,7 +2821,7 @@ dependencies = [ "alloy-eips", "alloy-genesis", "alloy-primitives", - "alloy-trie", + "alloy-trie 0.6.0", "bytes", "modular-bitfield", "op-alloy-consensus", @@ -2906,7 +2946,7 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more", - "nybbles", + "nybbles 0.2.1", "reth-consensus", "reth-prune-types", "reth-storage-errors", @@ -3193,11 +3233,11 @@ dependencies = [ "alloy-genesis", "alloy-primitives", "alloy-rlp", - "alloy-trie", + "alloy-trie 0.6.0", "bytes", "derive_more", "itertools 0.13.0", - "nybbles", + "nybbles 0.2.1", "reth-codecs", "reth-primitives-traits", "revm-primitives", @@ -3594,9 +3634,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" dependencies = [ "rand", ] @@ -3972,6 +4012,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "steel-trie" +version = "0.1.0" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-trie 0.7.8", + "arrayvec", + "bincode", + "itertools 0.14.0", + "rkyv", + "serde", + "thiserror 2.0.11", +] + [[package]] name = "strsim" version = "0.11.1" @@ -4840,8 +4895,7 @@ dependencies = [ "reth-storage-errors", "rkyv", "serde", - "thiserror 1.0.65", - "tiny-keccak", + "steel-trie", ] [[package]] From 55c565b5a2258a74f40b07fc76425ed1a01f6626 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Thu, 16 Jan 2025 14:23:44 +0100 Subject: [PATCH 12/13] use public risc0-ethereum-trie --- Cargo.lock | 33 +++++++++++++++++---------------- Cargo.toml | 7 ++++++- crates/core/Cargo.toml | 2 +- crates/core/src/mpt.rs | 8 +++----- guests/reth-ethereum/Cargo.lock | 33 +++++++++++++++++---------------- guests/reth-optimism/Cargo.lock | 4 ++-- 6 files changed, 46 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 90fc815c..d69218c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4788,6 +4788,22 @@ dependencies = [ "rand_core", ] +[[package]] +name = "risc0-ethereum-trie" +version = "0.1.0" +source = "git+https://github.com/risc0/risc0-ethereum?branch=feat/trie#c39c05720ebfccff520ae380ee906395d8858669" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-trie 0.7.8", + "arrayvec", + "bincode", + "itertools 0.14.0", + "rkyv", + "serde", + "thiserror 2.0.11", +] + [[package]] name = "risc0-groth16" version = "1.2.1-rc.1" @@ -5514,21 +5530,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "steel-trie" -version = "0.1.0" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "alloy-trie 0.7.8", - "arrayvec", - "bincode", - "itertools 0.14.0", - "rkyv", - "serde", - "thiserror 2.0.11", -] - [[package]] name = "strsim" version = "0.10.0" @@ -6652,9 +6653,9 @@ dependencies = [ "reth-primitives", "reth-revm", "reth-storage-errors", + "risc0-ethereum-trie", "rkyv", "serde", - "steel-trie", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 56aa2b54..4073f50b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,11 @@ features = ["unstable"] version = "1.2.1-rc.1" features = ["unstable"] +[workspace.dependencies.risc0-ethereum-trie] +git = "https://github.com/risc0/risc0-ethereum" +branch = "feat/trie" +features = ["orphan", "rkyv", "rlp_serialize", "serde"] + # External [workspace.dependencies] # Alloy @@ -80,7 +85,7 @@ zeth-guests = { path = "guests" } zeth-preflight = { path = "crates/preflight" } zeth-preflight-ethereum = { path = "crates/preflight-ethereum" } zeth-preflight-optimism = { path = "crates/preflight-optimism" } -steel-trie = { path = "../scratch/dev/wwelz/steel-trie", features = ["orphan", "rkyv", "rlp_serialize", "serde"] } + # Others anyhow = "1.0.89" diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 0d5a25e4..36bc5ef5 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -13,7 +13,7 @@ k256.workspace = true pot.workspace = true rkyv.workspace = true serde.workspace = true -steel-trie.workspace = true +risc0-ethereum-trie.workspace = true reth-chainspec.workspace = true reth-primitives.workspace = true diff --git a/crates/core/src/mpt.rs b/crates/core/src/mpt.rs index e29bee49..b8ee3082 100644 --- a/crates/core/src/mpt.rs +++ b/crates/core/src/mpt.rs @@ -1,11 +1,11 @@ use alloy_primitives::map::B256Set; use alloy_primitives::{B256, U256}; use alloy_rlp::{Decodable, Encodable}; +use risc0_ethereum_trie::{orphan, CachedTrie}; use serde::{Deserialize, Serialize}; use std::borrow::Borrow; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; -use steel_trie::{orphan, CachedTrie}; #[derive( Debug, @@ -87,11 +87,9 @@ impl MptNode { } #[inline] - pub fn from_rlp_nodes>( - nodes: impl IntoIterator, - ) -> alloy_rlp::Result { + pub fn from_rlp>(nodes: impl IntoIterator) -> alloy_rlp::Result { Ok(Self { - inner: CachedTrie::from_rlp_nodes(nodes)?, + inner: CachedTrie::from_rlp(nodes)?, phantom_data: PhantomData, }) } diff --git a/guests/reth-ethereum/Cargo.lock b/guests/reth-ethereum/Cargo.lock index 1b60ddbf..72f36370 100644 --- a/guests/reth-ethereum/Cargo.lock +++ b/guests/reth-ethereum/Cargo.lock @@ -3404,6 +3404,22 @@ dependencies = [ "rand_core", ] +[[package]] +name = "risc0-ethereum-trie" +version = "0.1.0" +source = "git+https://github.com/risc0/risc0-ethereum?branch=feat/trie#c39c05720ebfccff520ae380ee906395d8858669" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-trie 0.7.8", + "arrayvec", + "bincode", + "itertools 0.14.0", + "rkyv", + "serde", + "thiserror 2.0.11", +] + [[package]] name = "risc0-groth16" version = "1.2.1-rc.1" @@ -3972,21 +3988,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "steel-trie" -version = "0.1.0" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "alloy-trie 0.7.8", - "arrayvec", - "bincode", - "itertools 0.14.0", - "rkyv", - "serde", - "thiserror 2.0.11", -] - [[package]] name = "strsim" version = "0.11.1" @@ -4853,9 +4854,9 @@ dependencies = [ "reth-primitives", "reth-revm", "reth-storage-errors", + "risc0-ethereum-trie", "rkyv", "serde", - "steel-trie", ] [[package]] diff --git a/guests/reth-optimism/Cargo.lock b/guests/reth-optimism/Cargo.lock index f65ea7b5..4d066a77 100644 --- a/guests/reth-optimism/Cargo.lock +++ b/guests/reth-optimism/Cargo.lock @@ -4013,7 +4013,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "steel-trie" +name = "risc0-ethereum-trie" version = "0.1.0" dependencies = [ "alloy-primitives", @@ -4895,7 +4895,7 @@ dependencies = [ "reth-storage-errors", "rkyv", "serde", - "steel-trie", + "risc0-ethereum-trie", ] [[package]] From c85c46310aebe107df599469c78691ee8b89c7ed Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Thu, 16 Jan 2025 15:10:20 +0100 Subject: [PATCH 13/13] fix Cargo.lock --- guests/reth-optimism/Cargo.lock | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/guests/reth-optimism/Cargo.lock b/guests/reth-optimism/Cargo.lock index 4d066a77..a3cd855b 100644 --- a/guests/reth-optimism/Cargo.lock +++ b/guests/reth-optimism/Cargo.lock @@ -3444,6 +3444,22 @@ dependencies = [ "rand_core", ] +[[package]] +name = "risc0-ethereum-trie" +version = "0.1.0" +source = "git+https://github.com/risc0/risc0-ethereum?branch=feat/trie#7fa3505fef029200251e8110f87656c0e9ddbd39" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-trie 0.7.8", + "arrayvec", + "bincode", + "itertools 0.14.0", + "rkyv", + "serde", + "thiserror 2.0.11", +] + [[package]] name = "risc0-groth16" version = "1.2.1-rc.1" @@ -4012,21 +4028,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "risc0-ethereum-trie" -version = "0.1.0" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "alloy-trie 0.7.8", - "arrayvec", - "bincode", - "itertools 0.14.0", - "rkyv", - "serde", - "thiserror 2.0.11", -] - [[package]] name = "strsim" version = "0.11.1" @@ -4893,9 +4894,9 @@ dependencies = [ "reth-primitives", "reth-revm", "reth-storage-errors", + "risc0-ethereum-trie", "rkyv", "serde", - "risc0-ethereum-trie", ] [[package]]