From edacc636eea2a22a42aa018e37a78c213fa91e4a Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Fri, 26 Apr 2024 18:35:05 +0200 Subject: [PATCH 1/6] fix evm testing --- Cargo.lock | 3 +-- compiler_tester/Cargo.toml | 4 +++- .../vm/eravm/deployers/system_contract_deployer.rs | 6 ++++-- compiler_tester/src/vm/eravm/mod.rs | 14 ++++++++++++++ compiler_tester/src/vm/eravm/system_contracts.rs | 10 +++++++++- fuzzer/Cargo.toml | 3 ++- 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a0f6fb6..0b8bf98f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2947,7 +2947,6 @@ checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" [[package]] name = "zk_evm" version = "1.5.0" -source = "git+https://github.com/matter-labs/zk_evm?branch=v1.5.0#54fd09c8777b2c3b06ab088f96bbd6bd968f6737" dependencies = [ "anyhow", "lazy_static", @@ -3008,9 +3007,9 @@ dependencies = [ [[package]] name = "zkevm_tester" version = "1.5.0" -source = "git+https://github.com/matter-labs/era-zkevm_tester?branch=v1.5.0#6097d4bdc67474747e437b023354cc06bba767d5" dependencies = [ "anyhow", + "ethabi", "futures", "hex", "num-bigint", diff --git a/compiler_tester/Cargo.toml b/compiler_tester/Cargo.toml index 3a7d82df..2767d72b 100644 --- a/compiler_tester/Cargo.toml +++ b/compiler_tester/Cargo.toml @@ -42,7 +42,9 @@ evm = { git = "https://github.com/rust-ethereum/evm", branch = "master" } zkevm-assembly = { git = "https://github.com/matter-labs/era-zkEVM-assembly", branch = "v1.5.0" } zkevm_opcode_defs = { git = "https://github.com/matter-labs/era-zkevm_opcode_defs", branch = "v1.5.0" } -zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } +#zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } +zkevm_tester = { path = "../../era-zkevm_tester" } + vm2 = { git = "https://github.com/matter-labs/vm2", optional = true } era-compiler-common = { git = "https://github.com/matter-labs/era-compiler-common", branch = "main" } diff --git a/compiler_tester/src/vm/eravm/deployers/system_contract_deployer.rs b/compiler_tester/src/vm/eravm/deployers/system_contract_deployer.rs index 21df6acc..3f620323 100644 --- a/compiler_tester/src/vm/eravm/deployers/system_contract_deployer.rs +++ b/compiler_tester/src/vm/eravm/deployers/system_contract_deployer.rs @@ -211,13 +211,15 @@ impl EraVMDeployer for SystemContractDeployer { calldata.extend(init_code); calldata.extend(constructor_calldata); - vm.execute::( + let result = vm.execute::( test_name, entry_address, caller, Some(context_u128_value), calldata, Some(vm_launch_option), - ) + ); + + result } } diff --git a/compiler_tester/src/vm/eravm/mod.rs b/compiler_tester/src/vm/eravm/mod.rs index 2972015f..7246bcf3 100644 --- a/compiler_tester/src/vm/eravm/mod.rs +++ b/compiler_tester/src/vm/eravm/mod.rs @@ -19,6 +19,7 @@ use std::time::Duration; use std::time::Instant; use colored::Colorize; +use web3::ethabi::Hash; use crate::compilers::downloader::Downloader as CompilerDownloader; use crate::vm::execution_result::ExecutionResult; @@ -39,6 +40,8 @@ pub struct EraVM { evm_interpreter_code_hash: web3::types::U256, /// The deployed contracts. deployed_contracts: HashMap, + /// The published EVM bytecodes + published_evm_bytecodes: HashMap>, /// The storage state. storage: HashMap, } @@ -104,6 +107,7 @@ impl EraVM { evm_interpreter_code_hash: system_contracts.evm_interpreter.bytecode_hash, deployed_contracts: HashMap::new(), storage, + published_evm_bytecodes: HashMap::new(), }; vm.add_known_contract( @@ -234,6 +238,7 @@ impl EraVM { vm_launch_option, usize::MAX, self.known_contracts.clone(), + self.published_evm_bytecodes.clone(), self.default_aa_code_hash, self.evm_interpreter_code_hash, )?; @@ -246,6 +251,15 @@ impl EraVM { self.deployed_contracts .insert(*address, assembly.to_owned()); } + + for (hash, preimage) in snapshot.published_sha256_blobs.iter() { + if self.published_evm_bytecodes.contains_key(&hash) { + continue; + } + + self.published_evm_bytecodes.insert(*hash, preimage.clone()); + } + self.storage = snapshot.storage.clone(); Ok(snapshot.into()) diff --git a/compiler_tester/src/vm/eravm/system_contracts.rs b/compiler_tester/src/vm/eravm/system_contracts.rs index d296c290..11d4c029 100644 --- a/compiler_tester/src/vm/eravm/system_contracts.rs +++ b/compiler_tester/src/vm/eravm/system_contracts.rs @@ -101,6 +101,10 @@ impl SystemContracts { const PATH_EVENT_WRITER: &'static str = "era-contracts/system-contracts/contracts/EventWriter.yul"; + /// The code oracle system contract implementation path. + const CODE_ORACLE: &'static str = + "era-contracts/system-contracts/contracts/precompiles/CodeOracle.yul"; + /// The ETH token system contract implementation path. const PATH_ETH_TOKEN: &'static str = "era-contracts/system-contracts/contracts/L2EthToken.sol:L2EthToken"; @@ -179,6 +183,10 @@ impl SystemContracts { ), Self::PATH_EVENT_WRITER, ), + ( + web3::types::Address::from_low_u64_be(0x8012), + Self::CODE_ORACLE, + ), ]; let solidity_system_contracts = vec![ @@ -234,7 +242,7 @@ impl SystemContracts { Self::PATH_ETH_TOKEN, ), ( - web3::types::Address::from_low_u64_be(0x8012), + web3::types::Address::from_low_u64_be(0x8013), Self::PATH_EVM_GAS_MANAGER, ), ( diff --git a/fuzzer/Cargo.toml b/fuzzer/Cargo.toml index ee74dde5..d7ac0a58 100644 --- a/fuzzer/Cargo.toml +++ b/fuzzer/Cargo.toml @@ -26,7 +26,8 @@ anyhow = "1.0" semver = { version = "1.0", features = ["serde"] } zkevm-assembly = { git = "https://github.com/matter-labs/era-zkEVM-assembly", branch = "v1.5.0" } -zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } +#zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } +zkevm_tester = { path = "../../era-zkevm_tester" } era-compiler-llvm-context = { git = "https://github.com/matter-labs/era-compiler-llvm-context", branch = "v1.5.0" } era-compiler-solidity = { git = "https://github.com/matter-labs/era-compiler-solidity", branch = "v1.5.0" } From 4ce7d9f2b931ba08155e94bd987bfb6add45e056 Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Fri, 26 Apr 2024 19:42:51 +0200 Subject: [PATCH 2/6] correct deps --- Cargo.lock | 3 ++- compiler_tester/Cargo.toml | 4 ++-- fuzzer/Cargo.toml | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b8bf98f..31c8bc81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2947,6 +2947,7 @@ checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" [[package]] name = "zk_evm" version = "1.5.0" +source = "git+https://github.com/matter-labs/era-zk_evm?branch=v1.5.0#6119ce908ab714f2f99804794e725b97298a6b11" dependencies = [ "anyhow", "lazy_static", @@ -3007,9 +3008,9 @@ dependencies = [ [[package]] name = "zkevm_tester" version = "1.5.0" +source = "git+https://github.com/matter-labs/era-zkevm_tester?branch=v1.5.0#e52c562fbc8c1e6fa8171505b11b754f6d7ec989" dependencies = [ "anyhow", - "ethabi", "futures", "hex", "num-bigint", diff --git a/compiler_tester/Cargo.toml b/compiler_tester/Cargo.toml index 2767d72b..72d1aac5 100644 --- a/compiler_tester/Cargo.toml +++ b/compiler_tester/Cargo.toml @@ -42,8 +42,8 @@ evm = { git = "https://github.com/rust-ethereum/evm", branch = "master" } zkevm-assembly = { git = "https://github.com/matter-labs/era-zkEVM-assembly", branch = "v1.5.0" } zkevm_opcode_defs = { git = "https://github.com/matter-labs/era-zkevm_opcode_defs", branch = "v1.5.0" } -#zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } -zkevm_tester = { path = "../../era-zkevm_tester" } +zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } +#zkevm_tester = { path = "../../era-zkevm_tester" } vm2 = { git = "https://github.com/matter-labs/vm2", optional = true } diff --git a/fuzzer/Cargo.toml b/fuzzer/Cargo.toml index d7ac0a58..6699be08 100644 --- a/fuzzer/Cargo.toml +++ b/fuzzer/Cargo.toml @@ -26,8 +26,8 @@ anyhow = "1.0" semver = { version = "1.0", features = ["serde"] } zkevm-assembly = { git = "https://github.com/matter-labs/era-zkEVM-assembly", branch = "v1.5.0" } -#zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } -zkevm_tester = { path = "../../era-zkevm_tester" } +zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } +#zkevm_tester = { path = "../../era-zkevm_tester" } era-compiler-llvm-context = { git = "https://github.com/matter-labs/era-compiler-llvm-context", branch = "v1.5.0" } era-compiler-solidity = { git = "https://github.com/matter-labs/era-compiler-solidity", branch = "v1.5.0" } From 3efd6e977506e94e671fdc2781bc58eae698c34a Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Fri, 26 Apr 2024 19:43:24 +0200 Subject: [PATCH 3/6] fmt --- compiler_tester/src/vm/eravm/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler_tester/src/vm/eravm/mod.rs b/compiler_tester/src/vm/eravm/mod.rs index 7246bcf3..120a4ad7 100644 --- a/compiler_tester/src/vm/eravm/mod.rs +++ b/compiler_tester/src/vm/eravm/mod.rs @@ -41,7 +41,7 @@ pub struct EraVM { /// The deployed contracts. deployed_contracts: HashMap, /// The published EVM bytecodes - published_evm_bytecodes: HashMap>, + published_evm_bytecodes: HashMap>, /// The storage state. storage: HashMap, } From 97b98601c6aca72fd040f4ec4facae9b4157e750 Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Fri, 26 Apr 2024 19:44:57 +0200 Subject: [PATCH 4/6] cleanup --- compiler_tester/Cargo.toml | 1 - .../src/vm/eravm/deployers/system_contract_deployer.rs | 6 ++---- compiler_tester/src/vm/eravm/mod.rs | 1 - fuzzer/Cargo.toml | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/compiler_tester/Cargo.toml b/compiler_tester/Cargo.toml index 72d1aac5..2a46b6a4 100644 --- a/compiler_tester/Cargo.toml +++ b/compiler_tester/Cargo.toml @@ -43,7 +43,6 @@ evm = { git = "https://github.com/rust-ethereum/evm", branch = "master" } zkevm-assembly = { git = "https://github.com/matter-labs/era-zkEVM-assembly", branch = "v1.5.0" } zkevm_opcode_defs = { git = "https://github.com/matter-labs/era-zkevm_opcode_defs", branch = "v1.5.0" } zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } -#zkevm_tester = { path = "../../era-zkevm_tester" } vm2 = { git = "https://github.com/matter-labs/vm2", optional = true } diff --git a/compiler_tester/src/vm/eravm/deployers/system_contract_deployer.rs b/compiler_tester/src/vm/eravm/deployers/system_contract_deployer.rs index 3f620323..21df6acc 100644 --- a/compiler_tester/src/vm/eravm/deployers/system_contract_deployer.rs +++ b/compiler_tester/src/vm/eravm/deployers/system_contract_deployer.rs @@ -211,15 +211,13 @@ impl EraVMDeployer for SystemContractDeployer { calldata.extend(init_code); calldata.extend(constructor_calldata); - let result = vm.execute::( + vm.execute::( test_name, entry_address, caller, Some(context_u128_value), calldata, Some(vm_launch_option), - ); - - result + ) } } diff --git a/compiler_tester/src/vm/eravm/mod.rs b/compiler_tester/src/vm/eravm/mod.rs index 120a4ad7..5d3df9d4 100644 --- a/compiler_tester/src/vm/eravm/mod.rs +++ b/compiler_tester/src/vm/eravm/mod.rs @@ -19,7 +19,6 @@ use std::time::Duration; use std::time::Instant; use colored::Colorize; -use web3::ethabi::Hash; use crate::compilers::downloader::Downloader as CompilerDownloader; use crate::vm::execution_result::ExecutionResult; diff --git a/fuzzer/Cargo.toml b/fuzzer/Cargo.toml index 6699be08..ee74dde5 100644 --- a/fuzzer/Cargo.toml +++ b/fuzzer/Cargo.toml @@ -27,7 +27,6 @@ semver = { version = "1.0", features = ["serde"] } zkevm-assembly = { git = "https://github.com/matter-labs/era-zkEVM-assembly", branch = "v1.5.0" } zkevm_tester = { git = "https://github.com/matter-labs/era-zkevm_tester", branch = "v1.5.0" } -#zkevm_tester = { path = "../../era-zkevm_tester" } era-compiler-llvm-context = { git = "https://github.com/matter-labs/era-compiler-llvm-context", branch = "v1.5.0" } era-compiler-solidity = { git = "https://github.com/matter-labs/era-compiler-solidity", branch = "v1.5.0" } From 941e407feba1f0fa1b81c2c34e0eb966891ae982 Mon Sep 17 00:00:00 2001 From: Oleksandr Zarudnyi Date: Sat, 27 Apr 2024 01:12:59 +0700 Subject: [PATCH 5/6] fix: update branches --- Cargo.lock | 33 +++++++++++++++++---------------- system-contracts-stable-build | Bin 720691 -> 724735 bytes 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31c8bc81..fd625a72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1262,9 +1262,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -1490,9 +1490,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -1500,15 +1500,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -1778,11 +1778,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", ] [[package]] @@ -1944,9 +1944,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.11" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", @@ -2591,7 +2591,7 @@ checksum = "2266fcb904c50fb17fda4c9a751a1715629ecf8b21f4c9d78b4890fb71525d71" [[package]] name = "vm2" version = "0.1.0" -source = "git+https://github.com/matter-labs/vm2#f38b8f536168a24c5fb38b0d56f309b228cf3c58" +source = "git+https://github.com/matter-labs/vm2#1bc69da6137757ec22ccf8c3d477a1510150bc65" dependencies = [ "enum_dispatch", "primitive-types", @@ -2758,9 +2758,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134306a13c5647ad6453e8deaec55d3a44d6021970129e6188735e74bf546697" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ "windows-sys 0.52.0", ] @@ -3008,9 +3008,10 @@ dependencies = [ [[package]] name = "zkevm_tester" version = "1.5.0" -source = "git+https://github.com/matter-labs/era-zkevm_tester?branch=v1.5.0#e52c562fbc8c1e6fa8171505b11b754f6d7ec989" +source = "git+https://github.com/matter-labs/era-zkevm_tester?branch=v1.5.0#488ca0782fea1eb9af7ff82d252d54af3471f33e" dependencies = [ "anyhow", + "ethabi", "futures", "hex", "num-bigint", diff --git a/system-contracts-stable-build b/system-contracts-stable-build index 02c3885822f7d362e509d083cf1a7faf545a85c5..efaedc08cf0809888d9bc9165c818e8b3389d2a6 100644 GIT binary patch delta 832 zcmb7?Pe>F|9LITYW_ISSu8yv*8m;XJf|RW@Z+7;N8ZBmENLgW*AZ!1OTCKXRnG~_; zL5iX-Q~VAoVh~Y>P{Q^SSQ(wdR--&62!U6lL$xl|th*;q1@C+L{T}aqKEL;#|K9g! zsu9`8(F8IVoqCY>RpLYB&I`8g?VmpnJvc3 z83mgpx2;j=#T5zv0Wzdzum8n}9yn^6+DJLoG|u@+l9Q4Uf}BTWn;b3 z?o+HJG#HhLSJPCj(Unkgv6A8bn0uJeLV;RIY^cv2)gwa#1LrT3gbHOpI6J)DOPu0` zk%72dzeIw02nAkk@KwlUX=0ql^%=qFy;}leR#w)V1BXSU-8Omb!{W_UA#8IpoY>ty&ZL8=K8 delta 61 zcmexAS7-A-ZAPI+##TlkVrpe%-pa@_^}_TMb6EMeFTKF>>2!PY8de}?17da{<^W>O L?a6Dn<|F|C<^mYZ From 3a77136692cdc294f583668c6cebb7e943c29bba Mon Sep 17 00:00:00 2001 From: Oleksandr Zarudnyi Date: Fri, 26 Apr 2024 20:14:33 +0200 Subject: [PATCH 6/6] Update system_contracts.rs --- compiler_tester/src/vm/eravm/system_contracts.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler_tester/src/vm/eravm/system_contracts.rs b/compiler_tester/src/vm/eravm/system_contracts.rs index 11d4c029..17847cf5 100644 --- a/compiler_tester/src/vm/eravm/system_contracts.rs +++ b/compiler_tester/src/vm/eravm/system_contracts.rs @@ -102,7 +102,7 @@ impl SystemContracts { "era-contracts/system-contracts/contracts/EventWriter.yul"; /// The code oracle system contract implementation path. - const CODE_ORACLE: &'static str = + const PATH_CODE_ORACLE: &'static str = "era-contracts/system-contracts/contracts/precompiles/CodeOracle.yul"; /// The ETH token system contract implementation path. @@ -185,7 +185,7 @@ impl SystemContracts { ), ( web3::types::Address::from_low_u64_be(0x8012), - Self::CODE_ORACLE, + Self::PATH_CODE_ORACLE, ), ];