From 5fb946610e7ed5f0e1c4005b5ab91e8f3a2b3930 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Fri, 30 Aug 2024 17:49:29 -0300 Subject: [PATCH 1/2] Fix blob_tracer return when running program --- core/lib/multivm/src/versions/era_vm/vm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/multivm/src/versions/era_vm/vm.rs b/core/lib/multivm/src/versions/era_vm/vm.rs index 1ebd1a2e0baf..97f6ec0f7da7 100644 --- a/core/lib/multivm/src/versions/era_vm/vm.rs +++ b/core/lib/multivm/src/versions/era_vm/vm.rs @@ -167,7 +167,7 @@ impl Vm { let mut last_tx_result = None; loop { - let (result, _blob_tracer) = self.inner.run_program_with_custom_bytecode(); + let result = self.inner.run_program_with_custom_bytecode(); let result = match result { ExecutionOutput::Ok(output) => { From 87dd05ca77fca5b343c5935b5b033816d9674b4a Mon Sep 17 00:00:00 2001 From: Gianbelinche <39842759+gianbelinche@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:07:06 -0300 Subject: [PATCH 2/2] Adress PR comments --- core/lib/multivm/src/glue/tracers/mod.rs | 4 +-- .../src/tracers/call_tracer/era_vm/mod.rs | 28 ++++++++----------- .../multivm/src/tracers/multivm_dispatcher.rs | 2 +- .../versions/era_vm/tracers/pubdata_tracer.rs | 1 - 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/core/lib/multivm/src/glue/tracers/mod.rs b/core/lib/multivm/src/glue/tracers/mod.rs index 6bae150dec58..432d569979b8 100644 --- a/core/lib/multivm/src/glue/tracers/mod.rs +++ b/core/lib/multivm/src/glue/tracers/mod.rs @@ -59,7 +59,7 @@ pub trait IntoLatestTracer { } pub trait IntoEraVmTracer { - fn era_vm(&self) -> Box>; + fn into_era_vm(&self) -> Box>; } pub trait IntoVmVirtualBlocksTracer { @@ -117,7 +117,7 @@ where H: HistoryMode, T: crate::era_vm::tracers::traits::VmTracer + Clone + 'static, { - fn era_vm(&self) -> Box> { + fn into_era_vm(&self) -> Box> { Box::new(self.clone()) } } diff --git a/core/lib/multivm/src/tracers/call_tracer/era_vm/mod.rs b/core/lib/multivm/src/tracers/call_tracer/era_vm/mod.rs index cfb07b63f53a..31d06610a4ec 100644 --- a/core/lib/multivm/src/tracers/call_tracer/era_vm/mod.rs +++ b/core/lib/multivm/src/tracers/call_tracer/era_vm/mod.rs @@ -36,12 +36,12 @@ impl Tracer for CallTracer { .map(|call| call.frame.gas_left.0.saturating_add(current_ergs)) .unwrap_or(current_ergs) as u64; - // we need to to this cast because `Call` uses another library + // we need to do this cast because `Call` uses another library let far_call_variant = match far_call as u8 { 0 => FarCallOpcode::Normal, 1 => FarCallOpcode::Delegate, 2 => FarCallOpcode::Mimic, - _ => unreachable!(), + _ => FarCallOpcode::Normal, // Should never happen }; let mut current_call = Call { @@ -94,7 +94,7 @@ impl CallTracer { CallType::Call(far_call) } } else { - unreachable!() + return; }; let calldata = if current.heap_id == 0 || current.frame.gas_left.0 == 0 { vec![] @@ -127,22 +127,18 @@ impl CallTracer { let fat_data_pointer = execution.get_register(1); // if `fat_data_pointer` is not a pointer then there is no output - let output = if fat_data_pointer.is_pointer { - let fat_data_pointer = FatPointer::decode(fat_data_pointer.value); - if fat_data_pointer.len == 0 && fat_data_pointer.offset == 0 { - Some( - execution + let output = match fat_data_pointer.is_pointer { + true => { + let fat_data_pointer = FatPointer::decode(fat_data_pointer.value); + match (fat_data_pointer.len, fat_data_pointer.offset) { + (0, 0) => execution .heaps .get(fat_data_pointer.page) - .unwrap() - .read_unaligned_from_pointer(&fat_data_pointer) - .unwrap(), - ) - } else { - None + .and_then(|ptr| ptr.read_unaligned_from_pointer(&fat_data_pointer).ok()), + _ => None, + } } - } else { - None + _ => None, }; match ret_opcode { diff --git a/core/lib/multivm/src/tracers/multivm_dispatcher.rs b/core/lib/multivm/src/tracers/multivm_dispatcher.rs index 53cdab4d4737..e0126f18ed8c 100644 --- a/core/lib/multivm/src/tracers/multivm_dispatcher.rs +++ b/core/lib/multivm/src/tracers/multivm_dispatcher.rs @@ -41,7 +41,7 @@ impl From> for crate::era_vm::tracers::dispatcher::TracerDispatcher { fn from(value: TracerDispatcher) -> Self { - Self::new(value.tracers.into_iter().map(|x| x.era_vm()).collect()) + Self::new(value.tracers.into_iter().map(|x| x.into_era_vm()).collect()) } } diff --git a/core/lib/multivm/src/versions/era_vm/tracers/pubdata_tracer.rs b/core/lib/multivm/src/versions/era_vm/tracers/pubdata_tracer.rs index f907dcfb16db..0041a10da526 100644 --- a/core/lib/multivm/src/versions/era_vm/tracers/pubdata_tracer.rs +++ b/core/lib/multivm/src/versions/era_vm/tracers/pubdata_tracer.rs @@ -75,7 +75,6 @@ impl PubdataTracer { ), enumeration_index: vm .storage - .borrow_mut() .get_enumeration_index(&StorageKey::new( AccountTreeId::new(address), u256_to_h256(key),