Repository navigation
rpc: fail scanblocks instead of silently skipping missing filters - #37016
shivansh023023 wants to merge 1 commit into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. ConflictsReviewers, 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.
2026-11-30 05:45:20 |
|
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. |

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.