From 077c0c689317fa33c9bf3623942b565e8471f418 Mon Sep 17 00:00:00 2001 From: perekopskiy <53865202+perekopskiy@users.noreply.github.com> Date: Fri, 12 Jan 2024 12:01:27 +0200 Subject: [PATCH] fix(vm): `inspect_transaction_with_bytecode_compression` for old VMs (#862) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Fixes `inspect_transaction_with_bytecode_compression` for vm_1_3_2 and vm_m6 to work correctly with all tx execution modes ## Why ❔ Fix bug ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. - [x] Spellcheck has been run via `zk spellcheck`. --- core/lib/multivm/src/versions/vm_1_3_2/vm.rs | 23 +++++++++++++++----- core/lib/multivm/src/versions/vm_m6/vm.rs | 23 +++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs index 50fa44380f58..be99537187b5 100644 --- a/core/lib/multivm/src/versions/vm_1_3_2/vm.rs +++ b/core/lib/multivm/src/versions/vm_1_3_2/vm.rs @@ -204,20 +204,31 @@ impl VmInterface for Vm { }; // Even that call tracer is supported here, we don't use it. - let result = self.vm.execute_next_tx( - self.system_env.default_validation_computational_gas_limit, - false, - ); + let result = match self.system_env.execution_mode { + TxExecutionMode::VerifyExecute => self + .vm + .execute_next_tx( + self.system_env.default_validation_computational_gas_limit, + false, + ) + .glue_into(), + TxExecutionMode::EstimateFee | TxExecutionMode::EthCall => self + .vm + .execute_till_block_end( + crate::vm_1_3_2::vm_with_bootloader::BootloaderJobType::TransactionExecution, + ) + .glue_into(), + }; if bytecodes .iter() .any(|info| !self.vm.is_bytecode_known(info)) { ( Err(BytecodeCompressionError::BytecodeCompressionFailed), - result.glue_into(), + result, ) } else { - (Ok(()), result.glue_into()) + (Ok(()), result) } } diff --git a/core/lib/multivm/src/versions/vm_m6/vm.rs b/core/lib/multivm/src/versions/vm_m6/vm.rs index 420b5c8f9bf7..25a922ee510d 100644 --- a/core/lib/multivm/src/versions/vm_m6/vm.rs +++ b/core/lib/multivm/src/versions/vm_m6/vm.rs @@ -221,20 +221,31 @@ impl VmInterface for Vm { }; // Even that call tracer is supported here, we don't use it. - let result = self.vm.execute_next_tx( - self.system_env.default_validation_computational_gas_limit, - false, - ); + let result = match self.system_env.execution_mode { + TxExecutionMode::VerifyExecute => self + .vm + .execute_next_tx( + self.system_env.default_validation_computational_gas_limit, + false, + ) + .glue_into(), + TxExecutionMode::EstimateFee | TxExecutionMode::EthCall => self + .vm + .execute_till_block_end( + crate::vm_m6::vm_with_bootloader::BootloaderJobType::TransactionExecution, + ) + .glue_into(), + }; if bytecodes .iter() .any(|info| !self.vm.is_bytecode_exists(info)) { ( Err(BytecodeCompressionError::BytecodeCompressionFailed), - result.glue_into(), + result, ) } else { - (Ok(()), result.glue_into()) + (Ok(()), result) } }