diff --git a/core/lib/multivm/src/versions/vm_fast/bootloader_state/l2_block.rs b/core/lib/multivm/src/versions/vm_fast/bootloader_state/l2_block.rs index 009f2040d20b..adb406eec789 100644 --- a/core/lib/multivm/src/versions/vm_fast/bootloader_state/l2_block.rs +++ b/core/lib/multivm/src/versions/vm_fast/bootloader_state/l2_block.rs @@ -11,7 +11,7 @@ use crate::{ const EMPTY_TXS_ROLLING_HASH: H256 = H256::zero(); -#[derive(Debug, Clone)] +#[derive(Debug)] pub(crate) struct BootloaderL2Block { pub(crate) number: u32, pub(crate) timestamp: u64, @@ -54,12 +54,6 @@ impl BootloaderL2Block { self.txs_rolling_hash = concat_and_hash(self.txs_rolling_hash, tx_hash) } - pub(crate) fn interim_version(&self) -> BootloaderL2Block { - let mut interim = self.clone(); - interim.max_virtual_blocks_to_create = 0; - interim - } - pub(crate) fn make_snapshot(&self) -> L2BlockSnapshot { L2BlockSnapshot { txs_rolling_hash: self.txs_rolling_hash, 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 c915c5aa7838..ae1c70db5862 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 @@ -26,7 +26,7 @@ use crate::{ /// Serves two purposes: /// - Tracks where next tx should be pushed to in the bootloader memory. /// - Tracks which transaction should be executed next. -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct BootloaderState { /// ID of the next transaction to be executed. /// See the structure doc-comment for a better explanation of purpose. 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 c188388c5a2f..21259e366d1b 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 @@ -63,13 +63,7 @@ pub(super) fn apply_tx_to_memory( (tx_description_offset..tx_description_offset + bootloader_tx.encoded_len()) .zip(bootloader_tx.encoded.clone()), ); - - let bootloader_l2_block = if start_new_l2_block { - bootloader_l2_block.clone() - } else { - bootloader_l2_block.interim_version() - }; - apply_l2_block(memory, &bootloader_l2_block, tx_index); + apply_l2_block_inner(memory, bootloader_l2_block, tx_index, start_new_l2_block); // Note, +1 is moving for pointer let compressed_bytecodes_offset = COMPRESSED_BYTECODES_OFFSET + 1 + compressed_bytecodes_size; @@ -90,6 +84,15 @@ pub(crate) fn apply_l2_block( memory: &mut BootloaderMemory, bootloader_l2_block: &BootloaderL2Block, txs_index: usize, +) { + apply_l2_block_inner(memory, bootloader_l2_block, txs_index, true) +} + +fn apply_l2_block_inner( + memory: &mut BootloaderMemory, + bootloader_l2_block: &BootloaderL2Block, + txs_index: usize, + start_new_l2_block: bool, ) { // Since L2 block information start from the `TX_OPERATOR_L2_BLOCK_INFO_OFFSET` and each // L2 block info takes `TX_OPERATOR_SLOTS_PER_L2_BLOCK_INFO` slots, the position where the L2 block info @@ -107,7 +110,11 @@ pub(crate) fn apply_l2_block( ), ( block_position + 3, - bootloader_l2_block.max_virtual_blocks_to_create.into(), + if start_new_l2_block { + bootloader_l2_block.max_virtual_blocks_to_create.into() + } else { + U256::zero() + }, ), ]) } diff --git a/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs b/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs index 6976febabce6..dc6326dd6352 100644 --- a/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs +++ b/core/lib/multivm/src/versions/vm_fast/tests/get_used_contracts.rs @@ -43,10 +43,7 @@ fn test_get_used_contracts() { // Note: `Default_AA` will be in the list of used contracts if L2 tx is used assert_eq!( - vm.vm - .get_decommitted_hashes() - .cloned() - .collect::>(), + vm.vm.get_decommitted_hashes().collect::>(), known_bytecodes_without_aa_code(&vm.vm) );