Skip to content

Commit 65e37ba

Browse files
committed
Add new era_vm module to multivm crate
1 parent 86c9657 commit 65e37ba

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed

core/lib/multivm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub use zk_evm_1_5_0 as zk_evm_latest;
77
pub use zksync_types::vm_version::VmVersion;
88

99
pub use self::versions::{
10-
vm_1_3_2, vm_1_4_1, vm_1_4_2, vm_boojum_integration, vm_latest, vm_m5, vm_m6,
10+
era_vm, vm_1_3_2, vm_1_4_1, vm_1_4_2, vm_boojum_integration, vm_latest, vm_m5, vm_m6,
1111
vm_refunds_enhancement, vm_virtual_blocks,
1212
};
1313
pub use crate::{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod vm;
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
use era_vm::VMState;
2+
use zksync_state::{ReadStorage, StoragePtr};
3+
use zksync_types::Transaction;
4+
use zksync_utils::bytecode::CompressedBytecodeInfo;
5+
6+
use crate::{
7+
interface::{VmInterface, VmInterfaceHistoryEnabled},
8+
vm_latest,
9+
vm_latest::{
10+
BootloaderMemory, CurrentExecutionState, ExecutionResult, HistoryEnabled, L1BatchEnv,
11+
L2BlockEnv, SystemEnv, VmExecutionLogs, VmExecutionMode, VmExecutionResultAndLogs,
12+
},
13+
};
14+
15+
pub struct Vm<S: ReadStorage> {
16+
pub(crate) inner: VMState,
17+
suspended_at: u16,
18+
gas_for_account_validation: u32,
19+
last_tx_result: Option<ExecutionResult>,
20+
21+
bootloader_state: BootloaderState, // TODO: Implement bootloader state logic
22+
pub(crate) storage: StoragePtr<S>,
23+
24+
// TODO: Maybe not necessary, check
25+
// program_cache: Rc<RefCell<HashMap<U256, Program>>>,
26+
27+
// these two are only needed for tests so far
28+
pub(crate) batch_env: L1BatchEnv,
29+
pub(crate) system_env: SystemEnv,
30+
31+
snapshots: Vec<VmSnapshot>, // TODO: Implement snapshots logic
32+
}
33+
34+
impl<S: ReadStorage + 'static> VmInterface<S, HistoryEnabled> for Vm<S> {
35+
type TracerDispatcher = ();
36+
37+
fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr<S>) -> Self {
38+
todo!()
39+
}
40+
41+
fn push_transaction(&mut self, tx: Transaction) {
42+
todo!()
43+
}
44+
45+
fn inspect(
46+
&mut self,
47+
_tracer: Self::TracerDispatcher,
48+
_execution_mode: VmExecutionMode,
49+
) -> VmExecutionResultAndLogs {
50+
todo!()
51+
}
52+
53+
fn get_bootloader_memory(&self) -> BootloaderMemory {
54+
todo!()
55+
}
56+
57+
fn get_last_tx_compressed_bytecodes(&self) -> Vec<CompressedBytecodeInfo> {
58+
todo!()
59+
}
60+
61+
fn start_new_l2_block(&mut self, l2_block_env: L2BlockEnv) {
62+
todo!()
63+
}
64+
65+
fn get_current_execution_state(&self) -> CurrentExecutionState {
66+
todo!()
67+
}
68+
69+
fn inspect_transaction_with_bytecode_compression(
70+
&mut self,
71+
tracer: Self::TracerDispatcher,
72+
tx: zksync_types::Transaction,
73+
with_compression: bool,
74+
) -> (
75+
Result<(), crate::interface::BytecodeCompressionError>,
76+
VmExecutionResultAndLogs,
77+
) {
78+
todo!()
79+
}
80+
81+
fn record_vm_memory_metrics(&self) -> crate::vm_1_4_1::VmMemoryMetrics {
82+
todo!()
83+
}
84+
85+
fn gas_remaining(&self) -> u32 {
86+
todo!()
87+
}
88+
}
89+
90+
impl<S: ReadStorage + 'static> VmInterfaceHistoryEnabled<S> for Vm<S> {
91+
fn make_snapshot(&mut self) {
92+
todo!()
93+
}
94+
95+
fn rollback_to_the_latest_snapshot(&mut self) {
96+
todo!()
97+
}
98+
99+
fn pop_snapshot_no_rollback(&mut self) {
100+
todo!()
101+
}
102+
}

core/lib/multivm/src/versions/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod era_vm;
12
pub mod vm_1_3_2;
23
pub mod vm_1_4_1;
34
pub mod vm_1_4_2;

0 commit comments

Comments
 (0)