Skip to content

Commit

Permalink
refactor: cleanup deprecated code for MN version validation
Browse files Browse the repository at this point in the history
It removes 2 unused flags:
 - BIP9CheckMasternodesUpgraded from CChainParams
 - check_mn_protocol from versionbitsinfo

These flags have no meaning since 17c792c (PR dashpay#2594)

The TODO in removed code is super-seeded by new way to validate MN version
in hard-fork (see dashpay#5469 and DIP0023 for more details)
knst committed Jul 3, 2023
1 parent 207f9ca commit ba44e9b
Showing 7 changed files with 3 additions and 21 deletions.
6 changes: 0 additions & 6 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
@@ -274,7 +274,6 @@ class CMainParams : public CChainParams {

vSporkAddresses = {"Xgtyuk76vhuFW2iT7UAiHgNdWXCf3J34wh"};
nMinSporkKeys = 1;
fBIP9CheckMasternodesUpgraded = true;

checkpointData = {
{
@@ -464,7 +463,6 @@ class CTestNetParams : public CChainParams {

vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
nMinSporkKeys = 1;
fBIP9CheckMasternodesUpgraded = true;

checkpointData = {
{
@@ -644,8 +642,6 @@ class CDevNetParams : public CChainParams {

vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
nMinSporkKeys = 1;
// devnets are started with no blocks and no MN, so we can't check for upgraded MN (as there are none)
fBIP9CheckMasternodesUpgraded = false;

checkpointData = (CCheckpointData) {
{
@@ -846,8 +842,6 @@ class CRegTestParams : public CChainParams {
// privKey: cP4EKFyJsHT39LDqgdcB43Y3YXjNyjb5Fuas1GQSeAtjnZWmZEQK
vSporkAddresses = {"yj949n1UH6fDhw6HtVE5VMj2iSTaSWBMcW"};
nMinSporkKeys = 1;
// regtest usually has no masternodes in most tests, so don't check for upgraged MNs
fBIP9CheckMasternodesUpgraded = false;

checkpointData = {
{
2 changes: 0 additions & 2 deletions src/chainparams.h
Original file line number Diff line number Diff line change
@@ -135,7 +135,6 @@ class CChainParams
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
const std::vector<std::string>& SporkAddresses() const { return vSporkAddresses; }
int MinSporkKeys() const { return nMinSporkKeys; }
bool BIP9CheckMasternodesUpgraded() const { return fBIP9CheckMasternodesUpgraded; }
std::optional<Consensus::LLMQParams> GetLLMQ(Consensus::LLMQType llmqType) const;

protected:
@@ -170,7 +169,6 @@ class CChainParams
int nFulfilledRequestExpireTime;
std::vector<std::string> vSporkAddresses;
int nMinSporkKeys;
bool fBIP9CheckMasternodesUpgraded;
uint16_t nDefaultPlatformP2PPort;
uint16_t nDefaultPlatformHTTPPort;

2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
bool fDIP0003Active_context = nHeight >= chainparams.GetConsensus().DIP0003Height;
bool fDIP0008Active_context = nHeight >= chainparams.GetConsensus().DIP0008Height;

pblock->nVersion = ComputeBlockVersion(pindexPrev, chainparams.GetConsensus(), chainparams.BIP9CheckMasternodesUpgraded());
pblock->nVersion = ComputeBlockVersion(pindexPrev, chainparams.GetConsensus());
// Non-mainnet only: allow overriding block.nVersion with
// -blockversion=N to test forking scenarios
if (Params().NetworkIDString() != CBaseChainParams::MAIN)
7 changes: 1 addition & 6 deletions src/validation.cpp
Original file line number Diff line number Diff line change
@@ -45,7 +45,6 @@
#include <util/translation.h>
#include <util/system.h>
#include <validationinterface.h>
#include <versionbitsinfo.h>
#include <warnings.h>

#include <masternode/payments.h>
@@ -1960,18 +1959,14 @@ void StopScriptCheckWorkerThreads()

VersionBitsCache versionbitscache GUARDED_BY(cs_main);

int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params, bool fCheckMasternodesUpgraded)
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params)
{
LOCK(cs_main);
int32_t nVersion = VERSIONBITS_TOP_BITS;

for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) {
Consensus::DeploymentPos pos = Consensus::DeploymentPos(i);
ThresholdState state = VersionBitsState(pindexPrev, params, pos, versionbitscache);
const struct VBDeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos];
if (vbinfo.check_mn_protocol && state == ThresholdState::STARTED && fCheckMasternodesUpgraded) {
// TODO implement new logic for MN upgrade checks (e.g. with LLMQ based feature/version voting)
}
if (state == ThresholdState::LOCKED_IN || state == ThresholdState::STARTED) {
nVersion |= VersionBitsMask(params, static_cast<Consensus::DeploymentPos>(i));
}
2 changes: 1 addition & 1 deletion src/validation.h
Original file line number Diff line number Diff line change
@@ -1069,7 +1069,7 @@ extern VersionBitsCache versionbitscache;
/**
* Determine what nVersion a new block should use.
*/
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params, bool fCheckMasternodesUpgraded = false);
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params);

/**
* Return true if hash can be found in ::ChainActive() at nBlockHeight height.
3 changes: 0 additions & 3 deletions src/versionbitsinfo.cpp
Original file line number Diff line number Diff line change
@@ -10,16 +10,13 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B
{
/*.name =*/ "testdummy",
/*.gbt_force =*/ true,
/*.check_mn_protocol =*/ false,
},
{
/*.name =*/"v19",
/*.gbt_force =*/true,
/*.check_mn_protocol =*/false,
},
{
/*.name =*/"v20",
/*.gbt_force =*/true,
/*.check_mn_protocol =*/false,
},
};
2 changes: 0 additions & 2 deletions src/versionbitsinfo.h
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@ struct VBDeploymentInfo {
const char *name;
/** Whether GBT clients can safely ignore this rule in simplified usage */
bool gbt_force;
/** Whether to check current MN protocol or not */
bool check_mn_protocol;
};

extern const struct VBDeploymentInfo VersionBitsDeploymentInfo[];

0 comments on commit ba44e9b

Please sign in to comment.