aboutsummaryrefslogtreecommitdiff
path: root/src/chainparams.cpp
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2017-12-28 15:04:08 +0000
committerRoss Nicoll <[email protected]>2018-09-19 19:24:06 +0100
commit1be681a1b97b686f838af90682a57f2030d26015 (patch)
treeb2795e4a1d35004dbfd84d49b07bc54413a2a9e1 /src/chainparams.cpp
parentChange BIP65/66 enforcement to match Dogecoin (#1403) (diff)
downloaddiscoin-1be681a1b97b686f838af90682a57f2030d26015.tar.xz
discoin-1be681a1b97b686f838af90682a57f2030d26015.zip
Modify chain consensus parameters to be height aware (#1396)
* Modify chain consensus parameters to be height aware * Correct implementation of simplified rewards in parameters * Correct max money * Use base block version in IsSuperMajority() instead of full version * Correct mining of blocks in AuxPoW tests * Add in missing pre-AuxPoW consensus checks
Diffstat (limited to 'src/chainparams.cpp')
-rw-r--r--src/chainparams.cpp112
1 files changed, 103 insertions, 9 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 5e0e51f27..96540938c 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -67,9 +67,14 @@ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits
*/
class CMainParams : public CChainParams {
+private:
+ Consensus::Params digishieldConsensus;
+ Consensus::Params auxpowConsensus;
public:
CMainParams() {
strNetworkID = "main";
+
+ // Blocks 0 - 144999 are conventional difficulty calculation
consensus.nSubsidyHalvingInterval = 100000;
consensus.nMajorityEnforceBlockUpgrade = 1500;
consensus.nMajorityRejectBlockOutdated = 1900;
@@ -82,7 +87,9 @@ public:
consensus.powLimit = uint256S("0x00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20;
consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
consensus.nPowTargetSpacing = 60; // 1 minute
+ consensus.fDigishieldDifficultyCalculation = false;
consensus.fPowAllowMinDifficultyBlocks = false;
+ consensus.fPowAllowDigishieldMinDifficultyBlocks = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
@@ -108,10 +115,30 @@ public:
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0xca5eb72f1e0d160f1481f74d56d7cc4a27d91aa585ba012da8018a5fe934d61b"); // 1,600,000
+ // AuxPoW parameters
consensus.nAuxpowChainId = 0x0062; // 98 - Josh Wise!
- consensus.nAuxpowStartHeight = 371337;
consensus.fStrictChainId = true;
- consensus.nLegacyBlocksBefore = 371337;
+ consensus.fAllowLegacyBlocks = true;
+ consensus.nHeightEffective = 0;
+
+ // Blocks 145000 - 371336 are Digishield without AuxPoW
+ digishieldConsensus = consensus;
+ digishieldConsensus.nHeightEffective = 145000;
+ digishieldConsensus.fSimplifiedRewards = true;
+ digishieldConsensus.fDigishieldDifficultyCalculation = true;
+ digishieldConsensus.nPowTargetTimespan = 60; // post-digishield: 1 minute
+ digishieldConsensus.nCoinbaseMaturity = 240;
+
+ // Blocks 371337+ are AuxPoW
+ auxpowConsensus = digishieldConsensus;
+ auxpowConsensus.nHeightEffective = 371337;
+ auxpowConsensus.fAllowLegacyBlocks = false;
+
+ // Assemble the binary search tree of consensus parameters
+ pConsensusRoot = &digishieldConsensus;
+ digishieldConsensus.pLeft = &consensus;
+ digishieldConsensus.pRight = &auxpowConsensus;
+
/**
* The message start string is designed to be unlikely to occur in normal data.
* The characters are rarely used upper ASCII, not valid as UTF-8, and produce
@@ -127,6 +154,8 @@ public:
genesis = CreateGenesisBlock(1386325540, 99943, 0x1e0ffff0, 1, 88 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
+ digishieldConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
+ auxpowConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
assert(consensus.hashGenesisBlock == uint256S("0x1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691"));
assert(genesis.hashMerkleRoot == uint256S("0x5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69"));
@@ -181,9 +210,20 @@ static CMainParams mainParams;
* Testnet (v3)
*/
class CTestNetParams : public CChainParams {
+private:
+ Consensus::Params digishieldConsensus;
+ Consensus::Params auxpowConsensus;
+ Consensus::Params minDifficultyConsensus;
public:
CTestNetParams() {
strNetworkID = "test";
+
+ // Blocks 0 - 144999 are pre-Digishield
+ consensus.nHeightEffective = 0;
+ consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
+ consensus.fDigishieldDifficultyCalculation = false;
+ consensus.fPowAllowMinDifficultyBlocks = true;
+ consensus.fPowAllowDigishieldMinDifficultyBlocks = false;
consensus.nSubsidyHalvingInterval = 100000;
consensus.nMajorityEnforceBlockUpgrade = 501;
consensus.nMajorityRejectBlockOutdated = 750;
@@ -196,7 +236,6 @@ public:
consensus.powLimit = uint256S("0x00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20;
consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
consensus.nPowTargetSpacing = 60; // 1 minute
- consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
consensus.nMinerConfirmationWindow = 240; // nPowTargetTimespan / nPowTargetSpacing
@@ -222,9 +261,38 @@ public:
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x6943eaeaba98dc7d09f7e73398daccb4abcabb18b66c8c875e52b07638d93951"); // 900,000
- consensus.nAuxpowStartHeight = 158100;
+ // AuxPoW parameters
+ consensus.nAuxpowChainId = 0x0062; // 98 - Josh Wise!
consensus.fStrictChainId = false;
- consensus.nLegacyBlocksBefore = -1;
+ consensus.nHeightEffective = 0;
+ consensus.fAllowLegacyBlocks = true;
+
+ // Blocks 145000 - 157499 are Digishield without minimum difficulty on all blocks
+ digishieldConsensus = consensus;
+ digishieldConsensus.nHeightEffective = 145000;
+ digishieldConsensus.nPowTargetTimespan = 60; // post-digishield: 1 minute
+ digishieldConsensus.fDigishieldDifficultyCalculation = true;
+ digishieldConsensus.fSimplifiedRewards = true;
+ digishieldConsensus.fPowAllowMinDifficultyBlocks = false;
+ digishieldConsensus.nCoinbaseMaturity = 240;
+
+ // Blocks 157500 - 158099 are Digishield with minimum difficulty on all blocks
+ minDifficultyConsensus = digishieldConsensus;
+ minDifficultyConsensus.nHeightEffective = 157500;
+ minDifficultyConsensus.fPowAllowDigishieldMinDifficultyBlocks = true;
+ minDifficultyConsensus.fPowAllowMinDifficultyBlocks = true;
+
+ // Enable AuxPoW at 158100
+ auxpowConsensus = minDifficultyConsensus;
+ auxpowConsensus.nHeightEffective = 158100;
+ auxpowConsensus.fPowAllowDigishieldMinDifficultyBlocks = true;
+ auxpowConsensus.fAllowLegacyBlocks = false;
+
+ // Assemble the binary search tree of parameters
+ pConsensusRoot = &digishieldConsensus;
+ digishieldConsensus.pLeft = &consensus;
+ digishieldConsensus.pRight = &minDifficultyConsensus;
+ minDifficultyConsensus.pRight = &auxpowConsensus;
pchMessageStart[0] = 0xfc;
pchMessageStart[1] = 0xc1;
@@ -235,6 +303,9 @@ public:
genesis = CreateGenesisBlock(1391503289, 997879, 0x1e0ffff0, 1, 88 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
+ digishieldConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
+ minDifficultyConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
+ auxpowConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
assert(consensus.hashGenesisBlock == uint256S("0xbb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e"));
assert(genesis.hashMerkleRoot == uint256S("0x5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69"));
@@ -257,7 +328,6 @@ public:
fRequireStandard = false;
fMineBlocksOnDemand = false;
-
checkpointData = (CCheckpointData) {
boost::assign::map_list_of
( 0, uint256S("0xbb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e"))
@@ -282,6 +352,9 @@ static CTestNetParams testNetParams;
* Regression test
*/
class CRegTestParams : public CChainParams {
+private:
+ Consensus::Params digishieldConsensus;
+ Consensus::Params auxpowConsensus;
public:
CRegTestParams() {
strNetworkID = "regtest";
@@ -294,8 +367,8 @@ public:
// consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
consensus.powLimit = uint256S("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1;
- consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
- consensus.nPowTargetSpacing = 10 * 60;
+ consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
+ consensus.nPowTargetSpacing = 1; // regtest: 1 second blocks
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = true;
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
@@ -316,8 +389,29 @@ public:
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x00");
+ // AuxPow parameters
+ consensus.nAuxpowChainId = 0x0062; // 98 - Josh Wise!
consensus.fStrictChainId = true;
- consensus.nLegacyBlocksBefore = 0;
+ consensus.fAllowLegacyBlocks = true;
+
+ // Dogecoin parameters
+ consensus.fSimplifiedRewards = true;
+ consensus.nCoinbaseMaturity = 60; // For easier testability in RPC tests
+
+ digishieldConsensus = consensus;
+ digishieldConsensus.nHeightEffective = 10;
+ digishieldConsensus.nPowTargetTimespan = 1; // regtest: also retarget every second in digishield mode, for conformity
+ digishieldConsensus.fDigishieldDifficultyCalculation = true;
+
+ auxpowConsensus = digishieldConsensus;
+ auxpowConsensus.fAllowLegacyBlocks = false;
+ auxpowConsensus.nHeightEffective = 20;
+
+ // Assemble the binary search tree of parameters
+ digishieldConsensus.pLeft = &consensus;
+ digishieldConsensus.pRight = &auxpowConsensus;
+ pConsensusRoot = &digishieldConsensus;
+
pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0xb5;