|
| 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 | +} |
0 commit comments