Skip to content

Commit

Permalink
Add evm simulator as optional for the server
Browse files Browse the repository at this point in the history
  • Loading branch information
IAvecilla committed Sep 11, 2024
1 parent 6cae61a commit 45bde69
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
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,
}
10 changes: 9 additions & 1 deletion core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use ethabi::{
};
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use zksync_config::configs::use_evm_simulator::UseEvmSimulator;
use zksync_env_config::FromEnv;
use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, env::Workspace};

pub mod test_contracts;
Expand Down Expand Up @@ -342,10 +344,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

0 comments on commit 45bde69

Please sign in to comment.