diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07378df..6a7078e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,10 +49,6 @@ jobs: name: Clippy timeout-minutes: 30 runs-on: ubuntu-latest - strategy: - matrix: - target: [ "--all-targets", "--bin stateless-block-verifier" ] - features: [ "--features=\"bin-deps\"", "--features=\"bin-deps, dev\"", "--all-features" ] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master @@ -61,8 +57,18 @@ jobs: components: clippy - name: cargo cache uses: Swatinem/rust-cache@v2 - - name: clippy - run: cargo clippy --workspace ${{ matrix.target }} ${{ matrix.features }} -- -D warnings + - name: clippy default + run: cargo clippy --workspace -- -D warnings + - name: clippy dev + run: cargo clippy --workspace --features dev -- -D warnings + - name: clippy metrics + run: cargo clippy --workspace --features metrics -- -D warnings + - name: clippy all + run: cargo clippy --workspace --all-features -- -D warnings + - name: clippy test + run: cargo clippy --workspace --tests -- -D warnings + - name: clippy test all + run: cargo clippy --workspace --tests --all-features -- -D warnings integration-tests: needs: [ clippy ] @@ -88,5 +94,5 @@ jobs: with: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@v2 - - run: cargo run --release --features bin-deps --package stateless-block-verifier --bin stateless-block-verifier -- -k run-file testdata/mainnet_blocks/flatten-proofs/* - - run: cargo run --release --features bin-deps --package stateless-block-verifier --bin stateless-block-verifier -- -k run-file testdata/sepolia_blocks/* + - run: cargo run --release --package stateless-block-verifier -- -k run-file testdata/mainnet_blocks/flatten-proofs/* + - run: cargo run --release --package stateless-block-verifier -- -k run-file testdata/sepolia_blocks/* diff --git a/Cargo.lock b/Cargo.lock index a606ede..f6554be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,7 +123,7 @@ checksum = "4d0f2d905ebd295e7effec65e5f6868d153936130ae718352771de3e7d03c75c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -357,7 +357,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -377,17 +377,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "aurora-engine-modexp" version = "1.1.0" @@ -406,7 +395,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -704,7 +693,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -901,7 +890,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -934,7 +923,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -945,7 +934,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -998,7 +987,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1108,20 +1097,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", -] - -[[package]] -name = "env_logger" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", + "syn 2.0.77", ] [[package]] @@ -1486,7 +1462,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1615,7 +1591,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.4.0", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -1634,7 +1610,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.4.0", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -1682,15 +1658,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -1795,12 +1762,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.30" @@ -1997,9 +1958,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -2013,7 +1974,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "232929e1d75fe899576a3d5c7416ad0d88dbfbb3c3d6aa00873a7408a50ddb88" dependencies = [ "ahash 0.8.11", - "indexmap 2.4.0", + "indexmap 2.5.0", "is-terminal", "itoa", "log", @@ -2429,14 +2390,14 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "object" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -2495,7 +2456,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2655,7 +2616,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2794,7 +2755,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3121,9 +3082,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.48" +version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f86ae463694029097b846d8f99fd5536740602ae00022c0c50c5600720b2f71" +checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" dependencies = [ "bytemuck", ] @@ -3349,6 +3310,61 @@ dependencies = [ "cipher", ] +[[package]] +name = "sbv-core" +version = "0.1.0" +dependencies = [ + "ctor", + "eth-types", + "hex", + "itertools 0.13.0", + "mpt-zktrie", + "once_cell", + "revm", + "rkyv", + "sbv-primitives", + "sbv-utils", + "serde", + "serde_json", + "thiserror", + "tiny-keccak", + "tracing", + "tracing-subscriber", + "zktrie", +] + +[[package]] +name = "sbv-primitives" +version = "0.1.0" +dependencies = [ + "eth-types", + "mpt-zktrie", + "revm-primitives", + "rkyv", + "sbv-utils", + "tiny-keccak", +] + +[[package]] +name = "sbv-utils" +version = "0.1.0" +dependencies = [ + "csv", + "eth-types", + "http-body-util", + "hyper 1.4.1", + "hyper-util", + "mpt-zktrie", + "once_cell", + "prometheus-client", + "rand", + "reqwest 0.12.7", + "revm", + "serde", + "tokio", + "tracing", +] + [[package]] name = "scale-info" version = "2.11.3" @@ -3515,7 +3531,7 @@ checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3524,7 +3540,7 @@ version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "itoa", "memchr", "ryu", @@ -3553,7 +3569,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.4.0", + "indexmap 2.5.0", "serde", "serde_derive", "serde_json", @@ -3570,7 +3586,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3579,7 +3595,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "itoa", "ryu", "serde", @@ -3711,35 +3727,22 @@ dependencies = [ "anyhow", "async-channel", "clap", - "csv", - "ctor", - "env_logger", "eth-types", "ethers-core", "ethers-providers", "futures", - "hex", - "http-body-util", - "hyper 1.4.1", - "hyper-util", - "itertools 0.13.0", "mpt-zktrie", - "once_cell", "pprof", - "prometheus-client", - "rand", - "reqwest 0.12.7", - "revm", - "rkyv", + "sbv-core", + "sbv-primitives", + "sbv-utils", "serde", "serde_json", - "thiserror", "tiny-keccak", "tokio", "tracing", "tracing-subscriber", "url", - "zktrie", ] [[package]] @@ -3798,7 +3801,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3856,9 +3859,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.76" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -3941,15 +3944,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.63" @@ -3967,7 +3961,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4046,9 +4040,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -4069,7 +4063,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4118,7 +4112,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "toml_datetime", "winnow 0.5.40", ] @@ -4129,7 +4123,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "toml_datetime", "winnow 0.6.18", ] @@ -4180,7 +4174,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4404,7 +4398,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-shared", ] @@ -4438,7 +4432,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4475,15 +4469,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys 0.48.0", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -4751,7 +4736,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4771,7 +4756,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 312b48f..aeeda9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,8 @@ -[package] -name = "stateless-block-verifier" -version = "0.1.0" -edition = "2021" +[workspace] +members = ["crates/*"] +resolver = "2" -[dependencies] +[workspace.dependencies] hex = "0.4" itertools = "0.13.0" # for compatibility msrv 1.75 once_cell = "1.19" @@ -16,45 +15,40 @@ eth-types = { git = "https://github.com/scroll-tech/zkevm-circuits", features = mpt-zktrie = { git = "https://github.com/scroll-tech/zkevm-circuits", branch = "feat/rkyv" } zktrie = { git = "https://github.com/scroll-tech/zktrie.git", branch = "main", features= ["rs_zktrie"] } -# for local development -# eth-types = { path = "../zkevm-circuits/eth-types", features = ["scroll"] } -# mpt-zktrie = { path = "../zkevm-circuits/zktrie" } -# revm = {path = "../revm/crates/revm", default-features = false, features = ["scroll-default-handler", "std", "optional_no_base_fee"] } # v40 -# zktrie = { path = "../zktrie", features= ["rs_zktrie"] } - - # binary dependencies -anyhow = { version = "1.0", optional = true } -async-channel = { version = "2.2", optional = true } -clap = { version = "4", optional = true } -env_logger = { version = "0.9", optional = true } -ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv", optional = true } -ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv", default-features = false, optional = true } -futures = { version = "0.3", optional = true } -serde_json = { version = "1.0", optional = true } -serde = { version = "1.0", optional = true } -tokio = { version = "1", default-features = false, optional = true } -url = { version = "2.5", optional = true } +anyhow = "1.0" +async-channel = "2.2" +clap = "4" +env_logger = "0.9" +ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" } +ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv", default-features = false } +futures = "0.3" +serde_json = "1.0" +serde = "1.0" +tokio = { version = "1", default-features = false } +url = "2.5" # optional dependencies -csv = { version = "1.3", optional = true } -ctor = { version = "0.2", optional = true } -hyper = { version = "1.4", features = ["server", "http1"], optional = true } -hyper-util = { version = "0.1", features = ["tokio"], optional = true } -http-body-util = { version = "0.1", optional = true } -prometheus-client = { version = "0.22", optional = true } -pprof = { version = "0.13", features = ["flamegraph"], optional = true } -tracing = { version = "0.1", optional = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true } +csv = "1.3" +ctor = "0.2" +hyper = { version = "1.4", features = ["server", "http1"] } +hyper-util = { version = "0.1", features = ["tokio"] } +http-body-util = "0.1" +prometheus-client = "0.22" +pprof = { version = "0.13", features = ["flamegraph"] } +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } -# for local development -# [patch."https://github.com/scroll-tech/zkevm-circuits"] -# eth-types = { path = "../zkevm-circuits/eth-types" } -# mpt-zktrie = { path = "../zkevm-circuits/zktrie" } -# [patch."https://github.com/scroll-tech/revm"] -# revm = { path = "../revm/crates/revm" } +# dev dependencies +rand = "0.8" +reqwest = "0.12" -[dependencies.revm] # v40 +# workspace +sbv-core = { path = "crates/core" } +sbv-primitives = { path = "crates/primitives" } +sbv-utils = { path = "crates/utils" } + +[workspace.dependencies.revm] # v41 git = "https://github.com/scroll-tech/revm" branch = "scroll-evm-executor/v41" default-features = false @@ -65,47 +59,16 @@ features = [ "optional_no_base_fee" ] -[dev-dependencies] -rand = "0.8" -reqwest = "0.12" -serde = { version = "1.0" } -serde_json = { version = "1.0" } - -[[bin]] -name = "stateless-block-verifier" -path = "src/bin/trace-verifier/main.rs" -required-features = ["bin-deps"] - -[features] -bin-deps = [ - "anyhow", - "async-channel", - "clap", - "clap/derive", - "env_logger", - "ethers-core", - "ethers-core/scroll", - "ethers-providers", - "futures", - "serde_json", - "serde", - "serde/derive", - "tokio", - "tokio/fs", - "tokio/macros", - "tokio/rt-multi-thread", - "url" +[workspace.dependencies.revm-primitives] # v41 +git = "https://github.com/scroll-tech/revm" +branch = "scroll-evm-executor/v41" +default-features = false +features = [ + "scroll-default-handler", + "scroll-poseidon-codehash", + "std", + "optional_no_base_fee" ] -profiling = ["pprof"] -debug-account = ["csv", "revm/serde"] -debug-storage = ["csv", "revm/serde"] -dev = ["ctor", "tracing", "tracing-subscriber"] -metrics = ["hyper", "hyper-util", "http-body-util", "prometheus-client", "tokio", "tokio/macros", "tokio/signal"] - -# sp1 related -sp1 = [] -cycle-tracker = [] -ordered-db = ["revm/ordered-cache-db"] [patch.crates-io] ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" } @@ -122,5 +85,12 @@ ff = { git = "https://github.com/scroll-tech/ff", branch = "feat/sp1" } # primitive-types = { path = "../parity-common/primitive-types" } # ethereum-types = { path = "../parity-common/ethereum-types" } -[profile.release] -debug-assertions = true +# for local development +# [patch."https://github.com/scroll-tech/zkevm-circuits"] +# eth-types = { path = "../zkevm-circuits/eth-types" } +# mpt-zktrie = { path = "../zkevm-circuits/zktrie" } +# [patch."https://github.com/scroll-tech/revm"] +# revm = { path = "../revm/crates/revm" } + +#[profile.release] +#debug-assertions = true \ No newline at end of file diff --git a/README.md b/README.md index e97862c..a15d589 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,16 @@ This project provides tools for stateless verification of blocks with mpt state ## Run and verify a trace file ``` -cargo run --bin stateless-block-verifier --features="bin-deps" -- [--disable-checks] run-file testdata/mainnet_blocks/0x7ea4fb.json +cargo run --package stateless-block-verifier -- [--disable-checks] run-file testdata/mainnet_blocks/0x7ea4fb.json ``` ## Run Chunk mode trace files ``` -cargo run --bin stateless-block-verifier --features="bin-deps" -- run-file --chunk-mode testdata/mainnet_blocks/837* +cargo run --package stateless-block-verifier -- run-file --chunk-mode testdata/mainnet_blocks/837* ``` ## Fetch and verify traces from Geth rpc ``` -cargo run --bin stateless-block-verifier --features="bin-deps" -- [--disable-checks] run-rpc --url http://localhost:8545 --start-block latest +cargo run --package stateless-block-verifier -- [--disable-checks] run-rpc --url http://localhost:8545 --start-block latest ``` diff --git a/crates/bin/Cargo.toml b/crates/bin/Cargo.toml new file mode 100644 index 0000000..abc50c3 --- /dev/null +++ b/crates/bin/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "stateless-block-verifier" +version = "0.1.0" +edition = "2021" + +[dependencies] +anyhow.workspace = true +async-channel.workspace = true +clap = { workspace = true, features = ["derive"] } +ethers-core = { workspace = true, features = ["scroll"] } +ethers-providers.workspace = true +futures.workspace = true +serde_json.workspace = true +serde = { workspace = true, features = ["derive"] } +tiny-keccak.workspace = true +tokio = { workspace = true, features = ["fs", "macros", "rt-multi-thread"] } +url.workspace = true + +sbv-core.workspace = true +sbv-primitives.workspace = true +sbv-utils.workspace = true + +eth-types.workspace = true +mpt-zktrie.workspace = true + +pprof = { workspace = true, optional = true } +tracing-subscriber = { workspace = true, optional = true } + +[dev-dependencies] +tracing.workspace = true +tracing-subscriber.workspace = true + +[features] +default = ["dev"] +dev = ["sbv-core/dev", "dep:tracing-subscriber"] +debug-account = ["sbv-core/debug-account"] +debug-storage = ["sbv-core/debug-storage"] +profiling = ["dep:pprof"] +metrics = ["sbv-core/metrics"] \ No newline at end of file diff --git a/src/bin/trace-verifier/commands/mod.rs b/crates/bin/src/commands/mod.rs similarity index 93% rename from src/bin/trace-verifier/commands/mod.rs rename to crates/bin/src/commands/mod.rs index 9e68ae3..376a3cf 100644 --- a/src/bin/trace-verifier/commands/mod.rs +++ b/crates/bin/src/commands/mod.rs @@ -1,5 +1,5 @@ use clap::Subcommand; -use stateless_block_verifier::HardforkConfig; +use sbv_core::HardforkConfig; mod run_file; mod run_rpc; diff --git a/src/bin/trace-verifier/commands/run_file.rs b/crates/bin/src/commands/run_file.rs similarity index 90% rename from src/bin/trace-verifier/commands/run_file.rs rename to crates/bin/src/commands/run_file.rs index 15ce200..235032e 100644 --- a/src/bin/trace-verifier/commands/run_file.rs +++ b/crates/bin/src/commands/run_file.rs @@ -2,8 +2,8 @@ use crate::utils; use anyhow::bail; use clap::Args; use eth_types::{l2_types::BlockTrace, H256}; -use stateless_block_verifier::{ChunkInfo, EvmExecutorBuilder, HardforkConfig}; -use std::{cell::RefCell, path::PathBuf, rc::Rc}; +use sbv_core::{ChunkInfo, EvmExecutorBuilder, HardforkConfig}; +use std::{cell::RefCell, path::PathBuf}; use tiny_keccak::{Hasher, Keccak}; use tokio::task::JoinSet; @@ -76,14 +76,13 @@ impl RunFileCommand { let fork_config = fork_config(traces[0].chain_id); let (chunk_info, mut zktrie_state) = ChunkInfo::from_block_traces(&traces); - let tx_bytes_hasher = Rc::new(RefCell::new(Keccak::v256())); + let tx_bytes_hasher = RefCell::new(Keccak::v256()); let mut executor = EvmExecutorBuilder::new(&zktrie_state) .hardfork_config(fork_config) .with_execute_hooks(|hooks| { - let hasher = tx_bytes_hasher.clone(); - hooks.add_tx_rlp_handler(move |_, rlp| { - hasher.borrow_mut().update(rlp); + hooks.add_tx_rlp_handler(|_, rlp| { + tx_bytes_hasher.borrow_mut().update(rlp); }); }) .build(&traces[0])?; @@ -101,8 +100,7 @@ impl RunFileCommand { drop(executor); let mut tx_bytes_hash = H256::zero(); - let hasher = Rc::into_inner(tx_bytes_hasher).unwrap(); - hasher.into_inner().finalize(&mut tx_bytes_hash.0); + tx_bytes_hasher.into_inner().finalize(&mut tx_bytes_hash.0); let _public_input_hash = chunk_info.public_input_hash(&tx_bytes_hash); dev_info!("[chunk mode] public input hash: {:?}", _public_input_hash); diff --git a/src/bin/trace-verifier/commands/run_rpc.rs b/crates/bin/src/commands/run_rpc.rs similarity index 99% rename from src/bin/trace-verifier/commands/run_rpc.rs rename to crates/bin/src/commands/run_rpc.rs index 68730c8..44a9134 100644 --- a/src/bin/trace-verifier/commands/run_rpc.rs +++ b/crates/bin/src/commands/run_rpc.rs @@ -2,7 +2,7 @@ use clap::Args; use eth_types::l2_types::BlockTrace; use ethers_providers::{Http, Middleware, Provider}; use futures::future::OptionFuture; -use stateless_block_verifier::HardforkConfig; +use sbv_core::HardforkConfig; use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; diff --git a/src/bin/trace-verifier/main.rs b/crates/bin/src/main.rs similarity index 90% rename from src/bin/trace-verifier/main.rs rename to crates/bin/src/main.rs index 5819858..665efd1 100644 --- a/src/bin/trace-verifier/main.rs +++ b/crates/bin/src/main.rs @@ -1,8 +1,8 @@ #[macro_use] -extern crate stateless_block_verifier; +extern crate sbv_utils; use clap::Parser; -use stateless_block_verifier::HardforkConfig; +use sbv_core::HardforkConfig; #[cfg(feature = "dev")] use tracing_subscriber::EnvFilter; @@ -47,7 +47,7 @@ async fn main() -> anyhow::Result<()> { #[cfg(feature = "metrics")] if cmd.metrics { - stateless_block_verifier::metrics::start_metrics_server(cmd.metrics_addr); + sbv_utils::metrics::start_metrics_server(cmd.metrics_addr); } let get_fork_config = move |chain_id: u64| { diff --git a/src/bin/trace-verifier/utils.rs b/crates/bin/src/utils.rs similarity index 67% rename from src/bin/trace-verifier/utils.rs rename to crates/bin/src/utils.rs index 4c03d23..4b0d5b7 100644 --- a/src/bin/trace-verifier/utils.rs +++ b/crates/bin/src/utils.rs @@ -1,11 +1,10 @@ -use eth_types::l2_types::BlockTrace; use mpt_zktrie::ZktrieState; -use stateless_block_verifier::{ - post_check, utils::ext::BlockZktrieExt, EvmExecutorBuilder, HardforkConfig, VerificationError, -}; +use sbv_core::{EvmExecutorBuilder, HardforkConfig, VerificationError}; +use sbv_primitives::BlockTrace; +use sbv_utils::post_check; -pub fn verify( - l2_trace: &BlockTrace, +pub fn verify( + l2_trace: T, fork_config: &HardforkConfig, disable_checks: bool, ) -> Result<(), VerificationError> { @@ -15,13 +14,13 @@ pub fn verify( ) } -fn verify_inner( - l2_trace: &BlockTrace, +fn verify_inner( + l2_trace: T, fork_config: &HardforkConfig, disable_checks: bool, ) -> Result<(), VerificationError> { dev_trace!("{l2_trace:#?}"); - let root_after = l2_trace.storage_trace.root_after; + let root_after = l2_trace.root_after(); // or with v2 trace // let v2_trace = BlockTraceV2::from(l2_trace.clone()); @@ -40,9 +39,12 @@ fn verify_inner( let mut zktrie_state = cycle_track!( { - let old_root = l2_trace.storage_trace.root_before; + let old_root = l2_trace.root_before(); let mut zktrie_state = ZktrieState::construct(old_root); - l2_trace.build_zktrie_state(&mut zktrie_state); + measure_duration_histogram!( + build_zktrie_state_duration_microseconds, + l2_trace.build_zktrie_state(&mut zktrie_state) + ); zktrie_state }, "build ZktrieState" @@ -51,10 +53,13 @@ fn verify_inner( let mut executor = EvmExecutorBuilder::new(&zktrie_state) .hardfork_config(*fork_config) .with_execute_hooks(|hooks| { - let l2_trace = l2_trace.clone(); if !disable_checks { - hooks.add_post_tx_execution_handler(move |executor, tx_id| { - post_check(executor.db(), &l2_trace.execution_results[tx_id]); + hooks.add_post_tx_execution_handler(|executor, tx_id| { + if let Some(execution_result) = l2_trace.execution_results(tx_id) { + post_check(executor.db(), execution_result); + } else { + dev_warn!("No execution result found in trace but post check is enabled"); + } }) } }) @@ -62,10 +67,12 @@ fn verify_inner( // TODO: change to Result::inspect_err when sp1 toolchain >= 1.76 #[allow(clippy::map_identity)] + #[allow(clippy::manual_inspect)] executor.handle_block(&l2_trace).map_err(|e| { dev_error!( - "Error occurs when executing block {:?}: {e:?}", - l2_trace.header.hash.unwrap() + "Error occurs when executing block #{}({:?}): {e:?}", + l2_trace.number(), + l2_trace.block_hash() ); update_metrics_counter!(verification_error); @@ -79,10 +86,7 @@ fn verify_inner( .join(env!("CARGO_PKG_NAME")) .join("profiling"); std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join(format!( - "block-{}.svg", - l2_trace.header.number.unwrap().as_u64() - )); + let path = dir.join(format!("block-{}.svg", l2_trace.number())); let file = std::fs::File::create(&path).unwrap(); report.flamegraph(file).unwrap(); dev_info!("Profiling report saved to: {:?}", path); @@ -91,8 +95,8 @@ fn verify_inner( if root_after != revm_root_after { dev_error!( "Block #{}({:?}) root mismatch: root after in trace = {root_after:x}, root after in revm = {revm_root_after:x}", - l2_trace.header.number.unwrap().as_u64(), - l2_trace.header.hash.unwrap() + l2_trace.number(), + l2_trace.block_hash(), ); update_metrics_counter!(verification_error); @@ -104,8 +108,8 @@ fn verify_inner( } dev_info!( "Block #{}({}) verified successfully", - l2_trace.header.number.unwrap().as_u64(), - l2_trace.header.hash.unwrap() + l2_trace.number(), + l2_trace.block_hash(), ); Ok(()) } diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml new file mode 100644 index 0000000..a3459c2 --- /dev/null +++ b/crates/core/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "sbv-core" +version = "0.1.0" +edition = "2021" + +[dependencies] +hex.workspace = true +itertools.workspace = true +once_cell.workspace = true +revm.workspace = true +rkyv.workspace = true +thiserror.workspace = true +tiny-keccak.workspace = true + +# dependencies from scroll-tech +eth-types.workspace = true +mpt-zktrie.workspace = true +zktrie.workspace = true + +sbv-primitives.workspace = true +sbv-utils.workspace = true + +[dev-dependencies] +ctor.workspace = true +serde.workspace = true +serde_json.workspace = true +tracing.workspace = true +tracing-subscriber.workspace = true + +[features] +debug-account = ["sbv-utils/debug-account"] +debug-storage = ["sbv-utils/debug-storage"] +dev = ["sbv-utils/dev"] +metrics = ["sbv-utils/metrics"] + +# sp1 related +sp1 = [] +cycle-tracker = [] +ordered-db = ["revm/ordered-cache-db"] diff --git a/src/chunk.rs b/crates/core/src/chunk.rs similarity index 84% rename from src/chunk.rs rename to crates/core/src/chunk.rs index e58562c..1093a25 100644 --- a/src/chunk.rs +++ b/crates/core/src/chunk.rs @@ -1,6 +1,6 @@ -use crate::BlockTraceExt; use eth_types::H256; use mpt_zktrie::ZktrieState; +use sbv_primitives::BlockTrace; use tiny_keccak::{Hasher, Keccak}; /// A chunk is a set of continuous blocks. @@ -22,7 +22,7 @@ pub struct ChunkInfo { impl ChunkInfo { /// Construct by block traces - pub fn from_block_traces(traces: &[T]) -> (Self, ZktrieState) { + pub fn from_block_traces(traces: &[T]) -> (Self, ZktrieState) { let chain_id = traces.first().unwrap().chain_id(); let prev_state_root = traces .first() @@ -43,7 +43,10 @@ impl ChunkInfo { let mut zktrie_state = ZktrieState::construct(prev_state_root); for trace in traces.iter() { - trace.build_zktrie_state(&mut zktrie_state); + measure_duration_histogram!( + build_zktrie_state_duration_microseconds, + trace.build_zktrie_state(&mut zktrie_state) + ); } let info = ChunkInfo { @@ -113,13 +116,12 @@ mod tests { use crate::{EvmExecutorBuilder, HardforkConfig}; use eth_types::l2_types::BlockTrace; use std::cell::RefCell; - use std::rc::Rc; const TRACES_STR: [&str; 4] = [ - include_str!("../testdata/mainnet_blocks/8370400.json"), - include_str!("../testdata/mainnet_blocks/8370401.json"), - include_str!("../testdata/mainnet_blocks/8370402.json"), - include_str!("../testdata/mainnet_blocks/8370403.json"), + include_str!("../../../testdata/mainnet_blocks/8370400.json"), + include_str!("../../../testdata/mainnet_blocks/8370401.json"), + include_str!("../../../testdata/mainnet_blocks/8370402.json"), + include_str!("../../../testdata/mainnet_blocks/8370403.json"), ]; #[test] @@ -137,14 +139,13 @@ mod tests { let fork_config = HardforkConfig::default_from_chain_id(traces[0].chain_id); let (chunk_info, mut zktrie_state) = ChunkInfo::from_block_traces(&traces); - let tx_bytes_hasher = Rc::new(RefCell::new(Keccak::v256())); + let tx_bytes_hasher = RefCell::new(Keccak::v256()); let mut executor = EvmExecutorBuilder::new(&zktrie_state) .hardfork_config(fork_config) .with_execute_hooks(|hooks| { - let hasher = tx_bytes_hasher.clone(); - hooks.add_tx_rlp_handler(move |_, rlp| { - hasher.borrow_mut().update(rlp); + hooks.add_tx_rlp_handler(|_, rlp| { + tx_bytes_hasher.borrow_mut().update(rlp); }); }) .zktrie_state(&zktrie_state) @@ -162,8 +163,7 @@ mod tests { drop(executor); // drop executor to release Rc let mut tx_bytes_hash = H256::zero(); - let hasher = Rc::into_inner(tx_bytes_hasher).unwrap(); - hasher.into_inner().finalize(&mut tx_bytes_hash.0); + tx_bytes_hasher.into_inner().finalize(&mut tx_bytes_hash.0); let _public_input_hash = chunk_info.public_input_hash(&tx_bytes_hash); } } diff --git a/src/database.rs b/crates/core/src/database.rs similarity index 96% rename from src/database.rs rename to crates/core/src/database.rs index ecdcce9..d692a7d 100644 --- a/src/database.rs +++ b/crates/core/src/database.rs @@ -1,5 +1,4 @@ use crate::error::ZkTrieError; -use crate::utils::ext::BlockTraceExt; use mpt_zktrie::state::StorageData; use mpt_zktrie::{AccountData, ZktrieState}; use once_cell::sync::Lazy; @@ -8,6 +7,7 @@ use revm::{ db::DatabaseRef, primitives::{AccountInfo, Address, Bytecode, B256, U256}, }; +use sbv_primitives::BlockTrace; use std::rc::Rc; use std::{cell::RefCell, collections::HashMap, convert::Infallible, fmt}; use zktrie::{SharedMemoryDb, ZkMemoryDb, ZkTrie}; @@ -45,13 +45,13 @@ impl fmt::Debug for ReadOnlyDB { impl ReadOnlyDB { /// Initialize an EVM database from a block trace. - pub fn new(l2_trace: T, zktrie_state: &ZktrieState) -> Result { + pub fn new(l2_trace: T, zktrie_state: &ZktrieState) -> Result { let size_hint = l2_trace.codes().len(); Self::new_with_size_hint(l2_trace, zktrie_state, size_hint) } /// Initialize an EVM database from a block trace with size hint of code database. - pub fn new_with_size_hint( + pub fn new_with_size_hint( l2_trace: T, zktrie_state: &ZktrieState, size_hint: usize, @@ -107,11 +107,11 @@ impl ReadOnlyDB { } /// Update the database with a new block trace. - pub fn update(&mut self, l2_trace: T) -> Result<()> { + pub fn update(&mut self, l2_trace: T) -> Result<()> { measure_duration_histogram!(update_db_duration_microseconds, self.update_inner(l2_trace)) } - fn update_inner(&mut self, l2_trace: T) -> Result<()> { + fn update_inner(&mut self, l2_trace: T) -> Result<()> { cycle_tracker_start!("insert CodeDB"); for code in l2_trace.codes() { let hash = revm::primitives::keccak256(code); diff --git a/src/error.rs b/crates/core/src/error.rs similarity index 100% rename from src/error.rs rename to crates/core/src/error.rs diff --git a/src/executor/builder.rs b/crates/core/src/executor/builder.rs similarity index 67% rename from src/executor/builder.rs rename to crates/core/src/executor/builder.rs index 83489a7..f4c63d3 100644 --- a/src/executor/builder.rs +++ b/crates/core/src/executor/builder.rs @@ -1,21 +1,20 @@ use crate::error::ZkTrieError; -use crate::{ - executor::hooks::ExecuteHooks, BlockTraceExt, EvmExecutor, HardforkConfig, ReadOnlyDB, -}; +use crate::{executor::hooks::ExecuteHooks, EvmExecutor, HardforkConfig, ReadOnlyDB}; use mpt_zktrie::ZktrieState; use revm::db::CacheDB; +use sbv_primitives::BlockTrace; /// Builder for EVM executor. #[derive(Debug)] -pub struct EvmExecutorBuilder<'a, H> { +pub struct EvmExecutorBuilder<'e, 'z, H> { hardfork_config: H, - execute_hooks: ExecuteHooks, - zktrie_state: &'a ZktrieState, + execute_hooks: ExecuteHooks<'e>, + zktrie_state: &'z ZktrieState, } -impl<'a> EvmExecutorBuilder<'a, ()> { +impl<'e, 'z> EvmExecutorBuilder<'e, 'z, ()> { /// Create a new builder. - pub fn new(zktrie_state: &'a ZktrieState) -> Self { + pub fn new(zktrie_state: &'z ZktrieState) -> Self { Self { hardfork_config: (), execute_hooks: ExecuteHooks::default(), @@ -24,9 +23,9 @@ impl<'a> EvmExecutorBuilder<'a, ()> { } } -impl<'a, H> EvmExecutorBuilder<'a, H> { +impl<'e, 'z, H> EvmExecutorBuilder<'e, 'z, H> { /// Set hardfork config. - pub fn hardfork_config

(self, hardfork_config: H1) -> EvmExecutorBuilder<'a, H1> { + pub fn hardfork_config

(self, hardfork_config: H1) -> EvmExecutorBuilder<'e, 'z, H1> { EvmExecutorBuilder { hardfork_config, execute_hooks: self.execute_hooks, @@ -35,13 +34,13 @@ impl<'a, H> EvmExecutorBuilder<'a, H> { } /// Modify execute hooks. - pub fn with_execute_hooks(mut self, modify: impl FnOnce(&mut ExecuteHooks)) -> Self { + pub fn with_execute_hooks(mut self, modify: impl FnOnce(&mut ExecuteHooks<'e>)) -> Self { modify(&mut self.execute_hooks); self } /// Set zktrie state. - pub fn zktrie_state(self, zktrie_state: &ZktrieState) -> EvmExecutorBuilder { + pub fn zktrie_state(self, zktrie_state: &'z ZktrieState) -> EvmExecutorBuilder<'e, 'z, H> { EvmExecutorBuilder { zktrie_state, ..self @@ -49,9 +48,9 @@ impl<'a, H> EvmExecutorBuilder<'a, H> { } } -impl<'a> EvmExecutorBuilder<'a, HardforkConfig> { +impl<'e, 'z> EvmExecutorBuilder<'e, 'z, HardforkConfig> { /// Initialize an EVM executor from a block trace as the initial state. - pub fn build(self, l2_trace: &'a T) -> Result { + pub fn build(self, l2_trace: &'z T) -> Result, ZkTrieError> { let block_number = l2_trace.number(); let spec_id = self.hardfork_config.get_spec_id(block_number); diff --git a/src/executor/hooks.rs b/crates/core/src/executor/hooks.rs similarity index 72% rename from src/executor/hooks.rs rename to crates/core/src/executor/hooks.rs index 5954a92..8e45cb8 100644 --- a/src/executor/hooks.rs +++ b/crates/core/src/executor/hooks.rs @@ -2,18 +2,18 @@ use crate::EvmExecutor; use std::fmt::{Debug, Formatter}; /// Transaction RLP handler. -pub type TxRLPHandler = dyn Fn(&EvmExecutor, &[u8]) + 'static; +pub type TxRLPHandler<'a> = dyn Fn(&EvmExecutor, &[u8]) + 'a; /// Post transaction execution handler. -pub type PostTxExecutionHandler = dyn Fn(&EvmExecutor, usize) + 'static; +pub type PostTxExecutionHandler<'a> = dyn Fn(&EvmExecutor, usize) + 'a; /// Hooks for the EVM executor. #[derive(Default)] -pub struct ExecuteHooks { - tx_rlp_handlers: Vec>, - post_tx_execution_handlers: Vec>, +pub struct ExecuteHooks<'a> { + tx_rlp_handlers: Vec>>, + post_tx_execution_handlers: Vec>>, } -impl ExecuteHooks { +impl<'a> ExecuteHooks<'a> { /// Create a new hooks. pub fn new() -> Self { Self::default() @@ -22,7 +22,7 @@ impl ExecuteHooks { /// Add a transaction RLP handler. pub fn add_tx_rlp_handler(&mut self, handler: F) where - F: Fn(&EvmExecutor, &[u8]) + 'static, + F: Fn(&EvmExecutor, &[u8]) + 'a, { self.tx_rlp_handlers.push(Box::new(handler)); } @@ -30,7 +30,7 @@ impl ExecuteHooks { /// Add a post transaction execution handler. pub fn add_post_tx_execution_handler(&mut self, handler: F) where - F: Fn(&EvmExecutor, usize) + 'static, + F: Fn(&EvmExecutor, usize) + 'a, { self.post_tx_execution_handlers.push(Box::new(handler)); } @@ -49,9 +49,10 @@ impl ExecuteHooks { } } -impl Debug for ExecuteHooks { +impl Debug for ExecuteHooks<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.debug_struct("ExecuteHooks") + .field("tx_rlp_handlers", &self.tx_rlp_handlers.len()) .field( "post_tx_execution_handlers", &self.post_tx_execution_handlers.len(), diff --git a/src/executor/mod.rs b/crates/core/src/executor/mod.rs similarity index 92% rename from src/executor/mod.rs rename to crates/core/src/executor/mod.rs index 45314bc..442aa84 100644 --- a/src/executor/mod.rs +++ b/crates/core/src/executor/mod.rs @@ -1,10 +1,4 @@ -use crate::{ - database::ReadOnlyDB, - error::VerificationError, - error::ZkTrieError, - utils::ext::{BlockTraceRevmExt, TxRevmExt}, - HardforkConfig, -}; +use crate::{database::ReadOnlyDB, error::VerificationError, error::ZkTrieError, HardforkConfig}; use eth_types::{geth_types::TxType, H256, U256}; use mpt_zktrie::{AccountData, ZktrieState}; use revm::db::AccountState; @@ -14,31 +8,31 @@ use revm::{ db::CacheDB, primitives::{AccountInfo, Env, SpecId}, }; +use sbv_primitives::{BlockTrace, Transaction}; use std::fmt::Debug; mod builder; -use crate::utils::ext::BlockTraceExt; pub use builder::EvmExecutorBuilder; /// Execute hooks pub mod hooks; /// EVM executor that handles the block. -pub struct EvmExecutor { +pub struct EvmExecutor<'a> { hardfork_config: HardforkConfig, db: CacheDB, spec_id: SpecId, - hooks: hooks::ExecuteHooks, + hooks: hooks::ExecuteHooks<'a>, } -impl EvmExecutor { +impl EvmExecutor<'_> { /// Get reference to the DB pub fn db(&self) -> &CacheDB { &self.db } /// Update the DB - pub fn update_db(&mut self, l2_trace: &T) -> Result<(), ZkTrieError> { + pub fn update_db(&mut self, l2_trace: &T) -> Result<(), ZkTrieError> { self.db.db.invalidate_storage_root_caches( self.db .accounts @@ -50,26 +44,20 @@ impl EvmExecutor { } /// Handle a block. - pub fn handle_block( - &mut self, - l2_trace: &T, - ) -> Result<(), VerificationError> { + pub fn handle_block(&mut self, l2_trace: &T) -> Result<(), VerificationError> { measure_duration_histogram!( handle_block_duration_microseconds, self.handle_block_inner(l2_trace) )?; #[cfg(feature = "metrics")] - crate::metrics::REGISTRY.block_counter.inc(); + sbv_utils::metrics::REGISTRY.block_counter.inc(); Ok(()) } #[inline(always)] - fn handle_block_inner( - &mut self, - l2_trace: &T, - ) -> Result<(), VerificationError> { + fn handle_block_inner(&mut self, l2_trace: &T) -> Result<(), VerificationError> { self.hardfork_config .migrate(l2_trace.number(), &mut self.db) .unwrap(); @@ -176,7 +164,7 @@ impl EvmExecutor { .expect("infallible"); #[cfg(any(feature = "debug-account", feature = "debug-storage"))] - let mut debug_recorder = crate::utils::debug::DebugRecorder::new(); + let mut debug_recorder = sbv_utils::DebugRecorder::new(); for (addr, db_acc) in self.db.accounts.iter() { // If EVM didn't touch the account, we don't need to update it @@ -276,7 +264,7 @@ impl EvmExecutor { } } -impl Debug for EvmExecutor { +impl Debug for EvmExecutor<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("EvmExecutor") .field("db", &self.db) diff --git a/src/hardfork.rs b/crates/core/src/hardfork.rs similarity index 100% rename from src/hardfork.rs rename to crates/core/src/hardfork.rs diff --git a/src/lib.rs b/crates/core/src/lib.rs similarity index 65% rename from src/lib.rs rename to crates/core/src/lib.rs index 32aafbf..c706b6c 100644 --- a/src/lib.rs +++ b/crates/core/src/lib.rs @@ -1,17 +1,12 @@ -//! Stateless Block Verifier +//! Stateless Block Verifier core library. #![deny(missing_docs)] #![deny(missing_debug_implementations)] -#[cfg(feature = "dev")] -#[doc(hidden)] -pub use tracing; - #[macro_use] -mod macros; +extern crate sbv_utils; mod chunk; - pub use chunk::ChunkInfo; mod database; @@ -26,16 +21,7 @@ pub use executor::{hooks, EvmExecutor, EvmExecutorBuilder}; mod hardfork; pub use hardfork::HardforkConfig; -/// Module for utilities. -pub mod utils; -pub use utils::{post_check, BlockTraceExt}; - -/// Metrics module -#[cfg(feature = "metrics")] -#[doc(hidden)] -pub mod metrics; - -#[cfg(all(feature = "dev", test))] +#[cfg(test)] #[ctor::ctor] fn init() { use tracing_subscriber::EnvFilter; diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml new file mode 100644 index 0000000..02fe2b9 --- /dev/null +++ b/crates/primitives/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "sbv-primitives" +version = "0.1.0" +edition = "2021" + +[dependencies] +revm-primitives.workspace = true +rkyv.workspace = true +tiny-keccak.workspace = true + +eth-types.workspace = true +mpt-zktrie.workspace = true + +sbv-utils.workspace = true diff --git a/src/utils/ext/imp/archived_block_trace_v2.rs b/crates/primitives/src/imp/archived_block_trace_v2.rs similarity index 91% rename from src/utils/ext/imp/archived_block_trace_v2.rs rename to crates/primitives/src/imp/archived_block_trace_v2.rs index 7dbfbaf..6125ecd 100644 --- a/src/utils/ext/imp/archived_block_trace_v2.rs +++ b/crates/primitives/src/imp/archived_block_trace_v2.rs @@ -1,7 +1,7 @@ -use crate::utils::ext::*; +use crate::*; use eth_types::l2_types::{ArchivedBlockTraceV2, ArchivedTransactionTrace, TransactionTrace}; -use eth_types::{Address, Transaction, H256}; -use revm::primitives::{AccessListItem, TransactTo, B256, U256}; +use eth_types::{Address, H256}; +use revm_primitives::{AccessListItem, TransactTo, B256, U256}; use rkyv::Deserialize; impl BlockTraceExt for ArchivedBlockTraceV2 { @@ -96,7 +96,7 @@ impl BlockTraceRevmExt for ArchivedBlockTraceV2 { self.chain_id } #[inline] - fn coinbase(&self) -> revm::primitives::Address { + fn coinbase(&self) -> revm_primitives::Address { self.coinbase.address.0.into() } #[inline] @@ -120,10 +120,7 @@ impl BlockTraceRevmExt for ArchivedBlockTraceV2 { } #[inline] fn prevrandao(&self) -> Option { - self.header - .mix_hash - .as_ref() - .map(|h| revm::primitives::B256::from(h.0)) + self.header.mix_hash.as_ref().map(|h| B256::from(h.0)) } #[inline] fn transactions(&self) -> impl Iterator { @@ -133,7 +130,7 @@ impl BlockTraceRevmExt for ArchivedBlockTraceV2 { impl BlockZktrieExt for ArchivedBlockTraceV2 {} -impl TxRevmExt for ArchivedTransactionTrace { +impl Transaction for ArchivedTransactionTrace { #[inline] fn raw_type(&self) -> u8 { self.type_ @@ -143,7 +140,7 @@ impl TxRevmExt for ArchivedTransactionTrace { B256::new(self.tx_hash.0) } #[inline] - fn caller(&self) -> revm::precompile::Address { + fn caller(&self) -> revm_primitives::Address { self.from.0.into() } #[inline] @@ -166,8 +163,8 @@ impl TxRevmExt for ArchivedTransactionTrace { U256::from_limbs(self.value.0) } #[inline] - fn data(&self) -> revm::precompile::Bytes { - revm::precompile::Bytes::copy_from_slice(self.data.as_ref()) + fn data(&self) -> revm_primitives::Bytes { + revm_primitives::Bytes::copy_from_slice(self.data.as_ref()) } #[inline] fn nonce(&self) -> u64 { @@ -202,7 +199,7 @@ impl TxRevmExt for ArchivedTransactionTrace { block_number: u64, transaction_index: usize, base_fee_per_gas: Option, - ) -> Transaction { + ) -> eth_types::Transaction { // FIXME: zero copy here pls let tx_trace: TransactionTrace = Deserialize::::deserialize(self, &mut rkyv::Infallible).unwrap(); diff --git a/src/utils/ext/imp/blanket.rs b/crates/primitives/src/imp/blanket.rs similarity index 91% rename from src/utils/ext/imp/blanket.rs rename to crates/primitives/src/imp/blanket.rs index ee4dc05..7f47211 100644 --- a/src/utils/ext/imp/blanket.rs +++ b/crates/primitives/src/imp/blanket.rs @@ -1,6 +1,6 @@ -use crate::utils::ext::*; -use eth_types::{Address, Transaction, H256}; -use revm::primitives::{AccessListItem, TransactTo, B256, U256}; +use crate::*; +use eth_types::{Address, H256}; +use revm_primitives::{AccessListItem, TransactTo, B256, U256}; impl BlockTraceExt for &T { #[inline(always)] @@ -70,7 +70,7 @@ impl BlockTraceRevmExt for &T { } #[inline(always)] - fn coinbase(&self) -> revm::precompile::Address { + fn coinbase(&self) -> revm_primitives::Address { (*self).coinbase() } @@ -107,7 +107,7 @@ impl BlockTraceRevmExt for &T { impl BlockZktrieExt for &T {} -impl TxRevmExt for &T { +impl Transaction for &T { #[inline(always)] fn raw_type(&self) -> u8 { (*self).raw_type() @@ -118,7 +118,7 @@ impl TxRevmExt for &T { } #[inline(always)] - fn caller(&self) -> revm::precompile::Address { + fn caller(&self) -> revm_primitives::Address { (*self).caller() } @@ -143,7 +143,7 @@ impl TxRevmExt for &T { } #[inline(always)] - fn data(&self) -> revm::precompile::Bytes { + fn data(&self) -> revm_primitives::Bytes { (*self).data() } @@ -174,7 +174,7 @@ impl TxRevmExt for &T { block_number: u64, transaction_index: usize, base_fee_per_gas: Option, - ) -> Transaction { + ) -> eth_types::Transaction { (*self).to_eth_tx( block_hash, block_number, diff --git a/src/utils/ext/imp/block_trace.rs b/crates/primitives/src/imp/block_trace.rs similarity index 94% rename from src/utils/ext/imp/block_trace.rs rename to crates/primitives/src/imp/block_trace.rs index cb59299..c00b6e1 100644 --- a/src/utils/ext/imp/block_trace.rs +++ b/crates/primitives/src/imp/block_trace.rs @@ -1,7 +1,7 @@ -use crate::utils::ext::*; +use crate::*; use eth_types::l2_types::{BlockTrace, TransactionTrace}; use eth_types::{Address, H256}; -use revm::primitives::{B256, U256}; +use revm_primitives::{B256, U256}; impl BlockTraceExt for BlockTrace { #[inline(always)] @@ -95,7 +95,7 @@ impl BlockTraceRevmExt for BlockTrace { self.chain_id } #[inline] - fn coinbase(&self) -> revm::primitives::Address { + fn coinbase(&self) -> revm_primitives::Address { self.coinbase.address.0.into() } #[inline] @@ -116,9 +116,7 @@ impl BlockTraceRevmExt for BlockTrace { } #[inline] fn prevrandao(&self) -> Option { - self.header - .mix_hash - .map(|h| revm::primitives::B256::from(h.0)) + self.header.mix_hash.map(|h| B256::from(h.0)) } #[inline] fn transactions(&self) -> impl Iterator { diff --git a/src/utils/ext/imp/block_trace_v2.rs b/crates/primitives/src/imp/block_trace_v2.rs similarity index 95% rename from src/utils/ext/imp/block_trace_v2.rs rename to crates/primitives/src/imp/block_trace_v2.rs index af5928b..c12cfcf 100644 --- a/src/utils/ext/imp/block_trace_v2.rs +++ b/crates/primitives/src/imp/block_trace_v2.rs @@ -1,7 +1,7 @@ -use crate::utils::ext::*; +use crate::*; use eth_types::l2_types::{BlockTraceV2, TransactionTrace}; use eth_types::{Address, H256}; -use revm::primitives::{B256, U256}; +use revm_primitives::{B256, U256}; impl BlockTraceExt for BlockTraceV2 { #[inline(always)] @@ -94,7 +94,7 @@ impl BlockTraceRevmExt for BlockTraceV2 { self.chain_id } #[inline] - fn coinbase(&self) -> revm::primitives::Address { + fn coinbase(&self) -> revm_primitives::Address { self.coinbase.address.0.into() } #[inline] @@ -117,7 +117,7 @@ impl BlockTraceRevmExt for BlockTraceV2 { fn prevrandao(&self) -> Option { self.header .mix_hash - .map(|h| revm::primitives::B256::from(h.0)) + .map(|h| revm_primitives::B256::from(h.0)) } #[inline] fn transactions(&self) -> impl Iterator { diff --git a/src/utils/ext/imp/mod.rs b/crates/primitives/src/imp/mod.rs similarity index 85% rename from src/utils/ext/imp/mod.rs rename to crates/primitives/src/imp/mod.rs index 87dd4d5..4b21688 100644 --- a/src/utils/ext/imp/mod.rs +++ b/crates/primitives/src/imp/mod.rs @@ -1,14 +1,14 @@ -use crate::utils::ext::TxRevmExt; +use crate::Transaction; use eth_types::l2_types::TransactionTrace; -use eth_types::{Transaction, H256}; -use revm::primitives::{AccessListItem, TransactTo, B256, U256}; +use eth_types::H256; +use revm_primitives::{AccessListItem, TransactTo, B256, U256}; mod archived_block_trace_v2; mod blanket; mod block_trace; mod block_trace_v2; -impl TxRevmExt for TransactionTrace { +impl Transaction for TransactionTrace { #[inline] fn raw_type(&self) -> u8 { self.type_ @@ -18,7 +18,7 @@ impl TxRevmExt for TransactionTrace { B256::new(self.tx_hash.0) } #[inline] - fn caller(&self) -> revm::precompile::Address { + fn caller(&self) -> revm_primitives::Address { self.from.0.into() } #[inline] @@ -41,8 +41,8 @@ impl TxRevmExt for TransactionTrace { U256::from_limbs(self.value.0) } #[inline] - fn data(&self) -> revm::precompile::Bytes { - revm::precompile::Bytes::copy_from_slice(self.data.as_ref()) + fn data(&self) -> revm_primitives::Bytes { + revm_primitives::Bytes::copy_from_slice(self.data.as_ref()) } #[inline] fn nonce(&self) -> u64 { @@ -81,7 +81,7 @@ impl TxRevmExt for TransactionTrace { block_number: u64, transaction_index: usize, base_fee_per_gas: Option, - ) -> Transaction { + ) -> eth_types::Transaction { self.to_eth_tx( Some(H256::from(block_hash.0)), Some(block_number.into()), diff --git a/src/utils/ext/mod.rs b/crates/primitives/src/lib.rs similarity index 80% rename from src/utils/ext/mod.rs rename to crates/primitives/src/lib.rs index 7a6766e..16136a3 100644 --- a/src/utils/ext/mod.rs +++ b/crates/primitives/src/lib.rs @@ -1,10 +1,32 @@ -use eth_types::{Address, Transaction, H256}; +//! Stateless Block Verifier primitives library. + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] + +#[macro_use] +extern crate sbv_utils; + +use eth_types::{Address, H256}; use mpt_zktrie::ZktrieState; -use revm::primitives::{AccessListItem, TransactTo, TxEnv, B256, U256}; +use revm_primitives::{AccessListItem, TransactTo, TxEnv, B256, U256}; use std::fmt::Debug; mod imp; +/// Blanket trait for block trace extensions. +pub trait BlockTrace: + BlockTraceExt + BlockTraceRevmExt + BlockZktrieExt + BlockChunkExt + Debug +{ +} + +impl BlockTrace for eth_types::l2_types::BlockTrace {} + +impl BlockTrace for eth_types::l2_types::BlockTraceV2 {} + +impl BlockTrace for eth_types::l2_types::ArchivedBlockTraceV2 {} + +impl BlockTrace for &T {} + /// Common extension trait for BlockTrace pub trait BlockTraceExt { /// root before @@ -31,12 +53,16 @@ pub trait BlockTraceExt { fn codes(&self) -> impl ExactSizeIterator; /// start l1 queue index fn start_l1_queue_index(&self) -> u64; + /// execution_results + fn execution_results(&self, _tx_id: usize) -> Option<ð_types::l2_types::ExecutionResult> { + None + } } /// Revm extension trait for BlockTrace pub trait BlockTraceRevmExt { /// transaction type - type Tx: TxRevmExt + Debug; + type Tx: Transaction + Debug; /// block number fn number(&self) -> u64; @@ -45,7 +71,7 @@ pub trait BlockTraceRevmExt { /// chain id fn chain_id(&self) -> u64; /// coinbase address - fn coinbase(&self) -> revm::primitives::Address; + fn coinbase(&self) -> revm_primitives::Address; /// timestamp fn timestamp(&self) -> U256; /// gas limit @@ -62,8 +88,8 @@ pub trait BlockTraceRevmExt { /// creates `revm::primitives::BlockEnv` #[inline] - fn env(&self) -> revm::primitives::BlockEnv { - revm::primitives::BlockEnv { + fn env(&self) -> revm_primitives::BlockEnv { + revm_primitives::BlockEnv { number: U256::from_limbs([self.number(), 0, 0, 0]), coinbase: self.coinbase(), timestamp: self.timestamp(), @@ -80,24 +106,21 @@ pub trait BlockTraceRevmExt { pub trait BlockZktrieExt: BlockTraceExt { /// Update zktrie state from trace fn build_zktrie_state(&self, zktrie_state: &mut ZktrieState) { - measure_duration_histogram!( - build_zktrie_state_duration_microseconds, - if let Some(flatten_proofs) = self.flatten_proofs() { - dev_debug!("init zktrie state with flatten proofs"); - let zk_db = zktrie_state.expose_db(); - - for (k, bytes) in flatten_proofs { - zk_db.add_node_bytes(bytes, Some(k.as_bytes())).unwrap(); - } - } else { - dev_warn!("no flatten proofs, fallback to update zktrie state from trace"); - zktrie_state.update_from_trace( - self.account_proofs(), - self.storage_proofs(), - self.additional_proofs(), - ); + if let Some(flatten_proofs) = self.flatten_proofs() { + dev_debug!("init zktrie state with flatten proofs"); + let zk_db = zktrie_state.expose_db(); + + for (k, bytes) in flatten_proofs { + zk_db.add_node_bytes(bytes, Some(k.as_bytes())).unwrap(); } - ); + } else { + dev_warn!("no flatten proofs, fallback to update zktrie state from trace"); + zktrie_state.update_from_trace( + self.account_proofs(), + self.storage_proofs(), + self.additional_proofs(), + ); + } } } @@ -156,7 +179,7 @@ pub trait BlockChunkExt: BlockTraceExt + BlockTraceRevmExt { } /// Revm extension trait for Transaction -pub trait TxRevmExt { +pub trait Transaction { /// get the raw tx type fn raw_type(&self) -> u8; /// check if the tx is l1 tx @@ -166,7 +189,7 @@ pub trait TxRevmExt { /// get the tx hash fn tx_hash(&self) -> B256; /// get the caller - fn caller(&self) -> revm::primitives::Address; + fn caller(&self) -> revm_primitives::Address; /// get the gas limit fn gas_limit(&self) -> u64; /// get the gas price @@ -176,7 +199,7 @@ pub trait TxRevmExt { /// get the value fn value(&self) -> U256; /// get the data - fn data(&self) -> revm::primitives::Bytes; + fn data(&self) -> revm_primitives::Bytes; /// get the nonce fn nonce(&self) -> u64; /// get the chain id @@ -210,7 +233,7 @@ pub trait TxRevmExt { block_number: u64, transaction_index: usize, base_fee_per_gas: Option, - ) -> Transaction; + ) -> eth_types::Transaction; } #[cfg(test)] diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml new file mode 100644 index 0000000..291d838 --- /dev/null +++ b/crates/utils/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "sbv-utils" +version = "0.1.0" +edition = "2021" + +[dependencies] +revm.workspace = true + +eth-types.workspace = true +mpt-zktrie = { workspace = true, optional = true } + +csv = { workspace = true, optional = true } +hyper = { workspace = true, optional = true } +hyper-util = { workspace = true, optional = true } +http-body-util = { workspace = true, optional = true } +once_cell = { workspace = true, optional = true } +prometheus-client = { workspace = true, optional = true } +serde = { workspace = true, optional = true } +tokio = { workspace = true, optional = true } +tracing = { workspace = true, optional = true } + +[dev-dependencies] +rand.workspace = true +reqwest.workspace = true + +[features] +debug-account = ["dep:csv", "dep:mpt-zktrie", "dep:serde", "revm/serde"] +debug-storage = ["dep:csv", "dep:mpt-zktrie", "dep:serde", "revm/serde"] +dev = ["dep:tracing"] +metrics = ["dep:hyper", "dep:hyper-util", "dep:http-body-util", "dep:once_cell", "dep:prometheus-client", "dep:tokio", "tokio/macros", "tokio/signal"] \ No newline at end of file diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs new file mode 100644 index 0000000..e231437 --- /dev/null +++ b/crates/utils/src/lib.rs @@ -0,0 +1,21 @@ +//! Stateless Block Verifier utils library. + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] + +#[cfg(any(feature = "dev", test))] +#[doc(hidden)] +pub use tracing; + +#[macro_use] +mod macros; + +mod utils; +#[cfg(any(feature = "debug-account", feature = "debug-storage"))] +pub use utils::debug::DebugRecorder; +pub use utils::post_check; + +/// Metrics module +#[cfg(feature = "metrics")] +#[doc(hidden)] +pub mod metrics; diff --git a/src/macros.rs b/crates/utils/src/macros.rs similarity index 93% rename from src/macros.rs rename to crates/utils/src/macros.rs index 616605b..77ad3cf 100644 --- a/src/macros.rs +++ b/crates/utils/src/macros.rs @@ -39,7 +39,7 @@ macro_rules! cycle_tracker_end { #[macro_export] macro_rules! dev_trace { ($($arg:tt)*) => { - #[cfg(feature = "dev")] + #[cfg(any(feature = "dev", test))] { $crate::tracing::trace!($($arg)*); } @@ -50,7 +50,7 @@ macro_rules! dev_trace { #[macro_export] macro_rules! dev_info { ($($arg:tt)*) => { - #[cfg(feature = "dev")] + #[cfg(any(feature = "dev", test))] { $crate::tracing::info!($($arg)*); } @@ -61,7 +61,7 @@ macro_rules! dev_info { #[macro_export] macro_rules! dev_error { ($($arg:tt)*) => { - #[cfg(feature = "dev")] + #[cfg(any(feature = "dev", test))] { $crate::tracing::error!($($arg)*); } @@ -72,7 +72,7 @@ macro_rules! dev_error { #[macro_export] macro_rules! dev_debug { ($($arg:tt)*) => { - #[cfg(feature = "dev")] + #[cfg(any(feature = "dev", test))] { $crate::tracing::debug!($($arg)*); } @@ -83,7 +83,7 @@ macro_rules! dev_debug { #[macro_export] macro_rules! dev_warn { ($($arg:tt)*) => { - #[cfg(feature = "dev")] + #[cfg(any(feature = "dev", test))] { $crate::tracing::warn!($($arg)*); } diff --git a/src/metrics/mod.rs b/crates/utils/src/metrics/mod.rs similarity index 100% rename from src/metrics/mod.rs rename to crates/utils/src/metrics/mod.rs diff --git a/src/metrics/registry.rs b/crates/utils/src/metrics/registry.rs similarity index 100% rename from src/metrics/registry.rs rename to crates/utils/src/metrics/registry.rs diff --git a/src/utils/debug.rs b/crates/utils/src/utils/debug.rs similarity index 92% rename from src/utils/debug.rs rename to crates/utils/src/utils/debug.rs index 2148a11..aba0b52 100644 --- a/src/utils/debug.rs +++ b/crates/utils/src/utils/debug.rs @@ -3,14 +3,15 @@ use mpt_zktrie::AccountData; use revm::primitives::{Address, U256}; use std::collections::BTreeMap; -#[derive(serde::Serialize)] +#[derive(Debug, serde::Serialize)] struct StorageOps { kind: &'static str, key: U256, value: Option, } -#[derive(Default)] +/// Debug recorder for recording account and storage data. +#[derive(Debug, Default)] pub struct DebugRecorder { accounts: BTreeMap, storages_roots: BTreeMap, @@ -18,6 +19,7 @@ pub struct DebugRecorder { } impl DebugRecorder { + /// Create a new debug recorder. pub fn new() -> Self { #[cfg(any(feature = "debug-account", feature = "debug-storage"))] std::fs::create_dir_all("/tmp/sbv-debug").expect("failed to create debug dir"); @@ -25,16 +27,19 @@ impl DebugRecorder { Self::default() } + /// Record the account data. #[cfg(feature = "debug-account")] pub fn record_account(&mut self, addr: Address, data: AccountData) { self.accounts.insert(addr, data); } + /// Record the storage root of an account. #[cfg(feature = "debug-storage")] pub fn record_storage_root(&mut self, addr: Address, storage_root: H256) { self.storages_roots.insert(addr, storage_root); } + /// Record the storage operation. #[cfg(feature = "debug-storage")] pub fn record_storage(&mut self, addr: Address, key: U256, value: U256) { let entry = self.storages.entry(addr).or_default(); diff --git a/src/utils/mod.rs b/crates/utils/src/utils/mod.rs similarity index 86% rename from src/utils/mod.rs rename to crates/utils/src/utils/mod.rs index f094d47..aab64b4 100644 --- a/src/utils/mod.rs +++ b/crates/utils/src/utils/mod.rs @@ -8,22 +8,7 @@ use tracing::Level; /// Debugging utilities. #[cfg(any(feature = "debug-account", feature = "debug-storage"))] -pub(crate) mod debug; -/// Extensions for block trace. -pub mod ext; - -/// Blanket trait for block trace extensions. -pub trait BlockTraceExt: - ext::BlockTraceExt + ext::BlockTraceRevmExt + ext::BlockZktrieExt + ext::BlockChunkExt -{ -} - -impl BlockTraceExt for eth_types::l2_types::BlockTrace {} - -impl BlockTraceExt for eth_types::l2_types::BlockTraceV2 {} - -impl BlockTraceExt for eth_types::l2_types::ArchivedBlockTraceV2 {} -impl BlockTraceExt for &T {} +pub mod debug; /// Check the post state of the block with the execution result. pub fn post_check(db: DB, exec: &ExecutionResult) -> bool