mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
[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.
This commit is contained in:
parent
3b19d8e341
commit
4433ed0f73
1 changed files with 6 additions and 1 deletions
|
@ -2295,7 +2295,7 @@ bool CChainState::DisconnectTip(CValidationState& state, const CChainParams& cha
|
||||||
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
||||||
CBlock& block = *pblock;
|
CBlock& block = *pblock;
|
||||||
if (!ReadBlockFromDisk(block, pindexDelete, chainparams.GetConsensus()))
|
if (!ReadBlockFromDisk(block, pindexDelete, chainparams.GetConsensus()))
|
||||||
return AbortNode(state, "Failed to read block");
|
return error("DisconnectTip(): Failed to read block");
|
||||||
// Apply the block atomically to the chain state.
|
// Apply the block atomically to the chain state.
|
||||||
int64_t nStart = GetTimeMicros();
|
int64_t nStart = GetTimeMicros();
|
||||||
{
|
{
|
||||||
|
@ -2551,6 +2551,11 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
|
||||||
// This is likely a fatal error, but keep the mempool consistent,
|
// This is likely a fatal error, but keep the mempool consistent,
|
||||||
// just in case. Only remove from the mempool in this case.
|
// just in case. Only remove from the mempool in this case.
|
||||||
UpdateMempoolForReorg(disconnectpool, false);
|
UpdateMempoolForReorg(disconnectpool, false);
|
||||||
|
|
||||||
|
// If we're unable to disconnect a block during normal operation,
|
||||||
|
// then that is a failure of our local system -- we should abort
|
||||||
|
// rather than stay on a less work chain.
|
||||||
|
AbortNode(state, "Failed to disconnect block; see debug.log for details");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fBlocksDisconnected = true;
|
fBlocksDisconnected = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue