From 901b0a8e99a71ace384484a30728efd47234c381 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Thu, 28 Mar 2024 17:33:36 +0100 Subject: [PATCH] disable vm for trace_call --- modules/evm/src/runner/tracing.rs | 8 ++++++-- modules/evm/src/tests.rs | 2 +- runtime/acala/src/lib.rs | 4 ++-- runtime/karura/src/lib.rs | 4 ++-- runtime/mandala/src/lib.rs | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/evm/src/runner/tracing.rs b/modules/evm/src/runner/tracing.rs index 08f134a483..ad23eb8d3e 100644 --- a/modules/evm/src/runner/tracing.rs +++ b/modules/evm/src/runner/tracing.rs @@ -88,6 +88,7 @@ pub enum Event<'a> { } pub struct Tracer { + vm: bool, events: Vec, stack: Vec, steps: Vec, @@ -96,8 +97,9 @@ pub struct Tracer { } impl Tracer { - pub fn new() -> Self { + pub fn new(vm: bool) -> Self { Self { + vm, events: Vec::new(), stack: Vec::new(), steps: Vec::new(), @@ -135,6 +137,9 @@ impl Tracer { memory, } => { self.opcode = Some(opcode); + if !self.vm { + return; + } self.steps.push(Step { op: opcode.stringify().as_bytes().to_vec(), pc: position.clone().unwrap_or_default() as u64, @@ -542,7 +547,6 @@ impl Stringify for ExitError { ExitError::PCUnderflow => "PCUnderflow", ExitError::CreateEmpty => "CreateEmpty", ExitError::Other(msg) => msg, - ExitError::MaxNonce => "MaxNonce", } } } diff --git a/modules/evm/src/tests.rs b/modules/evm/src/tests.rs index d89252bd49..36ff6728a0 100644 --- a/modules/evm/src/tests.rs +++ b/modules/evm/src/tests.rs @@ -3030,7 +3030,7 @@ fn tracer_works() { let alice_account_id = ::AddressMapping::get_account_id(&alice()); - let mut tracer = crate::runner::tracing::Tracer::new(); + let mut tracer = crate::runner::tracing::Tracer::new(true); crate::runner::tracing::using(&mut tracer, || { assert_ok!(EVM::call( RuntimeOrigin::signed(alice_account_id.clone()), diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index ca356b0dcb..5b5e41e5b1 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -2189,7 +2189,7 @@ sp_api::impl_runtime_apis! { storage_limit: u32, access_list: Option>, ) -> Result, sp_runtime::DispatchError> { - let mut tracer = module_evm::runner::tracing::Tracer::new(); + let mut tracer = module_evm::runner::tracing::Tracer::new(false); module_evm::runner::tracing::using(&mut tracer, || { if to == H160::zero() { ::Runner::rpc_create( @@ -2228,7 +2228,7 @@ sp_api::impl_runtime_apis! { ) -> Result { use sp_core::H256; use sp_runtime::traits::UniqueSaturatedInto; - let mut tracer = module_evm::runner::tracing::Tracer::new(); + let mut tracer = module_evm::runner::tracing::Tracer::new(true); module_evm::runner::tracing::using(&mut tracer, || { if to == H160::zero() { ::Runner::rpc_create( diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index f205d894f1..eb23a7c125 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -2203,7 +2203,7 @@ impl_runtime_apis! { storage_limit: u32, access_list: Option>, ) -> Result, sp_runtime::DispatchError> { - let mut tracer = module_evm::runner::tracing::Tracer::new(); + let mut tracer = module_evm::runner::tracing::Tracer::new(false); module_evm::runner::tracing::using(&mut tracer, || { if to == H160::zero() { ::Runner::rpc_create( @@ -2242,7 +2242,7 @@ impl_runtime_apis! { ) -> Result { use sp_core::H256; use sp_runtime::traits::UniqueSaturatedInto; - let mut tracer = module_evm::runner::tracing::Tracer::new(); + let mut tracer = module_evm::runner::tracing::Tracer::new(true); module_evm::runner::tracing::using(&mut tracer, || { if to == H160::zero() { ::Runner::rpc_create( diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index 2eeaa13dbc..fe543c8fd6 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -2396,7 +2396,7 @@ impl_runtime_apis! { storage_limit: u32, access_list: Option>, ) -> Result, sp_runtime::DispatchError> { - let mut tracer = module_evm::runner::tracing::Tracer::new(); + let mut tracer = module_evm::runner::tracing::Tracer::new(false); module_evm::runner::tracing::using(&mut tracer, || { if to == H160::zero() { ::Runner::rpc_create( @@ -2435,7 +2435,7 @@ impl_runtime_apis! { ) -> Result { use sp_core::H256; use sp_runtime::traits::UniqueSaturatedInto; - let mut tracer = module_evm::runner::tracing::Tracer::new(); + let mut tracer = module_evm::runner::tracing::Tracer::new(true); module_evm::runner::tracing::using(&mut tracer, || { if to == H160::zero() { ::Runner::rpc_create(