From 153aa3cd60606dedb9a0aea49948c8845ecb36f0 Mon Sep 17 00:00:00 2001 From: DCG-Claude Date: Fri, 9 Oct 2026 19:26:10 -0500 Subject: [PATCH] Merge bitcoin/bitcoin#26177: refactor / kernel: Move non-gArgs chainparams functionality to kernel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit b3e78dc91d01e364b77aacd9fb9a2f88688ab8a6 refactor: Don't use global chainparams in chainstatemanager method (TheCharlatan) 382b692a503355df7347efd9c128aff465b5583e Split non/kernel chainparams (Carl Dong) edabbc78a3bc272b2b802e1dbab73d6ed8e31e96 Add factory functions for Main/Test/Sig/Reg chainparams (Carl Dong) d938098398814f37fed9b018b44716179cfa4b03 Remove UpdateVersionBitsParameters (Carl Dong) 84b85786f0f5cb23cc257a4464ae345e1d372313 Decouple RegTestChainParams from ArgsManager (Carl Dong) 76cd4e7c96242398172989609f1b9a8843c404b4 Decouple SigNetChainParams from ArgsManager (Carl Dong) Pull request description: This pull request is part of the `libbitcoinkernel` project https://github.com/bitcoin/bitcoin/issues/24303 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". dongcarl is the original author of this patchset, these commits were taken from https://github.com/dongcarl/bitcoin/tree/2022-03-libbitcoinkernel-chainparams-args-only. #### Context The bitcoin kernel library currently relies on code containing user configurations through the `ArgsManager`. This is not optimal, since as a stand-alone library it should not rely on bitcoind's argument parsing logic. Instead, its interfaces should accept control and options structs that control the kernel library's desired configuration. Similar work towards decoupling the `ArgsManager` from the kernel has been done in https://github.com/bitcoin/bitcoin/pull/25290, https://github.com/bitcoin/bitcoin/pull/25487, https://github.com/bitcoin/bitcoin/pull/25527 and https://github.com/bitcoin/bitcoin/pull/25862. #### Changes By moving the `CChainParams` class definition into the kernel and giving it new factory functions `CChainParams::{RegTest,SigNet,Main,TestNet}`it can be constructed without an `ArgsManager` reference, unlike the current factory function `CreateChainParams`. The first few commits remove uses of `ArgsManager` within `CChainParams`. Then the `CChainParams` definition is moved to a new file in the `kernel/` subdirectory. ACKs for top commit: MarcoFalke: re-ACK b3e78dc91d01e364b77aacd9fb9a2f88688ab8a6 🛁 ryanofsky: Code review ACK b3e78dc91d01e364b77aacd9fb9a2f88688ab8a6. Only changes since last review were recent review suggestions. ajtowns: ACK b3e78dc91d01e364b77aacd9fb9a2f88688ab8a6 Tree-SHA512: 3835aca1d3e3c75cc3303dd584bab3a77e58f6c678724a5e359fe4b0e17e0763a00931ee6191f516b9fde50496f59cc691f0709c0254206db3863bbf7ab2cacd Dash adaptations: - src/kernel/chainparams.{h,cpp}: moves Dash's CChainParams and network classes (all DIP, LLMQ, masternode and spork parameters), not Bitcoin's - src/kernel/chainparams.{h,cpp}: adds CChainParams::DevNet(DevNetOptions) next to Main()/TestNet()/RegTest() for Dash's fourth network - src/kernel/chainparams.h: VersionBitsParameters, RegTestOptions and DevNetOptions carry Dash's extra -vbparams fields and regtest/devnet overrides - src/kernel/chainparams.cpp: LLMQ overrides arrive as quorum names and are resolved in the kernel constructors, which own the per-chain LLMQ list - src/kernel/chainparams.cpp: the devnet name comes from DevNetOptions::name instead of gArgs.GetDevNetName(), keeping the kernel gArgs-free - src/kernel/chainparams.cpp: the moved classes keep develop's current values (EvoSnapshotHash, V24 bit 13, EVO_SHARES; no fRequireStandard after bitcoin#28354) - src/deploymentinfo.cpp: GetBuriedDeployment() maps the 12 names -testactivationheight already accepted (bip147 ... mn_rr) instead of upstream's segwit - src/chainparams.cpp: Dash's arg readers stay split into ReadRegTest*/ReadDevNet* helpers, called from ReadRegTestArgs()/ReadDevNetArgs() - src/chainparams.cpp: -minimumdifficultyblocks/-highsubsidyblocks/-highsubsidyfactor are read as separate optionals, so they log three lines instead of one - src/validation.h: upstream's is not added; Dash uses util/fs.h - src/active/dkgsession.cpp, src/chainlock/signing.cpp, src/instantsend/net_instantsend.cpp and Dash tests: include , which validation.h no longer provides Not applicable to Dash (intentionally omitted): - src/kernel/chainparams.cpp: CSigNetParams and CChainParams::SigNet(); Dash has no signet - src/kernel/chainparams.h: SigNetOptions and the SigNet() declaration; Dash has no signet - src/chainparams.cpp: ReadSigNetArgs() and the SIGNET branch of CreateChainParams(); Dash has no signet - src/kernel/chainparams.cpp: segwit/taproot fields, script_flag_exceptions and bech32_hrp of Bitcoin's chain classes; Dash's classes have none - src/deploymentinfo.cpp: the "segwit" -> DEPLOYMENT_SEGWIT mapping; Dash has no segwit deployment --- src/Makefile.am | 3 + src/active/dkgsession.cpp | 1 + src/bitcoin-chainstate.cpp | 5 +- src/chainlock/signing.cpp | 1 + src/chainparams.cpp | 1284 ++-------------------- src/chainparams.h | 182 +-- src/deploymentinfo.cpp | 32 + src/deploymentinfo.h | 3 + src/instantsend/net_instantsend.cpp | 1 + src/kernel/chainparams.cpp | 1191 ++++++++++++++++++++ src/kernel/chainparams.h | 286 +++++ src/node/blockstorage.cpp | 2 +- src/node/mempool_args.cpp | 2 +- src/qt/test/providertransactiontests.cpp | 1 + src/qt/test/wallettests.cpp | 1 + src/test/bls_tests.cpp | 1 + src/test/evo_islock_tests.cpp | 1 + src/test/llmq_chainlock_tests.cpp | 1 + src/test/validation_tests.cpp | 1 + src/validation.cpp | 3 +- src/validation.h | 4 +- src/versionbits.h | 1 + src/wallet/test/wallet_tests.cpp | 1 + 23 files changed, 1631 insertions(+), 1377 deletions(-) create mode 100644 src/kernel/chainparams.cpp create mode 100644 src/kernel/chainparams.h diff --git a/src/Makefile.am b/src/Makefile.am index b9fbff8fe40d..8b80f01dc504 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -287,6 +287,7 @@ BITCOIN_CORE_H = \ interfaces/wallet.h \ kernel/blockmanager_opts.h \ kernel/chain.h \ + kernel/chainparams.h \ kernel/chainstatemanager_opts.h \ kernel/checks.h \ kernel/coinstats.h \ @@ -992,6 +993,7 @@ libbitcoin_common_a_SOURCES = \ external_signer.cpp \ governance/common.cpp \ init/common.cpp \ + kernel/chainparams.cpp \ key.cpp \ key_io.cpp \ llmq/core_write.cpp \ @@ -1297,6 +1299,7 @@ libdashkernel_la_SOURCES = \ instantsend/lock.cpp \ kernel/chain.cpp \ kernel/checks.cpp \ + kernel/chainparams.cpp \ kernel/coinstats.cpp \ kernel/context.cpp \ kernel/cs_main.cpp \ diff --git a/src/active/dkgsession.cpp b/src/active/dkgsession.cpp index b50bd966f194..f9866bfb2651 100644 --- a/src/active/dkgsession.cpp +++ b/src/active/dkgsession.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp index 531872340c74..14563981e872 100644 --- a/src/bitcoin-chainstate.cpp +++ b/src/bitcoin-chainstate.cpp @@ -11,6 +11,7 @@ // // It is part of the libbitcoinkernel project. +#include #include #include #include @@ -61,7 +62,7 @@ int main(int argc, char* argv[]) // SETUP: Misc Globals SelectParams(CBaseChainParams::MAIN); - const CChainParams& chainparams = Params(); + auto chainparams = CChainParams::Main(); kernel::Context kernel_context{}; // We can't use a goto here, but we can use an assert since none of the @@ -90,7 +91,7 @@ int main(int argc, char* argv[]) // SETUP: Chainstate const ChainstateManager::Options chainman_opts{ - .chainparams = chainparams, + .chainparams = *chainparams, }; ChainstateManager chainman{chainman_opts}; diff --git a/src/chainlock/signing.cpp b/src/chainlock/signing.cpp index 3fe4f4e6e413..7cf84a184520 100644 --- a/src/chainlock/signing.cpp +++ b/src/chainlock/signing.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include diff --git a/src/chainparams.cpp b/src/chainparams.cpp index c46bc0a738b8..8d5a1195363d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -19,1072 +19,27 @@ #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; - txNew.nVersion = 1; - txNew.vin.resize(1); - txNew.vout.resize(1); - txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); - txNew.vout[0].nValue = genesisReward; - txNew.vout[0].scriptPubKey = genesisOutputScript; - - CBlock genesis; - genesis.nTime = nTime; - genesis.nBits = nBits; - genesis.nNonce = nNonce; - genesis.nVersion = nVersion; - genesis.vtx.push_back(MakeTransactionRef(std::move(txNew))); - genesis.hashPrevBlock.SetNull(); - genesis.hashMerkleRoot = BlockMerkleRoot(genesis); - return genesis; -} - -static CBlock CreateDevNetGenesisBlock(const uint256 &prevBlockHash, const std::string& devNetName, uint32_t nTime, uint32_t nNonce, uint32_t nBits, const CAmount& genesisReward) -{ - assert(!devNetName.empty()); - - CMutableTransaction txNew; - txNew.nVersion = 1; - txNew.vin.resize(1); - txNew.vout.resize(1); - // put height (BIP34) and devnet name into coinbase - txNew.vin[0].scriptSig = CScript() << 1 << std::vector(devNetName.begin(), devNetName.end()); - txNew.vout[0].nValue = genesisReward; - txNew.vout[0].scriptPubKey = CScript() << OP_RETURN; - - CBlock genesis; - genesis.nTime = nTime; - genesis.nBits = nBits; - genesis.nNonce = nNonce; - genesis.nVersion = 4; - genesis.vtx.push_back(MakeTransactionRef(std::move(txNew))); - genesis.hashPrevBlock = prevBlockHash; - genesis.hashMerkleRoot = BlockMerkleRoot(genesis); - return genesis; -} - -/** - * Build the genesis block. Note that the output of its generation - * transaction cannot be spent since it did not originally exist in the - * database. - * - * CBlock(hash=00000ffd590b14, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=e0028e, nTime=1390095618, nBits=1e0ffff0, nNonce=28917698, vtx=1) - * CTransaction(hash=e0028e, ver=1, vin.size=1, vout.size=1, nLockTime=0) - * CTxIn(COutPoint(000000, -1), coinbase 04ffff001d01044c5957697265642030392f4a616e2f3230313420546865204772616e64204578706572696d656e7420476f6573204c6976653a204f76657273746f636b2e636f6d204973204e6f7720416363657074696e6720426974636f696e73) - * CTxOut(nValue=50.00000000, scriptPubKey=0xA9037BAC7050C479B121CF) - * vMerkleTree: e0028e - */ -static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) -{ - const char* pszTimestamp = "Wired 09/Jan/2014 The Grand Experiment Goes Live: Overstock.com Is Now Accepting Bitcoins"; - const CScript genesisOutputScript = CScript() << ParseHex("040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9") << OP_CHECKSIG; - return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward); -} - -static CBlock FindDevNetGenesisBlock(const CBlock &prevBlock, const CAmount& reward) -{ - std::string devNetName = gArgs.GetDevNetName(); - assert(!devNetName.empty()); - - CBlock block = CreateDevNetGenesisBlock(prevBlock.GetHash(), devNetName, prevBlock.nTime + 1, 0, prevBlock.nBits, reward); - - arith_uint256 bnTarget; - bnTarget.SetCompact(block.nBits); - - for (uint32_t nNonce = 0; nNonce < UINT32_MAX; nNonce++) { - block.nNonce = nNonce; - - uint256 hash = block.GetHash(); - if (UintToArith256(hash) <= bnTarget) - return block; - } - - // This is very unlikely to happen as we start the devnet with a very low difficulty. In many cases even the first - // iteration of the above loop will give a result already - LogError("FindDevNetGenesisBlock: could not find devnet genesis block for %s\n", devNetName); - assert(false); -} - -bool CChainParams::IsValidMNActivation(int nBit, int64_t timePast) const -{ - assert(nBit < VERSIONBITS_NUM_BITS); - - for (int index = 0; index < Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++index) { - if (consensus.vDeployments[index].bit == nBit) { - auto& deployment = consensus.vDeployments[index]; - if (timePast > deployment.nTimeout || timePast < deployment.nStartTime) { - LogPrintf("%s: activation by bit=%d deployment='%s' is out of time range start=%lld timeout=%lld\n", __func__, nBit, VersionBitsDeploymentInfo[Consensus::DeploymentPos(index)].name, deployment.nStartTime, deployment.nTimeout); - continue; - } - if (!deployment.useEHF) { - LogPrintf("%s: trying to set MnEHF for non-masternode activation fork bit=%d\n", __func__, nBit); - return false; - } - LogPrintf("%s: set MnEHF for bit=%d is valid\n", __func__, nBit); - return true; - } - } - LogPrintf("%s: WARNING: unknown MnEHF fork bit=%d\n", __func__, nBit); - return true; -} - -void CChainParams::AddLLMQ(Consensus::LLMQType llmqType) -{ - assert(!GetLLMQ(llmqType).has_value()); - for (const auto& llmq_param : Consensus::available_llmqs) { - if (llmq_param.type == llmqType) { - consensus.llmqs.push_back(llmq_param); - return; - } - } - LogError("CChainParams::%s: unknown LLMQ type %d\n", __func__, static_cast(llmqType)); - assert(false); -} - -std::optional CChainParams::GetLLMQ(Consensus::LLMQType llmqType) const -{ - for (const auto& llmq_param : consensus.llmqs) { - if (llmq_param.type == llmqType) { - return std::make_optional(llmq_param); - } - } - return std::nullopt; -} - -/** - * Main network on which people trade goods and services. - */ -class CMainParams : public CChainParams { -public: - CMainParams() { - strNetworkID = CBaseChainParams::MAIN; - consensus.nSubsidyHalvingInterval = 210240; // Note: actual number of blocks per calendar year with DGW v3 is ~200700 (for example 449750 - 249050) - consensus.nMasternodePaymentsStartBlock = 100000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock - consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value - consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value - consensus.nInstantSendConfirmationsRequired = 6; - consensus.nInstantSendKeepLock = 24; - consensus.nBudgetPaymentsStartBlock = 328008; // actual historical value - consensus.nBudgetPaymentsCycleBlocks = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725 - consensus.nBudgetPaymentsWindowBlocks = 100; - consensus.nSuperblockStartBlock = 614820; // The block at which 12.1 goes live (end of final 12.0 budget cycle) - consensus.nSuperblockStartHash = uint256S("0000000000020cb27c7ef164d21003d5d20cdca2f54dd9a9ca6d45f4d47f8aa3"); - consensus.nSuperblockCycle = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725 - consensus.nSuperblockMaturityWindow = 1662; // ~(60*24*3)/2.6, ~3 days before actual Superblock is emitted - consensus.nGovernanceMinQuorum = 10; - consensus.nGovernanceFilterElements = 20000; - consensus.nMasternodeMinimumConfirmations = 15; - consensus.BIP34Height = 951; - consensus.BIP34Hash = uint256S("0x000001f35e70f7c5705f64c6c5cc3dea9449e74d5b5c7cf74dad1bcca14a8012"); - consensus.BIP65Height = 619382; // 00000000000076d8fcea02ec0963de4abfd01e771fec0863f960c2c64fe6f357 - consensus.BIP66Height = 245817; // 00000000000b1fa2dfa312863570e13fae9ca7b5566cb27e55422620b469aefa - consensus.BIP147Height = 939456; // 00000000000000117befca4fab5622514772f608852e5edd8df9c55464b6fe37 - consensus.CSVHeight = 622944; // 00000000000002e3d3a6224cfce80bae367fd3283d1e5a8ba50e5e60b2d2905d - consensus.DIP0001Height = 782208; // 000000000000000cbc9cb551e8ee1ac7aa223585cbdfb755d3683bafd93679e4 - consensus.DIP0003Height = 1028160; - consensus.DIP0003EnforcementHeight = 1047200; - consensus.DIP0003EnforcementHash = uint256S("000000000000002d1734087b4c5afc3133e4e1c3e1a89218f62bcd9bb3d17f81"); - consensus.DIP0008Height = 1088640; // 00000000000000112e41e4b3afda8b233b8cc07c532d2eac5de097b68358c43e - consensus.BRRHeight = 1374912; // 000000000000000c5a124f3eccfbe6e17876dca79cec9e63dfa70d269113c926 - consensus.DIP0020Height = 1516032; // 000000000000000f64ed3bd9af1078177ac026f6aa2677aa4d8beeae43be56cc - consensus.DIP0024Height = 1737792; // 0000000000000001342be9c0b75ad40c276beaad91616423c4d9cb101b3db438 - consensus.DIP0024QuorumsHeight = 1738698; // 000000000000001aa25181e4c466e593992c98f9eb21c69ee757b8bb0af50244 - consensus.V19Height = 1899072; // 0000000000000015e32e73052d663626327004c81c5c22cb8b42c361015c0eae - consensus.V20Height = 1987776; // 000000000000001bf41cff06b76780050682ca29e61a91c391893d4745579777 - consensus.MN_RRHeight = 2128896; // 0000000000000009a9696da93d3807eb14eb00a4ff449206d689156a21b27f26 - consensus.WithdrawalsHeight = 2201472; // 00000000000000210518749e17c00b035a2a4982c906236c28c41ea2231bf7ef - consensus.MinBIP9WarningHeight = 2201472 + 2016; // withdrawals activation height + miner confirmation window - consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20 - consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day - consensus.nPowTargetSpacing = 2.5 * 60; // Dash: 2.5 minutes - consensus.fPowAllowMinDifficultyBlocks = false; - consensus.fPowNoRetargeting = false; - consensus.nPowKGWHeight = 15200; - consensus.nPowDGWHeight = 34140; - consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016 - consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay - - consensus.vDeployments[Consensus::DEPLOYMENT_V24].bit = 13; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE; // TODO - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; // TODO - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nWindowSize = 4032; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nThresholdStart = 3226; // 80% of 4032 - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nThresholdMin = 2420; // 60% of 4032 - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nFalloffCoeff = 5; // this corresponds to 10 periods - consensus.vDeployments[Consensus::DEPLOYMENT_V24].useEHF = true; - - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].bit = 14; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE; // TODO: same as DEPLOYMENT_V24 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; // TODO: same as DEPLOYMENT_V24 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nWindowSize = 4032; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nThresholdStart = 3226; // 80% of 4032 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nThresholdMin = 2420; // 60% of 4032 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nFalloffCoeff = 5; // this corresponds to 10 periods - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].useEHF = true; - - consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000ba7225adc3153945d14d"); // 2487500 - consensus.defaultAssumeValid = uint256S("0x00000000000000119fe42827219e0686d3f7b494ae65f823194c740c5dbab492"); // 2487500 - - /** - * The message start string is designed to be unlikely to occur in normal data. - * The characters are rarely used upper ASCII, not valid as UTF-8, and produce - * a large 32-bit integer with any alignment. - */ - pchMessageStart[0] = 0xbf; - pchMessageStart[1] = 0x0c; - pchMessageStart[2] = 0x6b; - pchMessageStart[3] = 0xbd; - nDefaultPort = 9999; - nDefaultPlatformP2PPort = 26656; - nDefaultPlatformHTTPPort = 443; - nPruneAfterHeight = 100000; - m_assumed_blockchain_size = 57; - m_assumed_chain_state_size = 1; - - genesis = CreateGenesisBlock(1390095618, 28917698, 0x1e0ffff0, 1, 50 * COIN); - consensus.hashGenesisBlock = genesis.GetHash(); - assert(consensus.hashGenesisBlock == uint256S("0x00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6")); - assert(genesis.hashMerkleRoot == uint256S("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7")); - - // Note that of those which support the service bits prefix, most only support a subset of - // possible options. - // This is fine at runtime as we'll fall back to using them as an addrfetch if they don't support the - // service bits we want, but we should get them updated to support all service bits wanted by any - // release ASAP to avoid it where possible. - vSeeds.emplace_back("dnsseed.dash.org."); - - // Dash addresses start with 'X' - base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,76); - // Dash script addresses start with '7' - base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,16); - // Dash private keys start with '7' or 'X' - base58Prefixes[SECRET_KEY] = std::vector(1,204); - // Dash BIP32 pubkeys start with 'xpub' (Bitcoin defaults) - base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E}; - // Dash BIP32 prvkeys start with 'xprv' (Bitcoin defaults) - base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4}; - - // DIP-18 Dash Platform address HRP (bech32m) - bech32_platform_hrp = "dash"; - - // Dash BIP44 coin type is '5' - nExtCoinType = 5; - - vFixedSeeds = std::vector(std::begin(chainparams_seed_main), std::end(chainparams_seed_main)); - - // long living quorum params - AddLLMQ(Consensus::LLMQType::LLMQ_50_60); - AddLLMQ(Consensus::LLMQType::LLMQ_60_75); - AddLLMQ(Consensus::LLMQType::LLMQ_400_60); - AddLLMQ(Consensus::LLMQType::LLMQ_400_85); - AddLLMQ(Consensus::LLMQType::LLMQ_100_67); - consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_400_60; - consensus.llmqTypeDIP0024InstantSend = Consensus::LLMQType::LLMQ_60_75; - consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_100_67; - consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_400_85; - - fDefaultConsistencyChecks = false; - fRequireRoutableExternalIP = true; - m_is_test_chain = false; - fAllowMultipleAddressesFromGroup = false; - nLLMQConnectionRetryTimeout = 60; - m_is_mockable_chain = false; - - nPoolMinParticipants = 3; - nPoolMaxParticipants = 20; - nFulfilledRequestExpireTime = 60*60; // fulfilled requests expire in 1 hour - - strSporkAddress = "Xgtyuk76vhuFW2iT7UAiHgNdWXCf3J34wh"; - - nCreditPoolPeriodBlocks = 576; - - checkpointData = { - { - {1500, uint256S("0x000000aaf0300f59f49bc3e970bad15c11f961fe2347accffff19d96ec9778e3")}, - {4991, uint256S("0x000000003b01809551952460744d5dbb8fcbd6cbae3c220267bf7fa43f837367")}, - {9918, uint256S("0x00000000213e229f332c0ffbe34defdaa9e74de87f2d8d1f01af8d121c3c170b")}, - {16912, uint256S("0x00000000075c0d10371d55a60634da70f197548dbbfa4123e12abfcbc5738af9")}, - {23912, uint256S("0x0000000000335eac6703f3b1732ec8b2f89c3ba3a7889e5767b090556bb9a276")}, - {35457, uint256S("0x0000000000b0ae211be59b048df14820475ad0dd53b9ff83b010f71a77342d9f")}, - {45479, uint256S("0x000000000063d411655d590590e16960f15ceea4257122ac430c6fbe39fbf02d")}, - {55895, uint256S("0x0000000000ae4c53a43639a4ca027282f69da9c67ba951768a20415b6439a2d7")}, - {68899, uint256S("0x0000000000194ab4d3d9eeb1f2f792f21bb39ff767cb547fe977640f969d77b7")}, - {74619, uint256S("0x000000000011d28f38f05d01650a502cc3f4d0e793fbc26e2a2ca71f07dc3842")}, - {75095, uint256S("0x0000000000193d12f6ad352a9996ee58ef8bdc4946818a5fec5ce99c11b87f0d")}, - {88805, uint256S("0x00000000001392f1652e9bf45cd8bc79dc60fe935277cd11538565b4a94fa85f")}, - {107996, uint256S("0x00000000000a23840ac16115407488267aa3da2b9bc843e301185b7d17e4dc40")}, - {137993, uint256S("0x00000000000cf69ce152b1bffdeddc59188d7a80879210d6e5c9503011929c3c")}, - {167996, uint256S("0x000000000009486020a80f7f2cc065342b0c2fb59af5e090cd813dba68ab0fed")}, - {207992, uint256S("0x00000000000d85c22be098f74576ef00b7aa00c05777e966aff68a270f1e01a5")}, - {312645, uint256S("0x0000000000059dcb71ad35a9e40526c44e7aae6c99169a9e7017b7d84b1c2daf")}, - {407452, uint256S("0x000000000003c6a87e73623b9d70af7cd908ae22fee466063e4ffc20be1d2dbc")}, - {523412, uint256S("0x000000000000e54f036576a10597e0e42cc22a5159ce572f999c33975e121d4d")}, - {523930, uint256S("0x0000000000000bccdb11c2b1cfb0ecab452abf267d89b7f46eaf2d54ce6e652c")}, - {750000, uint256S("0x00000000000000b4181bbbdddbae464ce11fede5d0292fb63fdede1e7c8ab21c")}, - {888900, uint256S("0x0000000000000026c29d576073ab51ebd1d3c938de02e9a44c7ee9e16f82db28")}, - {967800, uint256S("0x0000000000000024e26c7df7e46d673724d223cf4ca2b2adc21297cc095600f4")}, - {1067570, uint256S("0x000000000000001e09926bcf5fa4513d23e870a34f74e38200db99eb3f5b7a70")}, - {1167570, uint256S("0x000000000000000fb7b1e9b81700283dff0f7d87cf458e5edfdae00c669de661")}, - {1364585, uint256S("0x00000000000000022f355c52417fca9b73306958f7c0832b3a7bce006ca369ef")}, - {1450000, uint256S("0x00000000000000105cfae44a995332d8ec256850ea33a1f7b700474e3dad82bc")}, - {1796500, uint256S("0x000000000000001d531f36005159f19351bd49ca676398a561e55dcccb84eacd")}, - {1850400, uint256S("0x00000000000000261bdbe99c01fcba992e577efa6cc41aae564b8ca9f112b2a3")}, - {1889000, uint256S("0x00000000000000075300e852d5bf5380f905b2768241f8b442498442084807a7")}, - {1969000, uint256S("0x000000000000000c8b7a3bdcd8b9f516462122314529c8342244c685a4c899bf")}, - {2029000, uint256S("0x0000000000000020d5e38b6aef5bc8e430029444d7977b46f710c7d281ef1281")}, - {2109672, uint256S("0x000000000000001889bd33ef019065e250d32bd46911f4003d3fdd8128b5358d")}, - {2175051, uint256S("0x000000000000001cf26547602d982dcaa909231bbcd1e70c0eb3c65de25473ba")}, - {2216986, uint256S("0x0000000000000010b1135dc743f27f6fc8a138c6420a9d963fc676f96c2048f4")}, - {2361500, uint256S("0x0000000000000009ba1e8f47851d036bb618a4f6565eb3c32d1f647d450ff195")}, - {2421800, uint256S("0x000000000000000718ed026ebd644a8b70b42d4cbd7b25304c066c9bf15f85b7")}, - {2471728, uint256S("0x000000000000001a19ad7270422a00f86123ea94e0b295a3a796d6861bd7b032")}, - {2487500, uint256S("0x00000000000000119fe42827219e0686d3f7b494ae65f823194c740c5dbab492")}, - } - }; - - m_assumeutxo_data = MapAssumeutxo{ - // TODO to be specified in a future patch. - }; - - // getchaintxstats 17280 000000000000001a19ad7270422a00f86123ea94e0b295a3a796d6861bd7b032 - chainTxData = ChainTxData{ - 1781318234, // * UNIX timestamp of last known number of transactions (Block 2487500) - 69770814, // * total number of transactions between genesis and that timestamp - // (the tx=... number in the ChainStateFlushed debug.log lines) - 0.1569520632249578, // * estimated number of transactions per second after that timestamp - }; - } -}; - -/** - * Testnet (v3): public test network which is reset from time to time. - */ -class CTestNetParams : public CChainParams { -public: - CTestNetParams() { - strNetworkID = CBaseChainParams::TESTNET; - consensus.nSubsidyHalvingInterval = 210240; - consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock - consensus.nMasternodePaymentsIncreaseBlock = 4030; - consensus.nMasternodePaymentsIncreasePeriod = 10; - consensus.nInstantSendConfirmationsRequired = 2; - consensus.nInstantSendKeepLock = 6; - consensus.nBudgetPaymentsStartBlock = 4100; - consensus.nBudgetPaymentsCycleBlocks = 50; - consensus.nBudgetPaymentsWindowBlocks = 10; - consensus.nSuperblockStartBlock = 4200; // NOTE: Should satisfy nSuperblockStartBlock > nBudgetPeymentsStartBlock - consensus.nSuperblockStartHash = uint256(); // do not check this on testnet - consensus.nSuperblockCycle = 24; // Superblocks can be issued hourly on testnet - consensus.nSuperblockMaturityWindow = 8; - consensus.nGovernanceMinQuorum = 1; - consensus.nGovernanceFilterElements = 500; - consensus.nMasternodeMinimumConfirmations = 1; - consensus.BIP34Height = 76; - consensus.BIP34Hash = uint256S("0x000008ebb1db2598e897d17275285767717c6acfeac4c73def49fbea1ddcbcb6"); - consensus.BIP65Height = 2431; // 0000039cf01242c7f921dcb4806a5994bc003b48c1973ae0c89b67809c2bb2ab - consensus.BIP66Height = 2075; // 0000002acdd29a14583540cb72e1c5cc83783560e38fa7081495d474fe1671f7 - consensus.BIP147Height = 4300; // 0000000040c1480d413c9203664253ab18da284130c329bf88fcfc84312bcbe0 - consensus.CSVHeight = 8064; // 00000005eb94d027e34649373669191188858a22c70f4a6d29105e559124cec7 - consensus.DIP0001Height = 5500; // 00000001d60a01d8f1f39011cc6b26e3a1c97a24238cab856c2da71a4dd801a9 - consensus.DIP0003Height = 7000; - consensus.DIP0003EnforcementHeight = 7300; - consensus.DIP0003EnforcementHash = uint256S("00000055ebc0e974ba3a3fb785c5ad4365a39637d4df168169ee80d313612f8f"); - consensus.DIP0008Height = 78800; // 000000000e9329d964d80e7dab2e704b43b6bd2b91fea1e9315d38932e55fb55 - consensus.BRRHeight = 387500; // 0000001537dbfd09dea69f61c1f8b2afa27c8dc91c934e144797761c9f10367b - consensus.DIP0020Height = 414100; // 000000cf961868662fbfbb5d1af6f1caa1809f6a4e390efe5f8cd3031adea668 - consensus.DIP0024Height = 769700; // 0000008d84e4efd890ae95c70a7a6126a70a80e5c19e4cb264a5b3469aeef172 - consensus.DIP0024QuorumsHeight = 770730; // 0000003c43b3ae7fffe61278ca5537a0e256ebf4d709d45f0ab040271074d51e - consensus.V19Height = 850100; // 000004728b8ff2a16b9d4eebb0fd61eeffadc9c7fe4b0ec0b5a739869401ab5b - consensus.V20Height = 905100; // 0000020c5e0f86f385cbf8e90210de9a9fd63633f01433bf47a6b3227a2851fd - consensus.MN_RRHeight = 1066900; // 000000d05d445958a9a4ad6bdc0f4bfb25af124b2326060703373ff2d3b397e9 - consensus.WithdrawalsHeight = 1148500; // 000000212a6fec2ee2af040c6d7a176360b154cbaa998888170cfd9ae7dd632d - consensus.MinBIP9WarningHeight = 1148500 + 2016; // withdrawals activation height + miner confirmation window - consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20 - consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day - consensus.nPowTargetSpacing = 2.5 * 60; // Dash: 2.5 minutes - consensus.fPowAllowMinDifficultyBlocks = true; - consensus.fPowNoRetargeting = false; - consensus.nPowKGWHeight = 4002; // nPowKGWHeight >= nPowDGWHeight means "no KGW" - consensus.nPowDGWHeight = 4002; // TODO: make sure to drop all spork6 related code on next testnet reset - consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains - consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay - - consensus.vDeployments[Consensus::DEPLOYMENT_V24].bit = 13; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nStartTime = 1790208000; // Thursday, September 24, 2026 0:00:00 - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nWindowSize = 100; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nThresholdStart = 80; // 80% of 100 - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nThresholdMin = 60; // 60% of 100 - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nFalloffCoeff = 5; // this corresponds to 10 periods - consensus.vDeployments[Consensus::DEPLOYMENT_V24].useEHF = true; - - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].bit = 14; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nStartTime = 1790208000; // Thursday, September 24, 2026 0:00:00 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nWindowSize = 100; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nThresholdStart = 80; // 80% of 100 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nThresholdMin = 60; // 60% of 100 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nFalloffCoeff = 5; // this corresponds to 10 periods - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].useEHF = true; - - consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000036c8f738da818d2"); // 1400000 - consensus.defaultAssumeValid = uint256S("0x000000541a23f9db7411cddbe50f9f1ebd4aa7108ebdcad62214753f648c0239"); // 1400000 - - pchMessageStart[0] = 0xce; - pchMessageStart[1] = 0xe2; - pchMessageStart[2] = 0xca; - pchMessageStart[3] = 0xff; - nDefaultPort = 19999; - nDefaultPlatformP2PPort = 22000; - nDefaultPlatformHTTPPort = 22001; - nPruneAfterHeight = 1000; - m_assumed_blockchain_size = 10; - m_assumed_chain_state_size = 1; - - genesis = CreateGenesisBlock(1390666206UL, 3861367235UL, 0x1e0ffff0, 1, 50 * COIN); - consensus.hashGenesisBlock = genesis.GetHash(); - assert(consensus.hashGenesisBlock == uint256S("0x00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c")); - assert(genesis.hashMerkleRoot == uint256S("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7")); - - vFixedSeeds.clear(); - vFixedSeeds = std::vector(std::begin(chainparams_seed_test), std::end(chainparams_seed_test)); - - vSeeds.clear(); - // nodes with support for servicebits filtering should be at the top - vSeeds.emplace_back("testnet-seed.dashdot.io."); // Just a static list of stable node(s), only supports x9 - - // Testnet Dash addresses start with 'y' - base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,140); - // Testnet Dash script addresses start with '8' or '9' - base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,19); - // Testnet private keys start with '9' or 'c' (Bitcoin defaults) - base58Prefixes[SECRET_KEY] = std::vector(1,239); - // Testnet Dash BIP32 pubkeys start with 'tpub' (Bitcoin defaults) - base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; - // Testnet Dash BIP32 prvkeys start with 'tprv' (Bitcoin defaults) - base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; - - // DIP-18 Dash Platform address HRP (bech32m) - bech32_platform_hrp = "tdash"; - - // Testnet Dash BIP44 coin type is '1' (All coin's testnet default) - nExtCoinType = 1; - - // long living quorum params - AddLLMQ(Consensus::LLMQType::LLMQ_50_60); - AddLLMQ(Consensus::LLMQType::LLMQ_60_75); - AddLLMQ(Consensus::LLMQType::LLMQ_400_60); - AddLLMQ(Consensus::LLMQType::LLMQ_400_85); - AddLLMQ(Consensus::LLMQType::LLMQ_100_67); - AddLLMQ(Consensus::LLMQType::LLMQ_25_67); - consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_50_60; - consensus.llmqTypeDIP0024InstantSend = Consensus::LLMQType::LLMQ_60_75; - consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_25_67; - consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_50_60; - - fDefaultConsistencyChecks = false; - fRequireRoutableExternalIP = true; - m_is_test_chain = true; - fAllowMultipleAddressesFromGroup = false; - nLLMQConnectionRetryTimeout = 60; - m_is_mockable_chain = false; - - nPoolMinParticipants = 2; - nPoolMaxParticipants = 20; - nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes - - strSporkAddress = "yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"; - - nCreditPoolPeriodBlocks = 576; - - checkpointData = { - { - {255, uint256S("0x0000080b600e06f4c07880673f027210f9314575f5f875fafe51971e268b886a")}, - {261, uint256S("0x00000c26026d0815a7e2ce4fa270775f61403c040647ff2c3091f99e894a4618")}, - {1999, uint256S("0x00000052e538d27fa53693efe6fb6892a0c1d26c0235f599171c48a3cce553b1")}, - {2999, uint256S("0x0000024bc3f4f4cb30d29827c13d921ad77d2c6072e586c7f60d83c2722cdcc5")}, - {96090, uint256S("0x00000000033df4b94d17ab43e999caaf6c4735095cc77703685da81254d09bba")}, - {200000, uint256S("0x000000001015eb5ef86a8fe2b3074d947bc972c5befe32b28dd5ce915dc0d029")}, - {395750, uint256S("0x000008b78b6aef3fd05ab78db8b76c02163e885305545144420cb08704dce538")}, - {470000, uint256S("0x0000009303aeadf8cf3812f5c869691dbd4cb118ad20e9bf553be434bafe6a52")}, - {794950, uint256S("0x000001860e4c7248a9c5cc3bc7106041750560dc5cd9b3a2641b49494bcff5f2")}, - {808000, uint256S("0x00000104cb60a2b5e00a8a4259582756e5bf0dca201c0993c63f0e54971ea91a")}, - {840000, uint256S("0x000000cd7c3084499912ae893125c13e8c3c656abb6e511dcec6619c3d65a510")}, - {851000, uint256S("0x0000014d3b875540ff75517b7fbb1714e25d50ce92f65d7086cfce357928bb02")}, - {905100, uint256S("0x0000020c5e0f86f385cbf8e90210de9a9fd63633f01433bf47a6b3227a2851fd")}, - {960000, uint256S("0x0000000386cf5061ea16404c66deb83eb67892fa4f79b9e58e5eaab097ec2bd6")}, - {1069875, uint256S("0x00000034bfeb926662ba547c0b8dd4ba8cbb6e0c581f4e7d1bddce8f9ca3a608")}, - {1143608, uint256S("0x000000eef20eb0062abd4e799967e98bdebb165dd1c567ab4118c1c86c6e948f")}, - {1189000, uint256S("0x000001690314036dfbbecbdf382b230ead8e9c584241290a51f9f05a87a9cf7e")}, - {1295700, uint256S("0x00000107d42829a38e31c1a38c660d621e1ca376a880df1520e85e38af175d3a")}, - {1380000, uint256S("0x000000a98084beaf77ed26a905a7d59979009e23367a55b5d634962d7d65a1f9")}, - } - }; - - m_assumeutxo_data = MapAssumeutxo{ - // TODO to be specified in a future patch. - }; - - // getchaintxstats 17280 000000a98084beaf77ed26a905a7d59979009e23367a55b5d634962d7d65a1f9 - chainTxData = ChainTxData{ - 1765334452, // * UNIX timestamp of last known number of transactions (Block 1380000) - 8182713, // * total number of transactions between genesis and that timestamp - // (the tx=... number in the ChainStateFlushed debug.log lines) - 0.1796716675173412, // * estimated number of transactions per second after that timestamp - }; - } -}; - -/** - * Devnet: The Development network intended for developers use. - */ -class CDevNetParams : public CChainParams { -public: - explicit CDevNetParams(const ArgsManager& args) { - strNetworkID = CBaseChainParams::DEVNET; - consensus.nSubsidyHalvingInterval = 210240; - consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock - consensus.nMasternodePaymentsIncreaseBlock = 4030; - consensus.nMasternodePaymentsIncreasePeriod = 10; - consensus.nInstantSendConfirmationsRequired = 2; - consensus.nInstantSendKeepLock = 6; - consensus.nBudgetPaymentsStartBlock = 4100; - consensus.nBudgetPaymentsCycleBlocks = 50; - consensus.nBudgetPaymentsWindowBlocks = 10; - consensus.nSuperblockStartBlock = 4200; // NOTE: Should satisfy nSuperblockStartBlock > nBudgetPeymentsStartBlock - consensus.nSuperblockStartHash = uint256(); // do not check this on devnet - consensus.nSuperblockCycle = 24; // Superblocks can be issued hourly on devnet - consensus.nSuperblockMaturityWindow = 8; - consensus.nGovernanceMinQuorum = 1; - consensus.nGovernanceFilterElements = 500; - consensus.nMasternodeMinimumConfirmations = 1; - consensus.BIP34Height = 1; // BIP34 activated immediately on devnet - consensus.BIP65Height = 1; // BIP65 activated immediately on devnet - consensus.BIP66Height = 1; // BIP66 activated immediately on devnet - consensus.BIP147Height = 1; // BIP147 activated immediately on devnet - consensus.CSVHeight = 1; // BIP68 activated immediately on devnet - consensus.DIP0001Height = 2; // DIP0001 activated immediately on devnet - consensus.DIP0003Height = 2; // DIP0003 activated immediately on devnet - consensus.DIP0003EnforcementHeight = 2; // DIP0003 activated immediately on devnet - consensus.DIP0003EnforcementHash = uint256(); - consensus.DIP0008Height = 2; // DIP0008 activated immediately on devnet - consensus.BRRHeight = 2; // BRR (realloc) activated immediately on devnet - consensus.DIP0020Height = 2; // DIP0020 activated immediately on devnet - consensus.DIP0024Height = 2; // DIP0024 activated immediately on devnet - consensus.DIP0024QuorumsHeight = 2; // DIP0024 activated immediately on devnet - consensus.V19Height = 2; // V19 activated immediately on devnet - consensus.V20Height = 2; // V20 activated immediately on devnet - consensus.MN_RRHeight = 2; // MN_RR activated immediately on devnet - consensus.WithdrawalsHeight = 2; // withdrawals activated immediately on devnet - consensus.MinBIP9WarningHeight = 2 + 2016; // withdrawals activation height + miner confirmation window - consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1 - consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day - consensus.nPowTargetSpacing = 2.5 * 60; // Dash: 2.5 minutes - consensus.fPowAllowMinDifficultyBlocks = true; - consensus.fPowNoRetargeting = false; - consensus.nPowKGWHeight = 4001; // nPowKGWHeight >= nPowDGWHeight means "no KGW" - consensus.nPowDGWHeight = 4001; - consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains - consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay - - consensus.vDeployments[Consensus::DEPLOYMENT_V24].bit = 13; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nStartTime = 1751328000; // July 1, 2025 - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nWindowSize = 120; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nThresholdStart = 96; // 80% of 120 - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nThresholdMin = 72; // 60% of 120 - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nFalloffCoeff = 5; // this corresponds to 10 periods - consensus.vDeployments[Consensus::DEPLOYMENT_V24].useEHF = true; - - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].bit = 14; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nStartTime = 1751328000; // July 1, 2025 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nWindowSize = 120; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nThresholdStart = 96; // 80% of 120 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nThresholdMin = 72; // 60% of 120 - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nFalloffCoeff = 5; // this corresponds to 10 periods - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].useEHF = true; - - consensus.nMinimumChainWork = uint256{}; - consensus.defaultAssumeValid = uint256{}; - - pchMessageStart[0] = 0xe2; - pchMessageStart[1] = 0xca; - pchMessageStart[2] = 0xff; - pchMessageStart[3] = 0xce; - nDefaultPort = 19799; - nDefaultPlatformP2PPort = 22100; - nDefaultPlatformHTTPPort = 22101; - nPruneAfterHeight = 1000; - 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")); - - devnetGenesis = FindDevNetGenesisBlock(genesis, 50 * COIN); - consensus.hashDevnetGenesisBlock = devnetGenesis.GetHash(); - - vFixedSeeds.clear(); - vSeeds.clear(); - //vSeeds.push_back(CDNSSeedData("dashevo.org.", "devnet-seed.dashevo.org.")); - - // Testnet Dash addresses start with 'y' - base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,140); - // Testnet Dash script addresses start with '8' or '9' - base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,19); - // Testnet private keys start with '9' or 'c' (Bitcoin defaults) - base58Prefixes[SECRET_KEY] = std::vector(1,239); - // Testnet Dash BIP32 pubkeys start with 'tpub' (Bitcoin defaults) - base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; - // Testnet Dash BIP32 prvkeys start with 'tprv' (Bitcoin defaults) - base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; - - // DIP-18 Dash Platform address HRP (bech32m) - bech32_platform_hrp = "tdash"; - - // Testnet Dash BIP44 coin type is '1' (All coin's testnet default) - nExtCoinType = 1; - - // long living quorum params - AddLLMQ(Consensus::LLMQType::LLMQ_50_60); - AddLLMQ(Consensus::LLMQType::LLMQ_60_75); - AddLLMQ(Consensus::LLMQType::LLMQ_400_60); - AddLLMQ(Consensus::LLMQType::LLMQ_400_85); - AddLLMQ(Consensus::LLMQType::LLMQ_100_67); - AddLLMQ(Consensus::LLMQType::LLMQ_DEVNET); - AddLLMQ(Consensus::LLMQType::LLMQ_DEVNET_DIP0024); - AddLLMQ(Consensus::LLMQType::LLMQ_DEVNET_PLATFORM); - consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_DEVNET; - consensus.llmqTypeDIP0024InstantSend = Consensus::LLMQType::LLMQ_DEVNET_DIP0024; - consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_DEVNET_PLATFORM; - consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_DEVNET; - - UpdateDevnetLLMQChainLocksFromArgs(args); - UpdateDevnetLLMQInstantSendDIP0024FromArgs(args); - UpdateDevnetLLMQPlatformFromArgs(args); - UpdateDevnetLLMQMnhfFromArgs(args); - UpdateLLMQDevnetParametersFromArgs(args); - UpdateDevnetPowTargetSpacingFromArgs(args); - - fDefaultConsistencyChecks = false; - fRequireRoutableExternalIP = true; - m_is_test_chain = true; - fAllowMultipleAddressesFromGroup = true; - nLLMQConnectionRetryTimeout = 60; - m_is_mockable_chain = false; - - nPoolMinParticipants = 2; - nPoolMaxParticipants = 20; - nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes - - strSporkAddress = "yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"; - - nCreditPoolPeriodBlocks = 576; - - checkpointData = (CCheckpointData) { - { - { 0, uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")}, - { 1, devnetGenesis.GetHash() }, - } - }; - - chainTxData = ChainTxData{ - devnetGenesis.GetBlockTime(), // * UNIX timestamp of devnet genesis block - 2, // * we only have 2 coinbase transactions when a devnet is started up - 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 (DIP0024). - */ - void UpdateDevnetLLMQDIP0024InstantSend(Consensus::LLMQType llmqType) - { - consensus.llmqTypeDIP0024InstantSend = llmqType; - } - - /** - * Allows modifying the LLMQ type for Platform. - */ - void UpdateDevnetLLMQPlatform(Consensus::LLMQType llmqType) - { - consensus.llmqTypePlatform = llmqType; - } - - /** - * Allows modifying the LLMQ type for Mnhf. - */ - void UpdateDevnetLLMQMnhf(Consensus::LLMQType llmqType) - { - consensus.llmqTypeMnhf = llmqType; - } - - /** - * Allows modifying PowTargetSpacing - */ - void UpdateDevnetPowTargetSpacing(int64_t nPowTargetSpacing) - { - consensus.nPowTargetSpacing = nPowTargetSpacing; - } - - /** - * Allows modifying parameters of the devnet LLMQ - */ - void UpdateLLMQDevnetParameters(int size, int threshold) - { - auto params = std::ranges::find_if(consensus.llmqs, [](const auto& llmq){ return llmq.type == Consensus::LLMQType::LLMQ_DEVNET;}); - assert(params != consensus.llmqs.end()); - params->size = size; - params->minSize = threshold; - params->threshold = threshold; - params->dkgBadVotesThreshold = threshold; - } - void UpdateLLMQDevnetParametersFromArgs(const ArgsManager& args); - void UpdateDevnetLLMQInstantSendFromArgs(const ArgsManager& args); - void UpdateDevnetLLMQInstantSendDIP0024FromArgs(const ArgsManager& args); - void UpdateDevnetLLMQPlatformFromArgs(const ArgsManager& args); - void UpdateDevnetLLMQMnhfFromArgs(const ArgsManager& args); - void UpdateDevnetPowTargetSpacingFromArgs(const ArgsManager& args); -}; - -/** - * Regression test: intended for private networks only. Has minimal difficulty to ensure that - * blocks can be found instantly. - */ -class CRegTestParams : public CChainParams { -public: - explicit CRegTestParams(const ArgsManager& args) { - strNetworkID = CBaseChainParams::REGTEST; - consensus.nSubsidyHalvingInterval = 150; - consensus.nMasternodePaymentsStartBlock = 240; - consensus.nMasternodePaymentsIncreaseBlock = 350; - consensus.nMasternodePaymentsIncreasePeriod = 10; - consensus.nInstantSendConfirmationsRequired = 2; - consensus.nInstantSendKeepLock = 6; - consensus.nBudgetPaymentsStartBlock = 1000; - consensus.nBudgetPaymentsCycleBlocks = 50; - consensus.nBudgetPaymentsWindowBlocks = 10; - consensus.nSuperblockStartBlock = 1500; - consensus.nSuperblockStartHash = uint256(); // do not check this on regtest - consensus.nSuperblockCycle = 20; - consensus.nSuperblockMaturityWindow = 10; - consensus.nGovernanceMinQuorum = 1; - consensus.nGovernanceFilterElements = 100; - consensus.nMasternodeMinimumConfirmations = 1; - consensus.BIP34Height = 1; // Always active unless overridden - consensus.BIP34Hash = uint256(); - consensus.BIP65Height = 1; // Always active unless overridden - consensus.BIP66Height = 1; // Always active unless overridden - consensus.BIP147Height = 0; // Always active unless overridden - consensus.CSVHeight = 1; // Always active unless overridden - consensus.DIP0001Height = 1; // Always active unless overridden - consensus.DIP0003Height = 432; // Always active for DashTestFramework in functional tests (see dip3params) - // For unit tests and for BitcoinTestFramework is disabled due to missing quorum commitment for blocks created by helpers such as create_blocks - consensus.DIP0003EnforcementHeight = 500; - consensus.DIP0003EnforcementHash = uint256(); - consensus.DIP0008Height = 1; // Always active unless overridden - consensus.BRRHeight = 1; // Always active unless overridden - consensus.DIP0020Height = 1; // Always active unless overridden - consensus.DIP0024Height = 1; // Always have dip0024 quorums unless overridden - consensus.DIP0024QuorumsHeight = 1; // Always have dip0024 quorums unless overridden - consensus.V19Height = 1; // Always active unless overridden - consensus.V20Height = consensus.DIP0003Height; // Active not earlier than dip0003. Functional tests (DashTestFramework) uses height 100 (same as coinbase maturity) - consensus.MN_RRHeight = consensus.V20Height; // MN_RR does not really have effect before v20 activation - consensus.WithdrawalsHeight = 600; - consensus.MinBIP9WarningHeight = 0; - consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1 - consensus.nPowTargetTimespan = 24 * 60 * 60; // Dash: 1 day - consensus.nPowTargetSpacing = 2.5 * 60; // Dash: 2.5 minutes - consensus.fPowAllowMinDifficultyBlocks = true; - consensus.fPowNoRetargeting = true; - consensus.nPowKGWHeight = 15200; // same as mainnet - consensus.nPowDGWHeight = 34140; // same as mainnet - consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains - consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016) - - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay - - consensus.vDeployments[Consensus::DEPLOYMENT_V24].bit = 13; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nStartTime = 0; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nWindowSize = 250; - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nThresholdStart = 250 / 5 * 4; // 80% of window size - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nThresholdMin = 250 / 5 * 3; // 60% of window size - consensus.vDeployments[Consensus::DEPLOYMENT_V24].nFalloffCoeff = 5; // this corresponds to 10 periods - consensus.vDeployments[Consensus::DEPLOYMENT_V24].useEHF = true; - - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].bit = 14; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nStartTime = 0; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nWindowSize = 250; - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nThresholdStart = 250 / 5 * 4; // 80% of window size - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nThresholdMin = 250 / 5 * 3; // 60% of window size - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].nFalloffCoeff = 5; // this corresponds to 10 periods - consensus.vDeployments[Consensus::DEPLOYMENT_EVO_SHARES].useEHF = true; - - consensus.nMinimumChainWork = uint256{}; - consensus.defaultAssumeValid = uint256{}; - - pchMessageStart[0] = 0xfc; - pchMessageStart[1] = 0xc1; - pchMessageStart[2] = 0xb7; - pchMessageStart[3] = 0xdc; - nDefaultPort = 19899; - nDefaultPlatformP2PPort = 22200; - nDefaultPlatformHTTPPort = 22201; - nPruneAfterHeight = args.GetBoolArg("-fastprune", false) ? 100 : 1000; - m_assumed_blockchain_size = 0; - m_assumed_chain_state_size = 0; - - UpdateActivationParametersFromArgs(args); - UpdateDIP3ParametersFromArgs(args); - UpdateBudgetParametersFromArgs(args); - - genesis = CreateGenesisBlock(1417713337, 1096447, 0x207fffff, 1, 50 * COIN); - consensus.hashGenesisBlock = genesis.GetHash(); - assert(consensus.hashGenesisBlock == uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")); - assert(genesis.hashMerkleRoot == uint256S("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7")); - - vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds. - vSeeds.clear(); - vSeeds.emplace_back("dummySeed.invalid."); - - fDefaultConsistencyChecks = true; - fRequireRoutableExternalIP = false; - m_is_test_chain = true; - fAllowMultipleAddressesFromGroup = true; - nLLMQConnectionRetryTimeout = 1; // must be lower then the LLMQ signing session timeout so that tests have control over failing behavior - m_is_mockable_chain = true; - - nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes - nPoolMinParticipants = 2; - nPoolMaxParticipants = 20; - - // privKey: cP4EKFyJsHT39LDqgdcB43Y3YXjNyjb5Fuas1GQSeAtjnZWmZEQK - strSporkAddress = "yj949n1UH6fDhw6HtVE5VMj2iSTaSWBMcW"; - - nCreditPoolPeriodBlocks = 100; - - checkpointData = { - { - {0, uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")}, - } - }; - - m_assumeutxo_data = MapAssumeutxo{ - { - 110, - {AssumeutxoHash{uint256S("0x9b2a277a3e3b979f1a539d57e949495d7f8247312dbc32bce6619128c192b44b")}, EvoSnapshotHash{uint256{}}, 110}, - }, - { - 200, - {AssumeutxoHash{uint256S("0x8a5bdd92252fc6b24663244bbe958c947bb036dc1f94ccd15439f48d8d1cb4e3")}, EvoSnapshotHash{uint256{}}, 200}, - }, - }; - - chainTxData = ChainTxData{ - 0, - 0, - 0 - }; - - // Regtest Dash addresses start with 'y' - base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,140); - // Regtest Dash script addresses start with '8' or '9' - base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,19); - // Regtest private keys start with '9' or 'c' (Bitcoin defaults) - base58Prefixes[SECRET_KEY] = std::vector(1,239); - // Regtest Dash BIP32 pubkeys start with 'tpub' (Bitcoin defaults) - base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; - // Regtest Dash BIP32 prvkeys start with 'tprv' (Bitcoin defaults) - base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; - - // DIP-18 Dash Platform address HRP (bech32m) - bech32_platform_hrp = "tdash"; - - // Regtest Dash BIP44 coin type is '1' (All coin's testnet default) - nExtCoinType = 1; - - // long living quorum params - AddLLMQ(Consensus::LLMQType::LLMQ_TEST); - AddLLMQ(Consensus::LLMQType::LLMQ_TEST_INSTANTSEND); - AddLLMQ(Consensus::LLMQType::LLMQ_TEST_V17); - AddLLMQ(Consensus::LLMQType::LLMQ_TEST_DIP0024); - AddLLMQ(Consensus::LLMQType::LLMQ_TEST_PLATFORM); - consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_TEST; - consensus.llmqTypeDIP0024InstantSend = Consensus::LLMQType::LLMQ_TEST_DIP0024; - consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_TEST_PLATFORM; - consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_TEST; - - UpdateLLMQTestParametersFromArgs(args, Consensus::LLMQType::LLMQ_TEST); - UpdateLLMQTestParametersFromArgs(args, Consensus::LLMQType::LLMQ_TEST_INSTANTSEND); - UpdateLLMQTestParametersFromArgs(args, Consensus::LLMQType::LLMQ_TEST_PLATFORM); - UpdateLLMQInstantSendDIP0024FromArgs(args); - // V20 features for CbTx (credit pool, CL) have no meaning without masternodes - assert(consensus.V20Height >= consensus.DIP0003Height); - // MN_RR reallocate part of reward to CreditPool which exits since V20 - assert(consensus.MN_RRHeight >= consensus.V20Height); - } - - /** - * Allows modifying the Version Bits regtest parameters. - */ - void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout, int min_activation_height, int64_t nWindowSize, int64_t nThresholdStart, int64_t nThresholdMin, int64_t nFalloffCoeff, int64_t nUseEHF) - { - consensus.vDeployments[d].nStartTime = nStartTime; - consensus.vDeployments[d].nTimeout = nTimeout; - consensus.vDeployments[d].min_activation_height = min_activation_height; - 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; - } - if (nUseEHF != -1) { - consensus.vDeployments[d].useEHF = nUseEHF > 0; - } - } - void UpdateActivationParametersFromArgs(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 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, const Consensus::LLMQType llmqType) - { - auto params = std::ranges::find_if(consensus.llmqs, [llmqType](const auto& llmq){ return llmq.type == llmqType;}); - assert(params != consensus.llmqs.end()); - params->size = size; - params->minSize = threshold; - params->threshold = threshold; - params->dkgBadVotesThreshold = threshold; - } - - /** - * Allows modifying the LLMQ type for InstantSend (DIP0024). - */ - void UpdateLLMQDIP0024InstantSend(Consensus::LLMQType llmqType) - { - consensus.llmqTypeDIP0024InstantSend = llmqType; - } - - void UpdateLLMQTestParametersFromArgs(const ArgsManager& args, const Consensus::LLMQType llmqType); - void UpdateLLMQInstantSendDIP0024FromArgs(const ArgsManager& args); -}; - -static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& consensus) +static void ReadRegTestActivationArgs(const ArgsManager& args, CChainParams::RegTestOptions& options) { for (const std::string& arg : args.GetArgs("-testactivationheight")) { const auto found{arg.find('@')}; if (found == std::string::npos) { throw std::runtime_error(strprintf("Invalid format (%s) for -testactivationheight=name@height.", arg)); } - const auto name{arg.substr(0, found)}; + const auto value{arg.substr(found + 1)}; int32_t height; if (!ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits::max()) { throw std::runtime_error(strprintf("Invalid height value (%s) for -testactivationheight=name@height.", arg)); } - if (name == "bip147") { - consensus.BIP147Height = int{height}; - } else if (name == "bip34") { - consensus.BIP34Height = int{height}; - } else if (name == "dersig") { - consensus.BIP66Height = int{height}; - } else if (name == "cltv") { - consensus.BIP65Height = int{height}; - } else if (name == "csv") { - consensus.CSVHeight = int{height}; - } else if (name == "brr") { - consensus.BRRHeight = int{height}; - } else if (name == "dip0001") { - consensus.DIP0001Height = int{height}; - } else if (name == "dip0008") { - consensus.DIP0008Height = int{height}; - } else if (name == "dip0024") { - consensus.DIP0024Height = int{height}; - consensus.DIP0024QuorumsHeight = int{height}; - } else if (name == "v19") { - consensus.V19Height = int{height}; - } else if (name == "v20") { - consensus.V20Height = int{height}; - } else if (name == "mn_rr") { - consensus.MN_RRHeight = int{height}; + + const auto deployment_name{arg.substr(0, found)}; + if (const auto buried_deployment = GetBuriedDeployment(deployment_name)) { + options.activation_heights[*buried_deployment] = height; } else { throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg)); } } -} - -void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args) -{ - MaybeUpdateHeights(args, consensus); if (!args.IsArgSet("-vbparams")) return; @@ -1097,43 +52,54 @@ void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args) "::::: or " "::::::::"); } - int64_t nStartTime, nTimeout, nWindowSize = -1, nThresholdStart = -1, nThresholdMin = -1, nFalloffCoeff = -1, nUseEHF = -1; - int min_activation_height = 0; - if (!ParseInt64(vDeploymentParams[1], &nStartTime)) { + CChainParams::VersionBitsParameters vbparams{}; + if (!ParseInt64(vDeploymentParams[1], &vbparams.start_time)) { throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1])); } - if (!ParseInt64(vDeploymentParams[2], &nTimeout)) { + if (!ParseInt64(vDeploymentParams[2], &vbparams.timeout)) { throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2])); } - if (vDeploymentParams.size() >= 4 && !ParseInt32(vDeploymentParams[3], &min_activation_height)) { - throw std::runtime_error(strprintf("Invalid min_activation_height (%s)", vDeploymentParams[3])); + if (vDeploymentParams.size() >= 4) { + if (!ParseInt32(vDeploymentParams[3], &vbparams.min_activation_height)) { + throw std::runtime_error(strprintf("Invalid min_activation_height (%s)", vDeploymentParams[3])); + } + } else { + vbparams.min_activation_height = 0; } if (vDeploymentParams.size() >= 6) { - if (!ParseInt64(vDeploymentParams[4], &nWindowSize)) { + if (!ParseInt64(vDeploymentParams[4], &vbparams.window_size)) { throw std::runtime_error(strprintf("Invalid nWindowSize (%s)", vDeploymentParams[4])); } - if (!ParseInt64(vDeploymentParams[5], &nThresholdStart)) { + if (!ParseInt64(vDeploymentParams[5], &vbparams.threshold_start)) { throw std::runtime_error(strprintf("Invalid nThresholdStart (%s)", vDeploymentParams[5])); } } if (vDeploymentParams.size() == 9) { - if (!ParseInt64(vDeploymentParams[6], &nThresholdMin)) { + if (!ParseInt64(vDeploymentParams[6], &vbparams.threshold_min)) { throw std::runtime_error(strprintf("Invalid nThresholdMin (%s)", vDeploymentParams[6])); } - if (!ParseInt64(vDeploymentParams[7], &nFalloffCoeff)) { + if (!ParseInt64(vDeploymentParams[7], &vbparams.falloff_coeff)) { throw std::runtime_error(strprintf("Invalid nFalloffCoeff (%s)", vDeploymentParams[7])); } - if (!ParseInt64(vDeploymentParams[8], &nUseEHF)) { + if (!ParseInt64(vDeploymentParams[8], &vbparams.use_ehf)) { throw std::runtime_error(strprintf("Invalid nUseEHF (%s)", vDeploymentParams[8])); } } 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, min_activation_height, nWindowSize, nThresholdStart, nThresholdMin, nFalloffCoeff, nUseEHF); + // Optional Dash fields left at -1 keep any value set by an earlier -vbparams + // for the same deployment, as UpdateVersionBitsParameters() did before. + auto& entry = options.version_bits_parameters[Consensus::DeploymentPos(j)]; + if (vbparams.window_size == -1) vbparams.window_size = entry.window_size; + if (vbparams.threshold_start == -1) vbparams.threshold_start = entry.threshold_start; + if (vbparams.threshold_min == -1) vbparams.threshold_min = entry.threshold_min; + if (vbparams.falloff_coeff == -1) vbparams.falloff_coeff = entry.falloff_coeff; + if (vbparams.use_ehf == -1) vbparams.use_ehf = entry.use_ehf; + entry = vbparams; found = true; LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld, min_activation_height=%ld, window=%ld, thresholdstart=%ld, thresholdmin=%ld, falloffcoeff=%ld, useehf=%ld\n", - vDeploymentParams[0], nStartTime, nTimeout, min_activation_height, nWindowSize, nThresholdStart, nThresholdMin, nFalloffCoeff, nUseEHF); + vDeploymentParams[0], vbparams.start_time, vbparams.timeout, vbparams.min_activation_height, vbparams.window_size, vbparams.threshold_start, vbparams.threshold_min, vbparams.falloff_coeff, vbparams.use_ehf); break; } } @@ -1143,7 +109,7 @@ void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args) } } -void CRegTestParams::UpdateDIP3ParametersFromArgs(const ArgsManager& args) +static void ReadRegTestDIP3Args(const ArgsManager& args, CChainParams::RegTestOptions& options) { if (!args.IsArgSet("-dip3params")) return; @@ -1160,10 +126,10 @@ void CRegTestParams::UpdateDIP3ParametersFromArgs(const ArgsManager& args) 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); + options.dip3_parameters = CChainParams::DIP3Parameters{nDIP3ActivationHeight, nDIP3EnforcementHeight}; } -void CRegTestParams::UpdateBudgetParametersFromArgs(const ArgsManager& args) +static void ReadRegTestBudgetArgs(const ArgsManager& args, CChainParams::RegTestOptions& options) { if (!args.IsArgSet("-budgetparams")) return; @@ -1183,10 +149,10 @@ void CRegTestParams::UpdateBudgetParametersFromArgs(const ArgsManager& args) 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); + options.budget_parameters = CChainParams::BudgetParameters{nMasternodePaymentsStartBlock, nBudgetPaymentsStartBlock, nSuperblockStartBlock}; } -void CRegTestParams::UpdateLLMQTestParametersFromArgs(const ArgsManager& args, const Consensus::LLMQType llmqType) +static void ReadRegTestLLMQTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& options, const Consensus::LLMQType llmqType) { assert(llmqType == Consensus::LLMQType::LLMQ_TEST || llmqType == Consensus::LLMQType::LLMQ_TEST_INSTANTSEND || llmqType == Consensus::LLMQType::LLMQ_TEST_PLATFORM); @@ -1219,141 +185,50 @@ void CRegTestParams::UpdateLLMQTestParametersFromArgs(const ArgsManager& args, c llmq_name, size, Consensus::MAX_LLMQ_SIZE)); } LogPrintf("Setting %s parameters to size=%ld, threshold=%ld\n", llmq_name, size, threshold); - UpdateLLMQTestParameters(size, threshold, llmqType); + options.llmq_test_parameters[llmqType] = CChainParams::LLMQParameters{size, threshold}; } -void CRegTestParams::UpdateLLMQInstantSendDIP0024FromArgs(const ArgsManager& args) +static void ReadRegTestLLMQInstantSendDIP0024Args(const ArgsManager& args, CChainParams::RegTestOptions& options) { if (!args.IsArgSet("-llmqtestinstantsenddip0024")) return; - const auto& llmq_params_opt = GetLLMQ(consensus.llmqTypeDIP0024InstantSend); - assert(llmq_params_opt.has_value()); - - std::string strLLMQType = gArgs.GetArg("-llmqtestinstantsenddip0024", std::string(llmq_params_opt->name)); - - Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE; - for (const auto& params : consensus.llmqs) { - if (params.name == strLLMQType) { - llmqType = params.type; - } - } - if (llmqType == Consensus::LLMQType::LLMQ_NONE) { - throw std::runtime_error("Invalid LLMQ type specified for -llmqtestinstantsenddip0024."); - } - LogPrintf("Setting llmqtestinstantsenddip0024 to %ld\n", std23::to_underlying(llmqType)); - UpdateLLMQDIP0024InstantSend(llmqType); -} - -void CDevNetParams::UpdateDevnetSubsidyAndDiffParametersFromArgs(const ArgsManager& args) -{ - if (!args.IsArgSet("-minimumdifficultyblocks") && !args.IsArgSet("-highsubsidyblocks") && !args.IsArgSet("-highsubsidyfactor")) return; - - int nMinimumDifficultyBlocks = gArgs.GetIntArg("-minimumdifficultyblocks", consensus.nMinimumDifficultyBlocks); - int nHighSubsidyBlocks = gArgs.GetIntArg("-highsubsidyblocks", consensus.nHighSubsidyBlocks); - int nHighSubsidyFactor = gArgs.GetIntArg("-highsubsidyfactor", consensus.nHighSubsidyFactor); - LogPrintf("Setting minimumdifficultyblocks=%ld, highsubsidyblocks=%ld, highsubsidyfactor=%ld\n", nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor); - UpdateDevnetSubsidyAndDiffParameters(nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor); + options.llmq_dip0024_instantsend = args.GetArg("-llmqtestinstantsenddip0024", ""); } -void CDevNetParams::UpdateDevnetLLMQChainLocksFromArgs(const ArgsManager& args) +void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& options) { - if (!args.IsArgSet("-llmqchainlocks")) return; - - const auto& llmq_params_opt = GetLLMQ(consensus.llmqTypeChainLocks); - assert(llmq_params_opt.has_value()); - - std::string strLLMQType = gArgs.GetArg("-llmqchainlocks", std::string(llmq_params_opt->name)); - - Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE; - for (const auto& params : consensus.llmqs) { - if (params.name == strLLMQType) { - if (params.useRotation) { - throw std::runtime_error("LLMQ type specified for -llmqchainlocks must NOT use rotation"); - } - llmqType = params.type; - } - } - if (llmqType == Consensus::LLMQType::LLMQ_NONE) { - throw std::runtime_error("Invalid LLMQ type specified for -llmqchainlocks."); - } - LogPrintf("Setting llmqchainlocks to size=%ld\n", static_cast(llmqType)); - UpdateDevnetLLMQChainLocks(llmqType); -} - -void CDevNetParams::UpdateDevnetLLMQInstantSendDIP0024FromArgs(const ArgsManager& args) -{ - if (!args.IsArgSet("-llmqinstantsenddip0024")) return; - - const auto& llmq_params_opt = GetLLMQ(consensus.llmqTypeDIP0024InstantSend); - assert(llmq_params_opt.has_value()); - - std::string strLLMQType = gArgs.GetArg("-llmqinstantsenddip0024", std::string(llmq_params_opt->name)); - - Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE; - for (const auto& params : consensus.llmqs) { - if (params.name == strLLMQType) { - if (!params.useRotation) { - throw std::runtime_error("LLMQ type specified for -llmqinstantsenddip0024 must use rotation"); - } - llmqType = params.type; - } - } - if (llmqType == Consensus::LLMQType::LLMQ_NONE) { - throw std::runtime_error("Invalid LLMQ type specified for -llmqinstantsenddip0024."); - } - LogPrintf("Setting llmqinstantsenddip0024 to size=%ld\n", static_cast(llmqType)); - UpdateDevnetLLMQDIP0024InstantSend(llmqType); + if (auto value = args.GetBoolArg("-fastprune")) options.fastprune = *value; + + ReadRegTestActivationArgs(args, options); + ReadRegTestDIP3Args(args, options); + ReadRegTestBudgetArgs(args, options); + ReadRegTestLLMQTestArgs(args, options, Consensus::LLMQType::LLMQ_TEST); + ReadRegTestLLMQTestArgs(args, options, Consensus::LLMQType::LLMQ_TEST_INSTANTSEND); + ReadRegTestLLMQTestArgs(args, options, Consensus::LLMQType::LLMQ_TEST_PLATFORM); + ReadRegTestLLMQInstantSendDIP0024Args(args, options); } -void CDevNetParams::UpdateDevnetLLMQPlatformFromArgs(const ArgsManager& args) +static void ReadDevNetSubsidyAndDiffArgs(const ArgsManager& args, CChainParams::DevNetOptions& options) { - if (!args.IsArgSet("-llmqplatform")) return; - - const auto& llmq_params_opt = GetLLMQ(consensus.llmqTypePlatform); - assert(llmq_params_opt.has_value()); - - std::string strLLMQType = gArgs.GetArg("-llmqplatform", std::string(llmq_params_opt->name)); - - Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE; - for (const auto& params : consensus.llmqs) { - if (params.name == strLLMQType) { - llmqType = params.type; - } + if (args.IsArgSet("-minimumdifficultyblocks")) { + options.minimum_difficulty_blocks = args.GetIntArg("-minimumdifficultyblocks", 0); + LogPrintf("Setting minimumdifficultyblocks=%ld\n", *options.minimum_difficulty_blocks); } - if (llmqType == Consensus::LLMQType::LLMQ_NONE) { - throw std::runtime_error("Invalid LLMQ type specified for -llmqplatform."); - } - LogPrintf("Setting llmqplatform to size=%ld\n", static_cast(llmqType)); - UpdateDevnetLLMQPlatform(llmqType); -} - -void CDevNetParams::UpdateDevnetLLMQMnhfFromArgs(const ArgsManager& args) -{ - if (!args.IsArgSet("-llmqmnhf")) return; - - const auto& llmq_params_opt = GetLLMQ(consensus.llmqTypeMnhf); - assert(llmq_params_opt.has_value()); - - std::string strLLMQType = gArgs.GetArg("-llmqmnhf", std::string(llmq_params_opt->name)); - - Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE; - for (const auto& params : consensus.llmqs) { - if (params.name == strLLMQType) { - llmqType = params.type; - } + if (args.IsArgSet("-highsubsidyblocks")) { + options.high_subsidy_blocks = args.GetIntArg("-highsubsidyblocks", 0); + LogPrintf("Setting highsubsidyblocks=%ld\n", *options.high_subsidy_blocks); } - if (llmqType == Consensus::LLMQType::LLMQ_NONE) { - throw std::runtime_error("Invalid LLMQ type specified for -llmqmnhf."); + if (args.IsArgSet("-highsubsidyfactor")) { + options.high_subsidy_factor = args.GetIntArg("-highsubsidyfactor", 1); + LogPrintf("Setting highsubsidyfactor=%ld\n", *options.high_subsidy_factor); } - LogPrintf("Setting llmqmnhf to size=%ld\n", static_cast(llmqType)); - UpdateDevnetLLMQMnhf(llmqType); } -void CDevNetParams::UpdateDevnetPowTargetSpacingFromArgs(const ArgsManager& args) +static void ReadDevNetPowTargetSpacingArgs(const ArgsManager& args, CChainParams::DevNetOptions& options) { if (!args.IsArgSet("-powtargetspacing")) return; - std::string strPowTargetSpacing = gArgs.GetArg("-powtargetspacing", ""); + std::string strPowTargetSpacing = args.GetArg("-powtargetspacing", ""); int64_t powTargetSpacing; if (!ParseInt64(strPowTargetSpacing, &powTargetSpacing)) { @@ -1365,10 +240,10 @@ void CDevNetParams::UpdateDevnetPowTargetSpacingFromArgs(const ArgsManager& args } LogPrintf("Setting powTargetSpacing to %ld\n", powTargetSpacing); - UpdateDevnetPowTargetSpacing(powTargetSpacing); + options.pow_target_spacing = powTargetSpacing; } -void CDevNetParams::UpdateLLMQDevnetParametersFromArgs(const ArgsManager& args) +static void ReadDevNetLLMQDevnetParamsArgs(const ArgsManager& args, CChainParams::DevNetOptions& options) { if (!args.IsArgSet("-llmqdevnetparams")) return; @@ -1389,7 +264,28 @@ void CDevNetParams::UpdateLLMQDevnetParametersFromArgs(const ArgsManager& args) size, Consensus::MAX_LLMQ_SIZE)); } LogPrintf("Setting LLMQ_DEVNET parameters to size=%ld, threshold=%ld\n", size, threshold); - UpdateLLMQDevnetParameters(size, threshold); + options.llmq_devnet_parameters = CChainParams::LLMQParameters{size, threshold}; +} + +void ReadDevNetArgs(const ArgsManager& args, CChainParams::DevNetOptions& options) +{ + options.name = args.GetDevNetName(); + + ReadDevNetSubsidyAndDiffArgs(args, options); + if (args.IsArgSet("-llmqchainlocks")) { + options.llmq_chainlocks = args.GetArg("-llmqchainlocks", ""); + } + if (args.IsArgSet("-llmqinstantsenddip0024")) { + options.llmq_dip0024_instantsend = args.GetArg("-llmqinstantsenddip0024", ""); + } + if (args.IsArgSet("-llmqplatform")) { + options.llmq_platform = args.GetArg("-llmqplatform", ""); + } + if (args.IsArgSet("-llmqmnhf")) { + options.llmq_mnhf = args.GetArg("-llmqmnhf", ""); + } + ReadDevNetLLMQDevnetParamsArgs(args, options); + ReadDevNetPowTargetSpacingArgs(args, options); } static std::unique_ptr globalChainParams; @@ -1402,13 +298,17 @@ const CChainParams &Params() { std::unique_ptr CreateChainParams(const ArgsManager& args, const std::string& chain) { if (chain == CBaseChainParams::MAIN) { - return std::unique_ptr(new CMainParams()); + return CChainParams::Main(); } else if (chain == CBaseChainParams::TESTNET) { - return std::unique_ptr(new CTestNetParams()); + return CChainParams::TestNet(); } else if (chain == CBaseChainParams::DEVNET) { - return std::unique_ptr(new CDevNetParams(args)); + auto opts = CChainParams::DevNetOptions{}; + ReadDevNetArgs(args, opts); + return CChainParams::DevNet(opts); } else if (chain == CBaseChainParams::REGTEST) { - return std::unique_ptr(new CRegTestParams(args)); + auto opts = CChainParams::RegTestOptions{}; + ReadRegTestArgs(args, opts); + return CChainParams::RegTest(opts); } throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); } diff --git a/src/chainparams.h b/src/chainparams.h index dc21b75f60f9..f787c1bf6a90 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -6,6 +6,8 @@ #ifndef BITCOIN_CHAINPARAMS_H #define BITCOIN_CHAINPARAMS_H +#include + #include #include #include @@ -14,189 +16,13 @@ #include #include +#include #include #include #include +#include #include -typedef std::map MapCheckpoints; - -struct CCheckpointData { - MapCheckpoints mapCheckpoints; - - int GetHeight() const { - const auto& final_checkpoint = mapCheckpoints.rbegin(); - return final_checkpoint->first /* height */; - } -}; - -struct AssumeutxoHash : public BaseHash { - explicit AssumeutxoHash(const uint256& hash) : BaseHash(hash) {} -}; - -struct EvoSnapshotHash : public BaseHash { - explicit EvoSnapshotHash(const uint256& hash) : BaseHash(hash) {} -}; - -/** - * Holds configuration for use during UTXO snapshot load and validation. The contents - * here are security critical, since they dictate which UTXO snapshots are recognized - * as valid. - */ -struct AssumeutxoData { - //! The expected hash of the deserialized UTXO set. - const AssumeutxoHash hash_serialized; - - //! The expected single-SHA256 hash of the canonical Dash evo section. - const EvoSnapshotHash evo_hash; - - //! Used to populate the nChainTx value, which is used during BlockManager::LoadBlockIndex(). - //! - //! We need to hardcode the value here because this is computed cumulatively using block data, - //! which we do not necessarily have at the time of snapshot load. - const unsigned int nChainTx; -}; - -using MapAssumeutxo = std::map; - -/** - * Holds various statistics on transactions within a chain. Used to estimate - * verification progress during chain sync. - * - * See also: CChainParams::TxData, GuessVerificationProgress. - */ -struct ChainTxData { - int64_t nTime; - int64_t nTxCount; - double dTxRate; -}; - -/** - * CChainParams defines various tweakable parameters of a given instance of the - * Dash system. - */ -class CChainParams -{ -public: - enum Base58Type { - PUBKEY_ADDRESS, - SCRIPT_ADDRESS, - SECRET_KEY, // BIP16 - EXT_PUBLIC_KEY, // BIP32 - EXT_SECRET_KEY, // BIP32 - - MAX_BASE58_TYPES - }; - - const Consensus::Params& GetConsensus() const { return consensus; } - const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; } - uint16_t GetDefaultPort() const { return nDefaultPort; } - uint16_t GetDefaultPort(Network net) const - { - return net == NET_I2P ? I2P_SAM31_PORT : GetDefaultPort(); - } - uint16_t GetDefaultPort(const std::string& addr) const - { - CNetAddr a; - return a.SetSpecial(addr) ? GetDefaultPort(a.GetNetwork()) : GetDefaultPort(); - } - uint16_t GetDefaultPlatformP2PPort() const { return nDefaultPlatformP2PPort; } - uint16_t GetDefaultPlatformHTTPPort() const { return nDefaultPlatformHTTPPort; } - - const CBlock& GenesisBlock() const { return genesis; } - const CBlock& DevNetGenesisBlock() const { return devnetGenesis; } - /** Default value for -checkmempool and -checkblockindex argument */ - bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; } - /** Require addresses specified with "-externalip" parameter to be routable */ - bool RequireRoutableExternalIP() const { return fRequireRoutableExternalIP; } - /** If this chain allows time to be mocked */ - bool IsMockableChain() const { return m_is_mockable_chain; } - /** If this chain is exclusively used for testing */ - bool IsTestChain() const { return m_is_test_chain; } - uint64_t PruneAfterHeight() const { return nPruneAfterHeight; } - /** Minimum free space (in GB) needed for data directory */ - uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; } - /** Minimum free space (in GB) needed for data directory when pruned; Does not include prune target*/ - uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; } - /** Whether it is possible to mine blocks on demand (no retargeting) */ - bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; } - /** Allow multiple addresses to be selected from the same network group (e.g. 192.168.x.x) */ - bool AllowMultipleAddressesFromGroup() const { return fAllowMultipleAddressesFromGroup; } - /** How long to wait until we allow retrying of a LLMQ connection */ - int LLMQConnectionRetryTimeout() const { return nLLMQConnectionRetryTimeout; } - /** Return the network string */ - std::string NetworkIDString() const { return strNetworkID; } - /** Return the list of hostnames to look up for DNS seeds */ - const std::vector& DNSSeeds() const { return vSeeds; } - const std::vector& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; } - /** DIP-18 Platform address bech32m HRP: "dash" on mainnet, "tdash" on test chains */ - const std::string& Bech32PlatformHRP() const { return bech32_platform_hrp; } - int ExtCoinType() const { return nExtCoinType; } - const std::vector& FixedSeeds() const { return vFixedSeeds; } - const CCheckpointData& Checkpoints() const { return checkpointData; } - - //! Get allowed assumeutxo configuration. - //! @see ChainstateManager - const MapAssumeutxo& Assumeutxo() const { return m_assumeutxo_data; } - - const ChainTxData& TxData() const { return chainTxData; } - void UpdateDIP3Parameters(int nActivationHeight, int nEnforcementHeight); - void UpdateDIP8Parameters(int nActivationHeight); - void UpdateBudgetParameters(int nMasternodePaymentsStartBlock, int nBudgetPaymentsStartBlock, int nSuperblockStartBlock); - void UpdateLLMQInstantSend(Consensus::LLMQType llmqType); - /** - * Validate params for Masternodes EHF - * - * @param[in] nBit The version bit to update - * @param[in] timePast The block time to validate if release is already time-outed - * @return Whether params are legit and params are updated (if release is known) - */ - bool IsValidMNActivation(int nBit, int64_t timePast) const; - int PoolMinParticipants() const { return nPoolMinParticipants; } - int PoolMaxParticipants() const { return nPoolMaxParticipants; } - int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; } - const std::string& SporkAddress() const { return strSporkAddress; } - int CreditPoolPeriodBlocks() const { return nCreditPoolPeriodBlocks; } - [[nodiscard]] std::optional GetLLMQ(Consensus::LLMQType llmqType) const; - -protected: - CChainParams() {} - - Consensus::Params consensus; - CMessageHeader::MessageStartChars pchMessageStart; - uint16_t nDefaultPort; - uint64_t nPruneAfterHeight; - uint64_t m_assumed_blockchain_size; - uint64_t m_assumed_chain_state_size; - std::vector vSeeds; - std::vector base58Prefixes[MAX_BASE58_TYPES]; - std::string bech32_platform_hrp; - int nExtCoinType; - std::string strNetworkID; - CBlock genesis; - CBlock devnetGenesis; - std::vector vFixedSeeds; - bool fDefaultConsistencyChecks; - bool fRequireRoutableExternalIP; - bool m_is_test_chain; - bool fAllowMultipleAddressesFromGroup; - bool m_is_mockable_chain; - int nLLMQConnectionRetryTimeout; - CCheckpointData checkpointData; - MapAssumeutxo m_assumeutxo_data; - ChainTxData chainTxData; - int nPoolMinParticipants; - int nPoolMaxParticipants; - int nFulfilledRequestExpireTime; - std::string strSporkAddress; - uint16_t nDefaultPlatformP2PPort; - uint16_t nDefaultPlatformHTTPPort; - /// The number of blocks the credit pool tracks; 576 (one day) on mainnet, reduced on regtest - int nCreditPoolPeriodBlocks; - - void AddLLMQ(Consensus::LLMQType llmqType); -}; - /** * Creates and returns a std::unique_ptr of the chosen chain. * @returns a CChainParams* of the chosen chain. diff --git a/src/deploymentinfo.cpp b/src/deploymentinfo.cpp index 594bf6615a08..d2c8d9c35c9d 100644 --- a/src/deploymentinfo.cpp +++ b/src/deploymentinfo.cpp @@ -6,6 +6,8 @@ #include +#include + const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] = { { /*.name =*/ "testdummy", @@ -58,3 +60,33 @@ std::string DeploymentName(Consensus::BuriedDeployment dep) } // no default case, so the compiler can warn about missing cases return ""; } + +std::optional GetBuriedDeployment(const std::string_view name) +{ + if (name == "bip147") { + return Consensus::BuriedDeployment::DEPLOYMENT_BIP147; + } else if (name == "bip34") { + return Consensus::BuriedDeployment::DEPLOYMENT_HEIGHTINCB; + } else if (name == "dersig") { + return Consensus::BuriedDeployment::DEPLOYMENT_DERSIG; + } else if (name == "cltv") { + return Consensus::BuriedDeployment::DEPLOYMENT_CLTV; + } else if (name == "csv") { + return Consensus::BuriedDeployment::DEPLOYMENT_CSV; + } else if (name == "brr") { + return Consensus::BuriedDeployment::DEPLOYMENT_BRR; + } else if (name == "dip0001") { + return Consensus::BuriedDeployment::DEPLOYMENT_DIP0001; + } else if (name == "dip0008") { + return Consensus::BuriedDeployment::DEPLOYMENT_DIP0008; + } else if (name == "dip0024") { + return Consensus::BuriedDeployment::DEPLOYMENT_DIP0024; + } else if (name == "v19") { + return Consensus::BuriedDeployment::DEPLOYMENT_V19; + } else if (name == "v20") { + return Consensus::BuriedDeployment::DEPLOYMENT_V20; + } else if (name == "mn_rr") { + return Consensus::BuriedDeployment::DEPLOYMENT_MN_RR; + } + return std::nullopt; +} diff --git a/src/deploymentinfo.h b/src/deploymentinfo.h index 8b909dedb462..72ba297ea0b5 100644 --- a/src/deploymentinfo.h +++ b/src/deploymentinfo.h @@ -7,6 +7,7 @@ #include +#include #include struct VBDeploymentInfo { @@ -26,4 +27,6 @@ inline std::string DeploymentName(Consensus::DeploymentPos pos) return VersionBitsDeploymentInfo[pos].name; } +std::optional GetBuriedDeployment(const std::string_view deployment_name); + #endif // BITCOIN_DEPLOYMENTINFO_H diff --git a/src/instantsend/net_instantsend.cpp b/src/instantsend/net_instantsend.cpp index 6fb5dbcc9e7a..b5871d326546 100644 --- a/src/instantsend/net_instantsend.cpp +++ b/src/instantsend/net_instantsend.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp new file mode 100644 index 000000000000..a9310b5245a6 --- /dev/null +++ b/src/kernel/chainparams.cpp @@ -0,0 +1,1191 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2021 The Bitcoin Core developers +// Copyright (c) 2014-2025 The Dash Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include