feat(l1): implement debug_getBadBlocks RPC endpoint#6693
Conversation
Add debug_getBadBlocks which returns the list of bad blocks the client has encountered. Currently returns an empty array since ethrex does not maintain a bad block cache like geth does. Part of #6572
|
🤖 Kimi Code ReviewThe implementation is correct and follows the existing patterns in the codebase. A few minor observations:
Correctness verification:
Security: No concerns. This is a read-only endpoint returning static data with no side effects. The implementation appropriately acknowledges that ethrex doesn't currently track bad blocks (which would require maintaining a ring buffer of failed validations), and returning an empty array is the valid response per Geth's API specification. Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
Greptile SummaryThis PR adds the
Confidence Score: 5/5Safe to merge — the change adds a spec-valid stub endpoint that has no side effects and cannot corrupt state. The core implementation is a no-op handler (always returns test/tests/rpc/debug_trace_tests.rs — contains dead helper functions that will produce compiler warnings.
|
| Filename | Overview |
|---|---|
| crates/networking/rpc/debug/get_bad_blocks.rs | New stub handler for debug_getBadBlocks; correctly rejects params and returns an empty array; includes thorough unit tests. |
| crates/networking/rpc/debug/mod.rs | Adds get_bad_blocks module declaration; trivial one-line change, no issues. |
| crates/networking/rpc/rpc.rs | Registers GetBadBlocksRequest import and routes debug_getBadBlocks in the match arm; doc-comment updated to reflect new and existing methods. |
| test/tests/rpc/debug_trace_tests.rs | Integration test file for debug_getBadBlocks; contains unused helper functions (setup_single_transfer_block, build_block, create_transfer_tx, build_and_execute_block, TestEnv) that are dead code and will produce compiler warnings. |
| test/tests/rpc/mod.rs | Registers the new debug_trace_tests module; trivial change, no issues. |
Sequence Diagram
sequenceDiagram
participant Client
participant map_http_requests
participant map_debug_requests
participant GetBadBlocksRequest
Client->>map_http_requests: POST /rpc (debug_getBadBlocks)
map_http_requests->>map_debug_requests: "route debug_* method"
map_debug_requests->>GetBadBlocksRequest: call(req, context)
GetBadBlocksRequest->>GetBadBlocksRequest: parse(params) — rejects non-empty params
GetBadBlocksRequest->>GetBadBlocksRequest: handle() — returns []
GetBadBlocksRequest-->>map_debug_requests: Ok(Value::Array([]))
map_debug_requests-->>map_http_requests: Ok(Value::Array([]))
map_http_requests-->>Client: "{"jsonrpc":"2.0","result":[],"id":1}"
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
test/tests/rpc/debug_trace_tests.rs:65-160
**Unused scaffolding generates dead-code warnings**
`build_block`, `create_transfer_tx`, `build_and_execute_block`, `setup_single_transfer_block`, the `TestEnv` struct, `TEST_MAX_FEE_PER_GAS`, and `TEST_GAS_LIMIT` are all defined but never called by any `#[test]` function in this file. The Rust compiler will emit `dead_code` warnings for each of them, and if the project treats warnings as errors in CI these will become build failures. If these helpers are pre-emptive scaffolding for upcoming trace tests, adding `#[allow(dead_code)]` at the top of the file (or moving them into a private module gated by that attribute) will silence the warnings until the tests arrive.
Reviews (2): Last reviewed commit: "fix(rpc): update map_debug_requests doc-..." | Re-trigger Greptile
🤖 Claude Code ReviewHere is my review of PR #6693: PR Review:
|
🤖 Codex Code Review
No other correctness, security, or performance issues stood out in this diff. The change is mechanically small and follows the existing RPC handler pattern; the main problem is the misleading behavior of the new endpoint. Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Lines of code reportTotal lines added: Detailed view |
Call debug_getBadBlocks and assert the response is an empty array, since ethrex does not currently track bad blocks.
The doc-comment was missing debug_getBadBlocks, debug_chainConfig, debug_getBlockAccessList, and debug_executionWitnessByBlockHash.
🤖 Kimi Code ReviewThe implementation is correct and follows the established patterns in the codebase. Below are specific observations:
|
🤖 Codex Code Review
No consensus/EVM/gas-accounting/security issues are introduced by the dispatcher wiring in [crates/networking/rpc/rpc.rs:1062-1077] itself. I could not run the tests locally because Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
🤖 Claude Code ReviewNow I have all the information needed to write the review. PR Review:
|
Summary
Adds the
debug_getBadBlocksRPC endpoint as specified in the execution-apis OpenRPC spec.This is a stub that always returns
[]. A full implementation is not currently possible because ethrex lacks the required storage infrastructure:(bad_block_hash → latest_valid_hash)in theINVALID_CHAINStable (used by the fork-choice handler). It does not persist the full block data or the validation error when a block is rejected.Returning
[]is spec-valid — it's the correct response for a node that has not encountered any bad blocks. The endpoint is registered so that tooling that probes for it (e.g. Blockscout, hive tests) gets a well-formed response instead of amethod not founderror.Part of #6572
Test plan
debug_getBadBlocksreturns[]trace_get_bad_blocks)