Skip to content

Commit 9c5a4a6

Browse files
committed
Stop special-casing phashBlock handling in validation for TBV
1 parent 5d132e8 commit 9c5a4a6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/validation.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,9 +1771,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
17711771
{
17721772
AssertLockHeld(cs_main);
17731773
assert(pindex);
1774-
// pindex->phashBlock can be null if called by CreateNewBlock/TestBlockValidity
1775-
assert((pindex->phashBlock == nullptr) ||
1776-
(*pindex->phashBlock == block.GetHash()));
1774+
assert(*pindex->phashBlock == block.GetHash());
17771775
int64_t nTimeStart = GetTimeMicros();
17781776

17791777
// Check it again in case a previous version let a bad block in
@@ -1847,8 +1845,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
18471845
// Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the
18481846
// two in the chain that violate it. This prevents exploiting the issue against nodes during their
18491847
// initial block download.
1850-
bool fEnforceBIP30 = (!pindex->phashBlock) || // Enforce on CreateNewBlock invocations which don't have a hash.
1851-
!((pindex->nHeight==91842 && pindex->GetBlockHash() == uint256S("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
1848+
bool fEnforceBIP30 = !((pindex->nHeight==91842 && pindex->GetBlockHash() == uint256S("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
18521849
(pindex->nHeight==91880 && pindex->GetBlockHash() == uint256S("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721")));
18531850

18541851
// Once BIP34 activated it was not possible to create new duplicate coinbases and thus other than starting
@@ -3417,9 +3414,11 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams,
34173414
AssertLockHeld(cs_main);
34183415
assert(pindexPrev && pindexPrev == chainActive.Tip());
34193416
CCoinsViewCache viewNew(pcoinsTip.get());
3417+
uint256 block_hash(block.GetHash());
34203418
CBlockIndex indexDummy(block);
34213419
indexDummy.pprev = pindexPrev;
34223420
indexDummy.nHeight = pindexPrev->nHeight + 1;
3421+
indexDummy.phashBlock = &block_hash;
34233422

34243423
// NOTE: CheckBlockHeader is called by CheckBlock
34253424
if (!ContextualCheckBlockHeader(block, state, chainparams, pindexPrev, GetAdjustedTime()))

0 commit comments

Comments
 (0)