From b1ed8c09ef1ec1e148f728d8359d3f24776185fc Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Tue, 22 Oct 2024 19:07:14 +0200 Subject: [PATCH] Adapt for optional evm emulation --- compiler_tester/src/vm/eravm/mod.rs | 15 ++++++++++++++- era-contracts | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/compiler_tester/src/vm/eravm/mod.rs b/compiler_tester/src/vm/eravm/mod.rs index 5cd6c8f9..aa4a0bfd 100644 --- a/compiler_tester/src/vm/eravm/mod.rs +++ b/compiler_tester/src/vm/eravm/mod.rs @@ -21,6 +21,7 @@ use std::time::Instant; use colored::Colorize; use solidity_adapter::EVMVersion; +use zkevm_opcode_defs::ADDRESS_CONTRACT_DEPLOYER; use crate::vm::execution_result::ExecutionResult; @@ -59,6 +60,9 @@ impl EraVM { /// The extra amount of gas consumed by every call to the EVM interpreter. pub const EVM_INTERPRETER_GAS_OVERHEAD: u64 = 2500; + /// The `allowedBytecodesToDeploy` variable storage slot in the `ContractDeployer` contract. + pub const CONTRACT_DEPLOYER_ALLOWED_BYTECODES_MODE_SLOT: u64 = 2; + /// The `passGas` variable transient storage slot in the `EvmGasManager` contract. pub const EVM_GAS_MANAGER_GAS_TRANSIENT_SLOT: u64 = 4; @@ -122,9 +126,18 @@ impl EraVM { system_contracts_save_path, )?; - let storage = SystemContext::create_storage(target); + let mut storage = SystemContext::create_storage(target); let storage_transient = HashMap::new(); + // TODO move to the SystemContext after EVM emulator is ready + storage.insert( + zkevm_tester::compiler_tests::StorageKey { + address: web3::types::Address::from_low_u64_be(ADDRESS_CONTRACT_DEPLOYER.into()), + key: web3::types::U256::from(Self::CONTRACT_DEPLOYER_ALLOWED_BYTECODES_MODE_SLOT), + }, + web3::types::H256::from_low_u64_be(1), // Allow EVM contracts deployment + ); + let mut vm = Self { known_contracts: HashMap::new(), default_aa_code_hash: web3::types::U256::from_big_endian( diff --git a/era-contracts b/era-contracts index 31465df1..9923376b 160000 --- a/era-contracts +++ b/era-contracts @@ -1 +1 @@ -Subproject commit 31465df18b212c420c288bf8c05af7b47046a369 +Subproject commit 9923376b963d33fc113461ca53fceda57d784f69