Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename DF22Metachain to DF22MetachainHeight #2555

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class CMainParams : public CChainParams {
consensus.DF19FortCanningEpilogueHeight = 2257500; // Sep 22nd, 2022.
consensus.DF20GrandCentralHeight = 2479000; // Dec 8th, 2022.
consensus.DF21GrandCentralEpilogueHeight = 2574000; // Jan 10th, 2023.
consensus.DF22Metachain = std::numeric_limits<int>::max();
consensus.DF22MetachainHeight = std::numeric_limits<int>::max();

consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
Expand Down Expand Up @@ -417,7 +417,7 @@ class CTestNetParams : public CChainParams {
consensus.DF19FortCanningEpilogueHeight = 1244000;
consensus.DF20GrandCentralHeight = 1366000;
consensus.DF21GrandCentralEpilogueHeight = 1438200;
consensus.DF22Metachain = 1948000;
consensus.DF22MetachainHeight = 1948000;

consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
Expand Down Expand Up @@ -636,7 +636,7 @@ class CChangiParams : public CChainParams {
consensus.DF19FortCanningEpilogueHeight = 1244000;
consensus.DF20GrandCentralHeight = 1366000;
consensus.DF21GrandCentralEpilogueHeight = 1438200;
consensus.DF22Metachain = 1586750;
consensus.DF22MetachainHeight = 1586750;

consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.pos.nTargetTimespan = 5 * 60; // 5 min == 10 blocks
Expand Down Expand Up @@ -852,7 +852,7 @@ class CDevNetParams : public CChainParams {
consensus.DF19FortCanningEpilogueHeight = 1244000;
consensus.DF20GrandCentralHeight = 1366000;
consensus.DF21GrandCentralEpilogueHeight = 1438200;
consensus.DF22Metachain = 1586750;
consensus.DF22MetachainHeight = 1586750;

consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.pos.nTargetTimespan = 5 * 60; // 5 min == 10 blocks
Expand Down Expand Up @@ -1071,7 +1071,7 @@ class CRegTestParams : public CChainParams {
consensus.DF19FortCanningEpilogueHeight = 10000000;
consensus.DF20GrandCentralHeight = 10000000;
consensus.DF21GrandCentralEpilogueHeight = 10000000;
consensus.DF22Metachain = 10000000;
consensus.DF22MetachainHeight = 10000000;

consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
Expand Down Expand Up @@ -1338,7 +1338,7 @@ void SetupCommonArgActivationParams(Consensus::Params &consensus) {
UpdateHeightValidation("Fort Canning Epilogue", "-fortcanningepilogueheight", consensus.DF19FortCanningEpilogueHeight);
UpdateHeightValidation("Grand Central", "-grandcentralheight", consensus.DF20GrandCentralHeight);
UpdateHeightValidation("Grand Central Epilogue", "-grandcentralepilogueheight", consensus.DF21GrandCentralEpilogueHeight);
UpdateHeightValidation("Metachain", "-metachainheight", consensus.DF22Metachain);
UpdateHeightValidation("Metachain", "-metachainheight", consensus.DF22MetachainHeight);

if (gArgs.GetBoolArg("-simulatemainnet", false)) {
consensus.pos.nTargetTimespan = 5 * 60; // 5 min == 10 blocks
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct Params {
int DF19FortCanningEpilogueHeight;
int DF20GrandCentralHeight;
int DF21GrandCentralEpilogueHeight;
int DF22Metachain;
int DF22MetachainHeight;

/** Foundation share after AMK, normalized to COIN = 100% */
CAmount foundationShareDFIP1;
Expand Down
4 changes: 2 additions & 2 deletions src/masternodes/consensus/icxorders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <masternodes/mn_checks.h>

bool IsICXEnabled(const int height, const CCustomCSView &view, const Consensus::Params &consensus) {
if (height >= consensus.DF22Metachain) {
if (height >= consensus.DF22MetachainHeight) {
const CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::ICXEnabled};
auto attributes = view.GetAttributes();
assert(attributes);
Expand Down Expand Up @@ -402,7 +402,7 @@ Res CICXOrdersConsensus::operator()(const CICXClaimDFCHTLCMessage &obj) const {
auto ICXBugPath = [&](uint32_t height) {
if ((IsTestNetwork() && height >= 1250000) ||
IsRegtestNetwork() ||
(IsMainNetwork() && height >= static_cast<uint32_t>(consensus.DF22Metachain)))
(IsMainNetwork() && height >= static_cast<uint32_t>(consensus.DF22MetachainHeight)))
return false;
return true;
};
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/consensus/masternodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Res CMasternodesConsensus::operator()(const CUpdateMasterNodeMessage &obj) const
}
rewardType = true;

if (height < static_cast<uint32_t>(consensus.DF22Metachain)) {
if (height < static_cast<uint32_t>(consensus.DF22MetachainHeight)) {
if (addressType != PKHashType && addressType != WitV0KeyHashType) {
return Res::Err("Reward address must be P2PKH or P2WPKH type");
}
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/consensus/smartcontracts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Res CSmartContractsConsensus::HandleDFIP2201Contract(const CSmartContractMessage
Require(token->symbol == "BTC" && token->name == "Bitcoin" && token->IsDAT(),
"Only Bitcoin can be swapped in " + obj.name);

if (height >= static_cast<uint32_t>(consensus.DF22Metachain)) {
if (height >= static_cast<uint32_t>(consensus.DF22MetachainHeight)) {
mnview.CalculateOwnerRewards(script, height);
}

Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/consensus/txvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ Res CCustomTxVisitor::CollateralPctCheck(const bool hasDUSDLoans,
auto isPostFCE = static_cast<int>(height) >= consensus.DF19FortCanningEpilogueHeight;
auto isPostFCR = static_cast<int>(height) >= consensus.DF15FortCanningRoadHeight;
auto isPostGC = static_cast<int>(height) >= consensus.DF20GrandCentralHeight;
auto isPostNext = static_cast<int>(height) >= consensus.DF22Metachain;
auto isPostNext = static_cast<int>(height) >= consensus.DF22MetachainHeight;

if(isPostNext) {
const CDataStructureV0 enabledKey{AttributeTypes::Vaults, VaultIDs::DUSDVault, VaultKeys::DUSDVaultEnabled};
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/consensus/vaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Res CVaultsConsensus::operator()(const CWithdrawFromVaultMessage &obj) const {
}
}

if (height >= static_cast<uint32_t>(consensus.DF22Metachain)) {
if (height >= static_cast<uint32_t>(consensus.DF22MetachainHeight)) {
mnview.CalculateOwnerRewards(obj.to, height);
}

Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/consensus/xvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
constexpr uint32_t MAX_TRANSFERDOMAIN_EVM_DATA_LEN = 1024;

static bool IsTransferDomainEnabled(const int height, const CCustomCSView &view, const Consensus::Params &consensus) {
if (height < consensus.DF22Metachain) {
if (height < consensus.DF22MetachainHeight) {
return false;
}

Expand Down
16 changes: 8 additions & 8 deletions src/masternodes/govvariables/attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const {
}
// Post fork remove this guard as long as there were no non-DAT loan tokens before
// the fork. A full sync test on the removal of this guard will tell.
if (view.GetLastHeight() >= Params().GetConsensus().DF22Metachain) {
if (view.GetLastHeight() >= Params().GetConsensus().DF22MetachainHeight) {
if (!VerifyDATToken(view, attrV0->typeId)) {
return DeFiErrors::GovVarValidateToken(attrV0->typeId);
}
Expand All @@ -1836,7 +1836,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const {
}
// Post fork remove this guard as long as there were no non-DAT loan tokens before
// the fork. A full sync test on the removal of this guard will tell.
if (view.GetLastHeight() >= Params().GetConsensus().DF22Metachain) {
if (view.GetLastHeight() >= Params().GetConsensus().DF22MetachainHeight) {
if (!token->IsDAT()) {
return DeFiErrors::GovVarValidateToken(attrV0->typeId);
}
Expand Down Expand Up @@ -1984,8 +1984,8 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const {
return Res::Err("Cannot be set before GrandCentralEpilogueHeight");
}
} else if (attrV0->key == DFIPKeys::EVMEnabled || attrV0->key == DFIPKeys::TransferDomain) {
if (view.GetLastHeight() < Params().GetConsensus().DF22Metachain) {
return Res::Err("Cannot be set before metachainheight");
if (view.GetLastHeight() < Params().GetConsensus().DF22MetachainHeight) {
return Res::Err("Cannot be set before MetachainHeight");
}
}
} else if (attrV0->typeId == ParamIDs::Foundation) {
Expand Down Expand Up @@ -2033,13 +2033,13 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const {
break;

case AttributeTypes::EVMType:
if (view.GetLastHeight() < Params().GetConsensus().DF22Metachain) {
if (view.GetLastHeight() < Params().GetConsensus().DF22MetachainHeight) {
return Res::Err("Cannot be set before Metachain");
}
break;

case AttributeTypes::Transfer:
if (view.GetLastHeight() < Params().GetConsensus().DF22Metachain) {
if (view.GetLastHeight() < Params().GetConsensus().DF22MetachainHeight) {
return Res::Err("Cannot be set before Metachain");
}
if ((attrV0->typeId == TransferIDs::DVMToEVM || attrV0->typeId == TransferIDs::EVMToDVM) &&
Expand All @@ -2056,14 +2056,14 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const {

case AttributeTypes::Vaults:
if (attrV0->typeId == VaultIDs::DUSDVault && attrV0->key == VaultKeys::DUSDVaultEnabled) {
if (view.GetLastHeight() < Params().GetConsensus().DF22Metachain) {
if (view.GetLastHeight() < Params().GetConsensus().DF22MetachainHeight) {
return Res::Err("Cannot be set before Metachain");
}
}
break;

case AttributeTypes::Rules:
if (view.GetLastHeight() < Params().GetConsensus().DF22Metachain) {
if (view.GetLastHeight() < Params().GetConsensus().DF22MetachainHeight) {
return Res::Err("Cannot be set before Metachain");
}
break;
Expand Down
8 changes: 4 additions & 4 deletions src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class CCustomMetadataParseVisitor {
{ consensus.DF15FortCanningRoadHeight, "called before FortCanningRoad height" },
{ consensus.DF19FortCanningEpilogueHeight, "called before FortCanningEpilogue height" },
{ consensus.DF20GrandCentralHeight, "called before GrandCentral height" },
{ consensus.DF22Metachain, "called before Metachain height" },
{ consensus.DF22MetachainHeight, "called before Metachain height" },
};
if (startHeight && height < startHeight) {
auto it = hardforks.find(startHeight);
Expand Down Expand Up @@ -281,7 +281,7 @@ class CCustomMetadataParseVisitor {
else if constexpr (IsOneOf<T,
CTransferDomainMessage,
CEvmTxMessage>())
return IsHardforkEnabled(consensus.DF22Metachain);
return IsHardforkEnabled(consensus.DF22MetachainHeight);
else if constexpr (IsOneOf<T,
CCreateMasterNodeMessage,
CResignMasterNodeMessage>())
Expand Down Expand Up @@ -793,7 +793,7 @@ ResVal<uint256> ApplyAnchorRewardTxPlus(CCustomCSView &mnview,
anchorReward);

CTxDestination destination;
if (height < consensusParams.DF22Metachain) {
if (height < consensusParams.DF22MetachainHeight) {
destination = FromOrDefaultKeyIDToDestination(finMsg.rewardKeyID, TxDestTypeToKeyType(finMsg.rewardKeyType), KeyType::MNOwnerKeyType);
} else {
destination = FromOrDefaultKeyIDToDestination(finMsg.rewardKeyID, TxDestTypeToKeyType(finMsg.rewardKeyType), KeyType::MNRewardKeyType);
Expand Down Expand Up @@ -1345,7 +1345,7 @@ struct OpReturnLimitsKeys {
OpReturnLimits OpReturnLimits::From(const uint64_t height, const Consensus::Params &consensus, const ATTRIBUTES &attributes) {
OpReturnLimitsKeys k{};
auto item = OpReturnLimits::Default();
item.shouldEnforce = height >= static_cast<uint64_t>(consensus.DF22Metachain);
item.shouldEnforce = height >= static_cast<uint64_t>(consensus.DF22MetachainHeight);
item.coreSizeBytes = attributes.GetValue(k.coreKey, item.coreSizeBytes);
item.dvmSizeBytes = attributes.GetValue(k.dvmKey, item.dvmSizeBytes);
item.evmSizeBytes = attributes.GetValue(k.evmKey, item.evmSizeBytes);
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/mn_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ UniValue listgovs(const JSONRPCRequest& request) {
if (mode == GovVarsFilter::NoAttributes) {
skip = true;
} else {
if (height >= Params().GetConsensus().DF22Metachain) {
if (height >= Params().GetConsensus().DF22MetachainHeight) {
if (auto attributes = dynamic_cast<ATTRIBUTES*>(var.get()); attributes) {
AddDefaultVars(height, Params(), *attributes);
}
Expand Down
6 changes: 3 additions & 3 deletions src/masternodes/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ static void ProcessProposalEvents(const CBlockIndex* pindex, CCustomCSView& cach
LogPrintf("Proposal fee redistribution failed: %s Address: %s Amount: %d\n", res.msg, scriptPubKey.GetHex(), amountPerVoter);
}

if (pindex->nHeight >= chainparams.GetConsensus().DF22Metachain) {
if (pindex->nHeight >= chainparams.GetConsensus().DF22MetachainHeight) {
subView.CalculateOwnerRewards(scriptPubKey, pindex->nHeight);
}

Expand All @@ -2270,10 +2270,10 @@ static void ProcessProposalEvents(const CBlockIndex* pindex, CCustomCSView& cach
return true;
}

if (pindex->nHeight < chainparams.GetConsensus().DF22Metachain && lround(voteYes * 10000.f / voters.size()) <= prop.approvalThreshold) {
if (pindex->nHeight < chainparams.GetConsensus().DF22MetachainHeight && lround(voteYes * 10000.f / voters.size()) <= prop.approvalThreshold) {
cache.UpdateProposalStatus(propId, pindex->nHeight, CProposalStatusType::Rejected);
return true;
} else if (pindex->nHeight >= chainparams.GetConsensus().DF22Metachain) {
} else if (pindex->nHeight >= chainparams.GetConsensus().DF22MetachainHeight) {
auto onlyNeutral = voters.size() == voteNeutral;
if (onlyNeutral || lround(voteYes * 10000.f / (voters.size() - voteNeutral)) <= prop.approvalThreshold) {
cache.UpdateProposalStatus(propId, pindex->nHeight, CProposalStatusType::Rejected);
Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ ResVal<std::unique_ptr<CBlockTemplate>> BlockAssembler::CreateNewBlock(const CSc
metadata << finMsg;

CTxDestination destination;
if (nHeight < consensus.DF22Metachain) {
if (nHeight < consensus.DF22MetachainHeight) {
destination = FromOrDefaultKeyIDToDestination(finMsg.rewardKeyID, TxDestTypeToKeyType(finMsg.rewardKeyType), KeyType::MNOwnerKeyType);
} else {
destination = FromOrDefaultKeyIDToDestination(finMsg.rewardKeyID, TxDestTypeToKeyType(finMsg.rewardKeyType), KeyType::MNRewardKeyType);
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
BuriedForkDescPushBack(softforks, "fortcanningepilogue", consensusParams.DF19FortCanningEpilogueHeight);
BuriedForkDescPushBack(softforks, "grandcentral", consensusParams.DF20GrandCentralHeight);
BuriedForkDescPushBack(softforks, "grandcentralepilogue", consensusParams.DF21GrandCentralEpilogueHeight);
BuriedForkDescPushBack(softforks, "metachain", consensusParams.DF22Metachain);
BuriedForkDescPushBack(softforks, "metachain", consensusParams.DF22MetachainHeight);
BIP9SoftForkDescPushBack(softforks, "testdummy", consensusParams, Consensus::DEPLOYMENT_TESTDUMMY);
obj.pushKV("softforks", softforks);

Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4267,7 +4267,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
auto node = pcustomcsview->GetMasternode(*nodeId);
if (node->rewardAddressType != 0) {
CTxDestination destination;
if (height < consensusParams.DF22Metachain) {
if (height < consensusParams.DF22MetachainHeight) {
destination = FromOrDefaultKeyIDToDestination(node->rewardAddress, TxDestTypeToKeyType(node->rewardAddressType), KeyType::MNOwnerKeyType);
} else {
destination = FromOrDefaultKeyIDToDestination(node->rewardAddress, TxDestTypeToKeyType(node->rewardAddressType), KeyType::MNRewardKeyType);
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_evm.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ def evm_gov_vars(self):
# Check setting vars before height
assert_raises_rpc_error(
-32600,
"Cannot be set before metachainheight",
"Cannot be set before MetachainHeight",
self.nodes[0].setgov,
{"ATTRIBUTES": {"v0/params/feature/evm": "true"}},
)
assert_raises_rpc_error(
-32600,
"Cannot be set before metachainheight",
"Cannot be set before MetachainHeight",
self.nodes[0].setgov,
{"ATTRIBUTES": {"v0/params/feature/transferdomain": "true"}},
)
Expand Down