X Tutup
Skip to content

feat(rpc): structured JSON-RPC error codes for all endpoints#119

Open
prestwich wants to merge 1 commit intodevelopfrom
prestwich/eng-1899
Open

feat(rpc): structured JSON-RPC error codes for all endpoints#119
prestwich wants to merge 1 commit intodevelopfrom
prestwich/eng-1899

Conversation

@prestwich
Copy link
Copy Markdown
Member

@prestwich prestwich commented Mar 25, 2026

[Claude Code]

Summary

  • Restructure EthError, DebugError, and SignetError with IntoErrorPayload impls (ajj 0.7) so all 45 RPC endpoints return proper JSON-RPC error codes instead of blanket -32603
  • Migrate all endpoints from Result<T, String> / ResponsePayload<T, E> to Result<T, ErrorType> — the framework handles error-to-JSON-RPC conversion automatically
  • Remove CallErrorData, response_tri! macro, EthError::into_string; simplify await_handler! to single parameterized form
  • Cold storage and resolve errors use ? with #[from] impls for correct error codes and sanitized messages (no internal details leaked)
  • Remove unused EvmRevert variants from DebugError and SignetError
  • Add EthError::task_panic() constructor to deduplicate 20+ inline copies

Error code mapping

Code Meaning Examples
3 EVM revert (geth convention) eth_call, eth_estimateGas reverts — revert bytes in data field
-32000 Server error Storage failures, task panics, EVM halts
-32001 Resource not found Block/tx/receipt not found, hash resolution failures
-32602 Invalid params Bad percentiles, filter range violations, decode errors
-32601 Method not found debug_traceTransaction with unsupported tracer

Dependencies

  • Requires ajj 0.7.0 (IntoErrorPayload trait) — currently patched to ajj PR #42 branch. Will update to published version once merged.

Closes ENG-1899

Test plan

  • All 35 unit/integration tests pass
  • All 6 doc tests pass
  • Clippy clean with --all-features
  • Formatted with cargo +nightly fmt
  • Verify error responses with a running node (manual)
  • Update ajj dependency to published 0.7.0 once PR fix: Update Signet docs link in README #42 merges

🤖 Generated with Claude Code

@prestwich prestwich requested a review from a team as a code owner March 25, 2026 11:51
@prestwich prestwich requested a review from Fraser999 March 25, 2026 23:24
@prestwich prestwich force-pushed the prestwich/eng-1899 branch from dfd1229 to b87e46b Compare March 26, 2026 15:37
Replace string-based RPC errors with structured error types implementing
ajj's IntoErrorPayload trait. Each namespace (eth, debug, signet) gets a
dedicated error enum with spec-compliant error codes.

- Add EthError, DebugError, SignetError with thiserror + IntoErrorPayload
- Replace response_tri! macro and string errors with typed error propagation
- Add resolve_block_id/resolve_header helpers with ResolveError
- Update ajj dependency from git branch to published 0.7.0
- Preserve hot storage reader consistency from #118

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prestwich prestwich force-pushed the prestwich/eng-1899 branch from b87e46b to 112c417 Compare March 26, 2026 21:41
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.

1 participant

X Tutup