diff --git a/src/Makefile.am b/src/Makefile.am index 94e2dfd54b08..e538c4f3ffcb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -283,6 +283,7 @@ BITCOIN_CORE_H = \ validation.h \ validationinterface.h \ versionbits.h \ + versionbitsinfo.h \ walletinitinterface.h \ wallet/coincontrol.h \ wallet/crypter.h \ @@ -579,6 +580,7 @@ libdash_common_a_SOURCES = \ script/ismine.cpp \ script/sign.cpp \ script/standard.cpp \ + versionbitsinfo.cpp \ warnings.cpp \ $(BITCOIN_CORE_H) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 99f2efae5539..dd152c601469 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -11,11 +11,15 @@ #include #include #include +#include #include #include +#include +#include + static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) { CMutableTransaction txNew; @@ -79,75 +83,6 @@ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward); } - -void CChainParams::UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout, int64_t nWindowSize, int64_t nThresholdStart, int64_t nThresholdMin, int64_t nFalloffCoeff) -{ - consensus.vDeployments[d].nStartTime = nStartTime; - consensus.vDeployments[d].nTimeout = nTimeout; - if (nWindowSize != -1) { - consensus.vDeployments[d].nWindowSize = nWindowSize; - } - if (nThresholdStart != -1) { - consensus.vDeployments[d].nThresholdStart = nThresholdStart; - } - if (nThresholdMin != -1) { - consensus.vDeployments[d].nThresholdMin = nThresholdMin; - } - if (nFalloffCoeff != -1) { - consensus.vDeployments[d].nFalloffCoeff = nFalloffCoeff; - } -} - -void CChainParams::UpdateDIP3Parameters(int nActivationHeight, int nEnforcementHeight) -{ - consensus.DIP0003Height = nActivationHeight; - consensus.DIP0003EnforcementHeight = nEnforcementHeight; -} - -void CChainParams::UpdateDIP8Parameters(int nActivationHeight) -{ - consensus.DIP0008Height = nActivationHeight; -} - -void CChainParams::UpdateBudgetParameters(int nMasternodePaymentsStartBlock, int nBudgetPaymentsStartBlock, int nSuperblockStartBlock) -{ - consensus.nMasternodePaymentsStartBlock = nMasternodePaymentsStartBlock; - consensus.nBudgetPaymentsStartBlock = nBudgetPaymentsStartBlock; - consensus.nSuperblockStartBlock = nSuperblockStartBlock; -} - -void CChainParams::UpdateSubsidyAndDiffParams(int nMinimumDifficultyBlocks, int nHighSubsidyBlocks, int nHighSubsidyFactor) -{ - consensus.nMinimumDifficultyBlocks = nMinimumDifficultyBlocks; - consensus.nHighSubsidyBlocks = nHighSubsidyBlocks; - consensus.nHighSubsidyFactor = nHighSubsidyFactor; -} - -void CChainParams::UpdateLLMQChainLocks(Consensus::LLMQType llmqType) { - consensus.llmqTypeChainLocks = llmqType; -} - -void CChainParams::UpdateLLMQInstantSend(Consensus::LLMQType llmqType) { - consensus.llmqTypeInstantSend = llmqType; -} - -void CChainParams::UpdateLLMQTestParams(int size, int threshold) { - auto& params = consensus.llmqs.at(Consensus::LLMQ_TEST); - params.size = size; - params.minSize = threshold; - params.threshold = threshold; - params.dkgBadVotesThreshold = threshold; -} - -void CChainParams::UpdateLLMQDevnetParams(int size, int threshold) -{ - auto& params = consensus.llmqs.at(Consensus::LLMQ_DEVNET); - params.size = size; - params.minSize = threshold; - params.threshold = threshold; - params.dkgBadVotesThreshold = threshold; -} - static CBlock FindDevNetGenesisBlock(const CBlock &prevBlock, const CAmount& reward) { std::string devNetName = gArgs.GetDevNetName(); @@ -705,7 +640,7 @@ class CTestNetParams : public CChainParams { */ class CDevNetParams : public CChainParams { public: - CDevNetParams(bool fHelpOnly = false) { + explicit CDevNetParams(const ArgsManager& args) { strNetworkID = "devnet"; consensus.nSubsidyHalvingInterval = 210240; consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock @@ -807,15 +742,14 @@ class CDevNetParams : public CChainParams { nDefaultPort = 19799; nPruneAfterHeight = 1000; + UpdateDevnetSubsidyAndDiffParametersFromArgs(args); genesis = CreateGenesisBlock(1417713337, 1096447, 0x207fffff, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")); assert(genesis.hashMerkleRoot == uint256S("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7")); - if (!fHelpOnly) { - devnetGenesis = FindDevNetGenesisBlock(genesis, 50 * COIN); - consensus.hashDevnetGenesisBlock = devnetGenesis.GetHash(); - } + devnetGenesis = FindDevNetGenesisBlock(genesis, 50 * COIN); + consensus.hashDevnetGenesisBlock = devnetGenesis.GetHash(); vFixedSeeds.clear(); vSeeds.clear(); @@ -845,6 +779,10 @@ class CDevNetParams : public CChainParams { consensus.llmqTypeInstantSend = Consensus::LLMQ_50_60; consensus.llmqTypePlatform = Consensus::LLMQ_100_67; + UpdateDevnetLLMQChainLocksFromArgs(args); + UpdateDevnetLLMQInstantSendFromArgs(args); + UpdateLLMQDevnetParametersFromArgs(args); + fDefaultConsistencyChecks = false; fRequireStandard = false; fRequireRoutableExternalIP = true; @@ -875,6 +813,48 @@ class CDevNetParams : public CChainParams { 0.01 // * estimated number of transactions per second }; } + + /** + * Allows modifying the subsidy and difficulty devnet parameters. + */ + void UpdateDevnetSubsidyAndDiffParameters(int nMinimumDifficultyBlocks, int nHighSubsidyBlocks, int nHighSubsidyFactor) + { + consensus.nMinimumDifficultyBlocks = nMinimumDifficultyBlocks; + consensus.nHighSubsidyBlocks = nHighSubsidyBlocks; + consensus.nHighSubsidyFactor = nHighSubsidyFactor; + } + void UpdateDevnetSubsidyAndDiffParametersFromArgs(const ArgsManager& args); + + /** + * Allows modifying the LLMQ type for ChainLocks. + */ + void UpdateDevnetLLMQChainLocks(Consensus::LLMQType llmqType) + { + consensus.llmqTypeChainLocks = llmqType; + } + void UpdateDevnetLLMQChainLocksFromArgs(const ArgsManager& args); + + /** + * Allows modifying the LLMQ type for InstantSend. + */ + void UpdateDevnetLLMQInstantSend(Consensus::LLMQType llmqType) + { + consensus.llmqTypeInstantSend = llmqType; + } + void UpdateDevnetLLMQInstantSendFromArgs(const ArgsManager& args); + + /** + * Allows modifying parameters of the devnet LLMQ + */ + void UpdateLLMQDevnetParameters(int size, int threshold) + { + auto& params = consensus.llmqs.at(Consensus::LLMQ_DEVNET); + params.size = size; + params.minSize = threshold; + params.threshold = threshold; + params.dkgBadVotesThreshold = threshold; + } + void UpdateLLMQDevnetParametersFromArgs(const ArgsManager& args); }; /** @@ -882,7 +862,7 @@ class CDevNetParams : public CChainParams { */ class CRegTestParams : public CChainParams { public: - CRegTestParams() { + explicit CRegTestParams(const ArgsManager& args) { strNetworkID = "regtest"; consensus.nSubsidyHalvingInterval = 150; consensus.nMasternodePaymentsStartBlock = 240; @@ -963,6 +943,11 @@ class CRegTestParams : public CChainParams { nDefaultPort = 19899; nPruneAfterHeight = 1000; + UpdateVersionBitsParametersFromArgs(args); + UpdateDIP3ParametersFromArgs(args); + UpdateDIP8ParametersFromArgs(args); + UpdateBudgetParametersFromArgs(args); + genesis = CreateGenesisBlock(1417713337, 1096447, 0x207fffff, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")); @@ -1021,76 +1006,303 @@ class CRegTestParams : public CChainParams { consensus.llmqTypeChainLocks = Consensus::LLMQ_TEST; consensus.llmqTypeInstantSend = Consensus::LLMQ_TEST; consensus.llmqTypePlatform = Consensus::LLMQ_TEST; + + UpdateLLMQTestParametersFromArgs(args); } -}; -static std::unique_ptr globalChainParams; + /** + * Allows modifying the Version Bits regtest parameters. + */ + void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout, int64_t nWindowSize, int64_t nThresholdStart, int64_t nThresholdMin, int64_t nFalloffCoeff) + { + consensus.vDeployments[d].nStartTime = nStartTime; + consensus.vDeployments[d].nTimeout = nTimeout; + if (nWindowSize != -1) { + consensus.vDeployments[d].nWindowSize = nWindowSize; + } + if (nThresholdStart != -1) { + consensus.vDeployments[d].nThresholdStart = nThresholdStart; + } + if (nThresholdMin != -1) { + consensus.vDeployments[d].nThresholdMin = nThresholdMin; + } + if (nFalloffCoeff != -1) { + consensus.vDeployments[d].nFalloffCoeff = nFalloffCoeff; + } + } + void UpdateVersionBitsParametersFromArgs(const ArgsManager& args); + + /** + * Allows modifying the DIP3 activation and enforcement height + */ + void UpdateDIP3Parameters(int nActivationHeight, int nEnforcementHeight) + { + consensus.DIP0003Height = nActivationHeight; + consensus.DIP0003EnforcementHeight = nEnforcementHeight; + } + void UpdateDIP3ParametersFromArgs(const ArgsManager& args); + + /** + * Allows modifying the DIP8 activation height + */ + void UpdateDIP8Parameters(int nActivationHeight) + { + consensus.DIP0008Height = nActivationHeight; + } + void UpdateDIP8ParametersFromArgs(const ArgsManager& args); + + /** + * Allows modifying the budget regtest parameters. + */ + void UpdateBudgetParameters(int nMasternodePaymentsStartBlock, int nBudgetPaymentsStartBlock, int nSuperblockStartBlock) + { + consensus.nMasternodePaymentsStartBlock = nMasternodePaymentsStartBlock; + consensus.nBudgetPaymentsStartBlock = nBudgetPaymentsStartBlock; + consensus.nSuperblockStartBlock = nSuperblockStartBlock; + } + void UpdateBudgetParametersFromArgs(const ArgsManager& args); + + /** + * Allows modifying parameters of the test LLMQ + */ + void UpdateLLMQTestParameters(int size, int threshold) + { + auto& params = consensus.llmqs.at(Consensus::LLMQ_TEST); + params.size = size; + params.minSize = threshold; + params.threshold = threshold; + params.dkgBadVotesThreshold = threshold; + } + void UpdateLLMQTestParametersFromArgs(const ArgsManager& args); +}; -const CChainParams &Params() { - assert(globalChainParams); - return *globalChainParams; +void CRegTestParams::UpdateVersionBitsParametersFromArgs(const ArgsManager& args) +{ + if (!args.IsArgSet("-vbparams")) return; + + for (const std::string& strDeployment : args.GetArgs("-vbparams")) { + std::vector vDeploymentParams; + boost::split(vDeploymentParams, strDeployment, boost::is_any_of(":")); + if (vDeploymentParams.size() != 3 && vDeploymentParams.size() != 5 && vDeploymentParams.size() != 7) { + throw std::runtime_error("Version bits parameters malformed, expecting " + ":: or " + ":::: or " + "::::::"); + } + int64_t nStartTime, nTimeout, nWindowSize = -1, nThresholdStart = -1, nThresholdMin = -1, nFalloffCoeff = -1; + if (!ParseInt64(vDeploymentParams[1], &nStartTime)) { + throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1])); + } + if (!ParseInt64(vDeploymentParams[2], &nTimeout)) { + throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2])); + } + if (vDeploymentParams.size() >= 5) { + if (!ParseInt64(vDeploymentParams[3], &nWindowSize)) { + throw std::runtime_error(strprintf("Invalid nWindowSize (%s)", vDeploymentParams[3])); + } + if (!ParseInt64(vDeploymentParams[4], &nThresholdStart)) { + throw std::runtime_error(strprintf("Invalid nThresholdStart (%s)", vDeploymentParams[4])); + } + } + if (vDeploymentParams.size() == 7) { + if (!ParseInt64(vDeploymentParams[5], &nThresholdMin)) { + throw std::runtime_error(strprintf("Invalid nThresholdMin (%s)", vDeploymentParams[5])); + } + if (!ParseInt64(vDeploymentParams[6], &nFalloffCoeff)) { + throw std::runtime_error(strprintf("Invalid nFalloffCoeff (%s)", vDeploymentParams[6])); + } + } + bool found = false; + for (int j=0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) { + if (vDeploymentParams[0] == VersionBitsDeploymentInfo[j].name) { + UpdateVersionBitsParameters(Consensus::DeploymentPos(j), nStartTime, nTimeout, nWindowSize, nThresholdStart, nThresholdMin, nFalloffCoeff); + found = true; + LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld, window=%ld, thresholdstart=%ld, thresholdmin=%ld, falloffcoeff=%ld\n", + vDeploymentParams[0], nStartTime, nTimeout, nWindowSize, nThresholdStart, nThresholdMin, nFalloffCoeff); + break; + } + } + if (!found) { + throw std::runtime_error(strprintf("Invalid deployment (%s)", vDeploymentParams[0])); + } + } } -std::unique_ptr CreateChainParams(const std::string& chain, bool fHelpOnly) +void CRegTestParams::UpdateDIP3ParametersFromArgs(const ArgsManager& args) { - if (chain == CBaseChainParams::MAIN) - return std::unique_ptr(new CMainParams()); - else if (chain == CBaseChainParams::TESTNET) - return std::unique_ptr(new CTestNetParams()); - else if (chain == CBaseChainParams::DEVNET) { - return std::unique_ptr(new CDevNetParams(fHelpOnly)); - } else if (chain == CBaseChainParams::REGTEST) - return std::unique_ptr(new CRegTestParams()); - throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); + if (!args.IsArgSet("-dip3params")) return; + + std::string strParams = args.GetArg("-dip3params", ""); + std::vector vParams; + boost::split(vParams, strParams, boost::is_any_of(":")); + if (vParams.size() != 2) { + throw std::runtime_error("DIP3 parameters malformed, expecting :"); + } + int nDIP3ActivationHeight, nDIP3EnforcementHeight; + if (!ParseInt32(vParams[0], &nDIP3ActivationHeight)) { + throw std::runtime_error(strprintf("Invalid activation height (%s)", vParams[0])); + } + if (!ParseInt32(vParams[1], &nDIP3EnforcementHeight)) { + throw std::runtime_error(strprintf("Invalid enforcement height (%s)", vParams[1])); + } + LogPrintf("Setting DIP3 parameters to activation=%ld, enforcement=%ld\n", nDIP3ActivationHeight, nDIP3EnforcementHeight); + UpdateDIP3Parameters(nDIP3ActivationHeight, nDIP3EnforcementHeight); } -void SelectParams(const std::string& network) +void CRegTestParams::UpdateDIP8ParametersFromArgs(const ArgsManager& args) { - SelectBaseParams(network); - globalChainParams = CreateChainParams(network); + if (!args.IsArgSet("-dip8params")) return; + + std::string strParams = args.GetArg("-dip8params", ""); + std::vector vParams; + boost::split(vParams, strParams, boost::is_any_of(":")); + if (vParams.size() != 1) { + throw std::runtime_error("DIP8 parameters malformed, expecting "); + } + int nDIP8ActivationHeight; + if (!ParseInt32(vParams[0], &nDIP8ActivationHeight)) { + throw std::runtime_error(strprintf("Invalid activation height (%s)", vParams[0])); + } + LogPrintf("Setting DIP8 parameters to activation=%ld\n", nDIP8ActivationHeight); + UpdateDIP8Parameters(nDIP8ActivationHeight); } -void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout, int64_t nWindowSize, int64_t nThresholdStart, int64_t nThresholdMin, int64_t nFalloffCoeff) +void CRegTestParams::UpdateBudgetParametersFromArgs(const ArgsManager& args) { - globalChainParams->UpdateVersionBitsParameters(d, nStartTime, nTimeout, nWindowSize, nThresholdStart, nThresholdMin, nFalloffCoeff); + if (!args.IsArgSet("-budgetparams")) return; + + std::string strParams = args.GetArg("-budgetparams", ""); + std::vector vParams; + boost::split(vParams, strParams, boost::is_any_of(":")); + if (vParams.size() != 3) { + throw std::runtime_error("Budget parameters malformed, expecting ::"); + } + int nMasternodePaymentsStartBlock, nBudgetPaymentsStartBlock, nSuperblockStartBlock; + if (!ParseInt32(vParams[0], &nMasternodePaymentsStartBlock)) { + throw std::runtime_error(strprintf("Invalid masternode start height (%s)", vParams[0])); + } + if (!ParseInt32(vParams[1], &nBudgetPaymentsStartBlock)) { + throw std::runtime_error(strprintf("Invalid budget start block (%s)", vParams[1])); + } + if (!ParseInt32(vParams[2], &nSuperblockStartBlock)) { + throw std::runtime_error(strprintf("Invalid superblock start height (%s)", vParams[2])); + } + LogPrintf("Setting budget parameters to masternode=%ld, budget=%ld, superblock=%ld\n", nMasternodePaymentsStartBlock, nBudgetPaymentsStartBlock, nSuperblockStartBlock); + UpdateBudgetParameters(nMasternodePaymentsStartBlock, nBudgetPaymentsStartBlock, nSuperblockStartBlock); } -void UpdateDIP3Parameters(int nActivationHeight, int nEnforcementHeight) +void CRegTestParams::UpdateLLMQTestParametersFromArgs(const ArgsManager& args) { - globalChainParams->UpdateDIP3Parameters(nActivationHeight, nEnforcementHeight); + if (!args.IsArgSet("-llmqtestparams")) return; + + std::string strParams = args.GetArg("-llmqtestparams", ""); + std::vector vParams; + boost::split(vParams, strParams, boost::is_any_of(":")); + if (vParams.size() != 2) { + throw std::runtime_error("LLMQ_TEST parameters malformed, expecting :"); + } + int size, threshold; + if (!ParseInt32(vParams[0], &size)) { + throw std::runtime_error(strprintf("Invalid LLMQ_TEST size (%s)", vParams[0])); + } + if (!ParseInt32(vParams[1], &threshold)) { + throw std::runtime_error(strprintf("Invalid LLMQ_TEST threshold (%s)", vParams[1])); + } + LogPrintf("Setting LLMQ_TEST parameters to size=%ld, threshold=%ld\n", size, threshold); + UpdateLLMQTestParameters(size, threshold); } -void UpdateDIP8Parameters(int nActivationHeight) +void CDevNetParams::UpdateDevnetSubsidyAndDiffParametersFromArgs(const ArgsManager& args) { - globalChainParams->UpdateDIP8Parameters(nActivationHeight); + if (!args.IsArgSet("-minimumdifficultyblocks") && !args.IsArgSet("-highsubsidyblocks") && !args.IsArgSet("-highsubsidyfactor")) return; + + int nMinimumDifficultyBlocks = gArgs.GetArg("-minimumdifficultyblocks", consensus.nMinimumDifficultyBlocks); + int nHighSubsidyBlocks = gArgs.GetArg("-highsubsidyblocks", consensus.nHighSubsidyBlocks); + int nHighSubsidyFactor = gArgs.GetArg("-highsubsidyfactor", consensus.nHighSubsidyFactor); + LogPrintf("Setting minimumdifficultyblocks=%ld, highsubsidyblocks=%ld, highsubsidyfactor=%ld\n", nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor); + UpdateDevnetSubsidyAndDiffParameters(nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor); } -void UpdateBudgetParameters(int nMasternodePaymentsStartBlock, int nBudgetPaymentsStartBlock, int nSuperblockStartBlock) +void CDevNetParams::UpdateDevnetLLMQChainLocksFromArgs(const ArgsManager& args) { - globalChainParams->UpdateBudgetParameters(nMasternodePaymentsStartBlock, nBudgetPaymentsStartBlock, nSuperblockStartBlock); + if (!args.IsArgSet("-llmqchainlocks")) return; + + std::string strLLMQType = gArgs.GetArg("-llmqchainlocks", consensus.llmqs.at(consensus.llmqTypeChainLocks).name); + Consensus::LLMQType llmqType = Consensus::LLMQ_NONE; + for (const auto& p : consensus.llmqs) { + if (p.second.name == strLLMQType) { + llmqType = p.first; + } + } + if (llmqType == Consensus::LLMQ_NONE) { + throw std::runtime_error("Invalid LLMQ type specified for -llmqchainlocks."); + } + LogPrintf("Setting llmqchainlocks to size=%ld\n", llmqType); + UpdateDevnetLLMQChainLocks(llmqType); } -void UpdateDevnetSubsidyAndDiffParams(int nMinimumDifficultyBlocks, int nHighSubsidyBlocks, int nHighSubsidyFactor) +void CDevNetParams::UpdateDevnetLLMQInstantSendFromArgs(const ArgsManager& args) { - globalChainParams->UpdateSubsidyAndDiffParams(nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor); + if (!args.IsArgSet("-llmqinstantsend")) return; + + std::string strLLMQType = gArgs.GetArg("-llmqinstantsend", consensus.llmqs.at(consensus.llmqTypeInstantSend).name); + Consensus::LLMQType llmqType = Consensus::LLMQ_NONE; + for (const auto& p : consensus.llmqs) { + if (p.second.name == strLLMQType) { + llmqType = p.first; + } + } + if (llmqType == Consensus::LLMQ_NONE) { + throw std::runtime_error("Invalid LLMQ type specified for -llmqinstantsend."); + } + LogPrintf("Setting llmqinstantsend to size=%ld\n", llmqType); + UpdateDevnetLLMQInstantSend(llmqType); } -void UpdateDevnetLLMQChainLocks(Consensus::LLMQType llmqType) +void CDevNetParams::UpdateLLMQDevnetParametersFromArgs(const ArgsManager& args) { - globalChainParams->UpdateLLMQChainLocks(llmqType); + if (!args.IsArgSet("-llmqdevnetparams")) return; + + std::string strParams = args.GetArg("-llmqdevnetparams", ""); + std::vector vParams; + boost::split(vParams, strParams, boost::is_any_of(":")); + if (vParams.size() != 2) { + throw std::runtime_error("LLMQ_DEVNET parameters malformed, expecting :"); + } + int size, threshold; + if (!ParseInt32(vParams[0], &size)) { + throw std::runtime_error(strprintf("Invalid LLMQ_DEVNET size (%s)", vParams[0])); + } + if (!ParseInt32(vParams[1], &threshold)) { + throw std::runtime_error(strprintf("Invalid LLMQ_DEVNET threshold (%s)", vParams[1])); + } + LogPrintf("Setting LLMQ_DEVNET parameters to size=%ld, threshold=%ld\n", size, threshold); + UpdateLLMQDevnetParameters(size, threshold); } -void UpdateDevnetLLMQInstantSend(Consensus::LLMQType llmqType) -{ - globalChainParams->UpdateLLMQInstantSend(llmqType); +static std::unique_ptr globalChainParams; + +const CChainParams &Params() { + assert(globalChainParams); + return *globalChainParams; } -void UpdateLLMQTestParams(int size, int threshold) +std::unique_ptr CreateChainParams(const std::string& chain) { - globalChainParams->UpdateLLMQTestParams(size, threshold); + if (chain == CBaseChainParams::MAIN) + return std::unique_ptr(new CMainParams()); + else if (chain == CBaseChainParams::TESTNET) + return std::unique_ptr(new CTestNetParams()); + else if (chain == CBaseChainParams::DEVNET) { + return std::unique_ptr(new CDevNetParams(gArgs)); + } else if (chain == CBaseChainParams::REGTEST) + return std::unique_ptr(new CRegTestParams(gArgs)); + + throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); } -void UpdateLLMQDevnetParams(int size, int threshold) +void SelectParams(const std::string& network) { - globalChainParams->UpdateLLMQDevnetParams(size, threshold); + SelectBaseParams(network); + globalChainParams = CreateChainParams(network); } diff --git a/src/chainparams.h b/src/chainparams.h index ce30aaad77c2..9fa138421e3e 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -87,7 +87,6 @@ class CChainParams const std::vector& FixedSeeds() const { return vFixedSeeds; } const CCheckpointData& Checkpoints() const { return checkpointData; } const ChainTxData& TxData() const { return chainTxData; } - void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout, int64_t nWindowSize, int64_t nThresholdStart, int64_t nThresholdMin, int64_t nFalloffCoeff); void UpdateDIP3Parameters(int nActivationHeight, int nEnforcementHeight); void UpdateDIP8Parameters(int nActivationHeight); void UpdateBudgetParameters(int nMasternodePaymentsStartBlock, int nBudgetPaymentsStartBlock, int nSuperblockStartBlock); @@ -138,7 +137,7 @@ class CChainParams * @returns a CChainParams* of the chosen chain. * @throws a std::runtime_error if the chain is not supported. */ -std::unique_ptr CreateChainParams(const std::string& chain, bool fHelpOnly = false); +std::unique_ptr CreateChainParams(const std::string& chain); /** * Return the currently selected parameters. This won't change after app @@ -152,49 +151,4 @@ const CChainParams &Params(); */ void SelectParams(const std::string& chain); -/** - * Allows modifying the Version Bits regtest parameters. - */ -void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout, int64_t nWindowSize, int64_t nThresholdStart, int64_t nThresholdMin, int64_t nFalloffCoeff); - -/** - * Allows modifying the DIP3 activation and enforcement height - */ -void UpdateDIP3Parameters(int nActivationHeight, int nEnforcementHeight); - -/** - * Allows modifying the DIP8 activation height - */ -void UpdateDIP8Parameters(int nActivationHeight); - -/** - * Allows modifying the budget regtest parameters. - */ -void UpdateBudgetParameters(int nMasternodePaymentsStartBlock, int nBudgetPaymentsStartBlock, int nSuperblockStartBlock); - -/** - * Allows modifying the subsidy and difficulty devnet parameters. - */ -void UpdateDevnetSubsidyAndDiffParams(int nMinimumDifficultyBlocks, int nHighSubsidyBlocks, int nHighSubsidyFactor); - -/** - * Allows modifying the LLMQ type for ChainLocks. - */ -void UpdateDevnetLLMQChainLocks(Consensus::LLMQType llmqType); - -/** - * Allows modifying the LLMQ type for InstantSend. - */ -void UpdateDevnetLLMQInstantSend(Consensus::LLMQType llmqType); - -/** - * Allows modifying parameters of the test LLMQ - */ -void UpdateLLMQTestParams(int size, int threshold); - -/** - * Allows modifying parameters of the devnet LLMQ - */ -void UpdateLLMQDevnetParams(int size, int threshold); - #endif // BITCOIN_CHAINPARAMS_H diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index fa504c4b6a84..507eb136c03e 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -18,10 +18,24 @@ const std::string CBaseChainParams::REGTEST = "regtest"; void SetupChainParamsBaseOptions() { + gArgs.AddArg("-budgetparams=::", "Override masternode, budget and superblock start heights (regtest-only)", true, OptionsCategory::CHAINPARAMS); gArgs.AddArg("-devnet=", "Use devnet chain with provided name", false, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-dip3params=:", "Override DIP3 activation and enforcement heights (regtest-only)", true, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-dip8params=", "Override DIP8 activation height (regtest-only)", true, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-highsubsidyblocks=", "The number of blocks with a higher than normal subsidy to mine at the start of a chain (default: 0, devnet-only)", false, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-highsubsidyfactor=", "The factor to multiply the normal block subsidy by while in the highsubsidyblocks window of a chain (default: 1, devnet-only)", false, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-llmqchainlocks=", "Override the default LLMQ type used for ChainLocks. Allows using ChainLocks with smaller LLMQs. (default: llmq_50_60, devnet-only)", false, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-llmqdevnetparams=:", "Override the default LLMQ size for the LLMQ_DEVNET quorum (default: 3:2, devnet-only)", false, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-llmqinstantsend=", "Override the default LLMQ type used for InstantSend. Allows using InstantSend with smaller LLMQs. (default: llmq_50_60, devnet-only)", false, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-llmqtestparams=:", "Override the default LLMQ size for the LLMQ_TEST quorum (default: 10:6, regtest-only)", true, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-minimumdifficultyblocks=", "The number of blocks that can be mined with the minimum difficulty at the start of a chain (default: 0, devnet-only)", false, OptionsCategory::CHAINPARAMS); gArgs.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. " "This is intended for regression testing tools and app development.", true, OptionsCategory::CHAINPARAMS); gArgs.AddArg("-testnet", "Use the test chain", false, OptionsCategory::CHAINPARAMS); + gArgs.AddArg("-vbparams=::(::(::))", + "Use given start/end times for specified version bits deployment (regtest-only). " + "Specifying window, threshold/thresholdstart, thresholdmin and falloffcoeff is optional.", true, OptionsCategory::CHAINPARAMS); + } static std::unique_ptr globalChainBaseParams; diff --git a/src/init.cpp b/src/init.cpp index c6bf4d13386a..bb8b42c6997e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -477,11 +477,6 @@ void SetupServerArgs() const auto defaultChainParams = CreateChainParams(CBaseChainParams::MAIN); const auto testnetChainParams = CreateChainParams(CBaseChainParams::TESTNET); - Consensus::Params devnetConsensus = CreateChainParams(CBaseChainParams::DEVNET, true)->GetConsensus(); - Consensus::LLMQParams devnetLLMQ = devnetConsensus.llmqs.at(Consensus::LLMQ_DEVNET); - - const auto regtestLLMQ = CreateChainParams(CBaseChainParams::REGTEST)->GetConsensus().llmqs.at(Consensus::LLMQ_TEST); - // Hidden Options std::vector hidden_args = {"-rpcssl", "-benchmark", "-h", "-help", "-socks", "-tor", "-debugnet", "-whitelistalwaysrelay", "-blockminsize", "-dbcrashratio", "-forcecompactdb", @@ -644,24 +639,14 @@ void SetupServerArgs() gArgs.AddArg("-limitdescendantsize=", strprintf("Do not accept transactions if any ancestor would have more than kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT), true, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT), true, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-stopatheight", strprintf("Stop running after reaching the given height in the main chain (default: %u)", DEFAULT_STOPATHEIGHT), true, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-vbparams=::(::)", "Use given start/end times for specified version bits deployment (regtest-only). Specifying window and threshold is optional.", true, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-watchquorums=", strprintf("Watch and validate quorum communication (default: %u)", llmq::DEFAULT_WATCH_QUORUMS), true, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-addrmantest", "Allows to test address relay on localhost", true, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-budgetparams=::", "Override masternode, budget and superblock start heights", false, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-debug=", "Output debugging information (default: -nodebug, supplying is optional). " "If is not supplied or if = 1, output all debugging information. can be: " + ListLogCategories() + ".", false, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-debugexclude=", strprintf("Exclude debugging information for a category. Can be used in conjunction with -debug=1 to output debug logs for all categories except one or more specified categories."), false, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-dip3params=:", "Override DIP3 activation and enforcement heights", false, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-dip8params=", "Override DIP8 activation height", false, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-disablegovernance", strprintf("Disable governance validation (0-1, default: %u)", 0), false, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-help-debug", "Print help message with debugging options and exit", false, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-highsubsidyblocks=", strprintf("The number of blocks with a higher than normal subsidy to mine at the start of a devnet (default: %u)", devnetConsensus.nHighSubsidyBlocks), false, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-highsubsidyfactor=", strprintf("The factor to multiply the normal block subsidy by while in the highsubsidyblocks window of a devnet (default: %u)", devnetConsensus.nHighSubsidyFactor), false, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-llmqchainlocks=", strprintf("Override the default LLMQ type used for ChainLocks on a devnet. Allows using ChainLocks with smaller LLMQs. (default: %s)", devnetConsensus.llmqs.at(devnetConsensus.llmqTypeChainLocks).name), false, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-llmqdevnetparams=", strprintf("Override the default LLMQ size for the LLMQ_DEVNET quorum (default: %u:%u)", devnetLLMQ.size, devnetLLMQ.threshold), false, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-llmqinstantsend=", strprintf("Override the default LLMQ type used for InstantSend on a devnet. Allows using InstantSend with smaller LLMQs. (default: %s)", devnetConsensus.llmqs.at(devnetConsensus.llmqTypeInstantSend).name), false, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-llmqtestparams=", strprintf("Override the default LLMQ size for the LLMQ_TEST quorum (default: %u:%u)", regtestLLMQ.size, regtestLLMQ.threshold), false, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-logips", strprintf("Include IP addresses in debug output (default: %u)", DEFAULT_LOGIPS), false, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-logtimemicros", strprintf("Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS), true, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-logtimestamps", strprintf("Prepend debug output with timestamp (default: %u)", DEFAULT_LOGTIMESTAMPS), false, OptionsCategory::DEBUG_TEST); @@ -671,7 +656,6 @@ void SetupServerArgs() gArgs.AddArg("-mocktime=", "Replace actual time with seconds since epoch (default: 0)", true, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-maxtxfee=", strprintf("Maximum total fees (in %s) to use in a single wallet transaction or raw transaction; setting this too low may abort large transactions (default: %s)", CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)), false, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-minimumdifficultyblocks=", strprintf("The number of blocks that can be mined with the minimum difficulty at the start of a devnet (default: %u)", devnetConsensus.nMinimumDifficultyBlocks), false, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-minsporkkeys=", "Overrides minimum spork signers to change spork value. Only useful for regtest and devnet. Using this on mainnet or testnet will ban you.", false, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-printpriority", strprintf("Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY), true, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-printtoconsole", "Send trace/debug info to console (default: 1 when no -daemon. To disable logging to file, set -nodebuglogfile)", false, OptionsCategory::DEBUG_TEST); @@ -1481,177 +1465,6 @@ bool AppInitParameterInteraction() nMaxTipAge = gArgs.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); - if (gArgs.IsArgSet("-vbparams")) { - // Allow overriding version bits parameters for testing - if (!chainparams.MineBlocksOnDemand()) { - return InitError("Version bits parameters may only be overridden on regtest."); - } - for (const std::string& strDeployment : gArgs.GetArgs("-vbparams")) { - std::vector vDeploymentParams; - boost::split(vDeploymentParams, strDeployment, boost::is_any_of(":")); - if (vDeploymentParams.size() != 3 && vDeploymentParams.size() != 5 && vDeploymentParams.size() != 7) { - return InitError("Version bits parameters malformed, expecting deployment:start:end or deployment:start:end:window:threshold or deployment:start:end:window:thresholdstart:thresholdmin:falloffcoeff"); - } - int64_t nStartTime, nTimeout, nWindowSize = -1, nThresholdStart = -1, nThresholdMin = -1, nFalloffCoeff = -1; - if (!ParseInt64(vDeploymentParams[1], &nStartTime)) { - return InitError(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1])); - } - if (!ParseInt64(vDeploymentParams[2], &nTimeout)) { - return InitError(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2])); - } - if (vDeploymentParams.size() >= 5) { - if (!ParseInt64(vDeploymentParams[3], &nWindowSize)) { - return InitError(strprintf("Invalid nWindowSize (%s)", vDeploymentParams[3])); - } - if (!ParseInt64(vDeploymentParams[4], &nThresholdStart)) { - return InitError(strprintf("Invalid nThresholdStart (%s)", vDeploymentParams[4])); - } - } - if (vDeploymentParams.size() == 7) { - if (!ParseInt64(vDeploymentParams[5], &nThresholdMin)) { - return InitError(strprintf("Invalid nThresholdMin (%s)", vDeploymentParams[5])); - } - if (!ParseInt64(vDeploymentParams[6], &nFalloffCoeff)) { - return InitError(strprintf("Invalid nFalloffCoeff (%s)", vDeploymentParams[6])); - } - } - bool found = false; - for (int j=0; j<(int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) - { - if (vDeploymentParams[0].compare(VersionBitsDeploymentInfo[j].name) == 0) { - UpdateVersionBitsParameters(Consensus::DeploymentPos(j), nStartTime, nTimeout, nWindowSize, nThresholdStart, nThresholdMin, nFalloffCoeff); - found = true; - LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld, window=%ld, thresholdstart=%ld, thresholdmin=%ld, falloffcoeff=%ld\n", - vDeploymentParams[0], nStartTime, nTimeout, nWindowSize, nThresholdStart, nThresholdMin, nFalloffCoeff); - break; - } - } - if (!found) { - return InitError(strprintf("Invalid deployment (%s)", vDeploymentParams[0])); - } - } - } - - if (gArgs.IsArgSet("-dip3params")) { - // Allow overriding dip3 parameters for testing - if (!chainparams.MineBlocksOnDemand()) { - return InitError("DIP3 parameters may only be overridden on regtest."); - } - std::string strDIP3Params = gArgs.GetArg("-dip3params", ""); - std::vector vDIP3Params; - boost::split(vDIP3Params, strDIP3Params, boost::is_any_of(":")); - if (vDIP3Params.size() != 2) { - return InitError("DIP3 parameters malformed, expecting DIP3ActivationHeight:DIP3EnforcementHeight"); - } - int nDIP3ActivationHeight, nDIP3EnforcementHeight; - if (!ParseInt32(vDIP3Params[0], &nDIP3ActivationHeight)) { - return InitError(strprintf("Invalid nDIP3ActivationHeight (%s)", vDIP3Params[0])); - } - if (!ParseInt32(vDIP3Params[1], &nDIP3EnforcementHeight)) { - return InitError(strprintf("Invalid nDIP3EnforcementHeight (%s)", vDIP3Params[1])); - } - UpdateDIP3Parameters(nDIP3ActivationHeight, nDIP3EnforcementHeight); - } - - if (gArgs.IsArgSet("-dip8params")) { - // Allow overriding dip8 activation height for testing - if (!chainparams.MineBlocksOnDemand()) { - return InitError("DIP8 activation height may only be overridden on regtest."); - } - UpdateDIP8Parameters(gArgs.GetArg("-dip8params", Params().GetConsensus().DIP0008Height)); - } - - if (gArgs.IsArgSet("-budgetparams")) { - // Allow overriding budget parameters for testing - if (!chainparams.MineBlocksOnDemand()) { - return InitError("Budget parameters may only be overridden on regtest."); - } - - std::string strBudgetParams = gArgs.GetArg("-budgetparams", ""); - std::vector vBudgetParams; - boost::split(vBudgetParams, strBudgetParams, boost::is_any_of(":")); - if (vBudgetParams.size() != 3) { - return InitError("Budget parameters malformed, expecting masternodePaymentsStartBlock:budgetPaymentsStartBlock:superblockStartBlock"); - } - int nMasternodePaymentsStartBlock, nBudgetPaymentsStartBlock, nSuperblockStartBlock; - if (!ParseInt32(vBudgetParams[0], &nMasternodePaymentsStartBlock)) { - return InitError(strprintf("Invalid nMasternodePaymentsStartBlock (%s)", vBudgetParams[0])); - } - if (!ParseInt32(vBudgetParams[1], &nBudgetPaymentsStartBlock)) { - return InitError(strprintf("Invalid nBudgetPaymentsStartBlock (%s)", vBudgetParams[1])); - } - if (!ParseInt32(vBudgetParams[2], &nSuperblockStartBlock)) { - return InitError(strprintf("Invalid nSuperblockStartBlock (%s)", vBudgetParams[2])); - } - UpdateBudgetParameters(nMasternodePaymentsStartBlock, nBudgetPaymentsStartBlock, nSuperblockStartBlock); - } - - if (chainparams.NetworkIDString() == CBaseChainParams::DEVNET) { - int nMinimumDifficultyBlocks = gArgs.GetArg("-minimumdifficultyblocks", chainparams.GetConsensus().nMinimumDifficultyBlocks); - int nHighSubsidyBlocks = gArgs.GetArg("-highsubsidyblocks", chainparams.GetConsensus().nHighSubsidyBlocks); - int nHighSubsidyFactor = gArgs.GetArg("-highsubsidyfactor", chainparams.GetConsensus().nHighSubsidyFactor); - UpdateDevnetSubsidyAndDiffParams(nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor); - } else if (gArgs.IsArgSet("-minimumdifficultyblocks") || gArgs.IsArgSet("-highsubsidyblocks") || gArgs.IsArgSet("-highsubsidyfactor")) { - return InitError("Difficulty and subsidy parameters may only be overridden on devnet."); - } - - if (chainparams.NetworkIDString() == CBaseChainParams::DEVNET) { - std::string strLLMQTypeChainLocks = gArgs.GetArg("-llmqchainlocks", llmq::GetLLMQParams(Params().GetConsensus().llmqTypeChainLocks).name); - std::string strLLMQTypeInstantSend = gArgs.GetArg("-llmqinstantsend", llmq::GetLLMQParams(Params().GetConsensus().llmqTypeInstantSend).name); - Consensus::LLMQType llmqTypeChainLocks = Consensus::LLMQ_NONE; - Consensus::LLMQType llmqTypeInstantSend = Consensus::LLMQ_NONE; - for (const auto& p : Params().GetConsensus().llmqs) { - if (p.second.name == strLLMQTypeChainLocks) { - llmqTypeChainLocks = p.first; - } - if (p.second.name == strLLMQTypeInstantSend) { - llmqTypeInstantSend = p.first; - } - } - if (llmqTypeChainLocks == Consensus::LLMQ_NONE) { - return InitError("Invalid LLMQ type specified for -llmqchainlocks."); - } - if (llmqTypeInstantSend == Consensus::LLMQ_NONE) { - return InitError("Invalid LLMQ type specified for -llmqinstantsend."); - } - UpdateDevnetLLMQChainLocks(llmqTypeChainLocks); - UpdateDevnetLLMQInstantSend(llmqTypeInstantSend); - } else if (gArgs.IsArgSet("-llmqchainlocks")) { - return InitError("LLMQ type for ChainLocks can only be overridden on devnet."); - } else if (gArgs.IsArgSet("-llmqinstantsend")) { - return InitError("LLMQ type for InstantSend can only be overridden on devnet."); - } - - if (chainparams.NetworkIDString() == CBaseChainParams::DEVNET) { - if (gArgs.IsArgSet("-llmqdevnetparams")) { - std::string s = gArgs.GetArg("-llmqdevnetparams", ""); - std::vector v; - boost::split(v, s, boost::is_any_of(":")); - int size, threshold; - if (v.size() != 2 || !ParseInt32(v[0], &size) || !ParseInt32(v[1], &threshold)) { - return InitError("Invalid -llmqdevnetparams specified"); - } - UpdateLLMQDevnetParams(size, threshold); - } - } else if (gArgs.IsArgSet("-llmqdevnetparams")) { - return InitError("LLMQ devnet params can only be overridden on devnet."); - } - - if (chainparams.NetworkIDString() == CBaseChainParams::REGTEST) { - if (gArgs.IsArgSet("-llmqtestparams")) { - std::string s = gArgs.GetArg("-llmqtestparams", ""); - std::vector v; - boost::split(v, s, boost::is_any_of(":")); - int size, threshold; - if (v.size() != 2 || !ParseInt32(v[0], &size) || !ParseInt32(v[1], &threshold)) { - return InitError("Invalid -llmqtestparams specified"); - } - UpdateLLMQTestParams(size, threshold); - } - } else if (gArgs.IsArgSet("-llmqtestparams")) { - return InitError("LLMQ test params can only be overridden on regtest."); - } - try { const bool fRecoveryEnabled{llmq::CLLMQUtils::QuorumDataRecoveryEnabled()}; const bool fQuorumVvecRequestsEnabled{llmq::CLLMQUtils::GetEnabledQuorumVvecSyncEntries().size() > 0}; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index d098c184a108..ab92cfdf0ca0 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index b641dada085e..a8452f61a2de 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/src/test/test_dash.cpp b/src/test/test_dash.cpp index 4b8c568a7f7a..bd6b79502aff 100644 --- a/src/test/test_dash.cpp +++ b/src/test/test_dash.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,8 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName) InitScriptExecutionCache(); CCoinJoin::InitStandardDenominations(); fCheckBlockIndex = true; + // Make sure CreateAndProcessBlock() support building blocks before activating it in these tests. + //gArgs.ForceSetArg("-vbparams", strprintf("deployment_name:0:%d", (int64_t)Consensus::BIP9Deployment::NO_TIMEOUT)); SelectParams(chainName); evoDb.reset(new CEvoDB(1 << 20, true, true)); deterministicMNManager.reset(new CDeterministicMNManager(*evoDb)); diff --git a/src/validation.cpp b/src/validation.cpp index 5a4e68fd9880..8b889d430574 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/src/versionbits.cpp b/src/versionbits.cpp index cd9dd6f88ea7..41259839f674 100644 --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -5,49 +5,6 @@ #include #include -const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] = { - { - /*.name =*/ "testdummy", - /*.gbt_force =*/ true, - /*.check_mn_protocol =*/ false, - }, - { - /*.name =*/ "csv", - /*.gbt_force =*/ true, - /*.check_mn_protocol =*/ false, - }, - { - /*.name =*/ "dip0001", - /*.gbt_force =*/ true, - /*.check_mn_protocol =*/ true, - }, - { - /*.name =*/ "bip147", - /*.gbt_force =*/ true, - /*.check_mn_protocol =*/ false, - }, - { - /*.name =*/ "dip0003", - /*.gbt_force =*/ true, - /*.check_mn_protocol =*/ false, - }, - { - /*.name =*/ "dip0008", - /*.gbt_force =*/ true, - /*.check_mn_protocol =*/ false, - }, - { - /*.name =*/ "realloc", - /*.gbt_force =*/ true, - /*.check_mn_protocol =*/ false, - }, - { - /*.name =*/ "dip0020", - /*.gbt_force =*/ true, - /*.check_mn_protocol =*/ false, - }, -}; - ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const { int nPeriod = Period(params); diff --git a/src/versionbits.h b/src/versionbits.h index a19792d80412..f8e547a3fcd8 100644 --- a/src/versionbits.h +++ b/src/versionbits.h @@ -30,15 +30,6 @@ enum class ThresholdState { // will either be nullptr or a block with (height + 1) % Period() == 0. typedef std::map ThresholdConditionCache; -struct VBDeploymentInfo { - /** Deployment name */ - const char *name; - /** Whether GBT clients can safely ignore this rule in simplified usage */ - bool gbt_force; - /** Whether to check current MN protocol or not */ - bool check_mn_protocol; -}; - struct BIP9Stats { int period; int threshold; @@ -47,8 +38,6 @@ struct BIP9Stats { bool possible; }; -extern const struct VBDeploymentInfo VersionBitsDeploymentInfo[]; - /** * Abstract class that implements BIP9-style threshold logic, and caches results. */ diff --git a/src/versionbitsinfo.cpp b/src/versionbitsinfo.cpp new file mode 100644 index 000000000000..50baed90dcb6 --- /dev/null +++ b/src/versionbitsinfo.cpp @@ -0,0 +1,50 @@ +// Copyright (c) 2016-2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include + +const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] = { + { + /*.name =*/ "testdummy", + /*.gbt_force =*/ true, + /*.check_mn_protocol =*/ false, + }, + { + /*.name =*/ "csv", + /*.gbt_force =*/ true, + /*.check_mn_protocol =*/ false, + }, + { + /*.name =*/ "dip0001", + /*.gbt_force =*/ true, + /*.check_mn_protocol =*/ true, + }, + { + /*.name =*/ "bip147", + /*.gbt_force =*/ true, + /*.check_mn_protocol =*/ false, + }, + { + /*.name =*/ "dip0003", + /*.gbt_force =*/ true, + /*.check_mn_protocol =*/ false, + }, + { + /*.name =*/ "dip0008", + /*.gbt_force =*/ true, + /*.check_mn_protocol =*/ false, + }, + { + /*.name =*/ "realloc", + /*.gbt_force =*/ true, + /*.check_mn_protocol =*/ false, + }, + { + /*.name =*/ "dip0020", + /*.gbt_force =*/ true, + /*.check_mn_protocol =*/ false, + }, +}; diff --git a/src/versionbitsinfo.h b/src/versionbitsinfo.h new file mode 100644 index 000000000000..edf81a31f040 --- /dev/null +++ b/src/versionbitsinfo.h @@ -0,0 +1,19 @@ +// Copyright (c) 2016-2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_VERSIONBITSINFO_H +#define BITCOIN_VERSIONBITSINFO_H + +struct VBDeploymentInfo { + /** Deployment name */ + const char *name; + /** Whether GBT clients can safely ignore this rule in simplified usage */ + bool gbt_force; + /** Whether to check current MN protocol or not */ + bool check_mn_protocol; +}; + +extern const struct VBDeploymentInfo VersionBitsDeploymentInfo[]; + +#endif // BITCOIN_VERSIONBITSINFO_H