diff --git a/src/chainparams.cpp b/src/chainparams.cpp index c2b3480f9d41e..8d25e6bfd2446 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -87,7 +87,7 @@ class CMainParams : public CChainParams { consensus.fPowNoRetargeting = false; consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016 consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; + consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 12; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008 consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008 @@ -201,7 +201,7 @@ class CTestNetParams : public CChainParams { consensus.fPowNoRetargeting = false; consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; + consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 12; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008 consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008 @@ -294,7 +294,7 @@ class CRegTestParams : public CChainParams { consensus.fPowNoRetargeting = true; consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016) - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; + consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 12; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0; diff --git a/src/validation.cpp b/src/validation.cpp index a77362f5d6787..010fdb8bda6dc 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2160,7 +2160,7 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar for (int i = 0; i < 100 && pindex != nullptr; i++) { int32_t nExpectedVersion = ComputeBlockVersion(pindex->pprev, chainParams.GetConsensus()); - if (pindex->nVersion > VERSIONBITS_LAST_OLD_BLOCK_VERSION && (pindex->nVersion & ~nExpectedVersion) != 0) + if (pindex->nVersion > VERSIONBITS_LAST_OLD_BLOCK_VERSION && (pindex->nVersion & ~nExpectedVersion & VERSIONBITS_IGNORE_MASK) != 0) ++nUpgraded; pindex = pindex->pprev; } diff --git a/src/versionbits.h b/src/versionbits.h index 1600dc8c933fe..6bddf27ad9c3d 100644 --- a/src/versionbits.h +++ b/src/versionbits.h @@ -15,7 +15,9 @@ static const int32_t VERSIONBITS_TOP_BITS = 0x20000000UL; /** What bitmask determines whether versionbits is in use */ static const int32_t VERSIONBITS_TOP_MASK = 0xE0000000UL; /** Total bits available for versionbits */ -static const int32_t VERSIONBITS_NUM_BITS = 29; +static const int32_t VERSIONBITS_NUM_BITS = 13; +/** Bitmask for ignored versionbits. It should match VERSIONBITS_NUM_BITS (BIPxxx) */ +static const int32_t VERSIONBITS_IGNORE_MASK = 0xE0001FFFUL; enum ThresholdState { THRESHOLD_DEFINED, diff --git a/test/functional/feature_versionbits_warning.py b/test/functional/feature_versionbits_warning.py index 2985569a8fca3..55e299a577427 100755 --- a/test/functional/feature_versionbits_warning.py +++ b/test/functional/feature_versionbits_warning.py @@ -19,8 +19,9 @@ VB_PERIOD = 144 # versionbits period length for regtest VB_THRESHOLD = 108 # versionbits activation threshold for regtest VB_TOP_BITS = 0x20000000 -VB_UNKNOWN_BIT = 27 # Choose a bit unassigned to any deployment +VB_UNKNOWN_BIT = 11 # Choose a bit unassigned to any deployment VB_UNKNOWN_VERSION = VB_TOP_BITS | (1 << VB_UNKNOWN_BIT) +VB_IGNORE_VERSION = VB_TOP_BITS | 0x1FFFE000 WARN_UNKNOWN_RULES_MINED = "Unknown block versions being mined! It's possible unknown rules are in effect" WARN_UNKNOWN_RULES_ACTIVE = "unknown new rules activated (versionbit {})".format(VB_UNKNOWN_BIT) @@ -71,6 +72,15 @@ def run_test(self): # Mine one period worth of blocks node.generate(VB_PERIOD) + self.log.info("Check that there is no warning if previous VB_BLOCKS have VB_PERIOD blocks with ignored versionbits version.") + # Build one period of blocks with ignored bit. There should be no warning + self.send_blocks_with_version(node.p2p, VB_PERIOD, VB_IGNORE_VERSION) + assert(not WARN_UNKNOWN_RULES_MINED in node.getmininginfo()["warnings"]) + assert(not WARN_UNKNOWN_RULES_MINED in node.getnetworkinfo()["warnings"]) + assert(not VB_PATTERN.match(node.getmininginfo()["warnings"])) + assert(not VB_PATTERN.match(node.getnetworkinfo()["warnings"])) + assert(not self.versionbits_in_alert_file()) + self.log.info("Check that there is no warning if previous VB_BLOCKS have