feat(rpc): implement Parity trace_ namespace (9 methods)#121
feat(rpc): implement Parity trace_ namespace (9 methods)#121
Conversation
8221a2c to
b3d7ca3
Compare
9af104c to
4dd2e29
Compare
b3d7ca3 to
552d4ff
Compare
4dd2e29 to
03bbd7c
Compare
552d4ff to
d3034ae
Compare
03bbd7c to
c0379af
Compare
d3034ae to
d12d1b2
Compare
crates/rpc/src/config/rpc_config.rs
Outdated
| /// Maximum block range for trace_filter queries. | ||
| #[from_env( | ||
| var = "SIGNET_RPC_MAX_TRACE_FILTER_BLOCKS", | ||
| desc = "Maximum block range for trace_filter queries", |
There was a problem hiding this comment.
| desc = "Maximum block range for trace_filter queries", | |
| desc = "Maximum block range for trace_filter queries [default: 100]", |
There was a problem hiding this comment.
[Claude Code]
Fixed — added [default: 100] to match the other field descriptions.
crates/rpc/src/trace/endpoints.rs
Outdated
| /// | ||
| /// Replays all transactions in a block (stopping at the first | ||
| /// magic-signature tx) and returns localized Parity traces. | ||
| #[allow(clippy::too_many_arguments)] |
There was a problem hiding this comment.
I think this can be removed?
There was a problem hiding this comment.
[Claude Code]
Removed. trace_block_localized has 7 params — under clippy's threshold.
crates/rpc/src/trace/endpoints.rs
Outdated
| <Db as Database>::Error: DBErrorMarker, | ||
| <Db as DatabaseRef>::Error: DBErrorMarker, | ||
| { | ||
| use itertools::Itertools; |
There was a problem hiding this comment.
Import once at the top of the file rather than multiple times inline?
There was a problem hiding this comment.
[Claude Code]
Moved to a single top-level import. Removed all 4 inline use itertools::Itertools; statements.
crates/rpc/src/trace/endpoints.rs
Outdated
| constants: SignetSystemConstants, | ||
| spec_id: SpecId, | ||
| header: &alloy::consensus::Header, | ||
| _block_hash: B256, |
There was a problem hiding this comment.
Can we remove this param? If we can, we can also remove the #[allow(clippy::too_many_arguments)].
There was a problem hiding this comment.
[Claude Code]
Removed _block_hash and the #[allow(clippy::too_many_arguments)] — params drop from 8 to 7.
crates/rpc/src/trace/endpoints.rs
Outdated
| } | ||
|
|
||
| let max = ctx.config().max_trace_filter_blocks; | ||
| let distance = end.saturating_sub(start); |
There was a problem hiding this comment.
| let distance = end.saturating_sub(start); | |
| let distance = end.saturating_sub(start) + 1; |
There was a problem hiding this comment.
[Claude Code]
Fixed — end.saturating_sub(start) + 1 to correctly count inclusive range.
crates/rpc/src/trace/endpoints.rs
Outdated
| return Err(TraceError::BlockNotFound(BlockId::latest())); | ||
| } | ||
| if start > end { | ||
| return Err(TraceError::EvmHalt { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
[Claude Code]
Added a dedicated InvalidBlockRange { reason: String } variant for this case. Maps to -32602 (invalid params) which fits better than -32000 (server error).
crates/rpc/src/trace/endpoints.rs
Outdated
| if start > latest || end > latest { | ||
| return Err(TraceError::BlockNotFound(BlockId::latest())); | ||
| } |
There was a problem hiding this comment.
| 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()))); | |
| } |
There was a problem hiding this comment.
[Claude Code]
Split into two separate checks, each returning BlockNotFound with the specific out-of-range block number.
c0379af to
f3d693c
Compare
d12d1b2 to
8eb7f8c
Compare
f3d693c to
f945ca7
Compare
38ee26f to
c9734e7
Compare
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>
c9734e7 to
e596c5c
Compare
crates/rpc/src/trace/endpoints.rs
Outdated
| <Db as Database>::Error: DBErrorMarker, | ||
| <Db as DatabaseRef>::Error: std::fmt::Debug + DBErrorMarker, | ||
| { | ||
| use itertools::Itertools; |
There was a problem hiding this comment.
seems to be imported multiple times?
There was a problem hiding this comment.
[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>
Summary
Implements the complete Parity/OpenEthereum
trace_JSON-RPC namespace (9 methods) insignet-rpcfor Blockscout and general tooling compatibility. Stacks on top of #120.trace_block,trace_transaction,trace_get— localized Parity tracestrace_replayBlockTransactions,trace_replayTransaction— replay with trace type selection (trace,vmTrace,stateDiff)trace_call,trace_callMany— call tracing with state/block overrides and accumulated statetrace_rawTransaction— trace from raw RLP bytestrace_filter— brute-force block range filter with configurable limit (default 100, envSIGNET_RPC_MAX_TRACE_FILTER_BLOCKS)Architecture: new
tracemodule mirroringdebug; two shared Parity tracer functions indebug/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 passcargo clippy -p signet-rpc --all-features --all-targets— cleancargo clippy --all-features --all-targets— workspace cleancargo +nightly fmt --check— clean🤖 Generated with Claude Code