Skip to content

Commit

Permalink
Adapt for optional evm emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov committed Oct 22, 2024
1 parent 237ff47 commit b3a10f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion compiler_tester/src/vm/eravm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit b3a10f5

Please sign in to comment.