mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:44:38 +00:00
rpc: fail scanblocks instead of silently skipping missing filters #37016
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!37016
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/scanblocks-lookup-error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
In
scanblocks(src/rpc/blockchain.cpp), whenBlockFilterIndex::LookupFilterRangereturnsfalse, the chunk loop silently skips the failed range, advancesstart_index, and finishes with"completed": trueandto_heightset tostop_height.This causes silent false negatives in two realistic scenarios:
-blockfilterindex=1on an existing node and runsscanblocks startwhile the index is still catching up. Unindexed chunks are dropped without error, returning an empty or partialrelevant_blockslist marked"completed": true.fltr*.datfile is missing or unreadable,scanblockshides the read failure instead of reporting it (unlikegetblockfilter, which throws an error).Because
scanblocksis used to discover wallet history from descriptors, silently returning"completed": trueon missing filters can mislead callers into concluding no activity exists.Solution
Mirror
getblockfilter's error-handling pattern inscanblocks:index->BlockUntilSyncedToCurrentChain()before acquiringcs_main(preserving the ability to scan already-indexed historical ranges while the index is still catching up).index->LookupFilterRange(...)returnsfalse:RPC_MISC_ERROR("Block filters are still in the process of being indexed.") if the index is not yet synced.RPC_INTERNAL_ERRORindicating a filter read failure / index corruption otherwise.BlockFiltersScanReserveris already RAII-managed, so throwing out of the loop cleanly releases the active scan reservation.Tests
src/test/rpc_tests.cpp—scanblocks_unsynced_index): Registers an unstartedBlockFilterIndex, verifiesscanblocks startthrowsRPC_MISC_ERRORwith the expected message, confirms a second call is not blocked by a stale scan reservation, and checksscanblocks statusreturnsnull.test/functional/rpc_scanblocks.py): Stops the node, movesfltr00000.dat, restarts, verifiesscanblocks startfails with-32603(RPC_INTERNAL_ERROR), verifiesscanblocks statusreturnsNone, then restores the file and confirms the scan succeeds again.masterwithout thesrc/rpc/blockchain.cppchange and pass with the fix.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
LLM Linter (✨ experimental)
Possible places where named args for integral literals may be used (e.g.
func(x, /*named_arg=*/0)in C++, andfunc(x, named_arg=0)in Python):src/test/rpc_tests.cpp:MakeIndex<BlockFilterIndex>(interfaces::MakeChain(m_node), BlockFilterType::BASIC, 1_MiB, /*f_memory=*/true)2026-11-30 05:45:20
🟠 Minor · A new tip can make
scanblocksreport a healthy index as corruptA block arriving between the readiness check and tip selection can make
scanblocksmisreport indexing lag as corruption; production occurrence of this narrow race is unconfirmed.Location:
src/rpc/blockchain.cpp:2656(head).🟠 Minor ·
scanblocksclears abort requests received during the new synchronization waitThe new queue wait widens a pre-existing cancellation race:
scanblocks abortcan returntrueduring the wait, then have its flag cleared before scanning; production occurrence is unconfirmed.Location:
src/rpc/blockchain.cpp:2656(head).🔵 Suggestion · Catch-up coverage omits successful historical scans
The new tests would also accept rejecting every unsynced scan, leaving the intended ability to scan already-indexed historical ranges during catch-up unprotected.
Location:
src/test/rpc_tests.cpp:685(head).🔵 Suggestion · The new
scanblockserrors lack a release notescanblocksnow returnsRPC_MISC_ERRORorRPC_INTERNAL_ERRORfor unavailable filters instead of a result markedcompleted=true, but no release note explains this caller-visible change.Location:
src/rpc/blockchain.cpp:2717(head).Review coverage was incomplete.
Reviewed:
7cfd27f4c6fb· Review report · Previous reportspermalink
Thanks for your submission! The description and code changes match a pattern we sometimes see with PRs that lean heavily on LLM coding assistants. Because the project has such limited human resources for code review, we require code generated by LLMs to be reviewed by the author who submits them first.
It would help to know why you decided to open this PR (did you encounter a bug? find an open issue in repo?), how you reviewed the generated code, what you personally understand about it, how you tested the code before and after the change, etc.
If you don't understand the changes you submitted, we should close this PR. There are many other more helpful ways to contribute to the project, and we look forward to working with you there!
Please also reconsider the value of the PR given how limited our resources are for code review.