Skip to content

Commit 7949d23

Browse files
--wip-- [skip ci]
1 parent 23024ae commit 7949d23

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

crates/evm-debug-api/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ use sp_core::{sp_std::vec::Vec, H160, H256, U256};
77
sp_api::decl_runtime_apis! {
88
/// Runtime API for the EVM debug logic.
99
pub trait EvmDebugApi {
10+
/// Trace block.
11+
fn trace_block(
12+
extrinsics: Vec<Block::Extrinsic>,
13+
known_transactions: Vec<H256>,
14+
header: &Block::Header,
15+
) -> Result<(), sp_runtime::DispatchError>;
16+
1017
// Allow too many arguments to pass them in the way used at EVM runner call.
1118
#[allow(clippy::too_many_arguments)]
12-
/// Trace EVM call execution.
19+
/// Trace call execution.
1320
fn trace_call(
1421
header: &Block::Header,
1522
from: H160,

crates/humanode-runtime/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,35 @@ impl_runtime_apis! {
15061506

15071507
#[cfg(feature = "evm-tracing")]
15081508
impl evm_debug_api::EvmDebugApi<Block> for Runtime {
1509+
fn trace_block(
1510+
extrinsics: Vec<<Block as BlockT>::Extrinsic>,
1511+
known_transactions: Vec<H256>,
1512+
header: &<Block as BlockT>::Header,
1513+
) -> Result<(), sp_runtime::DispatchError> {
1514+
Executive::initialize_block(header);
1515+
1516+
let mut config = <Runtime as pallet_evm::Config>::config().clone();
1517+
config.estimate = true;
1518+
1519+
// Apply all extrinsics. Ethereum extrinsics are traced.
1520+
for ext in extrinsics.into_iter() {
1521+
match &ext.0.function {
1522+
RuntimeCall::Ethereum(transact { transaction }) => {},
1523+
_ => {
1524+
if let Err(err) = Executive::apply_extrinsic(ext) {
1525+
frame_support::log::debug!(
1526+
target: "tracing",
1527+
"Failed to apply non-eth extrinsic: {:?}",
1528+
err
1529+
);
1530+
}
1531+
}
1532+
}
1533+
}
1534+
1535+
Ok(())
1536+
}
1537+
15091538
fn trace_call(
15101539
header: &<Block as BlockT>::Header,
15111540
from: H160,

0 commit comments

Comments
 (0)