Skip to content

Commit

Permalink
EVM Simulator Flag (#244)
Browse files Browse the repository at this point in the history
* Add initial use evm interpreter flag

* Add use evm simulator flag to toml

* Update hashes

* Delete Storage.sol

* Update hashes

* Change hashes
  • Loading branch information
gianbelinche authored Aug 30, 2024
1 parent 06b88c6 commit 35440d7
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 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 core/lib/config/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub mod pruning;
pub mod secrets;
pub mod snapshot_recovery;
pub mod snapshots_creator;
pub mod use_evm_simulator;
pub mod utils;
pub mod vm_runner;
pub mod wallets;
Expand Down
7 changes: 7 additions & 0 deletions core/lib/config/src/configs/use_evm_simulator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use serde::Deserialize;

/// Configuration for the use evm simulator
#[derive(Debug, Deserialize, Clone, PartialEq)]
pub struct UseEvmSimulator {
pub use_evm_simulator: bool,
}
2 changes: 2 additions & 0 deletions core/lib/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ categories.workspace = true

[dependencies]
zksync_utils.workspace = true
zksync_config.workspace = true
zksync_env_config.workspace = true

ethabi.workspace = true
serde_json.workspace = true
Expand Down
13 changes: 12 additions & 1 deletion core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ use ethabi::{
};
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use zksync_config::configs::{
house_keeper::HouseKeeperConfig,
use_evm_simulator::{self, UseEvmSimulator},
};
use zksync_env_config::FromEnv;
use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, workspace_dir_or_current_dir};

pub mod test_contracts;
Expand Down Expand Up @@ -342,10 +347,16 @@ impl BaseSystemContracts {
hash,
};

let evm_simulator_bytecode =
let mut evm_simulator_bytecode =
read_sys_contract_bytecode("", "EvmInterpreter", ContractLanguage::Yul);
let evm_simulator_hash = hash_bytecode(&evm_simulator_bytecode);

let use_evm_simulator =
UseEvmSimulator::from_env().expect("USE EVM SIMULATOR FLAG SHOULD BE SET");
if !use_evm_simulator.use_evm_simulator {
evm_simulator_bytecode = vec![];
}

let evm_simulator = SystemContractCode {
code: bytes_to_be_words(evm_simulator_bytecode),
hash: evm_simulator_hash,
Expand Down
1 change: 1 addition & 0 deletions core/lib/env_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mod genesis;
mod prover_job_monitor;
#[cfg(test)]
mod test_utils;
mod use_evm_simulator;
mod vm_runner;
mod wallets;

Expand Down
9 changes: 9 additions & 0 deletions core/lib/env_config/src/use_evm_simulator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use zksync_config::configs::use_evm_simulator::UseEvmSimulator;

use crate::{envy_load, FromEnv};

impl FromEnv for UseEvmSimulator {
fn from_env() -> anyhow::Result<Self> {
envy_load("use_evm_simulator", "USE_EVM_SIMULATOR_")
}
}
2 changes: 2 additions & 0 deletions etc/env/base/use_evm_simulator.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[use_evm_simulator]
use_evm_simulator = true
2 changes: 2 additions & 0 deletions prover/Cargo.lock

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

0 comments on commit 35440d7

Please sign in to comment.