Skip to content

Commit fdb3e8f

Browse files
ajtownsjnewbery
authored andcommitted
Ignore old versionbit activations
Adds a hardcoded height to the consensus chain parameters for ignoring versionbit activations prior to a fixed height.
1 parent 5e20238 commit fdb3e8f

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/chainparams.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class CMainParams : public CChainParams {
7171
consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
7272
consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
7373
consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
74+
consensus.MinBIP9WarningHeight = consensus.SegwitHeight + consensus.nMinerConfirmationWindow;
7475
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
7576
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
7677
consensus.nPowTargetSpacing = 10 * 60;
@@ -177,6 +178,7 @@ class CTestNetParams : public CChainParams {
177178
consensus.BIP66Height = 330776; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
178179
consensus.CSVHeight = 770112; // 00000000025e930139bac5c6c31a403776da130831ab85be56578f3fa75369bb
179180
consensus.SegwitHeight = 834624; // 00000000002b980fcd729daaa248fd9316a5200e9b367f4ff2c42453e84201ca
181+
consensus.MinBIP9WarningHeight = consensus.SegwitHeight + consensus.nMinerConfirmationWindow;
180182
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
181183
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
182184
consensus.nPowTargetSpacing = 10 * 60;
@@ -261,6 +263,7 @@ class CRegTestParams : public CChainParams {
261263
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
262264
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
263265
consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
266+
consensus.MinBIP9WarningHeight = 0;
264267
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
265268
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
266269
consensus.nPowTargetSpacing = 10 * 60;

src/consensus/params.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ struct Params {
6262
* Note that segwit v0 script rules are enforced on all blocks except the
6363
* BIP 16 exception blocks. */
6464
int SegwitHeight;
65+
/** Don't warn about unknown BIP 9 activations below this height.
66+
* This prevents us from warning about the CSV and segwit activations. */
67+
int MinBIP9WarningHeight;
6568
/**
6669
* Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,
6770
* (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments.

src/validation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,8 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
16251625

16261626
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const override
16271627
{
1628-
return ((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) &&
1628+
return pindex->nHeight >= params.MinBIP9WarningHeight &&
1629+
((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) &&
16291630
((pindex->nVersion >> bit) & 1) != 0 &&
16301631
((ComputeBlockVersion(pindex->pprev, params) >> bit) & 1) == 0;
16311632
}

0 commit comments

Comments
 (0)