aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-04-08 11:08:04 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-04-08 11:08:43 +0200
commit24133b177a8555e8d16216d0f848b6707ed60b76 (patch)
tree4d6c81bdd1bad79e49326fbd9a5dd5cd09a2e60c
parent3190785c11f75f165adb841cdadc59e3b1698ab6 (diff)
parent0e7c52dc6cbb8fd881a0dd57a6167a812fe71dc4 (diff)
Merge #12561: Check for block corruption in ConnectBlock()
0e7c52d Shut down if trying to connect a corrupted block (Suhas Daftuar) Pull request description: (Updated OP after reworking the approach) Shut down if a corrupted block is found in ConnectBlock(). This prevents an infinite loop trying to connect such a block, and alerts the node operator that there may be potential hardware failure. Tree-SHA512: f20d56aa9d36d6eeff4c3d13c0fbd14f06a57701bd13c2416d36f0cc4235f81f752139e336a073617e8e803782c5096c960108af122b19a51227de512e9095ee
-rw-r--r--src/validation.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index b68319e235..4a6c4066fc 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1793,8 +1793,15 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
// is enforced in ContextualCheckBlockHeader(); we wouldn't want to
// re-enforce that rule here (at least until we make it impossible for
// GetAdjustedTime() to go backward).
- if (!CheckBlock(block, state, chainparams.GetConsensus(), !fJustCheck, !fJustCheck))
+ if (!CheckBlock(block, state, chainparams.GetConsensus(), !fJustCheck, !fJustCheck)) {
+ if (state.CorruptionPossible()) {
+ // We don't write down blocks to disk if they may have been
+ // corrupted, so this should be impossible unless we're having hardware
+ // problems.
+ return AbortNode(state, "Corrupt block found indicating potential hardware failure; shutting down");
+ }
return error("%s: Consensus::CheckBlock: %s", __func__, FormatStateMessage(state));
+ }
// verify that the view's current state corresponds to the previous block
uint256 hashPrevBlock = pindex->pprev == nullptr ? uint256() : pindex->pprev->GetBlockHash();