From b5c23409bb898766a0864faa2170a032eb8a8e26 Mon Sep 17 00:00:00 2001 From: Danil Date: Thu, 26 Oct 2023 14:54:19 +0200 Subject: [PATCH] Recover tests for vm virtual blocks Signed-off-by: Danil --- .../src/versions/vm_virtual_blocks/mod.rs | 6 ++-- .../vm_virtual_blocks/tests/bootloader.rs | 4 +-- .../tests/bytecode_publishing.rs | 4 +-- .../vm_virtual_blocks/tests/call_tracer.rs | 16 +++++----- .../vm_virtual_blocks/tests/default_aa.rs | 4 +-- .../vm_virtual_blocks/tests/gas_limit.rs | 4 +-- .../tests/get_used_contracts.rs | 6 ++-- .../tests/is_write_initial.rs | 4 +-- .../tests/l1_tx_execution.rs | 4 +-- .../vm_virtual_blocks/tests/l2_blocks.rs | 8 +++-- .../vm_virtual_blocks/tests/nonce_holder.rs | 5 +-- .../vm_virtual_blocks/tests/refunds.rs | 4 +-- .../vm_virtual_blocks/tests/require_eip712.rs | 4 +-- .../vm_virtual_blocks/tests/rollbacks.rs | 2 +- .../tests/simple_execution.rs | 4 +-- .../tests/tester/inner_state.rs | 5 +-- .../tests/tester/transaction_test_info.rs | 4 +-- .../tests/tester/vm_tester.rs | 32 +++++++------------ .../tests/tracing_execution_error.rs | 2 +- .../vm_virtual_blocks/tests/upgrade.rs | 6 ++-- .../vm_virtual_blocks/tracers/traits.rs | 14 +++----- 21 files changed, 69 insertions(+), 73 deletions(-) diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/mod.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/mod.rs index 3bc2b31ac61c..efd39b4e12c6 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/mod.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/mod.rs @@ -6,7 +6,7 @@ pub use old_vm::{ pub use tracers::{ dispatcher::TracerDispatcher, - traits::{ExecutionEndTracer, ExecutionProcessing, ToTracerPointer, TracerPointer, VmTracer}, + traits::{ExecutionEndTracer, ExecutionProcessing, TracerPointer, VmTracer}, utils::VmExecutionStopReason, }; @@ -27,5 +27,5 @@ mod vm; pub mod constants; pub mod utils; -// #[cfg(test)] -// mod tests; +#[cfg(test)] +mod tests; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/bootloader.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/bootloader.rs index 2219cc02014c..5abbd1dde47f 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/bootloader.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/bootloader.rs @@ -1,13 +1,13 @@ use zksync_types::U256; -use crate::interface::{ExecutionResult, Halt, TxExecutionMode, VmExecutionMode}; +use crate::interface::{ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, VmInterface}; use crate::vm_virtual_blocks::constants::BOOTLOADER_HEAP_PAGE; use crate::vm_virtual_blocks::tests::tester::VmTesterBuilder; use crate::vm_virtual_blocks::tests::utils::{ get_bootloader, verify_required_memory, BASE_SYSTEM_CONTRACTS, }; -use crate::vm_virtual_blocks::HistoryEnabled; +use crate::vm_latest::HistoryEnabled; #[test] fn test_dummy_bootloader() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/bytecode_publishing.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/bytecode_publishing.rs index bec771dd4a7a..773aa77e1502 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/bytecode_publishing.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/bytecode_publishing.rs @@ -1,10 +1,10 @@ use zksync_types::event::extract_long_l2_to_l1_messages; use zksync_utils::bytecode::compress_bytecode; -use crate::interface::{TxExecutionMode, VmExecutionMode}; +use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterface}; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::tests::tester::{DeployContractsTx, TxType, VmTesterBuilder}; use crate::vm_virtual_blocks::tests::utils::read_test_contract; -use crate::vm_virtual_blocks::HistoryEnabled; #[test] fn test_bytecode_publishing() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/call_tracer.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/call_tracer.rs index ed9084b7193b..5231b6af53e0 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/call_tracer.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/call_tracer.rs @@ -1,8 +1,10 @@ -use crate::interface::{TxExecutionMode, VmExecutionMode}; +use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterface}; +use crate::tracers::CallTracer; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::constants::BLOCK_GAS_LIMIT; use crate::vm_virtual_blocks::tests::tester::VmTesterBuilder; use crate::vm_virtual_blocks::tests::utils::{read_max_depth_contract, read_test_contract}; -use crate::vm_virtual_blocks::{CallTracer, HistoryEnabled}; +use crate::vm_virtual_blocks::VmTracer; use once_cell::sync::OnceCell; use std::sync::Arc; use zksync_types::{Address, Execute}; @@ -34,11 +36,9 @@ fn test_max_depth() { ); let result = Arc::new(OnceCell::new()); - let call_tracer = CallTracer::new(result.clone(), HistoryEnabled); + let call_tracer = CallTracer::new(result.clone()).to_rc_ptr(); vm.vm.push_transaction(tx); - let res = vm - .vm - .inspect(vec![Box::new(call_tracer)], VmExecutionMode::OneTx); + let res = vm.vm.inspect(call_tracer.into(), VmExecutionMode::OneTx); assert!(result.get().is_some()); assert!(res.result.is_failed()); } @@ -71,11 +71,11 @@ fn test_basic_behavior() { ); let result = Arc::new(OnceCell::new()); - let call_tracer = CallTracer::new(result.clone(), HistoryEnabled); + let call_tracer = CallTracer::new(result.clone()); vm.vm.push_transaction(tx); let res = vm .vm - .inspect(vec![Box::new(call_tracer)], VmExecutionMode::OneTx); + .inspect(call_tracer.to_rc_ptr().into(), VmExecutionMode::OneTx); let call_tracer_result = result.get().unwrap(); diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/default_aa.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/default_aa.rs index e7176c3ca74e..02a69a6a5d2d 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/default_aa.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/default_aa.rs @@ -4,12 +4,12 @@ use zksync_types::system_contracts::{DEPLOYMENT_NONCE_INCREMENT, TX_NONCE_INCREM use zksync_types::{get_code_key, get_known_code_key, get_nonce_key, AccountTreeId, U256}; use zksync_utils::u256_to_h256; -use crate::interface::{TxExecutionMode, VmExecutionMode}; +use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterface}; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::tests::tester::{DeployContractsTx, TxType, VmTesterBuilder}; use crate::vm_virtual_blocks::tests::utils::{ get_balance, read_test_contract, verify_required_storage, }; -use crate::vm_virtual_blocks::HistoryEnabled; #[test] fn test_default_aa_interaction() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/gas_limit.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/gas_limit.rs index 280f564901f6..01ebe4c0d225 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/gas_limit.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/gas_limit.rs @@ -6,8 +6,8 @@ use crate::vm_virtual_blocks::constants::{ }; use crate::vm_virtual_blocks::tests::tester::VmTesterBuilder; -use crate::interface::TxExecutionMode; -use crate::vm_virtual_blocks::HistoryDisabled; +use crate::interface::{TxExecutionMode, VmInterface}; +use crate::vm_latest::HistoryDisabled; /// Checks that `TX_GAS_LIMIT_OFFSET` constant is correct. #[test] diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/get_used_contracts.rs index cbee2968586f..496b7a847eda 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/get_used_contracts.rs @@ -2,6 +2,7 @@ use std::collections::{HashMap, HashSet}; use itertools::Itertools; +use crate::HistoryMode; use zksync_state::WriteStorage; use zksync_system_constants::CONTRACT_DEPLOYER_ADDRESS; use zksync_test_account::Account; @@ -9,10 +10,11 @@ use zksync_types::{Execute, U256}; use zksync_utils::bytecode::hash_bytecode; use zksync_utils::h256_to_u256; -use crate::interface::{TxExecutionMode, VmExecutionMode}; +use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterface}; +use crate::vm_latest::HistoryDisabled; use crate::vm_virtual_blocks::tests::tester::{TxType, VmTesterBuilder}; use crate::vm_virtual_blocks::tests::utils::{read_test_contract, BASE_SYSTEM_CONTRACTS}; -use crate::vm_virtual_blocks::{HistoryDisabled, HistoryMode, Vm}; +use crate::vm_virtual_blocks::Vm; #[test] fn test_get_used_contracts() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/is_write_initial.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/is_write_initial.rs index bc6bf4914785..8ac932687744 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/is_write_initial.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/is_write_initial.rs @@ -1,10 +1,10 @@ use zksync_state::ReadStorage; use zksync_types::get_nonce_key; -use crate::interface::{TxExecutionMode, VmExecutionMode}; +use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterface}; +use crate::vm_latest::HistoryDisabled; use crate::vm_virtual_blocks::tests::tester::{Account, TxType, VmTesterBuilder}; use crate::vm_virtual_blocks::tests::utils::read_test_contract; -use crate::vm_virtual_blocks::HistoryDisabled; #[test] fn test_is_write_initial_behaviour() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l1_tx_execution.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l1_tx_execution.rs index 3d2dcee11180..64d9f98ddb35 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l1_tx_execution.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l1_tx_execution.rs @@ -4,13 +4,13 @@ use zksync_types::storage_writes_deduplicator::StorageWritesDeduplicator; use zksync_types::{get_code_key, get_known_code_key, U256}; use zksync_utils::u256_to_h256; -use crate::interface::{TxExecutionMode, VmExecutionMode}; +use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterface}; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::tests::tester::{TxType, VmTesterBuilder}; use crate::vm_virtual_blocks::tests::utils::{ read_test_contract, verify_required_storage, BASE_SYSTEM_CONTRACTS, }; use crate::vm_virtual_blocks::types::internals::TransactionData; -use crate::vm_virtual_blocks::HistoryEnabled; #[test] fn test_l1_tx_execution() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l2_blocks.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l2_blocks.rs index 87a3351bb7d9..aebb389ebaf3 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l2_blocks.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/l2_blocks.rs @@ -3,14 +3,18 @@ //! The description for each of the tests can be found in the corresponding `.yul` file. //! -use crate::interface::{ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode}; +use crate::interface::{ + ExecutionResult, Halt, L2BlockEnv, TxExecutionMode, VmExecutionMode, VmInterface, +}; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::constants::{ BOOTLOADER_HEAP_PAGE, TX_OPERATOR_L2_BLOCK_INFO_OFFSET, TX_OPERATOR_SLOTS_PER_L2_BLOCK_INFO, }; use crate::vm_virtual_blocks::tests::tester::default_l1_batch; use crate::vm_virtual_blocks::tests::tester::VmTesterBuilder; use crate::vm_virtual_blocks::utils::l2_blocks::get_l2_block_hash_key; -use crate::vm_virtual_blocks::{HistoryEnabled, HistoryMode, Vm}; +use crate::vm_virtual_blocks::Vm; +use crate::HistoryMode; use zk_evm_1_3_3::aux_structures::Timestamp; use zksync_state::{ReadStorage, WriteStorage}; use zksync_system_constants::{ diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/nonce_holder.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/nonce_holder.rs index b38b85e7dff7..162a3f46cb10 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/nonce_holder.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/nonce_holder.rs @@ -1,12 +1,13 @@ use zksync_types::{Execute, Nonce}; use crate::interface::{ - ExecutionResult, Halt, TxExecutionMode, TxRevertReason, VmExecutionMode, VmRevertReason, + ExecutionResult, Halt, TxExecutionMode, TxRevertReason, VmExecutionMode, VmInterface, + VmRevertReason, }; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::tests::tester::{Account, VmTesterBuilder}; use crate::vm_virtual_blocks::tests::utils::read_nonce_holder_tester; use crate::vm_virtual_blocks::types::internals::TransactionData; -use crate::vm_virtual_blocks::HistoryEnabled; pub enum NonceHolderTestMode { SetValueUnderNonce, diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/refunds.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/refunds.rs index d84ca235c8fe..d0b3b7cbee37 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/refunds.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/refunds.rs @@ -1,9 +1,9 @@ -use crate::interface::{TxExecutionMode, VmExecutionMode}; +use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterface}; use crate::vm_virtual_blocks::tests::tester::{DeployContractsTx, TxType, VmTesterBuilder}; use crate::vm_virtual_blocks::tests::utils::read_test_contract; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::types::internals::TransactionData; -use crate::vm_virtual_blocks::HistoryEnabled; #[test] fn test_predetermined_refunded_gas() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/require_eip712.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/require_eip712.rs index efaba1a424ea..82c1a0527923 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/require_eip712.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/require_eip712.rs @@ -11,10 +11,10 @@ use zksync_types::transaction_request::TransactionRequest; use zksync_types::utils::storage_key_for_standard_token_balance; use zksync_types::{AccountTreeId, Address, Eip712Domain, Execute, Nonce, Transaction, U256}; -use crate::interface::{TxExecutionMode, VmExecutionMode}; +use crate::interface::{TxExecutionMode, VmExecutionMode, VmInterface}; +use crate::vm_latest::HistoryDisabled; use crate::vm_virtual_blocks::tests::tester::{Account, VmTester, VmTesterBuilder}; use crate::vm_virtual_blocks::tests::utils::read_many_owners_custom_account_contract; -use crate::vm_virtual_blocks::HistoryDisabled; impl VmTester { pub(crate) fn get_eth_balance(&mut self, address: Address) -> U256 { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/rollbacks.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/rollbacks.rs index 571c2530c838..240b7188377c 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/rollbacks.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/rollbacks.rs @@ -6,11 +6,11 @@ use zksync_contracts::test_contracts::LoadnextContractExecutionParams; use zksync_types::{Execute, U256}; use crate::interface::TxExecutionMode; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::tests::tester::{ DeployContractsTx, TransactionTestInfo, TxModifier, TxType, VmTesterBuilder, }; use crate::vm_virtual_blocks::tests::utils::read_test_contract; -use crate::vm_virtual_blocks::HistoryEnabled; #[test] fn test_vm_rollbacks() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/simple_execution.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/simple_execution.rs index 2aefbd49cd91..6b2237f5e59d 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/simple_execution.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/simple_execution.rs @@ -1,6 +1,6 @@ -use crate::interface::{ExecutionResult, VmExecutionMode}; +use crate::interface::{ExecutionResult, VmExecutionMode, VmInterface}; +use crate::vm_latest::HistoryDisabled; use crate::vm_virtual_blocks::tests::tester::{TxType, VmTesterBuilder}; -use crate::vm_virtual_blocks::HistoryDisabled; #[test] fn estimate_fee() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/inner_state.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/inner_state.rs index 0a6d9c03afe6..8105ca244d34 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/inner_state.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/inner_state.rs @@ -11,6 +11,7 @@ use crate::vm_virtual_blocks::old_vm::history_recorder::{ AppDataFrameManagerWithHistory, HistoryRecorder, }; use crate::vm_virtual_blocks::{HistoryEnabled, HistoryMode, SimpleMemory, Vm}; +use crate::HistoryMode as CommonHistoryMode; #[derive(Clone, Debug)] pub(crate) struct ModifiedKeysMap(HashMap); @@ -68,9 +69,9 @@ pub(crate) struct VmInstanceInnerState { local_state: VmLocalState, } -impl Vm { +impl Vm { // Dump inner state of the VM. - pub(crate) fn dump_inner_state(&self) -> VmInstanceInnerState { + pub(crate) fn dump_inner_state(&self) -> VmInstanceInnerState { let event_sink = self.state.event_sink.clone(); let precompile_processor_state = PrecompileProcessorTestInnerState { timestamp_history: self.state.precompiles_processor.timestamp_history.clone(), diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/transaction_test_info.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/transaction_test_info.rs index aa8678037fff..15d3d98ab1d0 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/transaction_test_info.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/transaction_test_info.rs @@ -2,10 +2,10 @@ use zksync_types::{ExecuteTransactionCommon, Transaction}; use crate::interface::{ CurrentExecutionState, ExecutionResult, Halt, TxRevertReason, VmExecutionMode, - VmExecutionResultAndLogs, VmRevertReason, + VmExecutionResultAndLogs, VmInterface, VmInterfaceHistoryEnabled, VmRevertReason, }; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::tests::tester::vm_tester::VmTester; -use crate::vm_virtual_blocks::HistoryEnabled; #[derive(Debug, Clone)] pub(crate) enum TxModifier { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/vm_tester.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/vm_tester.rs index 570da67a258b..0283239e7a25 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/vm_tester.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tester/vm_tester.rs @@ -1,6 +1,8 @@ +use std::marker::PhantomData; use zksync_contracts::BaseSystemContracts; use zksync_state::{InMemoryStorage, StoragePtr, StorageView, WriteStorage}; +use crate::HistoryMode; use zksync_types::block::legacy_miniblock_hash; use zksync_types::helpers::unix_timestamp_ms; use zksync_types::utils::{deployed_address_create, storage_key_for_eth_balance}; @@ -13,13 +15,13 @@ use zksync_utils::u256_to_h256; use crate::vm_virtual_blocks::constants::BLOCK_GAS_LIMIT; -use crate::interface::TxExecutionMode; use crate::interface::{L1BatchEnv, L2Block, L2BlockEnv, SystemEnv, VmExecutionMode}; +use crate::interface::{TxExecutionMode, VmInterface}; use crate::vm_virtual_blocks::tests::tester::Account; use crate::vm_virtual_blocks::tests::tester::TxType; use crate::vm_virtual_blocks::tests::utils::read_test_contract; use crate::vm_virtual_blocks::utils::l2_blocks::load_last_l2_block; -use crate::vm_virtual_blocks::{HistoryMode, Vm}; +use crate::vm_virtual_blocks::Vm; pub(crate) type InMemoryStorageView = StorageView; @@ -31,7 +33,7 @@ pub(crate) struct VmTester { pub(crate) test_contract: Option
, pub(crate) rich_accounts: Vec, pub(crate) custom_contracts: Vec, - history_mode: H, + _phantom: PhantomData, } impl VmTester { @@ -88,12 +90,7 @@ impl VmTester { }; } - let vm = Vm::new( - l1_batch, - self.vm.system_env.clone(), - self.storage.clone(), - self.history_mode.clone(), - ); + let vm = Vm::new(l1_batch, self.vm.system_env.clone(), self.storage.clone()); if self.test_contract.is_some() { self.deploy_test_contract(); @@ -106,7 +103,7 @@ impl VmTester { pub(crate) type ContractsToDeploy = (Vec, Address, bool); pub(crate) struct VmTesterBuilder { - history_mode: H, + _phantom: PhantomData, storage: Option, l1_batch_env: Option, system_env: SystemEnv, @@ -118,7 +115,7 @@ pub(crate) struct VmTesterBuilder { impl Clone for VmTesterBuilder { fn clone(&self) -> Self { Self { - history_mode: Default::default(), + _phantom: Default::default(), storage: None, l1_batch_env: self.l1_batch_env.clone(), system_env: self.system_env.clone(), @@ -131,9 +128,9 @@ impl Clone for VmTesterBuilder { #[allow(dead_code)] impl VmTesterBuilder { - pub(crate) fn new(history_mode: H) -> Self { + pub(crate) fn new(_: H) -> Self { Self { - history_mode, + _phantom: Default::default(), storage: None, l1_batch_env: None, system_env: SystemEnv { @@ -229,12 +226,7 @@ impl VmTesterBuilder { } let fee_account = l1_batch_env.fee_account; - let vm = Vm::new( - l1_batch_env, - self.system_env, - storage_ptr.clone(), - self.history_mode.clone(), - ); + let vm = Vm::new(l1_batch_env, self.system_env, storage_ptr.clone()); VmTester { vm, @@ -244,7 +236,7 @@ impl VmTesterBuilder { test_contract: None, rich_accounts: self.rich_accounts.clone(), custom_contracts: self.custom_contracts.clone(), - history_mode: self.history_mode, + _phantom: Default::default(), } } } diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tracing_execution_error.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tracing_execution_error.rs index 2f6644529924..8258abe0685a 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tracing_execution_error.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/tracing_execution_error.rs @@ -1,13 +1,13 @@ use crate::interface::{TxExecutionMode, TxRevertReason, VmRevertReason}; use zksync_types::{Execute, H160}; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::tests::tester::{ ExpectedError, TransactionTestInfo, VmTesterBuilder, }; use crate::vm_virtual_blocks::tests::utils::{ get_execute_error_calldata, read_error_contract, BASE_SYSTEM_CONTRACTS, }; -use crate::vm_virtual_blocks::HistoryEnabled; #[test] fn test_tracing_of_execution_errors() { diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/upgrade.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/upgrade.rs index f692f45ef7ef..7ba8ec6dfc0c 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tests/upgrade.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tests/upgrade.rs @@ -14,10 +14,12 @@ use zksync_contracts::{deployer_contract, load_contract, load_sys_contract, read use zksync_state::WriteStorage; use zksync_test_account::TxType; -use crate::interface::{ExecutionResult, Halt, TxExecutionMode, VmExecutionMode}; +use crate::interface::{ + ExecutionResult, Halt, TxExecutionMode, VmExecutionMode, VmInterface, VmInterfaceHistoryEnabled, +}; +use crate::vm_latest::HistoryEnabled; use crate::vm_virtual_blocks::tests::tester::VmTesterBuilder; use crate::vm_virtual_blocks::tests::utils::verify_required_storage; -use crate::vm_virtual_blocks::HistoryEnabled; use zksync_types::protocol_version::ProtocolUpgradeTxCommonData; use super::utils::read_test_contract; diff --git a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/traits.rs b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/traits.rs index e9e0279f3993..71146ad95eaf 100644 --- a/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/traits.rs +++ b/core/lib/multivm/src/versions/vm_virtual_blocks/tracers/traits.rs @@ -12,7 +12,6 @@ use crate::vm_virtual_blocks::types::internals::ZkSyncVmState; pub type TracerPointer = Rc>>; /// Run tracer for collecting data during the vm execution cycles -#[auto_impl::auto_impl(&mut, Box)] pub trait ExecutionProcessing: DynTracer> + ExecutionEndTracer { @@ -34,7 +33,6 @@ pub trait ExecutionProcessing: } /// Stop the vm execution if the tracer conditions are met -#[auto_impl::auto_impl(&mut, Box)] pub trait ExecutionEndTracer { // Returns whether the vm execution should stop. fn should_stop_execution(&self) -> bool { @@ -43,19 +41,15 @@ pub trait ExecutionEndTracer { } /// Save the results of the vm execution. -#[auto_impl::auto_impl(&mut, Box)] pub trait VmTracer: DynTracer> + ExecutionEndTracer + ExecutionProcessing { fn save_results(&mut self, _result: &mut VmExecutionResultAndLogs) {} -} - -pub trait ToTracerPointer { - fn into_tracer_pointer(self) -> Rc>>; -} -impl + 'static> ToTracerPointer for T { - fn into_tracer_pointer(self) -> Rc>> { + fn to_rc_ptr(self) -> TracerPointer + where + Self: Sized + 'static, + { Rc::new(RefCell::new(self)) } }