From 600825a975b32b93914debbf3ff9b074ade57d93 Mon Sep 17 00:00:00 2001 From: clostao <49268919+clostao@users.noreply.github.com> Date: Thu, 16 Nov 2023 12:00:11 +0100 Subject: [PATCH] Evm tracing for eth extrinsic wrapper (#150) --- runtime/src/lib.rs | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index d264567..59d7346 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -12,7 +12,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use account::AccountId20; use account::EthereumSigner; -use parity_scale_codec::{Decode, Encode}; use core::str::FromStr; use frame_support::pallet_prelude::EnsureOrigin; use frame_support::pallet_prelude::InvalidTransaction; @@ -26,6 +25,7 @@ use pallet_supported_tokens_manager::SupportedTokensManager as OtherSupportedTok use pallet_transaction_payment::OnChargeTransaction; use pallet_user_fee_selector::UserFeeTokenController; use pallet_validator_fee_selector::ValidatorFeeTokenController; +use parity_scale_codec::{Decode, Encode}; use runner::OnChargeDecentralizedNativeTokenFee; use sp_api::impl_runtime_apis; use sp_core::{ @@ -1298,7 +1298,23 @@ impl_runtime_apis! { } else { Executive::apply_extrinsic(ext) } - } + }, + RuntimeCall::MetaTransactions(pallet_sponsored_transactions::Call::send_sponsored_transaction { transaction, .. }) => { + if transaction == traced_transaction { + EvmTracer::new().trace(|| Executive::apply_extrinsic(ext)); + return Ok(()); + } else { + Executive::apply_extrinsic(ext) + } + }, + RuntimeCall::ZeroGasTransactions(pallet_zero_gas_transactions::Call::send_zero_gas_transaction { transaction, .. }) => { + if transaction == traced_transaction { + EvmTracer::new().trace(|| Executive::apply_extrinsic(ext)); + return Ok(()); + } else { + Executive::apply_extrinsic(ext) + } + }, _ => Executive::apply_extrinsic(ext), }; } @@ -1331,6 +1347,24 @@ impl_runtime_apis! { let _ = Executive::apply_extrinsic(ext); } } + RuntimeCall::MetaTransactions(pallet_sponsored_transactions::Call::send_sponsored_transaction { transaction, .. }) => { + if known_transactions.contains(&transaction.hash()) { + // Each known extrinsic is a new call stack. + EvmTracer::emit_new(); + EvmTracer::new().trace(|| Executive::apply_extrinsic(ext)); + } else { + let _ = Executive::apply_extrinsic(ext); + } + }, + RuntimeCall::ZeroGasTransactions(pallet_zero_gas_transactions::Call::send_zero_gas_transaction { transaction, .. }) => { + if known_transactions.contains(&transaction.hash()) { + // Each known extrinsic is a new call stack. + EvmTracer::emit_new(); + EvmTracer::new().trace(|| Executive::apply_extrinsic(ext)); + } else { + let _ = Executive::apply_extrinsic(ext); + } + }, _ => { let _ = Executive::apply_extrinsic(ext); }