Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2413,20 +2413,19 @@ impl_runtime_apis! {

fn trace_block(
block: Block,
config: pallet_revive::evm::TracerConfig
) -> Vec<(u32, pallet_revive::evm::CallTrace)> {
tracer_type: pallet_revive::evm::TracerType,
) -> Vec<(u32, pallet_revive::evm::Trace)> {
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let mut tracer = Revive::evm_tracer(tracer_type);
let mut traces = vec![];
let (header, extrinsics) = block.deconstruct();

Executive::initialize_block(&header);
for (index, ext) in extrinsics.into_iter().enumerate() {
trace(&mut tracer, || {
trace(tracer.as_tracing(), || {
let _ = Executive::apply_extrinsic(ext);
});

if let Some(tx_trace) = tracer.collect_traces().pop() {
if let Some(tx_trace) = tracer.collect_trace() {
traces.push((index as u32, tx_trace));
}
}
Expand All @@ -2437,16 +2436,16 @@ impl_runtime_apis! {
fn trace_tx(
block: Block,
tx_index: u32,
config: pallet_revive::evm::TracerConfig
) -> Option<pallet_revive::evm::CallTrace> {
tracer_type: pallet_revive::evm::TracerType,
) -> Option<pallet_revive::evm::Trace> {
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let mut tracer = Revive::evm_tracer(tracer_type);
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, || {
trace(tracer.as_tracing(), || {
let _ = Executive::apply_extrinsic(ext);
});
break;
Expand All @@ -2455,24 +2454,25 @@ impl_runtime_apis! {
}
}

tracer.collect_traces().pop()
tracer.collect_trace()
}

fn trace_call(
tx: pallet_revive::evm::GenericTransaction,
config: pallet_revive::evm::TracerConfig)
-> Result<pallet_revive::evm::CallTrace, pallet_revive::EthTransactError>
tracer_type: pallet_revive::evm::TracerType,
)
-> Result<pallet_revive::evm::Trace, pallet_revive::EthTransactError>
{
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let result = trace(&mut tracer, || Self::eth_transact(tx));
let mut tracer = Revive::evm_tracer(tracer_type);
let result = trace(tracer.as_tracing(), || Self::eth_transact(tx));

if let Some(trace) = tracer.collect_traces().pop() {
if let Some(trace) = tracer.collect_trace() {
Ok(trace)
} else if let Err(err) = result {
Err(err)
} else {
Ok(Default::default())
Ok(tracer.empty_trace())
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions prdoc/pr_8495.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: '[pallet-revive] tracing prepare support for future tracing APIS'
doc:
- audience: Runtime Dev
description: |-
- Fix eth_getStorageAt to use BigEndian for key encoding
- Refactor eth-rpc client storage and runtime API to a separate file
- Make debug_trace methods Return a composite Trace enum so we can introduce other trace types

companion evm-test-suite PR https://github.com/paritytech/evm-test-suite/pull/93
crates:
- name: asset-hub-westend-runtime
bump: major
- name: pallet-revive-eth-rpc
bump: major
- name: pallet-revive
bump: major
Comment on lines +11 to +16
Copy link
Member

@athei athei May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major bumps cannot be backportet. Did you intend to get this into 2503?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I marked is as major cause it makes breaking change to the runtime API

34 changes: 17 additions & 17 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3491,20 +3491,19 @@ impl_runtime_apis! {

fn trace_block(
block: Block,
config: pallet_revive::evm::TracerConfig
) -> Vec<(u32, pallet_revive::evm::CallTrace)> {
tracer_type: pallet_revive::evm::TracerType,
) -> Vec<(u32, pallet_revive::evm::Trace)> {
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let mut tracer = Revive::evm_tracer(tracer_type);
let mut traces = vec![];
let (header, extrinsics) = block.deconstruct();

Executive::initialize_block(&header);
for (index, ext) in extrinsics.into_iter().enumerate() {
trace(&mut tracer, || {
trace(tracer.as_tracing(), || {
let _ = Executive::apply_extrinsic(ext);
});

if let Some(tx_trace) = tracer.collect_traces().pop() {
if let Some(tx_trace) = tracer.collect_trace() {
traces.push((index as u32, tx_trace));
}
}
Expand All @@ -3515,16 +3514,16 @@ impl_runtime_apis! {
fn trace_tx(
block: Block,
tx_index: u32,
config: pallet_revive::evm::TracerConfig
) -> Option<pallet_revive::evm::CallTrace> {
tracer_type: pallet_revive::evm::TracerType,
) -> Option<pallet_revive::evm::Trace> {
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let mut tracer = Revive::evm_tracer(tracer_type);
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, || {
trace(tracer.as_tracing(), || {
let _ = Executive::apply_extrinsic(ext);
});
break;
Expand All @@ -3533,24 +3532,25 @@ impl_runtime_apis! {
}
}

tracer.collect_traces().pop()
tracer.collect_trace()
}

fn trace_call(
tx: pallet_revive::evm::GenericTransaction,
config: pallet_revive::evm::TracerConfig)
-> Result<pallet_revive::evm::CallTrace, pallet_revive::EthTransactError>
tracer_type: pallet_revive::evm::TracerType,
)
-> Result<pallet_revive::evm::Trace, pallet_revive::EthTransactError>
{
use pallet_revive::tracing::trace;
let mut tracer = config.build(Revive::evm_gas_from_weight);
let result = trace(&mut tracer, || Self::eth_transact(tx));
let mut tracer = Revive::evm_tracer(tracer_type);
let result = trace(tracer.as_tracing(), || Self::eth_transact(tx));

if let Some(trace) = tracer.collect_traces().pop() {
if let Some(trace) = tracer.collect_trace() {
Ok(trace)
} else if let Err(err) = result {
Err(err)
} else {
Ok(Default::default())
Ok(tracer.empty_trace())
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/revive/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ sc-cli = { workspace = true, default-features = true }
sc-rpc = { workspace = true, default-features = true }
sc-rpc-api = { workspace = true, default-features = true }
sc-service = { workspace = true, default-features = true }
serde_json = { workspace = true }
sp-arithmetic = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-crypto-hashing = { workspace = true }
sp-rpc = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
sp-weights = { workspace = true, default-features = true }
sqlx = { workspace = true, features = ["macros", "runtime-tokio", "sqlite"] }
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/rpc/examples/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn main() -> anyhow::Result<()> {

let print_balance = || async {
let balance = client.get_balance(alith_address, BlockTag::Latest.into()).await?;
println!("Alith {:?} balance: {balance:?}", alith_address);
println!("Alith {alith_address:?} balance: {balance:?}");
let balance = client.get_balance(ethan.address(), BlockTag::Latest.into()).await?;
println!("ethan {:?} balance: {balance:?}", ethan.address());
anyhow::Result::<()>::Ok(())
Expand Down
Binary file modified substrate/frame/revive/rpc/revive_chain.metadata
Binary file not shown.
26 changes: 10 additions & 16 deletions substrate/frame/revive/rpc/src/apis/debug_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait DebugRpc {
&self,
transaction_hash: H256,
tracer_config: TracerConfig,
) -> RpcResult<CallTrace>;
) -> RpcResult<Trace>;

/// Dry run a call and returns the transaction's traces.
///
Expand All @@ -55,7 +55,7 @@ pub trait DebugRpc {
transaction: GenericTransaction,
block: BlockNumberOrTag,
tracer_config: TracerConfig,
) -> RpcResult<CallTrace>;
) -> RpcResult<Trace>;
}

pub struct DebugRpcServerImpl {
Expand Down Expand Up @@ -93,32 +93,26 @@ impl DebugRpcServer for DebugRpcServerImpl {
block: BlockNumberOrTag,
tracer_config: TracerConfig,
) -> RpcResult<Vec<TransactionTrace>> {
with_timeout(tracer_config.timeout, self.client.trace_block_by_number(block, tracer_config))
.await
let TracerConfig { config, timeout } = tracer_config;
with_timeout(timeout, self.client.trace_block_by_number(block, config)).await
}

async fn trace_transaction(
&self,
transaction_hash: H256,
tracer_config: TracerConfig,
) -> RpcResult<CallTrace> {
with_timeout(
tracer_config.timeout,
self.client.trace_transaction(transaction_hash, tracer_config),
)
.await
) -> RpcResult<Trace> {
let TracerConfig { config, timeout } = tracer_config;
with_timeout(timeout, self.client.trace_transaction(transaction_hash, config)).await
}

async fn trace_call(
&self,
transaction: GenericTransaction,
block: BlockNumberOrTag,
tracer_config: TracerConfig,
) -> RpcResult<CallTrace> {
with_timeout(
tracer_config.timeout,
self.client.trace_call(transaction, block, tracer_config),
)
.await
) -> RpcResult<Trace> {
let TracerConfig { config, timeout } = tracer_config;
with_timeout(timeout, self.client.trace_call(transaction, block, config)).await
}
}
6 changes: 6 additions & 0 deletions substrate/frame/revive/rpc/src/block_info_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ impl BlockInfoProvider for SubxtBlockInfoProvider {
&self,
block_number: SubstrateBlockNumber,
) -> Result<Option<Arc<SubstrateBlock>>, ClientError> {
if block_number == self.latest_block().await.number() {
return Ok(Some(self.latest_block().await));
} else if block_number == self.latest_finalized_block().await.number() {
return Ok(Some(self.latest_finalized_block().await));
}

let Some(hash) = self.rpc.chain_get_block_hash(Some(block_number.into())).await? else {
return Ok(None);
};
Expand Down
Loading
Loading