Skip to content

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

Open
prestwich wants to merge 7 commits intodevelopfrom
prestwich/eng-1899
Open

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

Conversation

@prestwich
Copy link
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 and others added 7 commits March 26, 2026 11:34
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Payload

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restructure EthError, DebugError, and SignetError with IntoErrorPayload
impls. Migrate all 45 RPC endpoints from Result<T, String> /
ResponsePayload<T, E> to Result<T, ErrorType> with proper JSON-RPC
error codes:

- Code 3: EVM reverts (with revert bytes in data field)
- Code -32000: Server/infrastructure errors
- Code -32001: Resource not found (block, tx, receipt)
- Code -32602: Invalid client parameters
- Code -32601: Unsupported operations

Remove CallErrorData, response_tri! macro, EthError::into_string.
Simplify await_handler! to single parameterized form.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…licate

- Use `?` for resolve_block_id in eth endpoints so hash-not-found
  returns -32001 instead of -32000
- Use `?` for cold storage errors so they route through #[from] impls
  with sanitized "server error" messages instead of leaking internals
- Remove unused EvmRevert variants from DebugError and SignetError
- Add EthError::task_panic() to replace 20+ inline copies
- Fix resolve_error_code to be const fn (clippy)
- Map decode_2718 errors to InvalidParams (-32602) instead of Internal
- Remove tracked docs/ files from git, widen .gitignore to docs/

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace git branch reference with crates.io release.

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