diff --git a/Cargo.lock b/Cargo.lock index 5a33066..b67f09b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,18 +152,6 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" -[[package]] -name = "auto_impl" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -185,12 +173,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - [[package]] name = "base64" version = "0.21.0" @@ -220,7 +202,6 @@ checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", "radium", - "serde", "tap", "wyz", ] @@ -257,9 +238,6 @@ name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -dependencies = [ - "serde", -] [[package]] name = "cc" @@ -346,8 +324,6 @@ dependencies = [ "ethereum-types", "flexi_logger", "plonky2_evm", - "revm", - "ruint", "serde", ] @@ -364,12 +340,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "const-oid" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" - [[package]] name = "const-random" version = "0.1.15" @@ -392,12 +362,6 @@ dependencies = [ "tiny-keccak", ] -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "coolor" version = "0.5.0" @@ -520,18 +484,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto-bigint" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-common" version = "0.1.6" @@ -608,29 +560,6 @@ dependencies = [ "syn 2.0.16", ] -[[package]] -name = "der" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.6" @@ -638,22 +567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer", - "const-oid", "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.16.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "signature", ] [[package]] @@ -662,24 +576,6 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" -[[package]] -name = "elliptic-curve" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75c71eaa367f2e5d556414a8eea812bc62985c879748d6403edabd9cb03f16e7" -dependencies = [ - "base16ct", - "crypto-bigint", - "digest", - "ff", - "generic-array", - "group", - "rand_core", - "sec1", - "subtle", - "zeroize", -] - [[package]] name = "encode_unicode" version = "0.3.6" @@ -698,17 +594,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "enumn" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.16", -] - [[package]] name = "env_logger" version = "0.10.0" @@ -758,10 +643,8 @@ dependencies = [ "keccak-hash 0.10.0", "log", "plonky2_evm", - "revm", "rlp", "rlp-derive", - "ruint", "serde", "serde_cbor", "serde_json", @@ -836,8 +719,6 @@ dependencies = [ "log", "plonky2", "plonky2_evm", - "revm", - "ruint", "serde", "serde_cbor", "similar", @@ -846,16 +727,6 @@ dependencies = [ "tokio-stream", ] -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "rand_core", - "subtle", -] - [[package]] name = "fixed-hash" version = "0.7.0" @@ -1004,7 +875,6 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -1032,17 +902,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - [[package]] name = "half" version = "1.8.2" @@ -1055,16 +914,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", - "serde", -] - [[package]] name = "hashbrown" version = "0.14.0" @@ -1113,15 +962,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - [[package]] name = "humansize" version = "2.1.3" @@ -1294,27 +1134,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "k256" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2", -] - -[[package]] -name = "keccak" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" -dependencies = [ - "cpufeatures", -] - [[package]] name = "keccak-hash" version = "0.8.0" @@ -1340,9 +1159,6 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin", -] [[package]] name = "libc" @@ -1847,30 +1663,6 @@ 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-macro-hack" version = "0.5.20+deprecated" @@ -1979,90 +1771,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" -[[package]] -name = "revm" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f293f351c4c203d321744e54ed7eed3d2b6eef4c140228910dde3ac9a5ea8031" -dependencies = [ - "auto_impl", - "revm-interpreter", - "revm-precompile", - "serde", - "serde_json", -] - -[[package]] -name = "revm-interpreter" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a53980a26f9b5a66d13511c35074d4b53631e157850a1d7cf1af4efc2c2b72c9" -dependencies = [ - "derive_more", - "enumn", - "revm-primitives", - "serde", - "sha3", -] - -[[package]] -name = "revm-precompile" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41320af3bd6a65153d38eb1d3638ba89104cc9513c7feedb2d8510e8307dab29" -dependencies = [ - "k256", - "num", - "once_cell", - "revm-primitives", - "ripemd", - "secp256k1", - "sha2", - "sha3", - "substrate-bn", -] - -[[package]] -name = "revm-primitives" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304d998f466ffef72d76c7f20b05bf08a96801736a6fb1fdef47d49a292618df" -dependencies = [ - "auto_impl", - "bitvec", - "bytes", - "derive_more", - "enumn", - "fixed-hash 0.8.0", - "hashbrown 0.13.2", - "hex", - "hex-literal", - "primitive-types 0.12.1", - "rlp", - "ruint", - "serde", - "sha3", -] - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest", -] - [[package]] name = "rlp" version = "0.5.2" @@ -2084,27 +1792,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ruint" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d470e29e933dac4101180fd6574971892315c414cf2961a192729089687cc9b" -dependencies = [ - "derive_more", - "primitive-types 0.12.1", - "rlp", - "ruint-macro", - "rustc_version", - "serde", - "thiserror", -] - -[[package]] -name = "ruint-macro" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62cc5760263ea229d367e7dff3c0cbf09e4797a125bd87059a6c095804f3b2d1" - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2117,15 +1804,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "rustix" version = "0.37.19" @@ -2152,43 +1830,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "sec1" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" -dependencies = [ - "base16ct", - "der", - "generic-array", - "subtle", - "zeroize", -] - -[[package]] -name = "secp256k1" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" -dependencies = [ - "cc", -] - -[[package]] -name = "semver" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" - [[package]] name = "serde" version = "1.0.163" @@ -2225,7 +1866,6 @@ version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ - "indexmap", "itoa", "ryu", "serde", @@ -2270,16 +1910,6 @@ dependencies = [ "digest", ] -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest", - "keccak", -] - [[package]] name = "signal-hook" version = "0.3.15" @@ -2310,16 +1940,6 @@ dependencies = [ "libc", ] -[[package]] -name = "signature" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" -dependencies = [ - "digest", - "rand_core", -] - [[package]] name = "similar" version = "2.2.1" @@ -2351,12 +1971,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "static_assertions" version = "1.1.0" @@ -2369,25 +1983,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "substrate-bn" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b5bbfa79abbae15dd642ea8176a21a635ff3c00059961d1ea27ad04e5b441c" -dependencies = [ - "byteorder", - "crunchy", - "lazy_static", - "rand", - "rustc-hex", -] - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - [[package]] name = "syn" version = "1.0.109" @@ -2886,9 +2481,3 @@ checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", ] - -[[package]] -name = "zeroize" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/common/Cargo.toml b/common/Cargo.toml index bcfa309..ec15649 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -14,5 +14,3 @@ eth_trie_utils = { git = "https://github.com/mir-protocol/eth_trie_utils.git", r flexi_logger = { version = "0.25.4", features = ["async"] } plonky2_evm = { git = "https://github.com/mir-protocol/plonky2.git", rev = "1ff6d4a2839a0cd16598a5db263568885a47e7c9" } serde = {version = "1.0.163", features = ["derive"] } -revm = { version = "3.3.0", features = ["serde"] } -ruint = { version = "1.8.0", features = ["primitive-types"] } diff --git a/common/src/lib.rs b/common/src/lib.rs index ddf6302..3e1b405 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,4 +1,3 @@ pub mod config; -pub mod revm; pub mod types; pub mod utils; diff --git a/common/src/revm/cache_db.rs b/common/src/revm/cache_db.rs deleted file mode 100644 index 059a256..0000000 --- a/common/src/revm/cache_db.rs +++ /dev/null @@ -1,135 +0,0 @@ -//! The [`CacheDb`](revm::db::CacheDB) struct isn't serializable, so we need to -//! have our own representation of it. `From` is implemented on both sides to -//! make it easy to convert between the two. - -use revm::{ - db::{AccountState, CacheDB, DbAccount}, - primitives::{AccountInfo, Bytecode, HashMap, Log, B160, B256, U256}, - InMemoryDB, -}; -use serde::{Deserialize, Serialize}; - -/// Serializable version of [`AccountState`](revm::db::AccountState) -#[derive(Debug, Clone, Default, Eq, PartialEq, Serialize, Deserialize)] -pub enum SerializableAccountState { - NotExisting, - Touched, - StorageCleared, - #[default] - None, -} - -impl From for SerializableAccountState { - fn from(account_state: AccountState) -> Self { - match account_state { - AccountState::NotExisting => Self::NotExisting, - AccountState::Touched => Self::Touched, - AccountState::StorageCleared => Self::StorageCleared, - AccountState::None => Self::None, - } - } -} - -impl From for AccountState { - fn from(account_state: SerializableAccountState) -> Self { - match account_state { - SerializableAccountState::NotExisting => Self::NotExisting, - SerializableAccountState::Touched => Self::Touched, - SerializableAccountState::StorageCleared => Self::StorageCleared, - SerializableAccountState::None => Self::None, - } - } -} - -/// Serializable version of [`DbAccount`](revm::db::DbAccount) -#[derive(Serialize, Deserialize, Clone, Debug)] -pub struct SerializableDbAccount { - pub info: AccountInfo, - pub account_state: SerializableAccountState, - pub storage: HashMap, -} - -impl From for SerializableDbAccount { - fn from( - DbAccount { - info, - account_state, - storage, - }: DbAccount, - ) -> Self { - Self { - info, - account_state: account_state.into(), - storage, - } - } -} - -impl From for DbAccount { - fn from( - SerializableDbAccount { - info, - account_state, - storage, - }: SerializableDbAccount, - ) -> Self { - Self { - info, - account_state: account_state.into(), - storage, - } - } -} - -/// Serializable version of [`InMemoryDB`](revm::db::InMemoryDB) -#[derive(Serialize, Deserialize, Clone, Debug)] -pub struct SerializableInMemoryDb { - pub accounts: HashMap, - pub contracts: HashMap, - pub logs: Vec, - pub block_hashes: HashMap, -} - -impl From for SerializableInMemoryDb { - fn from( - CacheDB { - accounts, - contracts, - logs, - block_hashes, - .. - }: InMemoryDB, - ) -> Self { - Self { - accounts: accounts - .into_iter() - .map(|(address, account)| (address, SerializableDbAccount::from(account))) - .collect(), - contracts, - logs, - block_hashes, - } - } -} - -impl From for InMemoryDB { - fn from( - SerializableInMemoryDb { - accounts, - contracts, - logs, - block_hashes, - }: SerializableInMemoryDb, - ) -> Self { - Self { - accounts: accounts - .into_iter() - .map(|(address, account)| (address, DbAccount::from(account))) - .collect(), - contracts, - logs, - block_hashes, - ..Default::default() - } - } -} diff --git a/common/src/revm/mod.rs b/common/src/revm/mod.rs deleted file mode 100644 index 643c4af..0000000 --- a/common/src/revm/mod.rs +++ /dev/null @@ -1,40 +0,0 @@ -//! Serializable wrapper types for an [`EVM`](revm::EVM) instance. -//! -//! Getting a fully constructed [`revm`](revm) environment requires the -//! following steps: -//! -//! 1. Construct an [`EVM`](revm::EVM) instance. -//! 2. Configure the instance's [`Env`](revm::primitives::Env). Note this -//! includes setting up the transaction we're testing at this step. -//! 3. Construct a [`Db`](revm::db::Database). In our case, an -//! [`InMemoryDB`](revm::InMemoryDB). -//! 4. Load the database with the accounts and their storage. - -use revm::{primitives::Env, InMemoryDB, EVM}; -use serde::{Deserialize, Serialize}; - -use self::cache_db::SerializableInMemoryDb; - -pub mod cache_db; - -/// Serialized version of a hydrated evm instance. -#[derive(Deserialize, Serialize, Debug)] -pub struct SerializableEVMInstance { - pub env: Env, - pub db: SerializableInMemoryDb, -} - -impl SerializableEVMInstance { - pub fn into_hydrated(self) -> EVM { - EVM { - db: Some(self.db.into()), - env: self.env, - } - } -} - -impl From for EVM { - fn from(value: SerializableEVMInstance) -> Self { - value.into_hydrated() - } -} diff --git a/common/src/types.rs b/common/src/types.rs index 743e777..ef030fc 100644 --- a/common/src/types.rs +++ b/common/src/types.rs @@ -13,12 +13,9 @@ use plonky2_evm::{ }; use serde::{Deserialize, Serialize}; -use crate::revm::SerializableEVMInstance; - #[derive(Debug, Deserialize, Serialize)] pub struct ParsedTestManifest { pub plonky2_variants: Vec, - pub revm_variants: Option>, } pub struct FilteredVariantsOutput { @@ -31,31 +28,18 @@ impl ParsedTestManifest { self, v_filter: Option, ) -> FilteredVariantsOutput { - // If `self.revm_variants` is None, the parser was unable to generate an `revm` - // instance for any test variant. This occurs when some shared test data was - // unable to be parsed (e.g. the `transaction` section). In this case, we - // generate a `None` for each test variant slot so that it can be zipped with - // plonky2 variants. - let revm_variants: Vec> = match self.revm_variants { - // `revm_variants` will be parallel to `plonky2_variants`, given they are both - // generated from the same vec (`test.post.merge`). - None => (0..self.plonky2_variants.len()).map(|_| None).collect(), - Some(v) => v.into_iter().map(Some).collect(), - }; - let tot_variants_without_filter = self.plonky2_variants.len(); let variants = self .plonky2_variants .into_iter() - .zip(revm_variants.into_iter()) .enumerate() .filter(|(variant_idx, _)| match &v_filter { Some(VariantFilterType::Single(v)) => variant_idx == v, Some(VariantFilterType::Range(r)) => r.contains(variant_idx), None => true, }) - .map(|(variant_idx, (t_var, revm_variant))| { + .map(|(variant_idx, t_var)| { let trie_roots_after = TrieRoots { state_root: t_var.final_roots.state_root_hash, transactions_root: t_var.final_roots.txn_trie_root_hash, @@ -80,7 +64,6 @@ impl ParsedTestManifest { TestVariantRunInfo { gen_inputs, final_roots: t_var.final_roots, - revm_variant, variant_idx, } }) @@ -109,7 +92,6 @@ pub struct Plonky2ParsedTest { pub struct TestVariantRunInfo { pub gen_inputs: GenerationInputs, pub final_roots: ExpectedFinalRoots, - pub revm_variant: Option, pub variant_idx: usize, } diff --git a/eth_test_parser/Cargo.toml b/eth_test_parser/Cargo.toml index 6fb35b9..fcab7dc 100644 --- a/eth_test_parser/Cargo.toml +++ b/eth_test_parser/Cargo.toml @@ -27,5 +27,3 @@ serde_with = "3.0.0" serde_cbor = "0.11.2" tokio = { version = "1.28.1", features = ["full"] } futures = "0.3.28" -revm = { version = "3.3.0", features = ["serde"] } -ruint = { version = "1.8.0", features = ["primitive-types"] } diff --git a/eth_test_parser/src/main.rs b/eth_test_parser/src/main.rs index eb8735e..5dedb99 100644 --- a/eth_test_parser/src/main.rs +++ b/eth_test_parser/src/main.rs @@ -18,7 +18,6 @@ mod config; mod deserialize; mod eth_tests_fetching; mod fs_scaffolding; -mod revm_builder; mod trie_builder; mod utils; @@ -46,29 +45,11 @@ async fn run(ProgArgs { no_fetch, out_path }: ProgArgs) -> anyhow::Result<()> { let generation_input_handles = get_deserialized_test_bodies()?.filter_map(|res| { match res { Ok((test_dir_entry, test_bodies)) => Some(tokio::task::spawn_blocking(move || { - let mut plonky2_variants = Vec::with_capacity(test_bodies.len()); - let mut revm_variants = Vec::with_capacity(test_bodies.len()); - for test_body in test_bodies.iter() { - let plonky2_variant = test_body.as_plonky2_test_inputs(); - let revm_variant = match test_body.as_serializable_evm_instance() { - Ok(revm_variant) => Some(revm_variant), - Err(err) => { - warn!( - "Unable to generate evm instance for test {} due to error: {}. Skipping!", - test_dir_entry.path().display(), - err - ); - None - } - }; - - plonky2_variants.push(plonky2_variant); - revm_variants.push(revm_variant); - } - let test_manifest = ParsedTestManifest { - plonky2_variants, - revm_variants: revm_variants.into_iter().collect(), + plonky2_variants: test_bodies + .iter() + .map(|t| t.as_plonky2_test_inputs()) + .collect(), }; (test_dir_entry, serde_cbor::to_vec(&test_manifest).unwrap()) diff --git a/eth_test_parser/src/revm_builder/cache_db.rs b/eth_test_parser/src/revm_builder/cache_db.rs deleted file mode 100644 index 35977e7..0000000 --- a/eth_test_parser/src/revm_builder/cache_db.rs +++ /dev/null @@ -1,43 +0,0 @@ -//! Logic for dealing with converting a -//! [`TestBody`](crate::deserialize::TestBody) into -//! `revm`'s [`InMemoryDB`](revm::InMemoryDB) - -use anyhow::Result; -use common::revm::cache_db::SerializableInMemoryDb; -use revm::{ - primitives::{AccountInfo, Bytecode}, - InMemoryDB, -}; - -use crate::deserialize::TestBody; - -impl TestBody { - pub(crate) fn as_revm_cache_db(&self) -> Result { - let mut db = InMemoryDB::default(); - - for (address, account) in &self.pre { - let address = address.to_fixed_bytes().into(); - let account_info = AccountInfo::new( - account.balance.into(), - account.nonce, - Bytecode::new_raw(account.code.0.clone().into()).to_checked(), - ); - - db.insert_account_info(address, account_info); - - for (key, value) in account.storage.iter() { - db.insert_account_storage(address, (*key).into(), (*value).into())?; - } - } - - Ok(db.into()) - } -} - -impl TryFrom<&TestBody> for SerializableInMemoryDb { - type Error = anyhow::Error; - - fn try_from(body: &TestBody) -> Result { - body.as_revm_cache_db() - } -} diff --git a/eth_test_parser/src/revm_builder/env.rs b/eth_test_parser/src/revm_builder/env.rs deleted file mode 100644 index 1d89ffa..0000000 --- a/eth_test_parser/src/revm_builder/env.rs +++ /dev/null @@ -1,94 +0,0 @@ -//! Convert a `TestBody` into a `Vec` of [`Env`](revm::primitives::Env). -use anyhow::{anyhow, Result}; -use common::config::MATIC_CHAIN_ID; -use revm::primitives::{BlockEnv, CfgEnv, Env, TransactTo, TxEnv, B160}; -use ruint::Uint; - -use crate::deserialize::{AccessListsInner, TestBody, Transaction}; - -impl TestBody { - fn to_txn_env(transaction: &Transaction) -> Result { - let to = match transaction.to { - Some(to) => TransactTo::Call(to.to_fixed_bytes().into()), - None => TransactTo::Call(Default::default()), - }; - let v = transaction.value; - let value: ethereum_types::U256 = v - .try_into() - .expect("Unable to convert transaction.value to U256"); - - let access_list = transaction - .access_lists - .get(0) - .unwrap_or(&AccessListsInner::default()) - .0 - .iter() - .map(|x| { - ( - B160::from(x.address.to_fixed_bytes()), - x.storage_keys - .iter() - .map(|x| (*x).into()) - .collect::>>(), - ) - }) - .collect(); - - Ok(TxEnv { - caller: transaction.sender.to_fixed_bytes().into(), - gas_limit: transaction.gas_limit, - gas_price: transaction.gas_price.map(|p| p.into()).unwrap_or_default(), - gas_priority_fee: None, - transact_to: to, - value: value.into(), - data: transaction.data.0.clone().into(), - chain_id: Some(MATIC_CHAIN_ID), - nonce: transaction.nonce.try_into().ok(), - // `access_list` is defined parallel to `transaction.data` in the test - // filler definitions. - // https://ethereum-tests.readthedocs.io/en/latest/test_filler/test_transaction_state.html?highlight=access#fields - access_list, - }) - } - - pub(crate) fn as_revm_env(&self) -> Result { - let cfg = CfgEnv { - chain_id: MATIC_CHAIN_ID.try_into()?, - ..Default::default() - }; - - if self.blocks.is_empty() { - return Err(anyhow!("No block")); - } - - let block = &self.blocks[0]; - - let transaction = &block.transactions.as_ref().unwrap()[0]; - - let block_header = &block.block_header.clone().unwrap_or_default(); - - let block = BlockEnv { - number: block_header.number.into(), - coinbase: block_header.coinbase.to_fixed_bytes().into(), - timestamp: block_header.timestamp.into(), - difficulty: block_header.difficulty.into(), - prevrandao: Some(block_header.mix_hash.into()), - basefee: block_header.base_fee_per_gas.unwrap_or_default().into(), - gas_limit: block_header.gas_limit.into(), - }; - - Ok(Env { - cfg, - block, - tx: TestBody::to_txn_env(transaction).unwrap(), - }) - } -} - -impl TryFrom<&TestBody> for Env { - type Error = anyhow::Error; - - fn try_from(body: &TestBody) -> Result { - body.as_revm_env() - } -} diff --git a/eth_test_parser/src/revm_builder/mod.rs b/eth_test_parser/src/revm_builder/mod.rs deleted file mode 100644 index f19c651..0000000 --- a/eth_test_parser/src/revm_builder/mod.rs +++ /dev/null @@ -1,37 +0,0 @@ -//! Utilities constructing an in-memory [`revm`](revm) environment from a -//! [`TestBody`](crate::deserialize::TestBody). -//! -//! Getting a fully constructed [`revm`](revm) environment requires the -//! following steps: -//! -//! 1. Construct an [`EVM`](revm::EVM) instance. -//! 2. Configure the instance's [`Env`](revm::primitives::Env). Note this -//! includes setting up the transaction we're testing at this step. -//! 3. Construct a [`Db`](revm::db::Database). In our case, an -//! [`InMemoryDB`](revm::InMemoryDB). -//! 4. Load the database with the accounts and their storage. - -use anyhow::Result; -use common::revm::SerializableEVMInstance; - -use crate::deserialize::TestBody; - -mod cache_db; -mod env; - -impl TestBody { - pub(crate) fn as_serializable_evm_instance(&self) -> Result { - let env = self.as_revm_env()?; - let db = self.as_revm_cache_db()?; - - Ok(SerializableEVMInstance { env, db }) - } -} - -impl TryFrom for SerializableEVMInstance { - type Error = anyhow::Error; - - fn try_from(body: TestBody) -> Result { - body.as_serializable_evm_instance() - } -} diff --git a/evm_test_runner/Cargo.toml b/evm_test_runner/Cargo.toml index 6ac6999..2ead679 100644 --- a/evm_test_runner/Cargo.toml +++ b/evm_test_runner/Cargo.toml @@ -29,8 +29,6 @@ serde_cbor = "0.11.2" termimad = "0.23.0" tokio = {version = "1.28.1", features = ["fs", "macros", "rt-multi-thread"] } tokio-stream = {version = "0.1.14", features = ["fs"] } -revm = "3.3.0" similar = { version = "2.2.1", features = ["inline"] } -ruint = { version = "1.8.0", features = ["primitive-types"] } keccak-hash = "0.10.0" console = "0.15.6"