Skip to content

Commit

Permalink
fix: EVM interpreter testing (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: Oleksandr Zarudnyi <[email protected]>
  • Loading branch information
StanislavBreadless and hedgar2017 authored Apr 26, 2024
1 parent 9490c91 commit e56dbbb
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
35 changes: 18 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions compiler_tester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ 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" }

vm2 = { git = "https://github.com/matter-labs/vm2", optional = true }

era-compiler-common = { git = "https://github.com/matter-labs/era-compiler-common", branch = "main" }
Expand Down
13 changes: 13 additions & 0 deletions compiler_tester/src/vm/eravm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub struct EraVM {
evm_interpreter_code_hash: web3::types::U256,
/// The deployed contracts.
deployed_contracts: HashMap<web3::types::Address, zkevm_assembly::Assembly>,
/// The published EVM bytecodes
published_evm_bytecodes: HashMap<web3::types::U256, Vec<web3::types::U256>>,
/// The storage state.
storage: HashMap<zkevm_tester::runners::compiler_tests::StorageKey, web3::types::H256>,
}
Expand Down Expand Up @@ -104,6 +106,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(
Expand Down Expand Up @@ -234,6 +237,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,
)?;
Expand All @@ -246,6 +250,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())
Expand Down
10 changes: 9 additions & 1 deletion compiler_tester/src/vm/eravm/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 PATH_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";
Expand Down Expand Up @@ -179,6 +183,10 @@ impl SystemContracts {
),
Self::PATH_EVENT_WRITER,
),
(
web3::types::Address::from_low_u64_be(0x8012),
Self::PATH_CODE_ORACLE,
),
];

let solidity_system_contracts = vec![
Expand Down Expand Up @@ -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,
),
(
Expand Down
Binary file modified system-contracts-stable-build
Binary file not shown.

0 comments on commit e56dbbb

Please sign in to comment.