From 8f41b8c1a632abdf6ccc4eb1afc704747c0ee836 Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:05:32 +0200 Subject: [PATCH 1/3] chore: sdk-7163 --- runtime/mainnet/src/apis.rs | 14 +++++--------- runtime/mainnet/src/lib.rs | 6 ------ runtime/testnet/src/lib.rs | 10 +++------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/runtime/mainnet/src/apis.rs b/runtime/mainnet/src/apis.rs index 7414e9a9a..d28f3c5ad 100644 --- a/runtime/mainnet/src/apis.rs +++ b/runtime/mainnet/src/apis.rs @@ -33,8 +33,8 @@ use xcm_runtime_apis::{ // Local module imports use super::{ config::{monetary::fee::WeightToFee, system::RuntimeBlockWeights, xcm as xcm_config}, - AccountId, Balance, Balances, Block, BlockNumber, BlockWeights, EthExtraImpl, EventRecord, - Executive, ExtrinsicInclusionMode, InherentDataExt, Nfts, Nonce, OriginCaller, ParachainSystem, + AccountId, Balance, Balances, Block, BlockNumber, BlockWeights, Executive, + ExtrinsicInclusionMode, InherentDataExt, Nfts, Nonce, OriginCaller, ParachainSystem, PolkadotXcm, Revive, Runtime, RuntimeCall, RuntimeEvent, RuntimeGenesisConfig, RuntimeOrigin, SessionKeys, System, TransactionPayment, UncheckedExtrinsic, VERSION, }; @@ -395,7 +395,7 @@ impl_runtime_apis! { } } - impl pallet_revive::ReviveApi for Runtime + impl pallet_revive::ReviveApi for Runtime { fn balance(address: H160) -> Balance { use frame_support::traits::fungible::Inspect; @@ -438,7 +438,7 @@ impl_runtime_apis! { gas_limit: Option, storage_deposit_limit: Option, input_data: Vec, - ) -> pallet_revive::ContractResult { + ) -> pallet_revive::ContractResult { Revive::bare_call( RuntimeOrigin::signed(origin), dest, @@ -446,8 +446,6 @@ impl_runtime_apis! { gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block), pallet_revive::DepositLimit::Balance(storage_deposit_limit.unwrap_or(u128::MAX)), input_data, - pallet_revive::DebugInfo::UnsafeDebug, - pallet_revive::CollectEvents::UnsafeCollect, ) } @@ -459,7 +457,7 @@ impl_runtime_apis! { code: pallet_revive::Code, data: Vec, salt: Option<[u8; 32]>, - ) -> pallet_revive::ContractResult + ) -> pallet_revive::ContractResult { Revive::bare_instantiate( RuntimeOrigin::signed(origin), @@ -469,8 +467,6 @@ impl_runtime_apis! { code, data, salt, - pallet_revive::DebugInfo::UnsafeDebug, - pallet_revive::CollectEvents::UnsafeCollect, ) } diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index 778ea179b..094b535f3 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -71,12 +71,6 @@ pub type AccountId = <::Signer as IdentifyAccount>::Account /// The address format for describing accounts. pub type Address = MultiAddress; -/// Record of an event happening. -pub type EventRecord = frame_system::EventRecord< - ::RuntimeEvent, - ::Hash, ->; - /// Block header type as expected by this runtime. pub type Header = generic::Header; diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index 3a3a51823..5d68f2957 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -683,7 +683,7 @@ impl_runtime_apis! { } } - impl pallet_revive::ReviveApi for Runtime + impl pallet_revive::ReviveApi for Runtime { fn balance(address: H160) -> Balance { use frame_support::traits::fungible::Inspect; @@ -726,7 +726,7 @@ impl_runtime_apis! { gas_limit: Option, storage_deposit_limit: Option, input_data: Vec, - ) -> pallet_revive::ContractResult { + ) -> pallet_revive::ContractResult { Revive::bare_call( RuntimeOrigin::signed(origin), dest, @@ -734,8 +734,6 @@ impl_runtime_apis! { gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block), pallet_revive::DepositLimit::Balance(storage_deposit_limit.unwrap_or(u128::MAX)), input_data, - pallet_revive::DebugInfo::UnsafeDebug, - pallet_revive::CollectEvents::UnsafeCollect, ) } @@ -747,7 +745,7 @@ impl_runtime_apis! { code: pallet_revive::Code, data: Vec, salt: Option<[u8; 32]>, - ) -> pallet_revive::ContractResult + ) -> pallet_revive::ContractResult { Revive::bare_instantiate( RuntimeOrigin::signed(origin), @@ -757,8 +755,6 @@ impl_runtime_apis! { code, data, salt, - pallet_revive::DebugInfo::UnsafeDebug, - pallet_revive::CollectEvents::UnsafeCollect, ) } From 44d81544ae9ad379d52168c441e83a7d4467748a Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:07:01 +0200 Subject: [PATCH 2/3] chore: sdk-7166 --- runtime/mainnet/src/config/revive.rs | 6 ------ runtime/testnet/src/config/contracts.rs | 1 - 2 files changed, 7 deletions(-) diff --git a/runtime/mainnet/src/config/revive.rs b/runtime/mainnet/src/config/revive.rs index 42f16f18f..6062fbbed 100644 --- a/runtime/mainnet/src/config/revive.rs +++ b/runtime/mainnet/src/config/revive.rs @@ -29,7 +29,6 @@ impl pallet_revive::Config for Runtime { // 30 percent of storage deposit held for using a code hash. type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent; type Currency = Balances; - type Debug = (); type DepositPerByte = DepositPerByte; type DepositPerItem = DepositPerItem; type EthGasEncoder = (); @@ -115,11 +114,6 @@ mod tests { assert_eq!(TypeId::of::<::Currency>(), TypeId::of::(),); } - #[test] - fn debug_is_unset() { - assert_eq!(TypeId::of::<::Debug>(), TypeId::of::<()>(),); - } - #[test] fn deposit_per_byte_is_correct() { assert_eq!(<::DepositPerByte as Get>::get(), deposit(0, 1),); diff --git a/runtime/testnet/src/config/contracts.rs b/runtime/testnet/src/config/contracts.rs index 8fdb07a40..f11a4ba57 100644 --- a/runtime/testnet/src/config/contracts.rs +++ b/runtime/testnet/src/config/contracts.rs @@ -98,7 +98,6 @@ impl pallet_revive::Config for Runtime { // 30 percent of storage deposit held for using a code hash. type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent; type Currency = Balances; - type Debug = (); type DepositPerByte = DepositPerByte; type DepositPerItem = DepositPerItem; type EthGasEncoder = (); From 25287792b98d8fcaf68e6195d54acefd5b69b18e Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:20:13 +0200 Subject: [PATCH 3/3] chore: sdk-7167 --- runtime/mainnet/src/apis.rs | 61 +++++++++++++++++++++++++++++++++++++ runtime/testnet/src/lib.rs | 61 +++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/runtime/mainnet/src/apis.rs b/runtime/mainnet/src/apis.rs index d28f3c5ad..b39bef39c 100644 --- a/runtime/mainnet/src/apis.rs +++ b/runtime/mainnet/src/apis.rs @@ -492,6 +492,67 @@ impl_runtime_apis! { key ) } + + fn trace_block( + block: Block, + config: pallet_revive::evm::TracerConfig + ) -> Vec<(u32, pallet_revive::evm::CallTrace)> { + use pallet_revive::tracing::trace; + let mut tracer = config.build(Revive::evm_gas_from_weight); + let mut traces = vec![]; + let (header, extrinsics) = block.deconstruct(); + + Executive::initialize_block(&header); + for (index, ext) in extrinsics.into_iter().enumerate() { + trace(&mut tracer, || { + let _ = Executive::apply_extrinsic(ext); + }); + + if let Some(tx_trace) = tracer.collect_traces().pop() { + traces.push((index as u32, tx_trace)); + } + } + + traces + } + + fn trace_tx( + block: Block, + tx_index: u32, + config: pallet_revive::evm::TracerConfig + ) -> Option { + use pallet_revive::tracing::trace; + let mut tracer = config.build(Revive::evm_gas_from_weight); + let (header, extrinsics) = block.deconstruct(); + + Executive::initialize_block(&header); + for (index, ext) in extrinsics.into_iter().enumerate() { + if index as u32 == tx_index { + trace(&mut tracer, || { + let _ = Executive::apply_extrinsic(ext); + }); + break; + } else { + let _ = Executive::apply_extrinsic(ext); + } + } + + tracer.collect_traces().pop() + } + + fn trace_call( + tx: pallet_revive::evm::GenericTransaction, + config: pallet_revive::evm::TracerConfig) + -> Result + { + use pallet_revive::tracing::trace; + let mut tracer = config.build(Revive::evm_gas_from_weight); + trace(&mut tracer, || { + Self::eth_transact(tx) + })?; + + Ok(tracer.collect_traces().pop().expect("eth_transact succeeded, trace must exist, qed")) + } } } diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index 5d68f2957..4f900576c 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -780,6 +780,67 @@ impl_runtime_apis! { key ) } + + fn trace_block( + block: Block, + config: pallet_revive::evm::TracerConfig + ) -> Vec<(u32, pallet_revive::evm::CallTrace)> { + use pallet_revive::tracing::trace; + let mut tracer = config.build(Revive::evm_gas_from_weight); + let mut traces = vec![]; + let (header, extrinsics) = block.deconstruct(); + + Executive::initialize_block(&header); + for (index, ext) in extrinsics.into_iter().enumerate() { + trace(&mut tracer, || { + let _ = Executive::apply_extrinsic(ext); + }); + + if let Some(tx_trace) = tracer.collect_traces().pop() { + traces.push((index as u32, tx_trace)); + } + } + + traces + } + + fn trace_tx( + block: Block, + tx_index: u32, + config: pallet_revive::evm::TracerConfig + ) -> Option { + use pallet_revive::tracing::trace; + let mut tracer = config.build(Revive::evm_gas_from_weight); + let (header, extrinsics) = block.deconstruct(); + + Executive::initialize_block(&header); + for (index, ext) in extrinsics.into_iter().enumerate() { + if index as u32 == tx_index { + trace(&mut tracer, || { + let _ = Executive::apply_extrinsic(ext); + }); + break; + } else { + let _ = Executive::apply_extrinsic(ext); + } + } + + tracer.collect_traces().pop() + } + + fn trace_call( + tx: pallet_revive::evm::GenericTransaction, + config: pallet_revive::evm::TracerConfig) + -> Result + { + use pallet_revive::tracing::trace; + let mut tracer = config.build(Revive::evm_gas_from_weight); + trace(&mut tracer, || { + Self::eth_transact(tx) + })?; + + Ok(tracer.collect_traces().pop().expect("eth_transact succeeded, trace must exist, qed")) + } } impl pallet_ismp_runtime_api::IsmpRuntimeApi::Hash> for Runtime {