anvil_zksync_core/node/
boojumos.rs

1#![allow(dead_code)]
2#![allow(unused_variables)]
3#![allow(unused_imports)]
4
5//! Interfaces that use boojumos for VM execution.
6//! This is still experimental code.
7
8use anvil_zksync_config::types::BoojumConfig;
9
10use zksync_multivm::{
11    interface::{
12        storage::{StoragePtr, WriteStorage},
13        ExecutionResult, InspectExecutionMode, L1BatchEnv, PushTransactionResult, Refunds,
14        SystemEnv, TxExecutionMode, VmExecutionLogs, VmExecutionResultAndLogs, VmInterface,
15        VmInterfaceHistoryEnabled, VmRevertReason,
16    },
17    tracers::TracerDispatcher,
18    vm_latest::TracerPointer,
19    HistoryMode,
20};
21
22use zksync_multivm::MultiVmTracerPointer;
23use zksync_types::{
24    address_to_h256, get_code_key, u256_to_h256, web3::keccak256, AccountTreeId, Address,
25    ExecuteTransactionCommon, StorageKey, StorageLog, StorageLogWithPreviousValue, Transaction,
26    H160, H256, U256,
27};
28
29use crate::deps::InMemoryStorage;
30
31pub const BOOJUM_CALL_GAS_LIMIT: u64 = 100_000_000;
32
33pub fn boojumos_get_batch_witness(key: &u32) -> Option<Vec<u8>> {
34    todo!()
35}
36
37pub fn boojumos_get_nonce_key(account: &Address) -> StorageKey {
38    todo!()
39}
40
41pub fn boojumos_storage_key_for_eth_balance(address: &Address) -> StorageKey {
42    todo!();
43}
44
45#[derive(Debug)]
46pub struct BoojumOsVM<S: WriteStorage, H: HistoryMode> {
47    pub storage: StoragePtr<S>,
48
49    _phantom: std::marker::PhantomData<H>,
50}
51
52impl<S: WriteStorage, H: HistoryMode> BoojumOsVM<S, H> {
53    pub fn new(
54        batch_env: L1BatchEnv,
55        system_env: SystemEnv,
56        storage: StoragePtr<S>,
57        raw_storage: &InMemoryStorage,
58        config: &BoojumConfig,
59    ) -> Self {
60        todo!()
61    }
62
63    /// If any keys are updated in storage externally, but not reflected in internal tree.
64    pub fn update_inconsistent_keys(&mut self, inconsistent_nodes: &[&StorageKey]) {
65        todo!()
66    }
67}
68
69pub struct BoojumOsTracerDispatcher<S: WriteStorage, H: HistoryMode> {
70    _tracers: Vec<S>,
71    _marker: std::marker::PhantomData<H>,
72}
73
74impl<S: WriteStorage, H: HistoryMode> Default for BoojumOsTracerDispatcher<S, H> {
75    fn default() -> Self {
76        Self {
77            _tracers: Default::default(),
78            _marker: Default::default(),
79        }
80    }
81}
82
83impl<S: WriteStorage, H: HistoryMode> From<Vec<TracerPointer<S, H>>>
84    for BoojumOsTracerDispatcher<S, H>
85{
86    fn from(_value: Vec<TracerPointer<S, H>>) -> Self {
87        Self {
88            _tracers: Default::default(),
89            _marker: Default::default(),
90        }
91    }
92}
93
94impl<S: WriteStorage, H: HistoryMode> From<Vec<MultiVmTracerPointer<S, H>>>
95    for BoojumOsTracerDispatcher<S, H>
96{
97    fn from(_value: Vec<MultiVmTracerPointer<S, H>>) -> Self {
98        Self {
99            _tracers: Default::default(),
100            _marker: Default::default(),
101        }
102    }
103}
104
105impl<S: WriteStorage, H: HistoryMode> From<TracerDispatcher<S, H>>
106    for BoojumOsTracerDispatcher<S, H>
107{
108    fn from(_value: TracerDispatcher<S, H>) -> Self {
109        Self {
110            _tracers: Default::default(),
111            _marker: Default::default(),
112        }
113    }
114}
115
116impl<S: WriteStorage, H: HistoryMode> VmInterface for BoojumOsVM<S, H> {
117    type TracerDispatcher = BoojumOsTracerDispatcher<S, H>;
118
119    fn push_transaction(
120        &mut self,
121        tx: Transaction,
122    ) -> zksync_multivm::interface::PushTransactionResult<'_> {
123        todo!()
124    }
125
126    fn inspect(
127        &mut self,
128        _dispatcher: &mut Self::TracerDispatcher,
129        execution_mode: zksync_multivm::interface::InspectExecutionMode,
130    ) -> VmExecutionResultAndLogs {
131        todo!()
132    }
133
134    fn start_new_l2_block(&mut self, _l2_block_env: zksync_multivm::interface::L2BlockEnv) {
135        todo!()
136    }
137
138    fn inspect_transaction_with_bytecode_compression(
139        &mut self,
140        _tracer: &mut Self::TracerDispatcher,
141        _tx: Transaction,
142        _with_compression: bool,
143    ) -> (
144        zksync_multivm::interface::BytecodeCompressionResult<'_>,
145        VmExecutionResultAndLogs,
146    ) {
147        todo!()
148    }
149
150    fn finish_batch(
151        &mut self,
152        _pubdata_builder: std::rc::Rc<dyn zksync_multivm::interface::pubdata::PubdataBuilder>,
153    ) -> zksync_multivm::interface::FinishedL1Batch {
154        todo!()
155    }
156}
157
158impl<S: WriteStorage, H: HistoryMode> VmInterfaceHistoryEnabled for BoojumOsVM<S, H> {
159    fn make_snapshot(&mut self) {}
160
161    fn rollback_to_the_latest_snapshot(&mut self) {
162        panic!("Not implemented for boojumos");
163    }
164
165    fn pop_snapshot_no_rollback(&mut self) {}
166}