diff --git a/Cargo.lock b/Cargo.lock index ffda5b198..a9fa5b3f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,16 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -dependencies = [ - "lazy_static", - "regex", -] - [[package]] name = "addchain" version = "0.2.0" @@ -143,11 +133,28 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "alloy" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +dependencies = [ + "alloy-consensus", + "alloy-core", + "alloy-provider", + "alloy-rpc-client", + "alloy-rpc-types", + "alloy-signer", + "alloy-signer-wallet", + "alloy-transport", + "alloy-transport-http", + "hyper 1.3.1", +] + [[package]] name = "alloy-chains" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ceb48af11349cd7fbd12aa739800be3c4b3965f640b7ae26666907f3bdf091" +checksum = "d2feb5f466b3a786d5a622d8926418bc6a0d38bf632909f6ee9298a4a1d8c6e0" dependencies = [ "alloy-rlp", "arbitrary", @@ -170,11 +177,20 @@ dependencies = [ "serde", ] +[[package]] +name = "alloy-core" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5af3faff14c12c8b11037e0a093dd157c3702becb8435577a2408534d0758315" +dependencies = [ + "alloy-primitives", +] + [[package]] name = "alloy-dyn-abi" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8425a283510106b1a6ad25dd4bb648ecde7da3fd2baeb9400a85ad62f51ec90b" +checksum = "cb6e6436a9530f25010d13653e206fab4c9feddacf21a54de8d7311b275bc56b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -219,9 +235,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e30946aa6173020259055a44971f5cf40a7d76c931d209caeb51b333263df4f" +checksum = "aaeaccd50238126e3a0ff9387c7c568837726ad4f4e399b528ca88104d6c25ef" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -229,10 +245,40 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-json-rpc" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", + "thiserror", + "tracing", +] + +[[package]] +name = "alloy-network" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +dependencies = [ + "alloy-consensus", + "alloy-eips", + "alloy-json-rpc", + "alloy-primitives", + "alloy-rpc-types", + "alloy-signer", + "alloy-sol-types", + "async-trait", + "futures-utils-wasm", + "thiserror", +] + [[package]] name = "alloy-primitives" -version = "0.7.4" -source = "git+https://github.com/alloy-rs/core.git?rev=7f17fe3#7f17fe3cfa44823547cbd6b3305d5cdc138fcc85" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f783611babedbbe90db3478c120fb5f5daacceffc210b39adc0af4fe0da70bad" dependencies = [ "alloy-rlp", "arbitrary", @@ -255,6 +301,33 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "alloy-provider" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +dependencies = [ + "alloy-eips", + "alloy-json-rpc", + "alloy-network", + "alloy-primitives", + "alloy-rpc-client", + "alloy-rpc-types", + "alloy-rpc-types-trace", + "alloy-transport", + "alloy-transport-http", + "async-stream", + "async-trait", + "auto_impl", + "dashmap", + "futures", + "futures-utils-wasm", + "lru", + "serde_json", + "tokio", + "tracing", + "url", +] + [[package]] name = "alloy-rlp" version = "0.3.5" @@ -277,6 +350,26 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "alloy-rpc-client" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +dependencies = [ + "alloy-json-rpc", + "alloy-transport", + "alloy-transport-http", + "futures", + "hyper-util", + "pin-project", + "serde", + "serde_json", + "tokio", + "tokio-stream", + "tower", + "tracing", + "url", +] + [[package]] name = "alloy-rpc-types" version = "0.1.0" @@ -358,6 +451,34 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-signer" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +dependencies = [ + "alloy-primitives", + "async-trait", + "auto_impl", + "elliptic-curve", + "k256", + "thiserror", +] + +[[package]] +name = "alloy-signer-wallet" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +dependencies = [ + "alloy-consensus", + "alloy-network", + "alloy-primitives", + "alloy-signer", + "async-trait", + "k256", + "rand 0.8.5", + "thiserror", +] + [[package]] name = "alloy-sol-macro" version = "0.7.6" @@ -378,6 +499,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd9899da7d011b4fe4c406a524ed3e3f963797dbc93b45479d60341d3a27b252" dependencies = [ + "alloy-json-abi", "alloy-sol-macro-input", "const-hex", "heck 0.5.0", @@ -396,11 +518,13 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d32d595768fdc61331a132b6f65db41afae41b9b97d36c21eb1b955c422a7e60" dependencies = [ + "alloy-json-abi", "const-hex", "dunce", "heck 0.5.0", "proc-macro2 1.0.85", "quote 1.0.36", + "serde_json", "syn 2.0.66", "syn-solidity", ] @@ -416,16 +540,51 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a64d2d2395c1ac636b62419a7b17ec39031d6b2367e66e9acbf566e6055e9c" +checksum = "a49042c6d3b66a9fe6b2b5a8bf0d39fc2ae1ee0310a2a26ffedd79fb097878dd" dependencies = [ + "alloy-json-abi", "alloy-primitives", "alloy-sol-macro", "const-hex", "serde", ] +[[package]] +name = "alloy-transport" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +dependencies = [ + "alloy-json-rpc", + "base64 0.22.1", + "futures-util", + "futures-utils-wasm", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower", + "url", + "wasm-bindgen-futures", +] + +[[package]] +name = "alloy-transport-http" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=77c1240#77c1240533b411ed0eb5533f94396eba8d7f6ab6" +dependencies = [ + "alloy-json-rpc", + "alloy-transport", + "http-body-util", + "hyper 1.3.1", + "hyper-util", + "serde_json", + "tower", + "tracing", + "url", +] + [[package]] name = "alloy-trie" version = "0.3.1" @@ -791,15 +950,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "ascii-canvas" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" -dependencies = [ - "term", -] - [[package]] name = "asn1_der" version = "0.7.6" @@ -807,10 +957,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "155a5a185e42c6b77ac7b88a15143d930a9e9727a5b7b77eed417404ab15c247" [[package]] -name = "async-trait" -version = "0.1.80" +name = "async-stream" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2 1.0.85", "quote 1.0.36", @@ -818,14 +979,14 @@ dependencies = [ ] [[package]] -name = "async_io_stream" -version = "0.3.3" +name = "async-trait" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ - "futures", - "pharos", - "rustc_version 0.4.0", + "proc-macro2 1.0.85", + "quote 1.0.36", + "syn 2.0.66", ] [[package]] @@ -1153,7 +1314,7 @@ dependencies = [ "arrayvec", "cc", "cfg-if", - "constant_time_eq 0.3.0", + "constant_time_eq", ] [[package]] @@ -1404,7 +1565,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ - "sha2 0.10.8", "tinyvec", ] @@ -1455,16 +1615,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bzip2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] - [[package]] name = "bzip2-sys" version = "0.1.11+1.0.8" @@ -1522,20 +1672,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cargo_metadata" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" -dependencies = [ - "camino", - "cargo-platform", - "semver 1.0.23", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "cast" version = "0.3.0" @@ -1633,6 +1769,10 @@ dependencies = [ name = "citrea" version = "0.4.0-rc.3" dependencies = [ + "alloy", + "alloy-primitives", + "alloy-rlp", + "alloy-sol-types", "anyhow", "async-trait", "bincode", @@ -1646,13 +1786,6 @@ dependencies = [ "citrea-stf", "clap", "ethereum-rpc", - "ethereum-types", - "ethers", - "ethers-contract", - "ethers-core", - "ethers-middleware", - "ethers-providers", - "ethers-signers", "hex", "humantime", "jsonrpsee", @@ -1696,6 +1829,7 @@ dependencies = [ name = "citrea-evm" version = "0.4.0-rc.3" dependencies = [ + "alloy", "alloy-primitives", "alloy-rlp", "alloy-sol-types", @@ -1703,12 +1837,6 @@ dependencies = [ "borsh", "bytes", "clap", - "ethereum-types", - "ethers", - "ethers-contract", - "ethers-core", - "ethers-middleware", - "ethers-signers", "hex", "itertools 0.13.0", "jsonrpsee", @@ -1813,6 +1941,7 @@ name = "citrea-sequencer" version = "0.4.0-rc.3" dependencies = [ "alloy-rlp", + "alloy-sol-types", "anyhow", "borsh", "chrono", @@ -1820,7 +1949,6 @@ dependencies = [ "citrea-stf", "deadpool-postgres", "digest 0.10.7", - "ethers", "futures", "hex", "jsonrpsee", @@ -1928,58 +2056,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" -[[package]] -name = "coins-bip32" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" -dependencies = [ - "bs58", - "coins-core", - "digest 0.10.7", - "hmac 0.12.1", - "k256", - "serde", - "sha2 0.10.8", - "thiserror", -] - -[[package]] -name = "coins-bip39" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" -dependencies = [ - "bitvec", - "coins-bip32", - "hmac 0.12.1", - "once_cell", - "pbkdf2 0.12.2", - "rand 0.8.5", - "sha2 0.10.8", - "thiserror", -] - -[[package]] -name = "coins-core" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" -dependencies = [ - "base64 0.21.7", - "bech32 0.9.1", - "bs58", - "digest 0.10.7", - "generic-array", - "hex", - "ripemd", - "serde", - "serde_derive", - "sha2 0.10.8", - "sha3", - "thiserror", -] - [[package]] name = "colorchoice" version = "1.0.1" @@ -2030,12 +2106,6 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" name = "const-rollup-config" version = "0.4.0-rc.3" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "constant_time_eq" version = "0.3.0" @@ -2609,45 +2679,15 @@ dependencies = [ ] [[package]] -name = "dirs" -version = "5.0.1" +name = "dirs-sys" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", ] [[package]] @@ -2661,7 +2701,7 @@ dependencies = [ "alloy-rlp", "arrayvec", "delay_map", - "enr 0.12.0", + "enr", "fnv", "futures", "hashlink 0.8.4", @@ -2831,15 +2871,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ena" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" -dependencies = [ - "log", -] - [[package]] name = "encoding_rs" version = "0.8.34" @@ -2855,24 +2886,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" -[[package]] -name = "enr" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" -dependencies = [ - "base64 0.21.7", - "bytes", - "hex", - "k256", - "log", - "rand 0.8.5", - "rlp", - "serde", - "sha3", - "zeroize", -] - [[package]] name = "enr" version = "0.12.0" @@ -2967,45 +2980,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "eth-keystore" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" -dependencies = [ - "aes 0.8.4", - "ctr 0.9.2", - "digest 0.10.7", - "hex", - "hmac 0.12.1", - "pbkdf2 0.11.0", - "rand 0.8.5", - "scrypt", - "serde", - "serde_json", - "sha2 0.10.8", - "sha3", - "thiserror", - "uuid", -] - -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - [[package]] name = "ethbloom" version = "0.13.0" @@ -3014,10 +2988,8 @@ checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", "fixed-hash", - "impl-codec", "impl-rlp", "impl-serde", - "scale-info", "tiny-keccak", ] @@ -3028,7 +3000,6 @@ dependencies = [ "anyhow", "borsh", "citrea-evm", - "ethers", "jsonrpsee", "proptest", "reth-primitives", @@ -3054,11 +3025,9 @@ checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ "ethbloom", "fixed-hash", - "impl-codec", "impl-rlp", "impl-serde", "primitive-types", - "scale-info", "uint", ] @@ -3073,254 +3042,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "ethers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816841ea989f0c69e459af1cf23a6b0033b19a55424a1ea3a30099becdb8dec0" -dependencies = [ - "ethers-addressbook", - "ethers-contract", - "ethers-core", - "ethers-etherscan", - "ethers-middleware", - "ethers-providers", - "ethers-signers", - "ethers-solc", -] - -[[package]] -name = "ethers-addressbook" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5495afd16b4faa556c3bba1f21b98b4983e53c1755022377051a975c3b021759" -dependencies = [ - "ethers-core", - "once_cell", - "serde", - "serde_json", -] - -[[package]] -name = "ethers-contract" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fceafa3578c836eeb874af87abacfb041f92b4da0a78a5edd042564b8ecdaaa" -dependencies = [ - "const-hex", - "ethers-contract-abigen", - "ethers-contract-derive", - "ethers-core", - "ethers-providers", - "futures-util", - "once_cell", - "pin-project", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "ethers-contract-abigen" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04ba01fbc2331a38c429eb95d4a570166781f14290ef9fdb144278a90b5a739b" -dependencies = [ - "Inflector", - "const-hex", - "dunce", - "ethers-core", - "ethers-etherscan", - "eyre", - "prettyplease", - "proc-macro2 1.0.85", - "quote 1.0.36", - "regex", - "reqwest 0.11.27", - "serde", - "serde_json", - "syn 2.0.66", - "toml 0.8.14", - "walkdir", -] - -[[package]] -name = "ethers-contract-derive" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87689dcabc0051cde10caaade298f9e9093d65f6125c14575db3fd8c669a168f" -dependencies = [ - "Inflector", - "const-hex", - "ethers-contract-abigen", - "ethers-core", - "proc-macro2 1.0.85", - "quote 1.0.36", - "serde_json", - "syn 2.0.66", -] - -[[package]] -name = "ethers-core" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" -dependencies = [ - "arrayvec", - "bytes", - "cargo_metadata 0.18.1", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array", - "k256", - "num_enum", - "once_cell", - "open-fastrlp", - "rand 0.8.5", - "rlp", - "serde", - "serde_json", - "strum", - "syn 2.0.66", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid 0.2.4", -] - -[[package]] -name = "ethers-etherscan" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79e5973c26d4baf0ce55520bd732314328cabe53193286671b47144145b9649" -dependencies = [ - "chrono", - "ethers-core", - "reqwest 0.11.27", - "semver 1.0.23", - "serde", - "serde_json", - "thiserror", - "tracing", -] - -[[package]] -name = "ethers-middleware" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f9fdf09aec667c099909d91908d5eaf9be1bd0e2500ba4172c1d28bfaa43de" -dependencies = [ - "async-trait", - "auto_impl", - "ethers-contract", - "ethers-core", - "ethers-etherscan", - "ethers-providers", - "ethers-signers", - "futures-channel", - "futures-locks", - "futures-util", - "instant", - "reqwest 0.11.27", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", - "tracing-futures", - "url", -] - -[[package]] -name = "ethers-providers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6434c9a33891f1effc9c75472e12666db2fa5a0fec4b29af6221680a6fe83ab2" -dependencies = [ - "async-trait", - "auto_impl", - "base64 0.21.7", - "bytes", - "const-hex", - "enr 0.10.0", - "ethers-core", - "futures-core", - "futures-timer", - "futures-util", - "hashers", - "http 0.2.12", - "instant", - "jsonwebtoken 8.3.0", - "once_cell", - "pin-project", - "reqwest 0.11.27", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-tungstenite", - "tracing", - "tracing-futures", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "ws_stream_wasm", -] - -[[package]] -name = "ethers-signers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228875491c782ad851773b652dd8ecac62cda8571d3bc32a5853644dd26766c2" -dependencies = [ - "async-trait", - "coins-bip32", - "coins-bip39", - "const-hex", - "elliptic-curve", - "eth-keystore", - "ethers-core", - "rand 0.8.5", - "sha2 0.10.8", - "thiserror", - "tracing", -] - -[[package]] -name = "ethers-solc" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66244a771d9163282646dbeffe0e6eca4dda4146b6498644e678ac6089b11edd" -dependencies = [ - "cfg-if", - "const-hex", - "dirs", - "dunce", - "ethers-core", - "glob", - "home", - "md-5", - "num_cpus", - "once_cell", - "path-slash", - "rayon", - "regex", - "semver 1.0.23", - "serde", - "serde_json", - "solang-parser", - "svm-rs", - "thiserror", - "tiny-keccak", - "tokio", - "tracing", - "walkdir", - "yansi", -] - [[package]] name = "eyre" version = "0.6.12" @@ -3451,16 +3172,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "funty" version = "2.0.0" @@ -3516,16 +3227,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" -[[package]] -name = "futures-locks" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" -dependencies = [ - "futures-channel", - "futures-task", -] - [[package]] name = "futures-macro" version = "0.3.30" @@ -3573,7 +3274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" dependencies = [ "gloo-timers", - "send_wrapper 0.4.0", + "send_wrapper", ] [[package]] @@ -3595,13 +3296,10 @@ dependencies = [ ] [[package]] -name = "fxhash" -version = "0.2.1" +name = "futures-utils-wasm" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] +checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" [[package]] name = "generic-array" @@ -3801,15 +3499,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hashers" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" -dependencies = [ - "fxhash", -] - [[package]] name = "hashlink" version = "0.8.4" @@ -3912,15 +3601,6 @@ dependencies = [ "hmac 0.8.1", ] -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "hostname" version = "0.3.1" @@ -4059,6 +3739,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -4546,15 +4227,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.12.1" @@ -4826,49 +4498,19 @@ dependencies = [ name = "keccak" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "keccak-asm" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" -dependencies = [ - "digest 0.10.7", - "sha3-asm", -] - -[[package]] -name = "lalrpop" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cb077ad656299f160924eb2912aa147d7339ea7d69e1b5517326fdcec3c1ca" -dependencies = [ - "ascii-canvas", - "bit-set", - "ena", - "itertools 0.11.0", - "lalrpop-util", - "petgraph", - "regex", - "regex-syntax 0.8.4", - "string_cache", - "term", - "tiny-keccak", - "unicode-xid 0.2.4", - "walkdir", +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", ] [[package]] -name = "lalrpop-util" -version = "0.20.2" +name = "keccak-asm" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" +checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" dependencies = [ - "regex-automata 0.4.7", + "digest 0.10.7", + "sha3-asm", ] [[package]] @@ -5302,9 +4944,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -5515,12 +5157,6 @@ dependencies = [ "rayon", ] -[[package]] -name = "new_debug_unreachable" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" - [[package]] name = "nibble_vec" version = "0.1.0" @@ -5756,31 +5392,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2 1.0.85", - "quote 1.0.36", - "syn 1.0.109", -] - [[package]] name = "openssl-probe" version = "0.1.5" @@ -5879,56 +5490,17 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.1", + "redox_syscall 0.5.2", "smallvec", "windows-targets 0.52.5", ] -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" -[[package]] -name = "path-slash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" - -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest 0.10.7", - "hmac 0.12.1", - "password-hash", - "sha2 0.10.8", -] - -[[package]] -name = "pbkdf2" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" -dependencies = [ - "digest 0.10.7", - "hmac 0.12.1", -] - [[package]] name = "pem" version = "1.1.1" @@ -5988,16 +5560,6 @@ dependencies = [ "wyhash", ] -[[package]] -name = "pharos" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" -dependencies = [ - "futures", - "rustc_version 0.4.0", -] - [[package]] name = "phf" version = "0.11.2" @@ -6005,7 +5567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ "phf_macros", - "phf_shared 0.11.2", + "phf_shared", ] [[package]] @@ -6014,7 +5576,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ - "phf_shared 0.11.2", + "phf_shared", "rand 0.8.5", ] @@ -6025,21 +5587,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" dependencies = [ "phf_generator", - "phf_shared 0.11.2", + "phf_shared", "proc-macro2 1.0.85", "quote 1.0.36", "syn 2.0.66", ] -[[package]] -name = "phf_shared" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" -dependencies = [ - "siphasher", -] - [[package]] name = "phf_shared" version = "0.11.2" @@ -6198,12 +5751,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "precomputed-hash" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" - [[package]] name = "prettyplease" version = "0.2.20" @@ -6224,7 +5771,6 @@ dependencies = [ "impl-codec", "impl-rlp", "impl-serde", - "scale-info", "uint", ] @@ -6276,7 +5822,7 @@ version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" dependencies = [ - "unicode-xid 0.1.0", + "unicode-xid", ] [[package]] @@ -6602,9 +6148,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] @@ -6895,7 +6441,7 @@ source = "git+https://github.com/paradigmxyz/reth?tag=v0.2.0-beta.7#a44e0857373c dependencies = [ "alloy-rlp", "discv5", - "enr 0.12.0", + "enr", "generic-array", "parking_lot 0.12.3", "reth-net-common", @@ -6918,7 +6464,7 @@ dependencies = [ "alloy-rlp", "derive_more", "discv5", - "enr 0.12.0", + "enr", "futures", "itertools 0.12.1", "libp2p-identity", @@ -6940,7 +6486,7 @@ version = "0.2.0-beta.7" source = "git+https://github.com/paradigmxyz/reth?tag=v0.2.0-beta.7#a44e0857373cee447c3823608194ccac53509140" dependencies = [ "data-encoding", - "enr 0.12.0", + "enr", "linked_hash_set", "parking_lot 0.12.3", "reth-net-common", @@ -7198,7 +6744,7 @@ dependencies = [ "auto_impl", "derive_more", "discv5", - "enr 0.12.0", + "enr", "fnv", "futures", "futures-test", @@ -7243,7 +6789,7 @@ name = "reth-network-api" version = "0.2.0-beta.7" source = "git+https://github.com/paradigmxyz/reth?tag=v0.2.0-beta.7#a44e0857373cee447c3823608194ccac53509140" dependencies = [ - "enr 0.12.0", + "enr", "reth-discv4", "reth-eth-wire", "reth-network-types", @@ -7261,7 +6807,7 @@ source = "git+https://github.com/paradigmxyz/reth?tag=v0.2.0-beta.7#a44e0857373c dependencies = [ "alloy-primitives", "alloy-rlp", - "enr 0.12.0", + "enr", "secp256k1", "serde_with", "thiserror", @@ -7285,7 +6831,7 @@ dependencies = [ "sucds", "thiserror", "tracing", - "zstd 0.13.1", + "zstd", ] [[package]] @@ -7354,7 +6900,7 @@ dependencies = [ "strum", "tempfile", "thiserror", - "zstd 0.13.1", + "zstd", ] [[package]] @@ -7831,7 +7377,7 @@ checksum = "d7a6a0138c9ae1d82eaa2ab6047535481a17641ba6c354890770bf94fbef8049" dependencies = [ "anyhow", "cargo-platform", - "cargo_metadata 0.17.0", + "cargo_metadata", "docker-generate", "risc0-binfmt", "risc0-zkp", @@ -8041,21 +7587,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", - "rlp-derive", "rustc-hex", ] -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2 1.0.85", - "quote 1.0.36", - "syn 1.0.109", -] - [[package]] name = "roaring" version = "0.10.5" @@ -8367,15 +7901,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad97d4ce1560a5e27cec89519dc8300d1aa6035b099821261c651486a19e44d5" -[[package]] -name = "salsa20" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" -dependencies = [ - "cipher 0.4.4", -] - [[package]] name = "same-file" version = "1.0.6" @@ -8385,30 +7910,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scale-info" -version = "2.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" -dependencies = [ - "proc-macro-crate 3.1.0", - "proc-macro2 1.0.85", - "quote 1.0.36", - "syn 1.0.109", -] - [[package]] name = "schannel" version = "0.1.23" @@ -8459,18 +7960,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "scrypt" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" -dependencies = [ - "hmac 0.12.1", - "pbkdf2 0.11.0", - "salsa20", - "sha2 0.10.8", -] - [[package]] name = "sct" version = "0.7.1" @@ -8570,18 +8059,11 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" -[[package]] -name = "send_wrapper" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" - [[package]] name = "sequencer-client" version = "0.4.0-rc.3" dependencies = [ "anyhow", - "ethers", "hex", "jsonrpsee", "reth-primitives", @@ -8709,17 +8191,6 @@ dependencies = [ "opaque-debug", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - [[package]] name = "sha2" version = "0.9.9" @@ -8913,20 +8384,6 @@ dependencies = [ "sha-1", ] -[[package]] -name = "solang-parser" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" -dependencies = [ - "itertools 0.11.0", - "lalrpop", - "lalrpop-util", - "phf", - "thiserror", - "unicode-xid 0.2.4", -] - [[package]] name = "sov-accessory-state" version = "0.4.0-rc.3" @@ -9552,19 +9009,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "string_cache" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" -dependencies = [ - "new_debug_unreachable", - "once_cell", - "parking_lot 0.12.3", - "phf_shared 0.10.0", - "precomputed-hash", -] - [[package]] name = "stringprep" version = "0.1.5" @@ -9639,26 +9083,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "svm-rs" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11297baafe5fa0c99d5722458eac6a5e25c01eb1b8e5cd137f54079093daa7a4" -dependencies = [ - "dirs", - "fs2", - "hex", - "once_cell", - "reqwest 0.11.27", - "semver 1.0.23", - "serde", - "serde_json", - "sha2 0.10.8", - "thiserror", - "url", - "zip", -] - [[package]] name = "syn" version = "0.15.44" @@ -9667,7 +9091,7 @@ checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" dependencies = [ "proc-macro2 0.4.30", "quote 0.6.13", - "unicode-xid 0.1.0", + "unicode-xid", ] [[package]] @@ -9760,17 +9184,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "term" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" -dependencies = [ - "dirs-next", - "rustversion", - "winapi", -] - [[package]] name = "termcolor" version = "1.4.1" @@ -9992,21 +9405,6 @@ dependencies = [ "tokio-util", ] -[[package]] -name = "tokio-tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" -dependencies = [ - "futures-util", - "log", - "rustls 0.21.12", - "tokio", - "tokio-rustls 0.24.1", - "tungstenite", - "webpki-roots 0.25.4", -] - [[package]] name = "tokio-util" version = "0.7.11" @@ -10346,26 +9744,6 @@ dependencies = [ "toml 0.8.14", ] -[[package]] -name = "tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 0.2.12", - "httparse", - "log", - "rand 0.8.5", - "rustls 0.21.12", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "twox-hash" version = "1.6.3" @@ -10482,12 +9860,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - [[package]] name = "universal-hash" version = "0.4.0" @@ -10533,12 +9905,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "utf-8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" - [[package]] name = "utf16_iter" version = "1.0.5" @@ -10557,16 +9923,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "uuid" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" -dependencies = [ - "getrandom 0.2.15", - "serde", -] - [[package]] name = "valuable" version = "0.1.0" @@ -10974,25 +10330,6 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" -[[package]] -name = "ws_stream_wasm" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" -dependencies = [ - "async_io_stream", - "futures", - "js-sys", - "log", - "pharos", - "rustc_version 0.4.0", - "send_wrapper 0.6.0", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wyhash" version = "0.5.0" @@ -11026,12 +10363,6 @@ dependencies = [ "xml-rs", ] -[[package]] -name = "yansi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" - [[package]] name = "yoke" version = "0.7.4" @@ -11145,27 +10476,10 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ - "aes 0.8.4", "byteorder", - "bzip2", - "constant_time_eq 0.1.5", "crc32fast", "crossbeam-utils", "flate2", - "hmac 0.12.1", - "pbkdf2 0.11.0", - "sha1", - "time", - "zstd 0.11.2+zstd.1.5.2", -] - -[[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" -dependencies = [ - "zstd-safe 5.0.2+zstd.1.5.2", ] [[package]] @@ -11174,17 +10488,7 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" dependencies = [ - "zstd-safe 7.1.0", -] - -[[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" -dependencies = [ - "libc", - "zstd-sys", + "zstd-safe", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d2b36f6ec..36bfe5e93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,13 +127,6 @@ risc0-build = "0.21" bonsai-sdk = "0.7.0" # EVM dependencies -ethereum-types = "0.14.1" -ethers = "2.0" -ethers-core = { version = "2.0", default-features = false } -ethers-contract = "2.0" -ethers-providers = { version = "2.0", default-features = false } -ethers-signers = { version = "2.0", default-features = false } -ethers-middleware = { version = "2.0", default-features = false } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "7168ac5", default-features = false } reth-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v0.2.0-beta.7", default-features = false } @@ -152,11 +145,11 @@ reth-stages = { git = "https://github.com/paradigmxyz/reth", tag = "v0.2.0-beta. revm = { version = "8", features = ["serde"], default-features = false } # forcing cargo for this version or else chooses 3.1.1 and there is some dependency conflicts revm-primitives = { version = "3.1", default-features = false } -# forcing cargo for this version or else chooses 0.3.1 and there is some dependency conflicts -alloy-trie = { version = "=0.3.0", default-features = false } +alloy-trie = { version = "0.3", default-features = false } alloy-rlp = { version = "0.3", default-features = false } -alloy-primitives = { version = "0.7.4", default-features = false } -alloy-sol-types = { version = "0.7.4", default-features = false } +alloy-primitives = { version = "0.7.6", default-features = false } +alloy-sol-types = { version = "0.7.6", default-features = false, features = ["json"] } +alloy = { git = "https://github.com/alloy-rs/alloy", rev = "77c1240", default-features = false } ed25519-dalek = { version = "2", default-features = false, features = ["serde"] } secp256k1 = { version = "0.28.2", default-features = false, features = ["global-context", "recovery"] } @@ -180,5 +173,3 @@ sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8 # crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.2-risc0" } secp256k1_v028 = { package = "secp256k1", version = "0.28", git = "https://github.com/Sovereign-Labs/rust-secp256k1.git", branch = "risc0-compatible-0-28-2" } k256 = { package = "k256", version = "0.13.3", git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.0" } -# tmp fix until alloy/core release a new version -alloy-primitives = { git = "https://github.com/alloy-rs/core.git", rev = "7f17fe3" } diff --git a/bin/citrea/Cargo.toml b/bin/citrea/Cargo.toml index 669fad19e..2f48cb253 100644 --- a/bin/citrea/Cargo.toml +++ b/bin/citrea/Cargo.toml @@ -37,6 +37,8 @@ sov-state = { path = "../../crates/sovereign-sdk/module-system/sov-state", featu sov-stf-runner = { path = "../../crates/sovereign-sdk/full-node/sov-stf-runner", features = ["native"] } # 3rd-party deps +alloy-primitives = { workspace = true } +alloy-sol-types = { workspace = true } anyhow = { workspace = true } async-trait = { workspace = true } borsh = { workspace = true, features = ["bytes"] } @@ -62,6 +64,8 @@ sov-mock-da = { path = "../../crates/sovereign-sdk/adapters/mock-da", default-fe sov-prover-storage-manager = { path = "../../crates/sovereign-sdk/full-node/sov-prover-storage-manager", features = ["test-utils"] } sov-rollup-interface = { path = "../../crates/sovereign-sdk/rollup-interface", features = ["fuzzing"] } +alloy = { workspace = true, features = ["hyper", "rpc-types-eth", "provider-http", "signer-wallet", "signers"] } +alloy-rlp = { workspace = true } bincode = { workspace = true } borsh = { workspace = true } hex = { workspace = true } @@ -74,13 +78,6 @@ sha2 = { workspace = true } tempfile = { workspace = true } tokio = { workspace = true } -ethereum-types = { workspace = true } -ethers = { workspace = true } -ethers-contract = { workspace = true } -ethers-core = { workspace = true } -ethers-middleware = { workspace = true } -ethers-providers = { workspace = true } -ethers-signers = { workspace = true } revm = { workspace = true } log = "0.4" diff --git a/bin/citrea/provers/risc0/guest-bitcoin/Cargo.lock b/bin/citrea/provers/risc0/guest-bitcoin/Cargo.lock index 360e011eb..3df1088e3 100644 --- a/bin/citrea/provers/risc0/guest-bitcoin/Cargo.lock +++ b/bin/citrea/provers/risc0/guest-bitcoin/Cargo.lock @@ -71,10 +71,22 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-json-abi" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaeaccd50238126e3a0ff9387c7c568837726ad4f4e399b528ca88104d6c25ef" +dependencies = [ + "alloy-primitives", + "alloy-sol-type-parser", + "serde", +] + [[package]] name = "alloy-primitives" -version = "0.7.4" -source = "git+https://github.com/alloy-rs/core.git?rev=7f17fe3#7f17fe3cfa44823547cbd6b3305d5cdc138fcc85" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f783611babedbbe90db3478c120fb5f5daacceffc210b39adc0af4fe0da70bad" dependencies = [ "alloy-rlp", "bytes", @@ -125,6 +137,77 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-sol-macro" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bad41a7c19498e3f6079f7744656328699f8ea3e783bdd10d85788cd439f572" +dependencies = [ + "alloy-sol-macro-expander", + "alloy-sol-macro-input", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "alloy-sol-macro-expander" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd9899da7d011b4fe4c406a524ed3e3f963797dbc93b45479d60341d3a27b252" +dependencies = [ + "alloy-json-abi", + "alloy-sol-macro-input", + "const-hex", + "heck 0.5.0", + "indexmap 2.2.6", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.66", + "syn-solidity", + "tiny-keccak", +] + +[[package]] +name = "alloy-sol-macro-input" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32d595768fdc61331a132b6f65db41afae41b9b97d36c21eb1b955c422a7e60" +dependencies = [ + "alloy-json-abi", + "const-hex", + "dunce", + "heck 0.5.0", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.66", + "syn-solidity", +] + +[[package]] +name = "alloy-sol-type-parser" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa2fbd22d353d8685bd9fee11ba2d8b5c3b1d11e56adb3265fcf1f32bfdf404" +dependencies = [ + "winnow 0.6.13", +] + +[[package]] +name = "alloy-sol-types" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a49042c6d3b66a9fe6b2b5a8bf0d39fc2ae1ee0310a2a26ffedd79fb097878dd" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-macro", + "const-hex", +] + [[package]] name = "alloy-trie" version = "0.3.1" @@ -799,6 +882,7 @@ dependencies = [ name = "citrea-bitcoin-prover" version = "0.3.0" dependencies = [ + "alloy-primitives", "alloy-trie", "anyhow", "bitcoin-da", @@ -819,6 +903,7 @@ name = "citrea-evm" version = "0.4.0-rc.3" dependencies = [ "alloy-primitives", + "alloy-sol-types", "anyhow", "borsh", "hex", @@ -1105,6 +1190,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "dyn-clone" version = "1.0.17" @@ -1449,6 +1540,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -2031,6 +2128,30 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.84" @@ -2505,9 +2626,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -2529,9 +2650,9 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rustc-hex" @@ -3017,7 +3138,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -3065,6 +3186,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn-solidity" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d71e19bca02c807c9faa67b5a47673ff231b6e7449b251695188522f1dc44b2" +dependencies = [ + "paste", + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "tap" version = "1.0.1" @@ -3190,7 +3323,7 @@ checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.6", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -3475,6 +3608,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" + [[package]] name = "wyz" version = "0.5.1" diff --git a/bin/citrea/provers/risc0/guest-bitcoin/Cargo.toml b/bin/citrea/provers/risc0/guest-bitcoin/Cargo.toml index 2f1ac7111..9c0d7a348 100644 --- a/bin/citrea/provers/risc0/guest-bitcoin/Cargo.toml +++ b/bin/citrea/provers/risc0/guest-bitcoin/Cargo.toml @@ -8,6 +8,7 @@ resolver = "2" [dependencies] # forcing cargo for this version +alloy-primitives = { version = "0.7.6", default-features = false } alloy-trie = { version = "=0.3.1", default-features = false } # forcing cargo for this version reth-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v0.2.0-beta.7", default-features = false } @@ -30,8 +31,6 @@ ed25519-dalek = { git = "https://github.com/risc0/curve25519-dalek", tag = "curv crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.2-risc0" } secp256k1_v028 = { package = "secp256k1", version = "0.28", git = "https://github.com/Sovereign-Labs/rust-secp256k1.git", branch = "risc0-compatible-0-28-2" } k256 = { package = "k256", version = "0.13.3", git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.0" } -# tmp fix -alloy-primitives = { git = "https://github.com/alloy-rs/core.git", rev = "7f17fe3" } [profile.dev] opt-level = 3 diff --git a/bin/citrea/provers/risc0/guest-mock/Cargo.lock b/bin/citrea/provers/risc0/guest-mock/Cargo.lock index 116c71176..d169520ce 100644 --- a/bin/citrea/provers/risc0/guest-mock/Cargo.lock +++ b/bin/citrea/provers/risc0/guest-mock/Cargo.lock @@ -56,10 +56,22 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-json-abi" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaeaccd50238126e3a0ff9387c7c568837726ad4f4e399b528ca88104d6c25ef" +dependencies = [ + "alloy-primitives", + "alloy-sol-type-parser", + "serde", +] + [[package]] name = "alloy-primitives" -version = "0.7.4" -source = "git+https://github.com/alloy-rs/core.git?rev=7f17fe3#7f17fe3cfa44823547cbd6b3305d5cdc138fcc85" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f783611babedbbe90db3478c120fb5f5daacceffc210b39adc0af4fe0da70bad" dependencies = [ "alloy-rlp", "bytes", @@ -110,6 +122,77 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-sol-macro" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bad41a7c19498e3f6079f7744656328699f8ea3e783bdd10d85788cd439f572" +dependencies = [ + "alloy-sol-macro-expander", + "alloy-sol-macro-input", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "alloy-sol-macro-expander" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd9899da7d011b4fe4c406a524ed3e3f963797dbc93b45479d60341d3a27b252" +dependencies = [ + "alloy-json-abi", + "alloy-sol-macro-input", + "const-hex", + "heck 0.5.0", + "indexmap 2.2.6", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.66", + "syn-solidity", + "tiny-keccak", +] + +[[package]] +name = "alloy-sol-macro-input" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32d595768fdc61331a132b6f65db41afae41b9b97d36c21eb1b955c422a7e60" +dependencies = [ + "alloy-json-abi", + "const-hex", + "dunce", + "heck 0.5.0", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.66", + "syn-solidity", +] + +[[package]] +name = "alloy-sol-type-parser" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa2fbd22d353d8685bd9fee11ba2d8b5c3b1d11e56adb3265fcf1f32bfdf404" +dependencies = [ + "winnow 0.6.13", +] + +[[package]] +name = "alloy-sol-types" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a49042c6d3b66a9fe6b2b5a8bf0d39fc2ae1ee0310a2a26ffedd79fb097878dd" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-macro", + "const-hex", +] + [[package]] name = "alloy-trie" version = "0.3.1" @@ -697,6 +780,7 @@ name = "citrea-evm" version = "0.4.0-rc.3" dependencies = [ "alloy-primitives", + "alloy-sol-types", "anyhow", "borsh", "hex", @@ -983,6 +1067,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "dyn-clone" version = "1.0.17" @@ -1238,6 +1328,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -1802,6 +1898,30 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.84" @@ -2272,9 +2392,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -2296,9 +2416,9 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rustc-hex" @@ -2590,6 +2710,7 @@ dependencies = [ name = "sov-demo-prover-guest-mock" version = "0.3.0" dependencies = [ + "alloy-primitives", "alloy-trie", "anyhow", "citrea-stf", @@ -2805,7 +2926,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -2853,6 +2974,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn-solidity" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d71e19bca02c807c9faa67b5a47673ff231b6e7449b251695188522f1dc44b2" +dependencies = [ + "paste", + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "tap" version = "1.0.1" @@ -2978,7 +3111,7 @@ checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.6", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -3263,6 +3396,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" + [[package]] name = "wyz" version = "0.5.1" diff --git a/bin/citrea/provers/risc0/guest-mock/Cargo.toml b/bin/citrea/provers/risc0/guest-mock/Cargo.toml index 5b832e890..a3d39d403 100644 --- a/bin/citrea/provers/risc0/guest-mock/Cargo.toml +++ b/bin/citrea/provers/risc0/guest-mock/Cargo.toml @@ -8,6 +8,7 @@ resolver = "2" [dependencies] # forcing cargo for this version +alloy-primitives = { version = "0.7.6", default-features = false } alloy-trie = { version = "=0.3.1", default-features = false } # forcing cargo for this version reth-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v0.2.0-beta.7", default-features = false } @@ -28,8 +29,6 @@ ed25519-dalek = { git = "https://github.com/risc0/curve25519-dalek", tag = "curv crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.2-risc0" } secp256k1_v028 = { package = "secp256k1", version = "0.28", git = "https://github.com/Sovereign-Labs/rust-secp256k1.git", branch = "risc0-compatible-0-28-2" } k256 = { package = "k256", version = "0.13.3", git = "https://github.com/risc0/RustCrypto-elliptic-curves", tag = "k256/v0.13.3-risczero.0" } -# tmp fix -alloy-primitives = { git = "https://github.com/alloy-rs/core.git", rev = "7f17fe3" } [profile.dev] opt-level = 3 diff --git a/bin/citrea/tests/e2e/mod.rs b/bin/citrea/tests/e2e/mod.rs index 6ff79ad70..715674dbf 100644 --- a/bin/citrea/tests/e2e/mod.rs +++ b/bin/citrea/tests/e2e/mod.rs @@ -3,18 +3,18 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::time::Duration; +use alloy::consensus::{Signed, TxEip1559, TxEnvelope}; +use alloy::signers::wallet::LocalWallet; +use alloy::signers::Signer; +use alloy_rlp::{BytesMut, Decodable, Encodable}; use citrea_evm::smart_contracts::SimpleStorageContract; use citrea_evm::system_contracts::BitcoinLightClient; use citrea_evm::SYSTEM_SIGNER; use citrea_sequencer::{SequencerConfig, SequencerMempoolConfig}; use citrea_stf::genesis_config::GenesisPaths; use ethereum_rpc::CitreaStatus; -use ethereum_types::{H256, U256}; -use ethers::abi::Address; -use ethers_signers::{LocalWallet, Signer}; -use reth_primitives::{BlockNumberOrTag, TxHash}; +use reth_primitives::{Address, BlockNumberOrTag, TxHash, U256}; use rollup_constants::TEST_PRIVATE_KEY; -use secp256k1::rand::thread_rng; use shared_backup_db::{PostgresConnector, ProofType, SharedBackupDbConfig}; use sov_mock_da::{MockAddress, MockDaService, MockDaSpec, MockHash}; use sov_rollup_interface::da::{DaData, DaSpec}; @@ -227,10 +227,16 @@ async fn test_soft_batch_save() -> Result<(), anyhow::Error> { .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; - assert_eq!(seq_block.state_root, full_node_block.state_root); - assert_eq!(full_node_block.state_root, full_node_block_2.state_root); - assert_eq!(seq_block.hash, full_node_block.hash); - assert_eq!(full_node_block.hash, full_node_block_2.hash); + assert_eq!( + seq_block.header.state_root, + full_node_block.header.state_root + ); + assert_eq!( + full_node_block.header.state_root, + full_node_block_2.header.state_root + ); + assert_eq!(seq_block.header.hash, full_node_block.header.hash); + assert_eq!(full_node_block.header.hash, full_node_block_2.header.hash); seq_task.abort(); full_node_task.abort(); @@ -275,9 +281,14 @@ async fn test_full_node_send_tx() -> Result<(), anyhow::Error> { .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; - assert!(sq_block.transactions.contains(&tx_hash.tx_hash())); - assert!(full_node_block.transactions.contains(&tx_hash.tx_hash())); - assert_eq!(sq_block.state_root, full_node_block.state_root); + let sq_transactions = sq_block.transactions.as_hashes().unwrap(); + let full_node_transactions = full_node_block.transactions.as_hashes().unwrap(); + assert!(sq_transactions.contains(tx_hash.tx_hash())); + assert!(full_node_transactions.contains(tx_hash.tx_hash())); + assert_eq!( + sq_block.header.state_root, + full_node_block.header.state_root + ); seq_task.abort(); full_node_task.abort(); @@ -321,7 +332,7 @@ async fn test_delayed_sync_ten_blocks() -> Result<(), anyhow::Error> { let addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(); for _ in 0..10 { - seq_test_client + let _pending = seq_test_client .send_eth(addr, None, None, None, 0u128) .await .unwrap(); @@ -363,8 +374,11 @@ async fn test_delayed_sync_ten_blocks() -> Result<(), anyhow::Error> { .eth_get_block_by_number(Some(BlockNumberOrTag::Number(10))) .await; - assert_eq!(seq_block.state_root, full_node_block.state_root); - assert_eq!(seq_block.hash, full_node_block.hash); + assert_eq!( + seq_block.header.state_root, + full_node_block.header.state_root + ); + assert_eq!(seq_block.header.hash, full_node_block.header.hash); seq_task.abort(); full_node_task.abort(); @@ -461,7 +475,7 @@ async fn test_close_and_reopen_full_node() -> Result<(), anyhow::Error> { // create 10 blocks for _ in 0..10 { - seq_test_client + let _pending = seq_test_client .send_eth(addr, None, None, None, 0u128) .await .unwrap(); @@ -480,18 +494,21 @@ async fn test_close_and_reopen_full_node() -> Result<(), anyhow::Error> { .eth_get_block_by_number_with_detail(Some(BlockNumberOrTag::Latest)) .await; - assert_eq!(seq_last_block.number.unwrap().as_u64(), 10); - assert_eq!(full_node_last_block.number.unwrap().as_u64(), 10); + assert_eq!(seq_last_block.header.number.unwrap(), 10); + assert_eq!(full_node_last_block.header.number.unwrap(), 10); - assert_eq!(seq_last_block.state_root, full_node_last_block.state_root); - assert_eq!(seq_last_block.hash, full_node_last_block.hash); + assert_eq!( + seq_last_block.header.state_root, + full_node_last_block.header.state_root + ); + assert_eq!(seq_last_block.header.hash, full_node_last_block.header.hash); // close full node rollup_task.abort(); // create 100 more blocks for _ in 0..100 { - seq_test_client + let _pending = seq_test_client .send_eth(addr, None, None, None, 0u128) .await .unwrap(); @@ -545,11 +562,14 @@ async fn test_close_and_reopen_full_node() -> Result<(), anyhow::Error> { .eth_get_block_by_number_with_detail(Some(BlockNumberOrTag::Latest)) .await; - assert_eq!(seq_last_block.number.unwrap().as_u64(), 110); - assert_eq!(full_node_last_block.number.unwrap().as_u64(), 110); + assert_eq!(seq_last_block.header.number.unwrap(), 110); + assert_eq!(full_node_last_block.header.number.unwrap(), 110); - assert_eq!(seq_last_block.state_root, full_node_last_block.state_root); - assert_eq!(seq_last_block.hash, full_node_last_block.hash); + assert_eq!( + seq_last_block.header.state_root, + full_node_last_block.header.state_root + ); + assert_eq!(seq_last_block.header.hash, full_node_last_block.header.hash); seq_task.abort(); rollup_task.abort(); @@ -629,33 +649,33 @@ async fn test_get_transaction_by_hash() -> Result<(), anyhow::Error> { // currently there are two txs in the pool, the full node should be able to get them // should get with mempool_only true let tx1 = full_node_test_client - .eth_get_transaction_by_hash(pending_tx1.tx_hash(), Some(true)) + .eth_get_transaction_by_hash(*pending_tx1.tx_hash(), Some(true)) .await .unwrap(); // Should get with mempool_only false/none let tx2 = full_node_test_client - .eth_get_transaction_by_hash(pending_tx2.tx_hash(), None) + .eth_get_transaction_by_hash(*pending_tx2.tx_hash(), None) .await .unwrap(); assert!(tx1.block_hash.is_none()); assert!(tx2.block_hash.is_none()); - assert_eq!(tx1.hash, pending_tx1.tx_hash()); - assert_eq!(tx2.hash, pending_tx2.tx_hash()); + assert_eq!(tx1.hash, *pending_tx1.tx_hash()); + assert_eq!(tx2.hash, *pending_tx2.tx_hash()); // sequencer should also be able to get them // Should get just by checking the pool let tx1 = seq_test_client - .eth_get_transaction_by_hash(pending_tx1.tx_hash(), Some(true)) + .eth_get_transaction_by_hash(*pending_tx1.tx_hash(), Some(true)) .await .unwrap(); let tx2 = seq_test_client - .eth_get_transaction_by_hash(pending_tx2.tx_hash(), None) + .eth_get_transaction_by_hash(*pending_tx2.tx_hash(), None) .await .unwrap(); assert!(tx1.block_hash.is_none()); assert!(tx2.block_hash.is_none()); - assert_eq!(tx1.hash, pending_tx1.tx_hash()); - assert_eq!(tx2.hash, pending_tx2.tx_hash()); + assert_eq!(tx1.hash, *pending_tx1.tx_hash()); + assert_eq!(tx2.hash, *pending_tx2.tx_hash()); seq_test_client.send_publish_batch_request().await; @@ -666,59 +686,60 @@ async fn test_get_transaction_by_hash() -> Result<(), anyhow::Error> { let seq_block = seq_test_client .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; - assert!(seq_block.transactions.contains(&pending_tx1.tx_hash())); - assert!(seq_block.transactions.contains(&pending_tx2.tx_hash())); + let seq_block_transactions = seq_block.transactions.as_hashes().unwrap(); + assert!(seq_block_transactions.contains(pending_tx1.tx_hash())); + assert!(seq_block_transactions.contains(pending_tx2.tx_hash())); // same operations after the block is published, both sequencer and full node should be able to get them. // should not get with mempool_only true because it checks the sequencer mempool only let non_existent_tx = full_node_test_client - .eth_get_transaction_by_hash(pending_tx1.tx_hash(), Some(true)) + .eth_get_transaction_by_hash(*pending_tx1.tx_hash(), Some(true)) .await; // this should be none because it is not in the mempool anymore assert!(non_existent_tx.is_none()); let tx1 = full_node_test_client - .eth_get_transaction_by_hash(pending_tx1.tx_hash(), Some(false)) + .eth_get_transaction_by_hash(*pending_tx1.tx_hash(), Some(false)) .await .unwrap(); let tx2 = full_node_test_client - .eth_get_transaction_by_hash(pending_tx2.tx_hash(), None) + .eth_get_transaction_by_hash(*pending_tx2.tx_hash(), None) .await .unwrap(); assert!(tx1.block_hash.is_some()); assert!(tx2.block_hash.is_some()); - assert_eq!(tx1.hash, pending_tx1.tx_hash()); - assert_eq!(tx2.hash, pending_tx2.tx_hash()); + assert_eq!(tx1.hash, *pending_tx1.tx_hash()); + assert_eq!(tx2.hash, *pending_tx2.tx_hash()); // should not get with mempool_only true because it checks mempool only let none_existent_tx = seq_test_client - .eth_get_transaction_by_hash(pending_tx1.tx_hash(), Some(true)) + .eth_get_transaction_by_hash(*pending_tx1.tx_hash(), Some(true)) .await; // this should be none because it is not in the mempool anymore assert!(none_existent_tx.is_none()); // In other cases should check the block and find the tx let tx1 = seq_test_client - .eth_get_transaction_by_hash(pending_tx1.tx_hash(), Some(false)) + .eth_get_transaction_by_hash(*pending_tx1.tx_hash(), Some(false)) .await .unwrap(); let tx2 = seq_test_client - .eth_get_transaction_by_hash(pending_tx2.tx_hash(), None) + .eth_get_transaction_by_hash(*pending_tx2.tx_hash(), None) .await .unwrap(); assert!(tx1.block_hash.is_some()); assert!(tx2.block_hash.is_some()); - assert_eq!(tx1.hash, pending_tx1.tx_hash()); - assert_eq!(tx2.hash, pending_tx2.tx_hash()); + assert_eq!(tx1.hash, *pending_tx1.tx_hash()); + assert_eq!(tx2.hash, *pending_tx2.tx_hash()); // create random tx hash and make sure it returns None let random_tx_hash: TxHash = TxHash::random(); assert!(seq_test_client - .eth_get_transaction_by_hash(H256::from_slice(random_tx_hash.as_slice()), None) + .eth_get_transaction_by_hash(random_tx_hash, None) .await .is_none()); assert!(full_node_test_client - .eth_get_transaction_by_hash(H256::from_slice(random_tx_hash.as_slice()), None) + .eth_get_transaction_by_hash(random_tx_hash, None) .await .is_none()); @@ -866,7 +887,7 @@ async fn test_reopen_sequencer() -> Result<(), anyhow::Error> { let block = seq_test_client .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; - assert_eq!(block.number.unwrap().as_u64(), 0); + assert_eq!(block.header.number.unwrap(), 0); // close sequencer seq_task.abort(); @@ -914,10 +935,10 @@ async fn test_reopen_sequencer() -> Result<(), anyhow::Error> { .await; // make sure the state roots are the same - assert_eq!(seq_last_block.state_root, block.state_root); + assert_eq!(seq_last_block.header.state_root, block.header.state_root); assert_eq!( - seq_last_block.number.unwrap().as_u64(), - block.number.unwrap().as_u64() + seq_last_block.header.number.unwrap(), + block.header.number.unwrap() ); seq_test_client.send_publish_batch_request().await; @@ -929,9 +950,9 @@ async fn test_reopen_sequencer() -> Result<(), anyhow::Error> { seq_test_client .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await + .header .number - .unwrap() - .as_u64(), + .unwrap(), 2 ); @@ -972,8 +993,8 @@ async fn execute_blocks( sequencer_client.send_publish_batch_request().await; let contract_address = deploy_contract_req + .get_receipt() .await? - .unwrap() .contract_address .unwrap(); @@ -985,7 +1006,7 @@ async fn execute_blocks( .contract_transaction(contract_address, contract.set_call_data(42), None) .await; sequencer_client.send_publish_batch_request().await; - set_value_req.await.unwrap().unwrap(); + set_value_req.watch().await.unwrap(); } sequencer_client.send_publish_batch_request().await; @@ -1014,7 +1035,7 @@ async fn execute_blocks( let addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(); for _ in 0..300 { - sequencer_client + let _pending = sequencer_client .send_eth(addr, None, None, None, 0u128) .await .unwrap(); @@ -1033,11 +1054,14 @@ async fn execute_blocks( .eth_get_block_by_number_with_detail(Some(BlockNumberOrTag::Latest)) .await; - assert_eq!(seq_last_block.number.unwrap().as_u64(), 504); - assert_eq!(full_node_last_block.number.unwrap().as_u64(), 504); + assert_eq!(seq_last_block.header.number.unwrap(), 504); + assert_eq!(full_node_last_block.header.number.unwrap(), 504); - assert_eq!(seq_last_block.state_root, full_node_last_block.state_root); - assert_eq!(seq_last_block.hash, full_node_last_block.hash); + assert_eq!( + seq_last_block.header.state_root, + full_node_last_block.header.state_root + ); + assert_eq!(seq_last_block.header.hash, full_node_last_block.header.hash); Ok(()) } @@ -1608,10 +1632,11 @@ async fn test_system_transactions() -> Result<(), anyhow::Error> { .await; if block_num == 1 { - assert_eq!(block.transactions.len(), 3); + let block_transactions = block.transactions.as_transactions().unwrap(); + assert_eq!(block_transactions.len(), 3); - let init_tx = &block.transactions[0]; - let set_tx = &block.transactions[1]; + let init_tx = &block_transactions[0]; + let set_tx = &block_transactions[1]; assert_eq!(init_tx.from, system_signer_address); assert_eq!(init_tx.to.unwrap(), system_contract_address); @@ -1631,9 +1656,10 @@ async fn test_system_transactions() -> Result<(), anyhow::Error> { *hex::decode("0e27bc11").unwrap().as_slice() ); } else { - assert_eq!(block.transactions.len(), 1); + let block_transactions = block.transactions.as_transactions().unwrap(); + assert_eq!(block_transactions.len(), 1); - let tx = &block.transactions[0]; + let tx = &block_transactions[0]; assert_eq!(tx.from, system_signer_address); assert_eq!(tx.to.unwrap(), system_contract_address); @@ -1661,7 +1687,7 @@ async fn test_system_transactions() -> Result<(), anyhow::Error> { let hash_on_chain: String = full_node_test_client .contract_call( system_contract_address, - ethers::types::Bytes::from(BitcoinLightClient::get_block_hash(i).to_vec()), + BitcoinLightClient::get_block_hash(i).to_vec(), None, ) .await @@ -1758,7 +1784,7 @@ async fn test_system_tx_effect_on_block_gas_limit() -> Result<(), anyhow::Error> let addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(); for _ in 0..50 { - seq_test_client + let _pending = seq_test_client .send_eth(addr, None, None, None, 0u128) .await .unwrap(); @@ -1778,7 +1804,7 @@ async fn test_system_tx_effect_on_block_gas_limit() -> Result<(), anyhow::Error> da_service.publish_test_block().await.unwrap(); - let last_in_receipt = last_in_tx.unwrap().await.unwrap().unwrap(); + let last_in_receipt = last_in_tx.unwrap().get_receipt().await.unwrap(); wait_for_l2_block(&seq_test_client, 1, None).await; @@ -1788,18 +1814,21 @@ async fn test_system_tx_effect_on_block_gas_limit() -> Result<(), anyhow::Error> .unwrap(); let last_tx_hash = last_in_receipt.transaction_hash; - let last_tx_raw = seq_test_client + let last_tx = seq_test_client .eth_get_transaction_by_hash(last_tx_hash, Some(false)) .await - .unwrap() - .rlp(); + .unwrap(); + let signed_tx = Signed::::try_from(last_tx).unwrap(); + let envelope = TxEnvelope::Eip1559(signed_tx); + let mut last_tx_raw = BytesMut::new(); + envelope.encode(&mut last_tx_raw); assert!(last_in_receipt.block_number.is_some()); // last in tx byte array should be a subarray of txs[0] assert!(find_subarray( initial_soft_batch.clone().txs.unwrap()[0].tx.as_slice(), - &last_tx_raw + &last_tx_raw[2..] ) .is_some()); @@ -1807,20 +1836,23 @@ async fn test_system_tx_effect_on_block_gas_limit() -> Result<(), anyhow::Error> da_service.publish_test_block().await.unwrap(); - let not_in_receipt = not_in_tx.unwrap().await.unwrap().unwrap(); + let not_in_receipt = not_in_tx.unwrap().get_receipt().await.unwrap(); let not_in_hash = not_in_receipt.transaction_hash; - let not_in_raw = seq_test_client + let not_in_tx = seq_test_client .eth_get_transaction_by_hash(not_in_hash, Some(false)) .await - .unwrap() - .rlp(); + .unwrap(); + let signed_tx = Signed::::try_from(not_in_tx).unwrap(); + let envelope = TxEnvelope::Eip1559(signed_tx); + let mut not_in_raw = BytesMut::new(); + envelope.encode(&mut not_in_raw); // not in tx byte array should not be a subarray of txs[0] assert!(find_subarray( initial_soft_batch.txs.unwrap()[0].tx.as_slice(), - ¬_in_raw + ¬_in_raw[2..] ) .is_none()); @@ -1832,22 +1864,28 @@ async fn test_system_tx_effect_on_block_gas_limit() -> Result<(), anyhow::Error> .unwrap(); // should be in tx byte array of the soft batch after - assert!(find_subarray(second_soft_batch.txs.unwrap()[0].tx.as_slice(), ¬_in_raw).is_some()); + assert!(find_subarray( + second_soft_batch.txs.unwrap()[0].tx.as_slice(), + ¬_in_raw[2..] + ) + .is_some()); let block1 = seq_test_client .eth_get_block_by_number(Some(BlockNumberOrTag::Number(1))) .await; // the last in tx should be in the block - assert!(block1.transactions.iter().any(|tx| tx == &last_tx_hash)); + let block1_transactions = block1.transactions.as_hashes().unwrap(); + assert!(block1_transactions.iter().any(|tx| tx == &last_tx_hash)); // and the other tx should not be in - assert!(!block1.transactions.iter().any(|tx| tx == ¬_in_hash)); + assert!(!block1_transactions.iter().any(|tx| tx == ¬_in_hash)); let block2 = seq_test_client .eth_get_block_by_number(Some(BlockNumberOrTag::Number(2))) .await; // the other tx should be in second block - assert!(block2.transactions.iter().any(|tx| tx == ¬_in_hash)); + let block2_transactions = block2.transactions.as_hashes().unwrap(); + assert!(block2_transactions.iter().any(|tx| tx == ¬_in_hash)); seq_task.abort(); @@ -2053,20 +2091,20 @@ async fn transaction_failing_on_l1_is_removed_from_mempool() -> Result<(), anyho }) .await; - let random_wallet = LocalWallet::new(&mut thread_rng()).with_chain_id(seq_test_client.chain_id); + let random_wallet = LocalWallet::random().with_chain_id(Some(seq_test_client.chain_id)); let random_wallet_address = random_wallet.address(); - let second_block_base_fee: u64 = 768810081; + let second_block_base_fee = 768810081; - seq_test_client + let _pending = seq_test_client .send_eth( random_wallet_address, None, None, None, // gas needed for transaction + 500 (to send) but this won't be enough for L1 fees - (21000 * second_block_base_fee + 500) as u128, + 21000 * second_block_base_fee + 500, ) .await .unwrap(); @@ -2094,7 +2132,7 @@ async fn transaction_failing_on_l1_is_removed_from_mempool() -> Result<(), anyho .unwrap(); let tx_from_mempool = seq_test_client - .eth_get_transaction_by_hash(tx.tx_hash(), Some(true)) + .eth_get_transaction_by_hash(*tx.tx_hash(), Some(true)) .await; assert!(tx_from_mempool.is_some()); @@ -2107,16 +2145,16 @@ async fn transaction_failing_on_l1_is_removed_from_mempool() -> Result<(), anyho .await; assert_eq!( - block.base_fee_per_gas.unwrap(), - U256::from(second_block_base_fee) + block.header.base_fee_per_gas.unwrap(), + second_block_base_fee ); let tx_from_mempool = seq_test_client - .eth_get_transaction_by_hash(tx.tx_hash(), Some(true)) + .eth_get_transaction_by_hash(*tx.tx_hash(), Some(true)) .await; let soft_confirmation = seq_test_client - .ledger_get_soft_batch_by_number::(block.number.unwrap().as_u64()) + .ledger_get_soft_batch_by_number::(block.header.number.unwrap()) .await .unwrap(); @@ -2124,7 +2162,7 @@ async fn transaction_failing_on_l1_is_removed_from_mempool() -> Result<(), anyho assert!(tx_from_mempool.is_none()); assert_eq!(soft_confirmation.txs.unwrap().len(), 1); // TODO: if we can also remove the tx from soft confirmation, that'd be very efficient - wait_for_l2_block(&full_node_test_client, block.number.unwrap().as_u64(), None).await; + wait_for_l2_block(&full_node_test_client, block.header.number.unwrap(), None).await; let block_from_full_node = full_node_test_client .eth_get_block_by_number_with_detail(Some(BlockNumberOrTag::Latest)) @@ -2193,36 +2231,39 @@ async fn sequencer_crash_restore_mempool() -> Result<(), anyhow::Error> { let seq_test_client = init_test_rollup(seq_port).await; - let tx_hash = seq_test_client + let send_eth1 = seq_test_client .send_eth(addr, None, None, None, 0u128) .await - .unwrap() - .tx_hash(); + .unwrap(); + let tx_hash = send_eth1.tx_hash(); - let tx_hash2 = seq_test_client + let send_eth2 = seq_test_client .send_eth(addr, None, None, None, 0u128) .await - .unwrap() - .tx_hash(); + .unwrap(); + let tx_hash2 = send_eth2.tx_hash(); let tx_1 = seq_test_client - .eth_get_transaction_by_hash(tx_hash, Some(true)) + .eth_get_transaction_by_hash(*tx_hash, Some(true)) .await .unwrap(); let tx_2 = seq_test_client - .eth_get_transaction_by_hash(tx_hash2, Some(true)) + .eth_get_transaction_by_hash(*tx_hash2, Some(true)) .await .unwrap(); - assert_eq!(tx_1.hash, tx_hash); - assert_eq!(tx_2.hash, tx_hash2); + assert_eq!(tx_1.hash, *tx_hash); + assert_eq!(tx_2.hash, *tx_hash2); let txs = db_test_client.get_all_txs().await.unwrap(); assert_eq!(txs.len(), 2); - assert_eq!(txs[0].tx_hash, tx_hash.as_bytes().to_vec()); - assert_eq!(txs[1].tx_hash, tx_hash2.as_bytes().to_vec()); + assert_eq!(txs[0].tx_hash, tx_hash.to_vec()); + assert_eq!(txs[1].tx_hash, tx_hash2.to_vec()); - assert_eq!(txs[0].tx, tx_1.rlp().to_vec()); + let signed_tx = Signed::::try_from(tx_1.clone()).unwrap(); + let envelope = TxEnvelope::Eip1559(signed_tx); + let decoded = TxEnvelope::decode(&mut txs[0].tx.as_ref()).unwrap(); + assert_eq!(envelope, decoded); // crash and reopen and check if the txs are in the mempool seq_task.abort(); @@ -2263,11 +2304,11 @@ async fn sequencer_crash_restore_mempool() -> Result<(), anyhow::Error> { sleep(Duration::from_secs(2)).await; let tx_1_mempool = seq_test_client - .eth_get_transaction_by_hash(tx_hash, Some(true)) + .eth_get_transaction_by_hash(*tx_hash, Some(true)) .await .unwrap(); let tx_2_mempool = seq_test_client - .eth_get_transaction_by_hash(tx_hash2, Some(true)) + .eth_get_transaction_by_hash(*tx_hash2, Some(true)) .await .unwrap(); @@ -2284,11 +2325,11 @@ async fn sequencer_crash_restore_mempool() -> Result<(), anyhow::Error> { // should be removed from mempool assert!(seq_test_client - .eth_get_transaction_by_hash(tx_hash, Some(true)) + .eth_get_transaction_by_hash(*tx_hash, Some(true)) .await .is_none()); assert!(seq_test_client - .eth_get_transaction_by_hash(tx_hash2, Some(true)) + .eth_get_transaction_by_hash(*tx_hash2, Some(true)) .await .is_none()); @@ -2724,12 +2765,12 @@ async fn test_all_flow() { wait_for_l2_block(&test_client, 1, None).await; // send one ether to some address - test_client + let _pending = test_client .send_eth(addr, None, None, None, 1e18 as u128) .await .unwrap(); // send one ether to some address - test_client + let _pending = test_client .send_eth(addr, None, None, None, 1e18 as u128) .await .unwrap(); @@ -2738,7 +2779,7 @@ async fn test_all_flow() { wait_for_l2_block(&test_client, 3, None).await; // send one ether to some address - test_client + let _pending = test_client .send_eth(addr, None, None, None, 1e18 as u128) .await .unwrap(); @@ -2861,12 +2902,12 @@ async fn test_all_flow() { assert_eq!(balance, U256::from(3e18 as u128)); // send one ether to some address - test_client + let _pending = test_client .send_eth(addr, None, None, None, 1e18 as u128) .await .unwrap(); // send one ether to some address - test_client + let _pending = test_client .send_eth(addr, None, None, None, 1e18 as u128) .await .unwrap(); @@ -3066,20 +3107,24 @@ async fn test_gas_limit_too_high() { .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; + let block_transactions = block.transactions.as_hashes().unwrap(); // assert the block contains all txs apart from the last 5 for tx_hash in tx_hashes[0..tx_hashes.len() - 5].iter() { - assert!(block.transactions.contains(&tx_hash.tx_hash())); + assert!(block_transactions.contains(tx_hash.tx_hash())); } for tx_hash in tx_hashes[tx_hashes.len() - 5..].iter() { - assert!(!block.transactions.contains(&tx_hash.tx_hash())); + assert!(!block_transactions.contains(tx_hash.tx_hash())); } let block_from_sequencer = seq_test_client .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; - assert_eq!(block_from_sequencer.state_root, block.state_root); - assert_eq!(block_from_sequencer.hash, block.hash); + assert_eq!( + block_from_sequencer.header.state_root, + block.header.state_root + ); + assert_eq!(block_from_sequencer.header.hash, block.header.hash); seq_test_client.send_publish_batch_request().await; wait_for_l2_block(&full_node_test_client, 2, None).await; @@ -3093,8 +3138,11 @@ async fn test_gas_limit_too_high() { .await; assert!(!block.transactions.is_empty()); - assert_eq!(block_from_sequencer.state_root, block.state_root); - assert_eq!(block_from_sequencer.hash, block.hash); + assert_eq!( + block_from_sequencer.header.state_root, + block.header.state_root + ); + assert_eq!(block_from_sequencer.header.hash, block.header.hash); seq_task.abort(); full_node_task.abort(); @@ -3151,10 +3199,10 @@ async fn test_ledger_get_head_soft_batch() { .await .unwrap() .unwrap(); - assert_eq!(latest_block.number.unwrap().as_u64(), 2); + assert_eq!(latest_block.header.number.unwrap(), 2); assert_eq!( head_soft_batch.post_state_root.as_slice(), - latest_block.state_root.as_ref() + latest_block.header.state_root.as_slice() ); let head_soft_batch_height = seq_test_client @@ -3203,7 +3251,7 @@ async fn test_full_node_sync_status() { let addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(); for _ in 0..100 { - seq_test_client + let _pending = seq_test_client .send_eth(addr, None, None, None, 0u128) .await .unwrap(); diff --git a/bin/citrea/tests/evm/archival_state.rs b/bin/citrea/tests/evm/archival_state.rs index 7fa3e9b54..59f80464c 100644 --- a/bin/citrea/tests/evm/archival_state.rs +++ b/bin/citrea/tests/evm/archival_state.rs @@ -3,9 +3,7 @@ use std::time::Duration; use citrea_evm::smart_contracts::SimpleStorageContract; use citrea_stf::genesis_config::GenesisPaths; -use ethers::abi::Address; -use ethers_core::abi::Bytes; -use reth_primitives::BlockNumberOrTag; +use reth_primitives::{Address, BlockNumberOrTag, Bytes, U256}; use tokio::time::sleep; use crate::evm::init_test_rollup; @@ -65,7 +63,7 @@ async fn run_archival_fail_tests(addr: Address, seq_test_client: &TestClient) { .contains("unknown block number")); let invalid_block_storage = seq_test_client - .eth_get_storage_at(addr, 0u64.into(), Some(BlockNumberOrTag::Number(722))) + .eth_get_storage_at(addr, U256::from(0), Some(BlockNumberOrTag::Number(722))) .await .unwrap_err(); assert!(invalid_block_storage @@ -95,15 +93,15 @@ async fn run_archival_valid_tests(addr: Address, seq_test_client: &TestClient) { .eth_get_balance(addr, Some(BlockNumberOrTag::Latest)) .await .unwrap(), - 0u64.into() + U256::from(0) ); assert_eq!( seq_test_client - .eth_get_storage_at(addr, 0u64.into(), Some(BlockNumberOrTag::Latest)) + .eth_get_storage_at(addr, U256::from(0), Some(BlockNumberOrTag::Latest)) .await .unwrap(), - 0u64.into() + U256::from(0) ); assert_eq!( @@ -138,12 +136,12 @@ async fn run_archival_valid_tests(addr: Address, seq_test_client: &TestClient) { .eth_get_balance(addr, Some(BlockNumberOrTag::Latest)) .await .unwrap(), - 8u64.into() + U256::from(8) ); assert_eq!( seq_test_client.eth_get_balance(addr, None).await.unwrap(), - 8u64.into() + U256::from(8) ); assert_eq!( @@ -163,7 +161,7 @@ async fn run_archival_valid_tests(addr: Address, seq_test_client: &TestClient) { .eth_get_balance(addr, Some(BlockNumberOrTag::Number(i))) .await .unwrap(), - i.into() + U256::from(i) ); assert_eq!( @@ -182,12 +180,12 @@ async fn run_archival_valid_tests(addr: Address, seq_test_client: &TestClient) { seq_test_client .eth_get_storage_at( Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(), - 0u64.into(), + U256::from(0), Some(BlockNumberOrTag::Latest) ) .await .unwrap(), - 0u64.into() + U256::from(0) ); assert_eq!( @@ -226,9 +224,9 @@ async fn run_archival_valid_tests(addr: Address, seq_test_client: &TestClient) { wait_for_l2_block(seq_test_client, 9, None).await; let contract_address = deploy_contract_req + .get_receipt() .await .unwrap() - .unwrap() .contract_address .unwrap(); @@ -253,7 +251,7 @@ async fn run_archival_valid_tests(addr: Address, seq_test_client: &TestClient) { assert_eq!(non_existent_code, Bytes::from(vec![])); let set_arg = 923; - seq_test_client + let _pending = seq_test_client .contract_transaction(contract_address, contract.set_call_data(set_arg), None) .await; @@ -265,21 +263,21 @@ async fn run_archival_valid_tests(addr: Address, seq_test_client: &TestClient) { let storage_value = seq_test_client .eth_get_storage_at( contract_address, - storage_slot.into(), + U256::from(storage_slot), Some(BlockNumberOrTag::Latest), ) .await .unwrap(); - assert_eq!(storage_value, ethereum_types::U256::from(set_arg)); + assert_eq!(storage_value, U256::from(set_arg)); let previous_storage_value = seq_test_client .eth_get_storage_at( contract_address, - storage_slot.into(), + U256::from(storage_slot), Some(BlockNumberOrTag::Number(11)), ) .await .unwrap(); - assert_eq!(previous_storage_value, ethereum_types::U256::from(0)); + assert_eq!(previous_storage_value, U256::from(0)); } diff --git a/bin/citrea/tests/evm/gas_price.rs b/bin/citrea/tests/evm/gas_price.rs index 3cfae0912..a6d0efa9a 100644 --- a/bin/citrea/tests/evm/gas_price.rs +++ b/bin/citrea/tests/evm/gas_price.rs @@ -1,13 +1,11 @@ use std::net::SocketAddr; use std::time::Duration; +use alloy::signers::wallet::LocalWallet; +use alloy::signers::Signer; use citrea_evm::smart_contracts::SimpleStorageContract; use citrea_stf::genesis_config::GenesisPaths; -use ethers_core::rand::thread_rng; -use ethers_core::types::U256; -use ethers_core::utils::Units::Ether; -use ethers_signers::{LocalWallet, Signer}; -use reth_primitives::BlockNumberOrTag; +use reth_primitives::{BlockNumberOrTag, U256}; use crate::evm::init_test_rollup; use crate::test_client::TestClient; @@ -64,8 +62,8 @@ async fn execute( client.send_publish_batch_request().await; let contract_address = deploy_contract_req + .get_receipt() .await? - .unwrap() .contract_address .unwrap(); @@ -81,20 +79,20 @@ async fn execute( None, ) .await; - assert_eq!(initial_fee_history.oldest_block, U256::zero()); + assert_eq!(initial_fee_history.oldest_block, U256::from(0)); let mut block_index = 2; // Create 100 wallets and send them some eth let wallets_count = 100u32; let tx_count_from_single_address = 15u32; - let one_eth = u128::pow(10, Ether.as_num()); - let mut rng = thread_rng(); + let one_eth = u128::pow(10, 18); let mut wallets = Vec::with_capacity(wallets_count as usize); for i in 0..wallets_count { - let wallet = LocalWallet::new(&mut rng).with_chain_id(client.chain_id); + let mut wallet = LocalWallet::random(); + wallet.set_chain_id(Some(client.chain_id)); let address = wallet.address(); - client + let _pending = client .send_eth(address, None, None, None, one_eth) .await .unwrap(); @@ -115,7 +113,7 @@ async fn execute( let address = wallet.address(); let wallet_client = TestClient::new(client.chain_id, wallet, address, port).await; for i in 0..tx_count_from_single_address { - wallet_client + let _pending = wallet_client .contract_transaction(contract_address, contract.set_call_data(i), None) .await; } @@ -126,7 +124,7 @@ async fn execute( let block = client.eth_get_block_by_number(None).await; assert!( - block.gas_used.as_u64() <= reth_primitives::constants::ETHEREUM_BLOCK_GAS_LIMIT, + block.header.gas_used as u64 <= reth_primitives::constants::ETHEREUM_BLOCK_GAS_LIMIT, "Block has gas limit" ); assert!( @@ -159,7 +157,7 @@ async fn execute( None, ) .await; - assert_eq!(latest_fee_history.oldest_block, U256::zero()); + assert_eq!(latest_fee_history.oldest_block, U256::from(0)); // there are 10 blocks in between assert_eq!( diff --git a/bin/citrea/tests/evm/mod.rs b/bin/citrea/tests/evm/mod.rs index c19300bfb..8d29ad821 100644 --- a/bin/citrea/tests/evm/mod.rs +++ b/bin/citrea/tests/evm/mod.rs @@ -1,15 +1,14 @@ use std::net::SocketAddr; use std::str::FromStr; +use alloy::signers::wallet::LocalWallet; +use alloy::signers::Signer; // use citrea::initialize_logging; use citrea_evm::smart_contracts::{ HiveContract, LogsContract, SimpleStorageContract, TestContract, }; use citrea_stf::genesis_config::GenesisPaths; -use ethers_core::abi::Address; -use ethers_core::types::{BlockId, Bytes, U256}; -use ethers_signers::{LocalWallet, Signer}; -use reth_primitives::BlockNumberOrTag; +use reth_primitives::{Address, BlockId, BlockNumberOrTag, Bytes, U256}; use sov_rollup_interface::CITREA_VERSION; // use sov_demo_rollup::initialize_logging; @@ -211,10 +210,10 @@ async fn test_genesis_contract_call() -> Result<(), Box> assert_eq!(res, expected_res); let storage_value = seq_test_client - .eth_get_storage_at(contract_address, U256::zero(), None) + .eth_get_storage_at(contract_address, U256::from(0), None) .await .unwrap(); - assert_eq!(storage_value, 4660.into()); + assert_eq!(storage_value, U256::from(4660)); let storage_value = seq_test_client .eth_get_storage_at( @@ -225,7 +224,7 @@ async fn test_genesis_contract_call() -> Result<(), Box> ) .await .unwrap(); - assert_eq!(storage_value, 1.into()); + assert_eq!(storage_value, U256::from(1)); seq_task.abort(); Ok(()) } @@ -239,15 +238,15 @@ async fn test_getlogs(client: &Box) -> Result<(), Box) -> Result<(), Box) -> Result<(), Box) -> Result<(), Box U256::zero()); + assert!(balance > U256::from(0)); let (contract_address, contract, runtime_code) = { let contract = SimpleStorageContract::default(); @@ -359,8 +358,8 @@ async fn execute(client: &Box) -> Result<(), Box) -> Result<(), Box) -> Result<(), Box) -> Result<(), Box()); // Assert storage slot is set let storage_slot = 0x0; let storage_value = client - .eth_get_storage_at(contract_address, storage_slot.into(), None) + .eth_get_storage_at(contract_address, U256::from(storage_slot), None) .await .unwrap(); - assert_eq!(storage_value, ethereum_types::U256::from(set_arg)); + assert_eq!(storage_value, U256::from(set_arg)); // Check that the second block has published // None should return the latest block // It should have a single transaction, setting the value let latest_block = client.eth_get_block_by_number_with_detail(None).await; - assert_eq!(latest_block.number.unwrap().as_u64(), 2); - assert_eq!(latest_block.transactions.len(), 1); - assert_eq!(latest_block.transactions[0].hash, tx_hash); + let block_transactions: Vec<_> = latest_block.transactions.hashes().copied().collect(); + assert_eq!(latest_block.header.number.unwrap(), 2); + assert_eq!(block_transactions.len(), 1); + assert_eq!(block_transactions[0], tx_hash); // This should just pass without error let _: Bytes = client @@ -476,7 +467,7 @@ async fn execute(client: &Box) -> Result<(), Box) -> Result<(), Box) -> Result<(), Box) -> Result<(), Box()); } let first_block = client @@ -533,8 +525,8 @@ async fn execute(client: &Box) -> Result<(), Box Box { .await; assert_eq!(latest_block, earliest_block); - assert_eq!(latest_block.number.unwrap().as_u64(), 0); + assert_eq!(latest_block.header.number.unwrap(), 0); test_client } @@ -571,7 +563,7 @@ pub async fn make_test_client(rpc_address: SocketAddr) -> Box { let key = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" .parse::() .unwrap() - .with_chain_id(chain_id); + .with_chain_id(Some(chain_id)); let from_addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(); diff --git a/bin/citrea/tests/evm/tracing.rs b/bin/citrea/tests/evm/tracing.rs index 0c39ccdcc..e19af3137 100644 --- a/bin/citrea/tests/evm/tracing.rs +++ b/bin/citrea/tests/evm/tracing.rs @@ -3,8 +3,7 @@ use std::str::FromStr; // use citrea::initialize_logging; use citrea_evm::smart_contracts::{CallerContract, SimpleStorageContract}; use citrea_stf::genesis_config::GenesisPaths; -use ethers::abi::Address; -use reth_primitives::BlockNumberOrTag; +use reth_primitives::{Address, BlockNumberOrTag}; use reth_rpc_types::trace::geth::GethTrace::{self, CallTracer, FourByteTracer}; use reth_rpc_types::trace::geth::{ CallConfig, CallFrame, FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerType, @@ -64,14 +63,14 @@ async fn tracing_tests() -> Result<(), Box> { test_client.send_publish_batch_request().await; let ss_contract_address = deploy_ss_contract_req + .get_receipt() .await? - .unwrap() .contract_address .unwrap(); let caller_contract_address = deploy_caller_contract_req + .get_receipt() .await? - .unwrap() .contract_address .unwrap(); @@ -97,7 +96,11 @@ async fn tracing_tests() -> Result<(), Box> { ) .await; test_client.send_publish_batch_request().await; - call_set_value_req.await.unwrap().unwrap().transaction_hash + call_set_value_req + .get_receipt() + .await + .unwrap() + .transaction_hash }; let json_res = test_client @@ -157,8 +160,12 @@ async fn tracing_tests() -> Result<(), Box> { test_client.send_publish_batch_request().await; - let call_tx_hash = call_get_value_req.await.unwrap().unwrap().transaction_hash; - let send_eth_tx_hash = send_eth_req.await.unwrap().unwrap().transaction_hash; + let call_tx_hash = call_get_value_req + .get_receipt() + .await + .unwrap() + .transaction_hash; + let send_eth_tx_hash = send_eth_req.get_receipt().await.unwrap().transaction_hash; // get the trace of send_eth_tx_hash and expect call_tx_hash trace to be in the cache let send_eth_trace = test_client @@ -225,6 +232,7 @@ async fn tracing_tests() -> Result<(), Box> { let block_hash = test_client .eth_get_block_by_number(Some(BlockNumberOrTag::Number(3))) .await + .header .hash .unwrap(); diff --git a/bin/citrea/tests/mempool/mod.rs b/bin/citrea/tests/mempool/mod.rs index 9cd1e3f58..2b69fe9b2 100644 --- a/bin/citrea/tests/mempool/mod.rs +++ b/bin/citrea/tests/mempool/mod.rs @@ -1,10 +1,10 @@ use std::path::PathBuf; use std::str::FromStr; +use alloy::signers::wallet::LocalWallet; +use alloy::signers::Signer; use citrea_stf::genesis_config::GenesisPaths; -use ethers::abi::Address; -use ethers_signers::{LocalWallet, Signer}; -use reth_primitives::BlockNumberOrTag; +use reth_primitives::{Address, BlockNumberOrTag}; use tokio::task::JoinHandle; use crate::evm::make_test_client; @@ -55,12 +55,12 @@ async fn test_same_nonce_tx_should_panic() { let addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(); // send tx with nonce 0 - test_client + let _pending = test_client .send_eth(addr, None, None, Some(0), 0u128) .await .unwrap(); // send tx with nonce 1 - test_client + let _pending = test_client .send_eth(addr, None, None, Some(1), 0u128) .await .unwrap(); @@ -85,12 +85,12 @@ async fn test_nonce_too_low() { let addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(); // send tx with nonce 0 - test_client + let _pending = test_client .send_eth(addr, None, None, Some(0), 0u128) .await .unwrap(); // send tx with nonce 1 - test_client + let _pending = test_client .send_eth(addr, None, None, Some(1), 0u128) .await .unwrap(); @@ -136,7 +136,8 @@ async fn test_nonce_too_high() { .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; // assert the block does not contain the tx with nonce too high - assert!(!block.transactions.contains(&tx_hash2.tx_hash())); + let block_transactions = block.transactions.as_hashes().unwrap(); + assert!(!block_transactions.contains(tx_hash2.tx_hash())); seq_task.abort(); } @@ -153,7 +154,7 @@ async fn test_order_by_fee() { let key = "0xdcf2cbdd171a21c480aa7f53d77f31bb102282b3ff099c78e3118b37348c72f7" .parse::() .unwrap() - .with_chain_id(chain_id); + .with_chain_id(Some(chain_id)); let poor_addr = key.address(); let poor_test_client = TestClient::new(chain_id, key, poor_addr, test_client.rpc_addr).await; @@ -172,13 +173,14 @@ async fn test_order_by_fee() { .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; - assert!(block.transactions.contains(&sent_tx_hash1.tx_hash())); + let block_transactions = block.transactions.as_hashes().unwrap(); + assert!(block_transactions.contains(sent_tx_hash1.tx_hash())); // now make some txs from different accounts with different fees and see which tx lands first in block let tx_hash_poor = poor_test_client .send_eth( test_client.from_addr, - Some(100u64), + Some(100), Some(MAX_FEE_PER_GAS), None, 2_000_000_000_000_000_000u128, @@ -189,7 +191,7 @@ async fn test_order_by_fee() { let tx_hash_rich = test_client .send_eth( poor_test_client.from_addr, - Some(1000u64), + Some(1000), Some(MAX_FEE_PER_GAS), None, 2_000_000_000_000_000_000u128, @@ -205,15 +207,16 @@ async fn test_order_by_fee() { .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; - assert!(block.transactions[0] == tx_hash_rich.tx_hash()); - assert!(block.transactions[1] == tx_hash_poor.tx_hash()); + let block_transactions = block.transactions.as_hashes().unwrap(); + assert!(block_transactions[0] == *tx_hash_rich.tx_hash()); + assert!(block_transactions[1] == *tx_hash_poor.tx_hash()); // now change the order the txs are sent, the assertions should be the same let tx_hash_rich = test_client .send_eth( poor_test_client.from_addr, - Some(1000u64), - Some(1000000000001u64), + Some(1000), + Some(1000000000001), None, 2_000_000_000_000_000_000u128, ) @@ -224,8 +227,8 @@ async fn test_order_by_fee() { let tx_hash_poor = poor_test_client .send_eth( test_client.from_addr, - Some(100u64), - Some(100000000001u64), + Some(100), + Some(100000000001), None, 2_000_000_000_000_000_000u128, ) @@ -241,8 +244,9 @@ async fn test_order_by_fee() { .await; // first index tx should be rich tx - assert!(block.transactions[0] == tx_hash_rich.tx_hash()); - assert!(block.transactions[1] == tx_hash_poor.tx_hash()); + let block_transactions = block.transactions.as_hashes().unwrap(); + assert!(block_transactions[0] == *tx_hash_rich.tx_hash()); + assert!(block_transactions[1] == *tx_hash_poor.tx_hash()); seq_task.abort(); } @@ -260,10 +264,10 @@ async fn test_tx_with_low_base_fee() { let key = "0xdcf2cbdd171a21c480aa7f53d77f31bb102282b3ff099c78e3118b37348c72f7" .parse::() .unwrap() - .with_chain_id(chain_id); + .with_chain_id(Some(chain_id)); let poor_addr = key.address(); - test_client + let _pending = test_client .send_eth(poor_addr, None, None, None, 5_000_000_000_000_000_000u128) .await .unwrap(); @@ -273,9 +277,9 @@ async fn test_tx_with_low_base_fee() { let tx_hash_low_fee = test_client .send_eth( poor_addr, - Some(1u64), + Some(1), // normally base fee is 875 000 000 - Some(1_000_001u64), + Some(1_000_001), None, 5_000_000_000_000_000_000u128, ) @@ -288,7 +292,8 @@ async fn test_tx_with_low_base_fee() { .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; - assert!(!block.transactions.contains(&tx_hash_low_fee.tx_hash())); + let block_transactions: Vec<_> = block.transactions.hashes().copied().collect(); + assert!(!block_transactions.contains(tx_hash_low_fee.tx_hash())); // TODO: also check if tx is in the mempool after https://github.com/chainwayxyz/citrea/issues/83 @@ -307,13 +312,13 @@ async fn test_same_nonce_tx_replacement() { let addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap(); let tx_hash = test_client - .send_eth(addr, Some(100u64), Some(MAX_FEE_PER_GAS), Some(0), 0u128) + .send_eth(addr, Some(100), Some(MAX_FEE_PER_GAS), Some(0), 0u128) .await .unwrap(); // Replacement error with lower fee let err = test_client - .send_eth(addr, Some(90u64), Some(MAX_FEE_PER_GAS), Some(0), 0u128) + .send_eth(addr, Some(90), Some(MAX_FEE_PER_GAS), Some(0), 0u128) .await .unwrap_err(); @@ -323,7 +328,7 @@ async fn test_same_nonce_tx_replacement() { // Replacement error with equal fee let err = test_client - .send_eth(addr, Some(100u64), Some(MAX_FEE_PER_GAS), Some(0), 0u128) + .send_eth(addr, Some(100), Some(MAX_FEE_PER_GAS), Some(0), 0u128) .await .unwrap_err(); @@ -331,13 +336,7 @@ async fn test_same_nonce_tx_replacement() { // Replacement error with enough base fee but low priority fee let err = test_client - .send_eth( - addr, - Some(10u64), - Some(MAX_FEE_PER_GAS + 100u64), - Some(0), - 0u128, - ) + .send_eth(addr, Some(10), Some(MAX_FEE_PER_GAS + 100), Some(0), 0u128) .await .unwrap_err(); @@ -349,8 +348,8 @@ async fn test_same_nonce_tx_replacement() { let err = test_client .send_eth( addr, - Some(10u64), - Some(MAX_FEE_PER_GAS + 100000000000u64), + Some(10), + Some(MAX_FEE_PER_GAS + 100000000000), Some(0), 0u128, ) @@ -365,7 +364,7 @@ async fn test_same_nonce_tx_replacement() { let err = test_client .send_eth( addr, - Some(105u64), + Some(105), Some(MAX_FEE_PER_GAS + 1000000000), Some(0), 0u128, @@ -381,7 +380,7 @@ async fn test_same_nonce_tx_replacement() { let err = test_client .send_eth( addr, - Some(110u64), // 10% increase + Some(110), // 10% increase Some(MAX_FEE_PER_GAS + 1000000000), Some(0), 0u128, @@ -396,7 +395,7 @@ async fn test_same_nonce_tx_replacement() { let err = test_client .send_eth( addr, - Some(111u64), // 11% increase + Some(111), // 11% increase Some(MAX_FEE_PER_GAS + 100000000), // Not increasing more than 10 percent - should fail. Some(0), 0u128, @@ -412,7 +411,7 @@ async fn test_same_nonce_tx_replacement() { let tx_hash_11_bump = test_client .send_eth( addr, - Some(111u64), // 11% increase + Some(111), // 11% increase Some(MAX_FEE_PER_GAS + 1000000000), // More than 10 percent - should succeed. Some(0), 0u128, @@ -426,7 +425,7 @@ async fn test_same_nonce_tx_replacement() { let tx_hash_25_bump = test_client .send_eth( addr, - Some(125u64), + Some(125), Some(MAX_FEE_PER_GAS + 100000000000), Some(0), 0u128, @@ -439,7 +438,7 @@ async fn test_same_nonce_tx_replacement() { let tx_hash_ultra_bump = test_client .send_eth( addr, - Some(1000u64), + Some(1000), Some(MAX_FEE_PER_GAS + 10000000000000), Some(0), 0u128, @@ -456,10 +455,11 @@ async fn test_same_nonce_tx_replacement() { .eth_get_block_by_number(Some(BlockNumberOrTag::Latest)) .await; - assert!(!block.transactions.contains(&tx_hash.tx_hash())); - assert!(!block.transactions.contains(&tx_hash_11_bump.tx_hash())); - assert!(!block.transactions.contains(&tx_hash_25_bump.tx_hash())); - assert!(block.transactions.contains(&tx_hash_ultra_bump.tx_hash())); + let block_transactions = block.transactions.as_hashes().unwrap(); + assert!(!block_transactions.contains(tx_hash.tx_hash())); + assert!(!block_transactions.contains(tx_hash_11_bump.tx_hash())); + assert!(!block_transactions.contains(tx_hash_25_bump.tx_hash())); + assert!(block_transactions.contains(tx_hash_ultra_bump.tx_hash())); seq_task.abort(); } diff --git a/bin/citrea/tests/test_client/mod.rs b/bin/citrea/tests/test_client/mod.rs index b3dc646d4..ae0fd0883 100644 --- a/bin/citrea/tests/test_client/mod.rs +++ b/bin/citrea/tests/test_client/mod.rs @@ -2,20 +2,18 @@ use std::str::FromStr; use std::sync::atomic::{AtomicU64, Ordering}; use std::time::Duration; +use alloy::providers::network::{Ethereum, EthereumSigner}; +use alloy::providers::{PendingTransactionBuilder, Provider as AlloyProvider, ProviderBuilder}; +use alloy::rpc::types::eth::{Block, Transaction, TransactionReceipt, TransactionRequest}; +use alloy::signers::wallet::LocalWallet; +use alloy::transports::http::{Http, HyperClient}; use citrea_evm::LogResponse; use ethereum_rpc::CitreaStatus; -use ethereum_types::H160; -use ethers_core::abi::Address; -use ethers_core::k256::ecdsa::SigningKey; -use ethers_core::types::transaction::eip2718::TypedTransaction; -use ethers_core::types::{Block, BlockId, Bytes, Eip1559TransactionRequest, Transaction, TxHash}; -use ethers_middleware::SignerMiddleware; -use ethers_providers::{Http, Middleware, PendingTransaction, Provider}; -use ethers_signers::Wallet; use jsonrpsee::core::client::ClientT; use jsonrpsee::http_client::{HttpClient, HttpClientBuilder}; use jsonrpsee::rpc_params; -use reth_primitives::BlockNumberOrTag; +use reth_primitives::{Address, BlockId, BlockNumberOrTag, Bytes, TxHash, TxKind, B256, U256, U64}; +// use reth_rpc_types::TransactionReceipt; use reth_rpc_types::trace::geth::{GethDebugTracingOptions, GethTrace}; use sequencer_client::GetSoftBatchResponse; use sov_rollup_interface::rpc::{ @@ -23,12 +21,13 @@ use sov_rollup_interface::rpc::{ VerifiedProofResponse, }; -pub const MAX_FEE_PER_GAS: u64 = 1000000001; +pub const MAX_FEE_PER_GAS: u128 = 1000000001; pub struct TestClient { pub(crate) chain_id: u64, pub(crate) from_addr: Address, - client: SignerMiddleware, Wallet>, + //client: SignerMiddleware, LocalWallet>, + client: Box>>, http_client: HttpClient, current_nonce: AtomicU64, pub(crate) rpc_addr: std::net::SocketAddr, @@ -37,16 +36,18 @@ pub struct TestClient { impl TestClient { pub(crate) async fn new( chain_id: u64, - key: Wallet, + key: LocalWallet, from_addr: Address, rpc_addr: std::net::SocketAddr, ) -> Self { let host = format!("http://localhost:{}", rpc_addr.port()); - let provider = Provider::try_from(&host).unwrap(); - let client = SignerMiddleware::new_with_provider_chain(provider, key) - .await - .unwrap(); + let provider = ProviderBuilder::new() + // .with_recommended_fillers() + .with_chain_id(chain_id) + .signer(EthereumSigner::from(key)) + .on_hyper_http(host.parse().unwrap()); + let client: Box>> = Box::new(provider); let http_client = HttpClientBuilder::default() .request_timeout(Duration::from_secs(120)) @@ -94,156 +95,144 @@ impl TestClient { pub(crate) async fn deploy_contract( &self, - byte_code: Bytes, + byte_code: Vec, nonce: Option, - ) -> Result, Box> { + ) -> Result< + PendingTransactionBuilder<'_, Http, Ethereum>, + Box, + > { let nonce = match nonce { Some(nonce) => nonce, None => self.current_nonce.fetch_add(1, Ordering::Relaxed), }; - let mut req = Eip1559TransactionRequest::new() - .from(self.from_addr) - .chain_id(self.chain_id) - .data(byte_code); + let mut req = TransactionRequest::default() + .from(self.from_addr) + .input(byte_code.into()); + req.to = Some(TxKind::Create); let gas = self - .eth_estimate_gas(TypedTransaction::Eip1559(req.clone()), None) - .await; + .client + .estimate_gas(&req, BlockNumberOrTag::Latest.into()) + .await + .unwrap(); - req = req - .gas(gas) + let req = req + .gas_limit(gas) .nonce(nonce) - .max_priority_fee_per_gas(10u64) + .max_priority_fee_per_gas(10) .max_fee_per_gas(MAX_FEE_PER_GAS); - let typed_transaction = TypedTransaction::Eip1559(req); - - let receipt_req = self - .client - .send_transaction(typed_transaction, None) - .await?; + let receipt_req = self.client.send_transaction(req).await?; Ok(receipt_req) } pub(crate) async fn deploy_contract_call( &self, - byte_code: Bytes, + byte_code: Vec, nonce: Option, ) -> Result> { let nonce = match nonce { Some(nonce) => nonce, None => self.current_nonce.load(Ordering::Relaxed), }; - let mut req = Eip1559TransactionRequest::new() - .from(self.from_addr) - .chain_id(self.chain_id) - .nonce(nonce) - .data(byte_code); + let req = TransactionRequest::default() + .from(self.from_addr) + .input(byte_code.into()) + .nonce(nonce); let gas = self - .eth_estimate_gas(TypedTransaction::Eip1559(req.clone()), None) - .await; + .client + .estimate_gas(&req, BlockNumberOrTag::Latest.into()) + .await + .unwrap(); - req = req - .gas(gas) - .max_priority_fee_per_gas(10u64) + let req = req + .gas_limit(gas) + .max_priority_fee_per_gas(10) .max_fee_per_gas(MAX_FEE_PER_GAS); - let typed_transaction = TypedTransaction::Eip1559(req); - - let receipt_req = self.eth_call(typed_transaction, None).await?; + let receipt_req = self.client.call(&req).await?; Ok(receipt_req) } pub(crate) async fn contract_transaction( &self, - contract_address: H160, - data: Bytes, + contract_address: Address, + data: Vec, nonce: Option, - ) -> PendingTransaction<'_, Http> { + ) -> PendingTransactionBuilder<'_, Http, Ethereum> { let nonce = match nonce { Some(nonce) => nonce, None => self.current_nonce.fetch_add(1, Ordering::Relaxed), }; - let mut req = Eip1559TransactionRequest::new() + let req = TransactionRequest::default() .from(self.from_addr) .to(contract_address) - .chain_id(self.chain_id) - .data(data); + .input(data.into()); let gas = self - .eth_estimate_gas(TypedTransaction::Eip1559(req.clone()), None) - .await; + .client + .estimate_gas(&req, BlockNumberOrTag::Latest.into()) + .await + .unwrap(); - req = req - .gas(gas) + let req = req + .gas_limit(gas) .nonce(nonce) - .max_priority_fee_per_gas(10u64) + .max_priority_fee_per_gas(10) .max_fee_per_gas(MAX_FEE_PER_GAS); - let typed_transaction = TypedTransaction::Eip1559(req); - - self.client - .send_transaction(typed_transaction, None) - .await - .unwrap() + self.client.send_transaction(req).await.unwrap() } #[allow(dead_code)] pub(crate) async fn contract_transaction_with_custom_fee( &self, - contract_address: H160, - data: Bytes, + contract_address: Address, + data: Vec, max_priority_fee_per_gas: u64, max_fee_per_gas: u64, value: Option, nonce: Option, - ) -> PendingTransaction<'_, Http> { + ) -> PendingTransactionBuilder<'_, Http, Ethereum> { let nonce = match nonce { Some(nonce) => nonce, None => self.current_nonce.fetch_add(1, Ordering::Relaxed), }; - let mut req = Eip1559TransactionRequest::new() + let req = TransactionRequest::default() .from(self.from_addr) .to(contract_address) - .chain_id(self.chain_id) - .data(data) - .value(value.unwrap_or(0u64)); + .input(data.into()) + .value(value.map(U256::from).unwrap_or_default()); let gas = self - .eth_estimate_gas(TypedTransaction::Eip1559(req.clone()), None) - .await; + .client + .estimate_gas(&req, BlockNumberOrTag::Latest.into()) + .await + .unwrap(); - req = req - .gas(gas) + let req = req + .gas_limit(gas) .nonce(nonce) - .max_priority_fee_per_gas(max_priority_fee_per_gas) - .max_fee_per_gas(max_fee_per_gas); - - let typed_transaction = TypedTransaction::Eip1559(req); + .max_priority_fee_per_gas(max_priority_fee_per_gas.into()) + .max_fee_per_gas(max_fee_per_gas.into()); - self.client - .send_transaction(typed_transaction, None) - .await - .unwrap() + self.client.send_transaction(req).await.unwrap() } pub(crate) async fn contract_call( &self, - contract_address: H160, - data: Bytes, + contract_address: Address, + data: Vec, _nonce: Option, ) -> Result> { - let req = Eip1559TransactionRequest::new() + let req = TransactionRequest::default() .from(self.from_addr) .to(contract_address) - .chain_id(self.chain_id) - .data(data); - - let typed_transaction = TypedTransaction::Eip1559(req); + .input(data.into()); - let receipt_req = self.client.call(&typed_transaction, None).await?; + let receipt_req = self.client.call(&req).await?; T::from_str(&receipt_req.to_string()).map_err(|_| "Failed to parse bytes".into()) } @@ -251,36 +240,35 @@ impl TestClient { pub(crate) async fn send_eth( &self, to_addr: Address, - max_priority_fee_per_gas: Option, - max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + max_fee_per_gas: Option, nonce: Option, value: u128, - ) -> Result, anyhow::Error> { + ) -> Result, Ethereum>, anyhow::Error> { let nonce = match nonce { Some(nonce) => nonce, None => self.current_nonce.fetch_add(1, Ordering::Relaxed), }; - let mut req = Eip1559TransactionRequest::new() + let req = TransactionRequest::default() .from(self.from_addr) .to(to_addr) - .chain_id(self.chain_id) - .value(value); + .value(U256::from(value)); let gas = self - .eth_estimate_gas(TypedTransaction::Eip1559(req.clone()), None) - .await; + .client + .estimate_gas(&req, BlockNumberOrTag::Latest.into()) + .await + .unwrap(); - req = req - .gas(gas) + let req = req + .gas_limit(gas) .nonce(nonce) - .max_priority_fee_per_gas(max_priority_fee_per_gas.unwrap_or(10u64)) + .max_priority_fee_per_gas(max_priority_fee_per_gas.unwrap_or(10)) .max_fee_per_gas(max_fee_per_gas.unwrap_or(MAX_FEE_PER_GAS)); - let typed_transaction = TypedTransaction::Eip1559(req); - self.client - .send_transaction(typed_transaction, None) + .send_transaction(req) .await .map_err(|e| e.into()) } @@ -288,29 +276,24 @@ impl TestClient { pub(crate) async fn send_eth_with_gas( &self, to_addr: Address, - max_priority_fee_per_gas: Option, - max_fee_per_gas: Option, - gas: u64, + max_priority_fee_per_gas: Option, + max_fee_per_gas: Option, + gas: u128, value: u128, - ) -> Result, anyhow::Error> { + ) -> Result, Ethereum>, anyhow::Error> { let nonce = self.current_nonce.fetch_add(1, Ordering::Relaxed); - let mut req = Eip1559TransactionRequest::new() + let req = TransactionRequest::default() .from(self.from_addr) .to(to_addr) - .chain_id(self.chain_id) - .value(value); - - req = req - .gas(gas) + .value(U256::from(value)) + .gas_limit(gas) .nonce(nonce) - .max_priority_fee_per_gas(max_priority_fee_per_gas.unwrap_or(10u64)) + .max_priority_fee_per_gas(max_priority_fee_per_gas.unwrap_or(10)) .max_fee_per_gas(max_fee_per_gas.unwrap_or(MAX_FEE_PER_GAS)); - let typed_transaction = TypedTransaction::Eip1559(req); - self.client - .send_transaction(typed_transaction, None) + .send_transaction(req) .await .map_err(|e| e.into()) } @@ -336,33 +319,15 @@ impl TestClient { .unwrap() } - #[allow(dead_code)] - pub(crate) async fn eth_send_transaction( - &self, - tx: TypedTransaction, - ) -> PendingTransaction<'_, Http> { - self.client - .provider() - .send_transaction(tx, None) - .await - .unwrap() - } - pub(crate) async fn eth_chain_id(&self) -> u64 { - let chain_id: ethereum_types::U64 = self - .http_client - .request("eth_chainId", rpc_params![]) - .await - .unwrap(); - - chain_id.as_u64() + self.client.get_chain_id().await.unwrap() } pub(crate) async fn eth_get_balance( &self, address: Address, block_number: Option, - ) -> Result> { + ) -> Result> { let block_number = match block_number { Some(block_number) => block_number, None => BlockNumberOrTag::Latest, @@ -376,9 +341,9 @@ impl TestClient { pub(crate) async fn eth_get_storage_at( &self, address: Address, - index: ethereum_types::U256, + index: U256, block_number: Option, - ) -> Result> { + ) -> Result> { self.http_client .request( "eth_getStorageAt", @@ -406,13 +371,13 @@ impl TestClient { ) -> Result> { match self .http_client - .request::( + .request::( "eth_getTransactionCount", rpc_params![address, block_number], ) .await { - Ok(count) => Ok(count.as_u64()), + Ok(count) => Ok(count.saturating_to()), Err(e) => Err(e.into()), } } @@ -421,7 +386,7 @@ impl TestClient { // be different from the current gas price (for the next block being committed). // So because of that users can't fully rely on the returned value. // A part of https://github.com/chainwayxyz/citrea/issues/150 - pub(crate) async fn eth_gas_price(&self) -> ethereum_types::U256 { + pub(crate) async fn eth_gas_price(&self) -> U256 { self.http_client .request("eth_gasPrice", rpc_params![]) .await @@ -444,7 +409,7 @@ impl TestClient { pub(crate) async fn eth_get_block_by_number( &self, block_number: Option, - ) -> Block { + ) -> Block { self.http_client .request("eth_getBlockByNumber", rpc_params![block_number, false]) .await @@ -454,7 +419,7 @@ impl TestClient { pub(crate) async fn eth_get_block_by_number_with_detail( &self, block_number: Option, - ) -> Block { + ) -> Block { self.http_client .request("eth_getBlockByNumber", rpc_params![block_number, true]) .await @@ -479,7 +444,7 @@ impl TestClient { pub(crate) async fn eth_get_block_receipts( &self, block_number_or_hash: BlockId, - ) -> Vec { + ) -> Vec { self.http_client .request("eth_getBlockReceipts", rpc_params![block_number_or_hash]) .await @@ -489,7 +454,7 @@ impl TestClient { pub(crate) async fn eth_get_transaction_receipt( &self, tx_hash: TxHash, - ) -> Option { + ) -> Option { self.http_client .request("eth_getTransactionReceipt", rpc_params![tx_hash]) .await @@ -498,8 +463,8 @@ impl TestClient { pub(crate) async fn eth_get_tx_by_block_hash_and_index( &self, - block_hash: ethereum_types::H256, - index: ethereum_types::U256, + block_hash: B256, + index: U256, ) -> Transaction { self.http_client .request( @@ -513,7 +478,7 @@ impl TestClient { pub(crate) async fn eth_get_tx_by_block_number_and_index( &self, block_number: BlockNumberOrTag, - index: ethereum_types::U256, + index: U256, ) -> Transaction { self.http_client .request( @@ -524,32 +489,6 @@ impl TestClient { .unwrap() } - pub(crate) async fn eth_call( - &self, - tx: TypedTransaction, - block_number: Option, - ) -> Result> { - self.http_client - .request("eth_call", rpc_params![tx, block_number]) - .await - .map_err(|e| e.into()) - } - - #[allow(dead_code)] - pub(crate) async fn eth_estimate_gas( - &self, - tx: TypedTransaction, - block_number: Option, - ) -> u64 { - let gas: ethereum_types::U64 = self - .http_client - .request("eth_estimateGas", rpc_params![tx, block_number]) - .await - .unwrap(); - - gas.as_u64() - } - /// params is a tuple of (fromBlock, toBlock, address, topics, blockHash) /// any of these params are optional pub(crate) async fn eth_get_logs

(&self, params: P) -> Vec @@ -693,7 +632,7 @@ impl TestClient { pub(crate) async fn debug_trace_block_by_hash( &self, - block_hash: ethereum_types::H256, + block_hash: B256, opts: Option, ) -> Vec { self.http_client @@ -703,13 +642,13 @@ impl TestClient { } pub(crate) async fn eth_block_number(&self) -> u64 { - let block_number: ethereum_types::U256 = self + let block_number: U256 = self .http_client .request("eth_blockNumber", rpc_params![]) .await .unwrap(); - block_number.as_u64() + block_number.saturating_to() } pub(crate) async fn citrea_sync_status(&self) -> CitreaStatus { @@ -725,8 +664,8 @@ impl TestClient { // ethers version of FeeHistory doesn't accept None reward pub struct FeeHistory { #[allow(dead_code)] - pub base_fee_per_gas: Vec, + pub base_fee_per_gas: Vec, pub gas_used_ratio: Vec, - pub oldest_block: ethers::types::U256, - pub reward: Option>>, + pub oldest_block: U256, + pub reward: Option>>, } diff --git a/bin/citrea/tests/test_helpers/mod.rs b/bin/citrea/tests/test_helpers/mod.rs index bf7451d94..14b477317 100644 --- a/bin/citrea/tests/test_helpers/mod.rs +++ b/bin/citrea/tests/test_helpers/mod.rs @@ -200,13 +200,16 @@ pub async fn wait_for_l2_block(sequencer_client: &TestClient, num: u64, timeout: let latest_block = sequencer_client .eth_get_block_by_number_with_detail(Some(BlockNumberOrTag::Latest)) .await; - if latest_block.number >= Some(num.into()) { + if latest_block.header.number >= Some(num) { break; } let now = SystemTime::now(); if start + timeout <= now { - panic!("Timeout. Latest L2 block is {:?}", latest_block.number); + panic!( + "Timeout. Latest L2 block is {:?}", + latest_block.header.number + ); } sleep(Duration::from_secs(1)).await; diff --git a/crates/ethereum-rpc/Cargo.toml b/crates/ethereum-rpc/Cargo.toml index 67090c1a1..8d8a21326 100644 --- a/crates/ethereum-rpc/Cargo.toml +++ b/crates/ethereum-rpc/Cargo.toml @@ -28,7 +28,6 @@ reth-rpc = { workspace = true } reth-rpc-types = { workspace = true } reth-rpc-types-compat = { workspace = true } -ethers = { workspace = true } schnellru = "0.2.1" tokio = { workspace = true } diff --git a/crates/ethereum-rpc/src/lib.rs b/crates/ethereum-rpc/src/lib.rs index 5da630db8..21e76459a 100644 --- a/crates/ethereum-rpc/src/lib.rs +++ b/crates/ethereum-rpc/src/lib.rs @@ -7,13 +7,12 @@ use std::sync::Mutex; #[cfg(feature = "local")] pub use citrea_evm::DevSigner; use citrea_evm::Evm; -use ethers::types::{Bytes, H256}; pub use gas_price::fee_history::FeeHistoryCacheConfig; use gas_price::gas_oracle::GasPriceOracle; pub use gas_price::gas_oracle::GasPriceOracleConfig; use jsonrpsee::types::ErrorObjectOwned; use jsonrpsee::RpcModule; -use reth_primitives::{keccak256, BlockNumberOrTag, B256, U256}; +use reth_primitives::{keccak256, BlockNumberOrTag, Bytes, B256, U256}; use reth_rpc::eth::error::EthApiError; use reth_rpc_types::trace::geth::{ CallConfig, CallFrame, FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerConfig, @@ -715,7 +714,7 @@ fn register_rpc_methods( )?; if !is_sequencer { - rpc.register_async_method::, _, _>( + rpc.register_async_method::, _, _>( "eth_sendRawTransaction", |parameters, ethereum| async move { info!(params = ?parameters, "Full Node: eth_sendRawTransaction"); diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index acc253c8e..3d164ec4d 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -27,16 +27,9 @@ serde_json = { workspace = true, optional = true } thiserror = { workspace = true } tracing = { workspace = true, optional = true } -ethereum-types = { workspace = true, optional = true } -ethers = { workspace = true, optional = true } -ethers-contract = { workspace = true, optional = true } -ethers-core = { workspace = true, optional = true } -ethers-middleware = { workspace = true, optional = true } -ethers-signers = { workspace = true, optional = true } - -alloy-primitives = { workspace = true, features = ["rand", "rlp", "serde"] } +alloy-primitives = { workspace = true, features = ["rand", "serde"] } alloy-rlp = { workspace = true, optional = true } -alloy-sol-types = { workspace = true, optional = true } +alloy-sol-types = { workspace = true } itertools = { workspace = true, optional = true } reth-interfaces = { workspace = true, optional = true } reth-primitives = { workspace = true, default-features = false } @@ -48,6 +41,7 @@ revm-inspectors = { workspace = true, optional = true } secp256k1 = { workspace = true, optional = true } [dev-dependencies] +alloy = { workspace = true, features = ["consensus", "signer-wallet", "signers"] } bytes = { workspace = true } lazy_static = "1.4.0" rand = { workspace = true } @@ -70,7 +64,6 @@ native = [ "reth-rpc-types-compat", "revm-inspectors", "reth-rpc", - "alloy-sol-types", "alloy-rlp", "jsonrpsee", @@ -84,12 +77,5 @@ native = [ serde = [] smart_contracts = [ "native", - - "ethereum-types", - "ethers-core", - "ethers-contract", - "ethers-signers", - "ethers", - "serde_json", ] diff --git a/crates/evm/src/evm/system_contracts/mod.rs b/crates/evm/src/evm/system_contracts/mod.rs index 5a2691807..e6b5d98da 100644 --- a/crates/evm/src/evm/system_contracts/mod.rs +++ b/crates/evm/src/evm/system_contracts/mod.rs @@ -1,4 +1,13 @@ use alloy_primitives::{address, Address, Bytes, U256}; +use alloy_sol_types::{sol, SolCall}; + +// BitcoinLightClient wrapper. +sol! { + #[sol(abi)] + #[allow(missing_docs)] + BitcoinLightClientContract, + "./src/evm/system_contracts/out/BitcoinLightClient.sol/BitcoinLightClient.json" +} /// BitcoinLightClient wrapper. pub struct BitcoinLightClient {} @@ -10,45 +19,49 @@ impl BitcoinLightClient { } pub(crate) fn init(block_number: u64) -> Bytes { - let mut func_selector: Vec = vec![0x1f, 0x57, 0x83, 0x33]; // initializeBlockNumber(u256) 1f578333 - let block_number = U256::from(block_number); - func_selector.extend_from_slice(&block_number.to_be_bytes::<32>()); - Bytes::from(func_selector) + let mut func_selector = Vec::with_capacity(4 + 32); + func_selector.extend(BitcoinLightClientContract::initializeBlockNumberCall::SELECTOR); + func_selector.extend_from_slice(&block_number.to_be_bytes::<32>()); + func_selector.into() } pub(crate) fn set_block_info(block_hash: [u8; 32], txs_commitments: [u8; 32]) -> Bytes { - let mut func_selector = vec![0x0e, 0x27, 0xbc, 0x11]; // setBlockInfo(bytes32, bytes32) 0e27bc11 - + let mut func_selector = Vec::with_capacity(4 + 32 + 32); + func_selector.extend(BitcoinLightClientContract::setBlockInfoCall::SELECTOR); func_selector.extend_from_slice(&block_hash); func_selector.extend_from_slice(&txs_commitments); - - Bytes::from(func_selector) + func_selector.into() } /// Return input data to query the block hash by block number mapping pub fn get_block_hash(block_number: u64) -> Bytes { - let mut func_selector: Vec = vec![0xee, 0x82, 0xac, 0x5e]; // getBlockHash(uint256) ee82ac5e - - let block_number = U256::from(block_number); - println!("block_number: {:?}", block_number); - func_selector.extend_from_slice(&block_number.to_be_bytes::<32>()); - - Bytes::from(func_selector) + BitcoinLightClientContract::getBlockHashCall { + _blockNumber: U256::from(block_number), + } + .abi_encode() + .into() } - #[allow(dead_code)] + #[cfg(test)] pub(crate) fn get_witness_root_by_number(block_number: u64) -> Bytes { - let mut func_selector: Vec = vec![0x61, 0xb2, 0x07, 0xe2]; // getWitnessRootByNumber(uint256) 61b207e2 - - let block_number = U256::from(block_number); - func_selector.extend_from_slice(&block_number.to_be_bytes::<32>()); - - Bytes::from(func_selector) + BitcoinLightClientContract::getWitnessRootByNumberCall { + _blockNumber: U256::from(block_number), + } + .abi_encode() + .into() } } +// Bridge wrapper. +sol! { + #[sol(abi)] + #[allow(missing_docs)] + BridgeContract, + "./src/evm/system_contracts/out/Bridge.sol/Bridge.json" +} + /// Bridge wrapper. pub struct Bridge {} @@ -58,20 +71,52 @@ impl Bridge { address!("3100000000000000000000000000000000000002") } - pub(crate) fn initialize(data: Vec) -> Bytes { - let mut func_selector: Vec = vec![0x45, 0x07, 0xfc, 0x69]; // initialize(bytes,bytes,uint256,address) 4507fc69 - - func_selector.extend_from_slice(data.as_slice()); - - Bytes::from(func_selector) + pub(crate) fn initialize() -> Bytes { + // Hardcoded until better times. + + // This is equal to: + // + // BridgeContract::initializeCall { + // _depositScript: hex!("d2205daf577048c5e5a9a75d0a924ed03e226c3304f4a2f01c65ca1dab73522e6b8bad206228eba653cf1819bcfc1bc858630e5ae373eec1a9924322a5fe8445c5e76027ad201521d65f64be3f71b71ca462220f13c77b251027f6ca443a483353a96fbce222ad200fabeed269694ee83d9b3343a571202e68af65d05feda61dbed0c4bdb256a6eaad2000326d6f721c03dc5f1d8817d8f8ee890a95a2eeda0d4d9a01b1cc9b7b1b724dac00630663697472656114").into(), + // _scriptSuffix: hex!("0800000000000f424068").into(), + // _requiredSigsCount: U256::from(5), + // _owner: address!("f9725b63fe14efaf7cc705ba4e5c55a03d50e940"), + // } + // .abi_encode() + let params = vec![ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 249, 114, 91, 99, + 254, 20, 239, 175, 124, 199, 5, 186, 78, 92, 85, 160, 61, 80, 233, 64, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 181, 210, + 32, 93, 175, 87, 112, 72, 197, 229, 169, 167, 93, 10, 146, 78, 208, 62, 34, 108, 51, 4, + 244, 162, 240, 28, 101, 202, 29, 171, 115, 82, 46, 107, 139, 173, 32, 98, 40, 235, 166, + 83, 207, 24, 25, 188, 252, 27, 200, 88, 99, 14, 90, 227, 115, 238, 193, 169, 146, 67, + 34, 165, 254, 132, 69, 197, 231, 96, 39, 173, 32, 21, 33, 214, 95, 100, 190, 63, 113, + 183, 28, 164, 98, 34, 15, 19, 199, 123, 37, 16, 39, 246, 202, 68, 58, 72, 51, 83, 169, + 111, 188, 226, 34, 173, 32, 15, 171, 238, 210, 105, 105, 78, 232, 61, 155, 51, 67, 165, + 113, 32, 46, 104, 175, 101, 208, 95, 237, 166, 29, 190, 208, 196, 189, 178, 86, 166, + 234, 173, 32, 0, 50, 109, 111, 114, 28, 3, 220, 95, 29, 136, 23, 216, 248, 238, 137, + 10, 149, 162, 238, 218, 13, 77, 154, 1, 177, 204, 155, 123, 27, 114, 77, 172, 0, 99, 6, + 99, 105, 116, 114, 101, 97, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 8, 0, 0, 0, + 0, 0, 15, 66, 64, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, + ]; + + let mut func_selector = Vec::with_capacity(4 + params.len()); + func_selector.extend(BridgeContract::initializeCall::SELECTOR); + func_selector.extend(params); + func_selector.into() } /// Return data to deposit - pub fn deposit(data: Vec) -> Bytes { - let mut func_selector: Vec = vec![0xdd, 0x95, 0xc7, 0xc6]; // deposit((bytes4,bytes2,bytes,bytes,bytes,bytes4,bytes,uint256,uint256)) dd95c7c6 - - func_selector.extend_from_slice(data.as_slice()); - - Bytes::from(func_selector) + pub fn deposit(params: Vec) -> Bytes { + // Params can be read by `BridgeContract::depositCall::abi_decode_raw(¶ms, true)` + let mut func_selector = Vec::with_capacity(4 + params.len()); + func_selector.extend(BridgeContract::depositCall::SELECTOR); + func_selector.extend(params); + func_selector.into() } } diff --git a/crates/evm/src/evm/system_events.rs b/crates/evm/src/evm/system_events.rs index 3b16da4d9..e51b9e11c 100644 --- a/crates/evm/src/evm/system_events.rs +++ b/crates/evm/src/evm/system_events.rs @@ -21,7 +21,7 @@ pub const SYSTEM_SIGNER: Address = address!("deaddeaddeaddeaddeaddeaddeaddeaddea pub(crate) enum SystemEvent { BitcoinLightClientInitialize(/*block number*/ u64), BitcoinLightClientSetBlockInfo(/*hash*/ [u8; 32], /*merkle root*/ [u8; 32]), - BridgeInitialize(Vec), // deposit script, script suffix, required sigs count + BridgeInitialize, BridgeDeposit(Vec), // version, flag, vin, vout, witness, locktime, intermediate nodes, block height, index } @@ -47,9 +47,9 @@ fn system_event_to_transaction(event: SystemEvent, nonce: u64, chain_id: u64) -> max_fee_per_gas: u64::MAX as u128, ..Default::default() }, - SystemEvent::BridgeInitialize(data) => TxEip1559 { + SystemEvent::BridgeInitialize => TxEip1559 { to: TxKind::Call(Bridge::address()), - input: Bridge::initialize(data), + input: Bridge::initialize(), nonce, chain_id, value: U256::ZERO, @@ -57,9 +57,9 @@ fn system_event_to_transaction(event: SystemEvent, nonce: u64, chain_id: u64) -> max_fee_per_gas: u64::MAX as u128, ..Default::default() }, - SystemEvent::BridgeDeposit(data) => TxEip1559 { + SystemEvent::BridgeDeposit(params) => TxEip1559 { to: TxKind::Call(Bridge::address()), - input: Bridge::deposit(data), + input: Bridge::deposit(params), nonce, chain_id, value: U256::ZERO, diff --git a/crates/evm/src/evm/tests.rs b/crates/evm/src/evm/tests.rs index b29b9eff7..14bc4b6a5 100644 --- a/crates/evm/src/evm/tests.rs +++ b/crates/evm/src/evm/tests.rs @@ -57,7 +57,7 @@ fn simple_contract_execution + DatabaseCommit + In let contract_address: Address = { let tx = dev_signer - .sign_default_transaction(TxKind::Create, contract.byte_code().to_vec(), 1, 0) + .sign_default_transaction(TxKind::Create, contract.byte_code(), 1, 0) .unwrap(); let tx = &tx.try_into().unwrap(); @@ -78,12 +78,7 @@ fn simple_contract_execution + DatabaseCommit + In let call_data = contract.set_call_data(set_arg); let tx = dev_signer - .sign_default_transaction( - TxKind::Call(contract_address), - hex::decode(hex::encode(&call_data)).unwrap(), - 2, - 0, - ) + .sign_default_transaction(TxKind::Call(contract_address), call_data.clone(), 2, 0) .unwrap(); let tx = &tx.try_into().unwrap(); @@ -101,12 +96,7 @@ fn simple_contract_execution + DatabaseCommit + In let call_data = contract.get_call_data(); let tx = dev_signer - .sign_default_transaction( - TxKind::Call(contract_address), - hex::decode(hex::encode(&call_data)).unwrap(), - 3, - 0, - ) + .sign_default_transaction(TxKind::Call(contract_address), call_data.clone(), 3, 0) .unwrap(); let tx = &tx.try_into().unwrap(); @@ -121,21 +111,16 @@ fn simple_contract_execution + DatabaseCommit + In .unwrap(); let out = output(result); - ethereum_types::U256::from(out.to_vec().as_slice()) + U256::from_be_slice(out.to_vec().as_slice()) }; - assert_eq!(set_arg, get_res.as_u32()); + assert_eq!(U256::from(set_arg), get_res); { let failing_call_data = contract.failing_function_call_data(); let tx = dev_signer - .sign_default_transaction( - TxKind::Call(contract_address), - hex::decode(hex::encode(&failing_call_data)).unwrap(), - 4, - 0, - ) + .sign_default_transaction(TxKind::Call(contract_address), failing_call_data, 4, 0) .unwrap(); let tx = &tx.try_into().unwrap(); diff --git a/crates/evm/src/genesis.rs b/crates/evm/src/genesis.rs index 2a4857fa4..b6420c7c9 100644 --- a/crates/evm/src/genesis.rs +++ b/crates/evm/src/genesis.rs @@ -265,9 +265,8 @@ mod tests { use std::collections::HashMap; use std::str::FromStr; - use hex::FromHex; - use reth_primitives::{keccak256, Bytes}; - use revm::primitives::{Address, SpecId}; + use reth_primitives::{hex, keccak256, Address, Bytes}; + use revm::primitives::SpecId; use super::U256; use crate::{AccountData, EvmConfig}; @@ -334,13 +333,13 @@ mod tests { ); let address = Address::from_str("0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266").unwrap(); - let code = Bytes::from_hex("0x60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a223e05d1461006a578063").unwrap(); + let code = hex!("60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a223e05d1461006a578063"); let config = EvmConfig { data: vec![AccountData { address, balance: AccountData::balance(u64::MAX), - code_hash: keccak256(&code), - code, + code_hash: keccak256(code), + code: code.into(), nonce: 1, storage, }], diff --git a/crates/evm/src/hooks.rs b/crates/evm/src/hooks.rs index 405a4add3..fec0e93be 100644 --- a/crates/evm/src/hooks.rs +++ b/crates/evm/src/hooks.rs @@ -62,38 +62,14 @@ where soft_confirmation_info.da_slot_hash, soft_confirmation_info.da_slot_txs_commitment, )); - system_events.push(SystemEvent::BridgeInitialize( - // couldn't figure out how encoding worked lol - vec![ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 249, 114, 91, 99, 254, 20, 239, 175, 124, 199, 5, 186, 78, 92, 85, - 160, 61, 80, 233, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 181, 210, 32, 93, 175, 87, 112, 72, 197, - 229, 169, 167, 93, 10, 146, 78, 208, 62, 34, 108, 51, 4, 244, 162, 240, 28, - 101, 202, 29, 171, 115, 82, 46, 107, 139, 173, 32, 98, 40, 235, 166, 83, 207, - 24, 25, 188, 252, 27, 200, 88, 99, 14, 90, 227, 115, 238, 193, 169, 146, 67, - 34, 165, 254, 132, 69, 197, 231, 96, 39, 173, 32, 21, 33, 214, 95, 100, 190, - 63, 113, 183, 28, 164, 98, 34, 15, 19, 199, 123, 37, 16, 39, 246, 202, 68, 58, - 72, 51, 83, 169, 111, 188, 226, 34, 173, 32, 15, 171, 238, 210, 105, 105, 78, - 232, 61, 155, 51, 67, 165, 113, 32, 46, 104, 175, 101, 208, 95, 237, 166, 29, - 190, 208, 196, 189, 178, 86, 166, 234, 173, 32, 0, 50, 109, 111, 114, 28, 3, - 220, 95, 29, 136, 23, 216, 248, 238, 137, 10, 149, 162, 238, 218, 13, 77, 154, - 1, 177, 204, 155, 123, 27, 114, 77, 172, 0, 99, 6, 99, 105, 116, 114, 101, 97, - 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 8, 0, 0, 0, 0, 0, 15, - 66, 64, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - )); + system_events.push(SystemEvent::BridgeInitialize); } soft_confirmation_info .deposit_data .iter() - .for_each(|deposit_data| { - system_events.push(SystemEvent::BridgeDeposit(deposit_data.clone())); + .for_each(|params| { + system_events.push(SystemEvent::BridgeDeposit(params.clone())); }); let cfg = self diff --git a/crates/evm/src/smart_contracts/blockhash_contract.rs b/crates/evm/src/smart_contracts/blockhash_contract.rs index c142ca647..1644f0e71 100644 --- a/crates/evm/src/smart_contracts/blockhash_contract.rs +++ b/crates/evm/src/smart_contracts/blockhash_contract.rs @@ -1,62 +1,43 @@ -use std::any::Any; +use alloy_primitives::U256; +use alloy_sol_types::{sol, SolCall}; -use ethers_contract::BaseContract; -use ethers_core::types::Bytes; +use super::TestContract; -use super::{make_contract_from_abi, test_data_path, TestContract}; +// BlockHash wrapper. +sol! { + #[sol(abi)] + BlockHash, + "./src/evm/test_data/BlockHash.abi" +} /// Blockhash wrapper. pub struct BlockHashContract { - bytecode: Bytes, - base_contract: BaseContract, + bytecode: Vec, } impl Default for BlockHashContract { fn default() -> Self { - let contract_data = { - let mut path = test_data_path(); - path.push("BlockHash.bin"); - - let contract_data = std::fs::read_to_string(path).unwrap(); - hex::decode(contract_data).unwrap() - }; - - let contract = { - let mut path = test_data_path(); - path.push("BlockHash.abi"); - - make_contract_from_abi(path) + let bytecode = { + let bytecode_hex = include_str!("../../../evm/src/evm/test_data/BlockHash.bin"); + hex::decode(bytecode_hex).unwrap() }; - Self { - bytecode: Bytes::from(contract_data), - base_contract: contract, - } + Self { bytecode } } } impl TestContract for BlockHashContract { - /// BlockhashContract bytecode. - fn byte_code(&self) -> Bytes { + fn byte_code(&self) -> Vec { self.bytecode.clone() } - /// Dynamically dispatch from trait. Downcast to BlockHashContract. - fn as_any(&self) -> &dyn Any { - self - } - /// Create the default instance of the smart contract. - fn default_(&self) -> Self - where - Self: Sized, - { - Self::default() - } } impl BlockHashContract { /// Function to get block hash of given block number. - pub fn get_block_hash(&self, block_number: u64) -> Bytes { - let get_arg = ethereum_types::U256::from(block_number); - self.base_contract.encode("getBlockHash", get_arg).unwrap() + pub fn get_block_hash(&self, block_number: u64) -> Vec { + BlockHash::getBlockHashCall { + num: U256::from(block_number), + } + .abi_encode() } } diff --git a/crates/evm/src/smart_contracts/caller_contract.rs b/crates/evm/src/smart_contracts/caller_contract.rs index e71f394c0..a7c224680 100644 --- a/crates/evm/src/smart_contracts/caller_contract.rs +++ b/crates/evm/src/smart_contracts/caller_contract.rs @@ -1,74 +1,52 @@ -use std::any::Any; +use alloy_primitives::{Address, U256}; +use alloy_sol_types::{sol, SolCall}; -use ethers_contract::BaseContract; -use ethers_core::types::Bytes; -use reth_primitives::Address; +use super::TestContract; -use super::{make_contract_from_abi, test_data_path, TestContract}; +// CallerContract wrapper. +sol! { + #[sol(abi)] + Caller, + "./src/evm/test_data/Caller.abi" +} /// CallerContract wrapper. pub struct CallerContract { - bytecode: Bytes, - base_contract: BaseContract, + bytecode: Vec, } impl Default for CallerContract { fn default() -> Self { - let contract_data = { - let mut path = test_data_path(); - path.push("Caller.bin"); - - let contract_data = std::fs::read_to_string(path).unwrap(); - hex::decode(contract_data).unwrap() - }; - - let contract = { - let mut path = test_data_path(); - path.push("Caller.abi"); - - make_contract_from_abi(path) + let bytecode = { + let bytecode_hex = include_str!("../../../evm/src/evm/test_data/Caller.bin"); + hex::decode(bytecode_hex).unwrap() }; - Self { - bytecode: Bytes::from(contract_data), - base_contract: contract, - } + Self { bytecode } } } impl TestContract for CallerContract { - /// Caller bytecode. - fn byte_code(&self) -> Bytes { + fn byte_code(&self) -> Vec { self.byte_code() } - /// Dynamically dispatch from trait. Downcast to CallerContract. - fn as_any(&self) -> &dyn Any { - self - } - /// Create the default instance of the smart contract. - fn default_(&self) -> Self - where - Self: Sized, - { - Self::default() - } } impl CallerContract { /// Caller bytecode. - pub fn byte_code(&self) -> Bytes { + pub fn byte_code(&self) -> Vec { self.bytecode.clone() } - /// Calls Getter of Simple Storage Contract. - pub fn call_get_call_data(&self, address: Address) -> Bytes { - let address = ethereum_types::Address::from_slice(address.as_ref()); - self.base_contract.encode("callget", address).unwrap() + /// Calls Getter of Caller Contract. + pub fn call_get_call_data(&self, address: Address) -> Vec { + Caller::callgetCall { addr: address }.abi_encode() } - /// Calls Setter of Simple Storage Contract. - pub fn call_set_call_data(&self, address: Address, set_arg: u32) -> Bytes { - let set_arg = ethereum_types::U256::from(set_arg); - let address = ethereum_types::Address::from_slice(address.as_ref()); - let args = (address, set_arg); - self.base_contract.encode("callset", args).unwrap() + /// Calls Setter of Caller Contract. + pub fn call_set_call_data(&self, address: Address, set_arg: u32) -> Vec { + Caller::callsetCall { + addr: address, + num: U256::from(set_arg), + } + .abi_encode() } } diff --git a/crates/evm/src/smart_contracts/coinbase_contract.rs b/crates/evm/src/smart_contracts/coinbase_contract.rs index 63f89342b..7c975c8f2 100644 --- a/crates/evm/src/smart_contracts/coinbase_contract.rs +++ b/crates/evm/src/smart_contracts/coinbase_contract.rs @@ -1,66 +1,44 @@ -use std::any::Any; +use alloy_sol_types::{sol, SolCall}; -use ethers_contract::BaseContract; -use ethers_core::types::Bytes; +use super::TestContract; -use super::{make_contract_from_abi, test_data_path, TestContract}; +// Coinbase wrapper. +sol! { + #[sol(abi)] + Coinbase, + "./src/evm/test_data/Coinbase.abi" +} /// CoinbaseContract wrapper. pub struct CoinbaseContract { - bytecode: Bytes, - base_contract: BaseContract, + bytecode: Vec, } impl Default for CoinbaseContract { fn default() -> Self { - let contract_data = { - let mut path = test_data_path(); - path.push("Coinbase.bin"); - - let contract_data = std::fs::read_to_string(path).unwrap(); - hex::decode(contract_data).unwrap() - }; - - let contract = { - let mut path = test_data_path(); - path.push("Coinbase.abi"); - - make_contract_from_abi(path) + let bytecode = { + let bytecode_hex = include_str!("../../../evm/src/evm/test_data/Coinbase.bin"); + hex::decode(bytecode_hex).unwrap() }; - Self { - bytecode: Bytes::from(contract_data), - base_contract: contract, - } + Self { bytecode } } } impl TestContract for CoinbaseContract { - /// Coinbase bytecode. - fn byte_code(&self) -> Bytes { + fn byte_code(&self) -> Vec { self.byte_code() } - /// Dynamically dispatch from trait. Downcast to CoinbaseContract. - fn as_any(&self) -> &dyn Any { - self - } - /// Create the default instance of the smart contract. - fn default_(&self) -> Self - where - Self: Sized, - { - Self::default() - } } impl CoinbaseContract { /// Coinbase bytecode. - pub fn byte_code(&self) -> Bytes { + pub fn byte_code(&self) -> Vec { self.bytecode.clone() } /// Getter for the smart contract. - pub fn reward_miner(&self) -> Bytes { - self.base_contract.encode("rewardMiner", ()).unwrap() + pub fn reward_miner(&self) -> Vec { + Coinbase::rewardMinerCall {}.abi_encode() } } diff --git a/crates/evm/src/smart_contracts/hive_contract.rs b/crates/evm/src/smart_contracts/hive_contract.rs index 726a4ae3f..3c08ff791 100644 --- a/crates/evm/src/smart_contracts/hive_contract.rs +++ b/crates/evm/src/smart_contracts/hive_contract.rs @@ -1,12 +1,16 @@ -use ethers_contract::BaseContract; -use ethers_core::types::Bytes; - -use super::{make_contract_from_abi, test_data_path}; +use alloy_primitives::U256; +use alloy_sol_types::{sol, SolCall}; + +// HiveContract wrapper. +sol! { + #[sol(abi)] + Hive, + "./src/evm/test_data/HiveContract.abi" +} -/// CallerContract wrapper. +/// HiveContract wrapper. pub struct HiveContract { - bytecode: Bytes, - base_contract: BaseContract, + bytecode: Vec, } impl Default for HiveContract { @@ -18,36 +22,25 @@ impl Default for HiveContract { impl HiveContract { /// Create a new instance of HiveContract. pub fn new() -> Self { - let contract_data = { - let mut path = test_data_path(); - path.push("HiveContract.bin"); - - let contract_data = std::fs::read_to_string(path).unwrap(); - hex::decode(contract_data).unwrap() + let bytecode = { + let bytecode_hex = include_str!("../../../evm/src/evm/test_data/HiveContract.bin"); + hex::decode(bytecode_hex).unwrap() }; - let base_contract = { - let mut path = test_data_path(); - path.push("HiveContract.abi"); - - make_contract_from_abi(path) - }; - Self { - bytecode: Bytes::from(contract_data), - base_contract, - } + Self { bytecode } } /// Calls ConstFunc of Hive Contract - pub fn call_const_func(&self, a: u32, b: u32, c: u32) -> Bytes { - let arg_a = ethereum_types::U256::from(a); - let arg_b = ethereum_types::U256::from(b); - let arg_c = ethereum_types::U256::from(c); - let args = (arg_a, arg_b, arg_c); - self.base_contract.encode("constFunc", args).unwrap() + pub fn call_const_func(&self, a: u32, b: u32, c: u32) -> Vec { + Hive::constFuncCall { + a: U256::from(a), + b: U256::from(b), + c: U256::from(c), + } + .abi_encode() } /// Bytecode of the Hive Contract. - pub fn byte_code(&self) -> Bytes { + pub fn byte_code(&self) -> Vec { self.bytecode.clone() } } diff --git a/crates/evm/src/smart_contracts/infinite_loop_contract.rs b/crates/evm/src/smart_contracts/infinite_loop_contract.rs index cbe25e342..33cf2df14 100644 --- a/crates/evm/src/smart_contracts/infinite_loop_contract.rs +++ b/crates/evm/src/smart_contracts/infinite_loop_contract.rs @@ -1,65 +1,43 @@ -use std::any::Any; +use alloy_sol_types::{sol, SolCall}; -use ethers_contract::BaseContract; -use ethers_core::types::Bytes; +use super::TestContract; -use super::{make_contract_from_abi, test_data_path, TestContract}; +// InfiniteLoop wrapper. +sol! { + #[sol(abi)] + InfiniteLoop, + "./src/evm/test_data/InfiniteLoop.abi" +} /// InfiniteLoopContract wrapper. pub struct InfiniteLoopContract { - bytecode: Bytes, - base_contract: BaseContract, + bytecode: Vec, } impl Default for InfiniteLoopContract { fn default() -> Self { - let contract_data = { - let mut path = test_data_path(); - path.push("InfiniteLoop.bin"); - - let contract_data = std::fs::read_to_string(path).unwrap(); - hex::decode(contract_data).unwrap() + let bytecode = { + let bytecode_hex = include_str!("../../../evm/src/evm/test_data/InfiniteLoop.bin"); + hex::decode(bytecode_hex).unwrap() }; - let contract = { - let mut path = test_data_path(); - path.push("InfiniteLoop.abi"); - - make_contract_from_abi(path) - }; - - Self { - bytecode: Bytes::from(contract_data), - base_contract: contract, - } + Self { bytecode } } } impl TestContract for InfiniteLoopContract { - /// Caller bytecode. - fn byte_code(&self) -> Bytes { + fn byte_code(&self) -> Vec { self.byte_code() } - /// Dynamically dispatch from trait. Downcast to InfiniteLoopContract. - fn as_any(&self) -> &dyn Any { - self - } - /// Create the default instance of the smart contract. - fn default_(&self) -> Self - where - Self: Sized, - { - Self::default() - } } impl InfiniteLoopContract { /// InfiniteLoop bytecode. - pub fn byte_code(&self) -> Bytes { + pub fn byte_code(&self) -> Vec { self.bytecode.clone() } /// Calls InfiniteLoop::infiniteLoop. - pub fn call_infinite_loop(&self) -> Bytes { - self.base_contract.encode("infiniteLoop", ()).unwrap() + pub fn call_infinite_loop(&self) -> Vec { + InfiniteLoop::infiniteLoopCall {}.abi_encode() } } diff --git a/crates/evm/src/smart_contracts/logs_contract.rs b/crates/evm/src/smart_contracts/logs_contract.rs index 70ee5087a..e946a5072 100644 --- a/crates/evm/src/smart_contracts/logs_contract.rs +++ b/crates/evm/src/smart_contracts/logs_contract.rs @@ -1,61 +1,42 @@ -use std::any::Any; +use alloy_sol_types::{sol, SolCall}; -use ethers_contract::BaseContract; -use ethers_core::types::Bytes; +use super::TestContract; -use super::{make_contract_from_abi, test_data_path, TestContract}; +// Logs wrapper. +sol! { + #[sol(abi)] + Logs, + "./src/evm/test_data/Logs.abi" +} /// Logs wrapper. pub struct LogsContract { - bytecode: Bytes, - base_contract: BaseContract, + bytecode: Vec, } impl Default for LogsContract { fn default() -> Self { - let contract_data = { - let mut path = test_data_path(); - path.push("Logs.bin"); - - let contract_data = std::fs::read_to_string(path).unwrap(); - hex::decode(contract_data).unwrap() - }; - - let contract = { - let mut path = test_data_path(); - path.push("Logs.abi"); - - make_contract_from_abi(path) + let bytecode = { + let bytecode_hex = include_str!("../../../evm/src/evm/test_data/Logs.bin"); + hex::decode(bytecode_hex).unwrap() }; - Self { - bytecode: Bytes::from(contract_data), - base_contract: contract, - } + Self { bytecode } } } impl TestContract for LogsContract { - /// SimpleStorage bytecode. - fn byte_code(&self) -> Bytes { + fn byte_code(&self) -> Vec { self.bytecode.clone() } - /// Dynamically dispatch from trait. Downcast to LogsContract. - fn as_any(&self) -> &dyn Any { - self - } - /// Create the default instance of the smart contract. - fn default_(&self) -> Self - where - Self: Sized, - { - Self::default() - } } impl LogsContract { /// Log publishing function of the smart contract. - pub fn publish_event(&self, message: String) -> Bytes { - self.base_contract.encode("publishEvent", message).unwrap() + pub fn publish_event(&self, message: String) -> Vec { + Logs::publishEventCall { + _senderMessage: message, + } + .abi_encode() } } diff --git a/crates/evm/src/smart_contracts/mod.rs b/crates/evm/src/smart_contracts/mod.rs index dc8faaaa0..122e693bd 100644 --- a/crates/evm/src/smart_contracts/mod.rs +++ b/crates/evm/src/smart_contracts/mod.rs @@ -1,6 +1,4 @@ //! Includes the smart contracts used by the citrea-evm and the rollup itself, extensively for testing. -use std::any::Any; -use std::path::PathBuf; mod blockhash_contract; mod caller_contract; @@ -15,9 +13,6 @@ mod simple_storage_contract; pub use blockhash_contract::BlockHashContract; pub use caller_contract::CallerContract; pub use coinbase_contract::CoinbaseContract; -use ethers_contract::BaseContract; -use ethers_core::abi::Abi; -use ethers_core::types::Bytes; pub use hive_contract::HiveContract; pub use infinite_loop_contract::InfiniteLoopContract; pub use logs_contract::LogsContract; @@ -25,28 +20,8 @@ pub use payable_contract::SimplePayableContract; pub use self_destructor_contract::SelfDestructorContract; pub use simple_storage_contract::SimpleStorageContract; -fn test_data_path() -> PathBuf { - let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - path.push("src"); - path.push("evm"); - path.push("test_data"); - path -} - -fn make_contract_from_abi(path: PathBuf) -> BaseContract { - let abi_json = std::fs::read_to_string(path).unwrap(); - let abi: Abi = serde_json::from_str(&abi_json).unwrap(); - BaseContract::from(abi) -} - /// Trait for testing smart contracts. -pub trait TestContract { +pub trait TestContract: Default { /// Common method of all smart contracts. Returns bytecode - fn byte_code(&self) -> Bytes; - /// Dynamically dispatch from trait. - fn as_any(&self) -> &dyn Any; - /// Create the default instance of the smart contract. - fn default_(&self) -> Self - where - Self: Sized; + fn byte_code(&self) -> Vec; } diff --git a/crates/evm/src/smart_contracts/payable_contract.rs b/crates/evm/src/smart_contracts/payable_contract.rs index 7fbea3542..b1cb40478 100644 --- a/crates/evm/src/smart_contracts/payable_contract.rs +++ b/crates/evm/src/smart_contracts/payable_contract.rs @@ -1,65 +1,44 @@ -use std::any::Any; +use alloy_sol_types::{sol, SolCall}; -use ethers::contract::BaseContract; -use ethers::core::types::Bytes; +use super::TestContract; -use super::{make_contract_from_abi, test_data_path, TestContract}; +// Payable wrapper. +sol! { + #[sol(abi)] + Payable, + "./src/evm/test_data/Payable.abi" +} /// SimplePayableContract wrapper. pub struct SimplePayableContract { - bytecode: Bytes, - base_contract: BaseContract, + bytecode: Vec, } impl Default for SimplePayableContract { fn default() -> Self { - let contract_data = { - let mut path = test_data_path(); - path.push("Payable.bin"); - - let contract_data = std::fs::read_to_string(path).unwrap(); - hex::decode(contract_data).unwrap() - }; - - let contract = { - let mut path = test_data_path(); - path.push("Payable.abi"); - - make_contract_from_abi(path) + let bytecode = { + let bytecode_hex = include_str!("../../../evm/src/evm/test_data/Payable.bin"); + hex::decode(bytecode_hex).unwrap() }; - Self { - bytecode: Bytes::from(contract_data), - base_contract: contract, - } + Self { bytecode } } } impl TestContract for SimplePayableContract { - fn byte_code(&self) -> Bytes { + fn byte_code(&self) -> Vec { self.bytecode.clone() } - - fn as_any(&self) -> &dyn Any { - self - } - - fn default_(&self) -> Self - where - Self: Sized, - { - Self::default() - } } impl SimplePayableContract { /// Getter for the contract's balance. - pub fn get_balance(&self) -> Bytes { - self.base_contract.encode("getBalance", ()).unwrap() + pub fn get_balance(&self) -> Vec { + Payable::getBalanceCall {}.abi_encode() } /// Withdraw function call data. - pub fn withdraw(&self) -> Bytes { - self.base_contract.encode("withdraw", ()).unwrap() + pub fn withdraw(&self) -> Vec { + Payable::withdrawCall {}.abi_encode() } } diff --git a/crates/evm/src/smart_contracts/self_destructor_contract.rs b/crates/evm/src/smart_contracts/self_destructor_contract.rs index a2e5d466f..cf00b3d8b 100644 --- a/crates/evm/src/smart_contracts/self_destructor_contract.rs +++ b/crates/evm/src/smart_contracts/self_destructor_contract.rs @@ -1,68 +1,47 @@ -use std::any::Any; +use alloy_primitives::{Address, U256}; +use alloy_sol_types::{sol, SolCall}; -use ethers_contract::BaseContract; -use ethers_core::types::Bytes; -use reth_primitives::Address; +use super::TestContract; -use super::{make_contract_from_abi, test_data_path, TestContract}; +// SelfDestructor wrapper. +sol! { + #[sol(abi)] + SelfDestructor, + "./src/evm/test_data/SelfDestructor.abi" +} /// SelfDestructor wrapper. pub struct SelfDestructorContract { - bytecode: Bytes, - base_contract: BaseContract, + bytecode: Vec, } impl Default for SelfDestructorContract { fn default() -> Self { - let contract_data = { - let mut path = test_data_path(); - path.push("SelfDestructor.bin"); - - let contract_data = std::fs::read_to_string(path).unwrap(); - hex::decode(contract_data).unwrap() - }; - - let contract = { - let mut path = test_data_path(); - path.push("SelfDestructor.abi"); - - make_contract_from_abi(path) + let bytecode = { + let bytecode_hex = include_str!("../../../evm/src/evm/test_data/SelfDestructor.bin"); + hex::decode(bytecode_hex).unwrap() }; - Self { - bytecode: Bytes::from(contract_data), - base_contract: contract, - } + Self { bytecode } } } impl TestContract for SelfDestructorContract { - /// SimpleStorage bytecode. - fn byte_code(&self) -> Bytes { + fn byte_code(&self) -> Vec { self.bytecode.clone() } - /// Dynamically dispatch from trait. Downcast to SelfDestructorContract. - fn as_any(&self) -> &dyn Any { - self - } - /// Create the default instance of the smart contract. - fn default_(&self) -> Self - where - Self: Sized, - { - Self::default() - } } impl SelfDestructorContract { /// Setter of the smart contract. - pub fn set_call_data(&self, val: u32) -> Bytes { - let set_arg = ethereum_types::U256::from(val); - self.base_contract.encode("set", set_arg).unwrap() + pub fn set_call_data(&self, val: u32) -> Vec { + SelfDestructor::setCall { + _x: U256::from(val), + } + .abi_encode() } /// Selfdestructor of the smart contract. - pub fn selfdestruct(&self, to: Address) -> Bytes { - let set_arg = ethereum_types::Address::from_slice(to.as_ref()); - self.base_contract.encode("die", set_arg).unwrap() + pub fn selfdestruct(&self, to: Address) -> Vec { + SelfDestructor::dieCall { to }.abi_encode() } } diff --git a/crates/evm/src/smart_contracts/simple_storage_contract.rs b/crates/evm/src/smart_contracts/simple_storage_contract.rs index 1eec59f9c..efe05f51e 100644 --- a/crates/evm/src/smart_contracts/simple_storage_contract.rs +++ b/crates/evm/src/smart_contracts/simple_storage_contract.rs @@ -1,77 +1,57 @@ -use std::any::Any; +use alloy_primitives::U256; +use alloy_sol_types::{sol, SolCall}; -use ethers_contract::BaseContract; -use ethers_core::types::Bytes; +use super::TestContract; -use super::{make_contract_from_abi, test_data_path, TestContract}; +// SimpleStorageContract wrapper. +sol! { + #[sol(abi)] + SimpleStorage, + "./src/evm/test_data/SimpleStorage.abi" +} /// SimpleStorageContract wrapper. pub struct SimpleStorageContract { - bytecode: Bytes, - base_contract: BaseContract, + bytecode: Vec, } impl Default for SimpleStorageContract { fn default() -> Self { - let contract_data = { - let mut path = test_data_path(); - path.push("SimpleStorage.bin"); - - let contract_data = std::fs::read_to_string(path).unwrap(); - hex::decode(contract_data).unwrap() - }; - - let contract = { - let mut path = test_data_path(); - path.push("SimpleStorage.abi"); - - make_contract_from_abi(path) + let bytecode = { + let bytecode_hex = include_str!("../../../evm/src/evm/test_data/SimpleStorage.bin"); + hex::decode(bytecode_hex).unwrap() }; - Self { - bytecode: Bytes::from(contract_data), - base_contract: contract, - } + Self { bytecode } } } impl TestContract for SimpleStorageContract { - /// SimpleStorage bytecode. - fn byte_code(&self) -> Bytes { + fn byte_code(&self) -> Vec { self.byte_code() } - /// Dynamically dispatch from trait. Downcast to SimpleStorageContract. - fn as_any(&self) -> &dyn Any { - self - } - /// Create the default instance of the smart contract. - fn default_(&self) -> Self - where - Self: Sized, - { - Self::default() - } } impl SimpleStorageContract { /// SimpleStorage bytecode. - pub fn byte_code(&self) -> Bytes { + pub fn byte_code(&self) -> Vec { self.bytecode.clone() } /// Getter for the smart contract. - pub fn get_call_data(&self) -> Bytes { - self.base_contract.encode("get", ()).unwrap() + pub fn get_call_data(&self) -> Vec { + SimpleStorage::getCall {}.abi_encode() } /// Setter for the smart contract. - pub fn set_call_data(&self, set_arg: u32) -> Bytes { - let set_arg = ethereum_types::U256::from(set_arg); - self.base_contract.encode("set", set_arg).unwrap() + pub fn set_call_data(&self, set_arg: u32) -> Vec { + SimpleStorage::setCall { + _num: U256::from(set_arg), + } + .abi_encode() } /// Failing call data to test revert. - pub fn failing_function_call_data(&self) -> Bytes { + pub fn failing_function_call_data(&self) -> Vec { // Some random function signature. - let data = hex::decode("a5643bf2").unwrap(); - Bytes::from(data) + hex::decode("a5643bf2").unwrap() } } diff --git a/crates/evm/src/tests/call_tests.rs b/crates/evm/src/tests/call_tests.rs index ef8c1e0c8..419002c35 100644 --- a/crates/evm/src/tests/call_tests.rs +++ b/crates/evm/src/tests/call_tests.rs @@ -43,11 +43,7 @@ fn call_multiple_test() { let (evm, mut working_set) = get_evm(&config); - let contract_addr: Address = Address::from_slice( - hex::decode("819c5497b157177315e1204f52e588b393771719") - .unwrap() - .as_slice(), - ); + let contract_addr = address!("819c5497b157177315e1204f52e588b393771719"); let l1_fee_rate = 0; @@ -288,11 +284,7 @@ fn self_destruct_test() { let contract_balance: u64 = 1000000000000000; // address used in selfdestruct - let die_to_address = Address::from_slice( - hex::decode("11115497b157177315e1204f52e588b393111111") - .unwrap() - .as_slice(), - ); + let die_to_address = address!("11115497b157177315e1204f52e588b393111111"); let (config, dev_signer, contract_addr) = get_evm_config(U256::from_str("100000000000000000000").unwrap(), None); @@ -511,12 +503,7 @@ fn test_block_hash_in_evm() { gas: None, input: TransactionInput { data: None, - input: Some( - BlockHashContract::default() - .get_block_hash(0) - .to_vec() - .into(), - ), + input: Some(BlockHashContract::default().get_block_hash(0).into()), }, nonce: Some(0u64), chain_id: Some(DEFAULT_CHAIN_ID), @@ -528,12 +515,7 @@ fn test_block_hash_in_evm() { }; for i in 0..=1000 { - request.input.input = Some( - BlockHashContract::default() - .get_block_hash(i) - .to_vec() - .into(), - ); + request.input.input = Some(BlockHashContract::default().get_block_hash(i).into()); let resp = evm.get_call(request.clone(), None, None, None, &mut working_set); if !(260..=515).contains(&i) { // Should be 0, there is more than 256 blocks between the last block and the block number @@ -626,7 +608,7 @@ pub fn create_contract_message( contract: T, ) -> RlpEvmTransaction { dev_signer - .sign_default_transaction(TxKind::Create, contract.byte_code().to_vec(), nonce, 0) + .sign_default_transaction(TxKind::Create, contract.byte_code(), nonce, 0) .unwrap() } @@ -639,7 +621,7 @@ pub(crate) fn create_contract_message_with_fee( dev_signer .sign_default_transaction_with_fee( TxKind::Create, - contract.byte_code().to_vec(), + contract.byte_code(), nonce, 0, max_fee_per_gas, @@ -653,7 +635,7 @@ pub(crate) fn create_contract_transaction( contract: T, ) -> RlpEvmTransaction { dev_signer - .sign_default_transaction(TxKind::Create, contract.byte_code().to_vec(), nonce, 0) + .sign_default_transaction(TxKind::Create, contract.byte_code(), nonce, 0) .unwrap() } @@ -668,7 +650,7 @@ fn set_selfdestruct_arg_message( dev_signer .sign_default_transaction( TxKind::Call(contract_addr), - hex::decode(hex::encode(&contract.set_call_data(set_arg))).unwrap(), + contract.set_call_data(set_arg), nonce, 0, ) @@ -686,7 +668,7 @@ pub(crate) fn set_arg_message( dev_signer .sign_default_transaction( TxKind::Call(contract_addr), - hex::decode(hex::encode(&contract.set_call_data(set_arg))).unwrap(), + contract.set_call_data(set_arg), nonce, 0, ) @@ -704,7 +686,7 @@ fn set_arg_transaction( dev_signer .sign_default_transaction( TxKind::Call(contract_addr), - hex::decode(hex::encode(&contract.set_call_data(set_arg))).unwrap(), + contract.set_call_data(set_arg), nonce, 0, ) @@ -733,7 +715,7 @@ fn selfdestruct_message( dev_signer .sign_default_transaction( TxKind::Call(contract_addr), - hex::decode(hex::encode(&contract.selfdestruct(to_address))).unwrap(), + contract.selfdestruct(to_address), nonce, 0, ) @@ -751,7 +733,7 @@ pub(crate) fn publish_event_message( signer .sign_default_transaction( TxKind::Call(contract_addr), - hex::decode(hex::encode(&contract.publish_event(message))).unwrap(), + contract.publish_event(message), nonce, 0, ) @@ -764,11 +746,7 @@ pub(crate) fn get_evm_config( ) -> (EvmConfig, TestSigner, Address) { let dev_signer: TestSigner = TestSigner::new_random(); - let contract_addr: Address = Address::from_slice( - hex::decode("819c5497b157177315e1204f52e588b393771719") - .unwrap() - .as_slice(), - ); + let contract_addr = address!("819c5497b157177315e1204f52e588b393771719"); let config = EvmConfig { data: vec![AccountData { address: dev_signer.address(), @@ -792,11 +770,7 @@ pub(crate) fn get_evm_config_starting_base_fee( ) -> (EvmConfig, TestSigner, Address) { let dev_signer: TestSigner = TestSigner::new_random(); - let contract_addr: Address = Address::from_slice( - hex::decode("819c5497b157177315e1204f52e588b393771719") - .unwrap() - .as_slice(), - ); + let contract_addr = address!("819c5497b157177315e1204f52e588b393771719"); let config = EvmConfig { data: vec![AccountData { address: dev_signer.address(), diff --git a/crates/evm/src/tests/genesis_tests.rs b/crates/evm/src/tests/genesis_tests.rs index b4e1a6d3a..55b22f0c4 100644 --- a/crates/evm/src/tests/genesis_tests.rs +++ b/crates/evm/src/tests/genesis_tests.rs @@ -1,13 +1,13 @@ use std::collections::HashMap; -use hex::FromHex; use lazy_static::lazy_static; use reth_primitives::constants::{EMPTY_RECEIPTS, EMPTY_TRANSACTIONS, ETHEREUM_BLOCK_GAS_LIMIT}; use reth_primitives::hex_literal::hex; use reth_primitives::{ Address, BaseFeeParams, Bloom, Bytes, Header, SealedHeader, B256, EMPTY_OMMER_ROOT_HASH, + KECCAK_EMPTY, U256, }; -use revm::primitives::{SpecId, KECCAK_EMPTY, U256}; +use revm::primitives::SpecId; use sov_modules_api::prelude::*; use crate::evm::primitive_types::SealedBlock; @@ -29,14 +29,14 @@ lazy_static! { address:Address::from([2u8; 20]), balance: U256::checked_mul(U256::from(1000), U256::pow(U256::from(10), U256::from(18))).unwrap(), // 1000 ETH, - code_hash: B256::from_hex("0x4e8ee9adb469b245e3a5a8e58e9b733aaa857a9dce1982257531db8a2700aabf").unwrap(), - code: Bytes::from_hex("0x60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a223e05d1461006a578063").unwrap(), + code_hash: hex!("4e8ee9adb469b245e3a5a8e58e9b733aaa857a9dce1982257531db8a2700aabf").into(), + code: hex!("60606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063a223e05d1461006a578063").into(), storage: { let mut storage = HashMap::new(); storage.insert(U256::from(0), U256::from(0x4321)); storage.insert( U256::from_be_slice( - &hex::decode("6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9").unwrap(), + &hex!("6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9")[..], ), U256::from(8), ); diff --git a/crates/evm/src/tests/queries/basic_queries.rs b/crates/evm/src/tests/queries/basic_queries.rs index 99180a295..d8a39178f 100644 --- a/crates/evm/src/tests/queries/basic_queries.rs +++ b/crates/evm/src/tests/queries/basic_queries.rs @@ -1,9 +1,6 @@ use std::collections::BTreeMap; -use std::str::FromStr; -use alloy_primitives::FixedBytes; -use hex::FromHex; -use reth_primitives::{address, BlockId, BlockNumberOrTag, TxKind, U64}; +use reth_primitives::{address, b256, BlockId, BlockNumberOrTag, TxKind, U64}; use reth_rpc::eth::error::EthApiError; use reth_rpc_types::request::{TransactionInput, TransactionRequest}; use reth_rpc_types::{AnyTransactionReceipt, Block, Rich}; @@ -24,10 +21,7 @@ fn get_block_by_hash_test() { let third_block = evm .get_block_by_hash( - FixedBytes::from_hex( - "0x2d7962c316685635252886d6801a553139e94e3b7d2b678f8c9d974a54e24ab9", - ) - .unwrap(), + b256!("2d7962c316685635252886d6801a553139e94e3b7d2b678f8c9d974a54e24ab9"), None, &mut working_set, ) @@ -125,20 +119,17 @@ fn get_transaction_by_block_hash_and_index_test() { assert_eq!(result, Ok(None)); let tx_hashes = [ - "0x2ff3a833e99d5a97e26f912c2e855f95e2dda542c89131fea0d189889d384d99", - "0xa69485c543cd51dc1856619f3ddb179416af040da2835a10405c856cd5fb41b8", - "0x17fa953338b32b30795ccb62f050f1c9bcdd48f4793fb2d6d34290b444841271", - "0xd7e5b2bce65678b5e1a4430b1320b18a258fd5412e20bd5734f446124a9894e6", + b256!("2ff3a833e99d5a97e26f912c2e855f95e2dda542c89131fea0d189889d384d99"), + b256!("a69485c543cd51dc1856619f3ddb179416af040da2835a10405c856cd5fb41b8"), + b256!("17fa953338b32b30795ccb62f050f1c9bcdd48f4793fb2d6d34290b444841271"), + b256!("d7e5b2bce65678b5e1a4430b1320b18a258fd5412e20bd5734f446124a9894e6"), ]; for (i, tx_hash) in tx_hashes.iter().enumerate() { let result = evm.get_transaction_by_block_hash_and_index(hash, U64::from(i), &mut working_set); - assert_eq!( - result.unwrap().unwrap().hash, - FixedBytes::from_hex(tx_hash).unwrap() - ); + assert_eq!(result.unwrap().unwrap().hash, *tx_hash); } } @@ -175,10 +166,10 @@ fn get_transaction_by_block_number_and_index_test() { } let tx_hashes = [ - "0x2ff3a833e99d5a97e26f912c2e855f95e2dda542c89131fea0d189889d384d99", - "0xa69485c543cd51dc1856619f3ddb179416af040da2835a10405c856cd5fb41b8", - "0x17fa953338b32b30795ccb62f050f1c9bcdd48f4793fb2d6d34290b444841271", - "0xd7e5b2bce65678b5e1a4430b1320b18a258fd5412e20bd5734f446124a9894e6", + b256!("2ff3a833e99d5a97e26f912c2e855f95e2dda542c89131fea0d189889d384d99"), + b256!("a69485c543cd51dc1856619f3ddb179416af040da2835a10405c856cd5fb41b8"), + b256!("17fa953338b32b30795ccb62f050f1c9bcdd48f4793fb2d6d34290b444841271"), + b256!("d7e5b2bce65678b5e1a4430b1320b18a258fd5412e20bd5734f446124a9894e6"), ]; for (i, tx_hash) in tx_hashes.iter().enumerate() { let result = evm.get_transaction_by_block_number_and_index( @@ -187,10 +178,7 @@ fn get_transaction_by_block_number_and_index_test() { &mut working_set, ); - assert_eq!( - result.unwrap().unwrap().hash, - FixedBytes::from_hex(tx_hash).unwrap() - ); + assert_eq!(result.unwrap().unwrap().hash, *tx_hash); } } @@ -296,7 +284,7 @@ fn call_test() { working_set.unset_archival_version(); let contract = SimpleStorageContract::default(); - let call_data = contract.get_call_data().to_string(); + let call_data = contract.get_call_data(); let nonce_too_low_result = evm.get_call( TransactionRequest { @@ -309,7 +297,7 @@ fn call_test() { max_fee_per_gas: None, max_priority_fee_per_gas: None, value: Some(U256::from(100000000)), - input: TransactionInput::new(alloy_primitives::Bytes::from_str(&call_data).unwrap()), + input: TransactionInput::new(call_data.clone().into()), nonce: Some(7u64), chain_id: Some(1u64), access_list: None, @@ -339,9 +327,7 @@ fn call_test() { max_fee_per_gas: None, max_priority_fee_per_gas: None, value: None, - input: TransactionInput::new( - alloy_primitives::Bytes::from_str(&call_data).unwrap(), - ), + input: TransactionInput::new(call_data.clone().into()), nonce: None, chain_id: Some(1u64), access_list: None, @@ -376,9 +362,7 @@ fn call_test() { max_fee_per_gas: None, max_priority_fee_per_gas: None, value: None, - input: TransactionInput::new( - alloy_primitives::Bytes::from_str(&call_data).unwrap(), - ), + input: TransactionInput::new(call_data.into()), nonce: None, chain_id: None, access_list: None, diff --git a/crates/evm/src/tests/queries/estimate_gas_tests.rs b/crates/evm/src/tests/queries/estimate_gas_tests.rs index a4d268551..81fca9636 100644 --- a/crates/evm/src/tests/queries/estimate_gas_tests.rs +++ b/crates/evm/src/tests/queries/estimate_gas_tests.rs @@ -1,16 +1,12 @@ use std::str::FromStr; -use alloy_primitives::{FixedBytes, Uint}; -use hex::FromHex; use jsonrpsee::core::RpcResult; -use reth_primitives::hex::ToHexExt; use reth_primitives::{ - address, AccessList, AccessListItem, Address, BlockNumberOrTag, Bytes, TxKind, + address, b256, AccessList, AccessListItem, Address, BlockNumberOrTag, TxKind, U256, }; use reth_rpc::eth::error::RpcInvalidTransactionError; use reth_rpc_types::request::{TransactionInput, TransactionRequest}; use reth_rpc_types::AccessListWithGasUsed; -use revm::primitives::U256; use serde_json::json; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::WorkingSet; @@ -51,7 +47,7 @@ fn payable_contract_value_test() { }; let result = evm.eth_estimate_gas(tx_req, Some(BlockNumberOrTag::Latest), &mut working_set); - assert_eq!(result.unwrap(), Uint::from_str("0xab13").unwrap()); + assert_eq!(result.unwrap(), U256::from_str("0xab13").unwrap()); } #[test] @@ -88,7 +84,7 @@ fn test_tx_request_fields_gas() { ); assert_eq!( result_contract_call.unwrap(), - Uint::from_str("0x6602").unwrap() + U256::from_str("0x6602").unwrap() ); let contract_diff_size = evm.eth_estimate_diff_size( tx_req_contract_call.clone(), @@ -112,7 +108,7 @@ fn test_tx_request_fields_gas() { Some(BlockNumberOrTag::Latest), &mut working_set, ); - assert_eq!(result_no_sender.unwrap(), Uint::from_str("0x6602").unwrap()); + assert_eq!(result_no_sender.unwrap(), U256::from_str("0x6602").unwrap()); working_set.unset_archival_version(); let tx_req_no_recipient = TransactionRequest { @@ -127,7 +123,7 @@ fn test_tx_request_fields_gas() { ); assert_eq!( result_no_recipient.unwrap(), - Uint::from_str("0xd0ad").unwrap() + U256::from_str("0xd0ad").unwrap() ); working_set.unset_archival_version(); @@ -141,7 +137,7 @@ fn test_tx_request_fields_gas() { Some(BlockNumberOrTag::Latest), &mut working_set, ); - assert_eq!(result_no_gas.unwrap(), Uint::from_str("0x6602").unwrap()); + assert_eq!(result_no_gas.unwrap(), U256::from_str("0x6602").unwrap()); working_set.unset_archival_version(); let tx_req_no_gas_price = TransactionRequest { @@ -156,7 +152,7 @@ fn test_tx_request_fields_gas() { ); assert_eq!( result_no_gas_price.unwrap(), - Uint::from_str("0x6602").unwrap() + U256::from_str("0x6602").unwrap() ); working_set.unset_archival_version(); @@ -172,7 +168,7 @@ fn test_tx_request_fields_gas() { ); assert_eq!( result_no_chain_id.unwrap(), - Uint::from_str("0x6602").unwrap() + U256::from_str("0x6602").unwrap() ); working_set.unset_archival_version(); @@ -205,7 +201,7 @@ fn test_tx_request_fields_gas() { ); assert_eq!( result_no_blob_versioned_hashes.unwrap(), - Uint::from_str("0x6602").unwrap() + U256::from_str("0x6602").unwrap() ); working_set.unset_archival_version(); @@ -224,23 +220,21 @@ fn test_tx_request_fields_gas() { create_no_access_list_test.unwrap(), AccessListWithGasUsed { access_list: AccessList(vec![AccessListItem { - address: Address::from_str("0x819c5497b157177315e1204f52e588b393771719").unwrap(), - storage_keys: vec![FixedBytes::from_hex( - "0xd17c80a661d193357ea7c5311e029471883989438c7bcae8362437311a764685" - ) - .unwrap()] + address: address!("819c5497b157177315e1204f52e588b393771719"), + storage_keys: vec![b256!( + "d17c80a661d193357ea7c5311e029471883989438c7bcae8362437311a764685" + )] }]), - gas_used: Uint::from_str("0x6e67").unwrap() + gas_used: U256::from_str("0x6e67").unwrap() } ); let access_list_req = TransactionRequest { access_list: Some(AccessList(vec![AccessListItem { - address: Address::from_str("0x819c5497b157177315e1204f52e588b393771719").unwrap(), - storage_keys: vec![FixedBytes::from_hex( - "0xd17c80a661d193357ea7c5311e029471883989438c7bcae8362437311a764685", - ) - .unwrap()], + address: address!("819c5497b157177315e1204f52e588b393771719"), + storage_keys: vec![b256!( + "d17c80a661d193357ea7c5311e029471883989438c7bcae8362437311a764685" + )], }])), ..tx_req_contract_call.clone() }; @@ -254,7 +248,7 @@ fn test_tx_request_fields_gas() { // Wrong access punishment. assert_eq!( access_list_gas_test.unwrap(), - Uint::from_str("0x6e67").unwrap() + U256::from_str("0x6e67").unwrap() ); let already_formed_list = evm.create_access_list( @@ -267,13 +261,12 @@ fn test_tx_request_fields_gas() { already_formed_list.unwrap(), AccessListWithGasUsed { access_list: AccessList(vec![AccessListItem { - address: Address::from_str("0x819c5497b157177315e1204f52e588b393771719").unwrap(), - storage_keys: vec![FixedBytes::from_hex( - "0xd17c80a661d193357ea7c5311e029471883989438c7bcae8362437311a764685" - ) - .unwrap()] + address: address!("819c5497b157177315e1204f52e588b393771719"), + storage_keys: vec![b256!( + "d17c80a661d193357ea7c5311e029471883989438c7bcae8362437311a764685" + )] }]), - gas_used: Uint::from_str("0x6e67").unwrap() + gas_used: U256::from_str("0x6e67").unwrap() } ); } @@ -286,13 +279,9 @@ fn test_access_list() { let (evm, mut working_set, signer) = init_evm_with_caller_contract(); let caller = CallerContract::default(); - let input_data = Bytes::from( - caller - .call_set_call_data( - Address::from_str("0x819c5497b157177315e1204f52e588b393771719").unwrap(), - 42, - ) - .to_vec(), + let input_data = caller.call_set_call_data( + Address::from_str("0x819c5497b157177315e1204f52e588b393771719").unwrap(), + 42, ); let tx_req_contract_call = TransactionRequest { @@ -305,7 +294,7 @@ fn test_access_list() { max_fee_per_gas: None, max_priority_fee_per_gas: None, value: None, - input: TransactionInput::new(input_data), + input: TransactionInput::new(input_data.into()), nonce: Some(3u64), chain_id: Some(1u64), access_list: None, @@ -316,7 +305,7 @@ fn test_access_list() { }; let no_access_list = evm.eth_estimate_gas(tx_req_contract_call.clone(), None, &mut working_set); - assert_eq!(no_access_list.unwrap(), Uint::from_str("0x788c").unwrap()); + assert_eq!(no_access_list.unwrap(), U256::from_str("0x788c").unwrap()); let form_access_list = evm.create_access_list(tx_req_contract_call.clone(), None, &mut working_set); @@ -325,29 +314,27 @@ fn test_access_list() { form_access_list.unwrap(), AccessListWithGasUsed { access_list: AccessList(vec![AccessListItem { - address: Address::from_str("0x819c5497b157177315e1204f52e588b393771719").unwrap(), - storage_keys: vec![FixedBytes::from_hex( - "0x0000000000000000000000000000000000000000000000000000000000000000" - ) - .unwrap()] + address: address!("819c5497b157177315e1204f52e588b393771719"), + storage_keys: vec![b256!( + "0000000000000000000000000000000000000000000000000000000000000000" + )] }]), - gas_used: Uint::from_str("0x775e").unwrap() + gas_used: U256::from_str("0x775e").unwrap() } ); let tx_req_with_access_list = TransactionRequest { access_list: Some(AccessList(vec![AccessListItem { - address: Address::from_str("0x819c5497b157177315e1204f52e588b393771719").unwrap(), - storage_keys: vec![FixedBytes::from_hex( - "0x0000000000000000000000000000000000000000000000000000000000000000", - ) - .unwrap()], + address: address!("819c5497b157177315e1204f52e588b393771719"), + storage_keys: vec![b256!( + "0000000000000000000000000000000000000000000000000000000000000000" + )], }])), ..tx_req_contract_call.clone() }; let with_access_list = evm.eth_estimate_gas(tx_req_with_access_list, None, &mut working_set); - assert_eq!(with_access_list.unwrap(), Uint::from_str("0x775e").unwrap()); + assert_eq!(with_access_list.unwrap(), U256::from_str("0x775e").unwrap()); } #[test] @@ -358,13 +345,13 @@ fn estimate_gas_with_varied_inputs_test() { let simple_result = test_estimate_gas_with_input(&evm, &mut working_set, &signer, simple_call_data); - assert_eq!(simple_result.unwrap(), Uint::from_str("0x684e").unwrap()); + assert_eq!(simple_result.unwrap(), U256::from_str("0x684e").unwrap()); let simple_call_data = 131; let simple_result = test_estimate_gas_with_input(&evm, &mut working_set, &signer, simple_call_data); - assert_eq!(simple_result.unwrap(), Uint::from_str("0x68cd").unwrap()); + assert_eq!(simple_result.unwrap(), U256::from_str("0x68cd").unwrap()); // Testing with non-zero value transfer EOA let value_transfer_result = @@ -372,7 +359,7 @@ fn estimate_gas_with_varied_inputs_test() { assert_eq!( value_transfer_result.unwrap(), - Uint::from(MIN_TRANSACTION_GAS + 1) + U256::from(MIN_TRANSACTION_GAS + 1) ); } @@ -382,16 +369,14 @@ fn test_estimate_gas_with_input( signer: &TestSigner, input_data: u32, ) -> RpcResult { - let input_data = SimpleStorageContract::default() - .set_call_data(input_data) - .encode_hex(); + let input_data = SimpleStorageContract::default().set_call_data(input_data); let tx_req = TransactionRequest { from: Some(signer.address()), to: Some(TxKind::Call(address!( "eeb03d20dae810f52111b853b31c8be6f30f4cd3" ))), gas: Some(100_000), - input: TransactionInput::new(Bytes::from_hex(input_data).unwrap()), + input: TransactionInput::new(input_data.into()), ..Default::default() }; diff --git a/crates/evm/src/tests/queries/evm_call_tests.rs b/crates/evm/src/tests/queries/evm_call_tests.rs index 23c59be9e..f20deb838 100644 --- a/crates/evm/src/tests/queries/evm_call_tests.rs +++ b/crates/evm/src/tests/queries/evm_call_tests.rs @@ -1,6 +1,5 @@ use std::str::FromStr; -use hex::FromHex; use jsonrpsee::core::RpcResult; use reth_primitives::{address, Address, BlockNumberOrTag, Bytes, TxKind}; use reth_rpc::eth::error::RpcInvalidTransactionError; @@ -22,8 +21,6 @@ fn call_contract_without_value() { let contract = SimpleStorageContract::default(); let contract_address = Address::from_str("0xeeb03d20dae810f52111b853b31c8be6f30f4cd3").unwrap(); - let contract_call_data = Bytes::from(contract.set_call_data(5).to_vec()); - let call_result = evm.get_call( TransactionRequest { from: Some(signer.address()), @@ -31,7 +28,7 @@ fn call_contract_without_value() { gas: Some(100000), gas_price: Some(100000000), value: None, - input: TransactionInput::new(contract_call_data), + input: TransactionInput::new(contract.set_call_data(5).into()), ..Default::default() }, Some(BlockNumberOrTag::Latest), @@ -49,7 +46,7 @@ fn call_contract_without_value() { gas: Some(100000), gas_price: Some(100000000), value: None, - input: TransactionInput::new(contract.get_call_data().to_vec().into()), + input: TransactionInput::new(contract.get_call_data().into()), ..Default::default() }, Some(BlockNumberOrTag::Latest), @@ -118,8 +115,6 @@ fn call_contract_with_value_transfer() { let contract = SimpleStorageContract::default(); let contract_address = Address::from_str("0xeeb03d20dae810f52111b853b31c8be6f30f4cd3").unwrap(); - let contract_call_data = Bytes::from(contract.set_call_data(5).to_vec()); - let call_result = evm.get_call( TransactionRequest { from: Some(signer.address()), @@ -127,7 +122,7 @@ fn call_contract_with_value_transfer() { gas: Some(100000), gas_price: Some(100000000), value: Some(U256::from(100000000)), // reverts here. - input: TransactionInput::new(contract_call_data), + input: TransactionInput::new(contract.set_call_data(5).into()), ..Default::default() }, Some(BlockNumberOrTag::Latest), @@ -146,7 +141,7 @@ fn call_contract_with_invalid_nonce() { let contract = SimpleStorageContract::default(); let contract_address = Address::from_str("0xeeb03d20dae810f52111b853b31c8be6f30f4cd3").unwrap(); - let contract_call_data = Bytes::from(contract.set_call_data(5).to_vec()); + let contract_call_data = contract.set_call_data(5); let invalid_nonce = 100u64; @@ -157,7 +152,7 @@ fn call_contract_with_invalid_nonce() { gas: Some(100000), gas_price: Some(100000000), nonce: Some(invalid_nonce), - input: TransactionInput::new(contract_call_data.clone()), + input: TransactionInput::new(contract_call_data.clone().into()), ..Default::default() }, Some(BlockNumberOrTag::Latest), @@ -177,7 +172,7 @@ fn call_contract_with_invalid_nonce() { gas: Some(100000), gas_price: Some(100000000), nonce: Some(low_nonce), - input: TransactionInput::new(contract_call_data), + input: TransactionInput::new(contract_call_data.into()), ..Default::default() }, Some(BlockNumberOrTag::Latest), @@ -224,8 +219,6 @@ fn call_with_high_gas_price() { let contract = SimpleStorageContract::default(); let contract_address = Address::from_str("0xeeb03d20dae810f52111b853b31c8be6f30f4cd3").unwrap(); - let contract_call_data = Bytes::from(contract.set_call_data(5).to_vec()); - let high_gas_price = 1000u128 * 10_000_000_000_000_000_000_u128; // A very high gas price let call_result = evm.get_call( @@ -234,7 +227,7 @@ fn call_with_high_gas_price() { to: Some(TxKind::Call(contract_address)), gas: Some(100000), gas_price: Some(high_gas_price), - input: TransactionInput::new(contract_call_data), + input: TransactionInput::new(contract.set_call_data(5).into()), ..Default::default() }, Some(BlockNumberOrTag::Latest), @@ -329,7 +322,7 @@ fn eth_call_eip1559( max_fee_per_gas, max_priority_fee_per_gas, value: None, - input: TransactionInput::new(contract.get_call_data().to_vec().into()), + input: TransactionInput::new(contract.get_call_data().into()), nonce: Some(9u64), chain_id: Some(1u64), ..Default::default() @@ -401,7 +394,7 @@ fn gas_price_call_test() { &mut working_set, ); - assert_eq!(result_only_gas, Ok(Bytes::from_hex("0x").unwrap())); + assert_eq!(result_only_gas, Ok(Bytes::new())); working_set.unset_archival_version(); // Test with gas and gas_price specified - error @@ -438,7 +431,7 @@ fn gas_price_call_test() { &mut working_set, ); - assert_eq!(result_gas_and_gas_price, Ok(Bytes::from_hex("0x").unwrap())); + assert_eq!(result_gas_and_gas_price, Ok(Bytes::new())); working_set.unset_archival_version(); // Test with max_fee_per_gas and max_priority_fee_per_gas specified diff --git a/crates/evm/src/tests/queries/log_tests.rs b/crates/evm/src/tests/queries/log_tests.rs index 7694e8970..7edd3d268 100644 --- a/crates/evm/src/tests/queries/log_tests.rs +++ b/crates/evm/src/tests/queries/log_tests.rs @@ -1,9 +1,7 @@ use std::str::FromStr; -use alloy_primitives::FixedBytes; -use hex::FromHex; use reth_primitives::constants::ETHEREUM_BLOCK_GAS_LIMIT; -use reth_primitives::BlockNumberOrTag; +use reth_primitives::{b256, BlockNumberOrTag}; use reth_rpc::eth::error::EthApiError; use revm::primitives::{B256, U256}; use sov_modules_api::default_context::DefaultContext; @@ -42,12 +40,9 @@ fn logs_for_filter_test() { let available_res = evm.eth_get_logs( Filter { - block_option: FilterBlockOption::AtBlockHash( - FixedBytes::from_hex( - "0x2d7962c316685635252886d6801a553139e94e3b7d2b678f8c9d974a54e24ab9", - ) - .unwrap(), - ), + block_option: FilterBlockOption::AtBlockHash(b256!( + "2d7962c316685635252886d6801a553139e94e3b7d2b678f8c9d974a54e24ab9" + )), address: FilterSet::default(), topics: [ FilterSet::default(), diff --git a/crates/evm/src/tests/test_signer.rs b/crates/evm/src/tests/test_signer.rs index d897f1c1f..49258c90e 100644 --- a/crates/evm/src/tests/test_signer.rs +++ b/crates/evm/src/tests/test_signer.rs @@ -1,5 +1,5 @@ -use ethers_core::rand::rngs::StdRng; -use ethers_core::rand::SeedableRng; +use rand::rngs::StdRng; +use rand::SeedableRng; use reth_primitives::{ Address, Bytes as RethBytes, Transaction as RethTransaction, TxEip1559 as RethTxEip1559, TxKind, U256, diff --git a/crates/evm/src/tests/tx_tests.rs b/crates/evm/src/tests/tx_tests.rs index 88df7b332..d1103d091 100644 --- a/crates/evm/src/tests/tx_tests.rs +++ b/crates/evm/src/tests/tx_tests.rs @@ -1,10 +1,13 @@ use std::str::FromStr; -use ethers_core::types::transaction::eip2718::TypedTransaction; -use ethers_core::types::{Bytes, Eip1559TransactionRequest}; -use ethers_core::utils::rlp::Rlp; -use ethers_signers::{LocalWallet, Signer}; -use reth_primitives::{Address, TransactionSignedEcRecovered, TxKind, U256}; +use alloy::consensus::{SignableTransaction, TxEnvelope}; +use alloy::providers::network::TxSignerSync; +use alloy::signers::wallet::LocalWallet; +use alloy_rlp::{Decodable, Encodable}; +use bytes::BytesMut; +use reth_primitives::{ + Address, Bytes, TransactionSigned, TransactionSignedEcRecovered, TxKind, U256, +}; use reth_rpc_types::request::{TransactionInput, TransactionRequest}; use revm::primitives::{TransactTo, TxEnv}; @@ -19,39 +22,47 @@ fn tx_rlp_encoding_test() { .parse::() .unwrap(); let from_addr = wallet.address(); - let to_addr = - ethers_core::types::Address::from_str("0x0aa7420c43b8c1a7b165d216948870c8ecfe1ee1") - .unwrap(); + let to_addr = Address::from_str("0x0aa7420c43b8c1a7b165d216948870c8ecfe1ee1").unwrap(); let data: Bytes = Bytes::from_str( "0x6ecd23060000000000000000000000000000000000000000000000000000000000000002", ) .unwrap(); - let tx_request = Eip1559TransactionRequest::new() + let mut request = TransactionRequest::default() .from(from_addr) - .chain_id(DEFAULT_CHAIN_ID) .nonce(0u64) - .max_priority_fee_per_gas(413047990155u64) - .max_fee_per_gas(768658734568u64) - .gas(184156u64) + .max_priority_fee_per_gas(413047990155) + .max_fee_per_gas(768658734568) + .gas_limit(184156) .to(to_addr) - .value(2000000000000u64) - .data(data); + .value(U256::from(2000000000000u64)) + .input(data.into()); + request.chain_id = Some(DEFAULT_CHAIN_ID); - let tx = TypedTransaction::Eip1559(tx_request); + let typed_tx = request.build_typed_tx().unwrap(); + let mut tx = typed_tx.eip1559().unwrap().clone(); - let sig = wallet.sign_transaction_sync(&tx).unwrap(); - sig.verify(tx.sighash(), wallet.address()).unwrap(); + let sig = wallet.sign_transaction_sync(&mut tx).unwrap(); + let addr = sig + .recover_address_from_prehash(&tx.signature_hash()) + .unwrap(); + assert_eq!(addr, wallet.address()); - let rlp_bytes = tx.rlp_signed(&sig); - let rlp_encoded = Rlp::new(&rlp_bytes); + let sig = sig.with_parity_bool(); // drop signature.v so the hash of tx is calculated correctly + let signed = tx.into_signed(sig); + let envelope: TxEnvelope = signed.into(); - let (decoded_tx, decoded_sig) = TypedTransaction::decode_signed(&rlp_encoded).unwrap(); - decoded_sig - .verify(decoded_tx.sighash(), wallet.address()) - .unwrap(); + let mut bytes = BytesMut::new(); + envelope.encode(&mut bytes); + + let decoded = TransactionSigned::decode(&mut bytes.as_ref()).unwrap(); + + let decoded_signed = decoded.try_ecrecovered().unwrap(); + let decoded_signer = decoded_signed.signer(); + assert_eq!(decoded_signer, wallet.address()); - assert_eq!(tx, decoded_tx); + let decoded_envelope = TxEnvelope::decode(&mut bytes.as_ref()).unwrap(); + assert_eq!(envelope, decoded_envelope); } #[test] diff --git a/crates/sequencer-client/Cargo.toml b/crates/sequencer-client/Cargo.toml index d90a000d3..f27c7a270 100644 --- a/crates/sequencer-client/Cargo.toml +++ b/crates/sequencer-client/Cargo.toml @@ -22,7 +22,6 @@ hex = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } -ethers = { workspace = true } tokio = { workspace = true } reth-primitives = { workspace = true } diff --git a/crates/sequencer-client/src/lib.rs b/crates/sequencer-client/src/lib.rs index cdf00a386..9235001ff 100644 --- a/crates/sequencer-client/src/lib.rs +++ b/crates/sequencer-client/src/lib.rs @@ -1,10 +1,9 @@ use std::ops::Range; -use ethers::types::{Bytes, H256}; use jsonrpsee::core::client::{ClientT, Error}; use jsonrpsee::http_client::{HttpClient, HttpClientBuilder}; use jsonrpsee::rpc_params; -use reth_primitives::B256; +use reth_primitives::{Bytes, B256}; use serde::Deserialize; use sov_rollup_interface::rpc::HexTx; use sov_rollup_interface::soft_confirmation::SignedSoftConfirmationBatch; @@ -80,7 +79,7 @@ impl SequencerClient { /// Sends raw tx to sequencer #[instrument(level = "trace", skip_all, err, ret)] - pub async fn send_raw_tx(&self, tx: Bytes) -> Result { + pub async fn send_raw_tx(&self, tx: Bytes) -> Result { self.client .request("eth_sendRawTransaction", rpc_params![tx]) .await diff --git a/crates/sequencer/Cargo.toml b/crates/sequencer/Cargo.toml index df6d83af6..e510d2721 100644 --- a/crates/sequencer/Cargo.toml +++ b/crates/sequencer/Cargo.toml @@ -13,6 +13,8 @@ resolver = "2" [dependencies] alloy-rlp = { workspace = true } +alloy-sol-types = { workspace = true } + anyhow = { workspace = true } borsh = { workspace = true } chrono = { workspace = true } @@ -38,7 +40,6 @@ reth-trie = { workspace = true } revm = { workspace = true } deadpool-postgres = { workspace = true } -ethers = { workspace = true } schnellru = "0.2.1" tokio = { workspace = true }