Skip to content

Commit 33c90cf

Browse files
committed
Make skipping BIP30 check chain agnostic
1 parent 06d81ad commit 33c90cf

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,10 +1742,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
17421742
// time BIP34 activated, in each of the existing pairs the duplicate coinbase had overwritten the first
17431743
// before the first had been spent. Since those coinbases are sufficiently buried its no longer possible to create further
17441744
// duplicate transactions descending from the known pairs either.
1745-
// If we're on the known chain at height greater than 227931 where BIP34 activated, we can save the db accesses needed for the BIP30 check.
1746-
CBlockIndex *pindexBIP34height = pindex->pprev->GetAncestor(227931);
1747-
//Only continue to enforce if we're below height 227931 or the block hash at that height doesn't correspond.
1748-
fEnforceBIP30 = fEnforceBIP30 && (!pindexBIP34height || !(pindexBIP34height->GetBlockHash() == uint256S("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8")));
1745+
// 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.
1746+
CBlockIndex *pindexBIP34height = pindex->pprev->GetAncestor(chainparams.GetConsensus().BIP34Height);
1747+
//Only continue to enforce if we're below BIP34 activation height or the block hash at that height doesn't correspond.
1748+
fEnforceBIP30 = fEnforceBIP30 && (!pindexBIP34height || !(pindexBIP34height->GetBlockHash() == chainparams.GetConsensus().BIP34Hash));
17491749

17501750
if (fEnforceBIP30) {
17511751
BOOST_FOREACH(const CTransaction& tx, block.vtx) {

0 commit comments

Comments
 (0)