Provider refusals
write_verifier: Provider declined the request because of a cybersecurity restriction. Experiments remain incomplete; static verification can continue.
1 major finding · 2 minor findings · 5 suggestions
Findings
[major] · A concurrent flush can truncate a newly written block file
A concurrent forced flush can erase a newly written block yet leave BLOCK_HAVE_DATA set, causing later disk reads to fail; production occurrence is unconfirmed.
Location: src/flatfile.cpp:104 (head).
Details and suggested fix
FindNextBlockPos() publishes the new cursor and unsynced-file entry without creating the file. A concurrent gettxoutsetinfo call can force a flush whose FlatFileSeq::Open() fails its rb+ open, pauses while WriteNewBlock() creates and writes the file, then resumes with the truncating wb+ fallback. The flush does not take prealloc.mutex, and pinning only prevents pruning. UnpinBlockFile() marks the file unsynced again but cannot restore the bytes; FinishAcceptBlock() then records the successful write without rereading it. A later uncached read in ConnectTip() fails fatally, and persisting the entry can require reindexing or redownloading the missing data. Base excluded this overlap by creating and writing under cs_main.
Make writable open-or-create non-truncating, for example with O_CREAT and without O_TRUNC, and add a deterministic interleaving test that checks the stored bytes. The trigger requires the first write to a previously absent file and a local concurrent flusher paused between consecutive opens; no unauthenticated-peer-only trigger was found.
[minor] · Deferred automatic unlinking can cause a premature disk-space shutdown
On a low-disk pruned node with blocks and chainstate sharing a filesystem, deferred deletion can make the dirty-coins space check shut down the node where synchronous deletion previously let it proceed.
Location: src/validation.cpp:3020 (head).
Details and suggested fix
FlushStateToDisk() queues automatic UnlinkPrunedFiles() work and immediately checks for 50 MiB plus 192 bytes per dirty coin. Its earlier blocks-directory check requires only the 50 MiB reserve. If available space lies between those thresholds and the pending deletions would cover the gap, head reports the fatal low-disk error before deletion finishes; base unlinked those same files before checking. Manual pruning still deletes inline. Successful deletion during pool draining makes this conditional failure recoverable on restart. Wait for pending unlinks and retry the space check before treating the shortage as fatal.
[minor] · AllocateChunks() narrows 64-bit undo offsets to 32 bits
At a 4 GiB rev allocation start, AllocateChunks() wraps its offset and can reject sufficient disk space or overwrite undo data; no current or realistic chain reaching this size was identified.
Location: src/flatfile.cpp:97 (head).
Details and suggested fix
FlatFilePos::nPos and CBlockFileInfo::nUndoSize are uint64_t, and FindUndoPos() keeps appending to the undo file associated with block.nFile. However, AllocateChunks() converts from * m_chunk_size to unsigned int. At 4 GiB this becomes zero, so inc_size includes roughly 4 GiB already allocated instead of just the extension. WriteBlockUndo() can consequently report a fatal low-disk error despite sufficient room for the extension. If allocation reaches the Linux zero-writing fallback, it writes from the wrapped offset over existing undo records. Keep the offset at full width and add a boundary test around 4 GiB.
Optional improvements
[suggestion] · Position claims still wait on allocation I/O under cs_main
Although base allocated under cs_main, the new ClaimChunks() still waits on an I/O-held mutex, so overlapping claims can retain that global-lock stall.
Location: src/node/blockstorage.cpp:881 (head).
Details and suggested fix
ClaimChunks() unconditionally takes prealloc.mutex while holding cs_main, including when the file already has an entry. Preallocate() holds that same sequence-wide mutex through CheckDiskSpace(), opening, allocation and closing. An allocation can therefore block claims for other files, including the other assumeutxo cursor, despite the arithmetic-only claim described in validation.h. Give writers stable per-file allocation records initialized under cs_main, then serialize allocation with a writer-only lock that claims never acquire. Preserve the shared high-water mark so allocation cannot cover bytes already written. The latency benefit is unmeasured.
[suggestion] · Pin, cursor and deferred-trim guards lack targeted unit coverage
The new unit tests check durability flags and an unpinned file switch, but do not distinguish the pin/cursor pruning exclusions or deferred trimming.
Location: src/node/blockstorage.cpp:1024 (head).
Details and suggested fix
write_off_the_lock_marks_the_file_again only checks durability bookkeeping. LeftBlockFileSetup completes each WriteBlock() before claiming the next, so it exercises immediate trimming without a pin. Add a deterministic case starting with an allocated file, pin a pending claim, advance the cursor, and check that the preallocated tail remains until the last UnpinBlockFile() and is then trimmed to nSize. Separately, make a non-cursor file otherwise eligible for pruning and verify that both prune finders skip it only while pinned. Also test an otherwise eligible lower-numbered cursor file with a snapshot cursor present. Enable prune mode and satisfy GetPruneRange()'s trailing-block window, plus the automatic finder's height and usage thresholds, so another guard does not make the assertions pass.
[suggestion] · The invalidation and second-copy results lack deterministic assertions
processnewblock_signals_ordering ignores new_block and rejection state, leaving the new duplicate and FailedMeanwhile() results without deterministic assertions.
Location: src/validation.cpp:4794 (head).
Details and suggested fix
Drive the public stages directly: call AcceptNewBlock(), invalidate the parent, then call WriteNewBlock() and FinishNewBlock(). Assert failure with BLOCK_CACHED_INVALID and duplicate-invalid, in.new_block == false, and no BLOCK_HAVE_DATA. In a separate case, accept a second copy before finishing the first and assert that the second has prepared.store == false and new_block == false. Use the header/check/storage helpers to invalidate the parent before the storage hold as well, then assert that no position is claimed. These checks distinguish the new result and publication rules from the existing test's signal-ordering invariant.
[suggestion] · Storage tests do not verify preallocation with reversed writes
Direct block-storage tests write in claim order and do not verify byte preservation when a later claimed position is written first.
Location: src/node/blockstorage.cpp:894 (head).
Details and suggested fix
Claim distinct readable records across a preallocation chunk boundary in one file, write the later record first, then write the earlier records. Check every record byte-for-byte and assert that the file never shrinks. This exercises Preallocate()'s monotonic high-water mark, unlike the existing Allocate() boundary tests. Reverting to per-position allocation can truncate the later record through macOS ftruncate() or Windows SetEndOfFile(), or overwrite it through the zero-writing fallback. Successful native Linux posix_fallocate() preserves existing bytes and need not change the file size, so that backend alone would not distinguish every such regression. No sleeps or concurrent threads are needed.
[suggestion] · FlushBlockFile() retains unused finalization modes
FlushBlockFile() now has one caller that always passes both flags as false, so retaining finalization modes adds unused branches to the durability path.
Location: src/node/blockstorage.cpp:972 (base).
Details and suggested fix
Replacing the file-switch flush with trimming removes the only caller that used finalization. Drop fFinalize and finalize_undo from this private helper, always flush the block file without finalization, and unconditionally flush undo without finalization. Keep the empty m_blockfile_info guard. Also keep FlushUndoFile()'s separate finalization parameter, since WriteBlockUndo() still passes true. This removes unnecessary mode selection from the remaining call without changing its behavior.