Review report

core: PR #36543

1 major finding · 4 suggestions

Findings

Link

[major] · Restarts bypass failed or interrupted ordinary commitment verification

The forced flush persists the commitment block before verification, so an ordinary restart can resume above the check after either a fatal mismatch or a normal interruption.

Location: src/validation.cpp:3078 (head).

Details and suggested fix

At the matching block in an ordinary chainstate, view.Flush() advances CoinsTip(), and FORCE_SYNC persists that block as the database's best block before hashing. A mismatch or STATS_FAILED requests shutdown before m_chain.SetTip(), without undoing that write. INTERRUPTED instead lets connection finish. On restart, LoadChainTip() adopts the saved block, and subsequent connections are above the exact-height gate. Startup block verification does not compare the commitment. This also allows the shipped Restart=on-failure service to resume after a mismatch. Persist pending verification before the flush and require successful verification before resuming progress, including after restart. Add disk-backed restart coverage for mismatch and interruption. No production source of a mismatching shipped commitment was found; a normal shutdown during hashing is sufficient to skip completion of this audit.

A mismatch also leaves CoinsTip() ahead of m_chain. If another ActivateBestChain() call reaches its first step before exit, reconnecting the block hits ConnectBlock()'s predecessor/view assertion. Restore cache/tip consistency before permitting another connection attempt. This shutdown race is conditional; its production frequency was not measured.


Optional improvements

Link

[suggestion] · Retired commitments block startup before snapshot cleanup

Replacing the supported commitment prevents ordinary upgrades from reopening older snapshot chainstates, including fully validated ones still awaiting restart-time cleanup.

Location: src/node/blockstorage.cpp:449 (head).

Details and suggested fix

LoadBlockIndex() now rejects an installed snapshot unless its base matches the newest commitment. LoadChainstate() performs that lookup before MaybeValidateSnapshot() and ValidatedSnapshotCleanup(), so finishing background validation under the old binary does not avoid the rejection unless that binary has also been restarted for cleanup. The release process repeats this compatibility break whenever it replaces the commitment. Retain retired commitments for reopening and completing mandatory background validation of installed chainstates, while restricting new imports and the ordinary-IBD audit to the newest commitment. The audit already selects one exact height and block hash, so retaining reload metadata need not add hashing work. If immediate retirement remains intended, document the pre-upgrade procedure of finishing background validation and restarting the old release once, and point the startup error to it. The current release note warns about the refusal but gives no such procedure; rebuilding chainstate is recovery, not a progress-preserving upgrade.


Link

[suggestion] · Alternate-chain test does not assert progress past the commitment height

An early rejection of the alternate block at height 110 could leave this test passing at height 109 because the mining helpers ignore connection failures.

Location: src/test/validation_chainstatemanager_tests.cpp:992 (head).

Details and suggested fix

The fixture starts at height 100. This test changes the height-101 coinbase and attempts ten more blocks, so successful processing should reach height 111. Its only assertion checks that no UTXO scan is logged. CreateAndProcessBlock() discards ProcessNewBlock()'s result, and mineBlocks() does not check progress either. A regression rejecting the nonmatching height-110 block before scanning and before applying its changes could therefore pass. Keep the negative log check and assert final ActiveHeight() == 111, no shutdown request, and exit_status == EXIT_SUCCESS.


Link

[suggestion] · The ordinary commitment audit holds global locks for the full UTXO scan

The new ordinary-IBD audit holds cs_main and the mempool mutex throughout a potentially multi-minute scan, delaying operations that need either lock.

Location: src/validation.cpp:3079 (head).

Details and suggested fix

ActivateBestChain() holds both locks while ConnectTip() calls VerifyAssumeutxoData(). The short lock scope inside ComputeUTXOStats() does not release those enclosing locks. This extends the existing snapshot-validation pause to ordinary IBD and reindexing when they connect the matching commitment block, and to reconnection of that block. Measure the full lock-held pause on representative hardware and document its effect on lock-dependent RPC and P2P work, rather than describing only extra IBD time. Large IBD flushes already cause pauses, so this is a cost to quantify, not established unacceptable latency. Moving hashing off-lock is not a drop-in alternative: it needs database/cursor lifetime coordination across cache resizing and must preserve the requirement not to advance further before verification succeeds.


Link

[suggestion] · The UTXO-hash maintenance warning describes an obsolete IBD fallback

The ApplyHash warning says a hash-format change sends snapshot users back to traditional IBD, but ordinary IBD now requests shutdown on the same commitment mismatch.

Location: src/validation.cpp:3080 (head).

Details and suggested fix

The warning above ApplyHash() in src/kernel/coinstats.cpp still presents traditional IBD as the fallback after changing the hash construction. This PR uses the same HASH_SERIALIZED calculation during ordinary block connection and treats a mismatch as fatal. Changing the construction without updating the compiled commitments would therefore stop ordinary IBD at the matching block too. Update the local maintenance warning to describe this additional dependency and require coordinated commitment updates. The construction remains separate from consensus rules.


Coverage details