Skip to content

Commit

Permalink
Remove 16 bits from versionbits signalling
Browse files Browse the repository at this point in the history
This removes bits 13-28 inclusive (0x1fffe000) from the versionbits
signalling system, preventing warnings from being generated for any
miners using these bits.

This effectively reserves 16 bit for miscellaneous use by miners
for things like version-rolling and nonce-rolling and establishes
a zone miners can use without causing unexpected disruption.
  • Loading branch information
btcdrak committed Mar 6, 2018
1 parent 7deba93 commit d12516e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/versionbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 11 additions & 1 deletion test/functional/feature_versionbits_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 <VB_THRESHOLD blocks with unknown versionbits version.")
# Build one period of blocks with < VB_THRESHOLD blocks signaling some unknown bit
self.send_blocks_with_version(node.p2p, VB_THRESHOLD - 1, VB_UNKNOWN_VERSION)
Expand Down

0 comments on commit d12516e

Please sign in to comment.