From ab2a005212c0ac78d412a29fa069ca0df371e217 Mon Sep 17 00:00:00 2001 From: jouzo Date: Thu, 24 Nov 2022 21:56:14 +0100 Subject: [PATCH 1/2] Add feeBurnPct and emergencyPeriod to chainparams --- src/chainparams.cpp | 9 +++++++++ src/consensus/params.h | 2 ++ src/masternodes/masternodes.cpp | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 5ee55b530d9..ee4dd3fc30b 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 4166671311c..6cdb68dec71 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 fec773d93d0..f01032c4307 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); } From 3ccc4250ff063c8f31ffda6acb5a61c345935114 Mon Sep 17 00:00:00 2001 From: jouzo Date: Thu, 24 Nov 2022 21:56:47 +0100 Subject: [PATCH 2/2] Fix failing test and replace Approved by Completed to match CPropStatusType --- src/masternodes/rpc_proposals.cpp | 2 +- test/functional/feature_on_chain_government.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/masternodes/rpc_proposals.cpp b/src/masternodes/rpc_proposals.cpp index 3c49a186846..7c069dc6716 100644 --- a/src/masternodes/rpc_proposals.cpp +++ b/src/masternodes/rpc_proposals.cpp @@ -581,7 +581,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 6e92e62ee47..e247376c11a 100755 --- a/test/functional/feature_on_chain_government.py +++ b/test/functional/feature_on_chain_government.py @@ -281,7 +281,7 @@ def run_test(self): assert_equal(result["title"], title) 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) @@ -490,7 +490,7 @@ def run_test(self): assert_equal(result["title"], title) 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)