Skip to content

Commit

Permalink
disable vm for trace_call
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci committed Mar 28, 2024
1 parent 8ef1b3a commit 901b0a8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions modules/evm/src/runner/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub enum Event<'a> {
}

pub struct Tracer {
vm: bool,
events: Vec<CallTrace>,
stack: Vec<CallTrace>,
steps: Vec<Step>,
Expand All @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -542,7 +547,6 @@ impl Stringify for ExitError {
ExitError::PCUnderflow => "PCUnderflow",
ExitError::CreateEmpty => "CreateEmpty",
ExitError::Other(msg) => msg,
ExitError::MaxNonce => "MaxNonce",
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/evm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3030,7 +3030,7 @@ fn tracer_works() {

let alice_account_id = <Runtime as Config>::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()),
Expand Down
4 changes: 2 additions & 2 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,7 @@ sp_api::impl_runtime_apis! {
storage_limit: u32,
access_list: Option<Vec<AccessListItem>>,
) -> Result<Vec<module_evm::runner::tracing::CallTrace>, 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() {
<Runtime as module_evm::Config>::Runner::rpc_create(
Expand Down Expand Up @@ -2228,7 +2228,7 @@ sp_api::impl_runtime_apis! {
) -> Result<module_evm::runner::tracing::VMTrace, sp_runtime::DispatchError> {
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() {
<Runtime as module_evm::Config>::Runner::rpc_create(
Expand Down
4 changes: 2 additions & 2 deletions runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,7 @@ impl_runtime_apis! {
storage_limit: u32,
access_list: Option<Vec<AccessListItem>>,
) -> Result<Vec<module_evm::runner::tracing::CallTrace>, 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() {
<Runtime as module_evm::Config>::Runner::rpc_create(
Expand Down Expand Up @@ -2242,7 +2242,7 @@ impl_runtime_apis! {
) -> Result<module_evm::runner::tracing::VMTrace, sp_runtime::DispatchError> {
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() {
<Runtime as module_evm::Config>::Runner::rpc_create(
Expand Down
4 changes: 2 additions & 2 deletions runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,7 @@ impl_runtime_apis! {
storage_limit: u32,
access_list: Option<Vec<AccessListItem>>,
) -> Result<Vec<module_evm::runner::tracing::CallTrace>, 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() {
<Runtime as module_evm::Config>::Runner::rpc_create(
Expand Down Expand Up @@ -2435,7 +2435,7 @@ impl_runtime_apis! {
) -> Result<module_evm::runner::tracing::VMTrace, sp_runtime::DispatchError> {
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() {
<Runtime as module_evm::Config>::Runner::rpc_create(
Expand Down

0 comments on commit 901b0a8

Please sign in to comment.