From ccb914199ccac11b05bbd191a1771ec15199efc8 Mon Sep 17 00:00:00 2001 From: Brechtpd Date: Tue, 14 May 2024 07:40:24 +0200 Subject: [PATCH 1/5] test raiko integration --- Cargo.lock | 842 +++++++++++++++-- Cargo.toml | 45 +- crates/primitives/src/revm/env.rs | 1 + crates/rpc/rpc-types-compat/src/block.rs | 3 +- crates/rpc/rpc/src/eth/error.rs | 3 + crates/rpc/rpc/src/eth/revm_utils.rs | 1 + crates/trie/src/proof.rs | 10 +- testing/ef-tests/Cargo.toml | 12 + testing/ef-tests/src/case.rs | 41 +- testing/ef-tests/src/cases/blockchain_test.rs | 884 +++++++++++++++--- testing/ef-tests/src/models.rs | 6 +- testing/ef-tests/src/result.rs | 20 +- testing/ef-tests/src/suite.rs | 47 +- testing/ef-tests/tests/tests.rs | 11 +- 14 files changed, 1743 insertions(+), 183 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d20f04fa81d4..beedc502c6c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + [[package]] name = "aead" version = "0.4.3" @@ -133,7 +139,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-eips", "alloy-primitives", @@ -147,9 +153,9 @@ dependencies = [ [[package]] name = "alloy-dyn-abi" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ab339ca7b4ea9115f0578c941abc80a171edf8e5eadd01e6c4237b68db8083" +checksum = "545885d9b0b2c30fd344ae291439b4bfe59e48dd62fbc862f8503d98088967dc" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -166,7 +172,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -185,7 +191,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-primitives", "alloy-serde", @@ -195,9 +201,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44294729c145cf7ae65feab544b5b81fb2bb7e2fd060214842eb3989a1e9d882" +checksum = "786689872ec4e7d354810ab0dffd48bb40b838c047522eb031cbd47d15634849" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -208,7 +214,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-primitives", "serde", @@ -220,7 +226,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -237,7 +243,7 @@ dependencies = [ [[package]] name = "alloy-node-bindings" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -251,9 +257,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c715249705afa1e32be79dabfd35e2ef0f1cc02ad2cf48c9d1e20026ee637b" +checksum = "525448f6afc1b70dd0f9d0a8145631bf2f5e434678ab23ab18409ca264cae6b3" dependencies = [ "alloy-rlp", "arbitrary", @@ -279,7 +285,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -329,7 +335,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -349,7 +355,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -371,7 +377,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-primitives", "alloy-serde", @@ -381,7 +387,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-consensus", "alloy-eips", @@ -401,7 +407,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -413,7 +419,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-primitives", "serde", @@ -423,7 +429,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-primitives", "async-trait", @@ -436,7 +442,7 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-consensus", "alloy-network", @@ -452,9 +458,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef9a94a27345fb31e3fcb5f5e9f592bb4847493b07fa1e47dd9fde2222f2e28" +checksum = "89c80a2cb97e7aa48611cbb63950336f9824a174cdf670527cc6465078a26ea1" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -471,9 +477,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31fe73cd259527e24dc2dbfe64bc95e5ddfcd2b2731f670a11ff72b2be2c25b" +checksum = "c58894b58ac50979eeac6249661991ac40b9d541830d9a725f7714cc9ef08c23" dependencies = [ "alloy-json-abi", "const-hex", @@ -488,18 +494,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c8d6e74e4feeaa2bcfdecfd3da247ab53c67bd654ba1907270c32e02b142331" +checksum = "7da8e71ea68e780cc203919e03f69f59e7afe92d2696fb1dcb6662f61e4031b6" dependencies = [ "winnow 0.6.7", ] [[package]] name = "alloy-sol-types" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afaffed78bfb17526375754931e045f96018aa810844b29c7aef823266dd4b4b" +checksum = "399287f68d1081ed8b1f4903c49687658b95b142207d7cb4ae2f4813915343ef" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -511,7 +517,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-json-rpc", "base64 0.22.0", @@ -529,7 +535,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=4e22b9e#4e22b9e1de80f1b1cc5dfdcd9461d44b27cf27ca" +source = "git+https://github.com/brechtpd/alloy?branch=175_4e22b9e#08b6868cad113dbebf4a9818ae316aed0bad1d2c" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -953,6 +959,74 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core", + "axum-macros", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper 1.0.1", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00c055ee2d014ae5981ce1016374e8213682aa14d9bf40e48ab48b5f3ef20eaa" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "backon" version = "0.4.4" @@ -1424,6 +1498,18 @@ dependencies = [ "serde", ] +[[package]] +name = "c-kzg-taiko" +version = "1.0.0" +source = "git+https://github.com/smtmfft/c-kzg-4844?branch=for-alpha7#77e9ba0a65e10e6a470832da2914b17a968da791" +dependencies = [ + "blst", + "cc", + "glob", + "hex", + "libc", +] + [[package]] name = "camino" version = "1.1.6" @@ -1433,6 +1519,11 @@ dependencies = [ "serde", ] +[[package]] +name = "cap" +version = "0.1.2" +source = "git+https://github.com/brechtpd/cap?branch=more-stats#a75714150823408c0672c120eb68fde4340ca2f5" + [[package]] name = "cargo-platform" version = "0.1.8" @@ -1885,6 +1976,12 @@ dependencies = [ "itertools 0.10.5", ] +[[package]] +name = "critical-section" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" + [[package]] name = "crossbeam-channel" version = "0.5.12" @@ -2241,6 +2338,12 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "dary_heap" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7762d17f1241643615821a8455a0b2c3e803784b058693d990b11f2dce25a0ca" + [[package]] name = "dashmap" version = "5.5.3" @@ -2602,14 +2705,24 @@ name = "ef-tests" version = "0.2.0-beta.6" dependencies = [ "alloy-rlp", + "anyhow", + "raiko-host", + "raiko-lib", + "raiko-primitives", "rayon", "reth-db", "reth-interfaces", + "reth-network-api", "reth-node-ethereum", "reth-primitives", "reth-provider", "reth-revm", + "reth-rpc", + "reth-rpc-types", + "reth-rpc-types-compat", "reth-stages", + "reth-tasks", + "reth-transaction-pool", "serde", "serde_json", "thiserror", @@ -2731,6 +2844,29 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -3002,6 +3138,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -3304,6 +3455,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "h2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.1.0", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "2.4.1" @@ -3528,6 +3698,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +[[package]] +name = "http-range-header" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ce4ef31cda248bbdb6e6820603b82dfcd9e833db65a43e997a0ccec777d11fe" + [[package]] name = "http-types" version = "2.12.0" @@ -3592,7 +3768,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -3615,9 +3791,11 @@ dependencies = [ "bytes", "futures-channel", "futures-util", + "h2 0.4.4", "http 1.1.0", "http-body 1.0.0", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -3672,6 +3850,35 @@ dependencies = [ "tracing", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper 0.14.28", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.3.1", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.3" @@ -4094,6 +4301,17 @@ dependencies = [ "memoffset", ] +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "ipconfig" version = "0.3.2" @@ -4439,6 +4657,30 @@ dependencies = [ "cc", ] +[[package]] +name = "libflate" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7d5654ae1795afc7ff76f4365c2c8791b0feb18e8996a96adad8ffd7c3b2bf" +dependencies = [ + "adler32", + "core2", + "crc32fast", + "dary_heap", + "libflate_lz77", +] + +[[package]] +name = "libflate_lz77" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be5f52fb8c451576ec6b79d3f4deb327398bc05bbdbd99021a6e77a4c855d524" +dependencies = [ + "core2", + "hashbrown 0.13.2", + "rle-decode-fast", +] + [[package]] name = "libloading" version = "0.8.3" @@ -4666,6 +4908,12 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -4712,6 +4960,12 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "lru_time_cache" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9106e1d747ffd48e6be5bb2d97fa706ed25b144fbee4d5c02eae110cd8d6badd" + [[package]] name = "lz4_flex" version = "0.11.3" @@ -4765,6 +5019,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "memchr" version = "2.7.2" @@ -4848,7 +5108,7 @@ dependencies = [ "mach2", "metrics", "once_cell", - "procfs", + "procfs 0.16.0", "rlimit", "windows", ] @@ -5043,6 +5303,24 @@ dependencies = [ "unsigned-varint 0.7.2", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "network" version = "0.0.0" @@ -5287,6 +5565,10 @@ name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +dependencies = [ + "critical-section", + "portable-atomic", +] [[package]] name = "oorandom" @@ -5300,12 +5582,50 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -5800,6 +6120,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "procfs" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de8dacb0873f77e6aefc6d71e044761fcc68060290f5b1089fcdf84626bb69" +dependencies = [ + "bitflags 1.3.2", + "byteorder", + "hex", + "lazy_static", + "rustix 0.36.17", +] + [[package]] name = "procfs" version = "0.16.0" @@ -5812,7 +6145,7 @@ dependencies = [ "hex", "lazy_static", "procfs-core", - "rustix", + "rustix 0.38.34", ] [[package]] @@ -5826,6 +6159,23 @@ dependencies = [ "hex", ] +[[package]] +name = "prometheus" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" +dependencies = [ + "cfg-if", + "fnv", + "lazy_static", + "libc", + "memchr", + "parking_lot 0.12.2", + "procfs 0.14.2", + "protobuf", + "thiserror", +] + [[package]] name = "proptest" version = "1.4.0" @@ -5857,6 +6207,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "protobuf" +version = "2.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" + [[package]] name = "public-ip" version = "0.2.2" @@ -5943,6 +6299,117 @@ dependencies = [ "nibble_vec", ] +[[package]] +name = "raiko-host" +version = "0.1.0" +source = "git+https://github.com/taikoxyz/raiko.git?branch=reth-support#5e0eee5c97440e0e548c66df78212768ff7c328b" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-provider", + "alloy-rlp", + "alloy-rlp-derive", + "alloy-rpc-client", + "alloy-rpc-types", + "alloy-sol-types", + "alloy-transport-http", + "anyhow", + "axum", + "bincode", + "bytemuck", + "c-kzg", + "cap", + "cfg-if", + "clap", + "env_logger", + "flate2", + "hyper 0.14.28", + "lazy_static", + "lru_time_cache", + "once_cell", + "prometheus", + "proptest", + "raiko-lib", + "raiko-primitives", + "reqwest 0.11.27", + "reqwest 0.12.4", + "revm", + "rlp", + "serde", + "serde_json", + "serde_with", + "sha2 0.10.8", + "thiserror", + "tokio", + "tower", + "tower-http 0.5.2", + "tracing", + "tracing-appender", + "tracing-subscriber", + "url", + "utoipa", + "utoipa-scalar", + "utoipa-swagger-ui", +] + +[[package]] +name = "raiko-lib" +version = "0.1.0" +source = "git+https://github.com/taikoxyz/raiko.git?branch=reth-support#5e0eee5c97440e0e548c66df78212768ff7c328b" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-rlp", + "alloy-rlp-derive", + "alloy-rpc-types", + "alloy-sol-types", + "anyhow", + "c-kzg-taiko", + "cfg-if", + "chrono", + "flate2", + "hex", + "lazy_static", + "libflate", + "log", + "once_cell", + "raiko-primitives", + "revm", + "serde", + "serde_json", + "serde_with", + "sha2 0.10.8", + "thiserror", + "thiserror-no-std", + "url", +] + +[[package]] +name = "raiko-primitives" +version = "0.1.0" +source = "git+https://github.com/taikoxyz/raiko.git?branch=reth-support#5e0eee5c97440e0e548c66df78212768ff7c328b" +dependencies = [ + "alloy-dyn-abi", + "alloy-eips", + "alloy-primitives", + "alloy-rlp", + "alloy-rlp-derive", + "alloy-rpc-types", + "alloy-sol-types", + "anyhow", + "c-kzg", + "once_cell", + "revm-primitives", + "rlp", + "serde", + "sha2 0.10.8", + "sha3", + "tempfile", + "thiserror", +] + [[package]] name = "rand" version = "0.7.3" @@ -6166,23 +6633,27 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", + "hyper-tls 0.5.0", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", + "tokio-native-tls", "tokio-util", "tower-service", "url", @@ -6201,18 +6672,22 @@ checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" dependencies = [ "base64 0.22.0", "bytes", + "encoding_rs", "futures-core", "futures-util", + "h2 0.4.4", "http 1.1.0", "http-body 1.0.0", "http-body-util", "hyper 1.3.1", "hyper-rustls 0.26.0", + "hyper-tls 0.6.0", "hyper-util", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -6223,8 +6698,10 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", + "system-configuration", "tokio", + "tokio-native-tls", "tokio-rustls 0.25.0", "tower-service", "url", @@ -7188,7 +7665,7 @@ dependencies = [ "metrics-process", "metrics-util", "once_cell", - "procfs", + "procfs 0.16.0", "proptest", "rand 0.8.5", "reth-beacon-consensus", @@ -7612,7 +8089,7 @@ dependencies = [ "thiserror", "tokio", "tower", - "tower-http", + "tower-http 0.4.4", "tracing", ] @@ -7903,8 +8380,7 @@ dependencies = [ [[package]] name = "revm" version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72a454c1c650b2b2e23f0c461af09e6c31e1d15e1cbebe905a701c46b8a50afc" +source = "git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op#2733b062c075d11f09b15138be9a47801fa3c775" dependencies = [ "auto_impl", "cfg-if", @@ -7936,8 +8412,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d322f2730cd300e99d271a1704a2dfb8973d832428f5aa282aaa40e2473b5eec" +source = "git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op#2733b062c075d11f09b15138be9a47801fa3c775" dependencies = [ "revm-primitives", "serde", @@ -7946,11 +8421,11 @@ dependencies = [ [[package]] name = "revm-precompile" version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931f692f3f4fc72ec39d5d270f8e9d208c4a6008de7590ee96cf948e3b6d3f8d" +source = "git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op#2733b062c075d11f09b15138be9a47801fa3c775" dependencies = [ "aurora-engine-modexp", "c-kzg", + "cfg-if", "k256", "once_cell", "revm-primitives", @@ -7963,8 +8438,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbbc9640790cebcb731289afb7a7d96d16ad94afeb64b5d0b66443bd151e79d6" +source = "git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op#2733b062c075d11f09b15138be9a47801fa3c775" dependencies = [ "alloy-primitives", "auto_impl", @@ -8039,6 +8513,12 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "rle-decode-fast" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" + [[package]] name = "rlimit" version = "0.10.1" @@ -8142,6 +8622,40 @@ dependencies = [ "smallvec", ] +[[package]] +name = "rust-embed" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb78f46d0066053d16d4ca7b898e9343bc3530f71c61d5ad84cd404ada068745" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91ac2a3c6c0520a3fb3dd89321177c3c692937c4eb21893378219da10c44fc8" +dependencies = [ + "proc-macro2", + "quote", + "rust-embed-utils", + "syn 2.0.60", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f69089032567ffff4eada41c573fc43ff466c7db7c5688b2e7969584345581" +dependencies = [ + "sha2 0.10.8", + "walkdir", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -8178,6 +8692,20 @@ dependencies = [ "semver 1.0.22", ] +[[package]] +name = "rustix" +version = "0.36.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", +] + [[package]] name = "rustix" version = "0.38.34" @@ -8187,7 +8715,7 @@ dependencies = [ "bitflags 2.5.0", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.13", "windows-sys 0.52.0", ] @@ -8520,6 +9048,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" +dependencies = [ + "itoa", + "serde", +] + [[package]] name = "serde_qs" version = "0.8.5" @@ -9025,9 +9563,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70aba06097b6eda3c15f6eebab8a6339e121475bcf08bbe6758807e716c372a1" +checksum = "5aa0cefd02f532035d83cfec82647c6eb53140b0485220760e669f4bad489e36" dependencies = [ "paste", "proc-macro2", @@ -9041,6 +9579,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "synstructure" version = "0.13.1" @@ -9087,7 +9631,7 @@ checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand 2.1.0", - "rustix", + "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -9183,6 +9727,26 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "thiserror-impl-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "thiserror-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" +dependencies = [ + "thiserror-impl-no-std", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -9347,6 +9911,16 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" @@ -9487,7 +10061,38 @@ dependencies = [ "futures-util", "http 0.2.12", "http-body 0.4.6", - "http-range-header", + "http-range-header 0.3.1", + "httpdate", + "iri-string", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "tokio", + "tokio-util", + "tower", + "tower-layer", + "tower-service", + "tracing", + "uuid", +] + +[[package]] +name = "tower-http" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" +dependencies = [ + "async-compression", + "base64 0.21.7", + "bitflags 2.5.0", + "bytes", + "futures-core", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "http-range-header 0.4.0", "httpdate", "iri-string", "mime", @@ -9906,6 +10511,59 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "utoipa" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "272ebdfbc99111033031d2f10e018836056e4d2c8e2acda76450ec7974269fa7" +dependencies = [ + "indexmap 2.2.6", + "serde", + "serde_json", + "utoipa-gen", +] + +[[package]] +name = "utoipa-gen" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3c9f4d08338c1bfa70dde39412a040a884c6f318b3d09aaaf3437a1e52027fc" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "regex", + "syn 2.0.60", +] + +[[package]] +name = "utoipa-scalar" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3ab4b7269d14d93626b0bfedf212f1b0995cb7d13d35daba21d579511e7fae8" +dependencies = [ + "axum", + "serde", + "serde_json", + "utoipa", +] + +[[package]] +name = "utoipa-swagger-ui" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b39868d43c011961e04b41623e050aedf2cc93652562ff7935ce0f819aaf2da" +dependencies = [ + "axum", + "mime_guess", + "regex", + "rust-embed", + "serde", + "serde_json", + "utoipa", + "zip", +] + [[package]] name = "uuid" version = "1.8.0" @@ -10106,7 +10764,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix", + "rustix 0.38.34", ] [[package]] @@ -10165,6 +10823,15 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -10183,6 +10850,21 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -10214,6 +10896,12 @@ dependencies = [ "windows_x86_64_msvc 0.52.5", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -10226,6 +10914,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -10238,6 +10932,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -10256,6 +10956,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -10268,6 +10974,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -10280,6 +10992,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -10292,6 +11010,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -10494,6 +11218,18 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "byteorder", + "crc32fast", + "crossbeam-utils", + "flate2", +] + [[package]] name = "zstd" version = "0.13.1" diff --git a/Cargo.toml b/Cargo.toml index 70e36cd94e7d..18e8b1d90696 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -280,7 +280,7 @@ reth-testing-utils = { path = "testing/testing-utils" } # revm revm = { version = "8.0.0", features = ["std", "secp256k1"], default-features = false } -revm-primitives = { version = "3.1.0", features = ["std"], default-features = false } +revm-primitives = { version = "3.1.1", features = ["std"], default-features = false } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "848d568" } # eth @@ -290,20 +290,20 @@ alloy-dyn-abi = "0.7.1" alloy-sol-types = "0.7.1" alloy-rlp = "0.3.4" alloy-trie = "0.3.1" -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } -alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e", default-features = false, features = [ +alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-rpc-types-anvil = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-rpc-types-trace = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-rpc-types-engine = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-genesis = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-node-bindings = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-provider = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e", default-features = false, features = [ "reqwest", ] } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", default-features = false, rev = "4e22b9e" } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "4e22b9e" } +alloy-eips = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-signer = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-signer-wallet = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-network = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-consensus = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } # misc auto_impl = "1" @@ -398,3 +398,22 @@ proptest-derive = "0.4" serial_test = "3" similar-asserts = "1.5.0" test-fuzz = "5" + +# raiko +raiko-host = { git = "https://github.com/taikoxyz/raiko.git", branch = "reth-support" } +raiko-lib = { git = "https://github.com/taikoxyz/raiko.git", branch = "reth-support" } +raiko-primitives = { git = "https://github.com/taikoxyz/raiko.git", branch = "reth-support" } +anyhow = "1.0" + +# used in revm-inspector +[patch."https://github.com/alloy-rs/alloy"] +alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } +alloy-rpc-types-trace = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } + +[patch.crates-io] +revm = { git = "https://github.com/taikoxyz/revm.git", branch = "feat/zk-op", default-features = false, features = [ + "std", + "serde", + "taiko", +]} +revm-primitives = { git = "https://github.com/taikoxyz/revm.git", branch = "feat/zk-op", default-features = false } \ No newline at end of file diff --git a/crates/primitives/src/revm/env.rs b/crates/primitives/src/revm/env.rs index b13a7018f7ce..3979b52b7ed7 100644 --- a/crates/primitives/src/revm/env.rs +++ b/crates/primitives/src/revm/env.rs @@ -171,6 +171,7 @@ pub fn fill_tx_env_with_beacon_root_contract_call(env: &mut Env, parent_beacon_b // enveloped tx size. enveloped_tx: Some(Bytes::default()), }, + taiko: revm_primitives::TaikoFields { treasury: Address::default(), is_anchor: false }, }; // ensure the block gas limit is >= the tx diff --git a/crates/rpc/rpc-types-compat/src/block.rs b/crates/rpc/rpc-types-compat/src/block.rs index b342f8a30b29..8ea0fa4d8ded 100644 --- a/crates/rpc/rpc-types-compat/src/block.rs +++ b/crates/rpc/rpc-types-compat/src/block.rs @@ -144,8 +144,9 @@ pub fn from_primitive_with_hash(primitive_header: reth_primitives::SealedHeader) } } +/// from_block_with_transactions #[inline] -fn from_block_with_transactions( +pub fn from_block_with_transactions( block_length: usize, block_hash: B256, block: PrimitiveBlock, diff --git a/crates/rpc/rpc/src/eth/error.rs b/crates/rpc/rpc/src/eth/error.rs index 203b5bbd70e5..a83b00cc5b91 100644 --- a/crates/rpc/rpc/src/eth/error.rs +++ b/crates/rpc/rpc/src/eth/error.rs @@ -471,6 +471,9 @@ impl From for RpcInvalidTransactionError { InvalidTransaction::HaltedDepositPostRegolith => RpcInvalidTransactionError::Optimism( OptimismInvalidTransactionError::HaltedDepositPostRegolith, ), + InvalidTransaction::InvalidAnchorTransaction => { + RpcInvalidTransactionError::BlobTransactionIsCreate + } } } } diff --git a/crates/rpc/rpc/src/eth/revm_utils.rs b/crates/rpc/rpc/src/eth/revm_utils.rs index c80aee99d5c4..d0dc43471f80 100644 --- a/crates/rpc/rpc/src/eth/revm_utils.rs +++ b/crates/rpc/rpc/src/eth/revm_utils.rs @@ -272,6 +272,7 @@ pub(crate) fn create_txn_env( max_fee_per_blob_gas, #[cfg(feature = "optimism")] optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, + taiko: revm_primitives::TaikoFields { treasury: Address::default(), is_anchor: false }, }; Ok(env) diff --git a/crates/trie/src/proof.rs b/crates/trie/src/proof.rs index 55eb47710f03..c4ec233c9323 100644 --- a/crates/trie/src/proof.rs +++ b/crates/trie/src/proof.rs @@ -46,6 +46,7 @@ where address: Address, slots: &[B256], ) -> Result { + //println!("Brecht account proof"); let target_hashed_address = keccak256(address); let target_nibbles = Nibbles::unpack(target_hashed_address); let mut account_proof = AccountProof::new(address); @@ -66,11 +67,15 @@ where let mut account_rlp = Vec::with_capacity(128); let mut account_node_iter = AccountNodeIter::new(walker, hashed_account_cursor); while let Some(account_node) = account_node_iter.try_next()? { + println!("loop account: {:?}", account_node); match account_node { AccountNode::Branch(node) => { + println!("reth branch"); + assert!(false); hash_builder.add_branch(node.key, node.value, node.children_are_in_trie); } AccountNode::Leaf(hashed_address, account) => { + println!("reth leaf"); let storage_root = if hashed_address == target_hashed_address { let (storage_root, storage_proofs) = self.storage_root_with_proofs(hashed_address, slots)?; @@ -89,7 +94,9 @@ where } } - let _ = hash_builder.root(); + let root = hash_builder.root(); + println!("proof root: {:?}", root); + println!("{:?}", hash_builder); let proofs = hash_builder.take_proofs(); account_proof.set_proof(proofs.values().cloned().collect()); @@ -109,6 +116,7 @@ where hashed_address: B256, slots: &[B256], ) -> Result<(B256, Vec), StorageRootError> { + //println!("Brecht storage root"); let mut hashed_storage_cursor = self.hashed_cursor_factory.hashed_storage_cursor()?; let mut proofs = slots.iter().copied().map(StorageProof::new).collect::>(); diff --git a/testing/ef-tests/Cargo.toml b/testing/ef-tests/Cargo.toml index 3f219322710b..0eee88cdbc6b 100644 --- a/testing/ef-tests/Cargo.toml +++ b/testing/ef-tests/Cargo.toml @@ -23,6 +23,12 @@ reth-stages.workspace = true reth-interfaces.workspace = true reth-revm.workspace = true reth-node-ethereum.workspace = true +reth-rpc-types-compat.workspace = true +reth-rpc-types.workspace = true +reth-rpc.workspace = true +reth-transaction-pool = { workspace = true, features = ["test-utils"] } +reth-network-api.workspace = true +reth-tasks = { workspace = true } alloy-rlp.workspace = true tokio = "1.28.1" @@ -31,3 +37,9 @@ serde = "1.0.163" serde_json.workspace = true thiserror.workspace = true rayon.workspace = true + +# raiko +raiko-host.workspace = true +raiko-lib.workspace = true +raiko-primitives.workspace = true +anyhow.workspace = true diff --git a/testing/ef-tests/src/case.rs b/testing/ef-tests/src/case.rs index 7258dafb22aa..264e54148b4b 100644 --- a/testing/ef-tests/src/case.rs +++ b/testing/ef-tests/src/case.rs @@ -1,6 +1,6 @@ //! Test case definitions -use crate::result::{CaseResult, Error}; +use crate::result::{CaseAsyncResult, CaseResult, Error}; use std::{ fmt::Debug, path::{Path, PathBuf}, @@ -24,6 +24,24 @@ pub trait Case: Debug + Sync + Sized { fn run(&self) -> Result<(), Error>; } +/// A single test case, capable of loading a JSON description of itself and running it. +/// +/// See for test specs. +pub trait CaseAsync: Debug + Sync + Sized { + /// A description of the test. + fn description(&self) -> String { + "no description".to_string() + } + + /// Load the test from the given file path. + /// + /// The file can be assumed to be a valid EF test case as described on . + fn load(path: &Path) -> Result; + + /// Run the test. + async fn run(&self) -> Result<(), Error>; +} + /// A container for multiple test cases. #[derive(Debug)] pub struct Cases { @@ -37,3 +55,24 @@ impl Cases { self.test_cases.iter().map(|(path, case)| CaseResult::new(path, case, case.run())).collect() } } + +/// A container for multiple test cases. +#[derive(Debug)] +pub struct CasesAsync { + /// The contained test cases and the path to each test. + pub test_cases: Vec<(PathBuf, T)>, +} + +impl CasesAsync { + /// Run the contained test cases. + pub async fn run(&self) -> Vec { + let mut results = Vec::new(); + for (path, case) in self.test_cases.iter() { + let res = case.run().await; + results.push(CaseAsyncResult::new(path, case, res)); + } + results + //self.test_cases.iter().map(|(path, case)| CaseAsyncResult::new(path, case, + // case.run().await)).collect() + } +} diff --git a/testing/ef-tests/src/cases/blockchain_test.rs b/testing/ef-tests/src/cases/blockchain_test.rs index 424603cb4c21..6d648ac75d6f 100644 --- a/testing/ef-tests/src/cases/blockchain_test.rs +++ b/testing/ef-tests/src/cases/blockchain_test.rs @@ -1,17 +1,58 @@ //! Test runners for `BlockchainTests` in use crate::{ - models::{BlockchainTest, ForkSpec}, - Case, Error, Suite, + case::CaseAsync, + models::{BlockchainTest, ForkSpec, State}, + suite::SuiteAsync, + Error, +}; +use alloy_rlp::{Decodable, Encodable}; +use anyhow::{bail, Result}; +use raiko_host::{ + error::{HostError, HostResult}, + raiko::{BlockDataProvider, NativeResponse, Raiko}, + request::{ProofRequest, ProofType}, + MerkleProof, +}; +use raiko_lib::{ + consts::{ChainSpec, Eip1559Constants, Network}, + input::GuestOutput, +}; +use raiko_primitives::{ + keccak::keccak, + mpt::{to_nibs, MptNode, MptNodeData, StateAccount}, +}; +use reth_db::{ + mdbx::{tx::Tx, RO}, + test_utils::{create_test_rw_db, create_test_static_files_dir}, }; -use alloy_rlp::Decodable; -use rayon::iter::{ParallelBridge, ParallelIterator}; -use reth_db::test_utils::{create_test_rw_db, create_test_static_files_dir}; use reth_node_ethereum::EthEvmConfig; -use reth_primitives::{BlockBody, SealedBlock, StaticFileSegment}; -use reth_provider::{providers::StaticFileWriter, HashingWriter, ProviderFactory}; -use reth_stages::{stages::ExecutionStage, ExecInput, Stage}; -use std::{collections::BTreeMap, fs, path::Path, sync::Arc}; +use reth_primitives::{ + address, b256, stage::StageCheckpoint, Address, BlockBody, SealedBlock, StaticFileSegment, + B256, U256, +}; +use reth_provider::{ + providers::StaticFileWriter, AccountReader, BlockReader, DatabaseProvider, ProviderFactory, + StateProvider, +}; +use reth_revm::primitives::{AccountInfo, SpecId}; +use reth_rpc_types::{ + Block as RpcBlock, BlockTransactions, EIP1186AccountProofResponse, EIP1186StorageProof, +}; +use reth_rpc_types_compat::{ + block::from_block_with_transactions, proof::from_primitive_account_proof, + transaction::from_recovered_with_block_context, +}; +use reth_stages::{ + stages::{AccountHashingStage, ExecutionStage, MerkleStage, StorageHashingStage}, + ExecInput, Stage, +}; +use std::{ + collections::{BTreeMap, BTreeSet, HashMap, HashSet}, + fs, + path::Path, + sync::Arc, +}; /// A handler for the blockchain test suite. #[derive(Debug)] @@ -26,8 +67,8 @@ impl BlockchainTests { } } -impl Suite for BlockchainTests { - type Case = BlockchainTestCase; +impl SuiteAsync for BlockchainTests { + type CaseAsync = BlockchainTestCase; fn suite_name(&self) -> String { format!("BlockchainTests/{}", self.suite) @@ -37,13 +78,351 @@ impl Suite for BlockchainTests { /// An Ethereum blockchain test. #[derive(Debug, PartialEq, Eq)] pub struct BlockchainTestCase { + name: String, tests: BTreeMap, skip: bool, } -impl Case for BlockchainTestCase { +/// Computes the Merkle proof for the given key in the trie. +pub fn mpt_proof(root: &MptNode, key: impl AsRef<[u8]>) -> Result>, anyhow::Error> { + let mut path = proof_internal(root, &to_nibs(key.as_ref()))?; + path.reverse(); + Ok(path) +} + +fn proof_internal(node: &MptNode, key_nibs: &[u8]) -> Result>, anyhow::Error> { + if key_nibs.is_empty() { + return Ok(vec![alloy_rlp::encode(node)]); + } + + let mut path: Vec> = match node.as_data() { + MptNodeData::Null | MptNodeData::Leaf(_, _) => { + println!("test leaf/null"); + vec![] + } + MptNodeData::Branch(children) => { + println!("test Branch"); + let (i, tail) = key_nibs.split_first().unwrap(); + match &children[*i as usize] { + Some(child) => proof_internal(child, tail)?, + None => vec![], + } + } + MptNodeData::Extension(_, child) => { + println!("test Extension"); + if let Some(tail) = key_nibs.strip_prefix(node.nibs().as_slice()) { + proof_internal(child, tail)? + } else { + vec![] + } + } + MptNodeData::Digest(_) => bail!("Cannot descend pointer!"), + }; + println!("Adding: {:?}", alloy_rlp::encode(node)); + path.push(alloy_rlp::encode(node)); + + Ok(path) +} + +/// Builds the state trie and storage tries from the test state. +pub fn build_tries(state: &State) -> (MptNode, HashMap) { + let mut state_trie = MptNode::default(); + let mut storage_tries = HashMap::new(); + for (address, account) in state.iter() { + let mut storage_trie = MptNode::default(); + for (slot, value) in &account.storage { + if *value != U256::ZERO { + storage_trie.insert_rlp(&keccak(slot.to_be_bytes::<32>()), *value).unwrap(); + } + } + + state_trie + .insert_rlp( + &keccak(address), + StateAccount { + nonce: account.nonce.try_into().unwrap(), + balance: account.balance, + storage_root: storage_trie.hash(), + code_hash: keccak(account.code.clone()).into(), + }, + ) + .unwrap(); + storage_tries.insert(*address, storage_trie); + } + + println!("test state trie root: {:?}", state_trie.hash()); + + (state_trie, storage_tries) +} + +fn get_proof( + address: Address, + indices: impl IntoIterator, + state: &State, +) -> Result { + let account = state.get(&address).cloned().unwrap_or_default(); + let (state_trie, mut storage_tries) = build_tries(state); + let storage_trie = storage_tries.remove(&address).unwrap_or_default(); + + let account_proof = + mpt_proof(&state_trie, keccak(address))?.into_iter().map(|p| p.into()).collect(); + let mut storage_proof = vec![]; + let index_set = indices.into_iter().collect::>(); + for index in index_set { + let proof = EIP1186StorageProof { + key: index.into(), + proof: mpt_proof(&storage_trie, keccak(index.to_be_bytes::<32>()))? + .into_iter() + .map(|p| p.into()) + .collect(), + value: account.storage.get(&index).cloned().unwrap_or_default(), + }; + storage_proof.push(proof); + } + + Ok(EIP1186AccountProofResponse { + address: address.into_array().into(), + balance: account.balance, + code_hash: keccak(account.code).into(), + nonce: account.nonce.into_limbs()[0].try_into().unwrap(), + storage_hash: storage_trie.hash().0.into(), + account_proof, + storage_proof, + }) +} + +fn remove_duplicates(objects: Vec) -> Vec { + let mut unique_keys = HashSet::new(); + let mut unique_objects = Vec::new(); + + for object in objects { + if unique_keys.insert(object.key.0) { + unique_objects.push(object); + } + } + + unique_objects +} + +/// RethBlockDataProvider +pub struct RethBlockDataProvider { + provider: DatabaseProvider>, + block_number: u64, + block_state_pre: Box, + block_state_post: Box, + test_state_pre: State, + test_state_post: State, +} + +/// RethBlockDataProvider impl +impl RethBlockDataProvider { + /// Creates a new RethBlockDataProvider + pub fn new( + provider: DatabaseProvider>, + block_number: u64, + block_state_pre: Box, + block_state_post: Box, + test_state_pre: State, + test_state_post: State, + ) -> Self { + Self { + provider, + block_number, + block_state_pre, + block_state_post, + test_state_pre, + test_state_post, + } + } +} + +/// Root hash of an empty trie. +pub const EMPTY_ROOT: B256 = + b256!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); + +/// Raiko interface implementation for block data to directly connect with reth's database +impl BlockDataProvider for RethBlockDataProvider { + async fn get_blocks(&self, blocks_to_fetch: &[(u64, bool)]) -> HostResult> { + let mut blocks = Vec::new(); + + for (block_number, _full) in blocks_to_fetch { + let block = self + .provider + .block_by_number(*block_number) + .expect("failed to fetch block") + .unwrap(); + //println!("block: {:?}", block.unwrap().body); + + let senders = block.senders().unwrap(); + let block = block.try_with_senders_unchecked(senders).unwrap(); + + let block_hash = block.header.hash_slow(); + let block_number = block.number; + let base_fee_per_gas = Some(block.base_fee_per_gas.unwrap_or(1)); + + let body = &block.body; + let transactions_with_senders = body.into_iter().zip(block.senders.clone()); + let transactions = transactions_with_senders + .enumerate() + .map(|(idx, (tx, sender))| { + let signed_tx_ec_recovered = tx.clone().with_signer(sender); + + from_recovered_with_block_context( + signed_tx_ec_recovered, + block_hash, + block_number, + base_fee_per_gas, + idx, + ) + }) + .collect::>(); + + let total_difficulty = U256::ZERO; + let block = from_block_with_transactions( + block.length(), + block_hash, + block.block, + total_difficulty, + BlockTransactions::Full(transactions), + ); + blocks.push(block); + } + Ok(blocks) + } + + async fn get_storage_values(&self, accounts: &[(Address, U256)]) -> HostResult> { + let mut values = Vec::new(); + for (address, key) in accounts { + let value = self.block_state_pre.storage(*address, (*key).into()); + let value = value.unwrap().or_else(|| Some(U256::ZERO)).unwrap(); + values.push(value); + } + Ok(values) + } + + async fn get_accounts(&self, addresses: &[Address]) -> HostResult> { + let mut accounts = Vec::new(); + for address in addresses { + let account = self + .block_state_pre + .basic_account(*address) + .map_err(|e| HostError::Anyhow(e.into()))?; + //println!("bdp account {address}: {:?}", account); + let code = self.block_state_pre.account_code(*address).expect("code failed"); + //println!("bdp account {address}: {:?}", account); + let account = if let Some(account) = account { + AccountInfo { + balance: account.balance, + nonce: account.nonce, + code_hash: account.get_bytecode_hash(), + code: code.map(|code| { + reth_primitives::revm_primitives::Bytecode::new_raw(code.bytecode.clone()) + }), + } + } else { + AccountInfo::default() + }; + accounts.push(account); + } + Ok(accounts) + } + + async fn get_merkle_proofs( + &self, + block_number: u64, + accounts: HashMap>, + _offset: usize, + _num_storage_proofs: usize, + ) -> HostResult { + let mut storage_proofs: MerkleProof = HashMap::new(); + + println!("block_number: {block_number} ({})", self.block_number); + + let block_state = if block_number == self.block_number { + &self.block_state_pre + } else if block_number == self.block_number + 1 { + &self.block_state_post + } else { + unreachable!() + }; + + let block_state_test = if block_number == self.block_number { + &self.test_state_pre + } else if block_number == self.block_number + 1 { + &self.test_state_post + } else { + unreachable!() + }; + + /*for (account, keys) in accounts.iter() { + let keys = keys.into_iter().map(|v| v.clone().into()).collect::>(); + let proof = block_state.as_ref().proof(*account, &keys).unwrap(); + let prim_proof = from_primitive_account_proof(proof); + println!("-- {:?}: {:?}", account, prim_proof); + storage_proofs.insert(*account, prim_proof); + }*/ + + for (address, keys) in accounts.iter() { + let indices = keys.into_iter().map(|v| v.clone().into()).collect::>(); + let prim_proof_test = get_proof(*address, indices, &block_state_test)?; + + let indices = keys.into_iter().map(|v| v.clone().into()).collect::>(); + let proof = block_state.as_ref().proof(*address, &indices).unwrap(); + let mut prim_proof = from_primitive_account_proof(proof); + + for storage_proof in prim_proof.storage_proof.iter_mut() { + if storage_proof.proof.is_empty() { + storage_proof.proof.push(vec![128u8].into()); + } + } + + prim_proof.storage_proof = remove_duplicates(prim_proof.storage_proof); + + assert_eq!(prim_proof_test.address, prim_proof.address); + assert_eq!(prim_proof_test.balance, prim_proof.balance); + assert_eq!(prim_proof_test.code_hash, prim_proof.code_hash); + assert_eq!(prim_proof_test.nonce, prim_proof.nonce); + let storage_hash = if prim_proof.storage_hash == B256::ZERO { + EMPTY_ROOT + } else { + prim_proof.storage_hash + }; + assert_eq!(prim_proof_test.storage_hash, storage_hash); + /*if prim_proof_test.account_proof != prim_proof.account_proof { + prim_proof.account_proof = prim_proof_test.account_proof.clone(); + }*/ + let account = self + .block_state_pre + .basic_account(*address) + .map_err(|e| HostError::Anyhow(e.into()))?; + if account.is_some() { + assert_eq!(prim_proof_test.account_proof, prim_proof.account_proof); + } + assert_eq!(prim_proof_test.storage_proof.len(), prim_proof.storage_proof.len()); + /*for storage_proof in prim_proof.storage_proof.iter() { + let value = self.block_state_pre.storage(*address, storage_proof.key.0); + if value.is_ok() { + if value.unwrap().is_some() { + assert!(prim_proof_test.storage_proof.contains(storage_proof)); + } + } + }*/ + + //let proof = block_state..proof(*account, &keys).unwrap(); + //let prim_proof = from_primitive_account_proof(proof); + //println!("-- {:?}: {:?}", account, prim_proof); + //storage_proofs.insert(*account, prim_proof); + storage_proofs.insert(*address, prim_proof_test); + } + + Ok(storage_proofs) + } +} + +impl CaseAsync for BlockchainTestCase { fn load(path: &Path) -> Result { Ok(BlockchainTestCase { + name: path.to_str().unwrap().to_string(), tests: { let s = fs::read_to_string(path) .map_err(|error| Error::Io { path: path.into(), error })?; @@ -58,119 +437,412 @@ impl Case for BlockchainTestCase { /// /// # Errors /// Returns an error if the test is flagged for skipping or encounters issues during execution. - fn run(&self) -> Result<(), Error> { + async fn run(&self) -> Result<(), Error> { // If the test is marked for skipping, return a Skipped error immediately. if self.skip { return Err(Error::Skipped) } // Iterate through test cases, filtering by the network type to exclude specific forks. - self.tests - .values() - .filter(|case| { - !matches!( - case.network, - ForkSpec::ByzantiumToConstantinopleAt5 | - ForkSpec::Constantinople | - ForkSpec::ConstantinopleFix | - ForkSpec::MergeEOF | - ForkSpec::MergeMeterInitCode | - ForkSpec::MergePush0 | - ForkSpec::Unknown - ) + let tests = self + .tests + .iter() + .filter(|(name, case)| { + // !matches!( + // case.network, + // ForkSpec::ByzantiumToConstantinopleAt5 | + // ForkSpec::Constantinople | + // ForkSpec::ConstantinopleFix | + // ForkSpec::MergeEOF | + // ForkSpec::MergeMeterInitCode | + // ForkSpec::MergePush0 | + // ForkSpec::Unknown + matches!(case.network, ForkSpec::Shanghai) /* && !(name.starts_with("push0") || + * name.starts_with(" + * create2InitCodeSizeLimit")) */ }) - .par_bridge() - .try_for_each(|case| { - // Create a new test database and initialize a provider for the test case. - let db = create_test_rw_db(); - let (_static_files_dir, static_files_dir_path) = create_test_static_files_dir(); - let provider = ProviderFactory::new( - db.as_ref(), - Arc::new(case.network.clone().into()), - static_files_dir_path, - )? - .provider_rw() - .unwrap(); + .collect::>(); - // Insert initial test state into the provider. - provider - .insert_historical_block( - SealedBlock::new( - case.genesis_block_header.clone().into(), - BlockBody::default(), - ) - .try_seal_with_senders() - .unwrap(), - None, + for (name, case) in tests.iter() { + println!("## case: {}", name); + // Create a new test database and initialize a provider for the test case. + let db = create_test_rw_db(); + let (_static_files_dir, static_files_dir_path) = create_test_static_files_dir(); + let provider = ProviderFactory::new( + db.as_ref(), + Arc::new(case.network.clone().into()), + static_files_dir_path.clone(), + )? + .provider_rw() + .unwrap(); + + //let eth_api = build_test_eth_api(provider); + + // Insert initial test state into the provider. + provider + .insert_historical_block( + SealedBlock::new( + case.genesis_block_header.clone().into(), + BlockBody::default(), ) - .map_err(|err| Error::RethError(err.into()))?; - case.pre.write_to_db(provider.tx_ref())?; - - // Initialize receipts static file with genesis - { - let mut receipts_writer = provider - .static_file_provider() - .latest_writer(StaticFileSegment::Receipts) - .unwrap(); - receipts_writer.increment_block(StaticFileSegment::Receipts, 0).unwrap(); - receipts_writer.commit_without_sync_all().unwrap(); - } + .try_seal_with_senders() + .unwrap(), + None, + ) + .map_err(|err| Error::RethError(err.into()))?; + case.pre.write_to_db(provider.tx_ref())?; - // Decode and insert blocks, creating a chain of blocks for the test case. - let last_block = case.blocks.iter().try_fold(None, |_, block| { - let decoded = SealedBlock::decode(&mut block.rlp.as_ref())?; - provider - .insert_historical_block( - decoded.clone().try_seal_with_senders().unwrap(), - None, - ) - .map_err(|err| Error::RethError(err.into()))?; - Ok::, Error>(Some(decoded)) - })?; - provider + // Initialize receipts static file with genesis + { + let mut receipts_writer = provider .static_file_provider() - .latest_writer(StaticFileSegment::Headers) - .unwrap() - .commit_without_sync_all() + .latest_writer(StaticFileSegment::Receipts) .unwrap(); + receipts_writer.increment_block(StaticFileSegment::Receipts, 0).unwrap(); + receipts_writer.commit_without_sync_all().unwrap(); + } + + // Decode and insert blocks, creating a chain of blocks for the test case. + let last_block = case.blocks.iter().try_fold(None, |_, block| { + let decoded = SealedBlock::decode(&mut block.rlp.as_ref())?; + provider + .insert_historical_block(decoded.clone().try_seal_with_senders().unwrap(), None) + .map_err(|err| Error::RethError(err.into()))?; + Ok::, Error>(Some(decoded)) + })?; + + provider + .static_file_provider() + .latest_writer(StaticFileSegment::Headers) + .unwrap() + .commit() + .unwrap(); + + // Look up merkle checkpoint + /*let merkle_checkpoint = provider + .get_stage_checkpoint(StageId::MerkleExecute).unwrap() + .expect("merkle checkpoint exists"); + + let merkle_block_number = merkle_checkpoint.block_number; + println!("merkle_block_number: {}", merkle_block_number);*/ - // Execute the execution stage using the EVM processor factory for the test case - // network. - let _ = ExecutionStage::new_with_factory(reth_revm::EvmProcessorFactory::new( + let mut account_hashing_stage = AccountHashingStage::default(); + let mut storage_hashing_stage = StorageHashingStage::default(); + let mut merkle_stage = MerkleStage::default_execution(); + + let progress = None; + + let block = 0; + + let mut account_hashing_done = false; + while !account_hashing_done { + let output = account_hashing_stage + .execute( + &provider, + ExecInput { + target: Some(block), + checkpoint: progress.map(StageCheckpoint::new), + }, + ) + .unwrap(); + account_hashing_done = output.done; + } + + let mut storage_hashing_done = false; + while !storage_hashing_done { + let output = storage_hashing_stage + .execute( + &provider, + ExecInput { + target: Some(block), + checkpoint: progress.map(StageCheckpoint::new), + }, + ) + .unwrap(); + storage_hashing_done = output.done; + } + + let incremental_result = merkle_stage.execute( + &provider, + ExecInput { target: Some(block), checkpoint: progress.map(StageCheckpoint::new) }, + ); + println!("{:?}", incremental_result); + assert!(incremental_result.is_ok()); + + provider.commit().unwrap(); + + let block_state_pre = ProviderFactory::new( + db.as_ref(), + Arc::new(case.network.clone().into()), + static_files_dir_path.clone(), + )? + .latest() + .unwrap(); + + let coinbase = address!("2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"); + let proof = block_state_pre.as_ref().proof(coinbase, &Vec::new()).unwrap(); + let prim_proof = from_primitive_account_proof(proof); + println!("prim_proof: {:?}", prim_proof); + + //println!("account test: {:?}", + // block_state_pre.basic_account(address!("a94f5374Fce5edBC8E2a8697C15331677e6EbF0B"))); + + let provider = ProviderFactory::new( + db.as_ref(), + Arc::new(case.network.clone().into()), + static_files_dir_path.clone(), + )? + .provider_rw() + .unwrap(); + + // Execute the execution stage using the EVM processor factory for the test case + // network. + let mut executor = + ExecutionStage::new_with_factory(reth_revm::EvmProcessorFactory::new( Arc::new(case.network.clone().into()), EthEvmConfig::default(), - )) - .execute( - &provider, - ExecInput { target: last_block.as_ref().map(|b| b.number), checkpoint: None }, - ); - - // Validate the post-state for the test case. - match (&case.post_state, &case.post_state_hash) { - (Some(state), None) => { - // Validate accounts in the state against the provider's database. - for (&address, account) in state.iter() { - account.assert_db(address, provider.tx_ref())?; - } + )); + + let execution_result = executor.execute( + &provider, + ExecInput { target: last_block.as_ref().map(|b| b.number), checkpoint: None }, + ); + println!("execution result: {:?}", execution_result); + + let mut account_hashing_stage = AccountHashingStage::default(); + let mut storage_hashing_stage = StorageHashingStage::default(); + let mut merkle_stage = MerkleStage::default_execution(); + + let progress = None; + + let block = 1; + + let mut account_hashing_done = false; + while !account_hashing_done { + let output = account_hashing_stage + .execute( + &provider, + ExecInput { + target: Some(block), + checkpoint: progress.map(StageCheckpoint::new), + }, + ) + .unwrap(); + account_hashing_done = output.done; + } + + let mut storage_hashing_done = false; + while !storage_hashing_done { + let output = storage_hashing_stage + .execute( + &provider, + ExecInput { + target: Some(block), + checkpoint: progress.map(StageCheckpoint::new), + }, + ) + .unwrap(); + storage_hashing_done = output.done; + } + + let incremental_result = merkle_stage.execute( + &provider, + ExecInput { target: Some(block), checkpoint: progress.map(StageCheckpoint::new) }, + ); + println!("{:?}", incremental_result); + //assert!(incremental_result.is_ok()); + //if execution_result.is_ok() { + //assert!(incremental_result.is_ok()); + //} + + //incremental_result.is_err() { + + //result.unwrap(). + //let block_state = executor.take_output_state(); + + provider + .static_file_provider() + .latest_writer(StaticFileSegment::Headers) + .unwrap() + .commit() + .unwrap(); + + provider.commit().unwrap(); + + let provider = ProviderFactory::new( + db.as_ref(), + Arc::new(case.network.clone().into()), + static_files_dir_path.clone(), + )? + .provider() + .unwrap(); + + //provider.state_provider_by_block_number(block_number) + + let block_state_post = ProviderFactory::new( + db.as_ref(), + Arc::new(case.network.clone().into()), + static_files_dir_path.clone(), + )? + .latest() + .unwrap(); + + //block_state_post.state + + let test_address = address!("a94f5374fce5edbc8e2a8697c15331677e6ebf0b"); + println!("account test: {:?}", block_state_pre.basic_account(test_address)); + println!("account test: {:?}", block_state_post.basic_account(test_address)); + + println!("{:?}", block_state_pre.proof(test_address, &Vec::new())); + println!("{:?}", block_state_post.proof(test_address, &Vec::new())); + + println!("num blocks: {}", case.blocks.len()); + let last_block_ = case.blocks.last().unwrap(); + println!("{:?}", last_block_.block_header); + let first_block = /*case.blocks.last().unwrap().block_header.clone().unwrap().number*/1u64; + /*let db_state = ProviderFactory::new( + db.as_ref(), + Arc::new(case.network.clone().into()), + static_files_dir_path.clone(), + )? + .latest() + //.unwrap() + //.state_provider_by_block_number(first_block.try_into().unwrap()) + .unwrap();*/ + + //let revm_db = StateProviderDatabase::new(db.as_ref()); + + let block_number = first_block.try_into().unwrap(); + + let chain_spec = ChainSpec::new_single( + "test".to_string(), + 1, + SpecId::SHANGHAI, + Eip1559Constants::default(), + false, + ); + let provider_raiko = RethBlockDataProvider::new( + provider, + block_number - 1, + block_state_pre, + block_state_post, + case.pre.clone(), + State(case.post_state.clone().unwrap_or(case.pre.clone().0)), + ); + let request = ProofRequest { + block_number, + rpc: String::new(), + l1_rpc: String::new(), + beacon_rpc: String::new(), + network: Network::Ethereum, + graffiti: B256::random(), + prover: Address::random(), + l1_network: Network::Ethereum.to_string(), + proof_type: ProofType::Native, + prover_args: HashMap::new(), + }; + let raiko = Raiko::new(chain_spec, request); + let input = raiko + .generate_input(provider_raiko) + .await + .map_err(|e| Error::Assertion(e.to_string()))?; + let output = raiko.get_output(&input).map_err(|e| Error::Assertion(e.to_string())); + + //let raiko_result = raiko.prove(chain_spec, provider_raiko, proof_type, + // request).await; println!("result: {:?}", result); + //assert!(result.is_ok()); + + assert_eq!(execution_result.is_ok(), output.is_ok()); + + if output.is_ok() { + let proof = raiko + .prove(input, &output.unwrap()) + .await + .map_err(|e| Error::Assertion(e.to_string()))?; + let response: NativeResponse = serde_json::from_value(proof).unwrap(); + println!("response: {:?}", response); + match response.output { + GuestOutput::Success { header, hash: _ } => { + println!("raiko: {:?}", header.hash_slow()); + println!("expected: {:?}", case.lastblockhash); + assert_eq!(header.hash_slow(), case.lastblockhash); } - (None, Some(expected_state_root)) => { - // Insert state hashes into the provider based on the expected state root. - let last_block = last_block.unwrap_or_default(); - provider - .insert_hashes( - 0..=last_block.number, - last_block.hash(), - *expected_state_root, - ) - .map_err(|err| Error::RethError(err.into()))?; + GuestOutput::Failure => { + todo!() } - _ => return Err(Error::MissingPostState), + }; + } + + // Validate the post-state for the test case. + match (&case.post_state, &case.post_state_hash) { + (Some(state), None) => { + // Validate accounts in the state against the provider's database. + for (&address, account) in state.iter() { + /*account.assert_db(address, provider.tx_ref())?; + + let storage_keys = account.storage.keys().map(|key| B256::new(key.to_le_bytes())).collect::>(); + if storage_keys.len() > 0 { + let proof = db_state.as_ref().proof(address, &storage_keys).unwrap(); + let prim_proof = from_primitive_account_proof(proof); + //println!("proof: {:?}", prim_proof); + }*/ + } + + //Ok(()) } + (None, Some(expected_state_root)) => { + // Insert state hashes into the provider based on the expected state root. + let last_block = last_block.unwrap_or_default(); + /*provider + .insert_hashes( + 0..=last_block.number, + last_block.hash(), + *expected_state_root, + ) + .map_err(|err| Error::RethError(err.into()))?;*/ + //Ok(()) + } + _ => return Err(Error::MissingPostState), + } - // Drop the provider without committing to the database. - drop(provider); - Ok(()) - })?; + //println!("genesis_block_header: {:?}", case.genesis_block_header.number); + + /*let block_state = provider.state_provider_by_block_number(block_number).unwrap(); + //block_state.storage(account, storage_key)?; + block_state.basic_account(addr) + + //provider.block + provider.block_with_senders(reth_rpc_types::BlockHashOrNumber::Number(block_number), TransactionVariant::NoHash).unwrap(); + + let address = Address::default(); + let tx_db: &reth_db::mdbx::tx::Tx = provider.tx_ref(); + let account = tx_db.get::(address)?.ok_or_else(|| { + Error::Assertion(format!("Expected account ({address}) is missing from DB: {self:?}")) + })?;*/ + //account. + + /*let block_state = ProviderFactory::new( + db.as_ref(), + Arc::new(case.network.clone().into()), + static_files_dir_path.clone(), + )? + .provider() + .unwrap() + .state_provider_by_block_number(block_number) + .unwrap();*/ + + /*let block_state = ProviderFactory::new( + db.as_ref(), + Arc::new(case.network.clone().into()), + static_files_dir_path.clone(), + )? + .latest() + .unwrap();*/ + + // Drop the provider without committing to the database. + //drop(provider); + //Ok(()) + } Ok(()) } diff --git a/testing/ef-tests/src/models.rs b/testing/ef-tests/src/models.rs index a30aa3d930f2..24e464d6db40 100644 --- a/testing/ef-tests/src/models.rs +++ b/testing/ef-tests/src/models.rs @@ -146,7 +146,7 @@ pub struct TransactionSequence { /// Ethereum blockchain test data state. #[derive(Clone, Debug, Eq, PartialEq, Deserialize)] -pub struct State(BTreeMap); +pub struct State(pub BTreeMap); impl State { /// Write the state to the database. @@ -191,7 +191,7 @@ impl Deref for State { } /// An account. -#[derive(Debug, PartialEq, Eq, Deserialize, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Deserialize, Clone)] #[serde(deny_unknown_fields)] pub struct Account { /// Balance. @@ -213,6 +213,8 @@ impl Account { Error::Assertion(format!("Expected account ({address}) is missing from DB: {self:?}")) })?; + //println!("account: {} {:?}", address, account); + assert_equal(self.balance, account.balance, "Balance does not match")?; assert_equal(self.nonce.to(), account.nonce, "Nonce does not match")?; diff --git a/testing/ef-tests/src/result.rs b/testing/ef-tests/src/result.rs index c7a893c4cbde..1b4ece044473 100644 --- a/testing/ef-tests/src/result.rs +++ b/testing/ef-tests/src/result.rs @@ -1,6 +1,6 @@ //! Test results and errors -use crate::Case; +use crate::{case::CaseAsync, Case}; use reth_db::DatabaseError; use reth_interfaces::RethError; use std::path::{Path, PathBuf}; @@ -70,6 +70,24 @@ impl CaseResult { } } +/// The result of running a test. +#[derive(Debug)] +pub struct CaseAsyncResult { + /// A description of the test. + pub desc: String, + /// The full path to the test. + pub path: PathBuf, + /// The result of the test. + pub result: Result<(), Error>, +} + +impl CaseAsyncResult { + /// Create a new test result. + pub fn new(path: &Path, case: &impl CaseAsync, result: Result<(), Error>) -> Self { + CaseAsyncResult { desc: case.description(), path: path.into(), result } + } +} + /// Assert that all the given tests passed and print the results to stdout. pub(crate) fn assert_tests_pass(suite_name: &str, path: &Path, results: &[CaseResult]) { let (passed, failed, skipped) = categorize_results(results); diff --git a/testing/ef-tests/src/suite.rs b/testing/ef-tests/src/suite.rs index b26e129945bc..6dc9636d7fa6 100644 --- a/testing/ef-tests/src/suite.rs +++ b/testing/ef-tests/src/suite.rs @@ -1,7 +1,7 @@ //! Abstractions for groups of tests. use crate::{ - case::{Case, Cases}, + case::{Case, CaseAsync, Cases, CasesAsync}, result::assert_tests_pass, }; use std::path::{Path, PathBuf}; @@ -52,6 +52,51 @@ pub trait Suite { } } +/// A collection of tests. +pub trait SuiteAsync { + /// The type of test cases in this suite. + type CaseAsync: CaseAsync; + + /// The name of the test suite used to locate the individual test cases. + /// + /// # Example + /// + /// - `GeneralStateTests` + /// - `BlockchainTests/InvalidBlocks` + /// - `BlockchainTests/TransitionTests` + fn suite_name(&self) -> String; + + /// Load an run each contained test case. + /// + /// # Note + /// + /// This recursively finds every test description in the resulting path. + async fn run(&self) { + // Build the path to the test suite directory + let suite_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("ethereum-tests") + .join(self.suite_name()); + + // Verify that the path exists + assert!(suite_path.exists(), "Test suite path does not exist: {suite_path:?}"); + + // Find all files with the ".json" extension in the test suite directory + let test_cases = find_all_files_with_extension(&suite_path, ".json") + .into_iter() + .map(|test_case_path| { + let case = Self::CaseAsync::load(&test_case_path).expect("test case should load"); + (test_case_path, case) + }) + .collect(); + + // Run the test cases and collect the results + let results = CasesAsync { test_cases }.run().await; + + // Assert that all tests in the suite pass + //assert_tests_pass(&self.suite_name(), &suite_path, &results); + } +} + /// Recursively find all files with a given extension. fn find_all_files_with_extension(path: &Path, extension: &str) -> Vec { WalkDir::new(path) diff --git a/testing/ef-tests/tests/tests.rs b/testing/ef-tests/tests/tests.rs index afbaa2e796e7..16bd77f592b9 100644 --- a/testing/ef-tests/tests/tests.rs +++ b/testing/ef-tests/tests/tests.rs @@ -1,12 +1,15 @@ #![cfg(feature = "ef-tests")] -use ef_tests::{cases::blockchain_test::BlockchainTests, suite::Suite}; +use ef_tests::{ + cases::blockchain_test::BlockchainTests, + suite::{Suite, SuiteAsync}, +}; macro_rules! general_state_test { ($test_name:ident, $dir:ident) => { - #[test] - fn $test_name() { - BlockchainTests::new(format!("GeneralStateTests/{}", stringify!($dir))).run(); + #[tokio::test(flavor = "multi_thread")] + async fn $test_name() { + BlockchainTests::new(format!("GeneralStateTests/{}", stringify!($dir))).run().await; } }; } From 7509ce566471163b2627a73325d2763b9fd56cf4 Mon Sep 17 00:00:00 2001 From: Brechtpd Date: Thu, 23 May 2024 00:09:17 +0200 Subject: [PATCH 2/5] small changes to allow raiko to use reth for proving --- Cargo.lock | 115 ++++++++++++++++++++++------- Cargo.toml | 14 ++-- crates/ethereum/evm/src/execute.rs | 58 ++++++++++----- crates/evm/src/execute.rs | 6 +- crates/primitives/Cargo.toml | 4 + crates/primitives/src/block.rs | 2 +- crates/primitives/src/revm/env.rs | 1 + 7 files changed, 145 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index beedc502c6c5..059480ff56e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1508,6 +1508,7 @@ dependencies = [ "glob", "hex", "libc", + "serde", ] [[package]] @@ -6334,7 +6335,7 @@ dependencies = [ "raiko-primitives", "reqwest 0.11.27", "reqwest 0.12.4", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op)", "rlp", "serde", "serde_json", @@ -6376,7 +6377,7 @@ dependencies = [ "log", "once_cell", "raiko-primitives", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op)", "serde", "serde_json", "serde_with", @@ -6401,7 +6402,7 @@ dependencies = [ "anyhow", "c-kzg", "once_cell", - "revm-primitives", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op)", "rlp", "serde", "sha2 0.10.8", @@ -6836,7 +6837,7 @@ dependencies = [ "reth-revm", "reth-tasks", "reth-transaction-pool", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "tokio", "tracing", ] @@ -7269,7 +7270,7 @@ dependencies = [ "reth-primitives", "reth-rpc-types", "reth-rpc-types-compat", - "revm-primitives", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "serde", "serde_json", "sha2 0.10.8", @@ -7300,7 +7301,7 @@ dependencies = [ "reth-provider", "reth-revm", "reth-transaction-pool", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "tracing", ] @@ -7320,8 +7321,8 @@ version = "0.2.0-beta.6" dependencies = [ "reth-interfaces", "reth-primitives", - "revm", - "revm-primitives", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", ] [[package]] @@ -7333,7 +7334,7 @@ dependencies = [ "reth-primitives", "reth-provider", "reth-revm", - "revm-primitives", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "tracing", ] @@ -7346,7 +7347,7 @@ dependencies = [ "reth-primitives", "reth-provider", "reth-revm", - "revm-primitives", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "tracing", ] @@ -7786,8 +7787,8 @@ dependencies = [ "reth-rpc-types-compat", "reth-tracing", "reth-transaction-pool", - "revm", - "revm-primitives", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "serde", "serde_json", "thiserror", @@ -7819,7 +7820,7 @@ dependencies = [ "reth-rpc-types", "reth-rpc-types-compat", "reth-transaction-pool", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "sha2 0.10.8", "thiserror", "tracing", @@ -7839,7 +7840,7 @@ dependencies = [ "reth-provider", "reth-rpc-types", "reth-transaction-pool", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "serde_json", "thiserror", "tokio", @@ -7888,8 +7889,8 @@ dependencies = [ "reth-codecs", "reth-ethereum-forks", "reth-rpc-types", - "revm", - "revm-primitives", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "roaring", "secp256k1", "serde", @@ -7928,7 +7929,7 @@ dependencies = [ "reth-primitives", "reth-rpc-types", "reth-trie", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "strum", "tempfile", "tokio", @@ -7970,7 +7971,7 @@ dependencies = [ "reth-primitives", "reth-provider", "reth-trie", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "revm-inspectors", "tracing", ] @@ -8013,9 +8014,9 @@ dependencies = [ "reth-rpc-types-compat", "reth-tasks", "reth-transaction-pool", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "revm-inspectors", - "revm-primitives", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "schnellru", "secp256k1", "serde", @@ -8314,7 +8315,7 @@ dependencies = [ "reth-revm", "reth-tasks", "reth-tracing", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "rustc-hash", "schnellru", "serde", @@ -8343,7 +8344,7 @@ dependencies = [ "reth-metrics", "reth-primitives", "reth-provider", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "serde_json", "similar-asserts", "thiserror", @@ -8385,8 +8386,22 @@ dependencies = [ "auto_impl", "cfg-if", "dyn-clone", - "revm-interpreter", - "revm-precompile", + "revm-interpreter 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op)", + "revm-precompile 6.0.0 (git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op)", + "serde", + "serde_json", +] + +[[package]] +name = "revm" +version = "8.0.0" +source = "git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2#a5c01f345f4362f4d5d8bbddf37e9d8aeb27b0d3" +dependencies = [ + "auto_impl", + "cfg-if", + "dyn-clone", + "revm-interpreter 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", + "revm-precompile 6.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "serde", "serde_json", ] @@ -8404,7 +8419,7 @@ dependencies = [ "boa_engine", "boa_gc", "colorchoice", - "revm", + "revm 8.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "serde_json", "thiserror", ] @@ -8414,7 +8429,16 @@ name = "revm-interpreter" version = "4.0.0" source = "git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op#2733b062c075d11f09b15138be9a47801fa3c775" dependencies = [ - "revm-primitives", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op)", + "serde", +] + +[[package]] +name = "revm-interpreter" +version = "4.0.0" +source = "git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2#a5c01f345f4362f4d5d8bbddf37e9d8aeb27b0d3" +dependencies = [ + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "serde", ] @@ -8428,7 +8452,24 @@ dependencies = [ "cfg-if", "k256", "once_cell", - "revm-primitives", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=feat/zk-op)", + "ripemd", + "secp256k1", + "sha2 0.10.8", + "substrate-bn", +] + +[[package]] +name = "revm-precompile" +version = "6.0.0" +source = "git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2#a5c01f345f4362f4d5d8bbddf37e9d8aeb27b0d3" +dependencies = [ + "aurora-engine-modexp", + "c-kzg-taiko", + "cfg-if", + "k256", + "once_cell", + "revm-primitives 3.1.1 (git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2)", "ripemd", "secp256k1", "sha2 0.10.8", @@ -8455,6 +8496,26 @@ dependencies = [ "serde", ] +[[package]] +name = "revm-primitives" +version = "3.1.1" +source = "git+https://github.com/taikoxyz/revm.git?branch=v35_taiko_v2#a5c01f345f4362f4d5d8bbddf37e9d8aeb27b0d3" +dependencies = [ + "alloy-primitives", + "auto_impl", + "bitflags 2.5.0", + "bitvec", + "c-kzg-taiko", + "cfg-if", + "derive_more", + "dyn-clone", + "enumn", + "hashbrown 0.14.3", + "hex", + "once_cell", + "serde", +] + [[package]] name = "rfc6979" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 18e8b1d90696..cb18a22aa973 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -279,8 +279,8 @@ reth-node-events = { path = "crates/node/events" } reth-testing-utils = { path = "testing/testing-utils" } # revm -revm = { version = "8.0.0", features = ["std", "secp256k1"], default-features = false } -revm-primitives = { version = "3.1.1", features = ["std"], default-features = false } +revm = { version = "8.0.0", features = ["std", "secp256k1", "taiko"], default-features = false } +revm-primitives = { version = "3.1.1", features = ["std", "taiko"], default-features = false } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "848d568" } # eth @@ -411,9 +411,13 @@ alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "175_4e2 alloy-rpc-types-trace = { git = "https://github.com/brechtpd/alloy", branch = "175_4e22b9e" } [patch.crates-io] -revm = { git = "https://github.com/taikoxyz/revm.git", branch = "feat/zk-op", default-features = false, features = [ +revm = { git = "https://github.com/taikoxyz/revm.git", branch = "v35_taiko_v2", default-features = false, features = [ "std", "serde", - "taiko", + #"taiko", ]} -revm-primitives = { git = "https://github.com/taikoxyz/revm.git", branch = "feat/zk-op", default-features = false } \ No newline at end of file +revm-primitives = { git = "https://github.com/taikoxyz/revm.git", branch = "v35_taiko_v2", default-features = false, features = [ + #"std", + #"serde", + #"taiko", +]} \ No newline at end of file diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index 64b69d1e577c..e9ec77881a39 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -27,8 +27,7 @@ use reth_revm::{ Evm, State, }; use revm_primitives::{ - db::{Database, DatabaseCommit}, - BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, + db::{Database, DatabaseCommit}, Address, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, HashMap, ResultAndState }; use std::sync::Arc; use tracing::debug; @@ -73,7 +72,7 @@ where EvmConfig: ConfigureEvm, EvmConfig: ConfigureEvmEnv, { - fn eth_executor(&self, db: DB) -> EthBlockExecutor + pub fn eth_executor(&self, db: DB) -> EthBlockExecutor where DB: Database, { @@ -140,6 +139,7 @@ where &mut self, block: &BlockWithSenders, mut evm: Evm<'_, Ext, &mut State>, + optimistic: bool, ) -> Result<(Vec, u64), BlockExecutionError> where DB: Database, @@ -161,6 +161,9 @@ where // must be no greater than the block’s gasLimit. let block_available_gas = block.header.gas_limit - cumulative_gas_used; if transaction.gas_limit() > block_available_gas { + if optimistic { + continue; + } return Err(BlockValidationError::TransactionGasLimitMoreThanAvailableBlockGas { transaction_gas_limit: transaction.gas_limit(), block_available_gas, @@ -171,13 +174,17 @@ where EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender, ()); // Execute transaction. - let ResultAndState { result, state } = evm.transact().map_err(move |err| { + let res = evm.transact().map_err(move |err| { // Ensure hash is calculated for error log, if not already done BlockValidationError::EVM { hash: transaction.recalculate_hash(), error: err.into(), } - })?; + }); + if optimistic && res.is_err() { + continue; + } + let ResultAndState { result, state } = res?; evm.db_mut().commit(state); // append gas used @@ -200,14 +207,16 @@ where } drop(evm); - // Check if gas used matches the value set in header. - if block.gas_used != cumulative_gas_used { - let receipts = Receipts::from_block_receipt(receipts); - return Err(BlockValidationError::BlockGasUsed { - gas: GotExpected { got: cumulative_gas_used, expected: block.gas_used }, - gas_spent_by_tx: receipts.gas_spent_by_tx()?, + if !optimistic { + // Check if gas used matches the value set in header. + if block.gas_used != cumulative_gas_used { + let receipts = Receipts::from_block_receipt(receipts); + return Err(BlockValidationError::BlockGasUsed { + gas: GotExpected { got: cumulative_gas_used, expected: block.gas_used }, + gas_spent_by_tx: receipts.gas_spent_by_tx()?, + } + .into()) } - .into()) } Ok((receipts, cumulative_gas_used)) @@ -227,12 +236,14 @@ pub struct EthBlockExecutor { state: State, /// Optional inspector stack for debugging inspector: Option, + /// Allows the execution to continue even when a tx is invalid + optimistic: bool, } impl EthBlockExecutor { /// Creates a new Ethereum block executor. pub fn new(chain_spec: Arc, evm_config: EvmConfig, state: State) -> Self { - Self { executor: EthEvmExecutor { chain_spec, evm_config }, state, inspector: None } + Self { executor: EthEvmExecutor { chain_spec, evm_config }, state, inspector: None, optimistic: false } } /// Sets the inspector stack for debugging. @@ -241,6 +252,12 @@ impl EthBlockExecutor { self } + /// Optimistic execution + pub fn optimistic(mut self, optimistic: bool) -> Self { + self.optimistic = optimistic; + self + } + #[inline] fn chain_spec(&self) -> &ChainSpec { &self.executor.chain_spec @@ -248,7 +265,7 @@ impl EthBlockExecutor { /// Returns mutable reference to the state that wraps the underlying database. #[allow(unused)] - fn state_mut(&mut self) -> &mut State { + pub fn state_mut(&mut self) -> &mut State { &mut self.state } } @@ -302,11 +319,11 @@ where env, inspector, ); - self.executor.execute_pre_and_transactions(block, evm)? + self.executor.execute_pre_and_transactions(block, evm, self.optimistic)? } else { let evm = self.executor.evm_config.evm_with_env(&mut self.state, env); - self.executor.execute_pre_and_transactions(block, evm)? + self.executor.execute_pre_and_transactions(block, evm, self.optimistic)? } }; @@ -317,7 +334,7 @@ where // operation as hashing that is required for state root got calculated in every // transaction This was replaced with is_success flag. // See more about EIP here: https://eips.ethereum.org/EIPS/eip-658 - if self.chain_spec().is_byzantium_active_at_block(block.header.number) { + if !self.optimistic && self.chain_spec().is_byzantium_active_at_block(block.header.number) { if let Err(error) = verify_receipt(block.header.receipts_root, block.header.logs_bloom, receipts.iter()) { @@ -367,9 +384,10 @@ where // return balance to DAO beneficiary. *balance_increments.entry(DAO_HARDFORK_BENEFICIARY).or_default() += drained_balance; } + // increment balances self.state - .increment_balances(balance_increments) + .increment_balances(balance_increments.clone()) .map_err(|_| BlockValidationError::IncrementBalanceFailed)?; Ok(()) @@ -383,7 +401,7 @@ where DB: Database, { type Input<'a> = EthBlockExecutionInput<'a, BlockWithSenders>; - type Output = EthBlockOutput; + type Output = EthBlockOutput; type Error = BlockExecutionError; /// Executes the block and commits the state changes. @@ -400,7 +418,7 @@ where // prepare the state for extraction self.state.merge_transitions(BundleRetention::PlainState); - Ok(EthBlockOutput { state: self.state.take_bundle(), receipts, gas_used }) + Ok(EthBlockOutput { state: self.state.take_bundle(), receipts, gas_used, db: self.state }) } } diff --git a/crates/evm/src/execute.rs b/crates/evm/src/execute.rs index b8c1536029a9..e5bd0004526f 100644 --- a/crates/evm/src/execute.rs +++ b/crates/evm/src/execute.rs @@ -2,7 +2,7 @@ use reth_interfaces::provider::ProviderError; use reth_primitives::U256; -use revm::db::BundleState; +use revm::db::{BundleState, State}; use revm_primitives::db::Database; /// A general purpose executor trait that executes on an input (e.g. blocks) and produces an output @@ -51,13 +51,15 @@ pub struct BatchBlockOutput { /// /// TODO(mattsse): combine with BundleStateWithReceipts #[derive(Debug)] -pub struct EthBlockOutput { +pub struct EthBlockOutput { /// The changed state of the block after execution. pub state: BundleState, /// All the receipts of the transactions in the block. pub receipts: Vec, /// The total gas used by the block. pub gas_used: u64, + /// The full state. + pub db: State, } /// A helper type for ethereum block inputs that consists of a block and the total difficulty. diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index deaee2300683..c7b72014cd65 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -113,6 +113,10 @@ optimism = [ "reth-ethereum-forks/optimism", "revm/optimism", ] +taiko = [ + "revm-primitives/taiko", + "revm/taiko", +] test-utils = ["dep:plain_hasher", "dep:hash-db"] [[bench]] diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 864e7954f58b..b2b8dc5aac45 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -167,7 +167,7 @@ impl TryFrom for Block { s: signature.s, odd_y_parity: signature .y_parity - .unwrap_or(reth_rpc_types::Parity(false)) + .unwrap_or_else(|| reth_rpc_types::Parity(!signature.v.bit(0))) .0, }, )) diff --git a/crates/primitives/src/revm/env.rs b/crates/primitives/src/revm/env.rs index 3979b52b7ed7..ed4ab200ce5d 100644 --- a/crates/primitives/src/revm/env.rs +++ b/crates/primitives/src/revm/env.rs @@ -171,6 +171,7 @@ pub fn fill_tx_env_with_beacon_root_contract_call(env: &mut Env, parent_beacon_b // enveloped tx size. enveloped_tx: Some(Bytes::default()), }, + //#[cfg(feature = "taiko")] taiko: revm_primitives::TaikoFields { treasury: Address::default(), is_anchor: false }, }; From fbd1411637f5d30bc6b72e33010a4cbbe085d9e1 Mon Sep 17 00:00:00 2001 From: brechtpd Date: Fri, 31 May 2024 13:50:53 +0700 Subject: [PATCH 3/5] basic taiko support --- Cargo.toml | 12 ++--- crates/ethereum/evm/src/execute.rs | 9 ++++ crates/ethereum/evm/src/lib.rs | 1 + crates/evm/src/lib.rs | 11 +++-- crates/primitives/src/chain/mod.rs | 2 +- crates/primitives/src/chain/spec.rs | 68 ++++++++++++++++++++++++++++ crates/primitives/src/lib.rs | 2 +- crates/revm/Cargo.toml | 4 ++ crates/revm/src/test_utils.rs | 4 ++ crates/rpc/rpc/src/eth/revm_utils.rs | 2 +- 10 files changed, 103 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cb18a22aa973..300b5f22f4e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -279,8 +279,8 @@ reth-node-events = { path = "crates/node/events" } reth-testing-utils = { path = "testing/testing-utils" } # revm -revm = { version = "8.0.0", features = ["std", "secp256k1", "taiko"], default-features = false } -revm-primitives = { version = "3.1.1", features = ["std", "taiko"], default-features = false } +revm = { version = "8.0.0", features = ["std", "secp256k1"], default-features = false } +revm-primitives = { version = "3.1.1", features = ["std"], default-features = false } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "848d568" } # eth @@ -414,10 +414,10 @@ alloy-rpc-types-trace = { git = "https://github.com/brechtpd/alloy", branch = "1 revm = { git = "https://github.com/taikoxyz/revm.git", branch = "v35_taiko_v2", default-features = false, features = [ "std", "serde", - #"taiko", + "taiko", ]} revm-primitives = { git = "https://github.com/taikoxyz/revm.git", branch = "v35_taiko_v2", default-features = false, features = [ - #"std", - #"serde", - #"taiko", + "std", + "serde", + "taiko", ]} \ No newline at end of file diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index e9ec77881a39..ae480ee958ff 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -144,6 +144,8 @@ where where DB: Database, { + let is_taiko = self.chain_spec.is_taiko(); + // apply pre execution changes apply_beacon_root_contract_call( &self.chain_spec, @@ -156,6 +158,7 @@ where // execute transactions let mut cumulative_gas_used = 0; let mut receipts = Vec::with_capacity(block.body.len()); + let mut tx_number = 0; for (sender, transaction) in block.transactions_with_sender() { // The sum of the transaction’s gas limit, Tg, and the gas utilized in this block prior, // must be no greater than the block’s gasLimit. @@ -172,6 +175,12 @@ where } EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender, ()); + if is_taiko && tx_number == 0 { + evm.tx_mut().taiko.is_anchor = true; + // set the treasury address + //tx_env.taiko.treasury = chain_spec.l2_contract.unwrap_or_default(); + } + tx_number += 1; // Execute transaction. let res = evm.transact().map_err(move |err| { diff --git a/crates/ethereum/evm/src/lib.rs b/crates/ethereum/evm/src/lib.rs index a320a2b3c62a..84572d64ae84 100644 --- a/crates/ethereum/evm/src/lib.rs +++ b/crates/ethereum/evm/src/lib.rs @@ -52,6 +52,7 @@ impl ConfigureEvmEnv for EthEvmConfig { cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Analyse; cfg_env.handler_cfg.spec_id = spec_id; + cfg_env.handler_cfg.is_taiko = chain_spec.is_taiko(); } } diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index 78a76e54ccd5..19cb88517226 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -21,8 +21,13 @@ pub trait ConfigureEvm: ConfigureEvmEnv { /// This does not automatically configure the EVM with [ConfigureEvmEnv] methods. It is up to /// the caller to call an appropriate method to fill the transaction and block environment /// before executing any transactions using the provided EVM. - fn evm<'a, DB: Database + 'a>(&self, db: DB) -> Evm<'a, (), DB> { - EvmBuilder::default().with_db(db).build() + fn evm<'a, DB: Database + 'a>(&self, db: DB, is_taiko: bool) -> Evm<'a, (), DB> { + let builder = EvmBuilder::default().with_db(db); + if is_taiko { + builder.append_handler_register(revm::taiko::handler_register::taiko_handle_register).build() + } else { + builder.build() + } } /// Returns a new EVM with the given database configured with the given environment settings, @@ -34,7 +39,7 @@ pub trait ConfigureEvm: ConfigureEvmEnv { db: DB, env: EnvWithHandlerCfg, ) -> Evm<'a, (), DB> { - let mut evm = self.evm(db); + let mut evm = self.evm(db, env.handler_cfg.is_taiko); evm.modify_spec_id(env.spec_id()); evm.context.evm.env = env.env; evm diff --git a/crates/primitives/src/chain/mod.rs b/crates/primitives/src/chain/mod.rs index f8425f95e663..5cd3bb895a78 100644 --- a/crates/primitives/src/chain/mod.rs +++ b/crates/primitives/src/chain/mod.rs @@ -3,7 +3,7 @@ pub use info::ChainInfo; pub use spec::{ AllGenesisFormats, BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DisplayHardforks, ForkBaseFeeParams, ForkCondition, ForkTimestamps, DEV, GOERLI, HOLESKY, - MAINNET, SEPOLIA, + MAINNET, SEPOLIA, TAIKO_A7, }; #[cfg(feature = "optimism")] pub use spec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA}; diff --git a/crates/primitives/src/chain/spec.rs b/crates/primitives/src/chain/spec.rs index 4ce26f84b84e..2dd1616a8021 100644 --- a/crates/primitives/src/chain/spec.rs +++ b/crates/primitives/src/chain/spec.rs @@ -14,6 +14,7 @@ use std::{ fmt::{Display, Formatter}, sync::Arc, }; +use alloy_chains::ChainKind::Id; pub use alloy_eips::eip1559::BaseFeeParams; @@ -78,6 +79,66 @@ pub static MAINNET: Lazy> = Lazy::new(|| { .into() }); +/// The Taiko A7 spec +pub static TAIKO_A7: Lazy> = Lazy::new(|| { + ChainSpec { + chain: 167009.into(), + genesis: serde_json::from_str(include_str!("../../res/genesis/mainnet.json")) + .expect("Can't deserialize Mainnet genesis json"), + genesis_hash: Some(b256!( + "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" + )), + // + paris_block_and_final_difficulty: Some(( + 15537394, + U256::from(58_750_003_716_598_352_816_469u128), + )), + fork_timestamps: ForkTimestamps::default().shanghai(0), + hardforks: BTreeMap::from([ + (Hardfork::Shanghai, ForkCondition::Block(0)), + ]), + // https://etherscan.io/tx/0xe75fb554e433e03763a1560646ee22dcb74e5274b34c5ad644e7c0f619a7e1d0 + deposit_contract: Some(DepositContract::new( + address!("00000000219ab540356cbb839cbe05303d7705fa"), + 11052984, + b256!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"), + )), + base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()), + prune_delete_limit: 3500, + } + .into() +}); + +/// The Taiko A7 spec +pub static TAIKO_MAINNET: Lazy> = Lazy::new(|| { + ChainSpec { + chain: 167000.into(), + genesis: serde_json::from_str(include_str!("../../res/genesis/mainnet.json")) + .expect("Can't deserialize Mainnet genesis json"), + genesis_hash: Some(b256!( + "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" + )), + // + paris_block_and_final_difficulty: Some(( + 15537394, + U256::from(58_750_003_716_598_352_816_469u128), + )), + fork_timestamps: ForkTimestamps::default().shanghai(1681338455).cancun(1710338135), + hardforks: BTreeMap::from([ + (Hardfork::Shanghai, ForkCondition::Block(0)), + ]), + // https://etherscan.io/tx/0xe75fb554e433e03763a1560646ee22dcb74e5274b34c5ad644e7c0f619a7e1d0 + deposit_contract: Some(DepositContract::new( + address!("00000000219ab540356cbb839cbe05303d7705fa"), + 11052984, + b256!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"), + )), + base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()), + prune_delete_limit: 3500, + } + .into() +}); + /// The Goerli spec pub static GOERLI: Lazy> = Lazy::new(|| { ChainSpec { @@ -583,6 +644,13 @@ impl ChainSpec { self.chain.is_optimism() } + /// Returns `true` if this chain contains Taiko configuration. + #[inline] + pub fn is_taiko(&self) -> bool { + let id = self.chain.id(); + id >= 167000 && id <= 168000 + } + /// Returns `true` if this chain is Optimism mainnet. #[inline] pub fn is_optimism_mainnet(&self) -> bool { diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 1c8808628817..7dbebbbfc247 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -57,7 +57,7 @@ pub use block::{ pub use chain::{ AllGenesisFormats, BaseFeeParams, BaseFeeParamsKind, Chain, ChainInfo, ChainSpec, ChainSpecBuilder, DisplayHardforks, ForkBaseFeeParams, ForkCondition, ForkTimestamps, - NamedChain, DEV, GOERLI, HOLESKY, MAINNET, SEPOLIA, + NamedChain, DEV, GOERLI, HOLESKY, MAINNET, SEPOLIA, TAIKO_A7, }; #[cfg(feature = "zstd-codec")] pub use compression::*; diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index 5c62f324eb10..04fa792f0a4f 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -39,4 +39,8 @@ optimism = [ "reth-consensus-common/optimism", "reth-interfaces/optimism", ] +taiko = [ + "revm/taiko", + "reth-primitives/taiko", +] js-tracer = ["revm-inspectors/js-tracer"] diff --git a/crates/revm/src/test_utils.rs b/crates/revm/src/test_utils.rs index 193736987232..ea249390bfb3 100644 --- a/crates/revm/src/test_utils.rs +++ b/crates/revm/src/test_utils.rs @@ -154,6 +154,10 @@ impl ConfigureEvmEnv for TestEvmConfig { { cfg_env.handler_cfg.is_optimism = chain_spec.is_optimism(); } + #[cfg(feature = "taiko")] + { + cfg_env.handler_cfg.is_taiko = chain_spec.is_taiko(); + } } } diff --git a/crates/rpc/rpc/src/eth/revm_utils.rs b/crates/rpc/rpc/src/eth/revm_utils.rs index d0dc43471f80..e308e48613b8 100644 --- a/crates/rpc/rpc/src/eth/revm_utils.rs +++ b/crates/rpc/rpc/src/eth/revm_utils.rs @@ -272,7 +272,7 @@ pub(crate) fn create_txn_env( max_fee_per_blob_gas, #[cfg(feature = "optimism")] optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, - taiko: revm_primitives::TaikoFields { treasury: Address::default(), is_anchor: false }, + taiko: revm_primitives::TaikoFields { treasury: address!(0x1670090000000000000000000000000000010001), is_anchor: false }, }; Ok(env) From 33fa26473baca03930f2d42a9ada714f9bd81325 Mon Sep 17 00:00:00 2001 From: brechtpd Date: Mon, 10 Jun 2024 01:04:58 +0200 Subject: [PATCH 4/5] better invalid tx support --- crates/ethereum/evm/src/execute.rs | 53 ++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index ae480ee958ff..bd9111b0fc2e 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -31,6 +31,10 @@ use revm_primitives::{ }; use std::sync::Arc; use tracing::debug; +use revm_primitives::address; +use revm_primitives::EVMError; +use reth_revm::JournaledState; +use revm_primitives::HashSet; /// Provides executors to execute regular ethereum blocks #[derive(Debug, Clone)] @@ -160,6 +164,8 @@ where let mut receipts = Vec::with_capacity(block.body.len()); let mut tx_number = 0; for (sender, transaction) in block.transactions_with_sender() { + //println!("tx: {:?}", tx_number); + // The sum of the transaction’s gas limit, Tg, and the gas utilized in this block prior, // must be no greater than the block’s gasLimit. let block_available_gas = block.header.gas_limit - cumulative_gas_used; @@ -175,11 +181,14 @@ where } EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender, ()); - if is_taiko && tx_number == 0 { - evm.tx_mut().taiko.is_anchor = true; - // set the treasury address - //tx_env.taiko.treasury = chain_spec.l2_contract.unwrap_or_default(); - } + + let is_anchor = is_taiko && tx_number == 0; + + evm.tx_mut().taiko.is_anchor = is_anchor; + // set the treasury address + //tx_env.taiko.treasury = chain_spec.l2_contract.unwrap_or_default(); + evm.tx_mut().taiko.treasury = address!("1670090000000000000000000000000000010001"); + tx_number += 1; // Execute transaction. @@ -190,8 +199,38 @@ where error: err.into(), } }); - if optimistic && res.is_err() { - continue; + if res.is_err() { + + // Clear the state for the next tx + evm.context.evm.journaled_state = JournaledState::new(evm.context.evm.journaled_state.spec, HashSet::new()); + + if optimistic { + continue; + } + + if !is_taiko || is_anchor { + return Err(BlockExecutionError::Validation(res.err().unwrap())); + } + // only continue for invalid tx errors, not db errors (because those can be + // manipulated by the prover) + match res { + Err(BlockValidationError::EVM { hash, error }) => match *error { + EVMError::Transaction(invalid_transaction) => { + //#[cfg(feature = "std")] + println!("Invalid tx at {}: {:?}", tx_number, invalid_transaction); + // skip the tx + continue; + }, + _ => { + // any other error is not allowed + return Err(BlockExecutionError::Validation(BlockValidationError::EVM { hash, error })); + }, + }, + _ => { + // Any other type of error is not allowed + return Err(BlockExecutionError::Validation(res.err().unwrap())); + } + } } let ResultAndState { result, state } = res?; evm.db_mut().commit(state); From 527c3427376bbdf6776a26927ba0baa43837161e Mon Sep 17 00:00:00 2001 From: brechtpd Date: Fri, 14 Jun 2024 02:59:45 +0200 Subject: [PATCH 5/5] added full verification of taiko blocks --- Cargo.toml | 1 + crates/ethereum/evm/Cargo.toml | 3 + crates/ethereum/evm/src/execute.rs | 58 ++++++--- crates/ethereum/evm/src/lib.rs | 1 + crates/ethereum/evm/src/taiko.rs | 145 +++++++++++++++++++++++ crates/interfaces/src/provider.rs | 3 + crates/primitives/src/chain/mod.rs | 2 +- crates/primitives/src/chain/spec.rs | 77 ++++++------ crates/primitives/src/lib.rs | 2 +- crates/primitives/src/transaction/mod.rs | 18 +-- 10 files changed, 245 insertions(+), 65 deletions(-) create mode 100644 crates/ethereum/evm/src/taiko.rs diff --git a/Cargo.toml b/Cargo.toml index 300b5f22f4e1..f151988ab386 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -340,6 +340,7 @@ smallvec = "1" dyn-clone = "1.0.17" sha2 = { version = "0.10", default-features = false } paste = "1.0" +lazy_static = "1.4.0" # proc-macros proc-macro2 = "1.0" diff --git a/crates/ethereum/evm/Cargo.toml b/crates/ethereum/evm/Cargo.toml index ea7cfab8c236..47423f7b22bd 100644 --- a/crates/ethereum/evm/Cargo.toml +++ b/crates/ethereum/evm/Cargo.toml @@ -20,9 +20,12 @@ reth-provider.workspace = true # Ethereum revm-primitives.workspace = true +alloy-sol-types.workspace = true # misc tracing.workspace = true +anyhow.workspace = true +lazy_static.workspace = true [dev-dependencies] reth-revm = { workspace = true, features = ["test-utils"] } \ No newline at end of file diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index bd9111b0fc2e..e90e634a764c 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -1,6 +1,6 @@ //! Ethereum block executor. -use crate::EthEvmConfig; +use crate::{taiko::{check_anchor_tx, TaikoData}, EthEvmConfig}; use reth_evm::{ execute::{ BatchBlockOutput, BatchExecutor, EthBlockExecutionInput, EthBlockOutput, Executor, @@ -13,8 +13,7 @@ use reth_interfaces::{ provider::ProviderError, }; use reth_primitives::{ - BlockWithSenders, ChainSpec, GotExpected, Hardfork, Header, PruneModes, Receipt, Receipts, - Withdrawals, U256, + BlockWithSenders, ChainSpec, GotExpected, Hardfork, Header, PruneModes, Receipt, Receipts, Withdrawals, U256 }; use reth_provider::BundleStateWithReceipts; use reth_revm::{ @@ -27,14 +26,14 @@ use reth_revm::{ Evm, State, }; use revm_primitives::{ - db::{Database, DatabaseCommit}, Address, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, HashMap, ResultAndState + db::{Database, DatabaseCommit}, Address, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState }; use std::sync::Arc; use tracing::debug; -use revm_primitives::address; use revm_primitives::EVMError; use reth_revm::JournaledState; use revm_primitives::HashSet; +use anyhow::Result; /// Provides executors to execute regular ethereum blocks #[derive(Debug, Clone)] @@ -144,6 +143,7 @@ where block: &BlockWithSenders, mut evm: Evm<'_, Ext, &mut State>, optimistic: bool, + taiko_data: Option, ) -> Result<(Vec, u64), BlockExecutionError> where DB: Database, @@ -162,10 +162,28 @@ where // execute transactions let mut cumulative_gas_used = 0; let mut receipts = Vec::with_capacity(block.body.len()); - let mut tx_number = 0; - for (sender, transaction) in block.transactions_with_sender() { + for (idx, (sender, transaction)) in block.transactions_with_sender().enumerate() { //println!("tx: {:?}", tx_number); + let is_anchor = is_taiko && idx == 0; + + // verify the anchor tx + if is_anchor { + check_anchor_tx(transaction, sender, &block.block, taiko_data.clone().unwrap()) + .map_err(|e| BlockExecutionError::CanonicalRevert { inner: e.to_string() })?; + } + + // if the signature was not valid, the sender address will have been set to zero + if *sender == Address::ZERO { + // Signature can be invalid if not taiko or not the anchor tx + if is_taiko && !is_anchor { + // If the signature is not valid, skip the transaction + continue; + } + // In all other cases, the tx needs to have a valid signature + return Err(BlockExecutionError::CanonicalRevert { inner: "invalid tx".to_string() }); + } + // The sum of the transaction’s gas limit, Tg, and the gas utilized in this block prior, // must be no greater than the block’s gasLimit. let block_available_gas = block.header.gas_limit - cumulative_gas_used; @@ -182,14 +200,10 @@ where EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender, ()); - let is_anchor = is_taiko && tx_number == 0; - + // Set taiko specific data evm.tx_mut().taiko.is_anchor = is_anchor; // set the treasury address - //tx_env.taiko.treasury = chain_spec.l2_contract.unwrap_or_default(); - evm.tx_mut().taiko.treasury = address!("1670090000000000000000000000000000010001"); - - tx_number += 1; + evm.tx_mut().taiko.treasury = taiko_data.clone().unwrap().l2_contract; // Execute transaction. let res = evm.transact().map_err(move |err| { @@ -200,7 +214,6 @@ where } }); if res.is_err() { - // Clear the state for the next tx evm.context.evm.journaled_state = JournaledState::new(evm.context.evm.journaled_state.spec, HashSet::new()); @@ -216,8 +229,7 @@ where match res { Err(BlockValidationError::EVM { hash, error }) => match *error { EVMError::Transaction(invalid_transaction) => { - //#[cfg(feature = "std")] - println!("Invalid tx at {}: {:?}", tx_number, invalid_transaction); + println!("Invalid tx at {}: {:?}", idx, invalid_transaction); // skip the tx continue; }, @@ -286,12 +298,14 @@ pub struct EthBlockExecutor { inspector: Option, /// Allows the execution to continue even when a tx is invalid optimistic: bool, + /// Taiko data + taiko_data: Option, } impl EthBlockExecutor { /// Creates a new Ethereum block executor. pub fn new(chain_spec: Arc, evm_config: EvmConfig, state: State) -> Self { - Self { executor: EthEvmExecutor { chain_spec, evm_config }, state, inspector: None, optimistic: false } + Self { executor: EthEvmExecutor { chain_spec, evm_config }, state, inspector: None, optimistic: false, taiko_data: None } } /// Sets the inspector stack for debugging. @@ -300,6 +314,12 @@ impl EthBlockExecutor { self } + /// Optimistic execution + pub fn taiko_data(mut self, taiko_data: TaikoData) -> Self { + self.taiko_data = Some(taiko_data); + self + } + /// Optimistic execution pub fn optimistic(mut self, optimistic: bool) -> Self { self.optimistic = optimistic; @@ -367,11 +387,11 @@ where env, inspector, ); - self.executor.execute_pre_and_transactions(block, evm, self.optimistic)? + self.executor.execute_pre_and_transactions(block, evm, self.optimistic, self.taiko_data.clone())? } else { let evm = self.executor.evm_config.evm_with_env(&mut self.state, env); - self.executor.execute_pre_and_transactions(block, evm, self.optimistic)? + self.executor.execute_pre_and_transactions(block, evm, self.optimistic, self.taiko_data.clone())? } }; diff --git a/crates/ethereum/evm/src/lib.rs b/crates/ethereum/evm/src/lib.rs index 84572d64ae84..7fe587064730 100644 --- a/crates/ethereum/evm/src/lib.rs +++ b/crates/ethereum/evm/src/lib.rs @@ -15,6 +15,7 @@ use reth_primitives::{ Address, ChainSpec, Head, Header, Transaction, U256, }; pub mod execute; +pub mod taiko; /// Ethereum-related EVM configuration. #[derive(Debug, Clone, Copy, Default)] diff --git a/crates/ethereum/evm/src/taiko.rs b/crates/ethereum/evm/src/taiko.rs new file mode 100644 index 000000000000..333a50b68fd8 --- /dev/null +++ b/crates/ethereum/evm/src/taiko.rs @@ -0,0 +1,145 @@ +//! Taiko related functionality for the block executor. + +use reth_primitives::{Block, Header, TransactionSigned, TxKind}; +use revm_primitives::{alloy_primitives::uint, Address, U256}; +use std::str::FromStr; +use lazy_static::lazy_static; +use anyhow::{bail, Context, Result, ensure, anyhow}; + +#[derive(Clone, Debug, Default)] +pub struct TaikoData { + /// header + pub l1_header: Header, + /// parent L1 header + pub parent_header: Header, + /// L2 contract + pub l2_contract: Address, +} + +/// Anchor tx gas limit +pub const ANCHOR_GAS_LIMIT: u64 = 250_000; + +lazy_static! { + pub static ref GOLDEN_TOUCH_ACCOUNT: Address = { + Address::from_str("0x0000777735367b36bC9B61C50022d9D0700dB4Ec") + .expect("invalid golden touch account") + }; + static ref GX1: U256 = + uint!(0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798_U256); + static ref N: U256 = + uint!(0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141_U256); + static ref GX1_MUL_PRIVATEKEY: U256 = + uint!(0x4341adf5a780b4a87939938fd7a032f6e6664c7da553c121d3b4947429639122_U256); + static ref GX2: U256 = + uint!(0xc6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5_U256); +} + + +/// check the anchor signature with fixed K value +fn check_anchor_signature(anchor: &TransactionSigned) -> Result<()> { + let sign = anchor.signature(); + if sign.r == *GX1 { + return Ok(()); + } + let msg_hash = anchor.signature_hash(); + let msg_hash: U256 = msg_hash.into(); + if sign.r == *GX2 { + // when r == GX2 require s == 0 if k == 1 + // alias: when r == GX2 require N == msg_hash + *GX1_MUL_PRIVATEKEY + if *N != msg_hash + *GX1_MUL_PRIVATEKEY { + bail!( + "r == GX2, but N != msg_hash + *GX1_MUL_PRIVATEKEY, N: {}, msg_hash: {msg_hash}, *GX1_MUL_PRIVATEKEY: {}", + *N, *GX1_MUL_PRIVATEKEY + ); + } + return Ok(()); + } + Err(anyhow!( + "r != *GX1 && r != GX2, r: {}, *GX1: {}, GX2: {}", + sign.r, + *GX1, + *GX2 + )) +} + +use alloy_sol_types::{sol, SolCall}; + +/// Anchor call solidity code +sol! { + /// Anchor call + function anchor( + bytes32 l1Hash, + bytes32 l1StateRoot, + uint64 l1BlockId, + uint32 parentGasUsed + ) + external + {} +} + +/// Decode anchor tx data +pub fn decode_anchor(bytes: &[u8]) -> Result { + anchorCall::abi_decode(bytes, true).map_err(|e| anyhow!(e)) + // .context("Invalid anchor call") +} + +/// Verifies the anchor tx correctness +pub fn check_anchor_tx(tx: &TransactionSigned, from: &Address, block: &Block, taiko_data: TaikoData) -> Result<()> { + let anchor = tx.as_eip1559().context(anyhow!("anchor tx is not an EIP1559 tx"))?; + + // Check the signature + check_anchor_signature(tx).context(anyhow!("failed to check anchor signature"))?; + + // Extract the `to` address + let TxKind::Call(to) = anchor.to else { + panic!("anchor tx not a smart contract call") + }; + // Check that it's from the golden touch address + ensure!( + *from == *GOLDEN_TOUCH_ACCOUNT, + "anchor transaction from mismatch" + ); + // Check that the L2 contract is being called + ensure!( + to == taiko_data.l2_contract, + "anchor transaction to mismatch" + ); + // Tx can't have any ETH attached + ensure!( + anchor.value == U256::from(0), + "anchor transaction value mismatch" + ); + // Tx needs to have the expected gas limit + ensure!( + anchor.gas_limit == ANCHOR_GAS_LIMIT, + "anchor transaction gas price mismatch" + ); + // Check needs to have the base fee set to the block base fee + ensure!( + anchor.max_fee_per_gas == block.header.base_fee_per_gas.unwrap().into(), + "anchor transaction gas mismatch" + ); + + // Okay now let's decode the anchor tx to verify the inputs + let anchor_call = decode_anchor(&anchor.input)?; + // The L1 blockhash needs to match the expected value + ensure!( + anchor_call.l1Hash == taiko_data.l1_header.hash_slow(), + "L1 hash mismatch" + ); + ensure!( + anchor_call.l1StateRoot == taiko_data.l1_header.state_root, + "L1 state root mismatch" + ); + ensure!( + anchor_call.l1BlockId == taiko_data.l1_header.number, + "L1 block number mismatch" + ); + // The parent gas used input needs to match the gas used value of the parent block + ensure!( + anchor_call.parentGasUsed == taiko_data.parent_header.gas_used as u32, + "parentGasUsed mismatch" + ); + + Ok(()) +} \ No newline at end of file diff --git a/crates/interfaces/src/provider.rs b/crates/interfaces/src/provider.rs index 7221c0cdfc9d..7fee5e6acc1c 100644 --- a/crates/interfaces/src/provider.rs +++ b/crates/interfaces/src/provider.rs @@ -128,6 +128,9 @@ pub enum ProviderError { /// Consistent view error. #[error("failed to initialize consistent view: {0}")] ConsistentView(Box), + /// RPC error. + #[error("failed to fetch data from RPC: {0}")] + RPC(String), } impl From for ProviderError { diff --git a/crates/primitives/src/chain/mod.rs b/crates/primitives/src/chain/mod.rs index 5cd3bb895a78..26ee1a97e394 100644 --- a/crates/primitives/src/chain/mod.rs +++ b/crates/primitives/src/chain/mod.rs @@ -3,7 +3,7 @@ pub use info::ChainInfo; pub use spec::{ AllGenesisFormats, BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DisplayHardforks, ForkBaseFeeParams, ForkCondition, ForkTimestamps, DEV, GOERLI, HOLESKY, - MAINNET, SEPOLIA, TAIKO_A7, + MAINNET, SEPOLIA, TAIKO_A7, TAIKO_MAINNET, }; #[cfg(feature = "optimism")] pub use spec::{BASE_MAINNET, BASE_SEPOLIA, OP_MAINNET, OP_SEPOLIA}; diff --git a/crates/primitives/src/chain/spec.rs b/crates/primitives/src/chain/spec.rs index 2dd1616a8021..a189db28465f 100644 --- a/crates/primitives/src/chain/spec.rs +++ b/crates/primitives/src/chain/spec.rs @@ -14,7 +14,6 @@ use std::{ fmt::{Display, Formatter}, sync::Arc, }; -use alloy_chains::ChainKind::Id; pub use alloy_eips::eip1559::BaseFeeParams; @@ -85,26 +84,29 @@ pub static TAIKO_A7: Lazy> = Lazy::new(|| { chain: 167009.into(), genesis: serde_json::from_str(include_str!("../../res/genesis/mainnet.json")) .expect("Can't deserialize Mainnet genesis json"), - genesis_hash: Some(b256!( - "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" - )), - // - paris_block_and_final_difficulty: Some(( - 15537394, - U256::from(58_750_003_716_598_352_816_469u128), - )), + genesis_hash: None, + paris_block_and_final_difficulty: None, fork_timestamps: ForkTimestamps::default().shanghai(0), hardforks: BTreeMap::from([ - (Hardfork::Shanghai, ForkCondition::Block(0)), + (Hardfork::Frontier, ForkCondition::Block(0)), + (Hardfork::Homestead, ForkCondition::Block(0)), + (Hardfork::Dao, ForkCondition::Block(0)), + (Hardfork::Tangerine, ForkCondition::Block(0)), + (Hardfork::SpuriousDragon, ForkCondition::Block(0)), + (Hardfork::Byzantium, ForkCondition::Block(0)), + (Hardfork::Constantinople, ForkCondition::Block(0)), + (Hardfork::Petersburg, ForkCondition::Block(0)), + (Hardfork::Istanbul, ForkCondition::Block(1561651)), + (Hardfork::Berlin, ForkCondition::Block(4460644)), + (Hardfork::London, ForkCondition::Block(5062605)), + ( + Hardfork::Paris, + ForkCondition::TTD { fork_block: None, total_difficulty: U256::from(0) }, + ), + (Hardfork::Shanghai, ForkCondition::Timestamp(0)), ]), - // https://etherscan.io/tx/0xe75fb554e433e03763a1560646ee22dcb74e5274b34c5ad644e7c0f619a7e1d0 - deposit_contract: Some(DepositContract::new( - address!("00000000219ab540356cbb839cbe05303d7705fa"), - 11052984, - b256!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"), - )), - base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()), - prune_delete_limit: 3500, + deposit_contract: None, + ..Default::default() } .into() }); @@ -115,26 +117,29 @@ pub static TAIKO_MAINNET: Lazy> = Lazy::new(|| { chain: 167000.into(), genesis: serde_json::from_str(include_str!("../../res/genesis/mainnet.json")) .expect("Can't deserialize Mainnet genesis json"), - genesis_hash: Some(b256!( - "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" - )), - // - paris_block_and_final_difficulty: Some(( - 15537394, - U256::from(58_750_003_716_598_352_816_469u128), - )), - fork_timestamps: ForkTimestamps::default().shanghai(1681338455).cancun(1710338135), + genesis_hash: None, + paris_block_and_final_difficulty: None, + fork_timestamps: ForkTimestamps::default().shanghai(0), hardforks: BTreeMap::from([ - (Hardfork::Shanghai, ForkCondition::Block(0)), + (Hardfork::Frontier, ForkCondition::Block(0)), + (Hardfork::Homestead, ForkCondition::Block(0)), + (Hardfork::Dao, ForkCondition::Block(0)), + (Hardfork::Tangerine, ForkCondition::Block(0)), + (Hardfork::SpuriousDragon, ForkCondition::Block(0)), + (Hardfork::Byzantium, ForkCondition::Block(0)), + (Hardfork::Constantinople, ForkCondition::Block(0)), + (Hardfork::Petersburg, ForkCondition::Block(0)), + (Hardfork::Istanbul, ForkCondition::Block(1561651)), + (Hardfork::Berlin, ForkCondition::Block(4460644)), + (Hardfork::London, ForkCondition::Block(5062605)), + ( + Hardfork::Paris, + ForkCondition::TTD { fork_block: None, total_difficulty: U256::from(0) }, + ), + (Hardfork::Shanghai, ForkCondition::Timestamp(0)), ]), - // https://etherscan.io/tx/0xe75fb554e433e03763a1560646ee22dcb74e5274b34c5ad644e7c0f619a7e1d0 - deposit_contract: Some(DepositContract::new( - address!("00000000219ab540356cbb839cbe05303d7705fa"), - 11052984, - b256!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"), - )), - base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()), - prune_delete_limit: 3500, + deposit_contract: None, + ..Default::default() } .into() }); diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 7dbebbbfc247..b21dbdb1e5af 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -57,7 +57,7 @@ pub use block::{ pub use chain::{ AllGenesisFormats, BaseFeeParams, BaseFeeParamsKind, Chain, ChainInfo, ChainSpec, ChainSpecBuilder, DisplayHardforks, ForkBaseFeeParams, ForkCondition, ForkTimestamps, - NamedChain, DEV, GOERLI, HOLESKY, MAINNET, SEPOLIA, TAIKO_A7, + NamedChain, DEV, GOERLI, HOLESKY, MAINNET, SEPOLIA, TAIKO_A7, TAIKO_MAINNET, }; #[cfg(feature = "zstd-codec")] pub use compression::*; diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index f401b0ef631f..45b7f06e0f11 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -1145,11 +1145,12 @@ impl TransactionSigned { where T: IntoParallelIterator + IntoIterator + Send, { - if num_txes < *PARALLEL_SENDER_RECOVERY_THRESHOLD { - txes.into_iter().map(|tx| tx.recover_signer()).collect() + let signers = if num_txes < *PARALLEL_SENDER_RECOVERY_THRESHOLD { + txes.into_iter().map(|tx| tx.recover_signer().unwrap_or_default()).collect() } else { - txes.into_par_iter().map(|tx| tx.recover_signer()).collect() - } + txes.into_par_iter().map(|tx| tx.recover_signer().unwrap_or_default()).collect() + }; + Some(signers) } /// Recovers a list of signers from a transaction list iterator _without ensuring that the @@ -1161,11 +1162,12 @@ impl TransactionSigned { where T: IntoParallelIterator + IntoIterator, { - if num_txes < *PARALLEL_SENDER_RECOVERY_THRESHOLD { - txes.into_iter().map(|tx| tx.recover_signer_unchecked()).collect() + let signers = if num_txes < *PARALLEL_SENDER_RECOVERY_THRESHOLD { + txes.into_iter().map(|tx| tx.recover_signer_unchecked().unwrap_or_default()).collect() } else { - txes.into_par_iter().map(|tx| tx.recover_signer_unchecked()).collect() - } + txes.into_par_iter().map(|tx| tx.recover_signer_unchecked().unwrap_or_default()).collect() + }; + Some(signers) } /// Returns the [TransactionSignedEcRecovered] transaction with the given sender.