From b437bc60b2d85c6352159ac693791633329bf905 Mon Sep 17 00:00:00 2001 From: Jouzo <15011228+Jouzo@users.noreply.github.com> Date: Fri, 25 Nov 2022 20:28:52 +0100 Subject: [PATCH] Add emergencyPeriod and feeBurnPct to chainparams (#1597) * Add feeBurnPct and emergencyPeriod to chainparams * Fix failing test and replace Approved by Completed to match CPropStatusType Co-authored-by: Prasanna Loganathar --- src/chainparams.cpp | 9 +++++++++ src/consensus/params.h | 2 ++ src/masternodes/masternodes.cpp | 4 ++-- src/masternodes/rpc_proposals.cpp | 2 +- test/functional/feature_on_chain_government.py | 4 ++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 5ee55b530d..ee4dd3fc30 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -200,6 +200,8 @@ class CMainParams : public CChainParams { consensus.props.voc.approvalThreshold = 66670000; // vote pass with over 66.67% majority consensus.props.quorum = COIN / 100; // 1% of the masternodes must vote consensus.props.votingPeriod = 130000; // tally votes every 130K blocks + consensus.props.emergencyPeriod = 8640; + consensus.props.feeBurnPct = COIN / 2; consensus.nonUtxoBlockSubsidies.emplace(CommunityAccountType::IncentiveFunding, 45 * COIN / 200); // 45 DFI of 200 per block (rate normalized to (COIN == 100%)) consensus.nonUtxoBlockSubsidies.emplace(CommunityAccountType::AnchorReward, COIN /10 / 200); // 0.1 DFI of 200 per block @@ -451,6 +453,9 @@ class CTestNetParams : public CChainParams { consensus.props.voc.approvalThreshold = 66670000; // vote pass with over 66.67% majority consensus.props.quorum = COIN / 100; // 1% of the masternodes must vote consensus.props.votingPeriod = 70000; // tally votes every 70K blocks + consensus.props.emergencyPeriod = 8640; + consensus.props.feeBurnPct = COIN / 2; + consensus.nonUtxoBlockSubsidies.emplace(CommunityAccountType::IncentiveFunding, 45 * COIN / 200); // 45 DFI @ 200 per block (rate normalized to (COIN == 100%)) consensus.nonUtxoBlockSubsidies.emplace(CommunityAccountType::AnchorReward, COIN/10 / 200); // 0.1 DFI @ 200 per block @@ -655,6 +660,8 @@ class CDevNetParams : public CChainParams { consensus.props.voc.approvalThreshold = 66670000; // vote pass with over 66.67% majority consensus.props.quorum = COIN / 100; // 1% of the masternodes must vote consensus.props.votingPeriod = 100; // tally votes every 1K blocks + consensus.props.emergencyPeriod = 50; + consensus.props.feeBurnPct = COIN / 2; consensus.nonUtxoBlockSubsidies.emplace(CommunityAccountType::IncentiveFunding, 45 * COIN / 200); // 45 DFI @ 200 per block (rate normalized to (COIN == 100%)) consensus.nonUtxoBlockSubsidies.emplace(CommunityAccountType::AnchorReward, COIN/10 / 200); // 0.1 DFI @ 200 per block @@ -851,6 +858,8 @@ class CRegTestParams : public CChainParams { consensus.props.voc.approvalThreshold = 66670000; // vote pass with over 66.67% majority consensus.props.quorum = COIN / 100; // 1% of the masternodes must vote consensus.props.votingPeriod = 70; // tally votes every 70 blocks + consensus.props.emergencyPeriod = 50; + consensus.props.feeBurnPct = COIN / 2; consensus.vaultCreationFee = 1 * COIN; diff --git a/src/consensus/params.h b/src/consensus/params.h index 4166671311..6cdb68dec7 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -211,7 +211,9 @@ struct Params { CAmount approvalThreshold; } cfp, brp, voc; uint32_t votingPeriod; + uint32_t emergencyPeriod; CAmount quorum; + CAmount feeBurnPct; }; CPropsParams props; diff --git a/src/masternodes/masternodes.cpp b/src/masternodes/masternodes.cpp index fec773d93d..f01032c430 100644 --- a/src/masternodes/masternodes.cpp +++ b/src/masternodes/masternodes.cpp @@ -1303,7 +1303,7 @@ uint32_t CCustomCSView::GetEmergencyPeriodFromAttributes(const CPropType &type) assert(attributes); CDataStructureV0 VOCKey{AttributeTypes::Governance, GovernanceIDs::Proposals, GovernanceKeys::VOCEmergencyPeriod}; - return attributes->GetValue(VOCKey, uint32_t{8640}); + return attributes->GetValue(VOCKey, Params().GetConsensus().props.emergencyPeriod); } CAmount CCustomCSView::GetApprovalThresholdFromAttributes(const CPropType &type) const { @@ -1344,5 +1344,5 @@ CAmount CCustomCSView::GetFeeBurnPctFromAttributes() const { CDataStructureV0 feeBurnPctKey{AttributeTypes::Governance, GovernanceIDs::Proposals, GovernanceKeys::FeeBurnPct}; - return attributes->GetValue(feeBurnPctKey, COIN / 2); + return attributes->GetValue(feeBurnPctKey, Params().GetConsensus().props.feeBurnPct); } diff --git a/src/masternodes/rpc_proposals.cpp b/src/masternodes/rpc_proposals.cpp index 928474ad47..b635047866 100644 --- a/src/masternodes/rpc_proposals.cpp +++ b/src/masternodes/rpc_proposals.cpp @@ -583,7 +583,7 @@ UniValue getgovproposal(const JSONRPCRequest& request) ret.pushKV("contextHash", prop->contextHash); ret.pushKV("type", CPropTypeToString(type)); if (valid && votes >= approvalThreshold) { - ret.pushKV("status", "Approved"); + ret.pushKV("status", "Completed"); } else { ret.pushKV("status", "Rejected"); } diff --git a/test/functional/feature_on_chain_government.py b/test/functional/feature_on_chain_government.py index d379fd4a57..483ebc1f16 100755 --- a/test/functional/feature_on_chain_government.py +++ b/test/functional/feature_on_chain_government.py @@ -283,7 +283,7 @@ def run_test(self): assert_equal(result["creationHeight"], creationHeight) assert_equal(result["context"], context) assert_equal(result["type"], "VoteOfConfidence") - assert_equal(result["status"], "Approved") + assert_equal(result["status"], "Completed") assert_equal(result["votes"], "75.00 of 66.67%") assert_equal(result["contextHash"], "") assert_equal(result["currentCycle"], 1) @@ -495,7 +495,7 @@ def run_test(self): assert_equal(result["creationHeight"], creationHeight) assert_equal(result["context"], context) assert_equal(result["type"], "VoteOfConfidence") - assert_equal(result["status"], "Approved") + assert_equal(result["status"], "Completed") assert_equal(result["votes"], "50.00 of 49.99%") assert_equal(result["contextHash"], "") assert_equal(result["currentCycle"], 1)