Skip to content

Commit 4433ed0

Browse files
committed
[validation] Crash if disconnecting a block fails
If we're unable to disconnect a block during normal operation, then that is a failure of our local system (such as disk failure) or the chain that we are on (eg CVE-2018-17144), but cannot be due to failure of the (more work) chain that we're trying to validate. We should abort rather than stay on a less work chain.
1 parent 3b19d8e commit 4433ed0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/validation.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2295,7 +2295,7 @@ bool CChainState::DisconnectTip(CValidationState& state, const CChainParams& cha
22952295
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
22962296
CBlock& block = *pblock;
22972297
if (!ReadBlockFromDisk(block, pindexDelete, chainparams.GetConsensus()))
2298-
return AbortNode(state, "Failed to read block");
2298+
return error("DisconnectTip(): Failed to read block");
22992299
// Apply the block atomically to the chain state.
23002300
int64_t nStart = GetTimeMicros();
23012301
{
@@ -2551,6 +2551,11 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
25512551
// This is likely a fatal error, but keep the mempool consistent,
25522552
// just in case. Only remove from the mempool in this case.
25532553
UpdateMempoolForReorg(disconnectpool, false);
2554+
2555+
// If we're unable to disconnect a block during normal operation,
2556+
// then that is a failure of our local system -- we should abort
2557+
// rather than stay on a less work chain.
2558+
AbortNode(state, "Failed to disconnect block; see debug.log for details");
25542559
return false;
25552560
}
25562561
fBlocksDisconnected = true;

0 commit comments

Comments
 (0)