Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make evm simulator optional for the server #257

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading