Provider refusals
write_verifier: Provider declined the request because of a cybersecurity restriction. Experiments remain incomplete; static verification can continue.
2 major findings · 3 minor findings · 4 suggestions
Earlier concerns neither republished nor resolved: 1 major finding · 2 minor findings · 5 suggestions. See the Run archive for their assessments.
Findings
[major] · A snapshot write failure can deadlock loadtxoutset
If a batch write fails while more than four batches remain, the reader can block indefinitely and loadtxoutset never returns the stored error.
Location: src/node/utxo_snapshot.cpp:162 (head).
Details and suggested fix
When batch->Flush() throws in SnapshotWriteTask, the writer finishes to_write and to_reuse, but the serializer returns early when to_reuse.Pop(batch) fails without finishing its input queue. The reader continues publishing batches until serialize_queue reaches its four-batch capacity, then blocks in Push. WriteSnapshotCoins joins the reader before finishing that queue, so the reader cannot reach its interrupt check or exit. The RPC consequently never returns the write error, g_snapshot_load_in_progress remains set, and the partial chainstate_snapshot directory is not cleaned up. A mainnet snapshot has thousands of 65,536-coin batches, so a failure partway through will usually leave more than four batches to read. This behavior follows from the code; no failing run was performed. Finish in before the early return, or finish every queue on all serializer exits with a scope guard, and test a write failure with more than four batches remaining.
[major] · Non-seekable snapshot input can terminate the process
bitcoin-util txoutsetsummary aborts when reading piped stdin, and loadtxoutset on a FIFO path terminates bitcoind.
Location: src/utxo_snapshot.h:228 (head).
Details and suggested fix
AutoFile records a position only when FileTell64 succeeds; for pipes and FIFOs, tell() therefore throws std::ios_base::failure. ReadSnapshotBatches calls file.tell() before the first coin and again for each coin, outside ReadSnapshotCoins' error handling. The summary command documents stdin as an input mode. By the time the exception occurs, its stream-hash thread and, by default, its MuHash workers are running; destroying their joinable std::thread objects calls std::terminate. For example, cat utxo.dat | bitcoin-util txoutsetsummary aborts instead of printing a summary. In bitcoind, the reader runs under util::TraceThread, which rethrows, so loadtxoutset with a FIFO path terminates the node. The base loader did not need a file position. Track consumed bytes without tell(), for example by summing each decoded coin's serialized size, and ensure the summary command finishes its queues and joins its workers on exceptional exits. Redirecting stdin from a regular file is seekable and works.
[minor] · The completion marker can become durable before the snapshot database entries
After a power loss, startup could treat an incomplete snapshot database as completed; the window is short and depends on filesystem metadata ordering.
Location: src/node/utxo_snapshot.cpp:319 (head).
Details and suggested fix
With nosync, NoSyncFile::Sync() returns OK without calling the wrapped file's Sync(), so LevelDB's SyncDirIfManifest does not run. The base loader kept that barrier. WriteSnapshotChainstate then calls only DirectoryFilesCommit, which syncs file contents; its comment says DirectoryCommit makes names durable. The chainstate directory is first synced in WriteSnapshotBaseBlockhash, after base_blockhash has been created and committed. On a filesystem that can persist directory updates out of order, a crash in that interval could leave the marker durable while CURRENT, MANIFEST, .ldb or .log entries are not. LoadAssumeutxoChainstate could then treat a broken database as a completed snapshot chainstate. Call DirectoryCommit(chainstate_dir) after DirectoryFilesCommit succeeds and before returning. Journaling filesystems such as ext4 and XFS commit metadata in order in practice, so the real-world risk is probably small; no crash behavior was tested.
[minor] · The block index is synced before block and undo files are flushed
A power loss shortly after snapshot activation can leave the durable index pointing to block data that has not reached disk.
Location: src/validation.cpp:5770 (head).
Details and suggested fix
The snapshot database is built without cs_main, so the active chainstate continues storing blocks and undo data during the load. Those writes are dirty in m_dirty_fileinfo and m_dirty_blockindex but are not fsynced. The new direct m_blockman.WriteBlockIndexDB() writes all dirty entries, not just the snapshot's, with WriteBatchSync. Before this change, its only caller was FlushStateToDisk, which first calls FlushChainstateBlockFile. If power is lost after the synced index write and before the next ordered flush, the index can claim block or undo data that never reached disk, and later reads of those blocks fail. The direct call also bypasses FlushStateToDisk's catch (const std::runtime_error&), which raises FatalError. Since WriteBlockIndexDB erases the dirty sets before writing, a failure here becomes an RPC error and the entries leave dirty tracking. Route this through FlushStateToDisk(state, FlushStateMode::FORCE_SYNC) on the current chainstate after marking the entries, and abort activation if it fails. No block was observed arriving during an actual load; the window lasts until the next ordered flush.
[minor] · Snapshot stdin is read in text mode on Windows
On Windows, redirected snapshot input can be corrupted or cut short before parsing.
Location: src/bitcoin-util.cpp:254 (head).
Details and suggested fix
Named snapshot files are opened with "rb", but the stdin branch wraps the CRT's default stdin. On Windows that stream is in text mode, and nothing in the tree calls _setmode or sets _fmode. Text mode translates CRLF and treats 0x1A as end of file. Redirecting a binary snapshot with < utxo.dat can therefore make parsing fail or produce incorrect hashes. On Windows, call _setmode(_fileno(stdin), _O_BINARY) before wrapping stdin. Passing the file path instead works.
Optional improvements
[suggestion] · Structured fuzz snapshots violate the txid-order check
The new check rejects structured inputs before activation, preventing the fuzz targets from exercising successful loads or the INVALID target's late failure.
Location: src/test/fuzz/utxo_snapshot.cpp:147 (head).
Details and suggested fix
The structured branch writes one group per block's coinbase in g_chain height order, but those txids are not sorted. ReadSnapshotCoins now rejects any txid that is not strictly greater than the previous one, so these inputs fail with "txids are not in key order" before any coin is checked. The old loader accepted this order, and regtest has an assumeutxo entry at height 200 for this fuzz target. The valid target could therefore reach a successful ActivateSnapshot and its later assertions; that branch is now effectively unreachable. For the INVALID target, the appended height-999 coin is reached only if all earlier txids happen to be sorted, so the comment that it is "detected late in the snapshot load" no longer holds. Sort the generated entries by txid before writing, make the INVALID case corrupt a coin within that ordered stream, and keep a separate input for out-of-order data.
[suggestion] · txoutsetsummary lacks test coverage
Without tests, incorrect hashes or crashes in documented input modes could go unnoticed.
Location: src/bitcoin-util.cpp:56 (head).
Details and suggested fix
Nothing in the tree runs bitcoin-util txoutsetsummary. The command reimplements commitment serialization in WriteCoinStatsElement and splits MuHash across per-thread accumulators. Add a functional test that dumps a regtest snapshot with dumptxoutset and summarizes it using a file argument, a real pipe on stdin, and -nomuhash. Compare txouts, total_amount, hash_serialized_3 and muhash against gettxoutsetinfo at the dump height, and include a truncated-file error case. The piped case would have caught the stdin abort.
[suggestion] · The existing-directory error instructs users to delete a directory the node removes
After an interrupted load, the next loadtxoutset can return a misleading instruction even though a plain retry succeeds.
Location: src/node/utxo_snapshot.cpp:299 (head).
Details and suggested fix
WriteSnapshotChainstate refuses an existing chainstate_snapshot directory and says, "Delete it and call loadtxoutset again." Its only on-disk caller, ActivateSnapshot, handles every error from it by calling remove_partial_snapshot_dir(), which deletes that directory. The user is told to delete something that is already gone. An active snapshot is rejected earlier and an invalid one is renamed to _INVALID, so a directory found here is normally leftover from an interrupted load. Either remove the leftover and continue, or return this refusal without the caller's cleanup so the message is accurate.
[suggestion] · measures_waits relies on scheduler timing
A loaded or instrumented CI runner can fail this test even when the queue works correctly.
Location: src/test/util_tests.cpp:2172 (head).
Details and suggested fix
Push records the time between two steady_clock::now() calls around a wait whose predicate is already true. If the thread is descheduled between them, for example under valgrind or TSan, the time can exceed 10ms and fail pushed.total < 10'000. In the other direction, started is set before the consumer enters Pop. If the consumer is descheduled for more than the 50ms sleep, the push arrives first, Pop does not wait, and consumed.total > 0 can fail. Drop both wall-clock assertions and keep the deterministic event counts and the longest <= total check.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Share the coin-commitment serialization helper
- [major]: Propagate staging-directory sync failures
- [minor]: Allow a zero txid as the first snapshot key
- [suggestion]: Exclude non-blocking operations from queue wait-time totals
- [suggestion]: Remove unused standard-library includes
- [minor]: Join workers if pipeline thread startup fails (earlier report)
- [suggestion]: Bound default MuHash worker and queue memory use (earlier report)
- [suggestion]: Test that the persisted chainstate matches the commitment (earlier report)