Skip to content

Commit a679040

Browse files
committed
consensus/params: Move version bits period/threshold to bip9 param
Rather than having the rule change period/threshold be constant for all potential deployments on a chain, have it be specific to the deployment itself. This both matches history (BIP 9 specified a 2016 block period and 1916 block threshold; BIP 91 specified a 336 block period and 269 block threshold; and BIP 341 specified a 2016 block period and 1815 block threshold), and allows the code to be simplified, as only the BIP9Deployment structure is needed, not the full Consensus::Params structure.
1 parent e9d6170 commit a679040

File tree

5 files changed

+76
-45
lines changed

5 files changed

+76
-45
lines changed

src/consensus/params.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ struct BIP9Deployment {
5353
* boundary.
5454
*/
5555
int min_activation_height{0};
56+
/** Period of blocks to check signalling in (usually retarget period, ie params.DifficultyAdjustmentInterval()) */
57+
uint32_t period{2016};
58+
/**
59+
* Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,
60+
* which is also used for BIP9 deployments.
61+
* Examples: 1916 for 95%, 1512 for testchains.
62+
*/
63+
uint32_t threshold{1916};
5664

5765
/** Constant for nTimeout very far in the future. */
5866
static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max();
@@ -98,13 +106,6 @@ struct Params {
98106
/** Don't warn about unknown BIP 9 activations below this height.
99107
* This prevents us from warning about the CSV and segwit activations. */
100108
int MinBIP9WarningHeight;
101-
/**
102-
* Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,
103-
* (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments.
104-
* Examples: 1916 for 95%, 1512 for testchains.
105-
*/
106-
uint32_t nRuleChangeActivationThreshold;
107-
uint32_t nMinerConfirmationWindow;
108109
std::array<BIP9Deployment,MAX_VERSION_BITS_DEPLOYMENTS> vDeployments;
109110
/** Proof of work parameters */
110111
uint256 powLimit;

src/kernel/chainparams.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,20 @@ class CMainParams : public CChainParams {
104104
consensus.fPowAllowMinDifficultyBlocks = false;
105105
consensus.enforce_BIP94 = false;
106106
consensus.fPowNoRetargeting = false;
107-
consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016
108-
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
109107
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
110108
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
111109
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
112110
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
111+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 1815; // 90%
112+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 2016;
113113

114114
// Deployment of Taproot (BIPs 340-342)
115115
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
116116
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1619222400; // April 24th, 2021
117117
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021
118118
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 709632; // Approximately November 12th, 2021
119+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].threshold = 1815; // 90%
120+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].period = 2016;
119121

120122
consensus.nMinimumChainWork = uint256{"000000000000000000000000000000000000000088e186b70e0862c193ec44d6"};
121123
consensus.defaultAssumeValid = uint256{"000000000000000000011c5890365bdbe5d25b97ce0057589acaef4f1a57263f"}; // 856760
@@ -228,18 +230,20 @@ class CTestNetParams : public CChainParams {
228230
consensus.fPowAllowMinDifficultyBlocks = true;
229231
consensus.enforce_BIP94 = false;
230232
consensus.fPowNoRetargeting = false;
231-
consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
232-
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
233233
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
234234
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
235235
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
236236
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
237+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 1512; // 75%
238+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 2016;
237239

238240
// Deployment of Taproot (BIPs 340-342)
239241
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
240242
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1619222400; // April 24th, 2021
241243
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021
242244
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
245+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].threshold = 1512; // 75%
246+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].period = 2016;
243247

244248
consensus.nMinimumChainWork = uint256{"000000000000000000000000000000000000000000000f209695166be8b61fa9"};
245249
consensus.defaultAssumeValid = uint256{"000000000000000465b1a66c9f386308e8c75acef9201f3f577811da09fc90ad"}; // 2873500
@@ -327,18 +331,21 @@ class CTestNet4Params : public CChainParams {
327331
consensus.fPowAllowMinDifficultyBlocks = true;
328332
consensus.enforce_BIP94 = true;
329333
consensus.fPowNoRetargeting = false;
330-
consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
331-
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
334+
332335
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
333336
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
334337
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
335338
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
339+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 1512; // 75%
340+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 2016;
336341

337342
// Deployment of Taproot (BIPs 340-342)
338343
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
339344
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
340345
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
341346
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
347+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].threshold = 1512; // 75%
348+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].period = 2016;
342349

343350
consensus.nMinimumChainWork = uint256{"00000000000000000000000000000000000000000000005faa15d02e6202f3ba"};
344351
consensus.defaultAssumeValid = uint256{"000000005be348057db991fa5d89fe7c4695b667cfb311391a8db374b6f681fd"}; // 39550
@@ -465,20 +472,22 @@ class SigNetParams : public CChainParams {
465472
consensus.fPowAllowMinDifficultyBlocks = false;
466473
consensus.enforce_BIP94 = false;
467474
consensus.fPowNoRetargeting = false;
468-
consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016
469-
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
470475
consensus.MinBIP9WarningHeight = 0;
471476
consensus.powLimit = uint256{"00000377ae000000000000000000000000000000000000000000000000000000"};
472477
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
473478
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
474479
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
475480
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
481+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 1815; // 90%
482+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 2016;
476483

477484
// Activation of Taproot (BIPs 340-342)
478485
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
479486
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
480487
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
481488
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
489+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].threshold = 1815; // 90%
490+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].period = 2016;
482491

483492
// message start is defined as the first 4 bytes of the sha256d of the block script
484493
HashWriter h{};
@@ -544,18 +553,20 @@ class CRegTestParams : public CChainParams
544553
consensus.fPowAllowMinDifficultyBlocks = true;
545554
consensus.enforce_BIP94 = opts.enforce_bip94;
546555
consensus.fPowNoRetargeting = true;
547-
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
548-
consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
549556

550557
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
551558
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
552559
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
553560
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay
561+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].threshold = 108; // 75%
562+
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].period = 144; // Faster than normal for regtest (144 instead of 2016)
554563

555564
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
556565
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
557566
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
558567
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay
568+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].threshold = 108; // 75%
569+
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].period = 144;
559570

560571
consensus.nMinimumChainWork = uint256{};
561572
consensus.defaultAssumeValid = uint256{};

src/test/versionbits_tests.cpp

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ void check_computeblockversion(VersionBitsCache& versionbitscache, const Consens
268268
int64_t nStartTime = params.vDeployments[dep].nStartTime;
269269
int64_t nTimeout = params.vDeployments[dep].nTimeout;
270270
int min_activation_height = params.vDeployments[dep].min_activation_height;
271+
uint32_t period = params.vDeployments[dep].period;
272+
uint32_t threshold = params.vDeployments[dep].threshold;
273+
274+
BOOST_REQUIRE(period > 0); // no division by zero, thankyou
275+
BOOST_REQUIRE(0 < threshold); // must be able to have a window that doesn't activate
276+
BOOST_REQUIRE(threshold < period); // must be able to have a window that does activate
271277

272278
// should not be any signalling for first block
273279
BOOST_CHECK_EQUAL(versionbitscache.ComputeBlockVersion(nullptr, params), VERSIONBITS_TOP_BITS);
@@ -289,7 +295,7 @@ void check_computeblockversion(VersionBitsCache& versionbitscache, const Consens
289295
BOOST_REQUIRE(((1 << bit) & VERSIONBITS_TOP_MASK) == 0);
290296
BOOST_REQUIRE(min_activation_height >= 0);
291297
// Check min_activation_height is on a retarget boundary
292-
BOOST_REQUIRE_EQUAL(min_activation_height % params.nMinerConfirmationWindow, 0U);
298+
BOOST_REQUIRE_EQUAL(min_activation_height % period, 0U);
293299

294300
const uint32_t bitmask{versionbitscache.Mask(params, dep)};
295301
BOOST_CHECK_EQUAL(bitmask, uint32_t{1} << bit);
@@ -309,44 +315,44 @@ void check_computeblockversion(VersionBitsCache& versionbitscache, const Consens
309315
// since CBlockIndex::nTime is uint32_t we can't represent any
310316
// earlier time, so will transition from DEFINED to STARTED at the
311317
// end of the first period by mining blocks at nTime == 0
312-
lastBlock = firstChain.Mine(params.nMinerConfirmationWindow - 1, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
318+
lastBlock = firstChain.Mine(period - 1, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
313319
BOOST_CHECK_EQUAL(versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit), 0);
314-
lastBlock = firstChain.Mine(params.nMinerConfirmationWindow, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
320+
lastBlock = firstChain.Mine(period, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
315321
BOOST_CHECK((versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit)) != 0);
316322
// then we'll keep mining at nStartTime...
317323
} else {
318324
// use a time 1s earlier than start time to check we stay DEFINED
319325
--nTime;
320326

321327
// Start generating blocks before nStartTime
322-
lastBlock = firstChain.Mine(params.nMinerConfirmationWindow, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
328+
lastBlock = firstChain.Mine(period, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
323329
BOOST_CHECK_EQUAL(versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit), 0);
324330

325331
// Mine more blocks (4 less than the adjustment period) at the old time, and check that CBV isn't setting the bit yet.
326-
for (uint32_t i = 1; i < params.nMinerConfirmationWindow - 4; i++) {
327-
lastBlock = firstChain.Mine(params.nMinerConfirmationWindow + i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
332+
for (uint32_t i = 1; i < period - 4; i++) {
333+
lastBlock = firstChain.Mine(period + i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
328334
BOOST_CHECK_EQUAL(versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit), 0);
329335
}
330336
// Now mine 5 more blocks at the start time -- MTP should not have passed yet, so
331337
// CBV should still not yet set the bit.
332338
nTime = nStartTime;
333-
for (uint32_t i = params.nMinerConfirmationWindow - 4; i <= params.nMinerConfirmationWindow; i++) {
334-
lastBlock = firstChain.Mine(params.nMinerConfirmationWindow + i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
339+
for (uint32_t i = period - 4; i <= period; i++) {
340+
lastBlock = firstChain.Mine(period + i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
335341
BOOST_CHECK_EQUAL(versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit), 0);
336342
}
337343
// Next we will advance to the next period and transition to STARTED,
338344
}
339345

340-
lastBlock = firstChain.Mine(params.nMinerConfirmationWindow * 3, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
346+
lastBlock = firstChain.Mine(period * 3, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
341347
// so ComputeBlockVersion should now set the bit,
342348
BOOST_CHECK((versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit)) != 0);
343349
// and should also be using the VERSIONBITS_TOP_BITS.
344350
BOOST_CHECK_EQUAL(versionbitscache.ComputeBlockVersion(lastBlock, params) & VERSIONBITS_TOP_MASK, VERSIONBITS_TOP_BITS);
345351

346352
// Check that ComputeBlockVersion will set the bit until nTimeout
347353
nTime += 600;
348-
uint32_t blocksToMine = params.nMinerConfirmationWindow * 2; // test blocks for up to 2 time periods
349-
uint32_t nHeight = params.nMinerConfirmationWindow * 3;
354+
uint32_t blocksToMine = period * 2; // test blocks for up to 2 time periods
355+
uint32_t nHeight = period * 3;
350356
// These blocks are all before nTimeout is reached.
351357
while (nTime < nTimeout && blocksToMine > 0) {
352358
lastBlock = firstChain.Mine(nHeight+1, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
@@ -363,15 +369,15 @@ void check_computeblockversion(VersionBitsCache& versionbitscache, const Consens
363369
nTime = nTimeout;
364370

365371
// finish the last period before we start timing out
366-
while (nHeight % params.nMinerConfirmationWindow != 0) {
372+
while (nHeight % period != 0) {
367373
lastBlock = firstChain.Mine(nHeight+1, nTime - 1, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
368374
BOOST_CHECK((versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit)) != 0);
369375
nHeight += 1;
370376
}
371377

372378
// FAILED is only triggered at the end of a period, so CBV should be setting
373379
// the bit until the period transition.
374-
for (uint32_t i = 0; i < params.nMinerConfirmationWindow - 1; i++) {
380+
for (uint32_t i = 0; i < period - 1; i++) {
375381
lastBlock = firstChain.Mine(nHeight+1, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
376382
BOOST_CHECK((versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit)) != 0);
377383
nHeight += 1;
@@ -388,20 +394,20 @@ void check_computeblockversion(VersionBitsCache& versionbitscache, const Consens
388394

389395
// Mine one period worth of blocks, and check that the bit will be on for the
390396
// next period.
391-
lastBlock = secondChain.Mine(params.nMinerConfirmationWindow, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
397+
lastBlock = secondChain.Mine(period, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
392398
BOOST_CHECK((versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit)) != 0);
393399

394400
// Mine another period worth of blocks, signaling the new bit.
395-
lastBlock = secondChain.Mine(params.nMinerConfirmationWindow * 2, nTime, VERSIONBITS_TOP_BITS | (1<<bit)).Tip();
401+
lastBlock = secondChain.Mine(period * 2, nTime, VERSIONBITS_TOP_BITS | (1<<bit)).Tip();
396402
// After one period of setting the bit on each block, it should have locked in.
397403
// We keep setting the bit for one more period though, until activation.
398404
BOOST_CHECK((versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit)) != 0);
399405

400406
// Now check that we keep mining the block until the end of this period, and
401407
// then stop at the beginning of the next period.
402-
lastBlock = secondChain.Mine((params.nMinerConfirmationWindow * 3) - 1, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
408+
lastBlock = secondChain.Mine((period * 3) - 1, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
403409
BOOST_CHECK((versionbitscache.ComputeBlockVersion(lastBlock, params) & (1 << bit)) != 0);
404-
lastBlock = secondChain.Mine(params.nMinerConfirmationWindow * 3, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
410+
lastBlock = secondChain.Mine(period * 3, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
405411

406412
if (lastBlock->nHeight + 1 < min_activation_height) {
407413
// check signalling continues while min_activation_height is not reached

src/validation.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,8 +2378,20 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
23782378

23792379
int64_t BeginTime() const override { return 0; }
23802380
int64_t EndTime() const override { return std::numeric_limits<int64_t>::max(); }
2381-
int Period() const override { return m_chainman.GetConsensus().nMinerConfirmationWindow; }
2382-
int Threshold() const override { return m_chainman.GetConsensus().nRuleChangeActivationThreshold; }
2381+
int Period() const override {
2382+
if (m_chainman.GetParams().IsTestChain()) {
2383+
return m_chainman.GetConsensus().DifficultyAdjustmentInterval();
2384+
} else {
2385+
return 2016;
2386+
}
2387+
}
2388+
int Threshold() const override {
2389+
if (m_chainman.GetParams().IsTestChain()) {
2390+
return m_chainman.GetConsensus().DifficultyAdjustmentInterval() * 3 / 4; // 75% for test nets per BIP9 suggestion
2391+
} else {
2392+
return 1815; // 90% threshold used in BIP 341
2393+
}
2394+
}
23832395

23842396
bool Condition(const CBlockIndex* pindex) const override
23852397
{

0 commit comments

Comments
 (0)