Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
tACK b4b9570 Built PR head Also ran a mutation check by restoring the pre-fix Case 2 (
|
Thanks for checking, that's true, known. The Valid-state path (DisconnectBlock failure) is exercised by |
Add a unit test for the case when a mutated block is encountered in ConnectBlock, to document the exact return state and reject reason.
In order to avoid confusing partial override of error state, log the old state and override it in ConnectBlock(). When CheckBlock() returns an Invalid state due to a mutated block, the error is upgraded to Error state. A new log entry prints the Invalid state, then it is overridden to an Error state. The behavior change is that the reject reason was previously kept, now it is overwritten, and result and debug messages are reset.
In order to avoid confusing partial override of error state, don't overwrite the error in ActivateBestChainStep(). When DisconnectTip() returns an error state, the fatal error has already been reported (by FlushStateToDisk()). Log it and return, without reporting a second, less specific fatal error. Behavior change: the duplicate fatalError notification is no longer emitted in this case.
b4b9570 to
225057d
Compare
|
Non-contentious rebase (due to #36109), no other changes. ( |
225057d to
becd5c2
Compare

ValidationState::Error() only sets the reject reason if the state is still valid. When it is called on a state that is already Invalid or Error, the mode changes but the earlier reason, result and debug message are kept. The result is a mix of the old and new error. Code review in #35570 found two places where this happens. This makes the in-and-out use of the state parameter harder to follow and to remove later.
This PR makes both cases explicit:
ConnectBlock()→CheckBlock()with a mutated block (BLOCK_MUTATED, e.g. a merkle root mismatch). This is treated as a sign of corruption and reported throughFatalError(), but the resulting Error state keptBLOCK_MUTATED/bad-txnmrklroot. Now the Invalid state is logged and then replaced, so the Error state carries the corruption message.ActivateBestChainStep()→DisconnectTip()→FlushStateToDisk()failure.FlushStateToDisk()has already reported a fatal error, andActivateBestChainStep()then calledFatalError()a second time with a less specific message. Now the existing error is logged and returned unchanged, and no second fatal error is reported.Behavior changes:
The first commit adds a unit test for case 1 that captures the current behavior, and the second commit updates its expectations. Case 2 has no test, because a flush failure cannot be triggered without fault injection. The path where
DisconnectTip()fails while the state is still valid is covered byfeature_abortnode.pyand is unchanged.