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(vm): Extract VM interface to separate crate #2638

Merged
merged 17 commits into from
Aug 13, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 17 additions & 11 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ members = [
"core/lib/utils",
"core/lib/vlog",
"core/lib/multivm",
"core/lib/vm_interface",
"core/lib/vm_utils",
"core/lib/web3_decl",
"core/lib/snapshots_applier",
Expand Down Expand Up @@ -234,6 +235,7 @@ zksync_protobuf_build = "=0.1.0-rc.9"
zksync_multivm = { version = "0.1.0", path = "core/lib/multivm" }
zksync_prover_dal = { version = "0.1.0", path = "prover/crates/lib/prover_dal" }
zksync_vlog = { version = "0.1.0", path = "core/lib/vlog" }
zksync_vm_interface = { version = "0.1.0", path = "core/lib/vm_interface" }
zksync_vm_utils = { version = "0.1.0", path = "core/lib/vm_utils" }
zksync_vm_benchmark_harness = { version = "0.1.0", path = "core/tests/vm-benchmark/harness" }
zksync_basic_types = { version = "0.1.0", path = "core/lib/basic_types" }
Expand Down
1 change: 0 additions & 1 deletion core/bin/system-constants-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ categories.workspace = true
publish = false

[dependencies]
zksync_state.workspace = true
zksync_types.workspace = true
zksync_utils.workspace = true
zksync_contracts.workspace = true
Expand Down
8 changes: 5 additions & 3 deletions core/bin/system-constants-generator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ use zksync_contracts::{
};
use zksync_multivm::{
interface::{
dyn_tracers::vm_1_5_0::DynTracer, tracer::VmExecutionStopReason, L1BatchEnv, L2BlockEnv,
SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory, VmInterface,
storage::{InMemoryStorage, StorageView, WriteStorage},
tracer::VmExecutionStopReason,
L1BatchEnv, L2BlockEnv, SystemEnv, TxExecutionMode, VmExecutionMode, VmFactory,
VmInterface,
},
tracers::dynamic::vm_1_5_0::DynTracer,
vm_latest::{
constants::{BATCH_COMPUTATIONAL_GAS_LIMIT, BOOTLOADER_HEAP_PAGE},
BootloaderState, HistoryEnabled, HistoryMode, SimpleMemory, ToTracerPointer, Vm, VmTracer,
ZkSyncVmState,
},
zk_evm_latest::aux_structures::Timestamp,
};
use zksync_state::{InMemoryStorage, StorageView, WriteStorage};
use zksync_types::{
block::L2BlockHasher, ethabi::Token, fee::Fee, fee_model::BatchFeeInput, l1::L1Tx, l2::L2Tx,
utils::storage_key_for_eth_balance, AccountTreeId, Address, Execute, K256PrivateKey,
Expand Down
4 changes: 1 addition & 3 deletions core/lib/multivm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@ circuit_sequencer_api_1_4_2.workspace = true
circuit_sequencer_api_1_5_0.workspace = true

zksync_types.workspace = true
zksync_state.workspace = true
zksync_contracts.workspace = true
zksync_utils.workspace = true
zksync_system_constants.workspace = true

zksync_vm_interface.workspace = true

anyhow.workspace = true
hex.workspace = true
itertools.workspace = true
once_cell.workspace = true
pretty_assertions.workspace = true
serde.workspace = true
thiserror.workspace = true
tracing.workspace = true
vise.workspace = true
Expand Down
10 changes: 5 additions & 5 deletions core/lib/multivm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# External node's VM
# ZKsync Era VM Wrapper

This crate represents a wrapper over several versions of VM that have been used by the main node. It contains the glue
code that allows switching the VM version based on the externally provided marker while preserving the public interface.
This crate exists to enable the external node to process breaking upgrades and re-execute all the transactions from the
genesis block.
This crate represents a wrapper over several versions of VM that have been used by the ZKsync Era node. It contains the
glue code that allows switching the VM version based on the externally provided marker while preserving the public
interface. This crate exists to enable the external node to process breaking upgrades and re-execute all the
transactions from the genesis block.
4 changes: 1 addition & 3 deletions core/lib/multivm/src/glue/tracers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
//! - Add this trait as a trait bound for `T` in `MultiVMTracer` implementation.
//! - Implement the trait for `T` with a bound to `VmTracer` for a specific version.

use zksync_state::WriteStorage;

use crate::{tracers::old_tracers::OldTracers, HistoryMode};
use crate::{interface::storage::WriteStorage, tracers::old::OldTracers, HistoryMode};

pub type MultiVmTracerPointer<S, H> = Box<dyn MultiVMTracer<S, H>>;

Expand Down
4 changes: 2 additions & 2 deletions core/lib/multivm/src/glue/types/vm/vm_block_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use zksync_types::l2_to_l1_log::UserL2ToL1Log;
use crate::{
glue::{GlueFrom, GlueInto},
interface::{
types::outputs::VmExecutionLogs, CurrentExecutionState, ExecutionResult, Refunds,
VmExecutionResultAndLogs, VmExecutionStatistics,
CurrentExecutionState, ExecutionResult, Refunds, VmExecutionLogs, VmExecutionResultAndLogs,
VmExecutionStatistics,
},
};

Expand Down
2 changes: 0 additions & 2 deletions core/lib/multivm/src/interface/traits/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion core/lib/multivm/src/interface/traits/tracers/mod.rs

This file was deleted.

11 changes: 0 additions & 11 deletions core/lib/multivm/src/interface/types/errors/mod.rs

This file was deleted.

9 changes: 0 additions & 9 deletions core/lib/multivm/src/interface/types/inputs/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion core/lib/multivm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
pub use circuit_sequencer_api_1_5_0 as circuit_sequencer_api_latest;
pub use zk_evm_1_5_0 as zk_evm_latest;
pub use zksync_types::vm::VmVersion;
pub use zksync_vm_interface as interface;

pub use crate::{
glue::{
Expand All @@ -19,7 +20,6 @@ pub use crate::{
};

mod glue;
pub mod interface;
pub mod tracers;
pub mod utils;
pub mod versions;
Expand Down
4 changes: 2 additions & 2 deletions core/lib/multivm/src/tracers/call_tracer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl CallTracer {
}

impl IntoOldVmTracer for CallTracer {
fn old_tracer(&self) -> crate::tracers::old_tracers::OldTracers {
crate::tracers::old_tracers::OldTracers::CallTracer(self.result.clone())
fn old_tracer(&self) -> crate::tracers::old::OldTracers {
crate::tracers::old::OldTracers::CallTracer(self.result.clone())
}
}
6 changes: 3 additions & 3 deletions core/lib/multivm/src/tracers/call_tracer/vm_1_4_1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use zk_evm_1_4_1::{
RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER,
},
};
use zksync_state::{StoragePtr, WriteStorage};
use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS;
use zksync_types::{
vm_trace::{Call, CallType},
Expand All @@ -16,10 +15,11 @@ use zksync_types::{
use crate::{
glue::GlueInto,
interface::{
tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_4_1::DynTracer,
storage::{StoragePtr, WriteStorage},
tracer::VmExecutionStopReason,
VmRevertReason,
},
tracers::call_tracer::CallTracer,
tracers::{dynamic::vm_1_4_1::DynTracer, CallTracer},
vm_1_4_1::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState},
};

Expand Down
6 changes: 3 additions & 3 deletions core/lib/multivm/src/tracers/call_tracer/vm_1_4_2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use zk_evm_1_4_1::{
RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER,
},
};
use zksync_state::{StoragePtr, WriteStorage};
use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS;
use zksync_types::{
vm_trace::{Call, CallType},
Expand All @@ -16,10 +15,11 @@ use zksync_types::{
use crate::{
glue::GlueInto,
interface::{
tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_4_1::DynTracer,
storage::{StoragePtr, WriteStorage},
tracer::VmExecutionStopReason,
VmRevertReason,
},
tracers::call_tracer::CallTracer,
tracers::{dynamic::vm_1_4_1::DynTracer, CallTracer},
vm_1_4_2::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use zk_evm_1_4_0::{
RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER,
},
};
use zksync_state::{StoragePtr, WriteStorage};
use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS;
use zksync_types::{
vm_trace::{Call, CallType},
Expand All @@ -16,10 +15,11 @@ use zksync_types::{
use crate::{
glue::GlueInto,
interface::{
tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_4_0::DynTracer,
storage::{StoragePtr, WriteStorage},
tracer::VmExecutionStopReason,
VmRevertReason,
},
tracers::call_tracer::CallTracer,
tracers::{dynamic::vm_1_4_0::DynTracer, CallTracer},
vm_boojum_integration::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState},
};

Expand Down
6 changes: 3 additions & 3 deletions core/lib/multivm/src/tracers/call_tracer/vm_latest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use zk_evm_1_5_0::{
RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER,
},
};
use zksync_state::{StoragePtr, WriteStorage};
use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS;
use zksync_types::{
vm_trace::{Call, CallType},
Expand All @@ -16,10 +15,11 @@ use zksync_types::{
use crate::{
glue::GlueInto,
interface::{
tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_5_0::DynTracer,
storage::{StoragePtr, WriteStorage},
tracer::VmExecutionStopReason,
VmRevertReason,
},
tracers::call_tracer::CallTracer,
tracers::{dynamic::vm_1_5_0::DynTracer, CallTracer},
vm_latest::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use zk_evm_1_3_3::{
RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER,
},
};
use zksync_state::{StoragePtr, WriteStorage};
use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS;
use zksync_types::{
vm_trace::{Call, CallType},
Expand All @@ -16,10 +15,11 @@ use zksync_types::{
use crate::{
glue::GlueInto,
interface::{
tracer::VmExecutionStopReason, traits::tracers::dyn_tracers::vm_1_3_3::DynTracer,
storage::{StoragePtr, WriteStorage},
tracer::VmExecutionStopReason,
VmRevertReason,
},
tracers::call_tracer::CallTracer,
tracers::{dynamic::vm_1_3_3::DynTracer, CallTracer},
vm_refunds_enhancement::{BootloaderState, HistoryMode, SimpleMemory, VmTracer, ZkSyncVmState},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use zk_evm_1_3_3::{
RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER,
},
};
use zksync_state::{StoragePtr, WriteStorage};
use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS;
use zksync_types::{
vm_trace::{Call, CallType},
Expand All @@ -15,8 +14,11 @@ use zksync_types::{

use crate::{
glue::GlueInto,
interface::{dyn_tracers::vm_1_3_3::DynTracer, VmExecutionResultAndLogs, VmRevertReason},
tracers::call_tracer::CallTracer,
interface::{
storage::{StoragePtr, WriteStorage},
VmExecutionResultAndLogs, VmRevertReason,
},
tracers::{dynamic::vm_1_3_3::DynTracer, CallTracer},
vm_virtual_blocks::{
ExecutionEndTracer, ExecutionProcessing, HistoryMode, SimpleMemory, VmTracer,
},
Expand Down
Loading
Loading