1 minor finding · 5 suggestions
Findings
[minor] · Index catch-up can be misreported as corruption
If indexing catches up between a failed range lookup and GetSummary(), scanblocks can return -32603 for a healthy index instead of the retryable indexing error.
Location: src/rpc/blockchain.cpp:2725 (head).
Details and suggested fix
During an initial build or rebuild, BlockUntilSyncedToCurrentChain() returns false without waiting. LookupRange() can then miss an unwritten height in its fixed iterator view. If the indexing thread finishes and publishes a covering tip with synced=true before GetSummary(), the ancestry check passes and the RPC reports index corruption. The same ordering is possible when assumeutxo background validation advances the indexed tip through BlockConnected(). The scan still fails rather than returning an incomplete result, but a client that retries only -1 may stop unnecessarily even though another scan could succeed without repair. Take the summary before each lookup and classify failures using that earlier state, retaining the ancestry check for assumeutxo. This interleaving depends on scheduling; no concrete occurrence was observed, and its frequency is unmeasured.
Optional improvements
[suggestion] · Unavailable suffixes are detected only after scanning covered chunks
During an index rebuild or assumeutxo background validation, a scan can process many covered chunks before discovering an unavailable suffix and discarding its results.
Location: src/rpc/blockchain.cpp:2724 (head).
Details and suggested fix
If the requested endpoint remains beyond the indexed range, the loop reads and matches each complete covered chunk of up to 10,001 filters before throwing on the first uncovered chunk. With filter_false_positives=true, each hit also causes block and undo reads. The accumulated results are discarded, and the single scan reservation remains held until the error exits the call. Consider an endpoint-only LookupFilterHashRange(stop_block->nHeight, stop_block, hashes) preflight, classifying a missing endpoint before matching and keeping the per-chunk checks as a backstop. This still allows scans over already-written prefixes while the index builds. The tradeoff is earlier rejection of some scans whose suffix would become available during matching. Whether that is preferable depends on long rebuilds versus short catch-ups; scan durations have not been measured.
[suggestion] · Prefix and catch-up scans lack known-match assertions
The snapshot-node test checks only metadata for its successful prefix scan and never rescans that node after catch-up, leaving matching and successful retry unverified.
Location: test/functional/rpc_scanblocks.py:61 (head).
Details and suggested fix
The prefix scan uses a fresh destination with no expected matches and asserts only to_height and completed. Returning a successful empty result without scanning that prefix would satisfy those assertions. sync_all() already waits for node2's index to reach its tip, but the later positive-match tests run on node0. Use wallet.get_descriptor() for the prefix scan and assert a known cached MiniWallet block, such as height 76, appears in relevant_blocks. Also retain a block hash containing one of the existing self-transfers above START_HEIGHT, rescan node2 after sync_all(), and assert that hash is returned. These checks reuse existing blocks without changing the snapshot.
[suggestion] · The new tests never exercise an unsynced index
Both added fixtures run with synced=true, leaving readable-prefix and unavailable-range behavior during an actual index rebuild untested.
Location: test/functional/rpc_scanblocks.py:57 (head).
Details and suggested fix
The assumeutxo fixture explicitly asserts synced=true, and the deleted-file fixture restarts with its index database intact and waits for index synchronization. Neither exercises the !summary.synced case. An implementation that rejected every scan while unsynced would therefore pass these tests despite preventing scans over already-written prefixes during rebuilds. Add deterministic RPC coverage by persisting an index prefix, stopping the index, extending the chain, and reopening it with Init() without starting background synchronization. Assert that scanning the written prefix succeeds and scanning the uncovered suffix returns -1. Keep the assumeutxo fixture because it covers the separate synced-but-behind state.
[suggestion] · The new scanblocks failure behavior has no release note
For unavailable filter ranges, scanblocks now raises -1 or -32603 instead of potentially returning completed=true, but no release note explains the changed RPC behavior or earlier missing matches.
Location: src/rpc/blockchain.cpp:2729 (head).
Details and suggested fix
Failed range lookups previously advanced the scan without adding matches, so an unaborted call could return completed=true despite gaps. The new errors are visible to RPC callers and fall within the release-note guidance in doc/developer-notes.md. Add a PR-specific note describing the -1 indexing error and -32603 read-failure error, advising callers to retry -1 after index catch-up, and warning that scans made during index rebuilds on older versions may have silently missed matches and should be repeated.
[suggestion] · The PR description disagrees with the implemented checks and tests
The description specifies an index_ready flag and a wipe-and-restart test, while the commit uses summary-plus-ancestry classification and tests assumeutxo and a deleted filter file.
Location: src/rpc/blockchain.cpp:2708 (head).
Details and suggested fix
The implementation discards BlockUntilSyncedToCurrentChain()'s return value and classifies lookup failures using GetSummary().synced plus endpoint ancestry. That distinction matters because the index follows the validated chainstate: in the snapshot fixture, the wait returns true at background height 199 while the active tip is 299. Using only that flag as described would label the unavailable suffix as corruption, whereas the ancestry check selects -1. The description also names a nonexistent test_scanblocks_unindexed_range with index deletion, a genesis-only prefix scan, and a post-sync match assertion. Update it to explain the actual classification and describe test_unindexed_range and test_unreadable_range, matching the commit message.