From bd34fa5f190454f3703bf0c72739b32d517814ba Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Fri, 27 Jan 2023 12:10:16 +0100 Subject: [PATCH] Add -rpc-governance-accept-neutral for JellyFish --- src/init.cpp | 1 + src/masternodes/rpc_proposals.cpp | 6 +++++- .../feature_on_chain_government_fee_distribution.py | 10 +++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 8117c15854..57a1b14988 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -630,6 +630,7 @@ void SetupServerArgs() gArgs.AddArg("-consolidaterewards=", "Consolidate rewards on startup. Accepted multiple times for each token symbol", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-rpccache=<0/1/2>", "Cache rpc results - uses additional memory to hold on to the last results per block, but faster (0=none, 1=all, 2=smart)", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-negativeinterest", "(experimental) Track negative interest values", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); + gArgs.AddArg("-rpc-governance-accept-neutral", "Allow voting with neutral votes for JellyFish purpose", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); #if HAVE_DECL_DAEMON gArgs.AddArg("-daemon", "Run in the background as a daemon and accept commands", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); diff --git a/src/masternodes/rpc_proposals.cpp b/src/masternodes/rpc_proposals.cpp index f2a47ff63a..464a732e93 100644 --- a/src/masternodes/rpc_proposals.cpp +++ b/src/masternodes/rpc_proposals.cpp @@ -3,6 +3,8 @@ #include +const bool DEFAULT_RPC_GOV_NEUTRAL = false; + struct VotingInfo { int32_t votesPossible; int32_t votesPresent; @@ -457,7 +459,9 @@ UniValue votegov(const JSONRPCRequest &request) { vote = CProposalVoteType::VoteNo; } else if (voteStr == "yes") { vote = CProposalVoteType::VoteYes; - } else { + } else if (gArgs.GetBoolArg("-rpc-governance-accept-neutral", DEFAULT_RPC_GOV_NEUTRAL) && voteStr != "neutral") { + throw JSONRPCError(RPC_INVALID_PARAMETER, "decision supports yes/no/neutral"); + } else if (!gArgs.GetBoolArg("-rpc-governance-accept-neutral", DEFAULT_RPC_GOV_NEUTRAL)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Decision supports yes or no. Neutral is currently disabled because of issue https://github.com/DeFiCh/ain/issues/1704"); } diff --git a/test/functional/feature_on_chain_government_fee_distribution.py b/test/functional/feature_on_chain_government_fee_distribution.py index 7d826036ab..996a35878a 100755 --- a/test/functional/feature_on_chain_government_fee_distribution.py +++ b/test/functional/feature_on_chain_government_fee_distribution.py @@ -17,10 +17,10 @@ def set_test_params(self): self.num_nodes = 4 self.setup_clean_chain = True self.extra_args = [ - ['-dummypos=0', '-txnotokens=0', '-amkheight=50', '-bayfrontheight=51', '-eunosheight=80', '-fortcanningheight=82', '-fortcanninghillheight=84', '-fortcanningroadheight=86', '-fortcanningcrunchheight=88', '-fortcanningspringheight=90', '-fortcanninggreatworldheight=94', '-grandcentralheight=101'], - ['-dummypos=0', '-txnotokens=0', '-amkheight=50', '-bayfrontheight=51', '-eunosheight=80', '-fortcanningheight=82', '-fortcanninghillheight=84', '-fortcanningroadheight=86', '-fortcanningcrunchheight=88', '-fortcanningspringheight=90', '-fortcanninggreatworldheight=94', '-grandcentralheight=101'], - ['-dummypos=0', '-txnotokens=0', '-amkheight=50', '-bayfrontheight=51', '-eunosheight=80', '-fortcanningheight=82', '-fortcanninghillheight=84', '-fortcanningroadheight=86', '-fortcanningcrunchheight=88', '-fortcanningspringheight=90', '-fortcanninggreatworldheight=94', '-grandcentralheight=101'], - ['-dummypos=0', '-txnotokens=0', '-amkheight=50', '-bayfrontheight=51', '-eunosheight=80', '-fortcanningheight=82', '-fortcanninghillheight=84', '-fortcanningroadheight=86', '-fortcanningcrunchheight=88', '-fortcanningspringheight=90', '-fortcanninggreatworldheight=94', '-grandcentralheight=101'], + ['-dummypos=0', '-txnotokens=0', '-rpc-governance-accept-neutral', '-amkheight=50', '-bayfrontheight=51', '-eunosheight=80', '-fortcanningheight=82', '-fortcanninghillheight=84', '-fortcanningroadheight=86', '-fortcanningcrunchheight=88', '-fortcanningspringheight=90', '-fortcanninggreatworldheight=94', '-grandcentralheight=101'], + ['-dummypos=0', '-txnotokens=0', '-rpc-governance-accept-neutral', '-amkheight=50', '-bayfrontheight=51', '-eunosheight=80', '-fortcanningheight=82', '-fortcanninghillheight=84', '-fortcanningroadheight=86', '-fortcanningcrunchheight=88', '-fortcanningspringheight=90', '-fortcanninggreatworldheight=94', '-grandcentralheight=101'], + ['-dummypos=0', '-txnotokens=0', '-rpc-governance-accept-neutral', '-amkheight=50', '-bayfrontheight=51', '-eunosheight=80', '-fortcanningheight=82', '-fortcanninghillheight=84', '-fortcanningroadheight=86', '-fortcanningcrunchheight=88', '-fortcanningspringheight=90', '-fortcanninggreatworldheight=94', '-grandcentralheight=101'], + ['-dummypos=0', '-txnotokens=0', '-rpc-governance-accept-neutral', '-amkheight=50', '-bayfrontheight=51', '-eunosheight=80', '-fortcanningheight=82', '-fortcanninghillheight=84', '-fortcanningroadheight=86', '-fortcanningcrunchheight=88', '-fortcanningspringheight=90', '-fortcanninggreatworldheight=94', '-grandcentralheight=101'], ] def test_cfp_fee_distribution(self, amount, expectedFee, burnPct, vote, cycles=2, changeFeeAndBurnPCT = False): @@ -153,7 +153,7 @@ def run_test(self): self.nodes[0].generate(1) self.sync_blocks() - # self.test_cfp_fee_distribution(amount=1000, expectedFee=10, burnPct=30, vote="neutral",) + self.test_cfp_fee_distribution(amount=1000, expectedFee=10, burnPct=30, vote="neutral",) self.nodes[0].setgov({"ATTRIBUTES":{'v0/gov/proposals/cfp_fee':'2%'}}) self.nodes[0].generate(1)