Skip to content

Commit

Permalink
fix evm testing
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Apr 26, 2024
1 parent 9490c91 commit edacc63
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion compiler_tester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,15 @@ impl EraVMDeployer for SystemContractDeployer {
calldata.extend(init_code);
calldata.extend(constructor_calldata);

vm.execute::<M>(
let result = vm.execute::<M>(
test_name,
entry_address,
caller,
Some(context_u128_value),
calldata,
Some(vm_launch_option),
)
);

result
}
}
14 changes: 14 additions & 0 deletions compiler_tester/src/vm/eravm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,6 +40,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 +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(
Expand Down Expand Up @@ -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,
)?;
Expand All @@ -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())
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 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::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
3 changes: 2 additions & 1 deletion fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit edacc63

Please sign in to comment.