From e38f994d3ed8e409bb43c0dbc0d6a029ecb679f7 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 2 Feb 2024 22:58:50 +0100 Subject: [PATCH 01/12] refactor: rm `CallRequest` --- Cargo.lock | 240 ++++++++++-------- Cargo.toml | 10 +- crates/primitives/src/proofs.rs | 15 +- crates/rpc/rpc-api/src/debug.rs | 4 +- crates/rpc/rpc-api/src/engine.rs | 4 +- crates/rpc/rpc-api/src/eth.rs | 10 +- crates/rpc/rpc-api/src/trace.rs | 6 +- crates/rpc/rpc-testing-util/src/debug.rs | 8 +- crates/rpc/rpc-testing-util/src/trace.rs | 14 +- .../rpc-types-compat/src/transaction/mod.rs | 18 +- crates/rpc/rpc/src/debug.rs | 24 +- crates/rpc/rpc/src/engine.rs | 4 +- 12 files changed, 200 insertions(+), 157 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7c1e8e3e6a..08563110dc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,10 +173,10 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#48f1c0fbf6e22f09c1b3f297955f5acea0b0f99d" +source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" dependencies = [ "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", "serde", ] @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-node-bindings" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#48f1c0fbf6e22f09c1b3f297955f5acea0b0f99d" +source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -256,11 +256,11 @@ dependencies = [ [[package]] name = "alloy-rpc-engine-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#48f1c0fbf6e22f09c1b3f297955f5acea0b0f99d" +source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", "ethereum_ssz", "ethereum_ssz_derive", "jsonrpsee-types", @@ -271,10 +271,21 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#48f1c0fbf6e22f09c1b3f297955f5acea0b0f99d" +source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" dependencies = [ "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-rpc-trace-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#80206e7ba7686c514da291c06a5e7912b5361047" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy)", "serde", "serde_json", ] @@ -282,7 +293,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#48f1c0fbf6e22f09c1b3f297955f5acea0b0f99d" +source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -298,6 +309,19 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-rpc-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#80206e7ba7686c514da291c06a5e7912b5361047" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "itertools 0.12.1", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "alloy-sol-macro" version = "0.6.2" @@ -394,9 +418,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -844,16 +868,16 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.69.2" +version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c69fae65a523209d34240b60abe0c42d33d1045d445c0839d8a4894a736e2d" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ "bitflags 2.4.2", "cexpr", "clang-sys", + "itertools 0.12.1", "lazy_static", "lazycell", - "peeking_take_while", "proc-macro2", "quote", "regex", @@ -1163,9 +1187,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.14.1" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" [[package]] name = "byteorder" @@ -1207,9 +1231,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" +checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" dependencies = [ "serde", ] @@ -1339,9 +1363,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", "clap_derive", @@ -1349,21 +1373,21 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.10.0", + "strsim 0.11.0", ] [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck", "proc-macro2", @@ -1373,9 +1397,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "cli-extension-event-hooks" @@ -1510,9 +1534,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5104de16b218eddf8e34ffe2f86f74bfa4e61e95a1b89732fccf6325efd0557" +checksum = "18d59688ad0945eaf6b84cb44fedbe93484c81b48970e98f09db8a22832d7961" dependencies = [ "cfg-if", "cpufeatures", @@ -2251,9 +2275,9 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", @@ -2787,9 +2811,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" +checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" [[package]] name = "findshlibs" @@ -3046,9 +3070,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "git2" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" +checksum = "1b3ba52851e73b46a4c3df1d89343741112003f0f6f13beb0dfac9e457c3fdcd" dependencies = [ "bitflags 2.4.2", "libc", @@ -3217,9 +3241,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -3772,12 +3796,12 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +checksum = "fe8f25ce1159c7740ff0b9b2f5cdf4a8428742ba7c112b9f20f22cd5219c7dab" dependencies = [ "hermit-abi", - "rustix", + "libc", "windows-sys 0.52.0", ] @@ -3847,18 +3871,18 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -4113,9 +4137,9 @@ dependencies = [ [[package]] name = "libgit2-sys" -version = "0.16.1+1.7.1" +version = "0.16.2+1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" +checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" dependencies = [ "cc", "libc", @@ -4584,9 +4608,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] @@ -4609,19 +4633,18 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" dependencies = [ "autocfg", "num-integer", @@ -4642,9 +4665,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", @@ -4961,9 +4984,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" +checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" dependencies = [ "memchr", "thiserror", @@ -6239,7 +6262,7 @@ dependencies = [ name = "reth-mdbx-sys" version = "0.1.0-alpha.17" dependencies = [ - "bindgen 0.69.2", + "bindgen 0.69.4", "cc", "libc", ] @@ -6813,8 +6836,8 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-engine-types", - "alloy-rpc-trace-types", - "alloy-rpc-types", + "alloy-rpc-trace-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", "arbitrary", "bytes", "ethereum_ssz", @@ -6838,7 +6861,7 @@ name = "reth-rpc-types-compat" version = "0.1.0-alpha.17" dependencies = [ "alloy-rlp", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", "reth-primitives", "reth-rpc-types", "serde_json", @@ -7004,8 +7027,8 @@ dependencies = [ [[package]] name = "revm" -version = "3.5.0" -source = "git+https://github.com/bluealloy/revm?branch=main#45403345c18c4395be3bf0d5940e1bba53852613" +version = "4.0.0" +source = "git+https://github.com/bluealloy/revm?branch=main#bbca12830be2757ff3e608a36f062f5e2d62231b" dependencies = [ "auto_impl", "cfg-if", @@ -7021,8 +7044,8 @@ version = "0.1.0" source = "git+https://github.com/paradigmxyz/evm-inspectors?branch=main#573cf0f09c8f0f267dd387e8e4d13d75e09021c7" dependencies = [ "alloy-primitives", - "alloy-rpc-trace-types", - "alloy-rpc-types", + "alloy-rpc-trace-types 0.1.0 (git+https://github.com/alloy-rs/alloy)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy)", "alloy-sol-types", "boa_engine", "boa_gc", @@ -7034,8 +7057,8 @@ dependencies = [ [[package]] name = "revm-interpreter" -version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=main#45403345c18c4395be3bf0d5940e1bba53852613" +version = "2.0.0" +source = "git+https://github.com/bluealloy/revm?branch=main#bbca12830be2757ff3e608a36f062f5e2d62231b" dependencies = [ "revm-primitives", "serde", @@ -7043,8 +7066,8 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "2.2.0" -source = "git+https://github.com/bluealloy/revm?branch=main#45403345c18c4395be3bf0d5940e1bba53852613" +version = "3.0.0" +source = "git+https://github.com/bluealloy/revm?branch=main#bbca12830be2757ff3e608a36f062f5e2d62231b" dependencies = [ "aurora-engine-modexp", "blst", @@ -7060,8 +7083,8 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=main#45403345c18c4395be3bf0d5940e1bba53852613" +version = "2.0.0" +source = "git+https://github.com/bluealloy/revm?branch=main#bbca12830be2757ff3e608a36f062f5e2d62231b" dependencies = [ "alloy-primitives", "auto_impl", @@ -7626,9 +7649,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.6.0" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b0ed1662c5a68664f45b76d18deb0e234aff37207086803165c961eb695e981" +checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270" dependencies = [ "base64 0.21.7", "chrono", @@ -7636,6 +7659,7 @@ dependencies = [ "indexmap 1.9.3", "indexmap 2.2.2", "serde", + "serde_derive", "serde_json", "serde_with_macros", "time", @@ -7643,9 +7667,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.6.0" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568577ff0ef47b879f736cd66740e022f3672788cdf002a05a4e609ea5a6fb15" +checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d" dependencies = [ "darling 0.20.5", "proc-macro2", @@ -7848,9 +7872,9 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "sketches-ddsketch" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a406c1882ed7f29cd5e248c9848a80e7cb6ae0fea82346d2746f2f941c07e1" +checksum = "85636c14b73d81f541e525f585c0a2109e6744e1565b5c1668e31c70c10ed65c" [[package]] name = "slab" @@ -7981,6 +8005,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + [[package]] name = "strum" version = "0.25.0" @@ -8166,13 +8196,12 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall 0.4.1", "rustix", "windows-sys 0.52.0", ] @@ -8500,14 +8529,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a4b9e8023eb94392d3dca65d717c53abc5dad49c07cb65bb8fcd87115fa325" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.21.1", + "toml_edit 0.22.4", ] [[package]] @@ -8546,6 +8575,17 @@ name = "toml_edit" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap 2.2.2", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" dependencies = [ "indexmap 2.2.2", "serde", @@ -8955,9 +8995,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -9129,9 +9169,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -9139,9 +9179,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -9154,9 +9194,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -9166,9 +9206,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -9176,9 +9216,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -9189,9 +9229,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-streams" @@ -9208,9 +9248,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -9412,9 +9452,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.37" +version = "0.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index c731577fabe..8e1d3c4c11d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -184,11 +184,11 @@ alloy-dyn-abi = "0.6" alloy-sol-types = "0.6" alloy-rlp = "0.3" alloy-trie = "0.2" -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" } -alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" } -alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy" } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy" } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } +alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } +alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } ethers-core = { version = "2.0", default-features = false } ethers-providers = { version = "2.0", default-features = false } ethers-signers = { version = "2.0", default-features = false } diff --git a/crates/primitives/src/proofs.rs b/crates/primitives/src/proofs.rs index 6389f59b23e..bd1a37c92e3 100644 --- a/crates/primitives/src/proofs.rs +++ b/crates/primitives/src/proofs.rs @@ -86,8 +86,8 @@ pub fn calculate_receipt_root( // encoding. In the Regolith Hardfork, we must strip the deposit nonce from the // receipts before calculating the receipt root. This was corrected in the Canyon // hardfork. - if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) && - !chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp) + if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) + && !chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp) { let receipts = receipts .iter() @@ -100,7 +100,7 @@ pub fn calculate_receipt_root( return ordered_trie_root_with_encoder(receipts.as_slice(), |r, buf| { r.encode_inner(buf, false) - }) + }); } ordered_trie_root_with_encoder(receipts, |r, buf| r.encode_inner(buf, false)) @@ -130,8 +130,8 @@ pub fn calculate_receipt_root_ref( // encoding. In the Regolith Hardfork, we must strip the deposit nonce from the // receipts before calculating the receipt root. This was corrected in the Canyon // hardfork. - if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) && - !chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp) + if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) + && !chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp) { let receipts = receipts .iter() @@ -144,7 +144,7 @@ pub fn calculate_receipt_root_ref( return ordered_trie_root_with_encoder(&receipts, |r, buf| { ReceiptWithBloomRef::from(r).encode_inner(buf, false) - }) + }); } ordered_trie_root_with_encoder(receipts, |r, buf| { @@ -156,7 +156,7 @@ pub fn calculate_receipt_root_ref( pub fn calculate_ommers_root(ommers: &[Header]) -> B256 { // Check if `ommers` list is empty if ommers.is_empty() { - return EMPTY_OMMER_ROOT_HASH + return EMPTY_OMMER_ROOT_HASH; } // RLP Encode let mut ommers_rlp = Vec::new(); @@ -627,6 +627,7 @@ mod tests { let mut genesis_alloc = HashMap::new(); genesis_alloc .insert(test_addr, GenesisAccount { balance: U256::MAX, ..Default::default() }); + let root = state_root_unhashed(genesis_alloc); assert_eq!(root, expected_root); diff --git a/crates/rpc/rpc-api/src/debug.rs b/crates/rpc/rpc-api/src/debug.rs index 3304d672b1a..b9bae42079f 100644 --- a/crates/rpc/rpc-api/src/debug.rs +++ b/crates/rpc/rpc-api/src/debug.rs @@ -5,7 +5,7 @@ use reth_rpc_types::{ BlockTraceResult, GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, TraceResult, }, - Bundle, CallRequest, RichBlock, StateContext, + Bundle, RichBlock, StateContext, TransactionRequest, }; /// Debug rpc interface. @@ -102,7 +102,7 @@ pub trait DebugApi { #[method(name = "traceCall")] async fn debug_trace_call( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, opts: Option, ) -> RpcResult; diff --git a/crates/rpc/rpc-api/src/engine.rs b/crates/rpc/rpc-api/src/engine.rs index 15a6deb820e..6320afc8439 100644 --- a/crates/rpc/rpc-api/src/engine.rs +++ b/crates/rpc/rpc-api/src/engine.rs @@ -13,7 +13,7 @@ use reth_rpc_types::{ ForkchoiceUpdated, PayloadId, PayloadStatus, TransitionConfiguration, }, state::StateOverride, - BlockOverrides, CallRequest, Filter, Log, RichBlock, SyncStatus, + BlockOverrides, Filter, Log, RichBlock, SyncStatus, TransactionRequest, }; // NOTE: We can't use associated types in the `EngineApi` trait because of jsonrpsee, so we use a @@ -183,7 +183,7 @@ pub trait EngineEthApi { #[method(name = "call")] async fn call( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, state_overrides: Option, block_overrides: Option>, diff --git a/crates/rpc/rpc-api/src/eth.rs b/crates/rpc/rpc-api/src/eth.rs index c301864ee02..6ae452e2186 100644 --- a/crates/rpc/rpc-api/src/eth.rs +++ b/crates/rpc/rpc-api/src/eth.rs @@ -4,7 +4,7 @@ use reth_primitives::{ Address, BlockId, BlockNumberOrTag, Bytes, B256, B64, U256, U64, }; use reth_rpc_types::{ - state::StateOverride, AccessListWithGasUsed, BlockOverrides, Bundle, CallRequest, + state::StateOverride, AccessListWithGasUsed, BlockOverrides, Bundle, EIP1186AccountProofResponse, EthCallResponse, FeeHistory, Index, RichBlock, StateContext, SyncStatus, Transaction, TransactionReceipt, TransactionRequest, Work, }; @@ -146,7 +146,7 @@ pub trait EthApi { #[method(name = "call")] async fn call( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, state_overrides: Option, block_overrides: Option>, @@ -179,7 +179,7 @@ pub trait EthApi { #[method(name = "createAccessList")] async fn create_access_list( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, ) -> RpcResult; @@ -188,7 +188,7 @@ pub trait EthApi { #[method(name = "estimateGas")] async fn estimate_gas( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, state_override: Option, ) -> RpcResult; @@ -262,7 +262,7 @@ pub trait EthApi { /// Signs a transaction that can be submitted to the network at a later time using with /// `sendRawTransaction.` #[method(name = "signTransaction")] - async fn sign_transaction(&self, transaction: CallRequest) -> RpcResult; + async fn sign_transaction(&self, transaction: TransactionRequest) -> RpcResult; /// Signs data via [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md). #[method(name = "signTypedData")] diff --git a/crates/rpc/rpc-api/src/trace.rs b/crates/rpc/rpc-api/src/trace.rs index 557016a9a57..9caf4a1d487 100644 --- a/crates/rpc/rpc-api/src/trace.rs +++ b/crates/rpc/rpc-api/src/trace.rs @@ -3,7 +3,7 @@ use reth_primitives::{BlockId, Bytes, B256}; use reth_rpc_types::{ state::StateOverride, trace::{filter::TraceFilter, parity::*}, - BlockOverrides, CallRequest, Index, + BlockOverrides, Index, TransactionRequest, }; use std::collections::HashSet; @@ -15,7 +15,7 @@ pub trait TraceApi { #[method(name = "call")] async fn trace_call( &self, - call: CallRequest, + call: TransactionRequest, trace_types: HashSet, block_id: Option, state_overrides: Option, @@ -28,7 +28,7 @@ pub trait TraceApi { #[method(name = "callMany")] async fn trace_call_many( &self, - calls: Vec<(CallRequest, HashSet)>, + calls: Vec<(TransactionRequest, HashSet)>, block_id: Option, ) -> RpcResult>; diff --git a/crates/rpc/rpc-testing-util/src/debug.rs b/crates/rpc/rpc-testing-util/src/debug.rs index 7e40e7778af..282a11308a5 100644 --- a/crates/rpc/rpc-testing-util/src/debug.rs +++ b/crates/rpc/rpc-testing-util/src/debug.rs @@ -6,7 +6,7 @@ use reth_primitives::{BlockId, TxHash, B256}; use reth_rpc_api::{clients::DebugApiClient, EthApiClient}; use reth_rpc_types::{ trace::geth::{GethDebugTracerType, GethDebugTracingOptions}, - CallRequest, + TransactionRequest, }; use std::{ pin::Pin, @@ -42,7 +42,7 @@ pub trait DebugApiExt { /// method for debug_traceCall async fn debug_trace_call_json( &self, - request: CallRequest, + request: TransactionRequest, opts: GethDebugTracingOptions, ) -> Result; @@ -98,7 +98,7 @@ where } async fn debug_trace_call_json( &self, - request: CallRequest, + request: TransactionRequest, opts: GethDebugTracingOptions, ) -> Result { let mut params = jsonrpsee::core::params::ArrayParams::new(); @@ -112,7 +112,7 @@ where request_json: String, opts_json: String, ) -> Result { - let request = serde_json::from_str::(&request_json) + let request = serde_json::from_str::(&request_json) .map_err(|e| RpcError::Custom(e.to_string()))?; let opts = serde_json::from_str::(&opts_json) .map_err(|e| RpcError::Custom(e.to_string()))?; diff --git a/crates/rpc/rpc-testing-util/src/trace.rs b/crates/rpc/rpc-testing-util/src/trace.rs index 8d90cd8253d..72d071640e7 100644 --- a/crates/rpc/rpc-testing-util/src/trace.rs +++ b/crates/rpc/rpc-testing-util/src/trace.rs @@ -10,7 +10,7 @@ use reth_rpc_types::{ parity::{LocalizedTransactionTrace, TraceResults, TraceType}, tracerequest::TraceCallRequest, }, - CallRequest, Index, + Index, TransactionRequest, }; use std::{ collections::HashSet, @@ -29,8 +29,8 @@ pub type ReplayTransactionResult = Result<(TraceResults, TxHash), (RpcError, TxH /// A type representing the result of calling `trace_call_many` method. pub type CallManyTraceResult = Result< - (Vec, Vec<(CallRequest, HashSet)>), - (RpcError, Vec<(CallRequest, HashSet)>), + (Vec, Vec<(TransactionRequest, HashSet)>), + (RpcError, Vec<(TransactionRequest, HashSet)>), >; /// Result type for the `trace_get` method that also captures the requested transaction hash and /// index. @@ -91,7 +91,7 @@ pub trait TraceApiExt { block_id: Option, ) -> CallManyTraceStream<'_> where - I: IntoIterator)>; + I: IntoIterator)>; /// Returns a new stream that yields the traces for the given transaction hash and indices. fn trace_get_stream(&self, hash: B256, indices: I) -> TraceGetStream<'_> where @@ -306,7 +306,7 @@ impl TraceApiExt for T { block_id: Option, ) -> CallManyTraceStream<'_> where - I: IntoIterator)>, + I: IntoIterator)>, { let call_set = calls.into_iter().collect::>(); let stream = futures::stream::once(async move { @@ -569,8 +569,8 @@ mod tests { async fn can_create_trace_call_many_stream() { let client = HttpClientBuilder::default().build("http://localhost:8545").unwrap(); - let call_request_1 = CallRequest::default(); - let call_request_2 = CallRequest::default(); + let call_request_1 = TransactionRequest::default(); + let call_request_2 = TransactionRequest::default(); let trace_types = HashSet::from([TraceType::StateDiff, TraceType::VmTrace]); let calls = vec![(call_request_1, trace_types.clone()), (call_request_2, trace_types)]; diff --git a/crates/rpc/rpc-types-compat/src/transaction/mod.rs b/crates/rpc/rpc-types-compat/src/transaction/mod.rs index b7268e7213b..14886032d10 100644 --- a/crates/rpc/rpc-types-compat/src/transaction/mod.rs +++ b/crates/rpc/rpc-types-compat/src/transaction/mod.rs @@ -1,13 +1,14 @@ //! Compatibility functions for rpc `Transaction` type. mod signature; mod typed; +use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; use reth_primitives::{ BlockNumber, Transaction as PrimitiveTransaction, TransactionKind as PrimitiveTransactionKind, TransactionSignedEcRecovered, TxType, B256, U128, U256, U64, }; #[cfg(feature = "optimism")] use reth_rpc_types::optimism::OptimismTransactionFields; -use reth_rpc_types::{AccessListItem, CallInput, CallRequest, Transaction}; +use reth_rpc_types::{AccessListItem, Transaction}; use signature::from_primitive_signature; pub use typed::*; /// Create a new rpc transaction result for a mined transaction, using the given block hash, @@ -167,8 +168,8 @@ pub fn from_primitive_access_list( ) } -/// Convert [TransactionSignedEcRecovered] to [CallRequest] -pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> CallRequest { +/// Convert [TransactionSignedEcRecovered] to [TransactionRequest] +pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> TransactionRequest { let from = tx.signer(); let to = tx.transaction.to(); let gas = tx.transaction.gas_limit(); @@ -189,20 +190,21 @@ pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> CallRequ }; let max_priority_fee_per_gas = tx.transaction.max_priority_fee_per_gas(); - CallRequest { + TransactionRequest { from: Some(from), to, - gas_price: gas_price.map(U256::from), - max_fee_per_gas: max_fee_per_gas.map(U256::from), - max_priority_fee_per_gas: max_priority_fee_per_gas.map(U256::from), + gas_price: gas_price.map(U128::from), + max_fee_per_gas: max_fee_per_gas.map(U128::from), + max_priority_fee_per_gas: max_priority_fee_per_gas.map(U128::from), gas: Some(U256::from(gas)), value: Some(value.into()), - input: CallInput::new(input), + input: TransactionInput::new(input), nonce: Some(U64::from(nonce)), chain_id: chain_id.map(U64::from), access_list, max_fee_per_blob_gas: max_fee_per_blob_gas.map(U256::from), blob_versioned_hashes, transaction_type: Some(tx_type.into()), + ..Default::default() } } diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index 31d1c5be6ed..c0ae69f051e 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -27,7 +27,7 @@ use reth_rpc_types::{ BlockTraceResult, FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, NoopFrame, TraceResult, }, - BlockError, Bundle, CallRequest, RichBlock, StateContext, + BlockError, Bundle, RichBlock, StateContext, TransactionRequest, }; use revm::{ db::CacheDB, @@ -263,7 +263,7 @@ where /// - `debug_traceCall` executes with __enabled__ basefee check, `eth_call` does not: pub async fn debug_trace_call( &self, - call: CallRequest, + call: TransactionRequest, block_id: Option, opts: GethDebugTracingCallOptions, ) -> EthResult { @@ -286,7 +286,7 @@ where Ok(inspector) }) .await?; - return Ok(FourByteFrame::from(inspector).into()) + return Ok(FourByteFrame::from(inspector).into()); } GethDebugBuiltInTracerType::CallTracer => { let call_config = tracer_config @@ -309,7 +309,7 @@ where Ok(frame.into()) }) .await?; - return Ok(frame) + return Ok(frame); } GethDebugBuiltInTracerType::PreStateTracer => { let prestate_config = tracer_config @@ -334,7 +334,7 @@ where Ok(frame) }) .await?; - return Ok(frame.into()) + return Ok(frame.into()); } GethDebugBuiltInTracerType::NoopTracer => Ok(NoopFrame::default().into()), }, @@ -356,7 +356,7 @@ where Ok(GethTrace::JS(res)) } - } + }; } // default structlog tracer @@ -388,7 +388,7 @@ where opts: Option, ) -> EthResult>> { if bundles.is_empty() { - return Err(EthApiError::InvalidParams(String::from("bundles are empty."))) + return Err(EthApiError::InvalidParams(String::from("bundles are empty."))); } let StateContext { transaction_index, block_number } = state_context.unwrap_or_default(); @@ -505,7 +505,7 @@ where GethDebugBuiltInTracerType::FourByteTracer => { let mut inspector = FourByteInspector::default(); let (res, _) = inspect(db, env, &mut inspector)?; - return Ok((FourByteFrame::from(inspector).into(), res.state)) + return Ok((FourByteFrame::from(inspector).into(), res.state)); } GethDebugBuiltInTracerType::CallTracer => { let call_config = tracer_config @@ -523,7 +523,7 @@ where .into_geth_builder() .geth_call_traces(call_config, res.result.gas_used()); - return Ok((frame.into(), res.state)) + return Ok((frame.into(), res.state)); } GethDebugBuiltInTracerType::PreStateTracer => { let prestate_config = tracer_config @@ -544,7 +544,7 @@ where &*db, )?; - return Ok((frame.into(), res.state)) + return Ok((frame.into(), res.state)); } GethDebugBuiltInTracerType::NoopTracer => { Ok((NoopFrame::default().into(), Default::default())) @@ -563,7 +563,7 @@ where let result = inspector.json_result(res, &env, db)?; Ok((GethTrace::JS(result), state)) } - } + }; } // default structlog tracer @@ -721,7 +721,7 @@ where /// Handler for `debug_traceCall` async fn debug_trace_call( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, opts: Option, ) -> RpcResult { diff --git a/crates/rpc/rpc/src/engine.rs b/crates/rpc/rpc/src/engine.rs index d7c53221c49..7afe4313642 100644 --- a/crates/rpc/rpc/src/engine.rs +++ b/crates/rpc/rpc/src/engine.rs @@ -4,7 +4,7 @@ use reth_rpc_api::{EngineEthApiServer, EthApiServer, EthFilterApiServer}; /// Re-export for convenience pub use reth_rpc_engine_api::EngineApi; use reth_rpc_types::{ - state::StateOverride, BlockOverrides, CallRequest, Filter, Log, RichBlock, SyncStatus, + state::StateOverride, BlockOverrides, Filter, Log, RichBlock, SyncStatus, TransactionRequest, }; use tracing_futures::Instrument; @@ -59,7 +59,7 @@ where /// Handler for: `eth_call` async fn call( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, state_overrides: Option, block_overrides: Option>, From a4e6b020cee2184059c10b2a563cc2b8e04e9c9c Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 2 Feb 2024 23:14:42 +0100 Subject: [PATCH 02/12] refactor: rm more `CallRequest` --- Cargo.lock | 132 ++++++----- Cargo.toml | 2 +- crates/primitives/src/proofs.rs | 8 +- .../rpc-types/src/eth/transaction/request.rs | 224 +----------------- crates/rpc/rpc/src/eth/api/call.rs | 31 +-- crates/rpc/rpc/src/eth/api/server.rs | 18 +- crates/rpc/rpc/src/eth/api/transactions.rs | 151 ++++++++++-- crates/rpc/rpc/src/eth/error.rs | 62 ++--- crates/rpc/rpc/src/eth/revm_utils.rs | 31 +-- crates/rpc/rpc/src/trace.rs | 18 +- 10 files changed, 302 insertions(+), 375 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08563110dc2..44771cedcfb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,7 +176,7 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" dependencies = [ "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", + "alloy-rpc-types", "serde", ] @@ -260,7 +260,7 @@ source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#09 dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", + "alloy-rpc-types", "ethereum_ssz", "ethereum_ssz_derive", "jsonrpsee-types", @@ -274,18 +274,7 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" dependencies = [ "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", - "serde", - "serde_json", -] - -[[package]] -name = "alloy-rpc-trace-types" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#80206e7ba7686c514da291c06a5e7912b5361047" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy)", + "alloy-rpc-types", "serde", "serde_json", ] @@ -309,19 +298,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "alloy-rpc-types" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#80206e7ba7686c514da291c06a5e7912b5361047" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "itertools 0.12.1", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "alloy-sol-macro" version = "0.6.2" @@ -5870,7 +5846,7 @@ dependencies = [ "reth-revm", "reth-tasks", "reth-transaction-pool", - "revm", + "revm 4.0.0", "tokio", "tracing", ] @@ -6193,7 +6169,7 @@ dependencies = [ "reth-provider", "reth-revm", "reth-transaction-pool", - "revm", + "revm 4.0.0", "tracing", ] @@ -6412,7 +6388,7 @@ version = "0.1.0-alpha.17" dependencies = [ "reth-primitives", "reth-rpc-types", - "revm-primitives", + "revm-primitives 2.0.0", "serde", "thiserror", ] @@ -6518,7 +6494,7 @@ dependencies = [ "reth-provider", "reth-revm", "reth-transaction-pool", - "revm", + "revm 4.0.0", "thiserror", "tracing", ] @@ -6540,8 +6516,8 @@ dependencies = [ "reth-rpc-types-compat", "reth-tasks", "reth-transaction-pool", - "revm", - "revm-primitives", + "revm 4.0.0", + "revm-primitives 2.0.0", "serde", "sha2", "thiserror", @@ -6593,8 +6569,8 @@ dependencies = [ "reth-codecs", "reth-ethereum-forks", "reth-rpc-types", - "revm", - "revm-primitives", + "revm 4.0.0", + "revm-primitives 2.0.0", "secp256k1 0.27.0", "serde", "serde_json", @@ -6632,7 +6608,7 @@ dependencies = [ "reth-node-api", "reth-primitives", "reth-trie", - "revm", + "revm 4.0.0", "strum 0.26.1", "tempfile", "tokio", @@ -6675,7 +6651,7 @@ dependencies = [ "reth-primitives", "reth-provider", "reth-trie", - "revm", + "revm 4.0.0", "revm-inspectors", "tracing", ] @@ -6721,9 +6697,9 @@ dependencies = [ "reth-rpc-types-compat", "reth-tasks", "reth-transaction-pool", - "revm", + "revm 4.0.0", "revm-inspectors", - "revm-primitives", + "revm-primitives 2.0.0", "schnellru", "secp256k1 0.27.0", "serde", @@ -6836,8 +6812,8 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-engine-types", - "alloy-rpc-trace-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", + "alloy-rpc-trace-types", + "alloy-rpc-types", "arbitrary", "bytes", "ethereum_ssz", @@ -6861,7 +6837,7 @@ name = "reth-rpc-types-compat" version = "0.1.0-alpha.17" dependencies = [ "alloy-rlp", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", + "alloy-rpc-types", "reth-primitives", "reth-rpc-types", "serde_json", @@ -6918,7 +6894,7 @@ dependencies = [ "reth-revm", "reth-tokio-util", "reth-trie", - "revm", + "revm 4.0.0", "serde", "serde_json", "thiserror", @@ -6989,7 +6965,7 @@ dependencies = [ "reth-revm", "reth-tasks", "reth-tracing", - "revm", + "revm 4.0.0", "schnellru", "serde", "serde_json", @@ -7015,7 +6991,7 @@ dependencies = [ "reth-interfaces", "reth-primitives", "reth-provider", - "revm", + "revm 4.0.0", "serde_json", "similar-asserts", "thiserror", @@ -7025,6 +7001,16 @@ dependencies = [ "triehash", ] +[[package]] +name = "revm" +version = "3.5.0" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" +dependencies = [ + "auto_impl", + "revm-interpreter 1.3.0", + "revm-precompile 2.2.0", +] + [[package]] name = "revm" version = "4.0.0" @@ -7032,8 +7018,8 @@ source = "git+https://github.com/bluealloy/revm?branch=main#bbca12830be2757ff3e6 dependencies = [ "auto_impl", "cfg-if", - "revm-interpreter", - "revm-precompile", + "revm-interpreter 2.0.0", + "revm-precompile 3.0.0", "serde", "serde_json", ] @@ -7041,29 +7027,53 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?branch=main#573cf0f09c8f0f267dd387e8e4d13d75e09021c7" +source = "git+https://github.com/paradigmxyz/evm-inspectors?branch=onbjerg/rm-callrequest#9f87b5bce73d9808b9f3925985fb6aa93b83e75b" dependencies = [ "alloy-primitives", - "alloy-rpc-trace-types 0.1.0 (git+https://github.com/alloy-rs/alloy)", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy)", + "alloy-rpc-trace-types", + "alloy-rpc-types", "alloy-sol-types", "boa_engine", "boa_gc", - "revm", + "revm 3.5.0", "serde", "serde_json", "thiserror", ] +[[package]] +name = "revm-interpreter" +version = "1.3.0" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" +dependencies = [ + "revm-primitives 1.3.0", +] + [[package]] name = "revm-interpreter" version = "2.0.0" source = "git+https://github.com/bluealloy/revm?branch=main#bbca12830be2757ff3e608a36f062f5e2d62231b" dependencies = [ - "revm-primitives", + "revm-primitives 2.0.0", "serde", ] +[[package]] +name = "revm-precompile" +version = "2.2.0" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" +dependencies = [ + "aurora-engine-modexp", + "c-kzg", + "k256", + "once_cell", + "revm-primitives 1.3.0", + "ripemd", + "secp256k1 0.28.2", + "sha2", + "substrate-bn", +] + [[package]] name = "revm-precompile" version = "3.0.0" @@ -7074,13 +7084,29 @@ dependencies = [ "c-kzg", "k256", "once_cell", - "revm-primitives", + "revm-primitives 2.0.0", "ripemd", "secp256k1 0.28.2", "sha2", "substrate-bn", ] +[[package]] +name = "revm-primitives" +version = "1.3.0" +source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "auto_impl", + "bitflags 2.4.2", + "bitvec", + "cfg-if", + "enumn", + "hashbrown 0.14.3", + "hex", +] + [[package]] name = "revm-primitives" version = "2.0.0" diff --git a/Cargo.toml b/Cargo.toml index 8e1d3c4c11d..c1b72c907ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -175,7 +175,7 @@ revm = { git = "https://github.com/bluealloy/revm", branch = "main", features = revm-primitives = { git = "https://github.com/bluealloy/revm", branch = "main", features = [ "std", ], default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", branch = "main" } +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", branch = "onbjerg/rm-callrequest" } # eth alloy-chains = { version = "0.1", feature = ["serde", "rlp", "arbitrary"] } diff --git a/crates/primitives/src/proofs.rs b/crates/primitives/src/proofs.rs index bd1a37c92e3..096221e2599 100644 --- a/crates/primitives/src/proofs.rs +++ b/crates/primitives/src/proofs.rs @@ -86,8 +86,8 @@ pub fn calculate_receipt_root( // encoding. In the Regolith Hardfork, we must strip the deposit nonce from the // receipts before calculating the receipt root. This was corrected in the Canyon // hardfork. - if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) - && !chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp) + if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) && + !chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp) { let receipts = receipts .iter() @@ -130,8 +130,8 @@ pub fn calculate_receipt_root_ref( // encoding. In the Regolith Hardfork, we must strip the deposit nonce from the // receipts before calculating the receipt root. This was corrected in the Canyon // hardfork. - if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) - && !chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp) + if chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Regolith, timestamp) && + !chain_spec.is_fork_active_at_timestamp(crate::Hardfork::Canyon, timestamp) { let receipts = receipts .iter() diff --git a/crates/rpc/rpc-types/src/eth/transaction/request.rs b/crates/rpc/rpc-types/src/eth/transaction/request.rs index 410095fa8fb..831718f357d 100644 --- a/crates/rpc/rpc-types/src/eth/transaction/request.rs +++ b/crates/rpc/rpc-types/src/eth/transaction/request.rs @@ -1,223 +1 @@ -use crate::{ - eth::transaction::typed::{ - EIP1559TransactionRequest, EIP2930TransactionRequest, EIP4844TransactionRequest, - LegacyTransactionRequest, TransactionKind, TypedTransactionRequest, - }, - AccessList, -}; -use alloy_primitives::{Address, Bytes, B256, U128, U256, U64, U8}; -use alloy_rpc_types::BlobTransactionSidecar; -use serde::{Deserialize, Serialize}; - -/// Represents _all_ transaction requests received from RPC -#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] -#[serde(deny_unknown_fields)] -#[serde(rename_all = "camelCase")] -pub struct TransactionRequest { - /// from address - pub from: Option
, - /// to address - pub to: Option
, - /// legacy, gas Price - pub gas_price: Option, - /// max base fee per gas sender is willing to pay - pub max_fee_per_gas: Option, - /// miner tip - pub max_priority_fee_per_gas: Option, - /// gas - pub gas: Option, - /// value of th tx in wei - pub value: Option, - /// Any additional data sent - #[serde(alias = "data")] - pub input: Option, - /// Transaction nonce - pub nonce: Option, - /// warm storage access pre-payment - pub access_list: Option, - /// EIP-2718 type - #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - pub transaction_type: Option, - /// max fee per blob gas for EIP-4844 transactions - pub max_fee_per_blob_gas: Option, - /// blob versioned hashes for EIP-4844 transactions. - pub blob_versioned_hashes: Option>, - /// sidecar for EIP-4844 transactions - pub sidecar: Option, -} - -// == impl TransactionRequest == - -impl TransactionRequest { - /// Converts the request into a [`TypedTransactionRequest`] - /// - /// Returns None if mutual exclusive fields `gasPrice` and `max_fee_per_gas` are either missing - /// or both set. - pub fn into_typed_request(self) -> Option { - let TransactionRequest { - to, - gas_price, - max_fee_per_gas, - max_priority_fee_per_gas, - gas, - value, - input: data, - nonce, - mut access_list, - max_fee_per_blob_gas, - blob_versioned_hashes, - sidecar, - .. - } = self; - match ( - gas_price, - max_fee_per_gas, - access_list.take(), - max_fee_per_blob_gas, - blob_versioned_hashes, - sidecar, - ) { - // legacy transaction - // gas price required - (Some(_), None, None, None, None, None) => { - Some(TypedTransactionRequest::Legacy(LegacyTransactionRequest { - nonce: nonce.unwrap_or_default(), - gas_price: gas_price.unwrap_or_default(), - gas_limit: gas.unwrap_or_default(), - value: value.unwrap_or_default(), - input: data.unwrap_or_default(), - kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, - }, - chain_id: None, - })) - } - // EIP2930 - // if only accesslist is set, and no eip1599 fees - (_, None, Some(access_list), None, None, None) => { - Some(TypedTransactionRequest::EIP2930(EIP2930TransactionRequest { - nonce: nonce.unwrap_or_default(), - gas_price: gas_price.unwrap_or_default(), - gas_limit: gas.unwrap_or_default(), - value: value.unwrap_or_default(), - input: data.unwrap_or_default(), - kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, - }, - chain_id: 0, - access_list, - })) - } - // EIP1559 - // if 4844 fields missing - // gas_price, max_fee_per_gas, access_list, max_fee_per_blob_gas, blob_versioned_hashes, - // sidecar, - (None, _, _, None, None, None) => { - // Empty fields fall back to the canonical transaction schema. - Some(TypedTransactionRequest::EIP1559(EIP1559TransactionRequest { - nonce: nonce.unwrap_or_default(), - max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), - max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default(), - gas_limit: gas.unwrap_or_default(), - value: value.unwrap_or_default(), - input: data.unwrap_or_default(), - kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, - }, - chain_id: 0, - access_list: access_list.unwrap_or_default(), - })) - } - // EIP4884 - // all blob fields required - ( - None, - _, - _, - Some(max_fee_per_blob_gas), - Some(blob_versioned_hashes), - Some(sidecar), - ) => { - // As per the EIP, we follow the same semantics as EIP-1559. - Some(TypedTransactionRequest::EIP4844(EIP4844TransactionRequest { - chain_id: 0, - nonce: nonce.unwrap_or_default(), - max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default(), - max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), - gas_limit: gas.unwrap_or_default(), - value: value.unwrap_or_default(), - input: data.unwrap_or_default(), - kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, - }, - access_list: access_list.unwrap_or_default(), - - // eip-4844 specific. - max_fee_per_blob_gas, - blob_versioned_hashes, - sidecar, - })) - } - - _ => None, - } - } - - /// Sets the gas limit for the transaction. - pub fn gas_limit(mut self, gas_limit: u64) -> Self { - self.gas = Some(U256::from(gas_limit)); - self - } - - /// Sets the nonce for the transaction. - pub fn nonce(mut self, nonce: u64) -> Self { - self.nonce = Some(U64::from(nonce)); - self - } - - /// Sets the maximum fee per gas for the transaction. - pub fn max_fee_per_gas(mut self, max_fee_per_gas: u128) -> Self { - self.max_fee_per_gas = Some(U128::from(max_fee_per_gas)); - self - } - - /// Sets the maximum priority fee per gas for the transaction. - pub fn max_priority_fee_per_gas(mut self, max_priority_fee_per_gas: u128) -> Self { - self.max_priority_fee_per_gas = Some(U128::from(max_priority_fee_per_gas)); - self - } - - /// Sets the recipient address for the transaction. - pub fn to(mut self, to: Address) -> Self { - self.to = Some(to); - self - } - /// Sets the value (amount) for the transaction. - - pub fn value(mut self, value: u128) -> Self { - self.value = Some(U256::from(value)); - self - } - - /// Sets the access list for the transaction. - pub fn access_list(mut self, access_list: AccessList) -> Self { - self.access_list = Some(access_list); - self - } - - /// Sets the input data for the transaction. - pub fn input(mut self, input: impl Into) -> Self { - self.input = Some(input.into()); - self - } - - /// Sets the transactions type for the transactions. - pub fn transaction_type(mut self, transaction_type: u8) -> Self { - self.transaction_type = Some(U8::from(transaction_type)); - self - } -} +pub use alloy_rpc_types::request::TransactionRequest; diff --git a/crates/rpc/rpc/src/eth/api/call.rs b/crates/rpc/rpc/src/eth/api/call.rs index bef38a4da93..8b72feb3f92 100644 --- a/crates/rpc/rpc/src/eth/api/call.rs +++ b/crates/rpc/rpc/src/eth/api/call.rs @@ -20,7 +20,8 @@ use reth_provider::{ }; use reth_revm::{access_list::AccessListInspector, database::StateProviderDatabase}; use reth_rpc_types::{ - state::StateOverride, AccessListWithGasUsed, Bundle, CallRequest, EthCallResponse, StateContext, + state::StateOverride, AccessListWithGasUsed, Bundle, EthCallResponse, StateContext, + TransactionRequest, }; use reth_transaction_pool::TransactionPool; use revm::{ @@ -47,7 +48,7 @@ where /// Estimate gas needed for execution of the `request` at the [BlockId]. pub async fn estimate_gas_at( &self, - request: CallRequest, + request: TransactionRequest, at: BlockId, state_override: Option, ) -> EthResult { @@ -63,7 +64,7 @@ where /// Executes the call request (`eth_call`) and returns the output pub async fn call( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, overrides: EvmOverrides, ) -> EthResult { @@ -88,7 +89,7 @@ where ) -> EthResult> { let Bundle { transactions, block_override } = bundle; if transactions.is_empty() { - return Err(EthApiError::InvalidParams(String::from("transactions are empty."))) + return Err(EthApiError::InvalidParams(String::from("transactions are empty."))); } let StateContext { transaction_index, block_number } = state_context.unwrap_or_default(); @@ -173,12 +174,12 @@ where /// Estimates the gas usage of the `request` with the state. /// - /// This will execute the [CallRequest] and find the best gas limit via binary search + /// This will execute the [TransactionRequest] and find the best gas limit via binary search pub fn estimate_gas_with( &self, mut cfg: CfgEnvWithHandlerCfg, block: BlockEnv, - request: CallRequest, + request: TransactionRequest, state: S, state_override: Option, ) -> EthResult @@ -223,9 +224,9 @@ where if env.tx.value > available_funds { return Err( RpcInvalidTransactionError::InsufficientFundsForTransfer.into() - ) + ); } - return Ok(U256::from(MIN_TRANSACTION_GAS)) + return Ok(U256::from(MIN_TRANSACTION_GAS)); } } } @@ -257,7 +258,7 @@ where // if price or limit was included in the request then we can execute the request // again with the block's gas limit to check if revert is gas related or not if request_gas.is_some() || request_gas_price.is_some() { - return Err(map_out_of_gas_err(env_gas_limit, env, &mut db)) + return Err(map_out_of_gas_err(env_gas_limit, env, &mut db)); } } @@ -269,7 +270,7 @@ where ExecutionResult::Halt { reason, gas_used } => { // here we don't check for invalid opcode because already executed with highest gas // limit - return Err(RpcInvalidTransactionError::halt(reason, gas_used).into()) + return Err(RpcInvalidTransactionError::halt(reason, gas_used).into()); } ExecutionResult::Revert { output, .. } => { // if price or limit was included in the request then we can execute the request @@ -279,7 +280,7 @@ where } else { // the transaction did revert Err(RpcInvalidTransactionError::Revert(RevertError::new(output)).into()) - } + }; } } @@ -316,7 +317,7 @@ where // new midpoint mid_gas_limit = ((highest_gas_limit as u128 + lowest_gas_limit as u128) / 2) as u64; - continue + continue; } let (res, _) = ethres?; @@ -342,7 +343,7 @@ where err => { // these should be unreachable because we know the transaction succeeds, // but we consider these cases an error - return Err(RpcInvalidTransactionError::EvmHalt(err).into()) + return Err(RpcInvalidTransactionError::EvmHalt(err).into()); } } } @@ -357,7 +358,7 @@ where /// Creates the AccessList for the `request` at the [BlockId] or latest. pub(crate) async fn create_access_list_at( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, ) -> EthResult { self.on_blocking_task(|this| async move { @@ -368,7 +369,7 @@ where async fn create_access_list_with( &self, - mut request: CallRequest, + mut request: TransactionRequest, at: Option, ) -> EthResult { let block_id = at.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest)); diff --git a/crates/rpc/rpc/src/eth/api/server.rs b/crates/rpc/rpc/src/eth/api/server.rs index aa5d91ee14e..c27c1765473 100644 --- a/crates/rpc/rpc/src/eth/api/server.rs +++ b/crates/rpc/rpc/src/eth/api/server.rs @@ -23,7 +23,7 @@ use reth_provider::{ }; use reth_rpc_api::EthApiServer; use reth_rpc_types::{ - state::StateOverride, AccessListWithGasUsed, BlockOverrides, Bundle, CallRequest, + state::StateOverride, AccessListWithGasUsed, BlockOverrides, Bundle, EIP1186AccountProofResponse, EthCallResponse, FeeHistory, Index, RichBlock, StateContext, SyncStatus, TransactionReceipt, TransactionRequest, Work, }; @@ -229,7 +229,7 @@ where /// Handler for: `eth_call` async fn call( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, state_overrides: Option, block_overrides: Option>, @@ -254,7 +254,7 @@ where /// Handler for: `eth_createAccessList` async fn create_access_list( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, ) -> Result { trace!(target: "rpc::eth", ?request, ?block_number, "Serving eth_createAccessList"); @@ -266,7 +266,7 @@ where /// Handler for: `eth_estimateGas` async fn estimate_gas( &self, - request: CallRequest, + request: TransactionRequest, block_number: Option, state_override: Option, ) -> Result { @@ -283,19 +283,19 @@ where /// Handler for: `eth_gasPrice` async fn gas_price(&self) -> Result { trace!(target: "rpc::eth", "Serving eth_gasPrice"); - return Ok(EthApi::gas_price(self).await?) + return Ok(EthApi::gas_price(self).await?); } /// Handler for: `eth_blobGasPrice` async fn blob_gas_price(&self) -> Result { trace!(target: "rpc::eth", "Serving eth_blobGasPrice"); - return Ok(EthApi::blob_gas_price(self).await?) + return Ok(EthApi::blob_gas_price(self).await?); } /// Handler for: `eth_maxPriorityFeePerGas` async fn max_priority_fee_per_gas(&self) -> Result { trace!(target: "rpc::eth", "Serving eth_maxPriorityFeePerGas"); - return Ok(EthApi::suggested_priority_fee(self).await?) + return Ok(EthApi::suggested_priority_fee(self).await?); } // FeeHistory is calculated based on lazy evaluation of fees for historical blocks, and further @@ -316,7 +316,7 @@ where trace!(target: "rpc::eth", ?block_count, ?newest_block, ?reward_percentiles, "Serving eth_feeHistory"); return Ok( EthApi::fee_history(self, block_count.to(), newest_block, reward_percentiles).await? - ) + ); } /// Handler for: `eth_mining` @@ -363,7 +363,7 @@ where } /// Handler for: `eth_signTransaction` - async fn sign_transaction(&self, _transaction: CallRequest) -> Result { + async fn sign_transaction(&self, _transaction: TransactionRequest) -> Result { Err(internal_rpc_err("unimplemented")) } diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index d4873ae7a31..13b4c0b70b6 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -20,7 +20,7 @@ use reth_primitives::{ revm::env::{fill_block_env_with_coinbase, tx_env_with_recovered}, Address, BlockId, BlockNumberOrTag, Bytes, FromRecoveredPooledTransaction, Header, IntoRecoveredTransaction, Receipt, SealedBlock, SealedBlockWithSenders, - TransactionKind::{Call, Create}, + TransactionKind::{self, Call, Create}, TransactionMeta, TransactionSigned, TransactionSignedEcRecovered, B256, U128, U256, U64, }; use reth_provider::{ @@ -31,7 +31,11 @@ use reth_revm::{ tracing::{TracingInspector, TracingInspectorConfig}, }; use reth_rpc_types::{ - CallRequest, Index, Log, Transaction, TransactionInfo, TransactionReceipt, TransactionRequest, + transaction::{ + EIP1559TransactionRequest, EIP2930TransactionRequest, EIP4844TransactionRequest, + LegacyTransactionRequest, + }, + Index, Log, Transaction, TransactionInfo, TransactionReceipt, TransactionRequest, TypedTransactionRequest, }; use reth_rpc_types_compat::transaction::from_recovered_with_block_context; @@ -69,7 +73,7 @@ pub(crate) type StateCacheDB = CacheDB>; /// /// ## Calls /// -/// There are subtle differences between when transacting [CallRequest]: +/// There are subtle differences between when transacting [TransactionRequest]: /// /// The endpoints `eth_call` and `eth_estimateGas` and `eth_createAccessList` should always /// __disable__ the base fee check in the [EnvWithHandlerCfg] @@ -181,14 +185,14 @@ pub trait EthTransactions: Send + Sync { /// Returns the hash of the signed transaction. async fn send_transaction(&self, request: TransactionRequest) -> EthResult; - /// Prepares the state and env for the given [CallRequest] at the given [BlockId] and executes + /// Prepares the state and env for the given [TransactionRequest] at the given [BlockId] and executes /// the closure on a new task returning the result of the closure. /// - /// This returns the configured [EnvWithHandlerCfg] for the given [CallRequest] at the given + /// This returns the configured [EnvWithHandlerCfg] for the given [TransactionRequest] at the given /// [BlockId] and with configured call settings: `prepare_call_env`. async fn spawn_with_call_at( &self, - request: CallRequest, + request: TransactionRequest, at: BlockId, overrides: EvmOverrides, f: F, @@ -200,7 +204,7 @@ pub trait EthTransactions: Send + Sync { /// Executes the call request at the given [BlockId]. async fn transact_call_at( &self, - request: CallRequest, + request: TransactionRequest, at: BlockId, overrides: EvmOverrides, ) -> EthResult<(ResultAndState, EnvWithHandlerCfg)>; @@ -209,7 +213,7 @@ pub trait EthTransactions: Send + Sync { /// inspect call. async fn spawn_inspect_call_at( &self, - request: CallRequest, + request: TransactionRequest, at: BlockId, overrides: EvmOverrides, inspector: I, @@ -379,7 +383,7 @@ where let PendingBlockEnv { cfg, block_env, origin } = self.pending_block_env_and_cfg()?; Ok((cfg, block_env, origin.state_block_id())) } else { - // Use cached values if there is no pending block + // Use cached values if there is no pending block let block_hash = self .provider() .block_hash_for_id(at)? @@ -571,7 +575,7 @@ where let estimated_gas = self .estimate_gas_at( - CallRequest { + TransactionRequest { from: Some(from), to: request.to, gas: request.gas, @@ -586,6 +590,7 @@ where transaction_type: None, blob_versioned_hashes: None, max_fee_per_blob_gas: None, + ..Default::default() }, BlockId::Number(BlockNumberOrTag::Pending), None, @@ -593,7 +598,121 @@ where .await?; let gas_limit = estimated_gas; - let transaction = match request.into_typed_request() { + let TransactionRequest { + to, + gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, + gas, + value, + input: data, + nonce, + mut access_list, + max_fee_per_blob_gas, + blob_versioned_hashes, + sidecar, + .. + } = request; + + // todo: remove this inlining + let mut transaction = match ( + gas_price, + max_fee_per_gas, + access_list.take(), + max_fee_per_blob_gas, + blob_versioned_hashes, + sidecar, + ) { + // legacy transaction + // gas price required + (Some(_), None, None, None, None, None) => { + Some(TypedTransactionRequest::Legacy(LegacyTransactionRequest { + nonce: nonce.unwrap_or_default(), + gas_price: gas_price.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), + value: value.unwrap_or_default(), + input: data.unwrap_or_default(), + kind: match to { + Some(to) => TransactionKind::Call(to), + None => TransactionKind::Create, + }, + chain_id: None, + })) + } + // EIP2930 + // if only accesslist is set, and no eip1599 fees + (_, None, Some(access_list), None, None, None) => { + Some(TypedTransactionRequest::EIP2930(EIP2930TransactionRequest { + nonce: nonce.unwrap_or_default(), + gas_price: gas_price.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), + value: value.unwrap_or_default(), + input: data.unwrap_or_default(), + kind: match to { + Some(to) => TransactionKind::Call(to), + None => TransactionKind::Create, + }, + chain_id: 0, + access_list, + })) + } + // EIP1559 + // if 4844 fields missing + // gas_price, max_fee_per_gas, access_list, max_fee_per_blob_gas, blob_versioned_hashes, + // sidecar, + (None, _, _, None, None, None) => { + // Empty fields fall back to the canonical transaction schema. + Some(TypedTransactionRequest::EIP1559(EIP1559TransactionRequest { + nonce: nonce.unwrap_or_default(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), + max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), + value: value.unwrap_or_default(), + input: data.unwrap_or_default(), + kind: match to { + Some(to) => TransactionKind::Call(to), + None => TransactionKind::Create, + }, + chain_id: 0, + access_list: access_list.unwrap_or_default(), + })) + } + // EIP4884 + // all blob fields required + ( + None, + _, + _, + Some(max_fee_per_blob_gas), + Some(blob_versioned_hashes), + Some(sidecar), + ) => { + // As per the EIP, we follow the same semantics as EIP-1559. + Some(TypedTransactionRequest::EIP4844(EIP4844TransactionRequest { + chain_id: 0, + nonce: nonce.unwrap_or_default(), + max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default(), + max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), + gas_limit: gas.unwrap_or_default(), + value: value.unwrap_or_default(), + input: data.unwrap_or_default(), + kind: match to { + Some(to) => TransactionKind::Call(to), + None => TransactionKind::Create, + }, + access_list: access_list.unwrap_or_default(), + + // eip-4844 specific. + max_fee_per_blob_gas, + blob_versioned_hashes, + sidecar, + })) + } + + _ => None, + }; + + let transaction = match transaction { Some(TypedTransactionRequest::Legacy(mut m)) => { m.chain_id = Some(chain_id.to()); m.gas_limit = gas_limit; @@ -641,7 +760,7 @@ where async fn spawn_with_call_at( &self, - request: CallRequest, + request: TransactionRequest, at: BlockId, overrides: EvmOverrides, f: F, @@ -674,7 +793,7 @@ where async fn transact_call_at( &self, - request: CallRequest, + request: TransactionRequest, at: BlockId, overrides: EvmOverrides, ) -> EthResult<(ResultAndState, EnvWithHandlerCfg)> { @@ -684,7 +803,7 @@ where async fn spawn_inspect_call_at( &self, - request: CallRequest, + request: TransactionRequest, at: BlockId, overrides: EvmOverrides, inspector: I, @@ -1072,7 +1191,7 @@ where return match signer.sign_transaction(request, from) { Ok(tx) => Ok(tx), Err(e) => Err(e.into()), - } + }; } } Err(EthApiError::InvalidTransactionSignature) @@ -1097,7 +1216,7 @@ where block_number, base_fee_per_gas, index.into(), - ))) + ))); } } diff --git a/crates/rpc/rpc/src/eth/error.rs b/crates/rpc/rpc/src/eth/error.rs index 5bd4cb78064..a231e73b528 100644 --- a/crates/rpc/rpc/src/eth/error.rs +++ b/crates/rpc/rpc/src/eth/error.rs @@ -9,7 +9,7 @@ use jsonrpsee::{ use reth_interfaces::RethError; use reth_primitives::{revm_primitives::InvalidHeader, Address, Bytes, U256}; use reth_revm::tracing::js::JsInspectorError; -use reth_rpc_types::{error::EthRpcErrorCode, BlockError, CallInputError}; +use reth_rpc_types::{error::EthRpcErrorCode, request::TransactionInputError, BlockError}; use reth_transaction_pool::error::{ Eip4844PoolTransactionError, InvalidPoolTransactionError, PoolError, PoolErrorKind, PoolTransactionError, @@ -105,7 +105,7 @@ pub enum EthApiError { InternalJsTracerError(String), #[error(transparent)] /// Call Input error when both `data` and `input` fields are set and not equal. - CallInputError(#[from] CallInputError), + TransactionInputError(#[from] TransactionInputError), /// Optimism related error #[error(transparent)] #[cfg(feature = "optimism")] @@ -139,22 +139,22 @@ pub enum OptimismEthApiError { impl From for ErrorObject<'static> { fn from(error: EthApiError) -> Self { match error { - EthApiError::FailedToDecodeSignedTransaction | - EthApiError::InvalidTransactionSignature | - EthApiError::EmptyRawTransactionData | - EthApiError::InvalidBlockRange | - EthApiError::ConflictingFeeFieldsInRequest | - EthApiError::Signing(_) | - EthApiError::BothStateAndStateDiffInOverride(_) | - EthApiError::InvalidTracerConfig => invalid_params_rpc_err(error.to_string()), + EthApiError::FailedToDecodeSignedTransaction + | EthApiError::InvalidTransactionSignature + | EthApiError::EmptyRawTransactionData + | EthApiError::InvalidBlockRange + | EthApiError::ConflictingFeeFieldsInRequest + | EthApiError::Signing(_) + | EthApiError::BothStateAndStateDiffInOverride(_) + | EthApiError::InvalidTracerConfig => invalid_params_rpc_err(error.to_string()), EthApiError::InvalidTransaction(err) => err.into(), EthApiError::PoolError(err) => err.into(), - EthApiError::PrevrandaoNotSet | - EthApiError::ExcessBlobGasNotSet | - EthApiError::InvalidBlockData(_) | - EthApiError::Internal(_) | - EthApiError::TransactionNotFound | - EthApiError::EvmCustom(_) => internal_rpc_err(error.to_string()), + EthApiError::PrevrandaoNotSet + | EthApiError::ExcessBlobGasNotSet + | EthApiError::InvalidBlockData(_) + | EthApiError::Internal(_) + | EthApiError::TransactionNotFound + | EthApiError::EvmCustom(_) => internal_rpc_err(error.to_string()), EthApiError::UnknownBlockNumber | EthApiError::UnknownBlockOrTxIndex => { rpc_error_with_code(EthRpcErrorCode::ResourceNotFound.code(), error.to_string()) } @@ -175,9 +175,9 @@ impl From for ErrorObject<'static> { EthApiError::Optimism(err) => match err { OptimismEthApiError::HyperError(err) => internal_rpc_err(err.to_string()), OptimismEthApiError::HttpError(err) => internal_rpc_err(err.to_string()), - OptimismEthApiError::InvalidSequencerTransaction | - OptimismEthApiError::L1BlockFeeError | - OptimismEthApiError::L1BlockGasError => internal_rpc_err(err.to_string()), + OptimismEthApiError::InvalidSequencerTransaction + | OptimismEthApiError::L1BlockFeeError + | OptimismEthApiError::L1BlockGasError => internal_rpc_err(err.to_string()), }, } } @@ -212,12 +212,12 @@ impl From for EthApiError { fn from(error: reth_interfaces::provider::ProviderError) -> Self { use reth_interfaces::provider::ProviderError; match error { - ProviderError::HeaderNotFound(_) | - ProviderError::BlockHashNotFound(_) | - ProviderError::BestBlockNotFound | - ProviderError::BlockNumberForTransactionIndexNotFound | - ProviderError::TotalDifficultyNotFound { .. } | - ProviderError::UnknownBlockHash(_) => EthApiError::UnknownBlockNumber, + ProviderError::HeaderNotFound(_) + | ProviderError::BlockHashNotFound(_) + | ProviderError::BestBlockNotFound + | ProviderError::BlockNumberForTransactionIndexNotFound + | ProviderError::TotalDifficultyNotFound { .. } + | ProviderError::UnknownBlockHash(_) => EthApiError::UnknownBlockNumber, ProviderError::FinalizedBlockNotFound | ProviderError::SafeBlockNotFound => { EthApiError::UnknownSafeOrFinalizedBlock } @@ -379,9 +379,9 @@ impl RpcInvalidTransactionError { /// Returns the rpc error code for this error. fn error_code(&self) -> i32 { match self { - RpcInvalidTransactionError::InvalidChainId | - RpcInvalidTransactionError::GasTooLow | - RpcInvalidTransactionError::GasTooHigh => EthRpcErrorCode::InvalidInput.code(), + RpcInvalidTransactionError::InvalidChainId + | RpcInvalidTransactionError::GasTooLow + | RpcInvalidTransactionError::GasTooHigh => EthRpcErrorCode::InvalidInput.code(), RpcInvalidTransactionError::Revert(_) => EthRpcErrorCode::ExecutionError.code(), _ => EthRpcErrorCode::TransactionRejected.code(), } @@ -510,9 +510,9 @@ impl From for RpcInvalidTransactionErr RpcInvalidTransactionError::OldLegacyChainId } InvalidTransactionError::ChainIdMismatch => RpcInvalidTransactionError::InvalidChainId, - InvalidTransactionError::Eip2930Disabled | - InvalidTransactionError::Eip1559Disabled | - InvalidTransactionError::Eip4844Disabled => { + InvalidTransactionError::Eip2930Disabled + | InvalidTransactionError::Eip1559Disabled + | InvalidTransactionError::Eip4844Disabled => { RpcInvalidTransactionError::TxTypeNotSupported } InvalidTransactionError::TxTypeNotSupported => { diff --git a/crates/rpc/rpc/src/eth/revm_utils.rs b/crates/rpc/rpc/src/eth/revm_utils.rs index a6b0f9d471e..bba4ffa7da0 100644 --- a/crates/rpc/rpc/src/eth/revm_utils.rs +++ b/crates/rpc/rpc/src/eth/revm_utils.rs @@ -11,7 +11,7 @@ use reth_primitives::{ }; use reth_rpc_types::{ state::{AccountOverride, StateOverride}, - BlockOverrides, CallRequest, + BlockOverrides, TransactionRequest, }; #[cfg(feature = "optimism")] use revm::primitives::{Bytes, OptimismFields}; @@ -214,7 +214,7 @@ where for tx in transactions.into_iter() { if tx.hash() == target_tx_hash { // reached the target transaction - break + break; } tx.try_fill_tx_env(evm.tx_mut())?; @@ -235,7 +235,7 @@ where pub(crate) fn prepare_call_env( mut cfg: CfgEnvWithHandlerCfg, block: BlockEnv, - request: CallRequest, + request: TransactionRequest, gas_limit: u64, db: &mut CacheDB, overrides: EvmOverrides, @@ -296,29 +296,32 @@ where Ok(env) } -/// Creates a new [EnvWithHandlerCfg] to be used for executing the [CallRequest] in `eth_call`. +/// Creates a new [EnvWithHandlerCfg] to be used for executing the [TransactionRequest] in `eth_call`. /// /// Note: this does _not_ access the Database to check the sender. pub(crate) fn build_call_evm_env( cfg: CfgEnvWithHandlerCfg, block: BlockEnv, - request: CallRequest, + request: TransactionRequest, ) -> EthResult { let tx = create_txn_env(&block, request)?; Ok(EnvWithHandlerCfg::new_with_cfg_env(cfg, block, tx)) } -/// Configures a new [TxEnv] for the [CallRequest] +/// Configures a new [TxEnv] for the [TransactionRequest] /// -/// All [TxEnv] fields are derived from the given [CallRequest], if fields are `None`, they fall +/// All [TxEnv] fields are derived from the given [TransactionRequest], if fields are `None`, they fall /// back to the [BlockEnv]'s settings. -pub(crate) fn create_txn_env(block_env: &BlockEnv, request: CallRequest) -> EthResult { +pub(crate) fn create_txn_env( + block_env: &BlockEnv, + request: TransactionRequest, +) -> EthResult { // Ensure that if versioned hashes are set, they're not empty if request.has_empty_blob_hashes() { - return Err(RpcInvalidTransactionError::BlobTransactionMissingBlobHashes.into()) + return Err(RpcInvalidTransactionError::BlobTransactionMissingBlobHashes.into()); } - let CallRequest { + let TransactionRequest { from, to, gas_price, @@ -412,7 +415,7 @@ where .unwrap_or_default()) } -/// Helper type for representing the fees of a [CallRequest] +/// Helper type for representing the fees of a [TransactionRequest] pub(crate) struct CallFees { /// EIP-1559 priority fee max_priority_fee_per_gas: Option, @@ -430,7 +433,7 @@ pub(crate) struct CallFees { // === impl CallFees === impl CallFees { - /// Ensures the fields of a [CallRequest] are not conflicting. + /// Ensures the fields of a [TransactionRequest] are not conflicting. /// /// If no `gasPrice` or `maxFeePerGas` is set, then the `gas_price` in the returned `gas_price` /// will be `0`. See: @@ -463,7 +466,7 @@ impl CallFees { return Err( // `max_priority_fee_per_gas` is greater than the `max_fee_per_gas` RpcInvalidTransactionError::TipAboveFeeCap.into(), - ) + ); } } Ok(()) @@ -500,7 +503,7 @@ impl CallFees { // Ensure blob_hashes are present if !has_blob_hashes { // Blob transaction but no blob hashes - return Err(RpcInvalidTransactionError::BlobTransactionMissingBlobHashes.into()) + return Err(RpcInvalidTransactionError::BlobTransactionMissingBlobHashes.into()); } Ok(CallFees { diff --git a/crates/rpc/rpc/src/trace.rs b/crates/rpc/rpc/src/trace.rs index 64bbbe54573..c9091661fa0 100644 --- a/crates/rpc/rpc/src/trace.rs +++ b/crates/rpc/rpc/src/trace.rs @@ -22,7 +22,7 @@ use reth_rpc_api::TraceApiServer; use reth_rpc_types::{ state::StateOverride, trace::{filter::TraceFilter, parity::*, tracerequest::TraceCallRequest}, - BlockError, BlockOverrides, CallRequest, Index, + BlockError, BlockOverrides, Index, TransactionRequest, }; use revm::{ db::{CacheDB, DatabaseCommit}, @@ -125,7 +125,7 @@ where /// Note: Allows tracing dependent transactions, hence all transactions are traced in sequence pub async fn trace_call_many( &self, - calls: Vec<(CallRequest, HashSet)>, + calls: Vec<(TransactionRequest, HashSet)>, block_id: Option, ) -> EthResult> { let at = block_id.unwrap_or(BlockId::Number(BlockNumberOrTag::Pending)); @@ -211,7 +211,7 @@ where ) -> EthResult> { if indices.len() != 1 { // The OG impl failed if it gets more than a single index - return Ok(None) + return Ok(None); } self.trace_get_index(hash, indices[0]).await } @@ -249,7 +249,7 @@ where if distance > 100 { return Err(EthApiError::InvalidParams( "Block range too large; currently limited to 100 blocks".to_string(), - )) + )); } // fetch all blocks in that range @@ -285,7 +285,7 @@ where if let Some(idx) = tx_info.index { if !indices.contains(&idx) { // only record traces for relevant transactions - return Ok(None) + return Ok(None); } } let traces = inspector @@ -376,8 +376,8 @@ where author: block.header.beneficiary, reward_type: RewardType::Uncle, value: U256::from( - block_reward(base_block_reward, block.ommers.len()) - - base_block_reward, + block_reward(base_block_reward, block.ommers.len()) + - base_block_reward, ), }, )); @@ -432,7 +432,7 @@ where /// Handler for `trace_call` async fn trace_call( &self, - call: CallRequest, + call: TransactionRequest, trace_types: HashSet, block_id: Option, state_overrides: Option, @@ -447,7 +447,7 @@ where /// Handler for `trace_callMany` async fn trace_call_many( &self, - calls: Vec<(CallRequest, HashSet)>, + calls: Vec<(TransactionRequest, HashSet)>, block_id: Option, ) -> Result> { let _permit = self.acquire_trace_permit().await; From 4ede1e9fc2d4290bd42bf0c0043dd4e58c64e9cc Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 2 Feb 2024 23:15:16 +0100 Subject: [PATCH 03/12] chore: fmt --- crates/rpc/rpc/src/eth/api/transactions.rs | 8 +-- crates/rpc/rpc/src/eth/error.rs | 58 +++++++++++----------- crates/rpc/rpc/src/eth/revm_utils.rs | 7 +-- crates/rpc/rpc/src/trace.rs | 4 +- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index 13b4c0b70b6..b340ba5db09 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -185,11 +185,11 @@ pub trait EthTransactions: Send + Sync { /// Returns the hash of the signed transaction. async fn send_transaction(&self, request: TransactionRequest) -> EthResult; - /// Prepares the state and env for the given [TransactionRequest] at the given [BlockId] and executes - /// the closure on a new task returning the result of the closure. + /// Prepares the state and env for the given [TransactionRequest] at the given [BlockId] and + /// executes the closure on a new task returning the result of the closure. /// - /// This returns the configured [EnvWithHandlerCfg] for the given [TransactionRequest] at the given - /// [BlockId] and with configured call settings: `prepare_call_env`. + /// This returns the configured [EnvWithHandlerCfg] for the given [TransactionRequest] at the + /// given [BlockId] and with configured call settings: `prepare_call_env`. async fn spawn_with_call_at( &self, request: TransactionRequest, diff --git a/crates/rpc/rpc/src/eth/error.rs b/crates/rpc/rpc/src/eth/error.rs index a231e73b528..ef8a994b512 100644 --- a/crates/rpc/rpc/src/eth/error.rs +++ b/crates/rpc/rpc/src/eth/error.rs @@ -139,22 +139,22 @@ pub enum OptimismEthApiError { impl From for ErrorObject<'static> { fn from(error: EthApiError) -> Self { match error { - EthApiError::FailedToDecodeSignedTransaction - | EthApiError::InvalidTransactionSignature - | EthApiError::EmptyRawTransactionData - | EthApiError::InvalidBlockRange - | EthApiError::ConflictingFeeFieldsInRequest - | EthApiError::Signing(_) - | EthApiError::BothStateAndStateDiffInOverride(_) - | EthApiError::InvalidTracerConfig => invalid_params_rpc_err(error.to_string()), + EthApiError::FailedToDecodeSignedTransaction | + EthApiError::InvalidTransactionSignature | + EthApiError::EmptyRawTransactionData | + EthApiError::InvalidBlockRange | + EthApiError::ConflictingFeeFieldsInRequest | + EthApiError::Signing(_) | + EthApiError::BothStateAndStateDiffInOverride(_) | + EthApiError::InvalidTracerConfig => invalid_params_rpc_err(error.to_string()), EthApiError::InvalidTransaction(err) => err.into(), EthApiError::PoolError(err) => err.into(), - EthApiError::PrevrandaoNotSet - | EthApiError::ExcessBlobGasNotSet - | EthApiError::InvalidBlockData(_) - | EthApiError::Internal(_) - | EthApiError::TransactionNotFound - | EthApiError::EvmCustom(_) => internal_rpc_err(error.to_string()), + EthApiError::PrevrandaoNotSet | + EthApiError::ExcessBlobGasNotSet | + EthApiError::InvalidBlockData(_) | + EthApiError::Internal(_) | + EthApiError::TransactionNotFound | + EthApiError::EvmCustom(_) => internal_rpc_err(error.to_string()), EthApiError::UnknownBlockNumber | EthApiError::UnknownBlockOrTxIndex => { rpc_error_with_code(EthRpcErrorCode::ResourceNotFound.code(), error.to_string()) } @@ -175,9 +175,9 @@ impl From for ErrorObject<'static> { EthApiError::Optimism(err) => match err { OptimismEthApiError::HyperError(err) => internal_rpc_err(err.to_string()), OptimismEthApiError::HttpError(err) => internal_rpc_err(err.to_string()), - OptimismEthApiError::InvalidSequencerTransaction - | OptimismEthApiError::L1BlockFeeError - | OptimismEthApiError::L1BlockGasError => internal_rpc_err(err.to_string()), + OptimismEthApiError::InvalidSequencerTransaction | + OptimismEthApiError::L1BlockFeeError | + OptimismEthApiError::L1BlockGasError => internal_rpc_err(err.to_string()), }, } } @@ -212,12 +212,12 @@ impl From for EthApiError { fn from(error: reth_interfaces::provider::ProviderError) -> Self { use reth_interfaces::provider::ProviderError; match error { - ProviderError::HeaderNotFound(_) - | ProviderError::BlockHashNotFound(_) - | ProviderError::BestBlockNotFound - | ProviderError::BlockNumberForTransactionIndexNotFound - | ProviderError::TotalDifficultyNotFound { .. } - | ProviderError::UnknownBlockHash(_) => EthApiError::UnknownBlockNumber, + ProviderError::HeaderNotFound(_) | + ProviderError::BlockHashNotFound(_) | + ProviderError::BestBlockNotFound | + ProviderError::BlockNumberForTransactionIndexNotFound | + ProviderError::TotalDifficultyNotFound { .. } | + ProviderError::UnknownBlockHash(_) => EthApiError::UnknownBlockNumber, ProviderError::FinalizedBlockNotFound | ProviderError::SafeBlockNotFound => { EthApiError::UnknownSafeOrFinalizedBlock } @@ -379,9 +379,9 @@ impl RpcInvalidTransactionError { /// Returns the rpc error code for this error. fn error_code(&self) -> i32 { match self { - RpcInvalidTransactionError::InvalidChainId - | RpcInvalidTransactionError::GasTooLow - | RpcInvalidTransactionError::GasTooHigh => EthRpcErrorCode::InvalidInput.code(), + RpcInvalidTransactionError::InvalidChainId | + RpcInvalidTransactionError::GasTooLow | + RpcInvalidTransactionError::GasTooHigh => EthRpcErrorCode::InvalidInput.code(), RpcInvalidTransactionError::Revert(_) => EthRpcErrorCode::ExecutionError.code(), _ => EthRpcErrorCode::TransactionRejected.code(), } @@ -510,9 +510,9 @@ impl From for RpcInvalidTransactionErr RpcInvalidTransactionError::OldLegacyChainId } InvalidTransactionError::ChainIdMismatch => RpcInvalidTransactionError::InvalidChainId, - InvalidTransactionError::Eip2930Disabled - | InvalidTransactionError::Eip1559Disabled - | InvalidTransactionError::Eip4844Disabled => { + InvalidTransactionError::Eip2930Disabled | + InvalidTransactionError::Eip1559Disabled | + InvalidTransactionError::Eip4844Disabled => { RpcInvalidTransactionError::TxTypeNotSupported } InvalidTransactionError::TxTypeNotSupported => { diff --git a/crates/rpc/rpc/src/eth/revm_utils.rs b/crates/rpc/rpc/src/eth/revm_utils.rs index bba4ffa7da0..653d27a0328 100644 --- a/crates/rpc/rpc/src/eth/revm_utils.rs +++ b/crates/rpc/rpc/src/eth/revm_utils.rs @@ -296,7 +296,8 @@ where Ok(env) } -/// Creates a new [EnvWithHandlerCfg] to be used for executing the [TransactionRequest] in `eth_call`. +/// Creates a new [EnvWithHandlerCfg] to be used for executing the [TransactionRequest] in +/// `eth_call`. /// /// Note: this does _not_ access the Database to check the sender. pub(crate) fn build_call_evm_env( @@ -310,8 +311,8 @@ pub(crate) fn build_call_evm_env( /// Configures a new [TxEnv] for the [TransactionRequest] /// -/// All [TxEnv] fields are derived from the given [TransactionRequest], if fields are `None`, they fall -/// back to the [BlockEnv]'s settings. +/// All [TxEnv] fields are derived from the given [TransactionRequest], if fields are `None`, they +/// fall back to the [BlockEnv]'s settings. pub(crate) fn create_txn_env( block_env: &BlockEnv, request: TransactionRequest, diff --git a/crates/rpc/rpc/src/trace.rs b/crates/rpc/rpc/src/trace.rs index c9091661fa0..ded4153ab4d 100644 --- a/crates/rpc/rpc/src/trace.rs +++ b/crates/rpc/rpc/src/trace.rs @@ -376,8 +376,8 @@ where author: block.header.beneficiary, reward_type: RewardType::Uncle, value: U256::from( - block_reward(base_block_reward, block.ommers.len()) - - base_block_reward, + block_reward(base_block_reward, block.ommers.len()) - + base_block_reward, ), }, )); From a4571cac857f3e61d58efc96c8911b1607736005 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 2 Feb 2024 23:30:20 +0100 Subject: [PATCH 04/12] refactor: more work --- crates/rpc/rpc/src/eth/api/transactions.rs | 22 +++++++++++----------- crates/rpc/rpc/src/eth/error.rs | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index b340ba5db09..7fbbebc8fa4 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -579,14 +579,14 @@ where from: Some(from), to: request.to, gas: request.gas, - gas_price: Some(U256::from(gas_price)), - max_fee_per_gas: Some(U256::from(max_fee_per_gas)), + gas_price: Some(gas_price), + max_fee_per_gas: Some(max_fee_per_gas), value: request.value, input: request.input.clone().into(), nonce: request.nonce, chain_id: Some(chain_id), access_list: request.access_list.clone(), - max_priority_fee_per_gas: Some(U256::from(max_fee_per_gas)), + max_priority_fee_per_gas: Some(max_fee_per_gas), transaction_type: None, blob_versioned_hashes: None, max_fee_per_blob_gas: None, @@ -631,7 +631,7 @@ where gas_price: gas_price.unwrap_or_default(), gas_limit: gas.unwrap_or_default(), value: value.unwrap_or_default(), - input: data.unwrap_or_default(), + input: data.into_input().unwrap_or_default(), kind: match to { Some(to) => TransactionKind::Call(to), None => TransactionKind::Create, @@ -647,7 +647,7 @@ where gas_price: gas_price.unwrap_or_default(), gas_limit: gas.unwrap_or_default(), value: value.unwrap_or_default(), - input: data.unwrap_or_default(), + input: data.into_input().unwrap_or_default(), kind: match to { Some(to) => TransactionKind::Call(to), None => TransactionKind::Create, @@ -668,7 +668,7 @@ where max_priority_fee_per_gas: max_priority_fee_per_gas.unwrap_or_default(), gas_limit: gas.unwrap_or_default(), value: value.unwrap_or_default(), - input: data.unwrap_or_default(), + input: data.into_input().unwrap_or_default(), kind: match to { Some(to) => TransactionKind::Call(to), None => TransactionKind::Create, @@ -695,7 +695,7 @@ where max_fee_per_gas: max_fee_per_gas.unwrap_or_default(), gas_limit: gas.unwrap_or_default(), value: value.unwrap_or_default(), - input: data.unwrap_or_default(), + input: data.into_input().unwrap_or_default(), kind: match to { Some(to) => TransactionKind::Call(to), None => TransactionKind::Create, @@ -716,28 +716,28 @@ where Some(TypedTransactionRequest::Legacy(mut m)) => { m.chain_id = Some(chain_id.to()); m.gas_limit = gas_limit; - m.gas_price = gas_price; + m.gas_price = gas_price.unwrap_or_default(); TypedTransactionRequest::Legacy(m) } Some(TypedTransactionRequest::EIP2930(mut m)) => { m.chain_id = chain_id.to(); m.gas_limit = gas_limit; - m.gas_price = gas_price; + m.gas_price = gas_price.unwrap_or_default(); TypedTransactionRequest::EIP2930(m) } Some(TypedTransactionRequest::EIP1559(mut m)) => { m.chain_id = chain_id.to(); m.gas_limit = gas_limit; - m.max_fee_per_gas = max_fee_per_gas; + m.max_fee_per_gas = max_fee_per_gas.unwrap_or_default(); TypedTransactionRequest::EIP1559(m) } Some(TypedTransactionRequest::EIP4844(mut m)) => { m.chain_id = chain_id.to(); m.gas_limit = gas_limit; - m.max_fee_per_gas = max_fee_per_gas; + m.max_fee_per_gas = max_fee_per_gas.unwrap_or_default(); TypedTransactionRequest::EIP4844(m) } diff --git a/crates/rpc/rpc/src/eth/error.rs b/crates/rpc/rpc/src/eth/error.rs index ef8a994b512..cae7cc0dd04 100644 --- a/crates/rpc/rpc/src/eth/error.rs +++ b/crates/rpc/rpc/src/eth/error.rs @@ -170,7 +170,7 @@ impl From for ErrorObject<'static> { } err @ EthApiError::InternalBlockingTaskError => internal_rpc_err(err.to_string()), err @ EthApiError::InternalEthError => internal_rpc_err(err.to_string()), - err @ EthApiError::CallInputError(_) => invalid_params_rpc_err(err.to_string()), + err @ EthApiError::TransactionInputError(_) => invalid_params_rpc_err(err.to_string()), #[cfg(feature = "optimism")] EthApiError::Optimism(err) => match err { OptimismEthApiError::HyperError(err) => internal_rpc_err(err.to_string()), From 7437ceeb0e2304204dbeff7c376d6aa1759d1b0c Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Tue, 6 Feb 2024 17:02:32 +0100 Subject: [PATCH 05/12] fix: use u256 --- .../rpc/rpc-types-compat/src/transaction/mod.rs | 6 +++--- .../rpc/rpc-types/src/eth/transaction/typed.rs | 16 ++++++++-------- crates/rpc/rpc/src/eth/api/transactions.rs | 1 - 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/rpc/rpc-types-compat/src/transaction/mod.rs b/crates/rpc/rpc-types-compat/src/transaction/mod.rs index 14886032d10..ee2976ea972 100644 --- a/crates/rpc/rpc-types-compat/src/transaction/mod.rs +++ b/crates/rpc/rpc-types-compat/src/transaction/mod.rs @@ -193,9 +193,9 @@ pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> Transact TransactionRequest { from: Some(from), to, - gas_price: gas_price.map(U128::from), - max_fee_per_gas: max_fee_per_gas.map(U128::from), - max_priority_fee_per_gas: max_priority_fee_per_gas.map(U128::from), + gas_price: gas_price.map(U256::from), + max_fee_per_gas: max_fee_per_gas.map(U256::from), + max_priority_fee_per_gas: max_priority_fee_per_gas.map(U256::from), gas: Some(U256::from(gas)), value: Some(value.into()), input: TransactionInput::new(input), diff --git a/crates/rpc/rpc-types/src/eth/transaction/typed.rs b/crates/rpc/rpc-types/src/eth/transaction/typed.rs index 60b910f9057..7b301a33835 100644 --- a/crates/rpc/rpc-types/src/eth/transaction/typed.rs +++ b/crates/rpc/rpc-types/src/eth/transaction/typed.rs @@ -2,7 +2,7 @@ //! transaction deserialized from the json input of an RPC call. Depending on what fields are set, //! it can be converted into the container type [`TypedTransactionRequest`]. -use alloy_primitives::{Address, Bytes, B256, U128, U256, U64}; +use alloy_primitives::{Address, Bytes, B256, U256, U64}; use alloy_rlp::{BufMut, Decodable, Encodable, Error as RlpError}; use alloy_rpc_types::{AccessList, BlobTransactionSidecar}; use serde::{Deserialize, Serialize}; @@ -32,7 +32,7 @@ pub struct LegacyTransactionRequest { /// The nonce of the transaction pub nonce: U64, /// The gas price for the transaction - pub gas_price: U128, + pub gas_price: U256, /// The gas limit for the transaction pub gas_limit: U256, /// The kind of transaction (e.g., Call, Create) @@ -53,7 +53,7 @@ pub struct EIP2930TransactionRequest { /// The nonce of the transaction pub nonce: U64, /// The gas price for the transaction - pub gas_price: U128, + pub gas_price: U256, /// The gas limit for the transaction pub gas_limit: U256, /// The kind of transaction (e.g., Call, Create) @@ -74,9 +74,9 @@ pub struct EIP1559TransactionRequest { /// The nonce of the transaction pub nonce: U64, /// The maximum priority fee per gas for the transaction - pub max_priority_fee_per_gas: U128, + pub max_priority_fee_per_gas: U256, /// The maximum fee per gas for the transaction - pub max_fee_per_gas: U128, + pub max_fee_per_gas: U256, /// The gas limit for the transaction pub gas_limit: U256, /// The kind of transaction (e.g., Call, Create) @@ -97,9 +97,9 @@ pub struct EIP4844TransactionRequest { /// The nonce of the transaction pub nonce: U64, /// The maximum priority fee per gas for the transaction - pub max_priority_fee_per_gas: U128, + pub max_priority_fee_per_gas: U256, /// The maximum fee per gas for the transaction - pub max_fee_per_gas: U128, + pub max_fee_per_gas: U256, /// The gas limit for the transaction pub gas_limit: U256, /// The kind of transaction (e.g., Call, Create) @@ -111,7 +111,7 @@ pub struct EIP4844TransactionRequest { /// The access list for the transaction pub access_list: AccessList, /// The maximum fee per blob gas for the transaction - pub max_fee_per_blob_gas: U128, + pub max_fee_per_blob_gas: U256, /// Versioned hashes associated with the transaction pub blob_versioned_hashes: Vec, /// Sidecar information for the transaction diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index 7fbbebc8fa4..8a2efcfa686 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -1,5 +1,4 @@ //! Contains RPC handler implementations specific to transactions - use crate::{ eth::{ api::pending_block::PendingBlockEnv, From 4408e15987784b7301d34712ffd7e0ef1f37a171 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Tue, 6 Feb 2024 17:26:38 +0100 Subject: [PATCH 06/12] fix: correct types --- crates/rpc/rpc/src/eth/api/transactions.rs | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index 8a2efcfa686..902000f32f5 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -19,7 +19,7 @@ use reth_primitives::{ revm::env::{fill_block_env_with_coinbase, tx_env_with_recovered}, Address, BlockId, BlockNumberOrTag, Bytes, FromRecoveredPooledTransaction, Header, IntoRecoveredTransaction, Receipt, SealedBlock, SealedBlockWithSenders, - TransactionKind::{self, Call, Create}, + TransactionKind::{Call, Create}, TransactionMeta, TransactionSigned, TransactionSignedEcRecovered, B256, U128, U256, U64, }; use reth_provider::{ @@ -34,8 +34,8 @@ use reth_rpc_types::{ EIP1559TransactionRequest, EIP2930TransactionRequest, EIP4844TransactionRequest, LegacyTransactionRequest, }, - Index, Log, Transaction, TransactionInfo, TransactionReceipt, TransactionRequest, - TypedTransactionRequest, + Index, Log, Transaction, TransactionInfo, TransactionKind as RpcTransactionKind, + TransactionReceipt, TransactionRequest, TypedTransactionRequest, }; use reth_rpc_types_compat::transaction::from_recovered_with_block_context; use reth_transaction_pool::{TransactionOrigin, TransactionPool}; @@ -613,8 +613,8 @@ where .. } = request; - // todo: remove this inlining - let mut transaction = match ( + // todo: remove this inlining after https://github.com/alloy-rs/alloy/pull/183#issuecomment-1928161285 + let transaction = match ( gas_price, max_fee_per_gas, access_list.take(), @@ -632,8 +632,8 @@ where value: value.unwrap_or_default(), input: data.into_input().unwrap_or_default(), kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, + Some(to) => RpcTransactionKind::Call(to), + None => RpcTransactionKind::Create, }, chain_id: None, })) @@ -648,8 +648,8 @@ where value: value.unwrap_or_default(), input: data.into_input().unwrap_or_default(), kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, + Some(to) => RpcTransactionKind::Call(to), + None => RpcTransactionKind::Create, }, chain_id: 0, access_list, @@ -669,8 +669,8 @@ where value: value.unwrap_or_default(), input: data.into_input().unwrap_or_default(), kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, + Some(to) => RpcTransactionKind::Call(to), + None => RpcTransactionKind::Create, }, chain_id: 0, access_list: access_list.unwrap_or_default(), @@ -696,8 +696,8 @@ where value: value.unwrap_or_default(), input: data.into_input().unwrap_or_default(), kind: match to { - Some(to) => TransactionKind::Call(to), - None => TransactionKind::Create, + Some(to) => RpcTransactionKind::Call(to), + None => RpcTransactionKind::Create, }, access_list: access_list.unwrap_or_default(), From 0d8c3e6a6194f567d0c3c86d11ac7f21bac07ac8 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Tue, 6 Feb 2024 17:28:06 +0100 Subject: [PATCH 07/12] chore: exhaustiveness --- crates/rpc/rpc-types-compat/src/transaction/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/rpc/rpc-types-compat/src/transaction/mod.rs b/crates/rpc/rpc-types-compat/src/transaction/mod.rs index ee2976ea972..5ecad24dca8 100644 --- a/crates/rpc/rpc-types-compat/src/transaction/mod.rs +++ b/crates/rpc/rpc-types-compat/src/transaction/mod.rs @@ -1,7 +1,10 @@ //! Compatibility functions for rpc `Transaction` type. mod signature; mod typed; -use alloy_rpc_types::request::{TransactionInput, TransactionRequest}; +use alloy_rpc_types::{ + other::OtherFields, + request::{TransactionInput, TransactionRequest}, +}; use reth_primitives::{ BlockNumber, Transaction as PrimitiveTransaction, TransactionKind as PrimitiveTransactionKind, TransactionSignedEcRecovered, TxType, B256, U128, U256, U64, @@ -205,6 +208,7 @@ pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> Transact max_fee_per_blob_gas: max_fee_per_blob_gas.map(U256::from), blob_versioned_hashes, transaction_type: Some(tx_type.into()), - ..Default::default() + sidecar: None, + other: OtherFields::default(), } } From 50a8c8483840e6dd468d3ba10ecfd7dd0d7fdb09 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 9 Feb 2024 14:19:14 +0100 Subject: [PATCH 08/12] chore: update --- Cargo.lock | 92 +++++++++++++----------------------------------------- 1 file changed, 21 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44771cedcfb..6943adc4688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5846,7 +5846,7 @@ dependencies = [ "reth-revm", "reth-tasks", "reth-transaction-pool", - "revm 4.0.0", + "revm", "tokio", "tracing", ] @@ -6169,7 +6169,7 @@ dependencies = [ "reth-provider", "reth-revm", "reth-transaction-pool", - "revm 4.0.0", + "revm", "tracing", ] @@ -6388,7 +6388,7 @@ version = "0.1.0-alpha.17" dependencies = [ "reth-primitives", "reth-rpc-types", - "revm-primitives 2.0.0", + "revm-primitives", "serde", "thiserror", ] @@ -6494,7 +6494,7 @@ dependencies = [ "reth-provider", "reth-revm", "reth-transaction-pool", - "revm 4.0.0", + "revm", "thiserror", "tracing", ] @@ -6516,8 +6516,8 @@ dependencies = [ "reth-rpc-types-compat", "reth-tasks", "reth-transaction-pool", - "revm 4.0.0", - "revm-primitives 2.0.0", + "revm", + "revm-primitives", "serde", "sha2", "thiserror", @@ -6569,8 +6569,8 @@ dependencies = [ "reth-codecs", "reth-ethereum-forks", "reth-rpc-types", - "revm 4.0.0", - "revm-primitives 2.0.0", + "revm", + "revm-primitives", "secp256k1 0.27.0", "serde", "serde_json", @@ -6608,7 +6608,7 @@ dependencies = [ "reth-node-api", "reth-primitives", "reth-trie", - "revm 4.0.0", + "revm", "strum 0.26.1", "tempfile", "tokio", @@ -6651,7 +6651,7 @@ dependencies = [ "reth-primitives", "reth-provider", "reth-trie", - "revm 4.0.0", + "revm", "revm-inspectors", "tracing", ] @@ -6697,9 +6697,9 @@ dependencies = [ "reth-rpc-types-compat", "reth-tasks", "reth-transaction-pool", - "revm 4.0.0", + "revm", "revm-inspectors", - "revm-primitives 2.0.0", + "revm-primitives", "schnellru", "secp256k1 0.27.0", "serde", @@ -6894,7 +6894,7 @@ dependencies = [ "reth-revm", "reth-tokio-util", "reth-trie", - "revm 4.0.0", + "revm", "serde", "serde_json", "thiserror", @@ -6965,7 +6965,7 @@ dependencies = [ "reth-revm", "reth-tasks", "reth-tracing", - "revm 4.0.0", + "revm", "schnellru", "serde", "serde_json", @@ -6991,7 +6991,7 @@ dependencies = [ "reth-interfaces", "reth-primitives", "reth-provider", - "revm 4.0.0", + "revm", "serde_json", "similar-asserts", "thiserror", @@ -7001,16 +7001,6 @@ dependencies = [ "triehash", ] -[[package]] -name = "revm" -version = "3.5.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" -dependencies = [ - "auto_impl", - "revm-interpreter 1.3.0", - "revm-precompile 2.2.0", -] - [[package]] name = "revm" version = "4.0.0" @@ -7018,8 +7008,8 @@ source = "git+https://github.com/bluealloy/revm?branch=main#bbca12830be2757ff3e6 dependencies = [ "auto_impl", "cfg-if", - "revm-interpreter 2.0.0", - "revm-precompile 3.0.0", + "revm-interpreter", + "revm-precompile", "serde", "serde_json", ] @@ -7027,7 +7017,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?branch=onbjerg/rm-callrequest#9f87b5bce73d9808b9f3925985fb6aa93b83e75b" +source = "git+https://github.com/paradigmxyz/evm-inspectors?branch=onbjerg/rm-callrequest#9252718a209fbf0f7326fb08c653bb432281f543" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", @@ -7035,45 +7025,21 @@ dependencies = [ "alloy-sol-types", "boa_engine", "boa_gc", - "revm 3.5.0", + "revm", "serde", "serde_json", "thiserror", ] -[[package]] -name = "revm-interpreter" -version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" -dependencies = [ - "revm-primitives 1.3.0", -] - [[package]] name = "revm-interpreter" version = "2.0.0" source = "git+https://github.com/bluealloy/revm?branch=main#bbca12830be2757ff3e608a36f062f5e2d62231b" dependencies = [ - "revm-primitives 2.0.0", + "revm-primitives", "serde", ] -[[package]] -name = "revm-precompile" -version = "2.2.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" -dependencies = [ - "aurora-engine-modexp", - "c-kzg", - "k256", - "once_cell", - "revm-primitives 1.3.0", - "ripemd", - "secp256k1 0.28.2", - "sha2", - "substrate-bn", -] - [[package]] name = "revm-precompile" version = "3.0.0" @@ -7084,29 +7050,13 @@ dependencies = [ "c-kzg", "k256", "once_cell", - "revm-primitives 2.0.0", + "revm-primitives", "ripemd", "secp256k1 0.28.2", "sha2", "substrate-bn", ] -[[package]] -name = "revm-primitives" -version = "1.3.0" -source = "git+https://github.com/bluealloy/revm?branch=reth_freeze#ba28a42393604beeb2da5a339ac47d3d5d3f2271" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "auto_impl", - "bitflags 2.4.2", - "bitvec", - "cfg-if", - "enumn", - "hashbrown 0.14.3", - "hex", -] - [[package]] name = "revm-primitives" version = "2.0.0" From e8d5dd6941723befd85ed88ffbd1f8596d4c93da Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 9 Feb 2024 14:29:35 +0100 Subject: [PATCH 09/12] chore: update alloy --- Cargo.lock | 48 ++++++++++++++++++++++++++++++++++++------------ Cargo.toml | 10 +++++----- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6943adc4688..016ec7e5012 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,10 +173,10 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" +source = "git+https://github.com/alloy-rs/alloy?branch=main#80206e7ba7686c514da291c06a5e7912b5361047" dependencies = [ "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", "serde", ] @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-node-bindings" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" +source = "git+https://github.com/alloy-rs/alloy?branch=main#80206e7ba7686c514da291c06a5e7912b5361047" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -256,11 +256,11 @@ dependencies = [ [[package]] name = "alloy-rpc-engine-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" +source = "git+https://github.com/alloy-rs/alloy?branch=main#80206e7ba7686c514da291c06a5e7912b5361047" dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", "ethereum_ssz", "ethereum_ssz_derive", "jsonrpsee-types", @@ -268,13 +268,24 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-rpc-trace-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?branch=main#80206e7ba7686c514da291c06a5e7912b5361047" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", + "serde", + "serde_json", +] + [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" dependencies = [ "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", "serde", "serde_json", ] @@ -282,7 +293,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" +source = "git+https://github.com/alloy-rs/alloy?branch=main#80206e7ba7686c514da291c06a5e7912b5361047" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -298,6 +309,19 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-rpc-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "itertools 0.12.1", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "alloy-sol-macro" version = "0.6.2" @@ -6812,8 +6836,8 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-engine-types", - "alloy-rpc-trace-types", - "alloy-rpc-types", + "alloy-rpc-trace-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", "arbitrary", "bytes", "ethereum_ssz", @@ -6837,7 +6861,7 @@ name = "reth-rpc-types-compat" version = "0.1.0-alpha.17" dependencies = [ "alloy-rlp", - "alloy-rpc-types", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", "reth-primitives", "reth-rpc-types", "serde_json", @@ -7020,8 +7044,8 @@ version = "0.1.0" source = "git+https://github.com/paradigmxyz/evm-inspectors?branch=onbjerg/rm-callrequest#9252718a209fbf0f7326fb08c653bb432281f543" dependencies = [ "alloy-primitives", - "alloy-rpc-trace-types", - "alloy-rpc-types", + "alloy-rpc-trace-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", "alloy-sol-types", "boa_engine", "boa_gc", diff --git a/Cargo.toml b/Cargo.toml index c1b72c907ee..6b22b4843d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -184,11 +184,11 @@ alloy-dyn-abi = "0.6" alloy-sol-types = "0.6" alloy-rlp = "0.3" alloy-trie = "0.2" -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } -alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } -alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", branch = "onbjerg/rm-callrequest" } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", branch = "main" } +alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", branch = "main" } +alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy", branch = "main" } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", branch = "main" } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", branch = "main" } ethers-core = { version = "2.0", default-features = false } ethers-providers = { version = "2.0", default-features = false } ethers-signers = { version = "2.0", default-features = false } From 2d895e8cc03b20966162723d7a87680933906335 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 9 Feb 2024 14:32:38 +0100 Subject: [PATCH 10/12] chore: update evm-inspectors --- Cargo.lock | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 016ec7e5012..61a7e45c37a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,7 +176,7 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?branch=main#80206e7ba7686c514da291c06a5e7912b5361047" dependencies = [ "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", + "alloy-rpc-types", "serde", ] @@ -260,7 +260,7 @@ source = "git+https://github.com/alloy-rs/alloy?branch=main#80206e7ba7686c514da2 dependencies = [ "alloy-primitives", "alloy-rlp", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", + "alloy-rpc-types", "ethereum_ssz", "ethereum_ssz_derive", "jsonrpsee-types", @@ -274,18 +274,7 @@ version = "0.1.0" source = "git+https://github.com/alloy-rs/alloy?branch=main#80206e7ba7686c514da291c06a5e7912b5361047" dependencies = [ "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", - "serde", - "serde_json", -] - -[[package]] -name = "alloy-rpc-trace-types" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", + "alloy-rpc-types", "serde", "serde_json", ] @@ -309,19 +298,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "alloy-rpc-types" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest#093af2313ed25104ff7ca9e0850e0fcbe2256111" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "itertools 0.12.1", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "alloy-sol-macro" version = "0.6.2" @@ -6836,8 +6812,8 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-rpc-engine-types", - "alloy-rpc-trace-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", + "alloy-rpc-trace-types", + "alloy-rpc-types", "arbitrary", "bytes", "ethereum_ssz", @@ -6861,7 +6837,7 @@ name = "reth-rpc-types-compat" version = "0.1.0-alpha.17" dependencies = [ "alloy-rlp", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=main)", + "alloy-rpc-types", "reth-primitives", "reth-rpc-types", "serde_json", @@ -7041,11 +7017,11 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?branch=onbjerg/rm-callrequest#9252718a209fbf0f7326fb08c653bb432281f543" +source = "git+https://github.com/paradigmxyz/evm-inspectors?branch=onbjerg/rm-callrequest#70807da74e46641532f67caac9e37fbf5d7080c1" dependencies = [ "alloy-primitives", - "alloy-rpc-trace-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?branch=onbjerg/rm-callrequest)", + "alloy-rpc-trace-types", + "alloy-rpc-types", "alloy-sol-types", "boa_engine", "boa_gc", From fe486d0a047e85ad739c305d61bab073d58fc916 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 9 Feb 2024 14:41:06 +0100 Subject: [PATCH 11/12] chore: clippy --- crates/rpc/rpc/src/eth/api/transactions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index 902000f32f5..36348db5fc3 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -581,7 +581,7 @@ where gas_price: Some(gas_price), max_fee_per_gas: Some(max_fee_per_gas), value: request.value, - input: request.input.clone().into(), + input: request.input.clone(), nonce: request.nonce, chain_id: Some(chain_id), access_list: request.access_list.clone(), From 5b5a42e787c2f52a8a27db88a768400439110d90 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Fri, 9 Feb 2024 14:44:20 +0100 Subject: [PATCH 12/12] chore: adjust test --- crates/rpc/rpc-builder/tests/it/http.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index 41b27732179..2a46db0f90c 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -21,7 +21,7 @@ use reth_rpc_api::{ }; use reth_rpc_builder::RethRpcModule; use reth_rpc_types::{ - trace::filter::TraceFilter, CallRequest, Filter, Index, Log, PendingTransactionFilterKind, + trace::filter::TraceFilter, Filter, Index, Log, PendingTransactionFilterKind, TransactionRequest, }; use serde::{Deserialize, Serialize}; @@ -129,7 +129,7 @@ where let hash = B256::default(); let tx_hash = TxHash::default(); let block_number = BlockNumberOrTag::default(); - let call_request = CallRequest::default(); + let call_request = TransactionRequest::default(); let transaction_request = TransactionRequest::default(); let bytes = Bytes::default(); let tx = Bytes::from(hex!("02f871018303579880850555633d1b82520894eee27662c2b8eba3cd936a23f039f3189633e4c887ad591c62bdaeb180c080a07ea72c68abfb8fca1bd964f0f99132ed9280261bdca3e549546c0205e800f7d0a05b4ef3039e9c9b9babc179a1878fb825b5aaf5aed2fa8744854150157b08d6f3"));