Review report

bitcoin/bitcoin: PR #36778

1 major finding · 4 minor findings · 4 suggestions

Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive for their assessments.

Findings

Link

[major] · Genesis-only imports lack a practical header-preparation workflow

Ordinary P2P synchronization can make a receiver ineligible for startup import, while the documented alternative requires externally supplied headers one at a time.

Location: src/init.cpp:1414 (head).

Details and suggested fix

Activation still requires the snapshot base header, but ChainstateMayAdvance rejects any stored post-genesis block, even with an empty ordinary chainstate. Ordinary P2P synchronization starts requesting blocks once the peer's chain reaches minimum chain work, so letting headers synchronize does not reliably preserve import eligibility. Previously, the RPC could import while the ordinary chain still had less work than the snapshot. The documented replacement requires -networkactive=0 and submitheader, which means obtaining and submitting hundreds of thousands of headers for mainnet without a supplied acquisition/import procedure. Do not impose this restriction without a supported preparation workflow, such as a headers-only mode or a header-import helper with a worked procedure. This does not rule out specially orchestrated P2P preparation, but ordinary synchronization is no longer a reliable setup step.


Link

[minor] · A historical startup wallet aborts initialization after import

Autoloading a wallet that needs pre-snapshot history now aborts startup after the snapshot is committed, and restarting without the import option still cannot begin background validation.

Location: src/init.cpp:1548 (head).

Details and suggested fix

A genesis receiver can already have an older wallet configured for autoload, for example after restoring a backup at genesis. If its saved locator and birthday require history below the snapshot base, importing before wallet loading makes AttachChain fail its unavailable-history check. Wallet loading then aborts initialization before initload and networking start. The snapshot remains committed, so removing -loadtxoutset alone repeats the wallet failure and cannot make the error's advice to wait for synchronization succeed. A sufficiently recent birthday avoids this failure. Previously, an already loaded wallet could remain attached through the RPC import; the revised test restores it only afterwards. Document recovery by starting without -loadtxoutset and with -nowallet so background validation can run before retrying wallet loading, and cover this autoload ordering in the functional test.


Link

[minor] · Publishing the snapshot tip bypasses the historical genesis wait

With retained headers and an empty ordinary coins DB, publishing the snapshot tip lets networking start before historical genesis activation; an eligible peer completing its handshake in that window reaches a null dereference.

Location: src/init.cpp:1553 (head).

Details and suggested fix

CompleteChainstateInitialization skips LoadChainTip for an empty ordinary coins DB, a state the load_snapshot helper creates by deleting chainstate. Import assigns that chainstate a historical target without connecting genesis. The new blockTip call satisfies AppInitMain's wait using the snapshot tip, so networking need not wait for initload to connect the historical genesis. If an eligible non-limited peer completes its handshake first, GetHistoricalBlockRange returns a null tip and SendMessages passes it to LastCommonAncestor, which dereferences it. Connect the historical genesis synchronously before publishing the snapshot tip. The window is narrow, and the documented flow with genesis already flushed is unaffected. No documented production workflow producing the empty ordinary coins DB was identified, so production occurrence and practical remote timing remain unconfirmed.


Link

[minor] · loadtxoutset loses its documented RPC deprecation grace period

The replacement immediately breaks existing RPC callers instead of retaining the old behavior behind -deprecatedrpc=loadtxoutset for the documented one-major-release grace period.

Location: src/rpc/blockchain.cpp:3504 (head).

Details and suggested fix

doc/developer-notes.md specifies that removed RPC behavior remains available behind -deprecatedrpc=<feature> for at least one major release. Hiding this method and retaining migration help does not provide that transition: its handler now always throws RPC_METHOD_NOT_FOUND, and migrating callers requires restarting with a specially prepared receiver. Retain a gated runtime path for the grace period, including its mempool/work checks, cache budgeting and service demotion. That maintenance cost is real; if immediate removal is an intended exception instead, explicitly record the exception and migration timeline in the release note.


Link

[minor] · A repeated import option reports the wrong recovery

Leaving -loadtxoutset configured after the import is committed prevents restart, but the fatal message recommends a separate datadir instead of removing the now-unnecessary option.

Location: src/init.cpp:1531 (head).

Details and suggested fix

LoadChainstate first resumes the imported snapshot, after which ChainstateMayAdvance rejects its non-genesis active height. This happens during background validation and after completion if -loadtxoutset remains in the configuration. It also affects retrying the same command when import succeeds but a later initialization step fails. The usage document already says to remove the option after success, but this error only says to use a separate datadir. When an imported snapshot is already present, tell the operator to remove -loadtxoutset and resume that chainstate instead.


Optional improvements

Link

[suggestion] · An unopenable snapshot path reports an internal AutoFile error

A wrong path or permission failure surfaces as AutoFile::read: file handle is nullptr instead of explaining that the snapshot could not be opened.

Location: src/init.cpp:1544 (head).

Details and suggested fix

The loader wraps fopen in an AutoFile and immediately reads metadata without checking the handle. If opening fails, the catch reports the internal null-handle exception with the path, rather than the explicit could-not-open message the RPC provided. Check snapshot_file.IsNull() immediately after opening and return a clear fatal open-failure diagnostic. Tighten test_invalid_file_path to check that diagnostic rather than only the outer Unable to load UTXO snapshot prefix.


Link

[suggestion] · Duplicate snapshot activation is rejected only after population

An accidental second in-memory activation now deserializes and hashes the snapshot before AddChainstate asserts, although the production caller currently prevents this input.

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

Details and suggested fix

Removing the early m_from_snapshot_blockhash check makes a second valid in-memory activation reach assert(prev_chainstate.m_assumeutxo == Assumeutxo::VALIDATED) only after the full population and commitment-hash pass. No current production caller producing a second activation was found: init.cpp is the only production caller and checks receiver eligibility first. Retain the inexpensive duplicate-activation error and its regression test as an internal API safeguard. Genesis and work eligibility can remain the caller's responsibility, avoiding an unconditional genesis assertion that existing non-genesis unit-test fixtures cannot satisfy.


Link

[suggestion] · Startup-import coverage never restores a non-empty mempool

The test only waits for the mempool loaded flag, so it does not detect snapshot-dependent transactions being rejected by a premature mempool load.

Location: test/functional/feature_assumeutxo.py:89 (head).

Details and suggested fix

load_snapshot imports with no seeded persisted transactions and only checks getmempoolinfo()['loaded']; the snapshot-coin spend is submitted later through sendrawtransaction. If mempool loading moved before activation, validation against the genesis chainstate would reject that kind of spend and leave an empty pool. AddChainstate's empty-mempool assertion and the loaded flag could still pass. Before a receiver's first import, seed its mempool.dat with a non-expired spend of a mature, unspent snapshot coin, for example dumped from the producer. After import, assert that exact txid is in getrawmempool before connecting peers.


Link

[suggestion] · The splash screen shows no snapshot-import progress

Qt users see a static loading message throughout deserialization, flushing and hashing, although the loader already computes a coin percentage for the log.

Location: src/init.cpp:1547 (head).

Details and suggested fix

Startup sends one InitMessage before ActivateSnapshot, and the existing million-coin counter reports progress only through LogInfo. The final flush and commitment-hash phases also provide no UI status. Forward throttled coin-percentage updates through GetNotifications().progress() and show a separate status for hashing. The splash's existing ShowProgress path supplies both a percentage and the shutdown hint. Q and window-close shutdown already work, so this is a feedback gap, not an unresponsive GUI. Pass resume_possible=false because an interrupted import is discarded.


Coverage details

Earlier concerns

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