diff --git a/compiler_tester/src/directories/matter_labs/test/metadata/case/mod.rs b/compiler_tester/src/directories/matter_labs/test/metadata/case/mod.rs index 3520e0b8..55fc44fb 100644 --- a/compiler_tester/src/directories/matter_labs/test/metadata/case/mod.rs +++ b/compiler_tester/src/directories/matter_labs/test/metadata/case/mod.rs @@ -102,7 +102,7 @@ impl Case { continue; } - if name != "BenchmarkCaller" + if name != "Benchmark" && name.split('_').next().unwrap_or_default() != self.name.split('_').next().unwrap_or_default() { diff --git a/compiler_tester/src/directories/matter_labs/test/mod.rs b/compiler_tester/src/directories/matter_labs/test/mod.rs index 23fa3f9c..aa049fdb 100644 --- a/compiler_tester/src/directories/matter_labs/test/mod.rs +++ b/compiler_tester/src/directories/matter_labs/test/mod.rs @@ -210,7 +210,7 @@ impl MatterLabsTest { } /// - /// Adds the BenchmarkCaller contract as a proxy for the EVM interpreter. + /// Adds the Benchmark contract as a proxy for the EVM interpreter. /// fn push_benchmark_caller( &self, @@ -218,15 +218,15 @@ impl MatterLabsTest { contracts: &mut BTreeMap, ) -> anyhow::Result<()> { let benchmark_caller_string = std::fs::read_to_string(PathBuf::from( - "tests/solidity/complex/interpreter/BenchmarkCaller.sol", + "tests/solidity/complex/interpreter/Benchmark.sol", ))?; sources.push(( - "tests/solidity/complex/interpreter/BenchmarkCaller.sol".to_owned(), + "tests/solidity/complex/interpreter/Benchmark.sol".to_owned(), benchmark_caller_string, )); // TODO contracts.insert( - "BenchmarkCaller".to_owned(), - "tests/solidity/complex/interpreter/BenchmarkCaller.sol:BenchmarkCaller".to_owned(), + "Benchmark".to_owned(), + "tests/solidity/complex/interpreter/Benchmark.sol:Benchmark".to_owned(), ); Ok(()) } @@ -333,7 +333,7 @@ impl MatterLabsTest { caller: default_caller_address(), method: "benchmark".to_owned(), calldata: MatterLabsCaseInputCalldata::List(vec![ - "BenchmarkCaller.address".to_owned(), + "Benchmark.address".to_owned(), format!("{template}.address"), ]), value: None, @@ -348,7 +348,7 @@ impl MatterLabsTest { caller: default_caller_address(), method: "benchmark".to_owned(), calldata: MatterLabsCaseInputCalldata::List(vec![ - "BenchmarkCaller.address".to_owned(), + "Benchmark.address".to_owned(), format!("{full}.address"), ]), value: None, @@ -363,7 +363,7 @@ impl MatterLabsTest { caller: default_caller_address(), method: "benchmark".to_owned(), calldata: MatterLabsCaseInputCalldata::List(vec![ - "BenchmarkCaller.address".to_owned(), + "Benchmark.address".to_owned(), format!("{template}.address"), ]), value: None, @@ -378,7 +378,7 @@ impl MatterLabsTest { caller: default_caller_address(), method: "benchmark".to_owned(), calldata: MatterLabsCaseInputCalldata::List(vec![ - "BenchmarkCaller.address".to_owned(), + "Benchmark.address".to_owned(), format!("{full}.address"), ]), value: None, diff --git a/compiler_tester/src/test/case/input/runtime.rs b/compiler_tester/src/test/case/input/runtime.rs index afcbf001..2f3d0b45 100644 --- a/compiler_tester/src/test/case/input/runtime.rs +++ b/compiler_tester/src/test/case/input/runtime.rs @@ -197,16 +197,21 @@ impl Runtime { let benchmark_caller_address = web3::types::Address::from_str(EraVM::DEFAULT_BENCHMARK_CALLER_ADDRESS) .expect("Always valid"); + let evm_proxy_address = + web3::types::Address::from_low_u64_be(0x10000); let mut calldata = - Vec::with_capacity(era_compiler_common::BYTE_LENGTH_FIELD + self.calldata.inner.len()); + Vec::with_capacity(era_compiler_common::BYTE_LENGTH_X32 + (era_compiler_common::BYTE_LENGTH_FIELD * 2) + self.calldata.inner.len()); + calldata.extend(crate::utils::selector("benchmark(address,address)")); + calldata.extend([0u8; era_compiler_common::BYTE_LENGTH_FIELD - BYTE_LENGTH_ETH_ADDRESS]); + calldata.extend(benchmark_caller_address.as_bytes()); calldata.extend([0u8; era_compiler_common::BYTE_LENGTH_FIELD - BYTE_LENGTH_ETH_ADDRESS]); calldata.extend(self.address.as_bytes()); calldata.extend(self.calldata.inner); let mut result = match vm.execute::( name.clone(), - benchmark_caller_address, + evm_proxy_address, self.caller, self.value, calldata.clone(), diff --git a/compiler_tester/src/vm/eravm/system_contracts.rs b/compiler_tester/src/vm/eravm/system_contracts.rs index 5bcb6def..b3086df0 100644 --- a/compiler_tester/src/vm/eravm/system_contracts.rs +++ b/compiler_tester/src/vm/eravm/system_contracts.rs @@ -109,6 +109,10 @@ impl SystemContracts { const PATH_EVM_GAS_MANAGER: &'static str = "era-contracts/system-contracts/contracts/EvmGasManager.sol:EvmGasManager"; + /// The EVM proxy temporary system contract implementation path. + const PATH_EVM_PROXY: &'static str = + "tests/solidity/complex/interpreter/Proxy.sol:Proxy"; + /// /// Loads or builds the system contracts. /// @@ -234,6 +238,10 @@ impl SystemContracts { web3::types::Address::from_low_u64_be(0x8012), Self::PATH_EVM_GAS_MANAGER, ), + ( + web3::types::Address::from_low_u64_be(0x10000), + Self::PATH_EVM_PROXY, + ), ]; let mut yul_file_paths = Vec::with_capacity(yul_system_contracts.len() + 1); @@ -252,12 +260,15 @@ impl SystemContracts { let file_path = path.split(':').next().expect("Always valid"); solidity_file_paths.push(file_path.to_owned()); } - for path in glob::glob("era-contracts/system-contracts/**/*.sol")?.filter_map(Result::ok) { - let path = path.to_string_lossy().to_string(); - if !solidity_file_paths.contains(&path) { - solidity_file_paths.push(path); + for pattern in ["era-contracts/system-contracts/**/*.sol", "tests/solidity/complex/interpreter/*.sol"] { + for path in glob::glob(pattern)?.filter_map(Result::ok) { + let path = path.to_string_lossy().to_string(); + if !solidity_file_paths.contains(&path) { + solidity_file_paths.push(path); + } } } + let solidity_optimizer_settings = era_compiler_llvm_context::OptimizerSettings::evm_interpreter(); let solidity_mode = SolidityMode::new( diff --git a/system-contracts-stable-build b/system-contracts-stable-build index ad207b12..6641e083 100644 Binary files a/system-contracts-stable-build and b/system-contracts-stable-build differ diff --git a/tests b/tests index 9f476b5d..4427fca4 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 9f476b5df98e2791eaf4b66d0a542f4536529620 +Subproject commit 4427fca456f938d4f334ce5130a71e09abd3e217