From a7df979a2330b923a523310b9a7668b9d2928f16 Mon Sep 17 00:00:00 2001 From: Joonatan Saarhelo Date: Wed, 24 Jul 2024 17:49:47 +0200 Subject: [PATCH] compatibility with optimize external snapshots --- core/lib/multivm/src/versions/vm_fast/vm.rs | 13 +++++++------ core/tests/vm-benchmark/benches/fill_bootloader.rs | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/lib/multivm/src/versions/vm_fast/vm.rs b/core/lib/multivm/src/versions/vm_fast/vm.rs index dd599d471b3b..a745e3f75d67 100644 --- a/core/lib/multivm/src/versions/vm_fast/vm.rs +++ b/core/lib/multivm/src/versions/vm_fast/vm.rs @@ -46,9 +46,8 @@ use crate::{ }, vm_latest::{ constants::{ - get_used_bootloader_memory_bytes, get_vm_hook_params_start_position, - get_vm_hook_position, OPERATOR_REFUNDS_OFFSET, TX_GAS_LIMIT_OFFSET, - VM_HOOK_PARAMS_COUNT, + get_vm_hook_params_start_position, get_vm_hook_position, OPERATOR_REFUNDS_OFFSET, + TX_GAS_LIMIT_OFFSET, VM_HOOK_PARAMS_COUNT, }, BootloaderMemory, CurrentExecutionState, ExecutionResult, FinishedL1Batch, L1BatchEnv, L2BlockEnv, MultiVMSubversion, Refunds, SystemEnv, VmExecutionLogs, VmExecutionMode, @@ -326,9 +325,12 @@ impl Vm { ) { assert!(self.inner.state.previous_frames.is_empty()); // TODO: this should probably address `vm2::FIRST_HEAP` instead. - let heap = &mut self.inner.state.heaps[self.inner.state.current_frame.heap]; for (slot, value) in memory { - heap.write_u256(slot as u32 * 32, value); + self.inner.state.heaps.write_u256( + self.inner.state.current_frame.heap, + slot as u32 * 32, + value, + ); } } @@ -460,7 +462,6 @@ impl Vm { inner.state.current_frame.sp = 0; // The bootloader writes results to high addresses in its heap, so it makes sense to preallocate it. - inner.state.heaps[vm2::FIRST_HEAP].reserve(get_used_bootloader_memory_bytes(VM_VERSION)); inner.state.current_frame.heap_size = u32::MAX; inner.state.current_frame.aux_heap_size = u32::MAX; inner.state.current_frame.exception_handler = INITIAL_FRAME_FORMAL_EH_LOCATION; diff --git a/core/tests/vm-benchmark/benches/fill_bootloader.rs b/core/tests/vm-benchmark/benches/fill_bootloader.rs index 40e6727cb4ba..fc51a2348c6e 100644 --- a/core/tests/vm-benchmark/benches/fill_bootloader.rs +++ b/core/tests/vm-benchmark/benches/fill_bootloader.rs @@ -17,7 +17,6 @@ fn main() { let mut vm = BenchmarkingVm::new(); for _ in 0..1000 { vm.run_transaction(black_box(&tx)); - dbg!("tx"); } println!("{:?}", start.elapsed());