Skip to content

feat(rpc): implement Parity trace_ namespace (9 methods)#121

Merged
prestwich merged 13 commits intodevelopfrom
prestwich/parity-trace-namespace
Mar 31, 2026
Merged

feat(rpc): implement Parity trace_ namespace (9 methods)#121
prestwich merged 13 commits intodevelopfrom
prestwich/parity-trace-namespace

Conversation

@prestwich
Copy link
Copy Markdown
Member

Summary

Implements the complete Parity/OpenEthereum trace_ JSON-RPC namespace (9 methods) in signet-rpc for Blockscout and general tooling compatibility. Stacks on top of #120.

  • trace_block, trace_transaction, trace_get — localized Parity traces
  • trace_replayBlockTransactions, trace_replayTransaction — replay with trace type selection (trace, vmTrace, stateDiff)
  • trace_call, trace_callMany — call tracing with state/block overrides and accumulated state
  • trace_rawTransaction — trace from raw RLP bytes
  • trace_filter — brute-force block range filter with configurable limit (default 100, env SIGNET_RPC_MAX_TRACE_FILTER_BLOCKS)

Architecture: new trace module mirroring debug; two shared Parity tracer functions in debug/tracer.rs; two shared block replay helpers; all handlers semaphore-gated.

Closes ENG-2088, ENG-1064, ENG-1065

Test plan

  • cargo t -p signet-rpc — 35 unit + 6 doc-tests pass
  • cargo clippy -p signet-rpc --all-features --all-targets — clean
  • cargo clippy --all-features --all-targets — workspace clean
  • cargo +nightly fmt --check — clean
  • Route count: 9 trace routes wired (62 total)
  • Manual smoke test against a running node with Blockscout

🤖 Generated with Claude Code

@prestwich prestwich requested a review from a team as a code owner March 25, 2026 23:20
@prestwich prestwich requested a review from Fraser999 March 25, 2026 23:24
@prestwich prestwich marked this pull request as draft March 26, 2026 11:07
@prestwich prestwich force-pushed the prestwich/parity-trace-namespace branch from 8221a2c to b3d7ca3 Compare March 26, 2026 14:49
@prestwich prestwich force-pushed the prestwich/eng-960-rpc-namespace-completeness branch from 9af104c to 4dd2e29 Compare March 26, 2026 15:29
@prestwich prestwich force-pushed the prestwich/parity-trace-namespace branch from b3d7ca3 to 552d4ff Compare March 26, 2026 15:29
@prestwich prestwich force-pushed the prestwich/eng-960-rpc-namespace-completeness branch from 4dd2e29 to 03bbd7c Compare March 26, 2026 15:38
@prestwich prestwich force-pushed the prestwich/parity-trace-namespace branch from 552d4ff to d3034ae Compare March 26, 2026 15:38
@prestwich prestwich force-pushed the prestwich/eng-960-rpc-namespace-completeness branch from 03bbd7c to c0379af Compare March 26, 2026 21:41
@prestwich prestwich force-pushed the prestwich/parity-trace-namespace branch from d3034ae to d12d1b2 Compare March 26, 2026 21:41
/// Maximum block range for trace_filter queries.
#[from_env(
var = "SIGNET_RPC_MAX_TRACE_FILTER_BLOCKS",
desc = "Maximum block range for trace_filter queries",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
desc = "Maximum block range for trace_filter queries",
desc = "Maximum block range for trace_filter queries [default: 100]",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Claude Code]

Fixed — added [default: 100] to match the other field descriptions.

///
/// Replays all transactions in a block (stopping at the first
/// magic-signature tx) and returns localized Parity traces.
#[allow(clippy::too_many_arguments)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this can be removed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Claude Code]

Removed. trace_block_localized has 7 params — under clippy's threshold.

<Db as Database>::Error: DBErrorMarker,
<Db as DatabaseRef>::Error: DBErrorMarker,
{
use itertools::Itertools;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Import once at the top of the file rather than multiple times inline?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Claude Code]

Moved to a single top-level import. Removed all 4 inline use itertools::Itertools; statements.

constants: SignetSystemConstants,
spec_id: SpecId,
header: &alloy::consensus::Header,
_block_hash: B256,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we remove this param? If we can, we can also remove the #[allow(clippy::too_many_arguments)].

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Claude Code]

Removed _block_hash and the #[allow(clippy::too_many_arguments)] — params drop from 8 to 7.

}

let max = ctx.config().max_trace_filter_blocks;
let distance = end.saturating_sub(start);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let distance = end.saturating_sub(start);
let distance = end.saturating_sub(start) + 1;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Claude Code]

Fixed — end.saturating_sub(start) + 1 to correctly count inclusive range.

return Err(TraceError::BlockNotFound(BlockId::latest()));
}
if start > end {
return Err(TraceError::EvmHalt {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure that EvmHalt is the best way to describe this. Maybe we could change BlockRangeExceeded to something like InvalidBlockRange and make the requested field a negative value in this case, or just add a completely new error variant for this case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Claude Code]

Added a dedicated InvalidBlockRange { reason: String } variant for this case. Maps to -32602 (invalid params) which fits better than -32000 (server error).

Comment on lines +576 to +578
if start > latest || end > latest {
return Err(TraceError::BlockNotFound(BlockId::latest()));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if start > latest || end > latest {
return Err(TraceError::BlockNotFound(BlockId::latest()));
}
if start > latest {
return Err(TraceError::BlockNotFound(BlockId::Number(start.into())));
}
if end > latest {
return Err(TraceError::BlockNotFound(BlockId::Number(end.into())));
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Claude Code]

Split into two separate checks, each returning BlockNotFound with the specific out-of-range block number.

@prestwich prestwich force-pushed the prestwich/eng-960-rpc-namespace-completeness branch from c0379af to f3d693c Compare March 30, 2026 17:35
@prestwich prestwich force-pushed the prestwich/parity-trace-namespace branch from d12d1b2 to 8eb7f8c Compare March 30, 2026 17:42
@prestwich prestwich force-pushed the prestwich/eng-960-rpc-namespace-completeness branch from f3d693c to f945ca7 Compare March 31, 2026 11:31
@prestwich prestwich force-pushed the prestwich/parity-trace-namespace branch from 38ee26f to c9734e7 Compare March 31, 2026 11:32
@prestwich prestwich requested review from Evalir and Fraser999 March 31, 2026 11:38
prestwich and others added 11 commits March 31, 2026 08:08
12 tasks covering TraceError, param types, config, Parity tracer
functions, block replay helpers, 9 trace_ endpoints, and router wiring.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements the trace_block and trace_transaction async RPC handlers,
calling the existing trace_block_localized helper for block-level and
per-transaction Parity trace output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e_get, and trace_filter

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Creates trace/mod.rs with the router constructor and wires it into
the combined router. Fixes HashSet type mismatch (std to alloy) and
removes erroneous accept_state() call on already-needs-tx state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The docs/ directory is already in .gitignore — these were force-added.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prestwich prestwich force-pushed the prestwich/parity-trace-namespace branch from c9734e7 to e596c5c Compare March 31, 2026 12:09
@prestwich prestwich changed the base branch from prestwich/eng-960-rpc-namespace-completeness to develop March 31, 2026 12:09
@prestwich prestwich marked this pull request as ready for review March 31, 2026 12:09
<Db as Database>::Error: DBErrorMarker,
<Db as DatabaseRef>::Error: std::fmt::Debug + DBErrorMarker,
{
use itertools::Itertools;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems to be imported multiple times?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[Claude Code]

Fixed — moved to a single top-level import.

- Add [default: 100] to trace_filter config description
- Move itertools import to top-level, remove inline imports
- Remove unused _block_hash param from trace_block_replay
- Remove unnecessary #[allow(clippy::too_many_arguments)]
- Fix off-by-one in trace_filter block range distance
- Add InvalidBlockRange error variant for fromBlock > toBlock
- Return specific block numbers in BlockNotFound errors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prestwich prestwich enabled auto-merge (squash) March 31, 2026 19:37
@prestwich prestwich merged commit 7d0a118 into develop Mar 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants