3 minor findings · 4 suggestions
Earlier concerns neither republished nor resolved: 1 major finding · 1 minor finding · 1 suggestion. See the Run archive for their assessments.
Findings
[minor] · Delta rechecks retain a stale miss when the filter becomes unavailable
If a filter lookup fails during the post-top-up delta recheck, parallel rescan can miss a payment to a newly derived script while reporting success; serial scanning inspects blocks with unavailable filters.
Location: src/wallet/scan.cpp:312 (head).
Details and suggested fix
After a keypool top-up, UpdateFilter() rechecks pending FILTER_NO_MATCH verdicts against the new scripts, but copies back only FILTER_MATCH. Each lookup reads the filter from disk again and can return FILTER_NO_FILTER on an open, checksum or deserialization failure. Discarding that result retains a miss that ruled out only the old scripts, so NextBlocksParallel() skips a potentially relevant block. The range markers have already advanced, so the next iteration does not retry that delta check. AttachChain() can then persist the successful scan position despite the omitted payment. Propagate every result other than FILTER_NO_MATCH, for example if (res != FILTER_NO_MATCH) result->second = res;, to preserve conservative block inspection. A focused test should make the initial lookup succeed and the delta lookup fail. No current caller producing that transition was identified, so production occurrence remains unconfirmed. A later rescan can recover the payment.
[minor] · Batched skips bypass GUI progress updates and cancellation
An even-start parallel rescan through an all-no-match range reports only odd batch-ending heights, suppressing intermediate GUI progress notifications and preventing the Cancel button from aborting the scan.
Location: src/wallet/scan.cpp:572 (head).
Details and suggested fix
With a filter index, -walletpar > 1 and non-IBD status, Wait() normally collects one two-block task. For an all-no-match task, delivery skips both blocks and Scan() reports progress only for the last height. Without top-ups, the even-sized windows preserve task alignment, so an even start never reaches UpdateProgress() with a height divisible by 100. The GUI remains at 0%, and WalletView::showProgress() never polls wasCanceled() to forward an abort. Matches, top-ups or a final partial task can produce a notification, but do not ensure responsiveness throughout long skipped ranges. RPC progress and abortrescan still work. Emit progress when a batch crosses a 100-block boundary, rather than only at an exact multiple, and assert intermediate notifications in an even-start all-no-match parallel test.
[minor] · Stale read-ahead can fail a rescan after a multi-block reorg
If a reorg disconnects queued blocks, parallel delivery can skip a stale no-match and then fail on a later stale match, whereas a serial successor lookup after the reorg would stop successfully.
Location: src/wallet/scan.cpp:437 (head).
Details and suggested fix
Near the scan tip, read-ahead can span a fork and retain two or more blocks that a reorg disconnects before delivery. NextBlocksParallel() records a stale NO_MATCH without checking activeness. If its height is below the wallet tip, delivery continues to later queued stale blocks. A readable stale block that matches, from old-branch wallet activity or a GCS false positive, then reaches ScanBlock() and returns NOT_ACTIVE, making the scan fail. A serial successor lookup performed after that reorg finds no successor for the first stale no-match and ends successfully instead. This can make wallet initialization fail with “Failed to rescan the wallet during initialization”; retrying after the chain stabilizes recovers. The active-chain check prevents stale confirmations. Check activeness when delivering a skipped block and end the scan at the first stale block, discarding the remaining read-ahead. Add a test that reorgs after those blocks have been queued.
Optional improvements
[suggestion] · Automatic rescan concurrency relies on a latched IBD guard
Automatic fast rescans create up to 15 workers per wallet, but the latched IBD guard does not exclude later catch-up or background validation; the resulting contention remains unmeasured.
Location: src/wallet/wallet.cpp:2937 (head).
Details and suggested fix
-walletpar=0 selects the detected core count, capped at 16 threads including the caller, and each eligible scan creates its own pool. The only validation-contention guard checks IBD at scan start. Once that status latches false, it does not cover same-process catch-up after suspend or a network outage, or assumeutxo background validation. Measure block-connect and validation latency during default rescans before choosing this automatic concurrency, or use a conservative automatic cap while retaining explicit overrides. The supplied 20-core benchmark shows essentially identical rescan times at 8 and 16 threads, although that does not establish a universal optimum. -par follows the same automatic convention, idle workers block rather than spin, and -walletpar=1 restores serial behavior. These mitigate the concern but do not measure its foreground cost.
[suggestion] · The parallel fast-rescan default lacks a release note
The new -walletpar option changes eligible fast rescans to automatic parallel execution without a configuration change, but the PR adds no release note.
Location: src/wallet/init.cpp:79 (head).
Details and suggested fix
The default -walletpar=0 resolves to the detected core count, capped at 16 threads including the caller. This is a user-visible configuration and resource-use change covered by the release-note guidance in doc/developer-notes.md. Add a PR-specific release note explaining the option, automatic default and cap, the block-filter requirement, -walletpar=1 for serial scanning, and the serial fallback during IBD.
[suggestion] · The “No behaviour change” refactor includes a resume-after-tip fix
Commit c1b97000 adds a successor re-query and a regression test for a missed-payment race, despite describing the change as behavior-preserving.
Location: src/wallet/scan.cpp:608 (head).
Details and suggested fix
In base, the scan looks up a block's successor before processing that block and exits when the cursor is empty. If the chain extends after that lookup, its notification can miss a payment to a script that the scan derives only while processing the old tip. The new continuation re-queries the successor and finds that payment. scan_for_wallet_transactions_resume_after_tip explicitly constructs this ordering and asserts discovery, so its assertions would fail on base. Describe this fix and its rationale in c1b97000's commit message rather than claiming “No behaviour change”, or split the fix and test into a separate commit. The new production behavior itself is correct.
[suggestion] · -walletpar help advertises 15 threads but accepts 16
The help presents the dedicated-worker limit as the maximum option value, although -walletpar counts the caller and permits 16 total threads.
Location: src/wallet/init.cpp:79 (head).
Details and suggested fix
MAX_WALLETPAR limits dedicated workers to 15, while LoadWalletArgs() clamps the caller-inclusive setting to MAX_WALLETPAR + 1. Thus -walletpar=16 is accepted and the scan log reports “16 threads”, despite help saying “up to 15”. State the maximum as 16 total threads including the caller, or explicitly distinguish the 15-worker limit. -par uses the same ambiguous convention and this implementation deliberately follows it, so keep any clarification consistent between the two options.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [major]: Recheck descriptor ranges before consuming parallel verdicts
- [minor]: Honor abort and shutdown requests between blocks in a scan batch
- [suggestion]: -walletpar help omits its per-rescan scope (earlier report)