aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2018-09-19 15:58:29 +0100
committerRoss Nicoll <[email protected]>2021-05-20 12:02:35 +0100
commit0817a1bced90d59fb4d268c77f6c46ff1b02b012 (patch)
treeb125c9ea669fd1c3761cdbaa6872ad228443a232
parentAdjust download timeouts to handle shorter block interval (#1866) (diff)
downloaddiscoin-0817a1bced90d59fb4d268c77f6c46ff1b02b012.tar.xz
discoin-0817a1bced90d59fb4d268c77f6c46ff1b02b012.zip
Update miner confirmation window
* Update miner confirmation window to 240 for Dogecoin main net, and update related values. * Re-enable PoW tests with Dogecoin values. * Update version bit tests based on Dogecoin mining values.
-rw-r--r--src/chainparams.cpp12
-rw-r--r--src/test/pow_tests.cpp16
-rw-r--r--src/test/versionbits_tests.cpp4
3 files changed, 16 insertions, 16 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index c38754327..a0b28ef2c 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -80,8 +80,8 @@ public:
consensus.nPowTargetSpacing = 10 * 60;
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fPowNoRetargeting = false;
- consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
- consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
+ consensus.nRuleChangeActivationThreshold = 9576; // 95% of 10,080
+ consensus.nMinerConfirmationWindow = 10080; // 60 * 24 * 7 = 10,080 blocks, or one week
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
@@ -193,8 +193,8 @@ public:
consensus.nPowTargetSpacing = 10 * 60;
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = false;
- consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
- consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
+ consensus.nRuleChangeActivationThreshold = 2880; // 2 days (note this is significantly lower than Bitcoin standard)
+ consensus.nMinerConfirmationWindow = 10080; // 60 * 24 * 7 = 10,080 blocks, or one week
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
@@ -389,8 +389,8 @@ public:
consensus.nPowTargetSpacing = 10 * 60;
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = true;
- consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
- consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
+ consensus.nRuleChangeActivationThreshold = 540; // 75% for testchains
+ consensus.nMinerConfirmationWindow = 720; // Faster than normal for regtest (2,520 instead of 10,080)
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
diff --git a/src/test/pow_tests.cpp b/src/test/pow_tests.cpp
index 1d7f4861f..bb4d2ce4b 100644
--- a/src/test/pow_tests.cpp
+++ b/src/test/pow_tests.cpp
@@ -15,12 +15,12 @@ BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(get_next_work)
{
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
- int64_t nLastRetargetTime = 1261130161; // Block #30240
+ int64_t nLastRetargetTime = 1388149872; // Block #30240
CBlockIndex pindexLast;
- pindexLast.nHeight = 32255;
- pindexLast.nTime = 1262152739; // Block #32255
- pindexLast.nBits = 0x1d00ffff;
- BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1d00d86aU);
+ pindexLast.nHeight = 30479;
+ pindexLast.nTime = 1388163922; // Block #30479
+ pindexLast.nBits = 0x1c00974f;
+ BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1c0093a1U);
}
/* Test the constraint on the upper bound for next work */
@@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
pindexLast.nHeight = 2015;
pindexLast.nTime = 1233061996; // Block #2015
pindexLast.nBits = 0x1d00ffff;
- BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1d00ffffU);
+ BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1d03fffcU);
}
/* Test the constraint on the lower bound for actual time taken */
@@ -41,8 +41,8 @@ BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
int64_t nLastRetargetTime = 1279008237; // Block #66528
CBlockIndex pindexLast;
- pindexLast.nHeight = 68543;
- pindexLast.nTime = 1279297671; // Block #68543
+ pindexLast.nHeight = 66767;
+ pindexLast.nTime = 1279008237 + (239 * 60 / 4 - 1); // Bitcoin Block #66528 + less than a quarter of the target timespan
pindexLast.nBits = 0x1c05a3f4;
BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, chainParams->GetConsensus()), 0x1c0168fdU);
}
diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp
index 50444f7bb..5de2d11af 100644
--- a/src/test/versionbits_tests.cpp
+++ b/src/test/versionbits_tests.cpp
@@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
BOOST_CHECK_EQUAL(ComputeBlockVersion(lastBlock, mainnetParams) & VERSIONBITS_TOP_MASK, VERSIONBITS_TOP_BITS);
// Check that ComputeBlockVersion will set the bit until nTimeout
- nTime += 600;
+ nTime += 60;
uint32_t blocksToMine = mainnetParams.nMinerConfirmationWindow * 2; // test blocks for up to 2 time periods
uint32_t nHeight = mainnetParams.nMinerConfirmationWindow * 3;
// These blocks are all before nTimeout is reached.
@@ -306,7 +306,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
BOOST_CHECK((ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit)) != 0);
BOOST_CHECK_EQUAL(ComputeBlockVersion(lastBlock, mainnetParams) & VERSIONBITS_TOP_MASK, VERSIONBITS_TOP_BITS);
blocksToMine--;
- nTime += 600;
+ nTime += 60;
nHeight += 1;
}