merge bitcoin#13311: Don't edit Chainparams after initialization (#4362)

* Merge #13311: Don't edit Chainparams after initialization

6fa901fb47 Don't edit Chainparams after initialization (Jorge Timón)
980b38f8a1 MOVEONLY: Move versionbits info out of versionbits.o (Jorge Timón)

Pull request description:

  This encapsulates the "-vbparams" option, which is only meant for regtest, directly on CRegTestParams.

  This is a refactor and doesn't change functionality.

  Related to https://github.com/bitcoin/bitcoin/pull/8994

Tree-SHA512: 79771d729a63a720e743a9c77d5e2d80369f072d66202a43c1304e83a7d0ef7c6103d4968a03aea9666cc89a7203c618da972124a677b38cfe62ddaeb28f9f5d

* Resolve Merge with #13311

* Incorporated review changes

* Apply suggestions from code review

* Update src/chainparams.cpp

* Update src/chainparams.cpp

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
This commit is contained in:
rkarthik2k21 2021-09-02 18:36:11 -04:00 committed by GitHub
parent cc03953ded
commit f456edb07e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 428 additions and 412 deletions

View File

@ -289,6 +289,7 @@ BITCOIN_CORE_H = \
validation.h \
validationinterface.h \
versionbits.h \
versionbitsinfo.h \
walletinitinterface.h \
wallet/coincontrol.h \
wallet/crypter.h \
@ -603,6 +604,7 @@ libdash_common_a_SOURCES = \
script/ismine.cpp \
script/sign.cpp \
script/standard.cpp \
versionbitsinfo.cpp \
warnings.cpp \
$(BITCOIN_CORE_H)

View File

@ -11,11 +11,15 @@
#include <tinyformat.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <versionbitsinfo.h>
#include <arith_uint256.h>
#include <assert.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
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();
@ -709,7 +644,7 @@ public:
*/
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
@ -813,15 +748,14 @@ public:
m_assumed_blockchain_size = 0;
m_assumed_chain_state_size = 0;
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();
}
vFixedSeeds.clear();
vSeeds.clear();
@ -851,6 +785,10 @@ public:
consensus.llmqTypeInstantSend = Consensus::LLMQ_50_60;
consensus.llmqTypePlatform = Consensus::LLMQ_100_67;
UpdateDevnetLLMQChainLocksFromArgs(args);
UpdateDevnetLLMQInstantSendFromArgs(args);
UpdateLLMQDevnetParametersFromArgs(args);
fDefaultConsistencyChecks = false;
fRequireStandard = false;
fRequireRoutableExternalIP = true;
@ -881,6 +819,48 @@ public:
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);
};
/**
@ -888,7 +868,7 @@ public:
*/
class CRegTestParams : public CChainParams {
public:
CRegTestParams() {
explicit CRegTestParams(const ArgsManager& args) {
strNetworkID = "regtest";
consensus.nSubsidyHalvingInterval = 150;
consensus.nMasternodePaymentsStartBlock = 240;
@ -971,6 +951,11 @@ public:
m_assumed_blockchain_size = 0;
m_assumed_chain_state_size = 0;
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"));
@ -1029,26 +1014,298 @@ public:
consensus.llmqTypeChainLocks = Consensus::LLMQ_TEST;
consensus.llmqTypeInstantSend = Consensus::LLMQ_TEST;
consensus.llmqTypePlatform = Consensus::LLMQ_TEST;
UpdateLLMQTestParametersFromArgs(args);
}
/**
* 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);
};
static std::unique_ptr<CChainParams> globalChainParams;
void CRegTestParams::UpdateVersionBitsParametersFromArgs(const ArgsManager& args)
{
if (!args.IsArgSet("-vbparams")) return;
for (const std::string& strDeployment : args.GetArgs("-vbparams")) {
std::vector<std::string> 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 "
"<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)) {
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]));
}
}
}
void CRegTestParams::UpdateDIP3ParametersFromArgs(const ArgsManager& args)
{
if (!args.IsArgSet("-dip3params")) return;
std::string strParams = args.GetArg("-dip3params", "");
std::vector<std::string> vParams;
boost::split(vParams, strParams, boost::is_any_of(":"));
if (vParams.size() != 2) {
throw std::runtime_error("DIP3 parameters malformed, expecting <activation>:<enforcement>");
}
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 CRegTestParams::UpdateDIP8ParametersFromArgs(const ArgsManager& args)
{
if (!args.IsArgSet("-dip8params")) return;
std::string strParams = args.GetArg("-dip8params", "");
std::vector<std::string> vParams;
boost::split(vParams, strParams, boost::is_any_of(":"));
if (vParams.size() != 1) {
throw std::runtime_error("DIP8 parameters malformed, expecting <activation>");
}
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 CRegTestParams::UpdateBudgetParametersFromArgs(const ArgsManager& args)
{
if (!args.IsArgSet("-budgetparams")) return;
std::string strParams = args.GetArg("-budgetparams", "");
std::vector<std::string> vParams;
boost::split(vParams, strParams, boost::is_any_of(":"));
if (vParams.size() != 3) {
throw std::runtime_error("Budget parameters malformed, expecting <masternode>:<budget>:<superblock>");
}
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 CRegTestParams::UpdateLLMQTestParametersFromArgs(const ArgsManager& args)
{
if (!args.IsArgSet("-llmqtestparams")) return;
std::string strParams = args.GetArg("-llmqtestparams", "");
std::vector<std::string> vParams;
boost::split(vParams, strParams, boost::is_any_of(":"));
if (vParams.size() != 2) {
throw std::runtime_error("LLMQ_TEST parameters malformed, expecting <size>:<threshold>");
}
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 CDevNetParams::UpdateDevnetSubsidyAndDiffParametersFromArgs(const ArgsManager& args)
{
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 CDevNetParams::UpdateDevnetLLMQChainLocksFromArgs(const ArgsManager& args)
{
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 CDevNetParams::UpdateDevnetLLMQInstantSendFromArgs(const ArgsManager& args)
{
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 CDevNetParams::UpdateLLMQDevnetParametersFromArgs(const ArgsManager& args)
{
if (!args.IsArgSet("-llmqdevnetparams")) return;
std::string strParams = args.GetArg("-llmqdevnetparams", "");
std::vector<std::string> vParams;
boost::split(vParams, strParams, boost::is_any_of(":"));
if (vParams.size() != 2) {
throw std::runtime_error("LLMQ_DEVNET parameters malformed, expecting <size>:<threshold>");
}
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);
}
static std::unique_ptr<const CChainParams> globalChainParams;
const CChainParams &Params() {
assert(globalChainParams);
return *globalChainParams;
}
std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain, bool fHelpOnly)
std::unique_ptr<const CChainParams> CreateChainParams(const std::string& chain)
{
if (chain == CBaseChainParams::MAIN)
return std::unique_ptr<CChainParams>(new CMainParams());
else if (chain == CBaseChainParams::TESTNET)
return std::unique_ptr<CChainParams>(new CTestNetParams());
else if (chain == CBaseChainParams::DEVNET) {
return std::unique_ptr<CChainParams>(new CDevNetParams(fHelpOnly));
return std::unique_ptr<CChainParams>(new CDevNetParams(gArgs));
} else if (chain == CBaseChainParams::REGTEST)
return std::unique_ptr<CChainParams>(new CRegTestParams());
return std::unique_ptr<CChainParams>(new CRegTestParams(gArgs));
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
}
@ -1057,48 +1314,3 @@ void SelectParams(const std::string& network)
SelectBaseParams(network);
globalChainParams = CreateChainParams(network);
}
void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout, int64_t nWindowSize, int64_t nThresholdStart, int64_t nThresholdMin, int64_t nFalloffCoeff)
{
globalChainParams->UpdateVersionBitsParameters(d, nStartTime, nTimeout, nWindowSize, nThresholdStart, nThresholdMin, nFalloffCoeff);
}
void UpdateDIP3Parameters(int nActivationHeight, int nEnforcementHeight)
{
globalChainParams->UpdateDIP3Parameters(nActivationHeight, nEnforcementHeight);
}
void UpdateDIP8Parameters(int nActivationHeight)
{
globalChainParams->UpdateDIP8Parameters(nActivationHeight);
}
void UpdateBudgetParameters(int nMasternodePaymentsStartBlock, int nBudgetPaymentsStartBlock, int nSuperblockStartBlock)
{
globalChainParams->UpdateBudgetParameters(nMasternodePaymentsStartBlock, nBudgetPaymentsStartBlock, nSuperblockStartBlock);
}
void UpdateDevnetSubsidyAndDiffParams(int nMinimumDifficultyBlocks, int nHighSubsidyBlocks, int nHighSubsidyFactor)
{
globalChainParams->UpdateSubsidyAndDiffParams(nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor);
}
void UpdateDevnetLLMQChainLocks(Consensus::LLMQType llmqType)
{
globalChainParams->UpdateLLMQChainLocks(llmqType);
}
void UpdateDevnetLLMQInstantSend(Consensus::LLMQType llmqType)
{
globalChainParams->UpdateLLMQInstantSend(llmqType);
}
void UpdateLLMQTestParams(int size, int threshold)
{
globalChainParams->UpdateLLMQTestParams(size, threshold);
}
void UpdateLLMQDevnetParams(int size, int threshold)
{
globalChainParams->UpdateLLMQDevnetParams(size, threshold);
}

View File

@ -91,7 +91,6 @@ public:
const std::vector<SeedSpec6>& 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);
@ -144,7 +143,7 @@ protected:
* @returns a CChainParams* of the chosen chain.
* @throws a std::runtime_error if the chain is not supported.
*/
std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain, bool fHelpOnly = false);
std::unique_ptr<const CChainParams> CreateChainParams(const std::string& chain);
/**
* Return the currently selected parameters. This won't change after app
@ -158,49 +157,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

View File

@ -18,10 +18,24 @@ const std::string CBaseChainParams::REGTEST = "regtest";
void SetupChainParamsBaseOptions()
{
gArgs.AddArg("-budgetparams=<masternode>:<budget>:<superblock>", "Override masternode, budget and superblock start heights (regtest-only)", true, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-devnet=<name>", "Use devnet chain with provided name", false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-dip3params=<activation>:<enforcement>", "Override DIP3 activation and enforcement heights (regtest-only)", true, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-dip8params=<activation>", "Override DIP8 activation height (regtest-only)", true, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-highsubsidyblocks=<n>", "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=<n>", "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=<quorum name>", "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=<size>:<threshold>", "Override the default LLMQ size for the LLMQ_DEVNET quorum (default: 3:2, devnet-only)", false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-llmqinstantsend=<quorum name>", "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=<size>:<threshold>", "Override the default LLMQ size for the LLMQ_TEST quorum (default: 10:6, regtest-only)", true, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-minimumdifficultyblocks=<n>", "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=<deployment>:<start>:<end>(:<window>:<threshold/thresholdstart>(:<thresholdmin>:<falloffcoeff>))",
"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<CBaseChainParams> globalChainBaseParams;

View File

@ -445,11 +445,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<std::string> hidden_args = {"-h", "-help", "-dbcrashratio", "-forcecompactdb", "-printcrashinfo",
// GUI args. These will be overwritten by SetupUIArgs for the GUI
@ -615,24 +610,14 @@ void SetupServerArgs()
gArgs.AddArg("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> 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=<deployment>:<start>:<end>(:<window>:<threshold>)", "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=<n>", 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=<masternode>:<budget>:<superblock>", "Override masternode, budget and superblock start heights", false, OptionsCategory::DEBUG_TEST);
gArgs.AddArg("-debug=<category>", "Output debugging information (default: -nodebug, supplying <category> is optional). "
"If <category> is not supplied or if <category> = 1, output all debugging information. <category> can be: " + ListLogCategories() + ".", false, OptionsCategory::DEBUG_TEST);
gArgs.AddArg("-debugexclude=<category>", 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=<activation>:<enforcement>", "Override DIP3 activation and enforcement heights", false, OptionsCategory::DEBUG_TEST);
gArgs.AddArg("-dip8params=<activation>", "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=<n>", 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=<n>", 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=<quorum name>", 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=<size:threshold>", 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=<quorum name>", 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=<size:threshold>", 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);
@ -642,7 +627,6 @@ void SetupServerArgs()
gArgs.AddArg("-mocktime=<n>", "Replace actual time with <n> seconds since epoch (default: 0)", true, OptionsCategory::DEBUG_TEST);
gArgs.AddArg("-maxtxfee=<amt>", 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=<n>", 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=<n>", "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);
@ -1453,177 +1437,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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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};

View File

@ -35,6 +35,7 @@
#include <util/system.h>
#include <validation.h>
#include <validationinterface.h>
#include <versionbitsinfo.h>
#include <warnings.h>
#include <evo/specialtx.h>

View File

@ -28,6 +28,7 @@
#include <util/validation.h>
#include <validation.h>
#include <validationinterface.h>
#include <versionbitsinfo.h>
#include <warnings.h>
#include <governance/governance-classes.h>

View File

@ -7,6 +7,7 @@
#include <banman.h>
#include <chainparams.h>
#include <consensus/consensus.h>
#include <consensus/params.h>
#include <consensus/validation.h>
#include <crypto/sha256.h>
#include <index/txindex.h>
@ -52,6 +53,8 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
InitScriptExecutionCache();
CCoinJoin::InitStandardDenominations();
fCheckBlockIndex = true;
// Make sure CreateAndProcessBlock() support building <deployment_name> 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));

View File

@ -42,6 +42,7 @@
#include <util/validation.h>
#include <util/system.h>
#include <validationinterface.h>
#include <versionbitsinfo.h>
#include <warnings.h>
#include <masternode/masternode-payments.h>

View File

@ -5,49 +5,6 @@
#include <versionbits.h>
#include <consensus/params.h>
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);

View File

@ -30,15 +30,6 @@ enum class ThresholdState {
// will either be nullptr or a block with (height + 1) % Period() == 0.
typedef std::map<const CBlockIndex*, ThresholdState> 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.
*/

50
src/versionbitsinfo.cpp Normal file
View File

@ -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 <versionbitsinfo.h>
#include <consensus/params.h>
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,
},
};

19
src/versionbitsinfo.h Normal file
View File

@ -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