diff --git a/Cargo.lock b/Cargo.lock index 9c2f830ef..b33fe7d6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,37 +82,23 @@ dependencies = [ "strum", ] -[[package]] -name = "alloy-consensus" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae09ffd7c29062431dd86061deefe4e3c6f07fa0d674930095f8dcedb0baf02c" -dependencies = [ - "alloy-eips 0.6.4", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.6.4", - "auto_impl", - "c-kzg", - "derive_more", - "serde", -] - [[package]] name = "alloy-consensus" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a101d4d016f47f13890a74290fdd17b05dd175191d9337bc600791fb96e4dea8" dependencies = [ - "alloy-eips 0.7.3", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.7.3", + "alloy-serde", "alloy-trie", + "arbitrary", "auto_impl", "c-kzg", "derive_more", "k256", + "rand", "serde", ] @@ -122,11 +108,11 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa60357dda9a3d0f738f18844bd6d0f4a5924cc5cf00bfad2ff1369897966123" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.7.3", + "alloy-serde", "serde", ] @@ -138,6 +124,8 @@ checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" dependencies = [ "alloy-primitives", "alloy-rlp", + "arbitrary", + "rand", "serde", ] @@ -149,29 +137,13 @@ checksum = "4c986539255fb839d1533c128e190e557e52ff652c9ef62939e233a81dd93f7e" dependencies = [ "alloy-primitives", "alloy-rlp", + "arbitrary", "derive_more", "k256", + "rand", "serde", ] -[[package]] -name = "alloy-eips" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b6aa3961694b30ba53d41006131a2fca3bdab22e4c344e46db2c639e7c2dfdd" -dependencies = [ - "alloy-eip2930", - "alloy-eip7702", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.6.4", - "c-kzg", - "derive_more", - "once_cell", - "serde", - "sha2", -] - [[package]] name = "alloy-eips" version = "0.7.3" @@ -182,7 +154,8 @@ dependencies = [ "alloy-eip7702", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.7.3", + "alloy-serde", + "arbitrary", "c-kzg", "derive_more", "once_cell", @@ -192,27 +165,14 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53f7877ded3921d18a0a9556d55bedf84535567198c9edab2aa23106da91855" -dependencies = [ - "alloy-primitives", - "alloy-serde 0.6.4", - "serde", -] - -[[package]] -name = "alloy-json-rpc" -version = "0.6.4" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3694b7e480728c0b3e228384f223937f14c10caef5a4c766021190fc8f283d35" +checksum = "aeec8e6eab6e52b7c9f918748c9b811e87dbef7312a2e3a2ca1729a92966a6af" dependencies = [ "alloy-primitives", - "alloy-sol-types", + "alloy-serde", + "alloy-trie", "serde", - "serde_json", - "thiserror 1.0.69", - "tracing", ] [[package]] @@ -229,45 +189,22 @@ dependencies = [ "tracing", ] -[[package]] -name = "alloy-network" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea94b8ceb5c75d7df0a93ba0acc53b55a22b47b532b600a800a87ef04eb5b0b4" -dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", - "alloy-json-rpc 0.6.4", - "alloy-network-primitives 0.6.4", - "alloy-primitives", - "alloy-rpc-types-eth 0.6.4", - "alloy-serde 0.6.4", - "alloy-signer 0.6.4", - "alloy-sol-types", - "async-trait", - "auto_impl", - "futures-utils-wasm", - "serde", - "serde_json", - "thiserror 1.0.69", -] - [[package]] name = "alloy-network" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209a1882a08e21aca4aac6e2a674dc6fcf614058ef8cb02947d63782b1899552" dependencies = [ - "alloy-consensus 0.7.3", + "alloy-consensus", "alloy-consensus-any", - "alloy-eips 0.7.3", - "alloy-json-rpc 0.7.3", - "alloy-network-primitives 0.7.3", + "alloy-eips", + "alloy-json-rpc", + "alloy-network-primitives", "alloy-primitives", "alloy-rpc-types-any", - "alloy-rpc-types-eth 0.7.3", - "alloy-serde 0.7.3", - "alloy-signer 0.7.3", + "alloy-rpc-types-eth", + "alloy-serde", + "alloy-signer", "alloy-sol-types", "async-trait", "auto_impl", @@ -277,29 +214,16 @@ dependencies = [ "thiserror 2.0.4", ] -[[package]] -name = "alloy-network-primitives" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df9f3e281005943944d15ee8491534a1c7b3cbf7a7de26f8c433b842b93eb5f9" -dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", - "alloy-primitives", - "alloy-serde 0.6.4", - "serde", -] - [[package]] name = "alloy-network-primitives" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c20219d1ad261da7a6331c16367214ee7ded41d001fabbbd656fbf71898b2773" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", - "alloy-serde 0.7.3", + "alloy-serde", "serde", ] @@ -342,14 +266,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eefa6f4c798ad01f9b4202d02cea75f5ec11fa180502f4701e2b47965a8c0bb" dependencies = [ "alloy-chains", - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", - "alloy-json-rpc 0.7.3", - "alloy-network 0.7.3", - "alloy-network-primitives 0.7.3", + "alloy-consensus", + "alloy-eips", + "alloy-json-rpc", + "alloy-network", + "alloy-network-primitives", "alloy-primitives", "alloy-rpc-client", - "alloy-rpc-types-eth 0.7.3", + "alloy-rpc-types-eth", "alloy-transport", "alloy-transport-http", "async-stream", @@ -400,7 +324,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed30bf1041e84cabc5900f52978ca345dd9969f2194a945e6fdec25b0620705c" dependencies = [ - "alloy-json-rpc 0.7.3", + "alloy-json-rpc", "alloy-primitives", "alloy-transport", "alloy-transport-http", @@ -417,18 +341,6 @@ dependencies = [ "wasmtimer", ] -[[package]] -name = "alloy-rpc-types" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c74832aa474b670309c20fffc2a869fa141edab7c79ff7963fad0a08de60bae1" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types-eth 0.6.4", - "alloy-serde 0.6.4", - "serde", -] - [[package]] name = "alloy-rpc-types" version = "0.7.3" @@ -437,8 +349,8 @@ checksum = "5ab686b0fa475d2a4f5916c5f07797734a691ec58e44f0f55d4746ea39cbcefb" dependencies = [ "alloy-primitives", "alloy-rpc-types-debug", - "alloy-rpc-types-eth 0.7.3", - "alloy-serde 0.7.3", + "alloy-rpc-types-eth", + "alloy-serde", "serde", ] @@ -449,8 +361,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "200661999b6e235d9840be5d60a6e8ae2f0af9eb2a256dd378786744660e36ec" dependencies = [ "alloy-consensus-any", - "alloy-rpc-types-eth 0.7.3", - "alloy-serde 0.7.3", + "alloy-rpc-types-eth", + "alloy-serde", ] [[package]] @@ -459,10 +371,10 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc37861dc8cbf5da35d346139fbe6e03ee7823cc21138a2c4a590d3b0b4b24be" dependencies = [ - "alloy-eips 0.7.3", + "alloy-eips", "alloy-primitives", - "alloy-rpc-types-engine 0.7.3", - "alloy-serde 0.7.3", + "alloy-rpc-types-engine", + "alloy-serde", "serde", "serde_with", "thiserror 2.0.4", @@ -478,68 +390,35 @@ dependencies = [ "serde", ] -[[package]] -name = "alloy-rpc-types-engine" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56294dce86af23ad6ee8df46cf8b0d292eb5d1ff67dc88a0886051e32b1faf" -dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", - "alloy-primitives", - "alloy-rlp", - "derive_more", - "strum", -] - [[package]] name = "alloy-rpc-types-engine" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d297268357e3eae834ddd6888b15f764cbc0f4b3be9265f5f6ec239013f3d68" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.7.3", + "alloy-serde", "derive_more", "serde", "strum", ] -[[package]] -name = "alloy-rpc-types-eth" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a477281940d82d29315846c7216db45b15e90bcd52309da9f54bcf7ad94a11" -dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", - "alloy-network-primitives 0.6.4", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.6.4", - "alloy-sol-types", - "derive_more", - "itertools 0.13.0", - "serde", - "serde_json", -] - [[package]] name = "alloy-rpc-types-eth" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0600b8b5e2dc0cab12cbf91b5a885c35871789fb7b3a57b434bd4fced5b7a8b" dependencies = [ - "alloy-consensus 0.7.3", + "alloy-consensus", "alloy-consensus-any", - "alloy-eips 0.7.3", - "alloy-network-primitives 0.7.3", + "alloy-eips", + "alloy-network-primitives", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.7.3", + "alloy-serde", "alloy-sol-types", "derive_more", "itertools 0.13.0", @@ -547,17 +426,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-serde" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dfa4a7ccf15b2492bb68088692481fd6b2604ccbee1d0d6c44c21427ae4df83" -dependencies = [ - "alloy-primitives", - "serde", - "serde_json", -] - [[package]] name = "alloy-serde" version = "0.7.3" @@ -565,24 +433,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afa753a97002a33b2ccb707d9f15f31c81b8c1b786c95b73cc62bb1d1fd0c3f" dependencies = [ "alloy-primitives", + "arbitrary", "serde", "serde_json", ] -[[package]] -name = "alloy-signer" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e10aec39d60dc27edcac447302c7803d2371946fb737245320a05b78eb2fafd" -dependencies = [ - "alloy-primitives", - "async-trait", - "auto_impl", - "elliptic-curve", - "k256", - "thiserror 1.0.69", -] - [[package]] name = "alloy-signer" version = "0.7.3" @@ -661,7 +516,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d69d36982b9e46075ae6b792b0f84208c6c2c15ad49f6c500304616ef67b70e0" dependencies = [ - "alloy-json-rpc 0.7.3", + "alloy-json-rpc", "base64 0.22.1", "futures-util", "futures-utils-wasm", @@ -681,7 +536,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e02ffd5d93ffc51d72786e607c97de3b60736ca3e636ead0ec1f7dce68ea3fd" dependencies = [ - "alloy-json-rpc 0.7.3", + "alloy-json-rpc", "alloy-transport", "reqwest", "serde_json", @@ -787,6 +642,9 @@ name = "arbitrary" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" +dependencies = [ + "derive_arbitrary", +] [[package]] name = "ark-ff" @@ -2655,11 +2513,11 @@ dependencies = [ name = "kona-client" version = "0.1.0" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types-engine 0.7.3", + "alloy-rpc-types-engine", "async-trait", "cfg-if", "kona-derive", @@ -2671,11 +2529,15 @@ dependencies = [ "kona-std-fpvm", "kona-std-fpvm-proc", "lru", - "op-alloy-consensus 0.7.3", + "op-alloy-consensus", "op-alloy-genesis", "op-alloy-protocol", "op-alloy-rpc-types-engine", + "reth-evm", "reth-optimism-chainspec", + "reth-optimism-forks", + "reth-primitives", + "reth-primitives-traits", "revm", "serde", "serde_json", @@ -2688,13 +2550,13 @@ dependencies = [ name = "kona-derive" version = "0.2.0" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types-engine 0.7.3", + "alloy-rpc-types-engine", "async-trait", - "op-alloy-consensus 0.7.3", + "op-alloy-consensus", "op-alloy-genesis", "op-alloy-protocol", "op-alloy-registry", @@ -2712,12 +2574,12 @@ dependencies = [ name = "kona-driver" version = "0.2.0" dependencies = [ - "alloy-consensus 0.7.3", + "alloy-consensus", "alloy-primitives", "alloy-rlp", "async-trait", "kona-derive", - "op-alloy-consensus 0.7.3", + "op-alloy-consensus", "op-alloy-genesis", "op-alloy-protocol", "op-alloy-rpc-types-engine", @@ -2729,15 +2591,16 @@ dependencies = [ name = "kona-executor" version = "0.2.0" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types-engine 0.7.3", + "alloy-rpc-types-engine", "anyhow", "criterion", + "kona-client", "kona-mpt", - "op-alloy-consensus 0.7.3", + "op-alloy-consensus", "op-alloy-genesis", "op-alloy-rpc-types-engine", "pprof", @@ -2759,15 +2622,15 @@ dependencies = [ name = "kona-host" version = "0.1.0" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-provider", "alloy-rlp", "alloy-rpc-client", - "alloy-rpc-types 0.7.3", + "alloy-rpc-types", "alloy-rpc-types-beacon", - "alloy-serde 0.7.3", + "alloy-serde", "alloy-transport-http", "anyhow", "async-trait", @@ -2796,11 +2659,11 @@ dependencies = [ name = "kona-mpt" version = "0.1.1" dependencies = [ - "alloy-consensus 0.7.3", + "alloy-consensus", "alloy-primitives", "alloy-provider", "alloy-rlp", - "alloy-rpc-types 0.7.3", + "alloy-rpc-types", "alloy-transport-http", "alloy-trie", "anyhow", @@ -2833,8 +2696,8 @@ dependencies = [ name = "kona-proof" version = "0.2.0" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", "async-trait", @@ -2844,11 +2707,12 @@ dependencies = [ "kona-mpt", "kona-preimage", "lru", - "op-alloy-consensus 0.7.3", + "op-alloy-consensus", "op-alloy-genesis", "op-alloy-protocol", "op-alloy-registry", "op-alloy-rpc-types-engine", + "reth-evm", "reth-optimism-chainspec", "serde", "serde_json", @@ -3030,18 +2894,6 @@ dependencies = [ "portable-atomic", ] -[[package]] -name = "metrics-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3dbdd96ed57d565ec744cba02862d707acf373c5772d152abae6ec5c4e24f6c" -dependencies = [ - "proc-macro2", - "quote", - "regex", - "syn 2.0.90", -] - [[package]] name = "mime" version = "0.3.17" @@ -3330,33 +3182,18 @@ version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" -[[package]] -name = "op-alloy-consensus" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce158d886815d419222daa67fcdf949a34f7950653a4498ebeb4963331f70ed" -dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.6.4", - "derive_more", - "serde", - "thiserror 2.0.4", -] - [[package]] name = "op-alloy-consensus" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78f0daa0d0936d436a21b57571b1e27c5663aa2ab62f6edae5ba5be999f9f93e" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.7.3", + "alloy-serde", + "arbitrary", "derive_more", "serde", "thiserror 2.0.4", @@ -3368,8 +3205,8 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3eb0964932faa7050b74689f017aca66ffa3e52501080278a81bb0a43836c8dd" dependencies = [ - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-sol-types", "serde", @@ -3384,16 +3221,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d8c057c1a5bdf72d1f86c470a4d90f2d2ad1b273caa547c04cd6affe45b466d" dependencies = [ "alloc-no-stdlib", - "alloy-consensus 0.7.3", - "alloy-eips 0.7.3", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-serde 0.7.3", + "alloy-serde", "async-trait", "brotli", "cfg-if", "miniz_oxide", - "op-alloy-consensus 0.7.3", + "op-alloy-consensus", "op-alloy-genesis", "serde", "thiserror 2.0.4", @@ -3416,18 +3253,18 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.6.8" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060ebeaea8c772e396215f69bb86d231ec8b7f36aca0dd6ce367ceaa9a8c33e6" +checksum = "73741855ffaa2041b33cb616d7db7180c1149b648c68c23bee9e15501073fb32" dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", - "alloy-network-primitives 0.6.4", + "alloy-consensus", + "alloy-eips", + "alloy-network-primitives", "alloy-primitives", - "alloy-rpc-types-eth 0.6.4", - "alloy-serde 0.6.4", + "alloy-rpc-types-eth", + "alloy-serde", "derive_more", - "op-alloy-consensus 0.6.8", + "op-alloy-consensus", "serde", "serde_json", ] @@ -3438,12 +3275,12 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebedc32e24013c8b3faea62d091bccbb90f871286fe2238c6f7e2ff29974df8e" dependencies = [ - "alloy-eips 0.7.3", + "alloy-eips", "alloy-primitives", - "alloy-rpc-types-engine 0.7.3", - "alloy-serde 0.7.3", + "alloy-rpc-types-engine", + "alloy-serde", "derive_more", - "op-alloy-consensus 0.7.3", + "op-alloy-consensus", "op-alloy-genesis", "op-alloy-protocol", "serde", @@ -4029,11 +3866,11 @@ dependencies = [ [[package]] name = "reth-chainspec" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "alloy-chains", - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-genesis", "alloy-primitives", "auto_impl", @@ -4049,16 +3886,16 @@ dependencies = [ [[package]] name = "reth-codecs" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-genesis", "alloy-primitives", "alloy-trie", "bytes", "modular-bitfield", - "op-alloy-consensus 0.6.8", + "op-alloy-consensus", "reth-codecs-derive", "serde", ] @@ -4066,7 +3903,7 @@ dependencies = [ [[package]] name = "reth-codecs-derive" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "convert_case", "proc-macro2", @@ -4077,10 +3914,10 @@ dependencies = [ [[package]] name = "reth-consensus" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "auto_impl", "derive_more", @@ -4091,23 +3928,24 @@ dependencies = [ [[package]] name = "reth-consensus-common" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "reth-chainspec", "reth-consensus", "reth-primitives", + "reth-primitives-traits", "revm-primitives", ] [[package]] name = "reth-db" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", + "alloy-consensus", "alloy-primitives", "bytes", "derive_more", @@ -4123,15 +3961,15 @@ dependencies = [ "reth-trie-common", "serde", "sysinfo", - "thiserror 1.0.69", + "thiserror 2.0.4", ] [[package]] name = "reth-db-api" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", + "alloy-consensus", "alloy-genesis", "alloy-primitives", "bytes", @@ -4147,15 +3985,16 @@ dependencies = [ "reth-stages-types", "reth-storage-errors", "reth-trie-common", + "roaring", "serde", ] [[package]] name = "reth-db-models" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-eips 0.6.4", + "alloy-eips", "alloy-primitives", "bytes", "modular-bitfield", @@ -4167,7 +4006,7 @@ dependencies = [ [[package]] name = "reth-ethereum-forks" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "alloy-chains", "alloy-primitives", @@ -4178,26 +4017,24 @@ dependencies = [ "once_cell", "rustc-hash 2.1.0", "serde", - "thiserror-no-std", + "thiserror 2.0.4", ] [[package]] name = "reth-evm" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "auto_impl", "futures-util", - "metrics", "reth-chainspec", "reth-consensus", "reth-consensus-common", "reth-execution-errors", "reth-execution-types", - "reth-metrics", "reth-primitives", "reth-primitives-traits", "reth-prune-types", @@ -4210,25 +4047,26 @@ dependencies = [ [[package]] name = "reth-execution-errors" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-eips 0.6.4", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "derive_more", "nybbles", "reth-consensus", "reth-prune-types", "reth-storage-errors", "revm-primitives", + "thiserror 2.0.4", ] [[package]] name = "reth-execution-types" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-eips 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "reth-execution-errors", "reth-primitives", @@ -4236,44 +4074,37 @@ dependencies = [ "reth-trie", "revm", "serde", + "serde_with", ] [[package]] name = "reth-fs-util" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "serde", "serde_json", - "thiserror 1.0.69", -] - -[[package]] -name = "reth-metrics" -version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" -dependencies = [ - "metrics", - "metrics-derive", + "thiserror 2.0.4", ] [[package]] name = "reth-network-peers" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "alloy-primitives", "alloy-rlp", "enr", + "secp256k1", "serde_with", - "thiserror 1.0.69", + "thiserror 2.0.4", "url", ] [[package]] name = "reth-nippy-jar" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "anyhow", "bincode", @@ -4282,7 +4113,7 @@ dependencies = [ "memmap2", "reth-fs-util", "serde", - "thiserror 1.0.69", + "thiserror 2.0.4", "tracing", "zstd", ] @@ -4290,11 +4121,11 @@ dependencies = [ [[package]] name = "reth-optimism-chainspec" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "alloy-chains", - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-genesis", "alloy-primitives", "derive_more", @@ -4311,35 +4142,31 @@ dependencies = [ [[package]] name = "reth-optimism-forks" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "alloy-chains", "alloy-primitives", "once_cell", "reth-ethereum-forks", - "serde", ] [[package]] name = "reth-primitives" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", - "alloy-network 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types 0.6.4", - "alloy-serde 0.6.4", + "alloy-serde", "alloy-trie", "bytes", - "c-kzg", "derive_more", "k256", "modular-bitfield", "once_cell", - "op-alloy-rpc-types", + "op-alloy-consensus", "rayon", "reth-codecs", "reth-ethereum-forks", @@ -4348,16 +4175,17 @@ dependencies = [ "revm-primitives", "secp256k1", "serde", + "serde_with", "zstd", ] [[package]] name = "reth-primitives-traits" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-genesis", "alloy-primitives", "alloy-rlp", @@ -4366,16 +4194,17 @@ dependencies = [ "bytes", "derive_more", "modular-bitfield", + "op-alloy-consensus", "reth-codecs", "revm-primitives", - "roaring", "serde", + "serde_with", ] [[package]] name = "reth-prune-types" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "alloy-primitives", "bytes", @@ -4383,15 +4212,15 @@ dependencies = [ "modular-bitfield", "reth-codecs", "serde", - "thiserror 1.0.69", + "thiserror 2.0.4", ] [[package]] name = "reth-revm" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-eips 0.6.4", + "alloy-eips", "alloy-primitives", "reth-execution-errors", "reth-primitives", @@ -4405,7 +4234,7 @@ dependencies = [ [[package]] name = "reth-stages-types" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "alloy-primitives", "bytes", @@ -4418,7 +4247,7 @@ dependencies = [ [[package]] name = "reth-static-file-types" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "alloy-primitives", "derive_more", @@ -4429,12 +4258,12 @@ dependencies = [ [[package]] name = "reth-storage-api" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", - "alloy-eips 0.6.4", + "alloy-consensus", + "alloy-eips", "alloy-primitives", - "alloy-rpc-types-engine 0.6.4", + "alloy-rpc-types-engine", "auto_impl", "reth-chainspec", "reth-db", @@ -4447,25 +4276,28 @@ dependencies = [ "reth-stages-types", "reth-storage-errors", "reth-trie", + "reth-trie-db", + "revm", ] [[package]] name = "reth-storage-errors" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-eips 0.6.4", + "alloy-eips", "alloy-primitives", "alloy-rlp", "derive_more", "reth-fs-util", - "reth-primitives", + "reth-primitives-traits", + "reth-static-file-types", ] [[package]] name = "reth-tracing" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ "clap", "eyre", @@ -4480,9 +4312,9 @@ dependencies = [ [[package]] name = "reth-trie" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", + "alloy-consensus", "alloy-primitives", "alloy-rlp", "alloy-trie", @@ -4494,6 +4326,7 @@ dependencies = [ "reth-stages-types", "reth-storage-errors", "reth-trie-common", + "reth-trie-sparse", "revm", "tracing", ] @@ -4501,12 +4334,13 @@ dependencies = [ [[package]] name = "reth-trie-common" version = "1.1.2" -source = "git+https://github.com/paradigmxyz/reth.git?rev=8e4a917#8e4a917ec1aa70b3779083454ff2d5ecf6b44168" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" dependencies = [ - "alloy-consensus 0.6.4", + "alloy-consensus", "alloy-genesis", "alloy-primitives", "alloy-rlp", + "alloy-rpc-types-eth", "alloy-trie", "bytes", "derive_more", @@ -4518,6 +4352,39 @@ dependencies = [ "serde", ] +[[package]] +name = "reth-trie-db" +version = "1.1.2" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "derive_more", + "reth-db", + "reth-db-api", + "reth-execution-errors", + "reth-primitives", + "reth-storage-errors", + "reth-trie", + "revm", + "tracing", +] + +[[package]] +name = "reth-trie-sparse" +version = "1.1.2" +source = "git+https://github.com/zobront/reth.git?branch=fill-env-opt-deposit#3178269633ac812c19ebb724a21655b3eb1e60f3" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "reth-execution-errors", + "reth-primitives-traits", + "reth-tracing", + "reth-trie-common", + "smallvec", + "thiserror 2.0.4", +] + [[package]] name = "revm" version = "18.0.0" @@ -4674,7 +4541,6 @@ checksum = "f81dc953b2244ddd5e7860cb0bb2a790494b898ef321d4aff8e260efab60cc88" dependencies = [ "bytemuck", "byteorder", - "serde", ] [[package]] @@ -5326,9 +5192,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.31.4" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" +checksum = "4c33cd241af0f2e9e3b5c32163b873b29956890b5342e6745b917ce9d490f4af" dependencies = [ "core-foundation-sys", "libc", @@ -5417,26 +5283,6 @@ dependencies = [ "syn 2.0.90", ] -[[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" diff --git a/Cargo.toml b/Cargo.toml index 7ec165462..8f11c1eb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,11 +96,11 @@ op-alloy-consensus = { version = "0.7.2", default-features = false } op-alloy-rpc-types-engine = { version = "0.7.2", default-features = false } # Reth -reth-evm = { git = "https://github.com/paradigmxyz/reth.git", rev = "8e4a917" } -reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth.git", rev = "8e4a917" } -reth-primitives = { git = "https://github.com/paradigmxyz/reth.git", rev = "8e4a917" } -reth-optimism-chainspec = { git = "https://github.com/paradigmxyz/reth.git", rev = "8e4a917" } -reth-optimism-forks = { git = "https://github.com/paradigmxyz/reth.git", rev = "8e4a917" } +reth-evm = { git = "https://github.com/zobront/reth.git", branch = "fill-env-opt-deposit", default-features = false } +reth-primitives-traits = { git = "https://github.com/zobront/reth.git", branch = "fill-env-opt-deposit", default-features = false } +reth-primitives = { git = "https://github.com/zobront/reth.git", branch = "fill-env-opt-deposit", default-features = false, features = ["optimism"] } +reth-optimism-chainspec = { git = "https://github.com/zobront/reth.git", branch = "fill-env-opt-deposit", default-features = false } +reth-optimism-forks = { git = "https://github.com/zobront/reth.git", branch = "fill-env-opt-deposit", default-features = false } # General lru = "0.12.4" diff --git a/bin/client/Cargo.toml b/bin/client/Cargo.toml index 8d8cc0df5..bf0d96129 100644 --- a/bin/client/Cargo.toml +++ b/bin/client/Cargo.toml @@ -34,7 +34,13 @@ op-alloy-rpc-types-engine = { workspace = true, features = ["serde"] } # Revm revm.workspace = true + +# Reth +reth-evm.workspace = true +reth-primitives-traits.workspace = true +reth-primitives.workspace = true reth-optimism-chainspec.workspace = true +reth-optimism-forks.workspace = true # General lru.workspace = true diff --git a/bin/client/src/evm_config.rs b/bin/client/src/evm_config.rs new file mode 100644 index 000000000..e32a2af1f --- /dev/null +++ b/bin/client/src/evm_config.rs @@ -0,0 +1,299 @@ +use alloc::{sync::Arc, vec::Vec}; +use alloy_consensus::Header; +use alloy_rlp::Encodable; +use alloy_primitives::{Address, Bytes, TxKind, U256}; +use op_alloy_consensus::OpTxEnvelope; +use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes}; +use reth_optimism_chainspec::{DecodeError, OpChainSpec}; +use reth_optimism_forks::OpHardfork; +use revm::{ + Database, Evm, EvmBuilder, + primitives::{ + Env, OptimismFields, BlobExcessGasAndPrice, BlockEnv, CfgEnv, + CfgEnvWithHandlerCfg, SpecId, TransactTo, TxEnv, HandlerCfg, AnalysisKind + }, +}; + +use crate::fpvm_handle_register; + +/// A default implementation of the EVM Config. +#[derive(Clone, Debug)] +pub struct KonaEvmConfig { + chain_spec: Arc, +} + +impl KonaEvmConfig { + /// Create a new instance of the default EVM config from a chain spec. + pub const fn new(chain_spec: Arc) -> Self { + Self { chain_spec } + } +} + +impl ConfigureEvmEnv for KonaEvmConfig { + type Header = Header; + type Transaction = OpTxEnvelope; + type Error = DecodeError; + + /// Fill transaction environment from a [`OpTxEnvelope`] and the given sender address. + fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &OpTxEnvelope, sender: Address) { + match transaction { + OpTxEnvelope::Legacy(signed_tx) => { + let tx = signed_tx.tx(); + tx_env.caller = sender; + tx_env.gas_limit = tx.gas_limit; + tx_env.gas_price = U256::from(tx.gas_price); + tx_env.gas_priority_fee = None; + tx_env.transact_to = match tx.to { + TxKind::Call(to) => TransactTo::Call(to), + TxKind::Create => TransactTo::Create, + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = tx.chain_id; + tx_env.nonce = Some(tx.nonce); + tx_env.access_list.clear(); + tx_env.blob_hashes.clear(); + tx_env.max_fee_per_blob_gas.take(); + tx_env.optimism = OptimismFields { + source_hash: None, + mint: None, + is_system_transaction: Some(false), + enveloped_tx: { + let mut buf = Vec::new(); + transaction.encode(&mut buf); + Some(buf.into()) + }, + }; + } + OpTxEnvelope::Eip2930(signed_tx) => { + let tx = signed_tx.tx(); + tx_env.caller = sender; + tx_env.gas_limit = tx.gas_limit; + tx_env.gas_price = U256::from(tx.gas_price); + tx_env.gas_priority_fee = None; + tx_env.transact_to = match tx.to { + TxKind::Call(to) => TransactTo::Call(to), + TxKind::Create => TransactTo::Create, + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = Some(tx.chain_id); + tx_env.nonce = Some(tx.nonce); + tx_env.access_list = tx.access_list.to_vec(); + tx_env.blob_hashes.clear(); + tx_env.max_fee_per_blob_gas.take(); + tx_env.optimism = OptimismFields { + source_hash: None, + mint: None, + is_system_transaction: Some(false), + enveloped_tx: { + let mut buf = Vec::new(); + transaction.encode(&mut buf); + Some(buf.into()) + }, + }; + } + OpTxEnvelope::Eip1559(signed_tx) => { + let tx = signed_tx.tx(); + tx_env.caller = sender; + tx_env.gas_limit = tx.gas_limit; + tx_env.gas_price = U256::from(tx.max_fee_per_gas); + tx_env.gas_priority_fee = Some(U256::from(tx.max_priority_fee_per_gas)); + tx_env.transact_to = match tx.to { + TxKind::Call(to) => TransactTo::Call(to), + TxKind::Create => TransactTo::Create, + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = Some(tx.chain_id); + tx_env.nonce = Some(tx.nonce); + tx_env.access_list = tx.access_list.to_vec(); + tx_env.blob_hashes.clear(); + tx_env.max_fee_per_blob_gas.take(); + tx_env.optimism = OptimismFields { + source_hash: None, + mint: None, + is_system_transaction: Some(false), + enveloped_tx: { + let mut buf = Vec::new(); + transaction.encode(&mut buf); + Some(buf.into()) + }, + }; + } + OpTxEnvelope::Deposit(tx) => { + tx_env.caller = tx.from; + tx_env.access_list.clear(); + tx_env.gas_limit = tx.gas_limit; + tx_env.gas_price = U256::ZERO; + tx_env.gas_priority_fee = None; + match tx.to { + TxKind::Call(to) => tx_env.transact_to = TransactTo::Call(to), + TxKind::Create => tx_env.transact_to = TransactTo::Create, + } + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = None; + tx_env.nonce = None; + tx_env.optimism = OptimismFields { + source_hash: Some(tx.source_hash), + mint: tx.mint, + is_system_transaction: Some(tx.is_system_transaction), + enveloped_tx: { + let mut buf = Vec::new(); + transaction.encode(&mut buf); + Some(buf.into()) + }, + }; + } + _ => { + // ZTODO: no return, how to better handle errors? + panic!("Unsupported transaction type"); + } + } + } + + /// Fill transaction environment with a system contract call. + fn fill_tx_env_system_contract_call( + &self, + env: &mut Env, + caller: Address, + contract: Address, + data: Bytes, + ) { + env.tx = TxEnv { + caller, + transact_to: TxKind::Call(contract), + // Explicitly set nonce to None so revm does not do any nonce checks + nonce: None, + gas_limit: 30_000_000, + value: U256::ZERO, + data, + // Setting the gas price to zero enforces that no value is transferred as part of the + // call, and that the call will not count against the block's gas limit + gas_price: U256::ZERO, + // The chain ID check is not relevant here and is disabled if set to None + chain_id: None, + // Setting the gas priority fee to None ensures the effective gas price is derived from + // the `gas_price` field, which we need to be zero + gas_priority_fee: None, + access_list: Vec::new(), + // blob fields can be None for this tx + blob_hashes: Vec::new(), + max_fee_per_blob_gas: None, + authorization_list: None, + optimism: OptimismFields { + source_hash: None, + mint: None, + is_system_transaction: Some(false), + // The L1 fee is not charged for the EIP-4788 transaction, submit zero bytes for the + // enveloped tx size. + enveloped_tx: Some(Bytes::default()), + }, + }; + + // ensure the block gas limit is >= the tx + env.block.gas_limit = U256::from(env.tx.gas_limit); + + // disable the base fee check for this call by setting the base fee to zero + env.block.basefee = U256::ZERO; + } + + /// Fill [`CfgEnvWithHandlerCfg`] fields according to the chain spec and given header. + /// + /// This must set the corresponding spec id in the handler cfg, based on timestamp or total + /// difficulty + fn fill_cfg_env( + &self, + cfg_env: &mut CfgEnvWithHandlerCfg, + header: &Self::Header, + _total_difficulty: U256, + ) { + let spec_id = revm_spec_by_timestamp_after_bedrock(&self.chain_spec, header.timestamp); + + cfg_env.chain_id = self.chain_spec.chain().id(); + cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Analyse; + + cfg_env.handler_cfg.spec_id = spec_id; + cfg_env.handler_cfg.is_optimism = true; + } + + /// Returns the configured [`CfgEnvWithHandlerCfg`] and [`BlockEnv`] for `parent + 1` block. + /// + /// This is intended for usage in block building after the merge and requires additional + /// attributes that can't be derived from the parent block: attributes that are determined by + /// the CL, such as the timestamp, suggested fee recipient, and randomness value. + fn next_cfg_and_block_env( + &self, + parent: &Self::Header, + attributes: NextBlockEnvAttributes, + ) -> Result<(CfgEnvWithHandlerCfg, BlockEnv), Self::Error> { + // configure evm env based on parent block + let cfg = CfgEnv::default().with_chain_id(self.chain_spec.chain().id()); + + // ensure we're not missing any timestamp based hardforks + let spec_id = revm_spec_by_timestamp_after_bedrock(&self.chain_spec, attributes.timestamp); + + // if the parent block did not have excess blob gas (i.e. it was pre-cancun), but it is + // cancun now, we need to set the excess blob gas to the default value(0) + let blob_excess_gas_and_price = parent + .next_block_excess_blob_gas() + .or_else(|| (spec_id.is_enabled_in(SpecId::CANCUN)).then_some(0)) + .map(BlobExcessGasAndPrice::new); + + let block_env = BlockEnv { + number: U256::from(parent.number + 1), + coinbase: attributes.suggested_fee_recipient, + timestamp: U256::from(attributes.timestamp), + difficulty: U256::ZERO, + prevrandao: Some(attributes.prev_randao), + gas_limit: U256::from(parent.gas_limit), + // calculate basefee based on parent block's gas usage + basefee: self.chain_spec.next_block_base_fee(parent, attributes.timestamp)?, + // calculate excess gas based on parent block's blob gas usage + blob_excess_gas_and_price, + }; + + let cfg_with_handler_cfg; + { + cfg_with_handler_cfg = CfgEnvWithHandlerCfg { + cfg_env: cfg, + handler_cfg: HandlerCfg { spec_id, is_optimism: true }, + }; + } + + Ok((cfg_with_handler_cfg, block_env)) + } +} + +impl ConfigureEvm for KonaEvmConfig { + type DefaultExternalContext<'a> = (); + + fn evm(&self, db: DB) -> Evm<'_, Self::DefaultExternalContext<'_>, DB> { + EvmBuilder::default() + .with_db(db) + .optimism() + .append_handler_register(fpvm_handle_register) + .build() + } + + fn default_external_context<'a>(&self) -> Self::DefaultExternalContext<'a> {} +} + +fn revm_spec_by_timestamp_after_bedrock(chain_spec: &OpChainSpec, timestamp: u64) -> SpecId { + if chain_spec.fork(OpHardfork::Holocene).active_at_timestamp(timestamp) { + revm::primitives::HOLOCENE + } else if chain_spec.fork(OpHardfork::Granite).active_at_timestamp(timestamp) { + revm::primitives::GRANITE + } else if chain_spec.fork(OpHardfork::Fjord).active_at_timestamp(timestamp) { + revm::primitives::FJORD + } else if chain_spec.fork(OpHardfork::Ecotone).active_at_timestamp(timestamp) { + revm::primitives::ECOTONE + } else if chain_spec.fork(OpHardfork::Canyon).active_at_timestamp(timestamp) { + revm::primitives::CANYON + } else if chain_spec.fork(OpHardfork::Regolith).active_at_timestamp(timestamp) { + revm::primitives::REGOLITH + } else { + revm::primitives::BEDROCK + } +} diff --git a/bin/client/src/kona.rs b/bin/client/src/kona.rs index cf166c142..b96a59884 100644 --- a/bin/client/src/kona.rs +++ b/bin/client/src/kona.rs @@ -11,8 +11,7 @@ use alloc::string::String; use kona_preimage::{HintWriter, OracleReader}; use kona_std_fpvm::{FileChannel, FileDescriptor}; use kona_std_fpvm_proc::client_entry; - -mod precompiles; +use crate::{run, fpvm_handle_register}; /// The global preimage oracle reader pipe. static ORACLE_READER_PIPE: FileChannel = @@ -23,10 +22,10 @@ static HINT_WRITER_PIPE: FileChannel = FileChannel::new(FileDescriptor::HintRead, FileDescriptor::HintWrite); /// The global preimage oracle reader. -static ORACLE_READER: OracleReader = OracleReader::new(ORACLE_READER_PIPE); +pub static ORACLE_READER: OracleReader = OracleReader::new(ORACLE_READER_PIPE); /// The global hint writer. -static HINT_WRITER: HintWriter = HintWriter::new(HINT_WRITER_PIPE); +pub static HINT_WRITER: HintWriter = HintWriter::new(HINT_WRITER_PIPE); #[client_entry(100_000_000)] fn main() -> Result<(), String> { @@ -39,9 +38,8 @@ fn main() -> Result<(), String> { .expect("Failed to set tracing subscriber"); } - kona_proof::block_on(kona_client::run( + kona_proof::block_on(run( ORACLE_READER, HINT_WRITER, - Some(precompiles::fpvm_handle_register), )) } diff --git a/bin/client/src/lib.rs b/bin/client/src/lib.rs index 83c4c70cd..1e2a4c9e4 100644 --- a/bin/client/src/lib.rs +++ b/bin/client/src/lib.rs @@ -12,7 +12,7 @@ use alloy_consensus::{Header, Sealed}; use alloy_primitives::B256; use core::fmt::Debug; use kona_driver::{Driver, DriverError}; -use kona_executor::{ExecutorError, KonaHandleRegister, TrieDBProvider}; +use kona_executor::{ExecutorError, TrieDBProvider}; use kona_preimage::{ CommsClient, HintWriterClient, PreimageKey, PreimageKeyType, PreimageOracleClient, }; @@ -26,6 +26,16 @@ use kona_proof::{ }; use thiserror::Error; use tracing::{error, info, warn}; +use reth_optimism_chainspec::OP_MAINNET; + +mod precompiles; +pub use precompiles::fpvm_handle_register; + +mod evm_config; +use evm_config::KonaEvmConfig; + +mod kona; +pub use kona::{HINT_WRITER, ORACLE_READER}; /// An error that can occur when running the fault proof program. #[derive(Error, Debug)] @@ -45,17 +55,11 @@ pub enum FaultProofProgramError { #[inline] pub async fn run( oracle_client: P, - hint_client: H, - handle_register: Option< - KonaHandleRegister< - OracleL2ChainProvider>, - OracleL2ChainProvider>, - >, - >, + hint_client: H ) -> Result<(), FaultProofProgramError> where - P: PreimageOracleClient + Send + Sync + Debug + Clone, - H: HintWriterClient + Send + Sync + Debug + Clone, + P: PreimageOracleClient + Send + Sync + Debug + Clone + 'static, + H: HintWriterClient + Send + Sync + Debug + Clone + 'static, { const ORACLE_LRU_SIZE: usize = 1024; @@ -116,7 +120,9 @@ where l1_provider.clone(), l2_provider.clone(), ); - let executor = KonaExecutor::new(&cfg, l2_provider.clone(), l2_provider, handle_register, None); + // ZTODO: derive this from the rollup config + let evm_config = KonaEvmConfig::new(Arc::new((**OP_MAINNET).clone())); + let executor = KonaExecutor::new(&cfg, l2_provider.clone(), l2_provider, evm_config, None); let mut driver = Driver::new(cursor, executor, pipeline); // Run the derivation pipeline until we are able to produce the output root of the claimed diff --git a/bin/client/src/precompiles/mod.rs b/bin/client/src/precompiles/mod.rs index 910e343a1..fb1be9c98 100644 --- a/bin/client/src/precompiles/mod.rs +++ b/bin/client/src/precompiles/mod.rs @@ -3,12 +3,10 @@ //! [KonaHandleRegister]: kona_executor::KonaHandleRegister use alloc::sync::Arc; -use kona_executor::{TrieDB, TrieDBProvider}; -use kona_mpt::TrieHinter; use revm::{ handler::register::EvmHandler, primitives::{spec_to_generic, SpecId}, - State, + Database }; mod bn128_pair; @@ -18,17 +16,14 @@ mod kzg_point_eval; /// The [KonaHandleRegister] function for registering the FPVM-accelerated precompiles. /// /// [KonaHandleRegister]: kona_executor::KonaHandleRegister -pub(crate) fn fpvm_handle_register( - handler: &mut EvmHandler<'_, (), &mut State<&mut TrieDB>>, -) where - F: TrieDBProvider, - H: TrieHinter, -{ +pub fn fpvm_handle_register( + handler: &mut EvmHandler<'_, EXT, DB>, +) { let spec_id = handler.cfg.spec_id; handler.pre_execution.load_precompiles = Arc::new(move || { let mut ctx_precompiles = spec_to_generic!(spec_id, { - revm::optimism::load_precompiles::>>() + revm::optimism::load_precompiles::() }); // Extend with FPVM-accelerated precompiles diff --git a/bin/host/src/lib.rs b/bin/host/src/lib.rs index 0337777c9..42759288c 100644 --- a/bin/host/src/lib.rs +++ b/bin/host/src/lib.rs @@ -92,8 +92,7 @@ pub async fn start_server_and_native_client(cfg: HostCli) -> Result { // Start the client program in a separate child process. let program_task = task::spawn(kona_client::run( OracleReader::new(preimage_chan.client), - HintWriter::new(hint_chan.client), - None, + HintWriter::new(hint_chan.client) )); // Execute both tasks and wait for them to complete. diff --git a/crates/executor/Cargo.toml b/crates/executor/Cargo.toml index 6c2c7ebe3..19fad651e 100644 --- a/crates/executor/Cargo.toml +++ b/crates/executor/Cargo.toml @@ -50,6 +50,7 @@ alloy-rpc-types-engine.workspace = true serde = { workspace = true, features = ["derive"] } criterion = { workspace = true, features = ["html_reports"] } pprof = { workspace = true, features = ["criterion", "flamegraph", "frame-pointer"] } +kona-client.workspace = true [[bench]] name = "execution" diff --git a/crates/executor/benches/execution.rs b/crates/executor/benches/execution.rs index 0ced84e0b..cc98bb675 100644 --- a/crates/executor/benches/execution.rs +++ b/crates/executor/benches/execution.rs @@ -1,19 +1,23 @@ #![allow(missing_docs)] //! Benches for the [StatelessL2BlockExecutor] implementation. +extern crate alloc; +use alloc::sync::Arc; + use alloy_consensus::{Header, Sealable}; use alloy_primitives::{address, b256, hex, Bytes, B256}; use alloy_rlp::Decodable; use alloy_rpc_types_engine::PayloadAttributes; use anyhow::{anyhow, Result}; use criterion::{criterion_group, criterion_main, Bencher, Criterion}; -use kona_executor::{StatelessL2BlockExecutor, TrieDBProvider}; +use kona_executor::{StatelessL2BlockExecutor, TrieDBProvider, DefaultEvmConfig}; use kona_mpt::{NoopTrieHinter, TrieNode, TrieProvider}; use op_alloy_genesis::{RollupConfig, OP_MAINNET_BASE_FEE_PARAMS}; use op_alloy_rpc_types_engine::OpPayloadAttributes; use pprof::criterion::{Output, PProfProfiler}; use serde::Deserialize; use std::collections::HashMap; +use reth_optimism_chainspec::OpChainSpecBuilder; /// A [TrieProvider] implementation that fetches trie nodes and bytecode from the local /// testdata folder. @@ -85,14 +89,20 @@ fn op_mainnet_exec_bench( ..Default::default() }; + let evm_config = DefaultEvmConfig::new( + Arc::new( + OpChainSpecBuilder::optimism_mainnet().build() + ) + ); // Bench the block execution. bencher.iter(|| { - let mut l2_block_executor = StatelessL2BlockExecutor::builder( + let mut l2_block_executor: StatelessL2BlockExecutor<'_, _, _, DefaultEvmConfig> = StatelessL2BlockExecutor::builder( &rollup_config, TestdataTrieProvider::new(data_folder), NoopTrieHinter, ) .with_parent_header(pre_state_header.clone().seal_slow()) + .with_evm_config(evm_config.clone()) .build(); l2_block_executor.execute_payload(payload_attrs.clone()).unwrap(); }); diff --git a/crates/executor/src/errors.rs b/crates/executor/src/errors.rs index 853badc5c..d45fcd50e 100644 --- a/crates/executor/src/errors.rs +++ b/crates/executor/src/errors.rs @@ -46,6 +46,12 @@ pub enum ExecutorError { /// Missing the executor. #[error("Missing the executor")] MissingExecutor, + /// EVM Config error. + #[error("EVM Config error.")] + EvmConfigError, + /// Transaction signature error. + #[error("Transaction signature error")] + TransactionSignatureError } /// A [Result] type for the [ExecutorError] enum. diff --git a/crates/executor/src/executor/builder.rs b/crates/executor/src/executor/builder.rs index 37b023c1c..ec7452513 100644 --- a/crates/executor/src/executor/builder.rs +++ b/crates/executor/src/executor/builder.rs @@ -1,23 +1,12 @@ //! Contains the builder pattern for the [StatelessL2BlockExecutor]. -use super::{StatelessL2BlockExecutor, KonaEvmConfig}; +use super::StatelessL2BlockExecutor; use crate::db::{TrieDB, TrieDBProvider}; use alloy_consensus::{Header, Sealable, Sealed}; use kona_mpt::TrieHinter; use op_alloy_genesis::RollupConfig; -use reth_optimism_chainspec::OpChainSpec; -use alloc::sync::Arc; -use revm::{db::State, handler::register::EvmHandler}; - -/// A type alias for the [revm::handler::register::HandleRegister] for kona's block executor. -pub type KonaHandleRegister = - for<'i> fn(&mut EvmHandler<'i, (), &mut State<&mut TrieDB>>); - -#[derive(Debug)] -enum EvmConfigOrChainSpec { - EvmConfig(C), - ChainSpec(Arc), -} +use op_alloy_consensus::OpTxEnvelope; +use reth_evm::ConfigureEvm; /// The builder pattern for the [StatelessL2BlockExecutor]. #[derive(Debug)] @@ -25,7 +14,7 @@ pub struct StatelessL2BlockExecutorBuilder<'a, F, H, C> where F: TrieDBProvider, H: TrieHinter, - C: KonaEvmConfig, + C: ConfigureEvm, { /// The [RollupConfig]. config: &'a RollupConfig, @@ -35,21 +24,19 @@ where hinter: H, /// The parent [Header] to begin execution from. parent_header: Option>, - /// The [KonaEvmConfig] or chainspec used to derive it. - evm_config: Option>, - /// The [KonaHandleRegister] to use during execution. - handler_register: Option>, + /// The [ConfigureEvm] or chainspec used to derive it. + evm_config: Option, } impl<'a, F, H, C> StatelessL2BlockExecutorBuilder<'a, F, H, C> where F: TrieDBProvider, H: TrieHinter, - C: KonaEvmConfig, + C: ConfigureEvm, { /// Instantiate a new builder with the given [RollupConfig]. pub fn new(config: &'a RollupConfig, provider: F, hinter: H) -> Self { - Self { config, provider, hinter, parent_header: None, evm_config: None, handler_register: None } + Self { config, provider, hinter, parent_header: None, evm_config: None } } /// Set the [Header] to begin execution from. @@ -58,21 +45,10 @@ where self } - /// Set the [KonaHandleRegister] for execution. - pub fn with_handle_register(mut self, handler_register: KonaHandleRegister) -> Self { - self.handler_register = Some(handler_register); - self - } - /// Set the [KonaHandleRegister] for execution. pub fn with_evm_config(mut self, evm_config: C) -> Self { - self.evm_config = Some(EvmConfigOrChainSpec::EvmConfig(evm_config)); - self - } - - /// Set the [KonaHandleRegister] for execution. - pub fn with_chain_spec(mut self, chain_spec: Arc) -> Self { - self.evm_config = Some(EvmConfigOrChainSpec::ChainSpec(chain_spec)); + // ZTODO: Alternative to pass a chainspec here? + self.evm_config = Some(evm_config); self } @@ -83,21 +59,12 @@ where default_header.seal_slow() }); - // ZTODO: error handling - let evm_config = match self.evm_config.unwrap() { - EvmConfigOrChainSpec::EvmConfig(config) => config, - EvmConfigOrChainSpec::ChainSpec(chain_spec) => C::new(chain_spec) - }; + let evm_config = self.evm_config.expect("evm config must be set"); let trie_db = TrieDB::new(parent_header.state_root, parent_header, self.provider, self.hinter); - StatelessL2BlockExecutor { - config: self.config, - trie_db, - evm_config, - handler_register: self.handler_register, - } + StatelessL2BlockExecutor { config: self.config, trie_db, evm_config } } } @@ -106,22 +73,22 @@ mod tests { use super::*; use crate::NoopTrieDBProvider; use kona_mpt::NoopTrieHinter; + use kona_client::DefaultEvmConfig; + use reth_optimism_chainspec::OP_MAINNET; + use alloc::sync::Arc; #[test] fn test_build_full() { let config = RollupConfig::default(); let parent_header = Header::default().seal_slow(); - fn test_handler_register(_: &mut EvmHandler<'_, (), &mut State<&mut TrieDB>>) - where - F: TrieDBProvider, - H: TrieHinter, - { - } + let evm_config = DefaultEvmConfig::new_with_fpvm_precompiles( + (**OP_MAINNET).clone() + ); let executor = StatelessL2BlockExecutorBuilder::new(&config, NoopTrieDBProvider, NoopTrieHinter) - .with_handle_register(test_handler_register) + .with_evm_config(evm_config) .build(); assert_eq!(*executor.config, config); diff --git a/crates/executor/src/executor/evm_config.rs b/crates/executor/src/executor/evm_config.rs index 08ef5d4ed..cc84e6780 100644 --- a/crates/executor/src/executor/evm_config.rs +++ b/crates/executor/src/executor/evm_config.rs @@ -1,49 +1,168 @@ -use reth_evm::{ConfigureEvmEnv, NextBlockEnvAttributes}; -use reth_primitives::TransactionSigned; -use reth_primitives_traits::FillTxEnv; -use reth_optimism_chainspec::{OpChainSpec, DecodeError}; -use reth_optimism_forks::OpHardfork; -use alloy_consensus::{Sealed, Header as AlloyHeader}; -use alloy_primitives::{U256, Address, Bytes, TxKind}; use alloc::{sync::Arc, vec::Vec}; -use revm_primitives::{ - CfgEnv, BlobExcessGasAndPrice, TxEnv, SpecId, HandlerCfg, - BlockEnv, AnalysisKind, CfgEnvWithHandlerCfg +use alloy_consensus::Header; +use alloy_rlp::Encodable; +use alloy_primitives::{Address, Bytes, TxKind, U256}; +use op_alloy_consensus::OpTxEnvelope; +use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes}; +use reth_optimism_chainspec::{DecodeError, OpChainSpec}; +use reth_optimism_forks::OpHardfork; +use revm::{ + primitives::{Env, OptimismFields, BlobExcessGasAndPrice, BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, SpecId, + TransactTo, TxEnv, HandlerCfg, AnalysisKind}, + Database, Evm, EvmBuilder, + db::State, handler::register::EvmHandler }; -use revm::primitives::{Env, OptimismFields}; - -/// Trait for configuring the EVM for custom execution. -pub trait KonaEvmConfig: ConfigureEvmEnv { - /// Create a new instance of the EVM config. - fn new(chain_spec: Arc) -> Self; - - /// Localize a Sealed Alloy Header into the local Header type. - fn localize_alloy_header(header: &Sealed) -> Self::Header; -} +use crate::db::{TrieDB, TrieDBProvider}; +use kona_mpt::TrieHinter; +/// A type alias for the [revm::handler::register::HandleRegister] for kona's block executor. +pub type KonaHandleRegister = + for<'i> fn(&mut EvmHandler<'i, (), &mut State<&mut TrieDB>>); +/// A default implementation of the EVM Config. #[derive(Clone, Debug)] -pub struct DefaultEvmConfig { +pub struct DefaultEvmConfig { chain_spec: Arc, + handler_register: Option>, } -impl KonaEvmConfig for DefaultEvmConfig { - fn new(chain_spec: Arc) -> Self { - Self { chain_spec } - } - - fn localize_alloy_header(header: &Sealed) -> ::Header { - header.inner().clone() +impl DefaultEvmConfig +where + F: TrieDBProvider, + H: TrieHinter, +{ + /// Create a new instance of the default EVM config from a chain spec. + pub const fn new(chain_spec: Arc, handler_register: Option>) -> Self { + Self { chain_spec, handler_register } } } -impl ConfigureEvmEnv for DefaultEvmConfig { - type Header = AlloyHeader; +impl ConfigureEvmEnv for DefaultEvmConfig +where + F: TrieDBProvider + Clone + 'static, + H: TrieHinter + Clone + 'static, +{ + type Header = Header; + type Transaction = OpTxEnvelope; type Error = DecodeError; - /// Fill transaction environment from a [`TransactionSigned`] and the given sender address. - fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) { - transaction.fill_tx_env(tx_env, sender); + /// Fill transaction environment from a [`OpTxEnvelope`] and the given sender address. + fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &OpTxEnvelope, sender: Address) { + match transaction { + OpTxEnvelope::Legacy(signed_tx) => { + let tx = signed_tx.tx(); + tx_env.caller = sender; + tx_env.gas_limit = tx.gas_limit; + tx_env.gas_price = U256::from(tx.gas_price); + tx_env.gas_priority_fee = None; + tx_env.transact_to = match tx.to { + TxKind::Call(to) => TransactTo::Call(to), + TxKind::Create => TransactTo::Create, + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = tx.chain_id; + tx_env.nonce = Some(tx.nonce); + tx_env.access_list.clear(); + tx_env.blob_hashes.clear(); + tx_env.max_fee_per_blob_gas.take(); + tx_env.optimism = OptimismFields { + source_hash: None, + mint: None, + is_system_transaction: Some(false), + enveloped_tx: { + let mut buf = Vec::new(); + transaction.encode(&mut buf); + Some(buf.into()) + }, + }; + } + OpTxEnvelope::Eip2930(signed_tx) => { + let tx = signed_tx.tx(); + tx_env.caller = sender; + tx_env.gas_limit = tx.gas_limit; + tx_env.gas_price = U256::from(tx.gas_price); + tx_env.gas_priority_fee = None; + tx_env.transact_to = match tx.to { + TxKind::Call(to) => TransactTo::Call(to), + TxKind::Create => TransactTo::Create, + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = Some(tx.chain_id); + tx_env.nonce = Some(tx.nonce); + tx_env.access_list = tx.access_list.to_vec(); + tx_env.blob_hashes.clear(); + tx_env.max_fee_per_blob_gas.take(); + tx_env.optimism = OptimismFields { + source_hash: None, + mint: None, + is_system_transaction: Some(false), + enveloped_tx: { + let mut buf = Vec::new(); + transaction.encode(&mut buf); + Some(buf.into()) + }, + }; + } + OpTxEnvelope::Eip1559(signed_tx) => { + let tx = signed_tx.tx(); + tx_env.caller = sender; + tx_env.gas_limit = tx.gas_limit; + tx_env.gas_price = U256::from(tx.max_fee_per_gas); + tx_env.gas_priority_fee = Some(U256::from(tx.max_priority_fee_per_gas)); + tx_env.transact_to = match tx.to { + TxKind::Call(to) => TransactTo::Call(to), + TxKind::Create => TransactTo::Create, + }; + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = Some(tx.chain_id); + tx_env.nonce = Some(tx.nonce); + tx_env.access_list = tx.access_list.to_vec(); + tx_env.blob_hashes.clear(); + tx_env.max_fee_per_blob_gas.take(); + tx_env.optimism = OptimismFields { + source_hash: None, + mint: None, + is_system_transaction: Some(false), + enveloped_tx: { + let mut buf = Vec::new(); + transaction.encode(&mut buf); + Some(buf.into()) + }, + }; + } + OpTxEnvelope::Deposit(tx) => { + tx_env.caller = tx.from; + tx_env.access_list.clear(); + tx_env.gas_limit = tx.gas_limit; + tx_env.gas_price = U256::ZERO; + tx_env.gas_priority_fee = None; + match tx.to { + TxKind::Call(to) => tx_env.transact_to = TransactTo::Call(to), + TxKind::Create => tx_env.transact_to = TransactTo::Create, + } + tx_env.value = tx.value; + tx_env.data = tx.input.clone(); + tx_env.chain_id = None; + tx_env.nonce = None; + tx_env.optimism = OptimismFields { + source_hash: Some(tx.source_hash), + mint: tx.mint, + is_system_transaction: Some(tx.is_system_transaction), + enveloped_tx: { + let mut buf = Vec::new(); + transaction.encode(&mut buf); + Some(buf.into()) + }, + }; + } + _ => { + // ZTODO: no return, how to better handle errors? + panic!("Unsupported transaction type"); + } + } } /// Fill transaction environment with a system contract call. @@ -147,7 +266,6 @@ impl ConfigureEvmEnv for DefaultEvmConfig { blob_excess_gas_and_price, }; - // ZTODO: Understand plugging in OSAKA here for features, where else? let cfg_with_handler_cfg; { cfg_with_handler_cfg = CfgEnvWithHandlerCfg { @@ -160,11 +278,17 @@ impl ConfigureEvmEnv for DefaultEvmConfig { } } +impl ConfigureEvm for DefaultEvmConfig { + type DefaultExternalContext<'a> = (); + + fn evm(&self, db: DB) -> Evm<'_, Self::DefaultExternalContext<'_>, DB> { + EvmBuilder::default().with_db(db).optimism().build() + } + + fn default_external_context<'a>(&self) -> Self::DefaultExternalContext<'a> {} +} -fn revm_spec_by_timestamp_after_bedrock( - chain_spec: &OpChainSpec, - timestamp: u64, -) -> SpecId { +fn revm_spec_by_timestamp_after_bedrock(chain_spec: &OpChainSpec, timestamp: u64) -> SpecId { if chain_spec.fork(OpHardfork::Holocene).active_at_timestamp(timestamp) { revm_primitives::HOLOCENE } else if chain_spec.fork(OpHardfork::Granite).active_at_timestamp(timestamp) { diff --git a/crates/executor/src/executor/mod.rs b/crates/executor/src/executor/mod.rs index 6f431fbd2..3e9634fd5 100644 --- a/crates/executor/src/executor/mod.rs +++ b/crates/executor/src/executor/mod.rs @@ -9,26 +9,20 @@ use crate::{ }; use alloc::vec::Vec; use alloy_consensus::{Header, Sealable, Transaction, EMPTY_OMMER_ROOT_HASH, EMPTY_ROOT_HASH}; +use alloy_primitives::Address; use alloy_eips::eip2718::{Decodable2718, Encodable2718}; use alloy_primitives::{keccak256, logs_bloom, Bytes, Log, B256, U256}; use kona_mpt::{ordered_trie_with_encoder, TrieHinter}; use op_alloy_consensus::{OpReceiptEnvelope, OpTxEnvelope}; use op_alloy_genesis::RollupConfig; use op_alloy_rpc_types_engine::OpPayloadAttributes; -use revm::{ - db::{states::bundle_state::BundleRetention, State}, - Evm, -}; +use revm::db::{states::bundle_state::BundleRetention, State}; use revm_primitives::{calc_excess_blob_gas, EnvWithHandlerCfg}; mod builder; -pub use builder::{KonaHandleRegister, StatelessL2BlockExecutorBuilder}; - -use reth_evm::NextBlockEnvAttributes; -use reth_primitives::TransactionSigned; +pub use builder::StatelessL2BlockExecutorBuilder; -mod evm_config; -pub use evm_config::KonaEvmConfig; +use reth_evm::{ConfigureEvm, NextBlockEnvAttributes}; mod util; use util::encode_holocene_eip_1559_params; @@ -40,23 +34,21 @@ pub struct StatelessL2BlockExecutor<'a, F, H, C> where F: TrieDBProvider, H: TrieHinter, - C: KonaEvmConfig, + C: ConfigureEvm, { /// The [RollupConfig]. config: &'a RollupConfig, /// The inner state database component. trie_db: TrieDB, - /// The [KonaEvmConfig] used for execution. + /// The [ConfigureEvm] used for execution. evm_config: C, - /// The [KonaHandleRegister] to use during execution. - handler_register: Option>, } impl<'a, F, H, C> StatelessL2BlockExecutor<'a, F, H, C> where F: TrieDBProvider, H: TrieHinter, - C: KonaEvmConfig, + C: ConfigureEvm, { /// Constructs a new [StatelessL2BlockExecutorBuilder] with the given [RollupConfig]. pub fn builder( @@ -90,11 +82,10 @@ where prev_randao: payload.payload_attributes.prev_randao, }; - // TODO: error handling + let parent_header = self.trie_db.parent_block_header(); let (initialized_cfg, initialized_block_env) = - self.evm_config.next_cfg_and_block_env( - &C::localize_alloy_header(&self.trie_db.parent_block_header()), next_block_env_attrs - ).unwrap(); + self.evm_config.next_cfg_and_block_env(&parent_header, next_block_env_attrs).map_err( + |_| ExecutorError::EvmConfigError)?; let block_number = initialized_block_env.number.to::(); let base_fee = initialized_block_env.basefee.to::(); @@ -113,8 +104,6 @@ where let mut state = State::builder().with_database(&mut self.trie_db).with_bundle_update().build(); - - // ZTODO: Confirm ok to change this order // Ensure that the create2 contract is deployed upon transition to the Canyon hardfork. ensure_create2_deployer_canyon( &mut state, @@ -124,21 +113,12 @@ where // Construct the block-scoped EVM with the given configuration. // The transaction environment is set within the loop for each transaction. - let mut evm = { - let env_with_handler_cfg = EnvWithHandlerCfg::new_with_cfg_env( - initialized_cfg.clone(), - initialized_block_env.clone(), - Default::default(), - ); - - let mut base = Evm::builder().with_db(&mut state).with_env_with_handler_cfg(env_with_handler_cfg); - - if let Some(handler) = self.handler_register { - base = base.append_handler_register(handler); - } - - base.build() - }; + let env_with_handler_cfg = EnvWithHandlerCfg::new_with_cfg_env( + initialized_cfg, + initialized_block_env, + Default::default(), + ); + let mut evm = self.evm_config.evm_with_env(&mut state, env_with_handler_cfg); // Apply the pre-block EIP-4788 contract call. apply_beacon_root_contract_call( @@ -147,7 +127,7 @@ where payload.payload_attributes.timestamp, block_number, payload.payload_attributes.parent_beacon_block_root, - &mut evm + &mut evm, )?; let mut cumulative_gas_used = 0u64; @@ -175,10 +155,7 @@ where } // Modify the transaction environment with the current transaction. - // ZTODO: error handling - // ZTODO: clone required but says unnecessary - let reth_tx = TransactionSigned::decode_2718(&mut raw_transaction.clone()).unwrap(); - self.evm_config.fill_tx_env(evm.tx_mut(), &reth_tx, reth_tx.recover_signer().unwrap()); + self.evm_config.fill_tx_env(evm.tx_mut(), &transaction, Address::from([0; 20])); // If the transaction is a deposit, cache the depositor account. // @@ -464,11 +441,16 @@ mod test { use alloy_primitives::{b256, hex}; use alloy_rlp::Decodable; use alloy_rpc_types_engine::PayloadAttributes; + use alloy_eips::eip1559::BaseFeeParams; use anyhow::{anyhow, Result}; use kona_mpt::{NoopTrieHinter, TrieNode, TrieProvider}; use op_alloy_genesis::OP_MAINNET_BASE_FEE_PARAMS; use serde::Deserialize; use std::collections::HashMap; + use reth_optimism_chainspec::{OpChainSpec, OpChainSpecBuilder, OP_MAINNET}; + use reth_optimism_forks::OpHardfork; + use kona_client::DefaultEvmConfig; + use alloc::sync::Arc; /// A [TrieProvider] implementation that fetches trie nodes and bytecode from the local /// testdata folder. @@ -546,12 +528,17 @@ mod test { let expected_header = Header::decode(&mut &raw_expected_header[..]).unwrap(); // Initialize the block executor on block #120794431's post-state. - let mut l2_block_executor = StatelessL2BlockExecutor::builder( + let evm_config = DefaultEvmConfig::new_with_fpvm_precompiles( + Arc::new((**OP_MAINNET).clone()), + ); + + let mut l2_block_executor: StatelessL2BlockExecutor<'_, TestdataTrieProvider, NoopTrieHinter, DefaultEvmConfig> = StatelessL2BlockExecutor::builder( &rollup_config, TestdataTrieProvider::new("block_120794432_exec"), NoopTrieHinter, ) .with_parent_header(header.seal_slow()) + .with_evm_config(evm_config) .build(); let raw_tx = hex!("7ef8f8a003b511b9b71520cd62cad3b5fd5b1b8eaebd658447723c31c7f1eba87cfe98c894deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8a4440a5e2000000558000c5fc5000000000000000300000000665a33a70000000001310e960000000000000000000000000000000000000000000000000000000214d2697300000000000000000000000000000000000000000000000000000000000000015346d208a396843018a2e666c8e7832067358433fb87ca421273c6a4e69f78d50000000000000000000000006887246668a3b87f54deb3b94ba47a6f63f32985"); @@ -607,12 +594,17 @@ mod test { let expected_header = Header::decode(&mut &raw_expected_header[..]).unwrap(); // Initialize the block executor on block #121049888's post-state. - let mut l2_block_executor = StatelessL2BlockExecutor::builder( + let evm_config = DefaultEvmConfig::new_with_fpvm_precompiles( + Arc::new((**OP_MAINNET).clone()), + ); + + let mut l2_block_executor: StatelessL2BlockExecutor<'_, TestdataTrieProvider, NoopTrieHinter, DefaultEvmConfig> = StatelessL2BlockExecutor::builder( &rollup_config, TestdataTrieProvider::new("block_121049889_exec"), NoopTrieHinter, ) .with_parent_header(parent_header.seal_slow()) + .with_evm_config(evm_config) .build(); let raw_txs = alloc::vec![ @@ -672,12 +664,17 @@ mod test { let expected_header = Header::decode(&mut &raw_expected_header[..]).unwrap(); // Initialize the block executor on block #121003240's post-state. - let mut l2_block_executor = StatelessL2BlockExecutor::builder( + let evm_config = DefaultEvmConfig::new_with_fpvm_precompiles( + Arc::new((**OP_MAINNET).clone()), + ); + + let mut l2_block_executor: StatelessL2BlockExecutor<'_, TestdataTrieProvider, NoopTrieHinter, DefaultEvmConfig> = StatelessL2BlockExecutor::builder( &rollup_config, TestdataTrieProvider::new("block_121003241_exec"), NoopTrieHinter, ) .with_parent_header(parent_header.seal_slow()) + .with_evm_config(evm_config) .build(); let raw_txs = alloc::vec![ @@ -744,12 +741,17 @@ mod test { let expected_header = Header::decode(&mut &raw_expected_header[..]).unwrap(); // Initialize the block executor on block #121057302's post-state. - let mut l2_block_executor = StatelessL2BlockExecutor::builder( + let evm_config = DefaultEvmConfig::new_with_fpvm_precompiles( + Arc::new((**OP_MAINNET).clone()), + ); + + let mut l2_block_executor: StatelessL2BlockExecutor<'_, TestdataTrieProvider, NoopTrieHinter, DefaultEvmConfig> = StatelessL2BlockExecutor::builder( &rollup_config, TestdataTrieProvider::new("block_121057303_exec"), NoopTrieHinter, ) .with_parent_header(parent_header.seal_slow()) + .with_evm_config(evm_config) .build(); let raw_txs = alloc::vec![ @@ -809,13 +811,18 @@ mod test { let raw_expected_header = hex!("f90246a024c6416b9d3f0546dfa2d536403232d36cf91d5d38236655e2e580c1642fdbaca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347944200000000000000000000000000000000000011a01477b41c16571887dd0cfacd4972f67d98079cbaa4bf98244eacde4aef8d1ab7a043ab54ba630647289234e3e63861b49d99e839e78852450508d457e524eed43fa042351814b43a1a58a71fdff474360fbb9e510393764863cb04bde6fd4ca0367eb9010008408008c6000010581104c08c41068c8098020012402058d084a18a6408012213000000b02000000000102020800040202162c0424210820040e0405020215810c200800000000001a1000c480044002500011480822041080080c60e001840890a20850016240003012540010060c82006058024020014005480118000040a410c400000260800900000030004486a0820000c884400038060c08981201010322c060008200022100008195004cc082001049028d80000088000000000d402410030020080a102c2e00e1e141000044000208240045804001008018000800041110c1d0a4222056000201500806200190400049851890037500ac089c3000080840737513d8401c9c38084019fe25b8466627c3380a0c7acc30c856d749a81902d811e879e8dae5de2e022091aaa7eb4b586dcd3d05288000000000000000084039231b0a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b4218080a0a4414c4984ce7285b82bd9b21c642af30f0f648fb6f4929b67753e7345a06bab"); let expected_header = Header::decode(&mut &raw_expected_header[..]).unwrap(); - // Initialize the block executor on block #121057302's post-state. - let mut l2_block_executor = StatelessL2BlockExecutor::builder( + // Initialize the block executor on block #121065788's post-state. + let evm_config = DefaultEvmConfig::new_with_fpvm_precompiles( + Arc::new((**OP_MAINNET).clone()), + ); + + let mut l2_block_executor: StatelessL2BlockExecutor<'_, TestdataTrieProvider, NoopTrieHinter, DefaultEvmConfig> = StatelessL2BlockExecutor::builder( &rollup_config, TestdataTrieProvider::new("block_121065789_exec"), NoopTrieHinter, ) .with_parent_header(parent_header.seal_slow()) + .with_evm_config(evm_config) .build(); let raw_txs = alloc::vec![ @@ -885,12 +892,17 @@ mod test { let expected_header = Header::decode(&mut &raw_expected_header[..]).unwrap(); // Initialize the block executor on block #121135703's post-state. - let mut l2_block_executor = StatelessL2BlockExecutor::builder( + let evm_config = DefaultEvmConfig::new_with_fpvm_precompiles( + Arc::new((**OP_MAINNET).clone()), + ); + + let mut l2_block_executor: StatelessL2BlockExecutor<'_, TestdataTrieProvider, NoopTrieHinter, DefaultEvmConfig> = StatelessL2BlockExecutor::builder( &rollup_config, TestdataTrieProvider::new("block_121135704_exec"), NoopTrieHinter, ) .with_parent_header(parent_header.seal_slow()) + .with_evm_config(evm_config) .build(); let raw_txs = alloc::vec![ diff --git a/crates/executor/src/lib.rs b/crates/executor/src/lib.rs index b8226e95b..a4812aa23 100644 --- a/crates/executor/src/lib.rs +++ b/crates/executor/src/lib.rs @@ -17,7 +17,7 @@ pub use errors::{ExecutorError, ExecutorResult, TrieDBError, TrieDBResult}; mod executor; pub use executor::{ - KonaHandleRegister, StatelessL2BlockExecutor, StatelessL2BlockExecutorBuilder, KonaEvmConfig + StatelessL2BlockExecutor, StatelessL2BlockExecutorBuilder }; mod db; diff --git a/crates/executor/src/syscalls/eip4788.rs b/crates/executor/src/syscalls/eip4788.rs index 545a2d5de..c7c4bc5a3 100644 --- a/crates/executor/src/syscalls/eip4788.rs +++ b/crates/executor/src/syscalls/eip4788.rs @@ -3,7 +3,6 @@ use crate::{ db::TrieDB, errors::{ExecutorError, ExecutorResult}, - executor::KonaEvmConfig, TrieDBProvider, }; use alloc::boxed::Box; @@ -15,15 +14,16 @@ use revm::{ db::State, DatabaseCommit, Evm, }; +use reth_evm::ConfigureEvm; /// Apply the EIP-4788 pre-block beacon root contract call to a given EVM instance. -pub(crate) fn apply_beacon_root_contract_call( +pub(crate) fn apply_beacon_root_contract_call( config: &RollupConfig, evm_config: &C, timestamp: u64, block_number: u64, parent_beacon_block_root: Option, - evm: &mut Evm<'_, (), &mut State<&mut TrieDB>>, + evm: &mut Evm<'_, C::DefaultExternalContext<'_>, &mut State<&mut TrieDB>>, ) -> ExecutorResult<()> where F: TrieDBProvider, diff --git a/crates/proof-sdk/proof/Cargo.toml b/crates/proof-sdk/proof/Cargo.toml index d7b0ef702..b9020e5ba 100644 --- a/crates/proof-sdk/proof/Cargo.toml +++ b/crates/proof-sdk/proof/Cargo.toml @@ -32,7 +32,9 @@ op-alloy-consensus.workspace = true op-alloy-genesis = { workspace = true, features = ["serde"] } op-alloy-rpc-types-engine = { workspace = true, features = ["serde"] } +# Reth reth-optimism-chainspec.workspace = true +reth-evm.workspace = true # General lru.workspace = true diff --git a/crates/proof-sdk/proof/src/executor.rs b/crates/proof-sdk/proof/src/executor.rs index 3ceaaba0a..229525230 100644 --- a/crates/proof-sdk/proof/src/executor.rs +++ b/crates/proof-sdk/proof/src/executor.rs @@ -5,17 +5,20 @@ use alloy_consensus::{Header, Sealed}; use alloy_primitives::B256; use async_trait::async_trait; use kona_driver::Executor; -use kona_executor::{KonaHandleRegister, StatelessL2BlockExecutor, TrieDBProvider}; +use kona_executor::{StatelessL2BlockExecutor, TrieDBProvider}; +use op_alloy_consensus::OpTxEnvelope; +use reth_evm::ConfigureEvm; use kona_mpt::TrieHinter; use op_alloy_genesis::RollupConfig; use op_alloy_rpc_types_engine::OpPayloadAttributes; /// An executor wrapper type. #[derive(Debug)] -pub struct KonaExecutor<'a, P, H> +pub struct KonaExecutor<'a, P, H, C> where P: TrieDBProvider + Send + Sync + Clone, H: TrieHinter + Send + Sync + Clone, + C: ConfigureEvm, { /// The rollup config for the executor. rollup_config: &'a Arc, @@ -23,34 +26,36 @@ where trie_provider: P, /// The trie hinter for the executor. trie_hinter: H, - /// The handle register for the executor. - handle_register: Option>, + /// EVM config. + evm_config: C, /// The executor. - inner: Option>, + inner: Option>, } -impl<'a, P, H> KonaExecutor<'a, P, H> +impl<'a, P, H, C> KonaExecutor<'a, P, H, C> where P: TrieDBProvider + Send + Sync + Clone, H: TrieHinter + Send + Sync + Clone, + C: ConfigureEvm, { /// Creates a new executor. pub const fn new( rollup_config: &'a Arc, trie_provider: P, trie_hinter: H, - handle_register: Option>, - inner: Option>, + evm_config: C, + inner: Option>, ) -> Self { - Self { rollup_config, trie_provider, trie_hinter, handle_register, inner } + Self { rollup_config, trie_provider, trie_hinter, evm_config, inner } } } #[async_trait] -impl Executor for KonaExecutor<'_, P, H> +impl Executor for KonaExecutor<'_, P, H, C> where P: TrieDBProvider + Send + Sync + Clone, H: TrieHinter + Send + Sync + Clone, + C: ConfigureEvm, { type Error = kona_executor::ExecutorError; @@ -65,16 +70,14 @@ where /// Since the L2 block executor is stateless, on an update to the safe head, /// a new executor is created with the updated header. fn update_safe_head(&mut self, header: Sealed
) { - let mut builder = StatelessL2BlockExecutor::builder( + let builder = StatelessL2BlockExecutor::builder( self.rollup_config, self.trie_provider.clone(), self.trie_hinter.clone(), ) - .with_parent_header(header); + .with_parent_header(header) + .with_evm_config(self.evm_config.clone()); - if let Some(register) = self.handle_register { - builder = builder.with_handle_register(register); - } self.inner = Some(builder.build()); }