← Back to Pull requests

fix(l1,l2): make eth_getLogs topics optional and honour blockHash #7098

Closed
unknown closed this pull request without merging on Aug 06, 2026 07:29 UTC
View on GitHub
unknown unknown commented on Aug 03, 2026 20:45 UTC
Author

Two spec deviations in eth_getLogs, both in crates/networking/rpc/eth/logs.rs.

topics was mandatory

Every field of the filter object is optional in execution-apis/src/schemas/filter.yaml, and an absent topics means match any topic. LogsFilter::parse read it with .ok_or_else(|| RpcErr::MissingParam("topics")), so a request omitting it got -32000 Expected parameter: topics is missing, while fromBlock, toBlock and address immediately above all tolerate absence via .map(...).transpose()?. Everything downstream already handled the empty case (topics: topics_filters.unwrap_or_else(Vec::new), and the if filter.topics.is_empty() short-circuit in fetch_logs_with_filter), so this is the parse step being written in a different shape than its neighbours. "topics": null behaves as before.

geth agrees: GetLogs only rejects len(crit.Topics) > maxTopics and never requires the field.

blockHash was silently ignored

EIP-234 lets a filter name one block by hash instead of a range, and the schema models the two as mutually exclusive shapes. LogsFilter had no field for it, and since the parser reads keys by name and ignores the rest, {"blockHash": "0x…"} was not rejected but dropped, leaving from_block/to_block at their latest defaults. The request appeared to succeed and returned the head block's logs instead of the requested block's.

That failure mode matters precisely where the hash form is used. Naming a block by hash rather than by height exists so a reorg produces an error instead of substituting a different block at the same height; returning the head's logs defeats the guarantee and hands back wrong data with no signal. A chain-following consumer at the tip is the main caller of this shape.

So block_hash: Option<H256> is now a real field: parsed, WrongParam when malformed, and honoured in fetch_logs_with_filter, which resolves the hash to a block number and scans exactly that block, erroring with BadParams on an unknown hash. Combining it with fromBlock or toBlock is BadParams, matching geth's errBlockHashWithRange ("can't specify fromBlock/toBlock with blockHash").

eth_newFilter shares this parser but tracks a moving range of blocks, and the spec defines blockHash for eth_getLogs only, so NewFilterRequest::parse rejects the field rather than accepting something meaningless.

Tests

Added to the logs module: an absent topics key, a fully empty filter object, blockHash alone, blockHash combined with either range field rejected, and a malformed blockHash rejected. The existing tests all passed topics explicitly and never passed a blockHash, which is why neither gap was caught.

cargo test -p ethrex-rpc --lib is green (103 tests), cargo fmt --check and cargo clippy -p ethrex-rpc --lib clean.

Draft because the blockHash path is only covered by parse-level tests here: it would be worth an integration test against a store with a known block, and a hive/spec-test run, before merging.

Diff: 393 lines (+294 / -99) across 4 files Reviewer: ElFantasma Review duration: 3524m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 393 lines diff across 4 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.358
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #7098"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 43.1% (MEDIUM) · Higher = larger blast radius
43.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17% · Safe to merge
17%