Review report

bitcoin/bitcoin: PR #36621

2 suggestions

Optional improvements

Link

[suggestion] · Batch pruning test misses an unselected file inside the selected range

The batch test leaves only a higher-numbered file unselected, so it would miss a regression that pruned every populated file up to the largest selected number.

Location: src/test/blockmanager_tests.cpp:151 (head).

Details and suggested fix

PruneBlockFiles({file0, file1}) selects a contiguous prefix, with file2 above both selections. Changing only the block-index membership predicate to nFile <= *setFilesToPrune.rbegin() would still satisfy the batch test's assertions. Production height filters can skip populated files, including interleaved NORMAL and ASSUMED files during assumeutxo validation, so callers need exact membership. Reuse the three-file fixture to prune {file0, file2} instead. Assert that tip1 retains both storage flags, its file number and data/undo positions, a nonzero file-info size, and no dirty entry. Update the later survivor checks to use tip1/file1, including {file1, file2 + 1} for the mixed out-of-range case. The bitmap accepts the maximum file number, so this requires no additional blocks.


Link

[suggestion] · The status guard's file-zero rationale is undocumented

The new guard avoids redundant writes when pruning file 0, but only the tests and commit message explain why data-less entries must be skipped.

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

Details and suggested fix

CBlockIndex::nFile defaults to 0 and pruning resets it to 0, while CDiskBlockIndex serializes it only when BLOCK_HAVE_DATA or BLOCK_HAVE_UNDO is set. Without the guard, selecting file 0 would also mark header-only and already-pruned entries dirty, restoring the base code's redundant block-index writes. Add a short comment above the unchanged condition explaining that nFile is meaningful only when block or undo data is present, so data-less entries must not be treated as belonging to file 0.


Coverage details