Skip to content

Commit ab60ef9

Browse files
committed
chainparams: Add support for renouncing an HereticalDeployment
1 parent d211df0 commit ab60ef9

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/chainparams.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,26 @@ struct SetupDeployment
7979
};
8080
}
8181

82+
static void RenounceDeployments(const ArgsManager& args, Consensus::HereticalDeployment (&vDeployments)[Consensus::MAX_VERSION_BITS_DEPLOYMENTS])
83+
{
84+
if (!args.IsArgSet("-renounce")) return;
85+
for (const std::string& dep_name : args.GetArgs("-renounce")) {
86+
bool found = false;
87+
for (int j = 0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
88+
if (dep_name == VersionBitsDeploymentInfo[j].name) {
89+
vDeployments[j].nStartTime = Consensus::HereticalDeployment::NEVER_ACTIVE;
90+
vDeployments[j].nTimeout = Consensus::HereticalDeployment::NO_TIMEOUT;
91+
found = true;
92+
LogPrintf("Disabling deployment %s\n", dep_name);
93+
break;
94+
}
95+
}
96+
if (!found) {
97+
throw std::runtime_error(strprintf("Invalid deployment (%s)", dep_name));
98+
}
99+
}
100+
}
101+
82102
/**
83103
* Main network on which people trade goods and services.
84104
*/
@@ -348,6 +368,7 @@ class SigNetParams : public CChainParams {
348368
consensus.MinBIP9WarningHeight = 0;
349369
consensus.powLimit = uint256S("00000377ae000000000000000000000000000000000000000000000000000000");
350370
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.activate = 0x30000000, .abandon = 0, .never = true};
371+
RenounceDeployments(args, consensus.vDeployments);
351372

352373
// message start is defined as the first 4 bytes of the sha256d of the block script
353374
CHashWriter h(SER_DISK, 0);
@@ -424,6 +445,7 @@ class CRegTestParams : public CChainParams {
424445
m_assumed_chain_state_size = 0;
425446

426447
UpdateActivationParametersFromArgs(args);
448+
RenounceDeployments(args, consensus.vDeployments);
427449

428450
genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
429451
consensus.hashGenesisBlock = genesis.GetHash();

src/chainparamsbase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
2323
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
2424
argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
2525
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
26+
argsman.AddArg("-renounce=deployment", "Unconditionally disable an heretical deployment attempt", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
2627
argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
2728
argsman.AddArg("-signetchallenge", "Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
2829
argsman.AddArg("-signetseednode", "Specify a seed node for the signet network, in the hostname[:port] format, e.g. sig.net:1234 (may be used multiple times to specify multiple seed nodes; defaults to the global default signet test network seed node(s))", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);

0 commit comments

Comments
 (0)