perf(l1): precompute eth_getLogs bloom inputs once instead of per-block#6895
perf(l1): precompute eth_getLogs bloom inputs once instead of per-block#6895ElFantasma wants to merge 2 commits into
Conversation
🤖 Kimi Code ReviewThis is a well-crafted performance optimization. The change correctly moves bloom filter derivation from a per-block hot path to a one-time upfront computation, significantly reducing hashing overhead for wide block ranges. Correctness & Logic
Code Quality
Minor Suggestions
Verdict: The PR is correct, secure (read-only optimization with no side effects), and follows Rust idioms. The performance improvement for RPC log filtering on wide ranges will be substantial. Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Claude Code ReviewPR #6895 —
|
🤖 Codex Code ReviewNo findings. This looks correct on review. The change stays in the RPC log prefilter path and preserves the exact filtering logic later in The added unit coverage is good, especially the regression test at I could not run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Lines of code reportTotal lines added: Detailed view |
Benchmark Block Execution Results Comparison Against Main
|
Motivation
In the
eth_getLogsheader-bloom prefilter, the per-block check re-derived each requested address's and topic's bloom bits on every block:Bloom::contains_input(BloomInput::Raw(..))internally doesBloom::from(input)(a keccak + bit extraction) before the subset test. Since the filter is constant for the whole query, that derivation was recomputed once per block — and for wide-range queries that skip most blocks, the bloom check is the only per-block work, so a ~1M-block sparse query did ~1M redundant keccaks.Raised by @iovoid in review of #6813. Closes #6893.
Description
BloomFilterMatcher, built once before the block loop, holding each address and each constrained topic position pre-derived intoBlooms (a topic position is a wildcard, or an OR over its concrete alternatives — preserving theNone/empty-list wildcard semantics).block_bloom.contains_bloom(&precomputed)— a cheap bit-subset test with no hashing.bloom_match_*unit tests pass unchanged (rewired through abloom_matcheshelper that builds the matcher).Checklist
contains_bloombloom_match_*tests pass unchanged