Review report

bitcoin/bitcoin: PR #34400

3 minor findings · 2 suggestions

Earlier concerns neither republished nor resolved: 1 major finding · 1 minor finding. See the Run archive for their assessments.

Findings

Link

[minor] · A failed post-top-up filter lookup leaves a stale no-match verdict

If a filter lookup fails during a post-top-up recheck, the parallel rescan can skip a payment to a newly derived script while reporting success.

Location: src/wallet/scan.cpp:312 (head).

Details and suggested fix

After a keypool top-up, UpdateFilter() rechecks undelivered FILTER_NO_MATCH verdicts against the new scripts, but preserves only FILTER_MATCH results. A failed lookup becomes FILTER_NO_FILTER and is discarded, leaving the old verdict, which covered only the previous scripts. NextBlocksParallel() then records that block as skipped. Filter lookups reread disk and can fail on file-open, checksum, or deserialization errors. A payment to a newly derived script can therefore be omitted, and missing its next top-up can also hide later payments beyond the lookahead range. Preserve both match and unavailable-filter results with if (res != FILTER_NO_MATCH) result->second = res;. This restores the existing inspect-block fallback; a later rescan can recover omitted history. No caller or test was found where a lookup succeeds and then fails for the same block, so the transient-read-failure trigger and production impact remain unconfirmed.


Link

[minor] · Skipped-block batches can suppress GUI progress and cancellation

In an even-start, all-nonmatching parallel rescan, two-block progress batching can leave the GUI at 0% and prevent its Cancel button from aborting the scan.

Location: src/wallet/scan.cpp:572 (head).

Details and suggested fix

With -blockfilterindex and -walletpar > 1 outside IBD, Wait() collects one two-block task and Scan() reports only the last skipped height. Without top-ups, windows stay even-sized, so complete tasks starting at an even height report start_height + 2k + 1. None passes UpdateProgress()'s block_height % 100 == 0 gate. A long all-nonmatching range ending on an odd height therefore receives no intermediate GUI updates. WalletView::showProgress() polls wasCanceled() only on those updates, so Cancel does not abort the scan. Matches, top-ups, or a final singleton can permit updates, but do not resolve the skipped-range case. The serial path reports every block. Emit GUI progress when a 100-block boundary has been crossed rather than requiring the reported height to equal that boundary. getwalletinfo progress and RPC abortrescan remain functional.


Link

[minor] · Read-ahead never retries the successor lookup at the old tip

A tip extension during final read-ahead can escape an unlocked parallel rescan and omit a payment whose script is derived by a later queued top-up.

Location: src/wallet/scan.cpp:417 (head).

Details and suggested fix

Suppose read-ahead reaches tip H and clears ctx.next_block, then H+1 connects before an earlier queued historical block is scanned. If H+1's notification runs before that historical block derives the script H+1 pays, the notification misses the payment. StopAtWalletTip() sees the advanced wallet tip, but fill_queue never retries H's successor and HasPendingBlocks() ends the scan when the checker empties. The final mempool request does not revisit confirmed blocks. The base had a one-block race, but looked up each successor immediately before processing its block; read-ahead widens that window to queued blocks and their scan work. This affects unlocked rescanblockchain and importdescriptors scans outside IBD, not AttachChain, which holds cs_wallet. Before ending an unbounded scan with an exhausted cursor, re-query the last read block's successor while preserving the wallet-tip and reorg rules. Another rescan can recover the payment. No concrete occurrence of this tip-extension and top-up ordering was identified, so production impact is unconfirmed.


Optional improvements

Link

[suggestion] · The new rescan option and parallel default lack a release note

The PR introduces -walletpar and enables parallel fast rescans by default on multicore systems, but does not document that change in a release note.

Location: src/wallet/init.cpp:79 (head).

Details and suggested fix

-walletpar=0 resolves to the detected core count, clamped to 1–16 threads including the caller. With a block filter index outside IBD, this makes eligible rescans parallel without a configuration change. The developer notes request a PR-specific release note for new features, configuration changes, and visible user-facing changes. Add a short note describing the automatic default, the cap of 15 dedicated workers plus the caller, -walletpar=1 for serial scanning, and the serial fallback during IBD.


Link

[suggestion] · -walletpar help omits its per-rescan scope

Concurrent rescans on separate wallets each create up to 15 workers, but the help text does not explain that -walletpar is not a process-wide thread budget.

Location: src/wallet/scan.cpp:534 (head).

Details and suggested fix

Scan() creates a private ParallelFilterChecker and starts m_wallet_par - 1 workers for each eligible rescan. Reservations are per wallet, so authenticated RPC users rescanning N wallets concurrently can create up to N × 15 workers outside IBD. “Set the number of wallet threads” leaves that scope unclear. Describe the option as the number of threads used by each wallet rescan, including its calling thread. This preserves current behavior and makes the aggregate cost clear. A shared process-wide budget would require separate scheduling design to preserve per-scan ordering, filter lifetimes, draining, and fairness.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.