|
|
|
@ -2469,14 +2469,11 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
@@ -2469,14 +2469,11 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
|
|
|
|
|
return state.DoS(100, error("AcceptBlock() : forked chain older than last checkpoint (height %d)", nHeight)); |
|
|
|
|
|
|
|
|
|
// Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
|
|
|
|
|
if (block.nVersion < 2) |
|
|
|
|
if (block.nVersion < 2 && |
|
|
|
|
CBlockIndex::IsSuperMajority(2, pindexPrev, Params().RejectBlockOutdatedMajority())) |
|
|
|
|
{ |
|
|
|
|
if ((!TestNet() && CBlockIndex::IsSuperMajority(2, pindexPrev, 950, 1000)) || |
|
|
|
|
(TestNet() && CBlockIndex::IsSuperMajority(2, pindexPrev, 75, 100))) |
|
|
|
|
{ |
|
|
|
|
return state.Invalid(error("AcceptBlock() : rejected nVersion=1 block"), |
|
|
|
|
REJECT_OBSOLETE, "bad-version"); |
|
|
|
|
} |
|
|
|
|
return state.Invalid(error("AcceptBlock() : rejected nVersion=1 block"), |
|
|
|
|
REJECT_OBSOLETE, "bad-version"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2517,19 +2514,15 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
@@ -2517,19 +2514,15 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
|
|
|
|
|
if (block.nVersion >= 2) |
|
|
|
|
// if 750 of the last 1,000 blocks are version 2 or greater (51/100 if testnet):
|
|
|
|
|
if (block.nVersion >= 2 && |
|
|
|
|
CBlockIndex::IsSuperMajority(2, pindex->pprev, Params().EnforceBlockUpgradeMajority())) |
|
|
|
|
{ |
|
|
|
|
// if 750 of the last 1,000 blocks are version 2 or greater (51/100 if testnet):
|
|
|
|
|
if ((!TestNet() && CBlockIndex::IsSuperMajority(2, pindex->pprev, 750, 1000)) || |
|
|
|
|
(TestNet() && CBlockIndex::IsSuperMajority(2, pindex->pprev, 51, 100))) |
|
|
|
|
{ |
|
|
|
|
CScript expect = CScript() << nHeight; |
|
|
|
|
if (block.vtx[0].vin[0].scriptSig.size() < expect.size() || |
|
|
|
|
!std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) { |
|
|
|
|
pindex->nStatus |= BLOCK_FAILED_VALID; |
|
|
|
|
return state.DoS(100, error("AcceptBlock() : block height mismatch in coinbase"), |
|
|
|
|
REJECT_INVALID, "bad-cb-height"); |
|
|
|
|
} |
|
|
|
|
CScript expect = CScript() << nHeight; |
|
|
|
|
if (block.vtx[0].vin[0].scriptSig.size() < expect.size() || |
|
|
|
|
!std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) { |
|
|
|
|
pindex->nStatus |= BLOCK_FAILED_VALID; |
|
|
|
|
return state.DoS(100, error("AcceptBlock() : block height mismatch in coinbase"), REJECT_INVALID, "bad-cb-height"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2563,8 +2556,9 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
@@ -2563,8 +2556,9 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool CBlockIndex::IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned int nRequired, unsigned int nToCheck) |
|
|
|
|
bool CBlockIndex::IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned int nRequired) |
|
|
|
|
{ |
|
|
|
|
unsigned int nToCheck = Params().ToCheckBlockUpgradeMajority(); |
|
|
|
|
unsigned int nFound = 0; |
|
|
|
|
for (unsigned int i = 0; i < nToCheck && nFound < nRequired && pstart != NULL; i++) |
|
|
|
|
{ |
|
|
|
|