Review report

core: PR #34400

Provider refusals

write_verifier: Provider declined the request because of a cybersecurity restriction. Experiments remain incomplete; static verification can continue.

4 minor findings · 2 suggestions

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

Findings

Link

[minor] · Rescan cancellation waits for the current batch to finish

In the parallel path, abortrescan or shutdown can wait for up to 1,000 more full block reads and wallet syncs.

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

Details and suggested fix

ReadAndFilterNextBlocks() stops collecting blocks when m_abort or shutdownRequested() is set, but returns blocks it has already collected. The scan loop then reads and syncs every block in that batch without checking either flag, so cancellation can be delayed by up to 1,000 full block reads and SyncTransaction passes, and those blocks are still added to the wallet after the request. The final status remains USER_ABORT. The serial path checks both flags before each block. Check m_abort || chain.shutdownRequested() at the top of each loop iteration and break when either is set. Only the parallel path is affected because the serial path returns one block per batch.


Link

[minor] · Parallel rescans can miss payments to scripts added during a no-match run

A concurrent keypool top-up during an unlocked rescan can cause later blocks in the same no-match run to skip payments to newly derived scripts; production frequency is unconfirmed.

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

Details and suggested fix

The parallel path checks NeedsUpdate() only when ReadAndFilterNextBlocks() begins. It can then consume FILTER_NO_MATCH verdicts computed against the earlier script set and record those blocks as scanned. During an unlocked rescanblockchain or importdescriptors scan, another thread can extend a descriptor range, for example through MarkUnusedAddresses() or getnewaddress. Blocks consumed after that top-up are not checked against the new scripts, so a historical payment to one of them can be skipped while the rescan reports success. The base path called UpdateIfNeeded() before every block. Check NeedsUpdate() before committing each FILTER_NO_MATCH verdict and, when it returns true, call FinishChecks() and ApplyDelta(). AttachChain holds cs_wallet and is not affected. A miss requires both a concurrent top-up and on-chain payments to newly derived scripts within the same no-match run, so production frequency is unconfirmed.


Link

[minor] · A failed filter lookup during verdict patching preserves a no-match result

If rechecking a block against newly derived scripts fails, the block is skipped rather than scanned; no current path causing this production impact was identified.

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

Details and suggested fix

A FILTER_NO_MATCH verdict applies only to the earlier script set. After a top-up, ApplyDelta() rechecks the filter against newly derived scripts, but converts a failed lookup (nullopt) to false with value_or(false). The verdict therefore remains FILTER_NO_MATCH, and the block is skipped. The same issue affects the carried verdict. By contrast, the initial check maps nullopt to FILTER_NO_FILTER, and the base path fetched the block when the filter was unavailable after UpdateIfNeeded(). blockFilterMatchesAny() returns nullopt when the index is unavailable or LookupFilter() fails, including when the filter file cannot be opened or read. If a lookup fails between the initial check and the delta check, a block paying a newly derived wallet script can be skipped while the rescan reports success. Map nullopt to FILTER_NO_FILTER in both patch paths. No current path was identified where a lookup fails after an earlier successful lookup for the same block, so production impact is unconfirmed.


Link

[minor] · Skipped blocks can carry a scan past the wallet tip

If the wallet-tip block is skipped while the chain has advanced, the scan can record a height above the wallet's processed tip; this requires blocks to connect during the scan, and no specific occurrence was identified.

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

Details and suggested fix

The base path checked block_height >= GetLastBlockHeight() after every block, including filter-skipped blocks. The new check runs only for blocks returned for scanning; when a batch is empty, the scan updates progress and continues if ctx.next_block is set. Both serial and parallel paths are affected. If the block at the wallet's last processed height is skipped while the active chain is already longer, the scan can follow the chain beyond the wallet tip. In AttachChain, blocks connected during the rescan remain pending as notifications, so SetLastBlockProcessed() can record a height above its snapshot tip before those notifications replay. Until they catch up, transactions scanned above the wallet tip have zero or negative depth, and rescanblockchain can report a stop_height above the wallet's processed tip. Check GetLastBlockHeight() when recording a skipped block and end the scan once that height is reached. This requires blocks to connect while the scan runs; no specific production occurrence was identified.


Optional improvements

Link

[suggestion] · The new -walletpar option and default are undocumented in release notes

Fast rescans become multi-threaded by default, but users are not told about the behavior change or how to tune it.

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

Details and suggested fix

-walletpar is a new wallet startup option. Its default, 0, resolves to the detected core count, capped at 8, so eligible fast rescans become multi-threaded without a configuration change. The developer notes call for a PR-specific release note for notable features, configuration changes, and visible user-facing changes, but none is added here. Add a short note describing the option, its default, and -walletpar=1 for retaining single-threaded behavior.


Link

[suggestion] · A mocked clock can prevent parallel rescan work from being submitted

Production steady_clock avoids this condition, but the parallel save-progress path cannot use the repository's mocked-clock pattern, which would cause it to hang.

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

Details and suggested fix

CanSubmit() checks the reserver clock through IsNextInterval() on every call, while current_time is reset only by update_progress after ReadAndFilterNextBlocks() returns. If the clock advances by at least INTERVAL_TIME between that reset and the next CanSubmit() call, no work is submitted. The helper fills the queue, returns an empty batch when Pending() is zero, and the outer loop continues because the checker is not empty. With steady_clock in production, this does not happen. However, the existing rescan tests mock time with setNow([&] { fake_time += 60s; ... }); using that pattern with a filter index and m_wallet_par > 1 would hang rather than fail. The parallel path's interval pause and progress saving currently have no test using that pattern. Latch the pause when the interval elapses, then clear it after the scan loop logs and saves, or guarantee at least one Submit() per call.


Coverage details

Earlier concerns

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