Skip to content

Commit

Permalink
Prevent setting EVM or TD Gov var below height
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar committed Sep 12, 2023
1 parent 638d314 commit 22d068f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/masternodes/govvariables/attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1972,21 +1972,24 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const {
break;

case AttributeTypes::Param:
if (attrV0->typeId == ParamIDs::Feature && attrV0->key == DFIPKeys::MintTokens) {
if (view.GetLastHeight() < Params().GetConsensus().GrandCentralEpilogueHeight) {
return Res::Err("Cannot be set before GrandCentralEpilogueHeight");
}
} else if (attrV0->typeId == ParamIDs::Feature || attrV0->typeId == ParamIDs::Foundation ||
attrV0->key == DFIPKeys::Members) {
if (attrV0->typeId == ParamIDs::Feature) {
if (view.GetLastHeight() < Params().GetConsensus().GrandCentralHeight) {
return Res::Err("Cannot be set before GrandCentralHeight");
}
} else if (attrV0->typeId == ParamIDs::Foundation || attrV0->key == DFIPKeys::Members) {
if (attrV0->key == DFIPKeys::MintTokens) {
if (view.GetLastHeight() < Params().GetConsensus().GrandCentralEpilogueHeight) {
return Res::Err("Cannot be set before GrandCentralEpilogueHeight");
}
} else if (attrV0->key == DFIPKeys::EVMEnabled || attrV0->key == DFIPKeys::TransferDomain) {
if (view.GetLastHeight() < Params().GetConsensus().NextNetworkUpgradeHeight) {
return Res::Err("Cannot be set before NextNetworkUpgradeHeight");
}
}
} else if (attrV0->typeId == ParamIDs::Foundation) {
if (view.GetLastHeight() < Params().GetConsensus().GrandCentralHeight) {
return Res::Err("Cannot be set before GrandCentralHeight");
}
} else if (attrV0->typeId == ParamIDs::DFIP2206F || attrV0->key == DFIPKeys::StartBlock ||
attrV0->typeId == ParamIDs::DFIP2206A) {
} else if (attrV0->typeId == ParamIDs::DFIP2206F || attrV0->typeId == ParamIDs::DFIP2206A) {
if (view.GetLastHeight() < Params().GetConsensus().FortCanningSpringHeight) {
return Res::Err("Cannot be set before FortCanningSpringHeight");
}
Expand Down
12 changes: 12 additions & 0 deletions test/functional/feature_evm.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,18 @@ def erc55_wallet_support(self):

def evm_gov_vars(self):
# Check setting vars before height
assert_raises_rpc_error(
-32600,
"Cannot be set before NextNetworkUpgradeHeight",
self.nodes[0].setgov,
{"ATTRIBUTES": {"v0/params/feature/evm": "true"}}
)
assert_raises_rpc_error(
-32600,
"Cannot be set before NextNetworkUpgradeHeight",
self.nodes[0].setgov,
{"ATTRIBUTES": {"v0/params/feature/transferdomain": "true"}}
)
assert_raises_rpc_error(
-32600,
"called before NextNetworkUpgrade height",
Expand Down

0 comments on commit 22d068f

Please sign in to comment.