Skip to content

Commit

Permalink
chainparams: Add support for renouncing an HereticalDeployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtowns committed Sep 6, 2022
1 parent 2d20b44 commit 8d00408
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ struct SetupDeployment
};
}

static void RenounceDeployments(const ArgsManager& args, Consensus::HereticalDeployment (&vDeployments)[Consensus::MAX_VERSION_BITS_DEPLOYMENTS])
{
if (!args.IsArgSet("-renounce")) return;
for (const std::string& dep_name : args.GetArgs("-renounce")) {
bool found = false;
for (int j = 0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
if (dep_name == VersionBitsDeploymentInfo[j].name) {
vDeployments[j].nStartTime = Consensus::HereticalDeployment::NEVER_ACTIVE;
vDeployments[j].nTimeout = Consensus::HereticalDeployment::NO_TIMEOUT;
found = true;
LogPrintf("Disabling deployment %s\n", dep_name);
break;
}
}
if (!found) {
throw std::runtime_error(strprintf("Invalid deployment (%s)", dep_name));
}
}
}

/**
* Main network on which people trade goods and services.
*/
Expand Down Expand Up @@ -348,6 +368,7 @@ class SigNetParams : public CChainParams {
consensus.MinBIP9WarningHeight = 0;
consensus.powLimit = uint256S("00000377ae000000000000000000000000000000000000000000000000000000");
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY] = SetupDeployment{.activate = 0x30000000, .abandon = 0, .never = true};
RenounceDeployments(args, consensus.vDeployments);

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

UpdateActivationParametersFromArgs(args);
RenounceDeployments(args, consensus.vDeployments);

genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
Expand Down
1 change: 1 addition & 0 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
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);
argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
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);
argsman.AddArg("-renounce=deployment", "Unconditionally disable an heretical deployment attempt", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
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);
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);
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);
Expand Down

0 comments on commit 8d00408

Please sign in to comment.