diff --git a/core/lib/multivm/src/versions/testonly/require_eip712.rs b/core/lib/multivm/src/versions/testonly/require_eip712.rs index 9862b9277432..55cf7933154f 100644 --- a/core/lib/multivm/src/versions/testonly/require_eip712.rs +++ b/core/lib/multivm/src/versions/testonly/require_eip712.rs @@ -98,7 +98,7 @@ pub(crate) fn test_require_eip712() { vm.get_eth_balance(private_account.address) ); - // // Now send the 'classic' EIP712 transaction + // Now send the 'classic' EIP712 transaction let transaction: Transaction = make_aa_transaction(aa_address, beneficiary_address, &private_account).into(); diff --git a/core/lib/multivm/src/versions/vm_fast/with_builtin_tracers.rs b/core/lib/multivm/src/versions/vm_fast/builtin_tracers.rs similarity index 74% rename from core/lib/multivm/src/versions/vm_fast/with_builtin_tracers.rs rename to core/lib/multivm/src/versions/vm_fast/builtin_tracers.rs index 1d58b7ac16cb..8d5e49872b69 100644 --- a/core/lib/multivm/src/versions/vm_fast/with_builtin_tracers.rs +++ b/core/lib/multivm/src/versions/vm_fast/builtin_tracers.rs @@ -4,7 +4,7 @@ use zksync_vm_interface::tracer::ValidationParams; use super::{ circuits_tracer::CircuitsTracer, evm_deploy_tracer::{DynamicBytecodes, EvmDeployTracer}, - validation_tracer::{ValidationGasLimitOnly, ValidationMode, ValidationTracer}, + validation_tracer::{FullValidationTracer, ValidationGasLimitOnly, ValidationTracer}, }; #[derive(Debug, Default)] @@ -12,11 +12,11 @@ pub struct WithBuiltinTracers( (External, (Validation, (CircuitsTracer, EvmDeployTracer))), ); -pub type DefaultTracers = WithBuiltinTracersForSequencer<()>; +pub type DefaultTracers = SequencerTracers<()>; -pub type WithBuiltinTracersForValidation = WithBuiltinTracers; +pub type ValidationTracers = WithBuiltinTracers; -impl WithBuiltinTracersForValidation { +impl ValidationTracers { pub fn for_validation( external: External, validation_params: ValidationParams, @@ -25,24 +25,24 @@ impl WithBuiltinTracersForValidation { Self(( external, ( - ValidationTracer::new(validation_params, timestamp), + FullValidationTracer::new(validation_params, timestamp), Default::default(), ), )) } } -pub type WithBuiltinTracersForApi = WithBuiltinTracers; +pub type ApiTracers = WithBuiltinTracers; -impl WithBuiltinTracersForApi { +impl ApiTracers { pub fn for_api(external: External) -> Self { Self((external, Default::default())) } } -pub type WithBuiltinTracersForSequencer = WithBuiltinTracers; +pub type SequencerTracers = WithBuiltinTracers; -impl WithBuiltinTracersForSequencer { +impl SequencerTracers { pub fn for_sequencer(external: External) -> Self { Self((external, Default::default())) } @@ -70,7 +70,7 @@ impl WithBuiltinTracers { } } -impl Tracer +impl Tracer for WithBuiltinTracers { fn before_instruction< diff --git a/core/lib/multivm/src/versions/vm_fast/mod.rs b/core/lib/multivm/src/versions/vm_fast/mod.rs index df63258c6f05..fd41bfa2deca 100644 --- a/core/lib/multivm/src/versions/vm_fast/mod.rs +++ b/core/lib/multivm/src/versions/vm_fast/mod.rs @@ -2,14 +2,14 @@ pub use zksync_vm2::interface; pub(crate) use self::version::FastVmVersion; pub use self::{ - vm::Vm, - with_builtin_tracers::{ - DefaultTracers, WithBuiltinTracers, WithBuiltinTracersForApi, - WithBuiltinTracersForSequencer, WithBuiltinTracersForValidation, + builtin_tracers::{ + ApiTracers, DefaultTracers, SequencerTracers, ValidationTracers, WithBuiltinTracers, }, + vm::Vm, }; mod bootloader_state; +mod builtin_tracers; mod bytecode; mod circuits_tracer; mod events; @@ -25,4 +25,3 @@ mod utils; mod validation_tracer; mod version; mod vm; -mod with_builtin_tracers; diff --git a/core/lib/multivm/src/versions/vm_fast/tests/account_validation_rules.rs b/core/lib/multivm/src/versions/vm_fast/tests/account_validation_rules.rs index 3623ec5c95d5..cc76b20eebfd 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/account_validation_rules.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/account_validation_rules.rs @@ -1,9 +1,10 @@ +use super::TestedFastVm; use crate::{ versions::testonly::account_validation_rules::test_account_validation_rules, - vm_fast::{Vm, WithBuiltinTracersForValidation}, + vm_fast::ValidationTracers, }; #[test] fn test_account_validation_rules_fast() { - test_account_validation_rules::>>(); + test_account_validation_rules::>>(); } diff --git a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs index 8c511a0e662a..2aa10dcec394 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs @@ -10,9 +10,7 @@ use zksync_vm_interface::{ VmExecutionResultAndLogs, VmInterface, }; -use super::{ - validation_tracer::ValidationMode, Vm, WithBuiltinTracers, WithBuiltinTracersForValidation, -}; +use super::{validation_tracer::ValidationTracer, ValidationTracers, Vm, WithBuiltinTracers}; use crate::{ interface::storage::{ImmutableStorageView, InMemoryStorage}, versions::testonly::{validation_params, TestedVm, TestedVmForValidation}, @@ -81,8 +79,9 @@ impl PartialEq for VmStateDump { } } -impl TestedVm - for Vm, WithBuiltinTracers> +pub(crate) type TestedFastVm = Vm, Tr>; + +impl TestedVm for TestedFastVm> where WithBuiltinTracers: std::fmt::Debug + 'static, { @@ -172,9 +171,7 @@ where } } -impl TestedVmForValidation - for Vm, WithBuiltinTracersForValidation<()>> -{ +impl TestedVmForValidation for Vm, ValidationTracers<()>> { fn run_validation(&mut self, tx: L2Tx, timestamp: u64) -> Option { let validation_params = validation_params(&tx, &self.system_env); self.push_transaction(tx.into()); diff --git a/core/lib/multivm/src/versions/vm_fast/validation_tracer.rs b/core/lib/multivm/src/versions/vm_fast/validation_tracer.rs index 7ee25b6412f5..c0d8201254a1 100644 --- a/core/lib/multivm/src/versions/vm_fast/validation_tracer.rs +++ b/core/lib/multivm/src/versions/vm_fast/validation_tracer.rs @@ -17,7 +17,7 @@ use zksync_vm_interface::tracer::{ use super::utils::read_fat_pointer; use crate::tracers::TIMESTAMP_ASSERTER_FUNCTION_SELECTOR; -pub trait ValidationMode: Tracer + Default { +pub trait ValidationTracer: Tracer + Default { const STOP_AFTER_VALIDATION: bool; fn account_validation_entered(&mut self); fn validation_exited(&mut self); @@ -26,7 +26,7 @@ pub trait ValidationMode: Tracer + Default { #[derive(Debug, Default)] pub struct ValidationGasLimitOnly; impl Tracer for ValidationGasLimitOnly {} -impl ValidationMode for ValidationGasLimitOnly { +impl ValidationTracer for ValidationGasLimitOnly { const STOP_AFTER_VALIDATION: bool = false; fn account_validation_entered(&mut self) {} fn validation_exited(&mut self) {} @@ -57,7 +57,7 @@ impl ValidationMode for ValidationGasLimitOnly { /// that a contract adheres to the rules ahead of time would be challenging or even impossible, /// considering that contracts that the code depends on may get upgraded. #[derive(Debug, Default)] -pub struct ValidationTracer { +pub struct FullValidationTracer { in_validation: bool, add_return_value_to_allowed_slots: bool, @@ -75,7 +75,7 @@ pub struct ValidationTracer { traces: ValidationTraces, } -impl ValidationMode for ValidationTracer { +impl ValidationTracer for FullValidationTracer { const STOP_AFTER_VALIDATION: bool = true; fn account_validation_entered(&mut self) { @@ -87,7 +87,7 @@ impl ValidationMode for ValidationTracer { } } -impl Tracer for ValidationTracer { +impl Tracer for FullValidationTracer { fn before_instruction(&mut self, state: &mut S) { if !self.in_validation { return; @@ -223,7 +223,7 @@ impl Tracer for ValidationTracer { } } -impl ValidationTracer { +impl FullValidationTracer { pub fn new(params: ValidationParams, l1_batch_timestamp: u64) -> Self { let ValidationParams { user_address, diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index 2c5471fb85d7..8e63576b26b7 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -31,7 +31,7 @@ use super::{ hook::Hook, initial_bootloader_memory::bootloader_initial_memory, transaction_data::TransactionData, - validation_tracer::ValidationMode, + validation_tracer::ValidationTracer, DefaultTracers, WithBuiltinTracers, }; use crate::{ @@ -366,7 +366,12 @@ impl Vm { } } -impl Vm> +struct AccountValidationGasSplit { + gas_given: u32, + gas_hidden: u32, +} + +impl Vm> where WithBuiltinTracers: Tracer, { @@ -377,10 +382,6 @@ where track_refunds: bool, pubdata_builder: Option<&dyn PubdataBuilder>, ) -> VmRunResult { - struct AccountValidationGasSplit { - gas_given: u32, - gas_hidden: u32, - } let mut gas_left_for_account_validation = self.system_env.default_validation_computational_gas_limit; let mut account_validation_gas_split = None; @@ -744,7 +745,7 @@ where } } -impl VmInterface +impl VmInterface for Vm> { type TracerDispatcher = WithBuiltinTracers; diff --git a/core/lib/vm_executor/src/batch/factory.rs b/core/lib/vm_executor/src/batch/factory.rs index 0416dee8ac7b..149c6aa4cf87 100644 --- a/core/lib/vm_executor/src/batch/factory.rs +++ b/core/lib/vm_executor/src/batch/factory.rs @@ -16,7 +16,7 @@ use zksync_multivm::{ is_supported_by_fast_vm, pubdata_builders::pubdata_params_to_builder, tracers::CallTracer, - vm_fast::{self, WithBuiltinTracersForSequencer}, + vm_fast::{self, SequencerTracers}, vm_latest::HistoryEnabled, FastVmInstance, LegacyVmInstance, MultiVmTracer, }; @@ -150,7 +150,7 @@ type BytecodeResult = Result, BytecodeCompressionErr #[derive(Debug)] enum BatchVm { Legacy(LegacyVmInstance), - Fast(FastVmInstance>), + Fast(FastVmInstance>), } macro_rules! dispatch_batch_vm { diff --git a/core/lib/vm_executor/src/oneshot/mod.rs b/core/lib/vm_executor/src/oneshot/mod.rs index b3fcdc7a76da..e92886a23432 100644 --- a/core/lib/vm_executor/src/oneshot/mod.rs +++ b/core/lib/vm_executor/src/oneshot/mod.rs @@ -27,7 +27,7 @@ use zksync_multivm::{ is_supported_by_fast_vm, tracers::{CallTracer, StorageInvocations, TracerDispatcher, ValidationTracer}, utils::adjust_pubdata_price_for_tx, - vm_fast::{self, WithBuiltinTracers, WithBuiltinTracersForApi}, + vm_fast::{self, ApiTracers, WithBuiltinTracers}, vm_latest::{HistoryDisabled, HistoryEnabled}, zk_evm_latest::ethereum_types::U256, FastVmInstance, HistoryMode, LegacyVmInstance, MultiVmTracer, @@ -317,7 +317,7 @@ enum Vm { Fast(FastVmInstance), } -impl Vm> { +impl Vm> { fn inspect_transaction_with_bytecode_compression( &mut self, missed_storage_invocation_limit: usize,