#35837 rpc: fail scanblocks when block filter range is unavailable
https://github.com/bitcoin/bitcoin/pull/35837 · · +81/-13 in 2 files, 1 commits · labels: RPC/REST/ZMQ
Goal
- Stop scanblocks from silently skipping unindexed blocks and falsely reporting completion
- Ensure wallets and client applications are warned when scans cannot check requested ranges
Fixes `scanblocks` so that failures during `LookupFilterRange` are surfaced as RPC errors rather than silently skipped. It mirrors `getblockfilter` error handling by distinguishing between unindexed blocks while the index is catching up (`RPC_MISC_ERROR`) and unexpected read failures once synced (`RPC_INTERNAL_ERROR`), while adding functional test coverage.
Problem: When the block filter index is behind the active chain or rebuilding, `scanblocks` skipped unreadable filter chunks without throwing an error and still returned `completed: true`. Downstream callers had no way of knowing blocks were omitted from the scan results.
Category: RPC / REST / ZMQ (#2 of 52)
P2 · bug fix
- P2 because it fixes scanblocks silently reporting completion when blocks were skipped
- Prevents wallets and applications from missing transaction matches without warning
Fixes a correctness defect where an RPC returns successful status (`completed: true`) while silently omitting data due to unreadable filter chunks. Callers querying filters during background index syncing would receive false negatives.
Membership: Changes the error reporting and return behavior of the scanblocks RPC in src/rpc/blockchain.cpp
Factors: security/stability 1, bug 2, performance 0, user value 2, leverage 0
Reviewability: Ready
- Ready for review, clean patch with passing CI that incorporates prior reviewer feedback
The patch is small, cleanly rebased, passes CI, and addresses the initial review feedback.
Author status: active, addressed reviewer feedback and force-pushed changes on 2026-08-05
Resolved concerns:
- fjahr noted that getblockfilter does not fail unconditionally when the index is unsynced, only when the requested range is unavailable; author adjusted the implementation to allow scans of already-indexed ranges while the index catches up
Agreement: Strong
- Broad support for eliminating silent scan failures
- Concept approval without stated reasons (maflcko)
- Requested allowing scans on indexed ranges while catching up, which author addressed (fjahr)
Positive: Concept ACK from maflcko; fjahr's concern on handling already-indexed ranges was addressed in an updated push
Reviewers agree the silent skipping of unindexed ranges is a bug. The only criticism regarding error behavior alignment with getblockfilter has been fixed.
- 2026-07-30 maflcko: 'Concept ACK.'
- 2026-07-30 fjahr: 'What this is doing here is different from what getblockfilter does...'
- 2026-08-04 MicSm: 'I updated to match this...'
Objections:
| Reviewer | Kind | Harm | Status | Blocking | Author replied | Quote |
|---|---|---|---|---|---|---|
| fjahr | approach | Failing scans unconditionally when the index is behind tip would break valid scans of already-indexed block ranges | resolved | no | yes | 2026-07-30: 'There we don't fail unconditionally if the index isn't synced. We only fail if the range isn't available.' Settled: 2026-08-04 MicSm: 'You're right - thanks... So, I updated to match this: BlockUntilSyncedToCurrentChain() is only used as an index_ready flag and a failed LookupFilterRange is classified the same way.' |
Support:
- maflcko: Agreed with fixing the silent ignore of LookupFilterRange failures and gave Concept ACK
Participants: maflcko (support), fjahr (objection)
State derived from the lists: substantive support, no open objection (maflcko) (model's own read: Positive)
Review verdicts (DrahtBot): 0
- Concept ACK: maflcko
Files
59 lines under test/bench/ci.
- test/functional/rpc_scanblocks.py +59/-0
- src/rpc/blockchain.cpp +22/-13
Card
PR #35837 fixes a silent data omission bug in the scanblocks RPC. When the block filter index is behind the chain tip or rebuilding, failed filter range lookups were previously ignored while still returning completed: true. The PR updates scanblocks to report an error when a requested range cannot be read, mirroring getblockfilter's error handling. Initial review feedback from fjahr regarding scans of already-indexed prefixes was resolved in a follow-up push, and maflcko gave Concept ACK.