Skip to content

Conversation

@akaladarshi
Copy link
Collaborator

@akaladarshi akaladarshi commented Jan 19, 2026

Summary of changes

Changes introduced in this pull request:

  • Adds support for the EthTraceReplayBlockTransactions V2 API
  • Small Refactor
  • Fix the discrepancy in EthTraceReplayBlockTransactions response

Reference issue to close (if applicable)

Closes #6308

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Summary by CodeRabbit

  • New Features

    • Added a V2 Ethereum trace-replay RPC endpoint (new API path) returning the same trace items with updated parameters.
  • Changes

    • Trace responses now always include stateDiff and vmTrace (nullable) for compatibility.
    • Improved validation and clearer error responses for trace type parameters.
    • Aligned V1/V2 handling to a shared implementation for consistent results.
  • Tests

    • Extended RPC test coverage and updated snapshots to include the V2 endpoint.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Walkthrough

Adds a V2 RPC method EthTraceReplayBlockTransactionsV2, centralizes replay logic into a new async helper eth_trace_replay_block_transactions, ensures V1 delegates to the helper, changes serialization to always emit state_diff and vm_trace (nullable), and updates tests/snapshots and registration.

Changes

Cohort / File(s) Summary
RPC method implementation
src/rpc/methods/eth.rs
Added EthTraceReplayBlockTransactionsV2 (Params = (ExtBlockNumberOrHash, Vec<String>), Ok = Vec<EthReplayBlockTransactionTrace>). Introduced eth_trace_replay_block_transactions<DB> async helper used by both V1 and V2. V2 validates traceTypes and uses V2 tipset resolver.
Types / serialization
src/rpc/methods/eth/types.rs
Removed #[serde(skip_serializing_if = "Option::is_none")] from state_diff and vm_trace on EthReplayBlockTransactionTrace, so those fields are serialized as null when absent.
RPC registration
src/rpc/mod.rs
Registered EthTraceReplayBlockTransactionsV2 in the for_each_rpc_method macro.
Tests & snapshots
src/tool/subcommands/api_cmd/api_compare_tests.rs, src/tool/subcommands/api_cmd/test_snapshots.txt
Added test entry for V2 (EthTraceReplayBlockTransactionsV2::request) and replaced/added snapshot files for the V2 output.
Docs / changelog
CHANGELOG.md
Documented addition of API v2 method and change to always include stateDiff and vmTrace (nullable) in responses.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client
participant RPC as "RPC Method (V1/V2)"
participant Resolver as "Tipset Resolver"
participant Tracer as "Trace Executor"
participant DB as "DB / State Viewer"
participant Assembler as "Trace Assembler"

Client->>RPC: ReplayBlockTransactions request
RPC->>Resolver: resolve tipset (V1 or V2)
Resolver-->>RPC: tipset
RPC->>Tracer: execute traces for tipset
Tracer-->>RPC: raw trace results
RPC->>DB: resolve tx hashes & fetch state
DB-->>RPC: tx hashes / state snapshots
RPC->>Assembler: build envs, capture vm_trace/state_diff, assemble results
Assembler-->>Client: Vec

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • hanabi1224
  • sudo-shashank
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically describes the main change: adding V2 API support for EthTraceReplayBlockTransactions, which aligns with the primary objective of the changeset.
Linked Issues check ✅ Passed The pull request implements the RPC v2 endpoint for Filecoin.EthTraceReplayBlockTransactions as required by issue #6308, adding the V2 variant with appropriate parameter types and return types.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the V2 API endpoint. The refactoring of shared logic between V1 and V2, serialization adjustments, and test updates are all in scope for this feature implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@akaladarshi akaladarshi force-pushed the akaladarshi/replay-block-tx-v2 branch from 62d9e13 to 1b2504a Compare January 20, 2026 08:59
@akaladarshi akaladarshi marked this pull request as ready for review January 20, 2026 08:59
@akaladarshi akaladarshi requested a review from a team as a code owner January 20, 2026 08:59
@akaladarshi akaladarshi requested review from LesnyRumcajs and hanabi1224 and removed request for a team January 20, 2026 08:59
@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 70.17544% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.76%. Comparing base (f96325d) to head (0741774).

Files with missing lines Patch % Lines
src/rpc/methods/eth.rs 70.17% 10 Missing and 7 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/rpc/methods/eth/types.rs 66.06% <ø> (ø)
src/rpc/mod.rs 24.47% <ø> (ø)
src/rpc/methods/eth.rs 67.67% <70.17%> (+0.01%) ⬆️

... and 7 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f96325d...0741774. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@akaladarshi akaladarshi added the RPC requires calibnet RPC checks to run on CI label Jan 20, 2026

let state = StateTree::new_from_root(ctx.store_owned(), &state_root)?;
pub enum EthTraceReplayBlockTransactionsV2 {}
impl RpcMethod<2> for EthTraceReplayBlockTransactionsV2 {
Copy link
Member

Choose a reason for hiding this comment

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

description?

Copy link
Collaborator Author

@akaladarshi akaladarshi Jan 20, 2026

Choose a reason for hiding this comment

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

I didn't notice this earlier that some of the other API's also doesn't have a Description, I will create an issue for this so we can add in all API's.

ctx: Ctx<impl Blockstore + Send + Sync + 'static>,
(block_param, trace_types): Self::Params,
) -> Result<Self::Ok, ServerError> {
if trace_types.as_slice() != ["trace"] {
Copy link
Member

Choose a reason for hiding this comment

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

is there a point in using anyhow here? Seems to me it'd be easier to define a new method on ServerError, e.g., ServerError::unsupported_params. It'd be cheaper.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess we can use the ServerError::invalid_params("only 'trace' is supported", None)

@akaladarshi akaladarshi force-pushed the akaladarshi/replay-block-tx-v2 branch from 6cbc78a to 505c6f5 Compare January 20, 2026 19:08
#[serde(rename_all = "camelCase")]
pub struct EthReplayBlockTransactionTrace {
pub output: EthBytes,
#[serde(skip_serializing_if = "Option::is_none")]
Copy link
Member

Choose a reason for hiding this comment

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

so this was incorrect?

Copy link
Member

Choose a reason for hiding this comment

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

what's the struct in Lotus?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC requires calibnet RPC checks to run on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RPC v2] Filecoin.EthTraceReplayBlockTransactions

3 participants