Skip to content

Commit 54e8bfe

Browse files
committed
Merge pull request #6931
33c90cf Make skipping BIP30 check chain agnostic (Alex Morcos) 06d81ad Skip BIP30 check after BIP34 activation (Alex Morcos)
2 parents 5fcc14e + 33c90cf commit 54e8bfe

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/chainparams.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class CMainParams : public CChainParams {
7373
consensus.nMajorityEnforceBlockUpgrade = 750;
7474
consensus.nMajorityRejectBlockOutdated = 950;
7575
consensus.nMajorityWindow = 1000;
76+
consensus.BIP34Height = 227931;
77+
consensus.BIP34Hash = uint256S("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
7678
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
7779
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
7880
consensus.nPowTargetSpacing = 10 * 60;
@@ -153,6 +155,8 @@ class CTestNetParams : public CChainParams {
153155
consensus.nMajorityEnforceBlockUpgrade = 51;
154156
consensus.nMajorityRejectBlockOutdated = 75;
155157
consensus.nMajorityWindow = 100;
158+
consensus.BIP34Height = 21111;
159+
consensus.BIP34Hash = uint256S("0x0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8");
156160
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
157161
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
158162
consensus.nPowTargetSpacing = 10 * 60;
@@ -216,6 +220,8 @@ class CRegTestParams : public CChainParams {
216220
consensus.nMajorityEnforceBlockUpgrade = 750;
217221
consensus.nMajorityRejectBlockOutdated = 950;
218222
consensus.nMajorityWindow = 1000;
223+
consensus.BIP34Height = -1; // BIP34 has not necessarily activated on regtest
224+
consensus.BIP34Hash = uint256();
219225
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
220226
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
221227
consensus.nPowTargetSpacing = 10 * 60;

src/consensus/params.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ struct Params {
1919
int nMajorityEnforceBlockUpgrade;
2020
int nMajorityRejectBlockOutdated;
2121
int nMajorityWindow;
22+
/** Block height and hash at which BIP34 becomes active */
23+
int BIP34Height;
24+
uint256 BIP34Hash;
2225
/** Proof of work parameters */
2326
uint256 powLimit;
2427
bool fPowAllowMinDifficultyBlocks;

src/main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
17691769
bool fEnforceBIP30 = (!pindex->phashBlock) || // Enforce on CreateNewBlock invocations which don't have a hash.
17701770
!((pindex->nHeight==91842 && pindex->GetBlockHash() == uint256S("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
17711771
(pindex->nHeight==91880 && pindex->GetBlockHash() == uint256S("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721")));
1772+
1773+
// Once BIP34 activated it was not possible to create new duplicate coinbases and thus other than starting
1774+
// with the 2 existing duplicate coinbase pairs, not possible to create overwriting txs. But by the
1775+
// time BIP34 activated, in each of the existing pairs the duplicate coinbase had overwritten the first
1776+
// before the first had been spent. Since those coinbases are sufficiently buried its no longer possible to create further
1777+
// duplicate transactions descending from the known pairs either.
1778+
// If we're on the known chain at height greater than where BIP34 activated, we can save the db accesses needed for the BIP30 check.
1779+
CBlockIndex *pindexBIP34height = pindex->pprev->GetAncestor(chainparams.GetConsensus().BIP34Height);
1780+
//Only continue to enforce if we're below BIP34 activation height or the block hash at that height doesn't correspond.
1781+
fEnforceBIP30 = fEnforceBIP30 && (!pindexBIP34height || !(pindexBIP34height->GetBlockHash() == chainparams.GetConsensus().BIP34Hash));
1782+
17721783
if (fEnforceBIP30) {
17731784
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
17741785
const CCoins* coins = view.AccessCoins(tx.GetHash());

0 commit comments

Comments
 (0)