From 5e70510c517d56c8eb951a3c97a1dd7c8d791fa7 Mon Sep 17 00:00:00 2001 From: nzsquirrell Date: Sat, 7 Nov 2015 17:36:52 +1300 Subject: [PATCH] fix a bug in CheckBlockHeader that was introduced with the AuxPow changes. We were doing checkpoint checks in CheckBlockHeader, this caused the wallet to flag the blockchain as corrupt if the last checkpoint is within -checkblocks (default is 288) blocks of what is already stored in the local blockchain. The checks are completed in ProcessBlock - this is where it was done in 0.9.2.15 and prior, and bitcoin 0.9.2 upwards does the same. see https://github.com/bitcoin/bitcoin/issues/4246 and resulting commit https://github.com/sipa/bitcoin/commit/7a9e0b6460037b72376af293dc87acafe4fca831 for similar issue found during bitcoin 0.10 development. --- src/main.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ca8747de..a6c1c2fa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2578,28 +2578,6 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, int nH return state.Invalid(error("CheckBlockHeader() : block timestamp too far in the future"), REJECT_INVALID, "time-too-new"); - CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex); - if (pcheckpoint && block.hashPrevBlock != (chainActive.Tip() ? chainActive.Tip()->GetBlockHash() : uint256(0))) - { - // Extra checks to prevent "fill up memory by spamming with bogus blocks" - int64_t deltaTime = block.GetBlockTime() - pcheckpoint->nTime; - if (deltaTime < 0) - { - LogPrintf("CheckBlockHeader(): Height=%d, hash=%s, BlockTime=%d, Checkpoint=%d\n", nHeight, block.GetHash().GetHex().c_str(), block.GetBlockTime(), pcheckpoint->nTime); - return state.DoS(100, error("CheckBlockHeader() : block with timestamp before last checkpoint"), - REJECT_CHECKPOINT, "time-too-old"); - } - CBigNum bnNewBlock; - bnNewBlock.SetCompact(block.nBits); - CBigNum bnRequired; - bnRequired.SetCompact(ComputeMinWork(pcheckpoint->nBits, deltaTime)); - if (bnNewBlock > bnRequired) - { - return state.DoS(100, error("CheckBlockHeader() : block with too little proof-of-work"), - REJECT_INVALID, "bad-diffbits"); - } - } - return true; }