From 5df197626dcaa83837c08bf5b8011964f75c5a3f Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Thu, 7 Nov 2024 17:42:46 +0200 Subject: [PATCH 1/3] add gateway changes to fast vm --- .../vm_fast/bootloader_state/state.rs | 36 +++- .../vm_fast/bootloader_state/utils.rs | 70 +++++-- core/lib/multivm/src/versions/vm_fast/mod.rs | 3 +- .../multivm/src/versions/vm_fast/pubdata.rs | 123 ------------ .../multivm/src/versions/vm_fast/tests/mod.rs | 2 +- .../multivm/src/versions/vm_fast/version.rs | 28 +++ core/lib/multivm/src/versions/vm_fast/vm.rs | 81 +++++--- core/lib/multivm/src/vm_instance.rs | 6 +- yarn.lock | 188 ++++++++++++++++++ 9 files changed, 350 insertions(+), 187 deletions(-) delete mode 100644 core/lib/multivm/src/versions/vm_fast/pubdata.rs create mode 100644 core/lib/multivm/src/versions/vm_fast/version.rs diff --git a/core/lib/multivm/src/versions/vm_fast/bootloader_state/state.rs b/core/lib/multivm/src/versions/vm_fast/bootloader_state/state.rs index 15b4daf02a77..e104eba6ef4f 100644 --- a/core/lib/multivm/src/versions/vm_fast/bootloader_state/state.rs +++ b/core/lib/multivm/src/versions/vm_fast/bootloader_state/state.rs @@ -1,7 +1,7 @@ use std::cmp::Ordering; use once_cell::sync::OnceCell; -use zksync_types::{L2ChainId, U256}; +use zksync_types::{L2ChainId, ProtocolVersionId, U256}; use super::{ l2_block::BootloaderL2Block, @@ -10,8 +10,11 @@ use super::{ BootloaderStateSnapshot, }; use crate::{ - interface::{BootloaderMemory, CompressedBytecodeInfo, L2BlockEnv, TxExecutionMode}, - versions::vm_fast::{pubdata::PubdataInput, transaction_data::TransactionData}, + interface::{ + pubdata::{PubdataBuilder, PubdataInput}, + BootloaderMemory, CompressedBytecodeInfo, L2BlockEnv, TxExecutionMode, + }, + versions::vm_fast::transaction_data::TransactionData, vm_latest::{constants::TX_DESCRIPTION_OFFSET, utils::l2_blocks::assert_next_block}, }; @@ -42,6 +45,8 @@ pub struct BootloaderState { free_tx_offset: usize, /// Information about the pubdata that will be needed to supply to the L1Messenger pubdata_information: OnceCell, + /// Protocol version. + protocol_version: ProtocolVersionId, } impl BootloaderState { @@ -49,6 +54,7 @@ impl BootloaderState { execution_mode: TxExecutionMode, initial_memory: BootloaderMemory, first_l2_block: L2BlockEnv, + protocol_version: ProtocolVersionId, ) -> Self { let l2_block = BootloaderL2Block::new(first_l2_block, 0); Self { @@ -59,6 +65,7 @@ impl BootloaderState { execution_mode, free_tx_offset: 0, pubdata_information: Default::default(), + protocol_version, } } @@ -139,12 +146,23 @@ impl BootloaderState { .expect("Pubdata information is not set") } + pub(crate) fn settlement_layer_pubdata(&self, pubdata_builder: &dyn PubdataBuilder) -> Vec { + let pubdata_information = self + .pubdata_information + .get() + .expect("Pubdata information is not set"); + pubdata_builder.settlement_layer_pubdata(pubdata_information, self.protocol_version) + } + fn last_mut_l2_block(&mut self) -> &mut BootloaderL2Block { self.l2_blocks.last_mut().unwrap() } /// Apply all bootloader transaction to the initial memory - pub(crate) fn bootloader_memory(&self) -> BootloaderMemory { + pub(crate) fn bootloader_memory( + &self, + pubdata_builder: &dyn PubdataBuilder, + ) -> BootloaderMemory { let mut initial_memory = self.initial_memory.clone(); let mut offset = 0; let mut compressed_bytecodes_offset = 0; @@ -172,11 +190,15 @@ impl BootloaderState { let pubdata_information = self .pubdata_information - .clone() - .into_inner() + .get() .expect("Empty pubdata information"); - apply_pubdata_to_memory(&mut initial_memory, pubdata_information); + apply_pubdata_to_memory( + &mut initial_memory, + pubdata_builder, + pubdata_information, + self.protocol_version, + ); initial_memory } diff --git a/core/lib/multivm/src/versions/vm_fast/bootloader_state/utils.rs b/core/lib/multivm/src/versions/vm_fast/bootloader_state/utils.rs index 770f232019bf..fc259ccd30c9 100644 --- a/core/lib/multivm/src/versions/vm_fast/bootloader_state/utils.rs +++ b/core/lib/multivm/src/versions/vm_fast/bootloader_state/utils.rs @@ -1,11 +1,13 @@ -use zksync_types::{ethabi, U256}; +use zksync_types::{ethabi, ProtocolVersionId, U256}; use zksync_utils::{bytes_to_be_words, h256_to_u256}; use super::{l2_block::BootloaderL2Block, tx::BootloaderTx}; use crate::{ - interface::{BootloaderMemory, CompressedBytecodeInfo, TxExecutionMode}, + interface::{ + pubdata::{PubdataBuilder, PubdataInput}, + BootloaderMemory, CompressedBytecodeInfo, TxExecutionMode, + }, utils::bytecode, - versions::vm_fast::pubdata::PubdataInput, vm_latest::constants::{ BOOTLOADER_TX_DESCRIPTION_OFFSET, BOOTLOADER_TX_DESCRIPTION_SIZE, COMPRESSED_BYTECODES_OFFSET, OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET, @@ -120,26 +122,54 @@ fn apply_l2_block_inner( ]) } +fn bootloader_memory_input( + pubdata_builder: &dyn PubdataBuilder, + input: &PubdataInput, + protocol_version: ProtocolVersionId, +) -> Vec { + let l2_da_validator_address = pubdata_builder.l2_da_validator(); + let operator_input = pubdata_builder.l1_messenger_operator_input(input, protocol_version); + ethabi::encode(&[ + ethabi::Token::Address(l2_da_validator_address), + ethabi::Token::Bytes(operator_input), + ]) +} + pub(crate) fn apply_pubdata_to_memory( memory: &mut BootloaderMemory, - pubdata_information: PubdataInput, + pubdata_builder: &dyn PubdataBuilder, + pubdata_information: &PubdataInput, + protocol_version: ProtocolVersionId, ) { - // Skipping two slots as they will be filled by the bootloader itself: - // - One slot is for the selector of the call to the L1Messenger. - // - The other slot is for the 0x20 offset for the calldata. - let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 2; - - // Need to skip first word as it represents array offset - // while bootloader expects only [len || data] - let pubdata = ethabi::encode(&[ethabi::Token::Bytes( - pubdata_information.build_pubdata(true), - )])[32..] - .to_vec(); - - assert!( - pubdata.len() / 32 <= OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS - 2, - "The encoded pubdata is too big" - ); + let (l1_messenger_pubdata_start_slot, pubdata) = if protocol_version.is_pre_gateway() { + // Skipping two slots as they will be filled by the bootloader itself: + // - One slot is for the selector of the call to the L1Messenger. + // - The other slot is for the 0x20 offset for the calldata. + let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 2; + // Need to skip first word as it represents array offset + // while bootloader expects only [len || data] + let pubdata = ethabi::encode(&[ethabi::Token::Bytes( + pubdata_builder.l1_messenger_operator_input(pubdata_information, protocol_version), + )])[32..] + .to_vec(); + assert!( + pubdata.len() / 32 <= OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS - 2, + "The encoded pubdata is too big" + ); + (l1_messenger_pubdata_start_slot, pubdata) + } else { + // Skipping the first slot as it will be filled by the bootloader itself: + // It is for the selector of the call to the L1Messenger. + let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 1; + let pubdata = + bootloader_memory_input(pubdata_builder, pubdata_information, protocol_version); + assert!( + // Note that unlike the previous version, the difference is `1`, since now it also includes the offset + pubdata.len() / 32 < OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS, + "The encoded pubdata is too big" + ); + (l1_messenger_pubdata_start_slot, pubdata) + }; pubdata .chunks(32) diff --git a/core/lib/multivm/src/versions/vm_fast/mod.rs b/core/lib/multivm/src/versions/vm_fast/mod.rs index de6e7bd4ef6a..95f041583399 100644 --- a/core/lib/multivm/src/versions/vm_fast/mod.rs +++ b/core/lib/multivm/src/versions/vm_fast/mod.rs @@ -1,5 +1,6 @@ pub use zksync_vm2::interface; +pub(crate) use self::version::FastVMVersion; pub use self::vm::Vm; mod bootloader_state; @@ -10,10 +11,10 @@ mod evm_deploy_tracer; mod glue; mod hook; mod initial_bootloader_memory; -mod pubdata; mod refund; #[cfg(test)] mod tests; mod transaction_data; mod utils; +mod version; mod vm; diff --git a/core/lib/multivm/src/versions/vm_fast/pubdata.rs b/core/lib/multivm/src/versions/vm_fast/pubdata.rs deleted file mode 100644 index c1ca93152a03..000000000000 --- a/core/lib/multivm/src/versions/vm_fast/pubdata.rs +++ /dev/null @@ -1,123 +0,0 @@ -use zksync_types::writes::{compress_state_diffs, StateDiffRecord}; - -use crate::interface::pubdata::L1MessengerL2ToL1Log; - -/// Struct based on which the pubdata blob is formed -#[derive(Debug, Clone, Default)] -pub(crate) struct PubdataInput { - pub(crate) user_logs: Vec, - pub(crate) l2_to_l1_messages: Vec>, - pub(crate) published_bytecodes: Vec>, - pub(crate) state_diffs: Vec, -} - -impl PubdataInput { - pub(crate) fn build_pubdata(self, with_uncompressed_state_diffs: bool) -> Vec { - let mut l1_messenger_pubdata = vec![]; - - let PubdataInput { - user_logs, - l2_to_l1_messages, - published_bytecodes, - state_diffs, - } = self; - - // Encoding user L2->L1 logs. - // Format: `[(numberOfL2ToL1Logs as u32) || l2tol1logs[1] || ... || l2tol1logs[n]]` - l1_messenger_pubdata.extend((user_logs.len() as u32).to_be_bytes()); - for l2tol1log in user_logs { - l1_messenger_pubdata.extend(l2tol1log.packed_encoding()); - } - - // Encoding L2->L1 messages - // Format: `[(numberOfMessages as u32) || (messages[1].len() as u32) || messages[1] || ... || (messages[n].len() as u32) || messages[n]]` - l1_messenger_pubdata.extend((l2_to_l1_messages.len() as u32).to_be_bytes()); - for message in l2_to_l1_messages { - l1_messenger_pubdata.extend((message.len() as u32).to_be_bytes()); - l1_messenger_pubdata.extend(message); - } - - // Encoding bytecodes - // Format: `[(numberOfBytecodes as u32) || (bytecodes[1].len() as u32) || bytecodes[1] || ... || (bytecodes[n].len() as u32) || bytecodes[n]]` - l1_messenger_pubdata.extend((published_bytecodes.len() as u32).to_be_bytes()); - for bytecode in published_bytecodes { - l1_messenger_pubdata.extend((bytecode.len() as u32).to_be_bytes()); - l1_messenger_pubdata.extend(bytecode); - } - - // Encoding state diffs - // Format: `[size of compressed state diffs u32 || compressed state diffs || (# state diffs: intial + repeated) as u32 || sorted state diffs by ]` - let state_diffs_compressed = compress_state_diffs(state_diffs.clone()); - l1_messenger_pubdata.extend(state_diffs_compressed); - - if with_uncompressed_state_diffs { - l1_messenger_pubdata.extend((state_diffs.len() as u32).to_be_bytes()); - for state_diff in state_diffs { - l1_messenger_pubdata.extend(state_diff.encode_padded()); - } - } - - l1_messenger_pubdata - } -} - -#[cfg(test)] -mod tests { - use zksync_system_constants::{ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS}; - use zksync_utils::u256_to_h256; - - use super::*; - - #[test] - fn test_basic_pubdata_building() { - // Just using some constant addresses for tests - let addr1 = BOOTLOADER_ADDRESS; - let addr2 = ACCOUNT_CODE_STORAGE_ADDRESS; - - let user_logs = vec![L1MessengerL2ToL1Log { - l2_shard_id: 0, - is_service: false, - tx_number_in_block: 0, - sender: addr1, - key: 1.into(), - value: 128.into(), - }]; - - let l2_to_l1_messages = vec![hex::decode("deadbeef").unwrap()]; - - let published_bytecodes = vec![hex::decode("aaaabbbb").unwrap()]; - - // For covering more cases, we have two state diffs: - // One with enumeration index present (and so it is a repeated write) and the one without it. - let state_diffs = vec![ - StateDiffRecord { - address: addr2, - key: 155.into(), - derived_key: u256_to_h256(125.into()).0, - enumeration_index: 12, - initial_value: 11.into(), - final_value: 12.into(), - }, - StateDiffRecord { - address: addr2, - key: 156.into(), - derived_key: u256_to_h256(126.into()).0, - enumeration_index: 0, - initial_value: 0.into(), - final_value: 14.into(), - }, - ]; - - let input = PubdataInput { - user_logs, - l2_to_l1_messages, - published_bytecodes, - state_diffs, - }; - - let pubdata = - ethabi::encode(&[ethabi::Token::Bytes(input.build_pubdata(true))])[32..].to_vec(); - - assert_eq!(hex::encode(pubdata), "00000000000000000000000000000000000000000000000000000000000002c700000001000000000000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000100000004deadbeef0000000100000004aaaabbbb0100002a040001000000000000000000000000000000000000000000000000000000000000007e090e0000000c0901000000020000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009b000000000000000000000000000000000000000000000000000000000000007d000000000000000c000000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000007e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); - } -} 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 27192f46d8dd..6bad63aa8298 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/mod.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/mod.rs @@ -111,7 +111,7 @@ impl TestedVm for Vm> { } fn finish_batch_without_pubdata(&mut self) -> VmExecutionResultAndLogs { - self.inspect_inner(&mut Default::default(), VmExecutionMode::Batch) + self.inspect_inner(&mut Default::default(), VmExecutionMode::Batch, None) } fn insert_bytecodes(&mut self, bytecodes: &[&[u8]]) { diff --git a/core/lib/multivm/src/versions/vm_fast/version.rs b/core/lib/multivm/src/versions/vm_fast/version.rs new file mode 100644 index 000000000000..a813e6d0e886 --- /dev/null +++ b/core/lib/multivm/src/versions/vm_fast/version.rs @@ -0,0 +1,28 @@ +use crate::{vm_latest::MultiVMSubversion, VmVersion}; + +#[derive(Debug, Copy, Clone)] +pub(crate) enum FastVMVersion { + IncreasedBootloaderMemory, + Gateway, +} + +impl From for MultiVMSubversion { + fn from(value: FastVMVersion) -> Self { + match value { + FastVMVersion::IncreasedBootloaderMemory => Self::IncreasedBootloaderMemory, + FastVMVersion::Gateway => Self::Gateway, + } + } +} + +impl TryFrom for FastVMVersion { + type Error = (); + + fn try_from(value: VmVersion) -> Result { + match value { + VmVersion::Vm1_5_0IncreasedBootloaderMemory => Ok(Self::IncreasedBootloaderMemory), + VmVersion::VmGateway => Ok(Self::Gateway), + _ => Err(()), + } + } +} diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index f90bac149d0f..8c1121ed49c1 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -21,7 +21,6 @@ use zksync_vm2::{ interface::{CallframeInterface, HeapId, StateInterface, Tracer}, ExecutionEnd, FatPointer, Program, Settings, StorageSlot, VirtualMachine, }; -use zksync_vm_interface::{pubdata::PubdataBuilder, InspectExecutionMode}; use super::{ bootloader_state::{BootloaderState, BootloaderStateSnapshot}, @@ -35,20 +34,20 @@ use super::{ use crate::{ glue::GlueInto, interface::{ + pubdata::{PubdataBuilder, PubdataInput}, storage::{ImmutableStorageView, ReadStorage, StoragePtr, StorageView}, BytecodeCompressionError, BytecodeCompressionResult, CurrentExecutionState, - ExecutionResult, FinishedL1Batch, Halt, L1BatchEnv, L2BlockEnv, PushTransactionResult, - Refunds, SystemEnv, TxRevertReason, VmEvent, VmExecutionLogs, VmExecutionMode, - VmExecutionResultAndLogs, VmExecutionStatistics, VmFactory, VmInterface, + ExecutionResult, FinishedL1Batch, Halt, InspectExecutionMode, L1BatchEnv, L2BlockEnv, + PushTransactionResult, Refunds, SystemEnv, TxRevertReason, VmEvent, VmExecutionLogs, + VmExecutionMode, VmExecutionResultAndLogs, VmExecutionStatistics, VmFactory, VmInterface, VmInterfaceHistoryEnabled, VmRevertReason, VmTrackingContracts, }, - is_supported_by_fast_vm, utils::events::extract_l2tol1logs_from_l1_messenger, vm_fast::{ bootloader_state::utils::{apply_l2_block, apply_pubdata_to_memory}, events::merge_events, - pubdata::PubdataInput, refund::compute_refund, + version::FastVMVersion, }, vm_latest::{ constants::{ @@ -56,12 +55,10 @@ use crate::{ OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET, VM_HOOK_PARAMS_COUNT, }, utils::extract_bytecodes_marked_as_known, - MultiVMSubversion, }, + VmVersion, }; -const VM_VERSION: MultiVMSubversion = MultiVMSubversion::IncreasedBootloaderMemory; - type FullTracer = ((Tr, CircuitsTracer), EvmDeployTracer); #[derive(Debug)] @@ -102,17 +99,21 @@ pub struct Vm { pub(super) batch_env: L1BatchEnv, pub(super) system_env: SystemEnv, snapshot: Option, + vm_version: FastVMVersion, #[cfg(test)] enforced_state_diffs: Option>, } impl Vm { pub fn custom(batch_env: L1BatchEnv, system_env: SystemEnv, storage: S) -> Self { - assert!( - is_supported_by_fast_vm(system_env.version), - "Protocol version {:?} is not supported by fast VM", - system_env.version - ); + let vm_version: FastVMVersion = VmVersion::from(system_env.version) + .try_into() + .unwrap_or_else(|_| { + panic!( + "Protocol version {:?} is not supported by fast VM", + system_env.version + ) + }); let default_aa_code_hash = system_env.base_system_smart_contracts.default_aa.hash; let evm_emulator_hash = system_env @@ -146,7 +147,7 @@ impl Vm { Settings { default_aa_code_hash: default_aa_code_hash.into(), evm_interpreter_code_hash: evm_emulator_hash.into(), - hook_address: get_vm_hook_position(VM_VERSION) * 32, + hook_address: get_vm_hook_position(vm_version.into()) * 32, }, ); @@ -166,10 +167,12 @@ impl Vm { system_env.execution_mode, bootloader_memory.clone(), batch_env.first_l2_block, + system_env.version, ), system_env, batch_env, snapshot: None, + vm_version, #[cfg(test)] enforced_state_diffs: None, }; @@ -182,6 +185,7 @@ impl Vm { execution_mode: VmExecutionMode, tracer: &mut FullTracer, track_refunds: bool, + pubdata_builder: Option<&dyn PubdataBuilder>, ) -> VmRunResult { let mut refunds = Refunds { gas_refunded: 0, @@ -352,15 +356,20 @@ impl Vm { state_diffs: self.compute_state_diffs(), }; - // Save the pubdata for the future initial bootloader memory building - self.bootloader_state - .set_pubdata_input(pubdata_input.clone()); - // Apply the pubdata to the current memory let mut memory_to_apply = vec![]; - apply_pubdata_to_memory(&mut memory_to_apply, pubdata_input); + apply_pubdata_to_memory( + &mut memory_to_apply, + pubdata_builder.expect("`pubdata_builder` is required to finish batch"), + &pubdata_input, + self.system_env.version, + ); self.write_to_bootloader_heap(memory_to_apply); + + // Save the pubdata for the future initial bootloader memory building + self.bootloader_state + .set_pubdata_input(pubdata_input.clone()); } Hook::PaymasterValidationEntered | Hook::ValidationStepEnded => { /* unused */ } @@ -385,8 +394,8 @@ impl Vm { } fn get_hook_params(&self) -> [U256; 3] { - (get_vm_hook_params_start_position(VM_VERSION) - ..get_vm_hook_params_start_position(VM_VERSION) + VM_HOOK_PARAMS_COUNT) + (get_vm_hook_params_start_position(self.vm_version.into()) + ..get_vm_hook_params_start_position(self.vm_version.into()) + VM_HOOK_PARAMS_COUNT) .map(|word| self.read_word_from_bootloader_heap(word as usize)) .collect::>() .try_into() @@ -395,7 +404,7 @@ impl Vm { fn get_tx_result(&self) -> U256 { let tx_idx = self.bootloader_state.current_tx(); - let slot = get_result_success_first_slot(VM_VERSION) as usize + tx_idx; + let slot = get_result_success_first_slot(self.vm_version.into()) as usize + tx_idx; self.read_word_from_bootloader_heap(slot) } @@ -577,6 +586,7 @@ impl Vm { &mut self, tracer: &mut Tr, execution_mode: VmExecutionMode, + pubdata_builder: Option<&dyn PubdataBuilder>, ) -> VmExecutionResultAndLogs { let mut track_refunds = false; if matches!(execution_mode, VmExecutionMode::OneTx) { @@ -592,7 +602,12 @@ impl Vm { (mem::take(tracer), CircuitsTracer::default()), EvmDeployTracer::new(self.world.dynamic_bytecodes.clone()), ); - let result = self.run(execution_mode, &mut full_tracer, track_refunds); + let result = self.run( + execution_mode, + &mut full_tracer, + track_refunds, + pubdata_builder, + ); let ((external_tracer, circuits_tracer), _) = full_tracer; *tracer = external_tracer; // place the tracer back @@ -709,7 +724,7 @@ impl VmInterface for Vm { tracer: &mut Self::TracerDispatcher, execution_mode: InspectExecutionMode, ) -> VmExecutionResultAndLogs { - self.inspect_inner(tracer, execution_mode.into()) + self.inspect_inner(tracer, execution_mode.into(), None) } fn inspect_transaction_with_bytecode_compression( @@ -736,19 +751,23 @@ impl VmInterface for Vm { self.bootloader_state.start_new_l2_block(l2_block_env) } - fn finish_batch(&mut self, _pubdata_builder: Rc) -> FinishedL1Batch { - let result = self.inspect_inner(&mut Tr::default(), VmExecutionMode::Batch); + fn finish_batch(&mut self, pubdata_builder: Rc) -> FinishedL1Batch { + let result = self.inspect_inner( + &mut Tr::default(), + VmExecutionMode::Batch, + Some(pubdata_builder.as_ref()), + ); let execution_state = self.get_current_execution_state(); - let bootloader_memory = self.bootloader_state.bootloader_memory(); + let bootloader_memory = self + .bootloader_state + .bootloader_memory(pubdata_builder.as_ref()); FinishedL1Batch { block_tip_execution_result: result, final_execution_state: execution_state, final_bootloader_memory: Some(bootloader_memory), pubdata_input: Some( self.bootloader_state - .get_pubdata_information() - .clone() - .build_pubdata(false), + .settlement_layer_pubdata(pubdata_builder.as_ref()), ), state_diffs: Some( self.bootloader_state diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs index e2f72bd24113..a627e56340d1 100644 --- a/core/lib/multivm/src/vm_instance.rs +++ b/core/lib/multivm/src/vm_instance.rs @@ -14,6 +14,7 @@ use crate::{ VmMemoryMetrics, }, tracers::TracerDispatcher, + vm_fast::FastVMVersion, vm_latest::HistoryEnabled, }; @@ -340,8 +341,5 @@ impl FastVmInstance { /// Checks whether the protocol version is supported by the fast VM. pub fn is_supported_by_fast_vm(protocol_version: ProtocolVersionId) -> bool { - matches!( - protocol_version.into(), - VmVersion::Vm1_5_0IncreasedBootloaderMemory - ) + FastVMVersion::try_from(VmVersion::from(protocol_version)).is_ok() } diff --git a/yarn.lock b/yarn.lock index 58511dd1b9ff..5aadacfeff19 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1424,6 +1424,18 @@ resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c" integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg== +"@isaacs/cliui@^8.0.2": + version "8.0.2" + resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" + integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== + dependencies: + string-width "^5.1.2" + string-width-cjs "npm:string-width@^4.2.0" + strip-ansi "^7.0.1" + strip-ansi-cjs "npm:strip-ansi@^6.0.1" + wrap-ansi "^8.1.0" + wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -2303,6 +2315,11 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.6.tgz#2a880a24eb19b4f8b25adc2a5095f2aa27f39677" integrity sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA== +"@pkgjs/parseargs@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" + integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== + "@pkgr/core@^0.1.0": version "0.1.1" resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" @@ -2633,6 +2650,16 @@ mkdirp "^2.1.6" path-browserify "^1.0.1" +"@ts-morph/common@~0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.23.0.tgz#bd4ddbd3f484f29476c8bd985491592ae5fc147e" + integrity sha512-m7Lllj9n/S6sOkCkRftpM7L24uvmfXQFedlW/4hENcuJH1HHm9u5EgxZb9uVjQSCGrbBWBkOGgcTxNg36r6ywA== + dependencies: + fast-glob "^3.3.2" + minimatch "^9.0.3" + mkdirp "^3.0.1" + path-browserify "^1.0.1" + "@tsconfig/node10@^1.0.7": version "1.0.11" resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.11.tgz#6ee46400685f130e278128c7b38b7e031ff5b2f2" @@ -3305,6 +3332,11 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-regex@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.1.0.tgz#95ec409c69619d6cb1b8b34f14b660ef28ebd654" + integrity sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA== + ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -3324,6 +3356,11 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== +ansi-styles@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + antlr4@^4.11.0: version "4.13.1" resolved "https://registry.yarnpkg.com/antlr4/-/antlr4-4.13.1.tgz#1e0a1830a08faeb86217cb2e6c34716004e4253d" @@ -4183,6 +4220,11 @@ code-block-writer@^12.0.0: resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-12.0.0.tgz#4dd58946eb4234105aff7f0035977b2afdc2a770" integrity sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w== +code-block-writer@^13.0.1: + version "13.0.3" + resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-13.0.3.tgz#90f8a84763a5012da7af61319dd638655ae90b5b" + integrity sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg== + collect-v8-coverage@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9" @@ -4435,6 +4477,15 @@ cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" +cross-spawn@^7.0.0: + version "7.0.5" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.5.tgz#910aac880ff5243da96b728bc6521a5f6c2f2f82" + integrity sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" @@ -4738,6 +4789,11 @@ dotenv@^8.2.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b" integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g== +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -4804,6 +4860,11 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + encoding-down@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/encoding-down/-/encoding-down-6.3.0.tgz#b1c4eb0e1728c146ecaef8e32963c549e76d082b" @@ -5774,6 +5835,14 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" +foreground-child@^3.1.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.3.0.tgz#0ac8644c06e431439f8561db8ecf29a7b5519c77" + integrity sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg== + dependencies: + cross-spawn "^7.0.0" + signal-exit "^4.0.1" + forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -6062,6 +6131,18 @@ glob@8.1.0, glob@^8.0.3: minimatch "^5.0.1" once "^1.3.0" +glob@^10.4.1: + version "10.4.5" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956" + integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg== + dependencies: + foreground-child "^3.1.0" + jackspeak "^3.1.2" + minimatch "^9.0.4" + minipass "^7.1.2" + package-json-from-dist "^1.0.0" + path-scurry "^1.11.1" + glob@^5.0.15: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" @@ -6974,6 +7055,15 @@ istanbul-reports@^3.1.3: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" +jackspeak@^3.1.2: + version "3.4.3" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a" + integrity sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw== + dependencies: + "@isaacs/cliui" "^8.0.2" + optionalDependencies: + "@pkgjs/parseargs" "^0.11.0" + jest-changed-files@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-29.7.0.tgz#1c06d07e77c78e1585d020424dedc10d6e17ac3a" @@ -7877,6 +7967,11 @@ lowercase-keys@^3.0.0: resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-3.0.0.tgz#c5e7d442e37ead247ae9db117a9d0a467c89d4f2" integrity sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ== +lru-cache@^10.2.0: + version "10.4.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" + integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -8175,6 +8270,13 @@ minimatch@^7.4.3: dependencies: brace-expansion "^2.0.1" +minimatch@^9.0.3, minimatch@^9.0.4: + version "9.0.5" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.5.tgz#d74f9dd6b57d83d8e98cfb82133b03978bc929e5" + integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow== + dependencies: + brace-expansion "^2.0.1" + minimatch@~3.0.4: version "3.0.8" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.8.tgz#5e6a59bd11e2ab0de1cfb843eb2d82e546c321c1" @@ -8187,6 +8289,11 @@ minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6, minimist@^1.2.8, minimist@~1. resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== +"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.1.2: + version "7.1.2" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707" + integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw== + mkdirp-classic@^0.5.2: version "0.5.3" resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" @@ -8209,6 +8316,11 @@ mkdirp@^2.1.6: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19" integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A== +mkdirp@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50" + integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg== + mnemonist@^0.38.0: version "0.38.5" resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.38.5.tgz#4adc7f4200491237fe0fa689ac0b86539685cade" @@ -8664,6 +8776,11 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +package-json-from-dist@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz#4f1471a010827a86f94cfd9b0727e36d267de505" + integrity sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw== + package-json@^8.1.0: version "8.1.1" resolved "https://registry.yarnpkg.com/package-json/-/package-json-8.1.1.tgz#3e9948e43df40d1e8e78a85485f1070bf8f03dc8" @@ -8739,6 +8856,14 @@ path-parse@^1.0.6, path-parse@^1.0.7: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== +path-scurry@^1.11.1: + version "1.11.1" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2" + integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA== + dependencies: + lru-cache "^10.2.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + path-to-regexp@^6.2.1: version "6.2.2" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.2.2.tgz#324377a83e5049cbecadc5554d6a63a9a4866b36" @@ -9739,6 +9864,11 @@ signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +signal-exit@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + sinon-chai@^3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/sinon-chai/-/sinon-chai-3.7.0.tgz#cfb7dec1c50990ed18c153f1840721cf13139783" @@ -10070,6 +10200,15 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -10087,6 +10226,15 @@ string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2 is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + string.prototype.padend@^3.0.0: version "3.1.6" resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.1.6.tgz#ba79cf8992609a91c872daa47c6bb144ee7f62a5" @@ -10144,6 +10292,13 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" @@ -10165,6 +10320,13 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + dependencies: + ansi-regex "^6.0.1" + strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" @@ -10520,6 +10682,14 @@ ts-morph@^19.0.0: "@ts-morph/common" "~0.20.0" code-block-writer "^12.0.0" +ts-morph@^22.0.0: + version "22.0.0" + resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-22.0.0.tgz#5532c592fb6dddae08846f12c9ab0fc590b1d42e" + integrity sha512-M9MqFGZREyeb5fTl6gNHKZLqBQA0TjA1lea+CR48R8EBTDuWrNqW6ccC5QvjNR4s6wDumD3LTCjOFSp9iwlzaw== + dependencies: + "@ts-morph/common" "~0.23.0" + code-block-writer "^13.0.1" + ts-node@^10.1.0, ts-node@^10.7.0: version "10.9.2" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" @@ -11000,6 +11170,15 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" @@ -11009,6 +11188,15 @@ wrap-ansi@^7.0.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== + dependencies: + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" From c4bd2ad6fa812460b566d1ad5e0e7516153bc49e Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Tue, 12 Nov 2024 13:38:15 +0200 Subject: [PATCH 2/3] rename VM -> Vm in some types --- core/lib/multivm/src/glue/tracers/mod.rs | 16 +++++++------- core/lib/multivm/src/lib.rs | 2 +- core/lib/multivm/src/utils/mod.rs | 18 +++++++-------- core/lib/multivm/src/versions/vm_fast/mod.rs | 2 +- .../multivm/src/versions/vm_fast/version.rs | 14 ++++++------ core/lib/multivm/src/versions/vm_fast/vm.rs | 6 ++--- .../src/versions/vm_latest/constants.rs | 22 +++++++++---------- .../lib/multivm/src/versions/vm_latest/mod.rs | 2 +- .../src/versions/vm_latest/tests/constants.rs | 2 +- .../src/versions/vm_latest/tests/mod.rs | 2 +- .../vm_latest/tracers/default_tracers.rs | 6 ++--- .../vm_latest/tracers/pubdata_tracer.rs | 8 +++---- .../src/versions/vm_latest/tracers/refunds.rs | 6 ++--- .../vm_latest/tracers/result_tracer.rs | 8 +++---- .../src/versions/vm_latest/tracers/utils.rs | 10 ++++----- core/lib/multivm/src/versions/vm_latest/vm.rs | 10 ++++----- .../src/versions/vm_m5/oracle_tools.rs | 4 ++-- .../src/versions/vm_m5/oracles/storage.rs | 10 ++++----- core/lib/multivm/src/versions/vm_m5/vm.rs | 8 +++---- .../multivm/src/versions/vm_m5/vm_instance.rs | 8 +++---- .../src/versions/vm_m5/vm_with_bootloader.rs | 8 +++---- core/lib/multivm/src/versions/vm_m6/vm.rs | 8 +++---- .../multivm/src/versions/vm_m6/vm_instance.rs | 4 ++-- .../src/versions/vm_m6/vm_with_bootloader.rs | 18 +++++++-------- core/lib/multivm/src/vm_instance.rs | 18 +++++++-------- core/lib/vm_executor/src/batch/factory.rs | 2 +- core/lib/vm_executor/src/oneshot/contracts.rs | 14 ++++++------ core/lib/vm_executor/src/oneshot/mod.rs | 4 ++-- core/node/api_server/src/tx_sender/mod.rs | 6 ++--- core/node/consensus/src/vm.rs | 4 ++-- core/node/genesis/src/utils.rs | 4 ++-- 31 files changed, 127 insertions(+), 127 deletions(-) diff --git a/core/lib/multivm/src/glue/tracers/mod.rs b/core/lib/multivm/src/glue/tracers/mod.rs index bf2f67cae501..f5a854ecbaaf 100644 --- a/core/lib/multivm/src/glue/tracers/mod.rs +++ b/core/lib/multivm/src/glue/tracers/mod.rs @@ -7,7 +7,7 @@ //! Different VM versions may have distinct requirements and types for Tracers. To accommodate these differences, //! this module defines one primary trait: //! -//! - `MultiVMTracer`: This trait represents a tracer that can be converted into a tracer for +//! - `MultiVmTracer`: This trait represents a tracer that can be converted into a tracer for //! a specific VM version. //! //! Specific traits for each VM version, which support Custom Tracers: @@ -19,22 +19,22 @@ //! into a form compatible with the vm_virtual_blocks version. //! It defines a method `vm_virtual_blocks` for obtaining a boxed tracer. //! -//! For `MultiVMTracer` to be implemented, the Tracer must implement all N currently +//! For `MultiVmTracer` to be implemented, the Tracer must implement all N currently //! existing sub-traits. //! //! ## Adding a new VM version //! -//! To add support for one more VM version to MultiVMTracer, one needs to: +//! To add support for one more VM version to MultiVmTracer, one needs to: //! - Create a new trait performing conversion to the specified VM tracer, e.g., `IntoTracer`. -//! - Add this trait as a trait bound to the `MultiVMTracer`. -//! - Add this trait as a trait bound for `T` in `MultiVMTracer` implementation. +//! - Add this trait as a trait bound to the `MultiVmTracer`. +//! - Add this trait as a trait bound for `T` in `MultiVmTracer` implementation. //! - Implement the trait for `T` with a bound to `VmTracer` for a specific version. use crate::{interface::storage::WriteStorage, tracers::old::OldTracers, HistoryMode}; -pub type MultiVmTracerPointer = Box>; +pub type MultiVmTracerPointer = Box>; -pub trait MultiVMTracer: +pub trait MultiVmTracer: IntoLatestTracer + IntoVmVirtualBlocksTracer + IntoVmRefundsEnhancementTracer @@ -168,7 +168,7 @@ where } } -impl MultiVMTracer for T +impl MultiVmTracer for T where S: WriteStorage, H: HistoryMode, diff --git a/core/lib/multivm/src/lib.rs b/core/lib/multivm/src/lib.rs index 1cba2c0fb92b..fc4085d9b021 100644 --- a/core/lib/multivm/src/lib.rs +++ b/core/lib/multivm/src/lib.rs @@ -10,7 +10,7 @@ pub use zksync_vm_interface as interface; pub use crate::{ glue::{ history_mode::HistoryMode, - tracers::{MultiVMTracer, MultiVmTracerPointer}, + tracers::{MultiVmTracer, MultiVmTracerPointer}, }, versions::{ vm_1_3_2, vm_1_4_1, vm_1_4_2, vm_boojum_integration, vm_fast, vm_latest, vm_m5, vm_m6, diff --git a/core/lib/multivm/src/utils/mod.rs b/core/lib/multivm/src/utils/mod.rs index a55adb16c85a..4332c0327ff1 100644 --- a/core/lib/multivm/src/utils/mod.rs +++ b/core/lib/multivm/src/utils/mod.rs @@ -239,16 +239,16 @@ pub fn get_bootloader_encoding_space(version: VmVersion) -> u32 { VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::BOOTLOADER_TX_ENCODING_SPACE, VmVersion::Vm1_5_0SmallBootloaderMemory => { crate::vm_latest::constants::get_bootloader_tx_encoding_space( - crate::vm_latest::MultiVMSubversion::SmallBootloaderMemory, + crate::vm_latest::MultiVmSubversion::SmallBootloaderMemory, ) } VmVersion::Vm1_5_0IncreasedBootloaderMemory => { crate::vm_latest::constants::get_bootloader_tx_encoding_space( - crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory, + crate::vm_latest::MultiVmSubversion::IncreasedBootloaderMemory, ) } VmVersion::VmGateway => crate::vm_latest::constants::get_bootloader_tx_encoding_space( - crate::vm_latest::MultiVMSubversion::Gateway, + crate::vm_latest::MultiVmSubversion::Gateway, ), } } @@ -394,16 +394,16 @@ pub fn get_used_bootloader_memory_bytes(version: VmVersion) -> usize { VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::USED_BOOTLOADER_MEMORY_BYTES, VmVersion::Vm1_5_0SmallBootloaderMemory => { crate::vm_latest::constants::get_used_bootloader_memory_bytes( - crate::vm_latest::MultiVMSubversion::SmallBootloaderMemory, + crate::vm_latest::MultiVmSubversion::SmallBootloaderMemory, ) } VmVersion::Vm1_5_0IncreasedBootloaderMemory => { crate::vm_latest::constants::get_used_bootloader_memory_bytes( - crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory, + crate::vm_latest::MultiVmSubversion::IncreasedBootloaderMemory, ) } VmVersion::VmGateway => crate::vm_latest::constants::get_used_bootloader_memory_bytes( - crate::vm_latest::MultiVMSubversion::Gateway, + crate::vm_latest::MultiVmSubversion::Gateway, ), } } @@ -430,16 +430,16 @@ pub fn get_used_bootloader_memory_words(version: VmVersion) -> usize { VmVersion::Vm1_4_2 => crate::vm_1_4_2::constants::USED_BOOTLOADER_MEMORY_WORDS, VmVersion::Vm1_5_0SmallBootloaderMemory => { crate::vm_latest::constants::get_used_bootloader_memory_bytes( - crate::vm_latest::MultiVMSubversion::SmallBootloaderMemory, + crate::vm_latest::MultiVmSubversion::SmallBootloaderMemory, ) } VmVersion::Vm1_5_0IncreasedBootloaderMemory => { crate::vm_latest::constants::get_used_bootloader_memory_bytes( - crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory, + crate::vm_latest::MultiVmSubversion::IncreasedBootloaderMemory, ) } VmVersion::VmGateway => crate::vm_latest::constants::get_used_bootloader_memory_bytes( - crate::vm_latest::MultiVMSubversion::Gateway, + crate::vm_latest::MultiVmSubversion::Gateway, ), } } diff --git a/core/lib/multivm/src/versions/vm_fast/mod.rs b/core/lib/multivm/src/versions/vm_fast/mod.rs index 95f041583399..840653b63b08 100644 --- a/core/lib/multivm/src/versions/vm_fast/mod.rs +++ b/core/lib/multivm/src/versions/vm_fast/mod.rs @@ -1,6 +1,6 @@ pub use zksync_vm2::interface; -pub(crate) use self::version::FastVMVersion; +pub(crate) use self::version::FastVmVersion; pub use self::vm::Vm; mod bootloader_state; diff --git a/core/lib/multivm/src/versions/vm_fast/version.rs b/core/lib/multivm/src/versions/vm_fast/version.rs index a813e6d0e886..8da180d8ba59 100644 --- a/core/lib/multivm/src/versions/vm_fast/version.rs +++ b/core/lib/multivm/src/versions/vm_fast/version.rs @@ -1,21 +1,21 @@ -use crate::{vm_latest::MultiVMSubversion, VmVersion}; +use crate::{vm_latest::MultiVmSubversion, VmVersion}; #[derive(Debug, Copy, Clone)] -pub(crate) enum FastVMVersion { +pub(crate) enum FastVmVersion { IncreasedBootloaderMemory, Gateway, } -impl From for MultiVMSubversion { - fn from(value: FastVMVersion) -> Self { +impl From for MultiVmSubversion { + fn from(value: FastVmVersion) -> Self { match value { - FastVMVersion::IncreasedBootloaderMemory => Self::IncreasedBootloaderMemory, - FastVMVersion::Gateway => Self::Gateway, + FastVmVersion::IncreasedBootloaderMemory => Self::IncreasedBootloaderMemory, + FastVmVersion::Gateway => Self::Gateway, } } } -impl TryFrom for FastVMVersion { +impl TryFrom for FastVmVersion { type Error = (); fn try_from(value: VmVersion) -> Result { diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index f80ff11baf04..4f9aa03873fb 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -49,7 +49,7 @@ use crate::{ bootloader_state::utils::{apply_l2_block, apply_pubdata_to_memory}, events::merge_events, refund::compute_refund, - version::FastVMVersion, + version::FastVmVersion, }, vm_latest::constants::{ get_result_success_first_slot, get_vm_hook_params_start_position, get_vm_hook_position, @@ -98,14 +98,14 @@ pub struct Vm { pub(super) batch_env: L1BatchEnv, pub(super) system_env: SystemEnv, snapshot: Option, - vm_version: FastVMVersion, + vm_version: FastVmVersion, #[cfg(test)] enforced_state_diffs: Option>, } impl Vm { pub fn custom(batch_env: L1BatchEnv, system_env: SystemEnv, storage: S) -> Self { - let vm_version: FastVMVersion = VmVersion::from(system_env.version) + let vm_version: FastVmVersion = VmVersion::from(system_env.version) .try_into() .unwrap_or_else(|_| { panic!( diff --git a/core/lib/multivm/src/versions/vm_latest/constants.rs b/core/lib/multivm/src/versions/vm_latest/constants.rs index c047e6ffa3b0..c95771f9e849 100644 --- a/core/lib/multivm/src/versions/vm_latest/constants.rs +++ b/core/lib/multivm/src/versions/vm_latest/constants.rs @@ -5,7 +5,7 @@ pub use zk_evm_1_5_0::zkevm_opcode_defs::system_params::{ }; use zksync_system_constants::MAX_NEW_FACTORY_DEPS; -use super::vm::MultiVMSubversion; +use super::vm::MultiVmSubversion; use crate::vm_latest::old_vm::utils::heap_page_from_base; /// The amount of ergs to be reserved at the end of the batch to ensure that it has enough ergs to verify compression, etc. @@ -22,15 +22,15 @@ pub(crate) const MAX_BASE_LAYER_CIRCUITS: usize = 34100; /// the requirements on RAM. /// In this version of the VM the used bootloader memory bytes has increased from `30_000_000` to `59_000_000`, /// and then to `63_800_000` in a subsequent upgrade. -pub(crate) const fn get_used_bootloader_memory_bytes(subversion: MultiVMSubversion) -> usize { +pub(crate) const fn get_used_bootloader_memory_bytes(subversion: MultiVmSubversion) -> usize { match subversion { - MultiVMSubversion::SmallBootloaderMemory => 59_000_000, - MultiVMSubversion::IncreasedBootloaderMemory => 63_800_000, - MultiVMSubversion::Gateway => 63_800_000, + MultiVmSubversion::SmallBootloaderMemory => 59_000_000, + MultiVmSubversion::IncreasedBootloaderMemory => 63_800_000, + MultiVmSubversion::Gateway => 63_800_000, } } -pub(crate) const fn get_used_bootloader_memory_words(subversion: MultiVMSubversion) -> usize { +pub(crate) const fn get_used_bootloader_memory_words(subversion: MultiVmSubversion) -> usize { get_used_bootloader_memory_bytes(subversion) / 32 } @@ -105,7 +105,7 @@ pub(crate) const BOOTLOADER_TX_DESCRIPTION_OFFSET: usize = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS; /// The size of the bootloader memory dedicated to the encodings of transactions -pub(crate) const fn get_bootloader_tx_encoding_space(subversion: MultiVMSubversion) -> u32 { +pub(crate) const fn get_bootloader_tx_encoding_space(subversion: MultiVmSubversion) -> u32 { (get_used_bootloader_memory_words(subversion) - TX_DESCRIPTION_OFFSET - MAX_TXS_IN_BATCH) as u32 } @@ -129,21 +129,21 @@ pub const BOOTLOADER_HEAP_PAGE: u32 = heap_page_from_base(MemoryPage(INITIAL_BAS /// So the layout looks like this: /// `[param 0][param 1][param 2][vmhook opcode]` pub const VM_HOOK_PARAMS_COUNT: u32 = 3; -pub(crate) const fn get_vm_hook_position(subversion: MultiVMSubversion) -> u32 { +pub(crate) const fn get_vm_hook_position(subversion: MultiVmSubversion) -> u32 { get_result_success_first_slot(subversion) - 1 } -pub(crate) const fn get_vm_hook_params_start_position(subversion: MultiVMSubversion) -> u32 { +pub(crate) const fn get_vm_hook_params_start_position(subversion: MultiVmSubversion) -> u32 { get_vm_hook_position(subversion) - VM_HOOK_PARAMS_COUNT } /// Method that provides the start position of the vm hook in the memory for the latest version of v1.5.0. /// This method is used only in `test_infra` in the bootloader tests and that's why it should be exposed. pub const fn get_vm_hook_start_position_latest() -> u32 { - get_vm_hook_params_start_position(MultiVMSubversion::IncreasedBootloaderMemory) + get_vm_hook_params_start_position(MultiVmSubversion::IncreasedBootloaderMemory) } /// Arbitrary space in memory closer to the end of the page -pub(crate) const fn get_result_success_first_slot(subversion: MultiVMSubversion) -> u32 { +pub(crate) const fn get_result_success_first_slot(subversion: MultiVmSubversion) -> u32 { ((get_used_bootloader_memory_bytes(subversion) as u32) - (MAX_TXS_IN_BATCH as u32) * 32) / 32 } diff --git a/core/lib/multivm/src/versions/vm_latest/mod.rs b/core/lib/multivm/src/versions/vm_latest/mod.rs index 211c527c3816..46f8db789ddc 100644 --- a/core/lib/multivm/src/versions/vm_latest/mod.rs +++ b/core/lib/multivm/src/versions/vm_latest/mod.rs @@ -1,4 +1,4 @@ -pub(crate) use self::vm::MultiVMSubversion; +pub(crate) use self::vm::MultiVmSubversion; pub use self::{ bootloader_state::BootloaderState, old_vm::{ diff --git a/core/lib/multivm/src/versions/vm_latest/tests/constants.rs b/core/lib/multivm/src/versions/vm_latest/tests/constants.rs index 3b75bfd6d36b..8ee62650ca77 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/constants.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/constants.rs @@ -3,7 +3,7 @@ #[test] fn test_that_bootloader_encoding_space_is_large_enoguh() { let encoding_space = crate::vm_latest::constants::get_bootloader_tx_encoding_space( - crate::vm_latest::MultiVMSubversion::latest(), + crate::vm_latest::MultiVmSubversion::latest(), ); assert!(encoding_space >= 330000, "Bootloader tx space is too small"); } diff --git a/core/lib/multivm/src/versions/vm_latest/tests/mod.rs b/core/lib/multivm/src/versions/vm_latest/tests/mod.rs index 51c9dde0dd56..fc226f03ecea 100644 --- a/core/lib/multivm/src/versions/vm_latest/tests/mod.rs +++ b/core/lib/multivm/src/versions/vm_latest/tests/mod.rs @@ -91,7 +91,7 @@ impl TestedVm for TestedLatestVm { self.batch_env.clone(), VmExecutionMode::Batch, diffs, - crate::vm_latest::MultiVMSubversion::latest(), + crate::vm_latest::MultiVmSubversion::latest(), Some(pubdata_builder), ); self.inspect_inner( diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/default_tracers.rs b/core/lib/multivm/src/versions/vm_latest/tracers/default_tracers.rs index 7156acce152e..8755b98ddb8c 100755 --- a/core/lib/multivm/src/versions/vm_latest/tracers/default_tracers.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/default_tracers.rs @@ -32,7 +32,7 @@ use crate::{ CircuitsTracer, RefundsTracer, ResultTracer, }, types::internals::ZkSyncVmState, - vm::MultiVMSubversion, + vm::MultiVmSubversion, VmTracer, }, }; @@ -65,7 +65,7 @@ pub struct DefaultExecutionTracer { pub(crate) circuits_tracer: CircuitsTracer, // This tracer is responsible for handling EVM deployments and providing the data to the code decommitter. pub(crate) evm_deploy_tracer: Option>, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, storage: StoragePtr, _phantom: PhantomData, } @@ -80,7 +80,7 @@ impl DefaultExecutionTracer { storage: StoragePtr, refund_tracer: Option>, pubdata_tracer: Option>, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, ) -> Self { Self { tx_has_been_processed: false, diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs index 4c71c3b2fc49..3698914630dd 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/pubdata_tracer.rs @@ -33,7 +33,7 @@ use crate::{ tracers::{traits::VmTracer, utils::VmHook}, types::internals::ZkSyncVmState, utils::logs::collect_events_and_l1_system_logs_after_timestamp, - vm::MultiVMSubversion, + vm::MultiVmSubversion, StorageOracle, }, }; @@ -47,7 +47,7 @@ pub(crate) struct PubdataTracer { // For testing purposes it might be helpful to supply an exact set of state diffs to be provided // to the L1Messenger. enforced_state_diffs: Option>, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, pubdata_builder: Option>, _phantom_data: PhantomData, } @@ -56,7 +56,7 @@ impl PubdataTracer { pub(crate) fn new( l1_batch_env: L1BatchEnv, execution_mode: VmExecutionMode, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, pubdata_builder: Option>, ) -> Self { Self { @@ -77,7 +77,7 @@ impl PubdataTracer { l1_batch_env: L1BatchEnv, execution_mode: VmExecutionMode, forced_state_diffs: Vec, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, pubdata_builder: Option>, ) -> Self { Self { diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/refunds.rs b/core/lib/multivm/src/versions/vm_latest/tracers/refunds.rs index f3fc1b167b45..6ef251c2db98 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/refunds.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/refunds.rs @@ -24,7 +24,7 @@ use crate::{ }, types::internals::ZkSyncVmState, utils::fee::get_batch_base_fee, - vm::MultiVMSubversion, + vm::MultiVmSubversion, }, }; @@ -50,12 +50,12 @@ pub(crate) struct RefundsTracer { spent_pubdata_counter_before: u32, l1_batch: L1BatchEnv, pubdata_published: u32, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, _phantom: PhantomData, } impl RefundsTracer { - pub(crate) fn new(l1_batch: L1BatchEnv, subversion: MultiVMSubversion) -> Self { + pub(crate) fn new(l1_batch: L1BatchEnv, subversion: MultiVmSubversion) -> Self { Self { pending_refund_request: None, refund_gas: 0, diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/result_tracer.rs b/core/lib/multivm/src/versions/vm_latest/tracers/result_tracer.rs index 0687c8393c62..80a3147f65d2 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/result_tracer.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/result_tracer.rs @@ -23,7 +23,7 @@ use crate::{ utils::{get_vm_hook_params, read_pointer, VmHook}, }, types::internals::ZkSyncVmState, - vm::MultiVMSubversion, + vm::MultiVmSubversion, BootloaderState, HistoryMode, SimpleMemory, }, }; @@ -102,7 +102,7 @@ pub(crate) struct ResultTracer { execution_mode: VmExecutionMode, far_call_tracker: FarCallTracker, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, pub(crate) tx_finished_in_one_tx_mode: bool, @@ -110,7 +110,7 @@ pub(crate) struct ResultTracer { } impl ResultTracer { - pub(crate) fn new(execution_mode: VmExecutionMode, subversion: MultiVMSubversion) -> Self { + pub(crate) fn new(execution_mode: VmExecutionMode, subversion: MultiVmSubversion) -> Self { Self { result: None, bootloader_out_of_gas: false, @@ -336,7 +336,7 @@ impl ResultTracer { pub(crate) fn tx_has_failed( state: &ZkSyncVmState, tx_id: u32, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, ) -> bool { let mem_slot = get_result_success_first_slot(subversion) + tx_id; let mem_value = state diff --git a/core/lib/multivm/src/versions/vm_latest/tracers/utils.rs b/core/lib/multivm/src/versions/vm_latest/tracers/utils.rs index 50901dca62fc..6f81a3ac8de5 100644 --- a/core/lib/multivm/src/versions/vm_latest/tracers/utils.rs +++ b/core/lib/multivm/src/versions/vm_latest/tracers/utils.rs @@ -21,7 +21,7 @@ use crate::vm_latest::{ memory::SimpleMemory, utils::{aux_heap_page_from_base, heap_page_from_base}, }, - vm::MultiVMSubversion, + vm::MultiVmSubversion, }; #[derive(Clone, Debug, Copy)] @@ -47,7 +47,7 @@ impl VmHook { pub(crate) fn from_opcode_memory( state: &VmLocalStateData<'_>, data: &BeforeExecutionData, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, ) -> Self { let opcode_variant = data.opcode.variant; let heap_page = @@ -89,7 +89,7 @@ impl VmHook { pub(crate) fn get_debug_log( state: &VmLocalStateData<'_>, memory: &SimpleMemory, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, ) -> String { let vm_hook_params: Vec<_> = get_vm_hook_params(memory, subversion) .into_iter() @@ -161,7 +161,7 @@ pub(crate) fn print_debug_if_needed( state: &VmLocalStateData<'_>, memory: &SimpleMemory, latest_returndata_ptr: Option, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, ) { let log = match hook { VmHook::DebugLog => get_debug_log(state, memory, subversion), @@ -210,7 +210,7 @@ pub(crate) fn get_calldata_page_via_abi(far_call_abi: &FarCallABI, base_page: Me } pub(crate) fn get_vm_hook_params( memory: &SimpleMemory, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, ) -> Vec { let start_position = get_vm_hook_params_start_position(subversion); memory.dump_page_content_as_u256_words( diff --git a/core/lib/multivm/src/versions/vm_latest/vm.rs b/core/lib/multivm/src/versions/vm_latest/vm.rs index 5a0e77023a5e..ada20af9fa3c 100644 --- a/core/lib/multivm/src/versions/vm_latest/vm.rs +++ b/core/lib/multivm/src/versions/vm_latest/vm.rs @@ -35,7 +35,7 @@ use crate::{ /// version was released with increased bootloader memory. The version with the small bootloader memory /// is available only on internal staging environments. #[derive(Debug, Copy, Clone)] -pub(crate) enum MultiVMSubversion { +pub(crate) enum MultiVmSubversion { /// The initial version of v1.5.0, available only on staging environments. SmallBootloaderMemory, /// The final correct version of v1.5.0 @@ -44,7 +44,7 @@ pub(crate) enum MultiVMSubversion { Gateway, } -impl MultiVMSubversion { +impl MultiVmSubversion { #[cfg(test)] pub(crate) fn latest() -> Self { Self::IncreasedBootloaderMemory @@ -53,7 +53,7 @@ impl MultiVMSubversion { #[derive(Debug)] pub(crate) struct VmVersionIsNotVm150Error; -impl TryFrom for MultiVMSubversion { +impl TryFrom for MultiVmSubversion { type Error = VmVersionIsNotVm150Error; fn try_from(value: VmVersion) -> Result { match value { @@ -77,7 +77,7 @@ pub struct Vm { pub(crate) batch_env: L1BatchEnv, // Snapshots for the current run pub(crate) snapshots: Vec, - pub(crate) subversion: MultiVMSubversion, + pub(crate) subversion: MultiVmSubversion, _phantom: std::marker::PhantomData, } @@ -247,7 +247,7 @@ impl Vm { batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr, - subversion: MultiVMSubversion, + subversion: MultiVmSubversion, ) -> Self { let (state, bootloader_state) = new_vm_state(storage.clone(), &system_env, &batch_env); Self { diff --git a/core/lib/multivm/src/versions/vm_m5/oracle_tools.rs b/core/lib/multivm/src/versions/vm_m5/oracle_tools.rs index 32930f31cd71..f430ad346387 100644 --- a/core/lib/multivm/src/versions/vm_m5/oracle_tools.rs +++ b/core/lib/multivm/src/versions/vm_m5/oracle_tools.rs @@ -10,7 +10,7 @@ use crate::vm_m5::{ storage::StorageOracle, }, storage::{Storage, StoragePtr}, - vm_instance::MultiVMSubversion, + vm_instance::MultiVmSubversion, }; #[derive(Debug)] @@ -25,7 +25,7 @@ pub struct OracleTools { } impl OracleTools { - pub fn new(storage_pointer: StoragePtr, refund_state: MultiVMSubversion) -> Self { + pub fn new(storage_pointer: StoragePtr, refund_state: MultiVmSubversion) -> Self { Self { storage: StorageOracle::new(storage_pointer.clone(), refund_state), memory: SimpleMemory::default(), diff --git a/core/lib/multivm/src/versions/vm_m5/oracles/storage.rs b/core/lib/multivm/src/versions/vm_m5/oracles/storage.rs index ab373e9e7696..90bd9cfaab69 100644 --- a/core/lib/multivm/src/versions/vm_m5/oracles/storage.rs +++ b/core/lib/multivm/src/versions/vm_m5/oracles/storage.rs @@ -18,7 +18,7 @@ use crate::vm_m5::{ }, storage::{Storage, StoragePtr}, utils::StorageLogQuery, - vm_instance::MultiVMSubversion, + vm_instance::MultiVmSubversion, }; // While the storage does not support different shards, it was decided to write the @@ -45,7 +45,7 @@ pub struct StorageOracle { // to cover this slot. pub paid_changes: HistoryRecorder>, - pub refund_state: MultiVMSubversion, + pub refund_state: MultiVmSubversion, } impl OracleWithHistory for StorageOracle { @@ -63,7 +63,7 @@ impl OracleWithHistory for StorageOracle { } impl StorageOracle { - pub fn new(storage: StoragePtr, refund_state: MultiVMSubversion) -> Self { + pub fn new(storage: StoragePtr, refund_state: MultiVmSubversion) -> Self { Self { storage: HistoryRecorder::from_inner(StorageWrapper::new(storage)), frames_stack: Default::default(), @@ -74,10 +74,10 @@ impl StorageOracle { fn is_storage_key_free(&self, key: &StorageKey) -> bool { match self.refund_state { - MultiVMSubversion::V1 => { + MultiVmSubversion::V1 => { key.address() == &zksync_system_constants::SYSTEM_CONTEXT_ADDRESS } - MultiVMSubversion::V2 => { + MultiVmSubversion::V2 => { key.address() == &zksync_system_constants::SYSTEM_CONTEXT_ADDRESS || *key == storage_key_for_eth_balance(&BOOTLOADER_ADDRESS) } diff --git a/core/lib/multivm/src/versions/vm_m5/vm.rs b/core/lib/multivm/src/versions/vm_m5/vm.rs index 266a0a437e5e..bd104b868401 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm.rs @@ -12,7 +12,7 @@ use crate::{ }, vm_m5::{ storage::Storage, - vm_instance::{MultiVMSubversion, VmInstance}, + vm_instance::{MultiVmSubversion, VmInstance}, }, }; @@ -28,7 +28,7 @@ impl Vm { batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr, - vm_sub_version: MultiVMSubversion, + vm_sub_version: MultiVmSubversion, ) -> Self { let oracle_tools = crate::vm_m5::OracleTools::new(storage.clone(), vm_sub_version); let block_properties = zk_evm_1_3_1::block_properties::BlockProperties { @@ -127,8 +127,8 @@ impl VmFactory for Vm { fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let vm_version: VmVersion = system_env.version.into(); let vm_sub_version = match vm_version { - VmVersion::M5WithoutRefunds => MultiVMSubversion::V1, - VmVersion::M5WithRefunds => MultiVMSubversion::V2, + VmVersion::M5WithoutRefunds => MultiVmSubversion::V1, + VmVersion::M5WithRefunds => MultiVmSubversion::V2, _ => panic!("Unsupported protocol version for vm_m5: {:?}", vm_version), }; Self::new_with_subversion(batch_env, system_env, storage, vm_sub_version) diff --git a/core/lib/multivm/src/versions/vm_m5/vm_instance.rs b/core/lib/multivm/src/versions/vm_m5/vm_instance.rs index 4a96c4a750cc..94b86bce7ea7 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm_instance.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm_instance.rs @@ -81,7 +81,7 @@ pub(crate) fn get_vm_hook_params(memory: &SimpleMemory) -> Vec { /// /// This enum allows to execute blocks with the same VM but different support for refunds. #[derive(Debug, Copy, Clone)] -pub enum MultiVMSubversion { +pub enum MultiVmSubversion { /// Initial VM M5 version, refunds are fully disabled. V1, /// Refunds were enabled. ETH balance for bootloader address was marked as a free slot. @@ -99,7 +99,7 @@ pub struct VmInstance { pub snapshots: Vec, /// MultiVM-specific addition. See enum doc-comment for details. - pub(crate) refund_state: MultiVMSubversion, + pub(crate) refund_state: MultiVmSubversion, } /// This structure stores data that accumulates during the VM run. @@ -560,12 +560,12 @@ impl VmInstance { let refund_to_propose; let refund_slot; match self.refund_state { - MultiVMSubversion::V1 => { + MultiVmSubversion::V1 => { refund_to_propose = bootloader_refund; refund_slot = OPERATOR_REFUNDS_OFFSET + self.bootloader_state.tx_to_execute() - 1; } - MultiVMSubversion::V2 => { + MultiVmSubversion::V2 => { let gas_spent_on_pubdata = tracer .gas_spent_on_pubdata(&self.state.local_state) - spent_pubdata_counter_before; diff --git a/core/lib/multivm/src/versions/vm_m5/vm_with_bootloader.rs b/core/lib/multivm/src/versions/vm_m5/vm_with_bootloader.rs index 653169cd7ff0..706c0fbc717c 100644 --- a/core/lib/multivm/src/versions/vm_m5/vm_with_bootloader.rs +++ b/core/lib/multivm/src/versions/vm_m5/vm_with_bootloader.rs @@ -30,7 +30,7 @@ use crate::{ utils::{ code_page_candidate_from_base, heap_page_from_base, BLOCK_GAS_LIMIT, INITIAL_BASE_PAGE, }, - vm_instance::{MultiVMSubversion, VmInstance, ZkSyncVmState}, + vm_instance::{MultiVmSubversion, VmInstance, ZkSyncVmState}, OracleTools, }, }; @@ -222,7 +222,7 @@ impl Default for TxExecutionMode { } pub fn init_vm( - refund_state: MultiVMSubversion, + refund_state: MultiVmSubversion, oracle_tools: OracleTools, block_context: BlockContextMode, block_properties: BlockProperties, @@ -241,7 +241,7 @@ pub fn init_vm( } pub fn init_vm_with_gas_limit( - refund_state: MultiVMSubversion, + refund_state: MultiVmSubversion, oracle_tools: OracleTools, block_context: BlockContextMode, block_properties: BlockProperties, @@ -338,7 +338,7 @@ impl BlockContextMode { // This method accepts a custom bootloader code. // It should be used only in tests. pub fn init_vm_inner( - refund_state: MultiVMSubversion, + refund_state: MultiVmSubversion, mut oracle_tools: OracleTools, block_context: BlockContextMode, block_properties: BlockProperties, diff --git a/core/lib/multivm/src/versions/vm_m6/vm.rs b/core/lib/multivm/src/versions/vm_m6/vm.rs index 0443dc8fb55e..2ed2666b2208 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm.rs @@ -14,7 +14,7 @@ use crate::{ }, tracers::old::TracerDispatcher, utils::bytecode, - vm_m6::{storage::Storage, vm_instance::MultiVMSubversion, VmInstance}, + vm_m6::{storage::Storage, vm_instance::MultiVmSubversion, VmInstance}, }; #[derive(Debug)] @@ -28,7 +28,7 @@ impl Vm { batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr, - vm_sub_version: MultiVMSubversion, + vm_sub_version: MultiVmSubversion, ) -> Self { let oracle_tools = crate::vm_m6::OracleTools::new(storage.clone(), H::VmM6Mode::default()); let block_properties = zk_evm_1_3_1::block_properties::BlockProperties { @@ -220,8 +220,8 @@ impl VmFactory for Vm { fn new(batch_env: L1BatchEnv, system_env: SystemEnv, storage: StoragePtr) -> Self { let vm_version: VmVersion = system_env.version.into(); let vm_sub_version = match vm_version { - VmVersion::M6Initial => MultiVMSubversion::V1, - VmVersion::M6BugWithCompressionFixed => MultiVMSubversion::V2, + VmVersion::M6Initial => MultiVmSubversion::V1, + VmVersion::M6BugWithCompressionFixed => MultiVmSubversion::V2, _ => panic!("Unsupported protocol version for vm_m6: {:?}", vm_version), }; Self::new_with_subversion(batch_env, system_env, storage, vm_sub_version) diff --git a/core/lib/multivm/src/versions/vm_m6/vm_instance.rs b/core/lib/multivm/src/versions/vm_m6/vm_instance.rs index d6c418da4c20..29ef17aa4bc7 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm_instance.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm_instance.rs @@ -82,7 +82,7 @@ pub(crate) fn get_vm_hook_params(memory: &SimpleMemory) -> Ve /// /// This enum allows to execute blocks with the same VM but different support for refunds. #[derive(Debug, Copy, Clone)] -pub enum MultiVMSubversion { +pub enum MultiVmSubversion { /// Initial VM M6 version. V1, /// Bug with code compression was fixed. @@ -98,7 +98,7 @@ pub struct VmInstance { pub(crate) bootloader_state: BootloaderState, pub snapshots: Vec, - pub vm_subversion: MultiVMSubversion, + pub vm_subversion: MultiVmSubversion, } /// This structure stores data that accumulates during the VM run. diff --git a/core/lib/multivm/src/versions/vm_m6/vm_with_bootloader.rs b/core/lib/multivm/src/versions/vm_m6/vm_with_bootloader.rs index a47ffb116364..24cddd5eb5ea 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm_with_bootloader.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm_with_bootloader.rs @@ -30,7 +30,7 @@ use crate::{ utils::{ code_page_candidate_from_base, heap_page_from_base, BLOCK_GAS_LIMIT, INITIAL_BASE_PAGE, }, - vm_instance::{MultiVMSubversion, ZkSyncVmState}, + vm_instance::{MultiVmSubversion, ZkSyncVmState}, OracleTools, VmInstance, }, }; @@ -270,7 +270,7 @@ impl Default for TxExecutionMode { } pub fn init_vm( - vm_subversion: MultiVMSubversion, + vm_subversion: MultiVmSubversion, oracle_tools: OracleTools, block_context: BlockContextMode, block_properties: BlockProperties, @@ -289,7 +289,7 @@ pub fn init_vm( } pub fn init_vm_with_gas_limit( - vm_subversion: MultiVMSubversion, + vm_subversion: MultiVmSubversion, oracle_tools: OracleTools, block_context: BlockContextMode, block_properties: BlockProperties, @@ -386,7 +386,7 @@ impl BlockContextMode { // This method accepts a custom bootloader code. // It should be used only in tests. pub fn init_vm_inner( - vm_subversion: MultiVMSubversion, + vm_subversion: MultiVmSubversion, mut oracle_tools: OracleTools, block_context: BlockContextMode, block_properties: BlockProperties, @@ -434,7 +434,7 @@ fn bootloader_initial_memory(block_properties: &BlockContextMode) -> Vec<(usize, } pub fn get_bootloader_memory( - vm_subversion: MultiVMSubversion, + vm_subversion: MultiVmSubversion, txs: Vec, predefined_refunds: Vec, predefined_compressed_bytecodes: Vec>, @@ -442,14 +442,14 @@ pub fn get_bootloader_memory( block_context: BlockContextMode, ) -> Vec<(usize, U256)> { match vm_subversion { - MultiVMSubversion::V1 => get_bootloader_memory_v1( + MultiVmSubversion::V1 => get_bootloader_memory_v1( txs, predefined_refunds, predefined_compressed_bytecodes, execution_mode, block_context, ), - MultiVMSubversion::V2 => get_bootloader_memory_v2( + MultiVmSubversion::V2 => get_bootloader_memory_v2( txs, predefined_refunds, predefined_compressed_bytecodes, @@ -576,14 +576,14 @@ pub fn push_raw_transaction_to_bootloader_memory( explicit_compressed_bytecodes: Option>, ) -> Vec { match vm.vm_subversion { - MultiVMSubversion::V1 => push_raw_transaction_to_bootloader_memory_v1( + MultiVmSubversion::V1 => push_raw_transaction_to_bootloader_memory_v1( vm, tx, execution_mode, predefined_overhead, explicit_compressed_bytecodes, ), - MultiVMSubversion::V2 => push_raw_transaction_to_bootloader_memory_v2( + MultiVmSubversion::V2 => push_raw_transaction_to_bootloader_memory_v2( vm, tx, execution_mode, diff --git a/core/lib/multivm/src/vm_instance.rs b/core/lib/multivm/src/vm_instance.rs index a627e56340d1..9de99a7eb116 100644 --- a/core/lib/multivm/src/vm_instance.rs +++ b/core/lib/multivm/src/vm_instance.rs @@ -14,7 +14,7 @@ use crate::{ VmMemoryMetrics, }, tracers::TracerDispatcher, - vm_fast::FastVMVersion, + vm_fast::FastVmVersion, vm_latest::HistoryEnabled, }; @@ -133,7 +133,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - crate::vm_m5::vm_instance::MultiVMSubversion::V1, + crate::vm_m5::vm_instance::MultiVmSubversion::V1, ); Self::VmM5(vm) } @@ -142,7 +142,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - crate::vm_m5::vm_instance::MultiVMSubversion::V2, + crate::vm_m5::vm_instance::MultiVmSubversion::V2, ); Self::VmM5(vm) } @@ -151,7 +151,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - crate::vm_m6::vm_instance::MultiVMSubversion::V1, + crate::vm_m6::vm_instance::MultiVmSubversion::V1, ); Self::VmM6(vm) } @@ -160,7 +160,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - crate::vm_m6::vm_instance::MultiVMSubversion::V2, + crate::vm_m6::vm_instance::MultiVmSubversion::V2, ); Self::VmM6(vm) } @@ -195,7 +195,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - crate::vm_latest::MultiVMSubversion::SmallBootloaderMemory, + crate::vm_latest::MultiVmSubversion::SmallBootloaderMemory, ); Self::Vm1_5_0(vm) } @@ -204,7 +204,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - crate::vm_latest::MultiVMSubversion::IncreasedBootloaderMemory, + crate::vm_latest::MultiVmSubversion::IncreasedBootloaderMemory, ); Self::Vm1_5_0(vm) } @@ -213,7 +213,7 @@ impl LegacyVmInstance { l1_batch_env, system_env, storage_view, - crate::vm_latest::MultiVMSubversion::Gateway, + crate::vm_latest::MultiVmSubversion::Gateway, ); Self::Vm1_5_0(vm) } @@ -341,5 +341,5 @@ impl FastVmInstance { /// Checks whether the protocol version is supported by the fast VM. pub fn is_supported_by_fast_vm(protocol_version: ProtocolVersionId) -> bool { - FastVMVersion::try_from(VmVersion::from(protocol_version)).is_ok() + FastVmVersion::try_from(VmVersion::from(protocol_version)).is_ok() } diff --git a/core/lib/vm_executor/src/batch/factory.rs b/core/lib/vm_executor/src/batch/factory.rs index de0db5f0bf75..76ef244401bd 100644 --- a/core/lib/vm_executor/src/batch/factory.rs +++ b/core/lib/vm_executor/src/batch/factory.rs @@ -18,7 +18,7 @@ use zksync_multivm::{ tracers::CallTracer, vm_fast, vm_latest::HistoryEnabled, - FastVmInstance, LegacyVmInstance, MultiVMTracer, + FastVmInstance, LegacyVmInstance, MultiVmTracer, }; use zksync_types::{commitment::PubdataParams, vm::FastVmMode, Transaction}; diff --git a/core/lib/vm_executor/src/oneshot/contracts.rs b/core/lib/vm_executor/src/oneshot/contracts.rs index d4e0a94f9178..cacab36cb1c2 100644 --- a/core/lib/vm_executor/src/oneshot/contracts.rs +++ b/core/lib/vm_executor/src/oneshot/contracts.rs @@ -26,7 +26,7 @@ impl ContractsKind for CallOrExecute {} /// Provider of [`BaseSystemContracts`] for oneshot execution. /// -/// The main implementation of this trait is [`MultiVMBaseSystemContracts`], which selects contracts +/// The main implementation of this trait is [`MultiVmBaseSystemContracts`], which selects contracts /// based on [`ProtocolVersionId`]. #[async_trait] pub trait BaseSystemContractsProvider: fmt::Debug + Send + Sync { @@ -46,7 +46,7 @@ pub trait BaseSystemContractsProvider: fmt::Debug + Send + Syn /// System contracts (bootloader and default account abstraction) for all supported VM versions. #[derive(Debug)] -pub struct MultiVMBaseSystemContracts { +pub struct MultiVmBaseSystemContracts { /// Contracts to be used for pre-virtual-blocks protocol versions. pre_virtual_blocks: BaseSystemContracts, /// Contracts to be used for post-virtual-blocks protocol versions. @@ -69,11 +69,11 @@ pub struct MultiVMBaseSystemContracts { vm_protocol_defense: BaseSystemContracts, /// Contracts to be used after the gateway upgrade gateway: BaseSystemContracts, - // We use `fn() -> C` marker so that the `MultiVMBaseSystemContracts` unconditionally implements `Send + Sync`. + // We use `fn() -> C` marker so that the `MultiVmBaseSystemContracts` unconditionally implements `Send + Sync`. _contracts_kind: PhantomData C>, } -impl MultiVMBaseSystemContracts { +impl MultiVmBaseSystemContracts { fn get_by_protocol_version( &self, version: ProtocolVersionId, @@ -120,7 +120,7 @@ impl MultiVMBaseSystemContracts { } } -impl MultiVMBaseSystemContracts { +impl MultiVmBaseSystemContracts { /// Returned system contracts (mainly the bootloader) are tuned to provide accurate execution metrics. pub fn load_estimate_gas_blocking() -> Self { Self { @@ -142,7 +142,7 @@ impl MultiVMBaseSystemContracts { } } -impl MultiVMBaseSystemContracts { +impl MultiVmBaseSystemContracts { /// Returned system contracts (mainly the bootloader) are tuned to provide better UX (e.g. revert messages). pub fn load_eth_call_blocking() -> Self { Self { @@ -165,7 +165,7 @@ impl MultiVMBaseSystemContracts { } #[async_trait] -impl BaseSystemContractsProvider for MultiVMBaseSystemContracts { +impl BaseSystemContractsProvider for MultiVmBaseSystemContracts { async fn base_system_contracts( &self, block_info: &ResolvedBlockInfo, diff --git a/core/lib/vm_executor/src/oneshot/mod.rs b/core/lib/vm_executor/src/oneshot/mod.rs index e95164c0fc87..0dfdb67bff52 100644 --- a/core/lib/vm_executor/src/oneshot/mod.rs +++ b/core/lib/vm_executor/src/oneshot/mod.rs @@ -29,7 +29,7 @@ use zksync_multivm::{ utils::adjust_pubdata_price_for_tx, vm_latest::{HistoryDisabled, HistoryEnabled}, zk_evm_latest::ethereum_types::U256, - FastVmInstance, HistoryMode, LegacyVmInstance, MultiVMTracer, + FastVmInstance, HistoryMode, LegacyVmInstance, MultiVmTracer, }; use zksync_types::{ block::pack_block_info, @@ -46,7 +46,7 @@ pub use self::{ block::{BlockInfo, ResolvedBlockInfo}, contracts::{ BaseSystemContractsProvider, CallOrExecute, ContractsKind, EstimateGas, - MultiVMBaseSystemContracts, + MultiVmBaseSystemContracts, }, env::OneshotEnvParameters, mock::MockOneshotExecutor, diff --git a/core/node/api_server/src/tx_sender/mod.rs b/core/node/api_server/src/tx_sender/mod.rs index 180b53492839..91fb84ab8f17 100644 --- a/core/node/api_server/src/tx_sender/mod.rs +++ b/core/node/api_server/src/tx_sender/mod.rs @@ -33,7 +33,7 @@ use zksync_types::{ MAX_NEW_FACTORY_DEPS, U256, }; use zksync_vm_executor::oneshot::{ - CallOrExecute, EstimateGas, MultiVMBaseSystemContracts, OneshotEnvParameters, + CallOrExecute, EstimateGas, MultiVmBaseSystemContracts, OneshotEnvParameters, }; pub(super) use self::{gas_estimation::BinarySearchKind, result::SubmitTxError}; @@ -109,11 +109,11 @@ impl SandboxExecutorOptions { validation_computational_gas_limit: u32, ) -> anyhow::Result { let estimate_gas_contracts = - tokio::task::spawn_blocking(MultiVMBaseSystemContracts::load_estimate_gas_blocking) + tokio::task::spawn_blocking(MultiVmBaseSystemContracts::load_estimate_gas_blocking) .await .context("failed loading base contracts for gas estimation")?; let call_contracts = - tokio::task::spawn_blocking(MultiVMBaseSystemContracts::load_eth_call_blocking) + tokio::task::spawn_blocking(MultiVmBaseSystemContracts::load_eth_call_blocking) .await .context("failed loading base contracts for calls / tx execution")?; diff --git a/core/node/consensus/src/vm.rs b/core/node/consensus/src/vm.rs index cbd4918dcee1..81d26ebc3758 100644 --- a/core/node/consensus/src/vm.rs +++ b/core/node/consensus/src/vm.rs @@ -8,7 +8,7 @@ use zksync_state::PostgresStorage; use zksync_system_constants::DEFAULT_L2_TX_GAS_PER_PUBDATA_BYTE; use zksync_types::{ethabi, fee::Fee, l2::L2Tx, AccountTreeId, L2ChainId, Nonce, U256}; use zksync_vm_executor::oneshot::{ - CallOrExecute, MainOneshotExecutor, MultiVMBaseSystemContracts, OneshotEnvParameters, + CallOrExecute, MainOneshotExecutor, MultiVmBaseSystemContracts, OneshotEnvParameters, }; use zksync_vm_interface::{ executor::OneshotExecutor, storage::StorageWithOverrides, ExecutionResult, @@ -29,7 +29,7 @@ impl VM { /// Constructs a new `VM` instance. pub async fn new(pool: ConnectionPool) -> Self { let base_system_contracts = - scope::wait_blocking(MultiVMBaseSystemContracts::load_eth_call_blocking).await; + scope::wait_blocking(MultiVmBaseSystemContracts::load_eth_call_blocking).await; Self { pool, // L2 chain ID and fee account don't seem to matter for calls, hence the use of default values. diff --git a/core/node/genesis/src/utils.rs b/core/node/genesis/src/utils.rs index d89d7475e84b..d8076229fa54 100644 --- a/core/node/genesis/src/utils.rs +++ b/core/node/genesis/src/utils.rs @@ -5,7 +5,7 @@ use zksync_contracts::BaseSystemContracts; use zksync_dal::{Connection, Core, CoreDal}; use zksync_multivm::{ circuit_sequencer_api_latest::sort_storage_access::sort_storage_access_queries, - zk_evm_latest::aux_structures::{LogQuery as MultiVmLogQuery, Timestamp as MultiVMTimestamp}, + zk_evm_latest::aux_structures::{LogQuery as MultiVmLogQuery, Timestamp as MultiVmTimestamp}, }; use zksync_system_constants::{DEFAULT_ERA_CHAIN_ID, ETHEREUM_ADDRESS}; use zksync_types::{ @@ -84,7 +84,7 @@ pub(super) fn get_deduped_log_queries(storage_logs: &[StorageLog]) -> Vec Date: Tue, 12 Nov 2024 13:41:17 +0200 Subject: [PATCH 3/3] remove clone --- core/lib/multivm/src/versions/vm_fast/vm.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index 4f9aa03873fb..a91f0831ebbf 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -367,8 +367,7 @@ impl Vm { self.write_to_bootloader_heap(memory_to_apply); // Save the pubdata for the future initial bootloader memory building - self.bootloader_state - .set_pubdata_input(pubdata_input.clone()); + self.bootloader_state.set_pubdata_input(pubdata_input); } Hook::PaymasterValidationEntered | Hook::ValidationStepEnded => { /* unused */ }