1 minor finding · 4 suggestions
Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive for their assessments.
Findings
[minor] · ActivateBestChainStep discards the specific flush failure
A local flush failure during a reorg disconnect now returns Failed to disconnect block. instead of its specific cause, including in RPC errors, while fatal notifications and shutdown behavior remain unchanged.
Location: src/validation.cpp:3303 (head).
Details and suggested fix
When DisconnectTip fails in FlushStateToDisk(FlushStateMode::IF_NEEDED), state already carries an Error such as Disk space is too low!. The unconditional state = FatalError(...) here replaces that cause with the generic disconnect message. Previously, FatalError called state.Error(), which preserved an existing error reason. RPC callers such as preciousblock and reconsiderblock report state.ToString(), so they now lose that detail even though the original notification still fires. Call FatalError for its notification, but assign its returned state only when state.IsValid(). This preserves the flush error while still supplying an error for the other disconnect failures.
Optional improvements
[suggestion] · Corrupt-block Error states discard the original diagnosis
Corrupt stored blocks now reach BlockChecked with BLOCK_RESULT_UNSET rather than BLOCK_MUTATED; shutdown is unchanged, and practical impact is unconfirmed because no external consumer reading Error-mode results was identified.
Location: src/validation.cpp:2399 (head).
Details and suggested fix
Previously, this branch upgraded the existing invalid state through Error(), preserving BLOCK_MUTATED, the rejection reason such as bad-txnmrklroot, and its debug message. Assigning the fresh state returned by FatalError instead clears the result and debug message and substitutes the generic hardware-failure reason. The new log retains the original diagnosis, but the state forwarded by ConnectTip to BlockChecked no longer does. Kernel callbacks can observe the result change through btck_block_validation_state_get_block_validation_result. Preserve the existing payload by sending the fatal notification and then calling Error() on the existing state rather than replacing it. That keeps both the diagnostic information and the required fatal disposition.
[suggestion] · Stored-block corruption lacks a mode-specific regression test
The refactored branch correctly returns Error, but existing connect_block fuzzing disables its merkle check and only compares success with IsValid(), so it cannot protect the corruption disposition.
Location: src/validation.cpp:2399 (head).
Details and suggested fix
In src/test/fuzz/connect_block.cpp, fJustCheck=true disables the merkle check needed to reach this branch. Its connected == state.IsValid() assertion would also accept either Invalid or Error on failure. That distinction matters: ConnectTip calls InvalidBlockFound for Invalid, and activation resets that state and continues invalid-chain handling rather than taking the system-error exit. Add a deterministic unit test using an unchanged valid header, a matching block index and altered transaction data. Deserialize into a fresh block so validation-cache flags are unset, then call ConnectBlock with fJustCheck=false. Assert a false return, IsError(), the fatal notification, the original merkle reason in the log, and the intended returned metadata. This branch exits before checking the view's best block or modifying coins, so it needs no reorg fixture.
[suggestion] · TestBlockValidity describes normal rejection as unexpected
The remaining comment labels ordinary CheckBlock rejection as unexpected, although proposal-mode validation accepts external blocks that may fail this check.
Location: src/validation.cpp:4603 (head).
Details and suggested fix
The comment originally explained if (state.IsValid()) NONFATAL_UNREACHABLE() after a false return from CheckBlock: the unexpected case was failure paired with a valid state. Returning the state by value removes that possible mismatch, and this PR removes the consistency check. The comment now sits above ordinary propagation of a non-valid result, which is normal for callers such as getblocktemplate proposal mode. Delete the two comment lines along with the removed check.
[suggestion] · c9d80b7 describes a C-API change its patch does not make
The message for c9d80b7 claims a C-API return-type change, but its parent already returns btck_BlockValidationState*; the patch only simplifies the implementation.
Location: src/kernel/bitcoinkernel.cpp:1620 at c9d80b718916 (commit) (commit).
Details and suggested fix
Commit c9d80b718916702817b8dd19999c963d964fe31a (Change ProcessNewBlockHeaders) says it removes an int return and validation-state output parameter from btck_chainstate_manager_process_block_header. Its direct parent, 54304b438857b2b34c42b34e4adf0cb99f62a0e1, already returns btck_BlockValidationState* and takes only the chainstate manager and header. The patch removes the internal bool result and its consistency assertion, then constructs the returned wrapper from the by-value ProcessNewBlockHeaders result. Reword that paragraph to describe this internal simplification so readers do not look for a public C-API change that is absent.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Keep factory definitions out of the widely included validation header
- [suggestion]: Commit message inaccurately describes a kernel C API change (earlier report)
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Documented decisions
Corruption discovered while connecting an already-stored block is a reason to stop for operator investigation, rather than repeatedly retry chain activation. In 2018, Wladimir van der Laan reported a transaction bit flip in a block file that caused an endless merkle-root failure loop, consumed 100% CPU, and made no progress. He argued that giving up was preferable to continuing under suspected software or hardware failure, and valued detecting the corruption early.
This explains the purpose of ConnectBlock's BLOCK_MUTATED-to-Error transition: a failure that ordinarily describes an invalid block payload becomes a fatal local-system condition once encountered in data that should already have passed storage checks. The pinned base explicitly says potentially corrupted blocks are not written to disk and invokes FatalError on this path.
Ralph's inferences
The transition carries two distinct kinds of information: Error controls recovery behavior, while the existing rejection metadata describes the corruption. In the base implementation, calling Error() on an Invalid state changes only its mode; it preserves GetResult(), GetRejectReason(), and GetDebugMessage(). On this path, the result therefore remains BLOCK_MUTATED, and ToString() still exposes the original rejection reason and debug detail.
These three metadata fields are the observable compatibility baseline when FatalError begins constructing a fresh state. A fresh MakeError(message) instead starts with BLOCK_RESULT_UNSET, uses the fatal message as its rejection reason, and has no debug message. Preserving the fatal disposition and preserving the earlier diagnostic payload are separate concerns; the inspected evidence does not establish that exact field preservation is a protocol requirement.
Callers rely on Error not being treated as ordinary Invalid. ConnectTip invokes InvalidBlockFound only for IsInvalid(). ActivateBestChainStep resets an Invalid state and continues its invalid-chain handling, whereas a system-error return updates the mempool for the current tip and exits unsuccessfully.
The essential control-flow expectation is that stored-block corruption leaves ConnectBlock with a false return and an Error state, not merely an Invalid state carrying BLOCK_MUTATED. This directs activation away from the recoverable invalid-block branch and toward the local-system failure path, consistent with the historical reason for stopping.
The earlier corruption diagnosis is observable outside ConnectBlock: ConnectTip passes the resulting state to BlockChecked and includes state.ToString() in its failure log. Retaining a diagnostic in a log is distinct from retaining it in the returned validation-state fields.
The pinned head logs the original CheckBlock state before replacing it with FatalError's fresh Error state. That preserves the original reason and debug detail in that log entry, while the state subsequently delivered to ConnectTip and BlockChecked has the freshly constructed error payload. Historical evidence supports keeping corruption diagnosable, but the inspected record does not establish which subscribers require the original metadata fields.