Skip to content

Commit e4d54cd

Browse files
committed
Merge bitcoin#26177: refactor / kernel: Move non-gArgs chainparams functionality to kernel
b3e78dc refactor: Don't use global chainparams in chainstatemanager method (TheCharlatan) 382b692 Split non/kernel chainparams (Carl Dong) edabbc7 Add factory functions for Main/Test/Sig/Reg chainparams (Carl Dong) d938098 Remove UpdateVersionBitsParameters (Carl Dong) 84b8578 Decouple RegTestChainParams from ArgsManager (Carl Dong) 76cd4e7 Decouple SigNetChainParams from ArgsManager (Carl Dong) Pull request description: This pull request is part of the `libbitcoinkernel` project bitcoin#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 bitcoin#25290, bitcoin#25487, bitcoin#25527 and bitcoin#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 b3e78dc 🛁 ryanofsky: Code review ACK b3e78dc. Only changes since last review were recent review suggestions. ajtowns: ACK b3e78dc Tree-SHA512: 3835aca1d3e3c75cc3303dd584bab3a77e58f6c678724a5e359fe4b0e17e0763a00931ee6191f516b9fde50496f59cc691f0709c0254206db3863bbf7ab2cacd Dash adaptations: - src/kernel/chainparams.{h,cpp}: the moved CChainParams is Dash's, not Bitcoin's (the cherry-pick had created verbatim upstream files; both were rewritten). All Dash accessors and fields are kept: DevNetGenesisBlock, GetDefaultPlatformP2PPort/HTTPPort, RequireRoutableExternalIP, AllowMultipleAddressesFromGroup, LLMQConnectionRetryTimeout, Bech32PlatformHRP, ExtCoinType, IsValidMNActivation, PoolMin/MaxParticipants, FulfilledRequestExpireTime, SporkAddress, CreditPoolPeriodBlocks, GetLLMQ/AddLLMQ, UpdateDIP3/DIP8/Budget/LLMQInstantSend declarations. - src/kernel/chainparams.{h,cpp}: Dash has a fourth network, so a fourth factory CChainParams::DevNet(const DevNetOptions&) was added alongside Main()/TestNet()/RegTest(opts), mirroring upstream's pattern. - src/kernel/chainparams.h: CChainParams::VersionBitsParameters carries Dash's extra -vbparams fields (window_size, threshold_start, threshold_min, falloff_coeff, use_ehf) with the existing -1 "leave unchanged" sentinel, so -vbparams semantics are unchanged. - src/kernel/chainparams.h: RegTestOptions is extended with Dash-only entries (dip3_parameters, budget_parameters, llmq_test_parameters, llmq_dip0024_instantsend) and DevNetOptions carries name, minimum_difficulty_blocks, high_subsidy_blocks, high_subsidy_factor, pow_target_spacing, llmq_chainlocks, llmq_dip0024_instantsend, llmq_platform, llmq_mnhf, llmq_devnet_parameters, plus helper structs LLMQParameters/DIP3Parameters/BudgetParameters. - LLMQ overrides travel as quorum *names* (strings) in the options structs: resolving a name to a Consensus::LLMQType needs the per-chain consensus.llmqs list, which only exists inside the kernel constructors. The lookup loops, the rotation checks and the exact error strings/LogPrintf messages of the old Update*FromArgs functions are preserved, just moved into the kernel side. - src/kernel/chainparams.cpp: FindDevNetGenesisBlock()/CDevNetParams no longer call gArgs.GetDevNetName(); the devnet name arrives via DevNetOptions::name (filled by ReadDevNetArgs from args.GetDevNetName()), which is what keeps the kernel gArgs-free. - src/kernel/chainparams.cpp: CRegTestParams::UpdateActivationParameters switches exhaustively over Dash's 15 Consensus::BuriedDeployment values (no -Wswitch warning); DEPLOYMENT_DIP0024 sets both DIP0024Height and DIP0024QuorumsHeight, exactly as the old name-based if/else did. DEPLOYMENT_DIP0003/DIP0020/WITHDRAWALS are unreachable because GetBuriedDeployment does not map any -testactivationheight name to them, matching current behaviour. - src/deploymentinfo.cpp: GetBuriedDeployment() was auto-applied with Bitcoin's names and returned DEPLOYMENT_SEGWIT, which does not exist in Dash. Rewritten to the exact set of names -testactivationheight accepted before (bip147, bip34, dersig, cltv, csv, brr, dip0001, dip0008, dip0024, v19, v20, mn_rr); no name was added or removed. - src/chainparams.cpp: Dash's arg readers keep their existing decomposition as file-static helpers (ReadRegTestActivationArgs/DIP3/Budget/LLMQTest/LLMQInstantSendDIP0024, ReadDevNetSubsidyAndDiffArgs/PowTargetSpacing/LLMQDevnetParams) called from ReadRegTestArgs()/ReadDevNetArgs(). Merging them into one function was not possible verbatim because each body ends with an early `if (!args.IsArgSet(...)) return;`. - src/chainparams.cpp: ReadDevNetSubsidyAndDiffArgs applies -minimumdifficultyblocks/-highsubsidyblocks/-highsubsidyfactor as independent optionals and therefore logs three separate lines instead of the single combined LogPrintf; net effect on consensus is identical (unset values keep the chain defaults, which are no longer visible from the arg reader). - src/chainparams.cpp: CreateChainParams dispatches MAIN/TESTNET/DEVNET/REGTEST; the DEVNET branch uses the new ReadDevNetArgs + CChainParams::DevNet(opts). Include list and SetupChainParamsOptions() are untouched, as upstream left them untouched. - src/validation.h: added <deploymentstatus.h>, <kernel/chainparams.h>, <kernel/chainstatemanager_opts.h>, <node/blockstorage.h>. Upstream's <fs.h> and <kernel/cs_main.h> were not added: Dash uses util/fs.h and does not have that include in this block. Not applicable to Dash (intentionally omitted): - src/kernel/chainparams.cpp: Upstream's SigNetParams class body, CChainParams::SigNet() factory and the signet challenge/seed handling moved into the kernel file; Dash has no signet chain, so there is no counterpart to move. Dash's own CMainParams/CTestNetParams/CDevNetParams/CRegTestParams (with all DIP/LLMQ/masternode/governance/spork parameters) were moved instead. (reviewer: not for Dash) - src/kernel/chainparams.h: Upstream's SigNetOptions struct (challenge/seeds) and the static SigNet() declaration; no signet in Dash. Dash instead declares VersionBitsParameters (extended with window/threshold/falloff/useEHF), LLMQParameters, DIP3Parameters, BudgetParameters, DevNetOptions and RegTestOptions. (reviewer: not for Dash) - src/chainparams.cpp: ReadSigNetArgs() and the CBaseChainParams::SIGNET branch of CreateChainParams(); Dash has no signet. Dash adds ReadDevNetArgs()/the DEVNET branch in the same shape. (reviewer: not for Dash) - src/deploymentinfo.cpp: GetBuriedDeployment() returning Consensus::DEPLOYMENT_SEGWIT for name "segwit"; Dash has no segwit buried deployment. The Dash function covers exactly the 12 names the previous MaybeUpdateHeights() accepted (bip147, bip34, dersig, cltv, csv, brr, dip0001, dip0008, dip0024, v19, v20, mn_rr). (reviewer: not for Dash) - src/kernel/chainparams.cpp: Upstream's segwit/taproot consensus fields, script_flag_exceptions maps and bech32_hrp carried in the moved Bitcoin chain classes; Dash's classes have no such fields (Dash keeps bech32_platform_hrp, nExtCoinType, EvoSnapshotHash etc., all of which were moved). (reviewer: not for Dash) Replayed onto a newer base. Dash adaptations: - src/kernel/chainparams.h: EvoSnapshotHash struct and AssumeutxoData::evo_hash (added to src/chainparams.h on the new develop base) travel with the class into the kernel header, so develop's Dash evo-snapshot field is preserved. - src/kernel/chainparams.cpp: FindDevNetGenesisBlock() and CChainParams::AddLLMQ() use develop's LogError("...\n", ...) instead of the base's error(...) — the new base replaced error() in these two Dash-only helpers before they were moved. - src/kernel/chainparams.cpp: the two CRegTestParams m_assumeutxo_data entries carry develop's third aggregate member, EvoSnapshotHash{uint256{}}, between AssumeutxoHash and nChainTx. - src/chainparams.cpp: develop's '2009-2022 The Bitcoin Core developers' copyright line kept rather than the pre-rebase 2009-2021. - src/validation.h: upstream's kernel/chainparams.h + kernel/chainstatemanager_opts.h are inserted in sorted position alongside develop's new <kernel/cs_main.h> // IWYU pragma: export, which did not exist at the prior base. Upstream's <fs.h> is still not added: Dash uses util/fs.h. - src/wallet/test/wallet_tests.cpp: the prior backport added #include <chainparams.h> to wallet/test/availablecoins_tests.cpp (needed because validation.h no longer re-exports Params()); the new base deleted that file and moved the Dash-only UTXO tests into wallet_tests.cpp, so the include was applied there instead — that file calls Params().GetConsensus().DIP0003Height. - src/wallet/test/availablecoins_tests.cpp: deleted, following the new base (bitcoin#25789 + the Dash-only test move); the file's only backport hunk was the include described above. - src/kernel/chainparams.{h,cpp} content (Dash CChainParams instead of Bitcoin's, fourth DevNet() factory, Dash-extended VersionBitsParameters/RegTestOptions/DevNetOptions, name-based LLMQ override resolution, gArgs-free devnet name via DevNetOptions::name, Dash-specific GetBuriedDeployment names) is unchanged from the reviewed prior backport; see the prior commit body for the full rationale. Not applicable to Dash (intentionally omitted): - src/kernel/chainparams.cpp: Upstream's CSigNetParams / SigNetOptions / CChainParams::SigNet() and the ReadSigNetArgs reader: Dash has no signet chain, so there is no counterpart to move. - src/kernel/chainparams.h: Upstream's SigNetOptions struct and the signet challenge/seed members: no signet in Dash. - src/kernel/chainparams.cpp: Upstream's segwit/taproot chain fields and script_flag_exceptions maps do not exist in Dash; Dash's own chain classes (including DIP/LLMQ/masternode/governance/spork parameters) were moved instead. - src/deploymentinfo.cpp: Upstream's GetBuriedDeployment() returns Consensus::DEPLOYMENT_SEGWIT, which does not exist in Dash; the function was written over the exact set of names -testactivationheight already accepted (bip147, bip34, dersig, cltv, csv, brr, dip0001, dip0008, dip0024, v19, v20, mn_rr). Replayed onto a newer base. Dash adaptations: - src/chainparams.cpp: conflict resolved to the prior reviewed backport's content (verified identical to merge stage :3); the Dash CreateGenesisBlock/CreateDevNetGenesisBlock/FindDevNetGenesisBlock helpers, IsValidMNActivation, AddLLMQ/GetLLMQ and the CMain/CTestNet/CDevNet/CRegTest classes move to src/kernel/chainparams.cpp, leaving only the gArgs-reading Read*Args helpers behind - src/chainparams.h: conflict resolved to the prior reviewed backport's content; the Dash-extended CChainParams (platform ports, devnet genesis, LLMQ/spork/CoinJoin/credit-pool accessors, EvoSnapshotHash in AssumeutxoData) moves to src/kernel/chainparams.h, which this header now includes - src/kernel/chainparams.h: dropped RequireStandard()/fRequireStandard from the moved class — the new base already removed them from CChainParams via bitcoin#28354 (default acceptnonstdtxn=0 on all chains), which was not yet in the prior backport's base - src/kernel/chainparams.cpp: dropped the four fRequireStandard assignments (main/testnet/devnet/regtest) for the same reason - upstream ReadSigNetArgs has no Dash counterpart (no signet); the prior backport instead routes Dash's devnet through ReadDevNetArgs()/CChainParams::DevNet(DevNetOptions) and keeps the Dash-only -dip3params/-budgetparams/-llmqtest*/-llmqdevnetparams/-powtargetspacing readers as RegTest/DevNet option readers - upstream's flat ReadRegTestArgs is split into ReadRegTest{Activation,DIP3,Budget,LLMQTest,LLMQInstantSendDIP0024}Args because Dash's -vbparams accepts 3/4/6/9 fields (window, thresholdstart, thresholdmin, falloffcoeff, useehf) and regtest has several more Dash-only overrides Replayed onto a newer base. Dash adaptations: - src/chainparams.cpp: took the upstream side of the conflict, which removes the network classes (now in kernel/chainparams.cpp) and keeps the gArgs readers (ReadRegTestArgs/ReadDevNetArgs, CreateChainParams, SelectParams, SetupChainParamsOptions); matches the upstream stage and the previously reviewed prior.diff - src/kernel/chainparams.cpp: carried develop's CTestNetParams DEPLOYMENT_V24 nStartTime = 1790208000 (Thursday, September 24, 2026) into the moved testnet class; the old base had NEVER_ACTIVE, and this was the only change to src/chainparams.cpp between the old and new base Replayed onto a newer base. Dash adaptations: - src/bitcoin-chainstate.cpp: the ChainstateManager::Options initializer has no `.datadir = gArgs.GetDataDirNet(),` line because the new develop base's kernel::ChainstateManagerOpts has no `datadir` member (the prior base had one). Upstream only uses that line as context, so the upstream change `.chainparams = chainparams` -> `.chainparams = *chainparams` is applied alone. - All other staged files carry forward the published prior backport unchanged; their Dash adaptations (Makefile.am kernel/chainparams.cpp in libbitcoin_common and libdashkernel, added <chainparams.h> includes in Dash-only files such as active/dkgsession.cpp, chainlock/signing.cpp, instantsend/net_instantsend.cpp, qt/test/providertransactiontests.cpp and Dash tests, and the Dash CChainParams move into kernel/chainparams.cpp) are the same as in prior.diff Replayed onto a newer base. Dash adaptations: - src/chainparams.cpp: restored exactly the published resolution from prior.diff (checked by comparing its +/- lines with prior.diff: identical). Only the class bodies differ on the new base, and they move to kernel, so no line here changed. - src/kernel/chainparams.cpp: DEPLOYMENT_V24 .bit changed from 12 to 13 in CMainParams, CTestNetParams, CDevNetParams and CRegTestParams, carrying develop commit 1be3ac2 over to the moved classes. Without this the move would quietly undo the bit change. - All other staged files (Makefile.am, chainparams.h, deploymentinfo.{h,cpp}, validation.{h,cpp}, versionbits.h, node/blockstorage.cpp, node/mempool_args.cpp, bitcoin-chainstate.cpp, kernel/chainparams.h, and the Dash-only call sites active/dkgsession.cpp, chainlock/signing.cpp, instantsend/net_instantsend.cpp, qt/test/*, test/bls_tests.cpp, test/evo_islock_tests.cpp, test/llmq_chainlock_tests.cpp, test/validation_tests.cpp, wallet/test/wallet_tests.cpp) are unchanged from the published prior.diff, including its Dash adaptations: DevNetOptions/RegTestOptions for the LLMQ, DIP3, budget and devnet overrides, GetBuriedDeployment covering Dash's buried deployments, and the <chainparams.h> include fixes at call sites. Replayed onto a newer base. Dash adaptations: - src/validation.cpp: include conflict with the new base, which added #include <kernel/disconnected_transactions.h> where this backport adds #include <kernel/chainparams.h>; kept both, sorted alphabetically - src/active/dkgsession.cpp, src/chainlock/signing.cpp, src/instantsend/net_instantsend.cpp, src/qt/test/providertransactiontests.cpp, src/qt/test/wallettests.cpp, src/test/bls_tests.cpp, src/test/evo_islock_tests.cpp, src/test/llmq_chainlock_tests.cpp, src/test/validation_tests.cpp: (kept from the published backport) these Dash files now include <chainparams.h> directly, because validation.h includes <kernel/chainparams.h> instead of <chainparams.h> and so no longer pulls in Params() - src/chainparams.cpp, src/chainparams.h, src/kernel/chainparams.cpp, src/kernel/chainparams.h, src/deploymentinfo.*, src/versionbits.h, src/bitcoin-chainstate.cpp, src/node/*, src/validation.h, src/Makefile.am, src/wallet/test/wallet_tests.cpp: (kept from the published backport) carried over unchanged, including the Dash chain parameters, LLMQ and other Dash-specific fields moved into kernel/chainparams, and all earlier review fixes Replayed onto a newer base. Dash adaptations: - src/chainparams.cpp: took the prior backport's version unchanged (it matches blob 8d5a119, the prior post-image). On the HEAD side, the only change since the prior base (15db478) was #7807's DEPLOYMENT_EVO_SHARES blocks in the network classes, and this PR moves those classes out of the file - src/kernel/chainparams.cpp: added #7807's DEPLOYMENT_EVO_SHARES settings (bit 14, start/timeout, window, thresholds, falloff, useEHF) right after the DEPLOYMENT_V24 block in CMainParams, CTestNetParams, CDevNetParams and CRegTestParams, word for word, including mainnet's NEVER_ACTIVE/TODO start time. This keeps #7807's settings now that the class definitions live in kernel/chainparams.cpp - Carried over from the prior reviewed backport unchanged: Dash-only call sites (src/active/dkgsession.cpp, src/chainlock/signing.cpp, src/instantsend/net_instantsend.cpp, src/qt/test/providertransactiontests.cpp, src/qt/test/wallettests.cpp, src/test/bls_tests.cpp, src/test/evo_islock_tests.cpp, src/test/llmq_chainlock_tests.cpp, src/test/validation_tests.cpp, src/wallet/test/wallet_tests.cpp, src/versionbits.h) and the Dash devnet/LLMQ/EHF parts of src/kernel/chainparams.{h,cpp} and src/chainparams.{h,cpp}
1 parent f35a24c commit e4d54cd

23 files changed

Lines changed: 1631 additions & 1377 deletions

‎src/Makefile.am‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ BITCOIN_CORE_H = \
288288
interfaces/wallet.h \
289289
kernel/blockmanager_opts.h \
290290
kernel/chain.h \
291+
kernel/chainparams.h \
291292
kernel/chainstatemanager_opts.h \
292293
kernel/checks.h \
293294
kernel/coinstats.h \
@@ -994,6 +995,7 @@ libbitcoin_common_a_SOURCES = \
994995
external_signer.cpp \
995996
governance/common.cpp \
996997
init/common.cpp \
998+
kernel/chainparams.cpp \
997999
key.cpp \
9981000
key_io.cpp \
9991001
llmq/core_write.cpp \
@@ -1317,6 +1319,7 @@ libdashkernel_la_SOURCES = \
13171319
instantsend/lock.cpp \
13181320
kernel/chain.cpp \
13191321
kernel/checks.cpp \
1322+
kernel/chainparams.cpp \
13201323
kernel/coinstats.cpp \
13211324
kernel/context.cpp \
13221325
kernel/cs_main.cpp \

‎src/active/dkgsession.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <util/helpers.h>
1717

1818
#include <chain.h>
19+
#include <chainparams.h>
1920
#include <deploymentstatus.h>
2021
#include <validation.h>
2122

‎src/bitcoin-chainstate.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//
1212
// It is part of the libbitcoinkernel project.
1313

14+
#include <kernel/chainparams.h>
1415
#include <kernel/checks.h>
1516
#include <kernel/context.h>
1617
#include <kernel/validation_cache_sizes.h>
@@ -62,7 +63,7 @@ int main(int argc, char* argv[])
6263

6364
// SETUP: Misc Globals
6465
SelectParams(CBaseChainParams::MAIN);
65-
const CChainParams& chainparams = Params();
66+
auto chainparams = CChainParams::Main();
6667

6768
kernel::Context kernel_context{};
6869
// We can't use a goto here, but we can use an assert since none of the
@@ -91,7 +92,7 @@ int main(int argc, char* argv[])
9192

9293
// SETUP: Chainstate
9394
const ChainstateManager::Options chainman_opts{
94-
.chainparams = chainparams,
95+
.chainparams = *chainparams,
9596
};
9697
ChainstateManager chainman{chainman_opts};
9798

‎src/chainlock/signing.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <chainlock/clsig.h>
88
#include <chainlock/handler.h>
9+
#include <chainparams.h>
910
#include <instantsend/instantsend.h>
1011
#include <llmq/signing_shares.h>
1112
#include <masternode/sync.h>

‎src/chainparams.cpp‎

Lines changed: 92 additions & 1192 deletions
Large diffs are not rendered by default.

‎src/chainparams.h‎

Lines changed: 4 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#ifndef BITCOIN_CHAINPARAMS_H
77
#define BITCOIN_CHAINPARAMS_H
88

9+
#include <kernel/chainparams.h>
10+
911
#include <chainparamsbase.h>
1012
#include <consensus/params.h>
1113
#include <llmq/params.h>
@@ -14,189 +16,13 @@
1416
#include <protocol.h>
1517
#include <util/hash_type.h>
1618

19+
#include <cstdint>
1720
#include <memory>
1821
#include <optional>
1922
#include <string>
23+
#include <unordered_map>
2024
#include <vector>
2125

22-
typedef std::map<int, uint256> MapCheckpoints;
23-
24-
struct CCheckpointData {
25-
MapCheckpoints mapCheckpoints;
26-
27-
int GetHeight() const {
28-
const auto& final_checkpoint = mapCheckpoints.rbegin();
29-
return final_checkpoint->first /* height */;
30-
}
31-
};
32-
33-
struct AssumeutxoHash : public BaseHash<uint256> {
34-
explicit AssumeutxoHash(const uint256& hash) : BaseHash(hash) {}
35-
};
36-
37-
struct EvoSnapshotHash : public BaseHash<uint256> {
38-
explicit EvoSnapshotHash(const uint256& hash) : BaseHash(hash) {}
39-
};
40-
41-
/**
42-
* Holds configuration for use during UTXO snapshot load and validation. The contents
43-
* here are security critical, since they dictate which UTXO snapshots are recognized
44-
* as valid.
45-
*/
46-
struct AssumeutxoData {
47-
//! The expected hash of the deserialized UTXO set.
48-
const AssumeutxoHash hash_serialized;
49-
50-
//! The expected single-SHA256 hash of the canonical Dash evo section.
51-
const EvoSnapshotHash evo_hash;
52-
53-
//! Used to populate the nChainTx value, which is used during BlockManager::LoadBlockIndex().
54-
//!
55-
//! We need to hardcode the value here because this is computed cumulatively using block data,
56-
//! which we do not necessarily have at the time of snapshot load.
57-
const unsigned int nChainTx;
58-
};
59-
60-
using MapAssumeutxo = std::map<int, const AssumeutxoData>;
61-
62-
/**
63-
* Holds various statistics on transactions within a chain. Used to estimate
64-
* verification progress during chain sync.
65-
*
66-
* See also: CChainParams::TxData, GuessVerificationProgress.
67-
*/
68-
struct ChainTxData {
69-
int64_t nTime;
70-
int64_t nTxCount;
71-
double dTxRate;
72-
};
73-
74-
/**
75-
* CChainParams defines various tweakable parameters of a given instance of the
76-
* Dash system.
77-
*/
78-
class CChainParams
79-
{
80-
public:
81-
enum Base58Type {
82-
PUBKEY_ADDRESS,
83-
SCRIPT_ADDRESS,
84-
SECRET_KEY, // BIP16
85-
EXT_PUBLIC_KEY, // BIP32
86-
EXT_SECRET_KEY, // BIP32
87-
88-
MAX_BASE58_TYPES
89-
};
90-
91-
const Consensus::Params& GetConsensus() const { return consensus; }
92-
const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
93-
uint16_t GetDefaultPort() const { return nDefaultPort; }
94-
uint16_t GetDefaultPort(Network net) const
95-
{
96-
return net == NET_I2P ? I2P_SAM31_PORT : GetDefaultPort();
97-
}
98-
uint16_t GetDefaultPort(const std::string& addr) const
99-
{
100-
CNetAddr a;
101-
return a.SetSpecial(addr) ? GetDefaultPort(a.GetNetwork()) : GetDefaultPort();
102-
}
103-
uint16_t GetDefaultPlatformP2PPort() const { return nDefaultPlatformP2PPort; }
104-
uint16_t GetDefaultPlatformHTTPPort() const { return nDefaultPlatformHTTPPort; }
105-
106-
const CBlock& GenesisBlock() const { return genesis; }
107-
const CBlock& DevNetGenesisBlock() const { return devnetGenesis; }
108-
/** Default value for -checkmempool and -checkblockindex argument */
109-
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
110-
/** Require addresses specified with "-externalip" parameter to be routable */
111-
bool RequireRoutableExternalIP() const { return fRequireRoutableExternalIP; }
112-
/** If this chain allows time to be mocked */
113-
bool IsMockableChain() const { return m_is_mockable_chain; }
114-
/** If this chain is exclusively used for testing */
115-
bool IsTestChain() const { return m_is_test_chain; }
116-
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
117-
/** Minimum free space (in GB) needed for data directory */
118-
uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
119-
/** Minimum free space (in GB) needed for data directory when pruned; Does not include prune target*/
120-
uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
121-
/** Whether it is possible to mine blocks on demand (no retargeting) */
122-
bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
123-
/** Allow multiple addresses to be selected from the same network group (e.g. 192.168.x.x) */
124-
bool AllowMultipleAddressesFromGroup() const { return fAllowMultipleAddressesFromGroup; }
125-
/** How long to wait until we allow retrying of a LLMQ connection */
126-
int LLMQConnectionRetryTimeout() const { return nLLMQConnectionRetryTimeout; }
127-
/** Return the network string */
128-
std::string NetworkIDString() const { return strNetworkID; }
129-
/** Return the list of hostnames to look up for DNS seeds */
130-
const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
131-
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
132-
/** DIP-18 Platform address bech32m HRP: "dash" on mainnet, "tdash" on test chains */
133-
const std::string& Bech32PlatformHRP() const { return bech32_platform_hrp; }
134-
int ExtCoinType() const { return nExtCoinType; }
135-
const std::vector<uint8_t>& FixedSeeds() const { return vFixedSeeds; }
136-
const CCheckpointData& Checkpoints() const { return checkpointData; }
137-
138-
//! Get allowed assumeutxo configuration.
139-
//! @see ChainstateManager
140-
const MapAssumeutxo& Assumeutxo() const { return m_assumeutxo_data; }
141-
142-
const ChainTxData& TxData() const { return chainTxData; }
143-
void UpdateDIP3Parameters(int nActivationHeight, int nEnforcementHeight);
144-
void UpdateDIP8Parameters(int nActivationHeight);
145-
void UpdateBudgetParameters(int nMasternodePaymentsStartBlock, int nBudgetPaymentsStartBlock, int nSuperblockStartBlock);
146-
void UpdateLLMQInstantSend(Consensus::LLMQType llmqType);
147-
/**
148-
* Validate params for Masternodes EHF
149-
*
150-
* @param[in] nBit The version bit to update
151-
* @param[in] timePast The block time to validate if release is already time-outed
152-
* @return Whether params are legit and params are updated (if release is known)
153-
*/
154-
bool IsValidMNActivation(int nBit, int64_t timePast) const;
155-
int PoolMinParticipants() const { return nPoolMinParticipants; }
156-
int PoolMaxParticipants() const { return nPoolMaxParticipants; }
157-
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
158-
const std::string& SporkAddress() const { return strSporkAddress; }
159-
int CreditPoolPeriodBlocks() const { return nCreditPoolPeriodBlocks; }
160-
[[nodiscard]] std::optional<Consensus::LLMQParams> GetLLMQ(Consensus::LLMQType llmqType) const;
161-
162-
protected:
163-
CChainParams() {}
164-
165-
Consensus::Params consensus;
166-
CMessageHeader::MessageStartChars pchMessageStart;
167-
uint16_t nDefaultPort;
168-
uint64_t nPruneAfterHeight;
169-
uint64_t m_assumed_blockchain_size;
170-
uint64_t m_assumed_chain_state_size;
171-
std::vector<std::string> vSeeds;
172-
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
173-
std::string bech32_platform_hrp;
174-
int nExtCoinType;
175-
std::string strNetworkID;
176-
CBlock genesis;
177-
CBlock devnetGenesis;
178-
std::vector<uint8_t> vFixedSeeds;
179-
bool fDefaultConsistencyChecks;
180-
bool fRequireRoutableExternalIP;
181-
bool m_is_test_chain;
182-
bool fAllowMultipleAddressesFromGroup;
183-
bool m_is_mockable_chain;
184-
int nLLMQConnectionRetryTimeout;
185-
CCheckpointData checkpointData;
186-
MapAssumeutxo m_assumeutxo_data;
187-
ChainTxData chainTxData;
188-
int nPoolMinParticipants;
189-
int nPoolMaxParticipants;
190-
int nFulfilledRequestExpireTime;
191-
std::string strSporkAddress;
192-
uint16_t nDefaultPlatformP2PPort;
193-
uint16_t nDefaultPlatformHTTPPort;
194-
/// The number of blocks the credit pool tracks; 576 (one day) on mainnet, reduced on regtest
195-
int nCreditPoolPeriodBlocks;
196-
197-
void AddLLMQ(Consensus::LLMQType llmqType);
198-
};
199-
20026
/**
20127
* Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
20228
* @returns a CChainParams* of the chosen chain.

‎src/deploymentinfo.cpp‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include <consensus/params.h>
88

9+
#include <string_view>
10+
911
const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS] = {
1012
{
1113
/*.name =*/ "testdummy",
@@ -58,3 +60,33 @@ std::string DeploymentName(Consensus::BuriedDeployment dep)
5860
} // no default case, so the compiler can warn about missing cases
5961
return "";
6062
}
63+
64+
std::optional<Consensus::BuriedDeployment> GetBuriedDeployment(const std::string_view name)
65+
{
66+
if (name == "bip147") {
67+
return Consensus::BuriedDeployment::DEPLOYMENT_BIP147;
68+
} else if (name == "bip34") {
69+
return Consensus::BuriedDeployment::DEPLOYMENT_HEIGHTINCB;
70+
} else if (name == "dersig") {
71+
return Consensus::BuriedDeployment::DEPLOYMENT_DERSIG;
72+
} else if (name == "cltv") {
73+
return Consensus::BuriedDeployment::DEPLOYMENT_CLTV;
74+
} else if (name == "csv") {
75+
return Consensus::BuriedDeployment::DEPLOYMENT_CSV;
76+
} else if (name == "brr") {
77+
return Consensus::BuriedDeployment::DEPLOYMENT_BRR;
78+
} else if (name == "dip0001") {
79+
return Consensus::BuriedDeployment::DEPLOYMENT_DIP0001;
80+
} else if (name == "dip0008") {
81+
return Consensus::BuriedDeployment::DEPLOYMENT_DIP0008;
82+
} else if (name == "dip0024") {
83+
return Consensus::BuriedDeployment::DEPLOYMENT_DIP0024;
84+
} else if (name == "v19") {
85+
return Consensus::BuriedDeployment::DEPLOYMENT_V19;
86+
} else if (name == "v20") {
87+
return Consensus::BuriedDeployment::DEPLOYMENT_V20;
88+
} else if (name == "mn_rr") {
89+
return Consensus::BuriedDeployment::DEPLOYMENT_MN_RR;
90+
}
91+
return std::nullopt;
92+
}

‎src/deploymentinfo.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <consensus/params.h>
99

10+
#include <optional>
1011
#include <string>
1112

1213
struct VBDeploymentInfo {
@@ -26,4 +27,6 @@ inline std::string DeploymentName(Consensus::DeploymentPos pos)
2627
return VersionBitsDeploymentInfo[pos].name;
2728
}
2829

30+
std::optional<Consensus::BuriedDeployment> GetBuriedDeployment(const std::string_view deployment_name);
31+
2932
#endif // BITCOIN_DEPLOYMENTINFO_H

‎src/instantsend/net_instantsend.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <bls/bls_batchverifier.h>
88
#include <chainlock/chainlock.h>
9+
#include <chainparams.h>
910
#include <consensus/params.h>
1011
#include <cxxtimer.hpp>
1112
#include <instantsend/instantsend.h>

0 commit comments

Comments
 (0)