aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2018-09-19 15:58:29 +0100
committerRoss Nicoll <[email protected]>2018-09-23 21:22:58 +0100
commit199cf694ef955137f87138f78b9c0f010dcc90b6 (patch)
tree46d2e44b82eca63a6e6c7a13ad7dbe2f1ca5bc82 /src
parentCreate v1 transactions for compatibility with 1.10 (#1485) (diff)
downloaddiscoin-199cf694ef955137f87138f78b9c0f010dcc90b6.tar.xz
discoin-199cf694ef955137f87138f78b9c0f010dcc90b6.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.
Diffstat (limited to 'src')
-rw-r--r--src/chainparams.cpp12
-rw-r--r--src/test/pow_tests.cpp31
-rw-r--r--src/test/versionbits_tests.cpp30
3 files changed, 35 insertions, 38 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 722cf8c0d..baf54dffc 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -92,8 +92,8 @@ public:
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fPowAllowDigishieldMinDifficultyBlocks = 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
@@ -238,8 +238,8 @@ public:
consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
consensus.nPowTargetSpacing = 60; // 1 minute
consensus.fPowNoRetargeting = false;
- consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
- consensus.nMinerConfirmationWindow = 240; // 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
@@ -375,8 +375,8 @@ public:
consensus.fDigishieldDifficultyCalculation = false;
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = true;
- consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
- consensus.nMinerConfirmationWindow = 60; // Faster than normal for regtest (60 instead of 240)
+ 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 = 999999999999ULL;
diff --git a/src/test/pow_tests.cpp b/src/test/pow_tests.cpp
index a90e6896b..e112c7339 100644
--- a/src/test/pow_tests.cpp
+++ b/src/test/pow_tests.cpp
@@ -14,23 +14,21 @@
BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup)
/* Test calculation of next difficulty target with no constraints applying */
-// Replaced by Dogecoin-specific PoW test
-/* BOOST_AUTO_TEST_CASE(get_next_work)
+BOOST_AUTO_TEST_CASE(get_next_work)
{
SelectParams(CBaseChainParams::MAIN);
const Consensus::Params& params = Params().GetConsensus(0);
- 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, params), 0x1d00d86a);
-} */
+ pindexLast.nHeight = 30479;
+ pindexLast.nTime = 1388163922; // Block #30479
+ pindexLast.nBits = 0x1c00974f;
+ BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, params), 0x1c0093a1);
+}
/* Test the constraint on the upper bound for next work */
-// Replaced by Dogecoin-specific PoW test
-/* BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
+BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
{
SelectParams(CBaseChainParams::MAIN);
const Consensus::Params& params = Params().GetConsensus(0);
@@ -40,23 +38,22 @@ BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup)
pindexLast.nHeight = 2015;
pindexLast.nTime = 1233061996; // Block #2015
pindexLast.nBits = 0x1d00ffff;
- BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, params), 0x1d00ffff);
-} */
+ BOOST_CHECK_EQUAL(CalculateNextWorkRequired(&pindexLast, nLastRetargetTime, params), 0x1d03fffc);
+}
/* Test the constraint on the lower bound for actual time taken */
-// Replaced by Dogecoin-specific PoW test
-/* BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
+BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
{
SelectParams(CBaseChainParams::MAIN);
const Consensus::Params& params = Params().GetConsensus(0);
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, params), 0x1c0168fd);
-} */
+}
/* Test the constraint on the upper bound for actual time taken */
// Replaced by Dogecoin-specific PoW test
diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp
index 7427a1e57..422e283ba 100644
--- a/src/test/versionbits_tests.cpp
+++ b/src/test/versionbits_tests.cpp
@@ -255,12 +255,12 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
// Before MedianTimePast of the chain has crossed nStartTime, the bit
// should not be set.
CBlockIndex *lastBlock = NULL;
- lastBlock = firstChain.Mine(2016, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
+ lastBlock = firstChain.Mine(10080, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
BOOST_CHECK_EQUAL(ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit), 0);
- // Mine 2011 more blocks at the old time, and check that CBV isn't setting the bit yet.
- for (int i=1; i<2012; i++) {
- lastBlock = firstChain.Mine(2016+i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
+ // Mine 10075 more blocks at the old time, and check that CBV isn't setting the bit yet.
+ for (int i=1; i<10076; i++) {
+ lastBlock = firstChain.Mine(10080+i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
// This works because VERSIONBITS_LAST_OLD_BLOCK_VERSION happens
// to be 4, and the bit we're testing happens to be bit 28.
BOOST_CHECK_EQUAL(ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit), 0);
@@ -268,13 +268,13 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
// Now mine 5 more blocks at the start time -- MTP should not have passed yet, so
// CBV should still not yet set the bit.
nTime = nStartTime;
- for (int i=2012; i<=2016; i++) {
- lastBlock = firstChain.Mine(2016+i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
+ for (int i=10075; i<=10080; i++) {
+ lastBlock = firstChain.Mine(10080+i, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
BOOST_CHECK_EQUAL(ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit), 0);
}
// Advance to the next period and transition to STARTED,
- lastBlock = firstChain.Mine(6048, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
+ lastBlock = firstChain.Mine(30240, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
// so ComputeBlockVersion should now set the bit,
BOOST_CHECK((ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit)) != 0);
// and should also be using the VERSIONBITS_TOP_BITS.
@@ -282,22 +282,22 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
// Check that ComputeBlockVersion will set the bit until nTimeout
nTime += 600;
- int blocksToMine = 4032; // test blocks for up to 2 time periods
- int nHeight = 6048;
+ int blocksToMine = 20160; // test blocks for up to 2 time periods
+ int nHeight = 30240;
// These blocks are all before nTimeout is reached.
while (nTime < nTimeout && blocksToMine > 0) {
lastBlock = firstChain.Mine(nHeight+1, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
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;
}
nTime = nTimeout;
// FAILED is only triggered at the end of a period, so CBV should be setting
// the bit until the period transition.
- for (int i=0; i<2015; i++) {
+ for (int i=0; i<10079; i++) {
lastBlock = firstChain.Mine(nHeight+1, nTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
BOOST_CHECK((ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit)) != 0);
nHeight += 1;
@@ -313,20 +313,20 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
// Mine one period worth of blocks, and check that the bit will be on for the
// next period.
- lastBlock = secondChain.Mine(2016, nStartTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
+ lastBlock = secondChain.Mine(10080, nStartTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
BOOST_CHECK((ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit)) != 0);
// Mine another period worth of blocks, signaling the new bit.
- lastBlock = secondChain.Mine(4032, nStartTime, VERSIONBITS_TOP_BITS | (1<<bit)).Tip();
+ lastBlock = secondChain.Mine(20160, nStartTime, VERSIONBITS_TOP_BITS | (1<<bit)).Tip();
// After one period of setting the bit on each block, it should have locked in.
// We keep setting the bit for one more period though, until activation.
BOOST_CHECK((ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit)) != 0);
// Now check that we keep mining the block until the end of this period, and
// then stop at the beginning of the next period.
- lastBlock = secondChain.Mine(6047, nStartTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
+ lastBlock = secondChain.Mine(30239, nStartTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
BOOST_CHECK((ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit)) != 0);
- lastBlock = secondChain.Mine(6048, nStartTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
+ lastBlock = secondChain.Mine(30240, nStartTime, VERSIONBITS_LAST_OLD_BLOCK_VERSION).Tip();
BOOST_CHECK_EQUAL(ComputeBlockVersion(lastBlock, mainnetParams) & (1<<bit), 0);
// Finally, verify that after a soft fork has activated, CBV no longer uses