Review report

core: PR #33324

4 minor findings · 1 suggestion

Earlier concerns neither republished nor resolved: 1 major finding · 1 minor finding · 2 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Six-digit block-file numbers are skipped during migration

Files numbered 100000 or higher remain encoded with the old key and become unreadable after key activation; no current deployment with such files was identified.

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

Details and suggested fix

CollectBlockAndUndoFiles accepts only 12-character names, but FlatFileSeq::FileName uses %05u as a minimum width, and file numbers can grow beyond five digits. The scan therefore skips files such as blk100000.dat and rev100000.dat. Migration still activates the new key, so reads of those files fail. A normal restart does not repair them; recovery requires the old key from debug.log or a redownload. With default 128 MiB block files, reaching six-digit numbers takes about 12.8 TB of block data; test-only -fastprune uses 64 KiB files and reaches them sooner. Accept every numeric width the file sequence can produce, or abort before staging the key if an unrecognized blk*.dat or rev*.dat file exists.


Link

[minor] · A resumed migration does not commit its staged key

After a staged-key sync failure or a kill before the sync, a later power loss can leave rewritten files without their key, making block and undo data unreadable.

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

Details and suggested fix

WriteXorKeyFile writes the staged key and calls Commit(), which flushes before syncing the file. If the sync fails, startup aborts with the 8-byte staged file still present; the same state can result from a kill between those operations. On restart, IsValidXorKeyFile checks only the file size, and PrepareDeltaObfuscation reads the staged key without committing it. DirectoryCommit syncs the directory, not the file contents. Migration can then commit rewritten copies and delete originals. If power is lost before the staged key reaches storage, it can return empty or corrupted. A later resume may overwrite it with a different key and activate that key over files rewritten with the lost one. This requires an earlier sync failure, or a kill in that narrow window, followed by a power loss. Commit an existing staged key before migrating any file, and fail startup if that commit fails.


Link

[minor] · Symlinked block files are copied into the blocks directory

When block files are symlinked to another disk, migration copies them onto the blocks-directory filesystem and leaves old-key data at the targets; this layout is not documented as supported.

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

Details and suggested fix

entry.is_regular_file() follows symlinks, so symlinked blkNNNNN.dat and revNNNNN.dat files are selected. MigrateBlockFile writes each staged copy beside the link, inside the blocks directory. Removing the original path deletes only the link, and activation renames the staged copy into place as a regular file. The target retains its old-key data, possibly unobfuscated, while the blocks-directory filesystem must hold the copied files. If that filesystem runs out of space, migration remains pending and startup fails until space is freed. Detect symlinks with symlink_status and fail with a clear error before staging the key.


Link

[minor] · Activation renames unrelated .reobfuscated files

An unrelated regular file with this suffix in the blocks directory is renamed to its stem and may replace an existing file; no other producer of such files was identified.

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

Details and suggested fix

The rewrite step handles only block and undo files, but activation selects every regular file with the .reobfuscated extension except xor.dat.reobfuscated. For example, notes.reobfuscated would be renamed to notes, and fs::rename could replace an existing notes. This matters only if another source places such a file in the blocks directory, so the practical impact is limited. Restrict activation to the block and undo filenames created by this migration.


Optional improvements

Link

[suggestion] · Migration errors omit the underlying filesystem failure

Copy and directory-sync failures report only a path, making it difficult for users to identify the filesystem problem they need to correct before restarting.

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

Details and suggested fix

In MigrateBlockFile, the empty catch (const std::ios_base::failure&) discards the failure. A failed fopen or fwrite, such as ENOSPC or EACCES, is reported only as Error reobfuscating block file <path>. DirectoryCommit similarly combines open, fsync, and close failures into a path-only error, and its caller adds only Failed to commit blocks directory. FileCommit logs the failing operation and SysErrorString(errno). Because startup resumes the staged migration and can fail again, users need enough information to distinguish a full disk from permissions or hardware problems. Capture errno immediately after the failing call, before fclose can overwrite it, and include it and the operation name in the error.


Coverage details

Earlier concerns

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