feat(rpc): Add support for the EthTraceBlock V2 API#6451
Conversation
WalkthroughAdded a v2 RPC for Filecoin.EthTraceBlock, extracted shared block-tracing into a helper used by both v1 and v2, updated EthTraceTransaction to use v2 tipset resolution and the helper, registered the new method, and added tests and snapshots. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant RPC_Dispatcher
participant EthHandler as EthTraceBlockV2_Handler
participant TipsetResolver
participant EthHelper as eth_trace_block
participant Blockstore
participant Tracer
Client->>RPC_Dispatcher: Filecoin.EthTraceBlock request
RPC_Dispatcher->>EthHandler: dispatch to handler
EthHandler->>TipsetResolver: resolve block param (v2)
TipsetResolver-->>EthHandler: Tipset
EthHandler->>EthHelper: eth_trace_block(ctx, tipset)
EthHelper->>Blockstore: load blocks, receipts, state_root
Blockstore-->>EthHelper: block data & receipts
EthHelper->>Tracer: execute traces / collect execution traces & messages
Tracer-->>EthHelper: traces
EthHelper-->>EthHandler: Vec<EthBlockTrace>
EthHandler-->>RPC_Dispatcher: return traces
RPC_Dispatcher-->>Client: respond
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
b710370 to
cdc6e0c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
sudo-shashank
left a comment
There was a problem hiding this comment.
@akaladarshi let's update changelog and it would be good to update the change checklist in PR details.
dacba53 to
6862786
Compare
Co-authored-by: Shashank <99187193+sudo-shashank@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/rpc/methods/eth.rs (1)
3711-3753: Fix transaction_position off‑by‑one.
msg_idxis incremented before it is used, so the first trace in a block reportstransaction_position = 1instead of0. This will misalign trace output witheth_getTransactionByBlockNumberAndIndexand other zero‑based indices.🐛 Proposed fix
- let mut msg_idx = 0; + let mut msg_idx: i64 = 0; for ir in trace.into_iter() { // ignore messages from system actor if ir.msg.from == system::ADDRESS.into() { continue; } - msg_idx += 1; + let tx_position = msg_idx; + msg_idx += 1; let tx_hash = EthGetTransactionHashByCid::handle(ctx.clone(), (ir.msg_cid,)).await?; let tx_hash = tx_hash .with_context(|| format!("cannot find transaction hash for cid {}", ir.msg_cid))?; let mut env = trace::base_environment(&state, &ir.msg.from) .map_err(|e| format!("when processing message {}: {}", ir.msg_cid, e))?; if let Some(execution_trace) = ir.execution_trace { trace::build_traces(&mut env, &[], execution_trace)?; for trace in env.traces { all_traces.push(EthBlockTrace { @@ - transaction_position: msg_idx as i64, + transaction_position: tx_position, }); } } }
Summary of changes
Changes introduced in this pull request:
EthTraceBlockAPI V2 supportReference issue to close (if applicable)
Closes #6306
Other information and links
Change checklist
Summary by CodeRabbit
New Features
Tests
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.