diff --git a/doc/release-notes-6297.md b/doc/release-notes-6297.md new file mode 100644 index 0000000000..970e02ad6a --- /dev/null +++ b/doc/release-notes-6297.md @@ -0,0 +1,5 @@ +RPC changes +----------- + +- `quorum dkgsimerror` will no longer accept a decimal value between 0 and 1 for the `rate` argument, it will now + expect an integer between 0 to 100. diff --git a/src/rpc/quorums.cpp b/src/rpc/quorums.cpp index ba084ba364..f6c27f4c73 100644 --- a/src/rpc/quorums.cpp +++ b/src/rpc/quorums.cpp @@ -750,24 +750,24 @@ static RPCHelpMan quorum_dkgsimerror() "as you will get yourself very likely PoSe banned for this.\n", { {"type", RPCArg::Type::STR, RPCArg::Optional::NO, "Error type."}, - {"rate", RPCArg::Type::NUM, RPCArg::Optional::NO, "Rate at which to simulate this error type."}, + {"rate", RPCArg::Type::NUM, RPCArg::Optional::NO, "Rate at which to simulate this error type (between 0 and 100)."}, }, RPCResults{}, RPCExamples{""}, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { std::string type_str = request.params[0].get_str(); - double rate = ParseDoubleV(request.params[1], "rate"); + int32_t rate = ParseInt32V(request.params[1], "rate"); - if (rate < 0 || rate > 1) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid rate. Must be between 0 and 1"); + if (rate < 0 || rate > 100) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid rate. Must be between 0 and 100"); } if (const llmq::DKGError::type type = llmq::DKGError::from_string(type_str); type == llmq::DKGError::type::_COUNT) { throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid type. See DKGError class implementation"); } else { - llmq::SetSimulatedDKGErrorRate(type, rate); + llmq::SetSimulatedDKGErrorRate(type, static_cast(rate) / 100); return UniValue(); } }, diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 97b44915d2..727fa5e694 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -139,15 +139,6 @@ int64_t ParseInt64V(const UniValue& v, const std::string &strName) return num; } -double ParseDoubleV(const UniValue& v, const std::string &strName) -{ - std::string strNum = v.getValStr(); - double num; - if (!ParseDouble(strNum, &num)) - throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be a be number (not '"+strNum+"')"); - return num; -} - bool ParseBoolV(const UniValue& v, const std::string &strName) { std::string strBool; diff --git a/test/functional/feature_llmq_dkgerrors.py b/test/functional/feature_llmq_dkgerrors.py index bc026c5125..c37d7244bf 100755 --- a/test/functional/feature_llmq_dkgerrors.py +++ b/test/functional/feature_llmq_dkgerrors.py @@ -25,18 +25,18 @@ class LLMQDKGErrors(DashTestFramework): self.assert_member_valid(qh, self.mninfo[0].proTxHash, True) self.log.info("Lets omit the contribution") - self.mninfo[0].node.quorum('dkgsimerror', 'contribution-omit', '1') + self.mninfo[0].node.quorum('dkgsimerror', 'contribution-omit', '100') qh = self.mine_quorum(expected_contributions=2) self.assert_member_valid(qh, self.mninfo[0].proTxHash, False) self.log.info("Lets lie in the contribution but provide a correct justification") self.mninfo[0].node.quorum('dkgsimerror', 'contribution-omit', '0') - self.mninfo[0].node.quorum('dkgsimerror', 'contribution-lie', '1') + self.mninfo[0].node.quorum('dkgsimerror', 'contribution-lie', '100') qh = self.mine_quorum(expected_contributions=3, expected_complaints=2, expected_justifications=1) self.assert_member_valid(qh, self.mninfo[0].proTxHash, True) self.log.info("Lets lie in the contribution and then omit the justification") - self.mninfo[0].node.quorum('dkgsimerror', 'justify-omit', '1') + self.mninfo[0].node.quorum('dkgsimerror', 'justify-omit', '100') qh = self.mine_quorum(expected_contributions=3, expected_complaints=2) self.assert_member_valid(qh, self.mninfo[0].proTxHash, False) @@ -45,26 +45,26 @@ class LLMQDKGErrors(DashTestFramework): self.log.info("Lets lie in the contribution and then also lie in the justification") self.mninfo[0].node.quorum('dkgsimerror', 'justify-omit', '0') - self.mninfo[0].node.quorum('dkgsimerror', 'justify-lie', '1') + self.mninfo[0].node.quorum('dkgsimerror', 'justify-lie', '100') qh = self.mine_quorum(expected_contributions=3, expected_complaints=2, expected_justifications=1) self.assert_member_valid(qh, self.mninfo[0].proTxHash, False) self.log.info("Lets lie about another MN") self.mninfo[0].node.quorum('dkgsimerror', 'contribution-lie', '0') self.mninfo[0].node.quorum('dkgsimerror', 'justify-lie', '0') - self.mninfo[0].node.quorum('dkgsimerror', 'complain-lie', '1') + self.mninfo[0].node.quorum('dkgsimerror', 'complain-lie', '100') qh = self.mine_quorum(expected_contributions=3, expected_complaints=1, expected_justifications=2) self.assert_member_valid(qh, self.mninfo[0].proTxHash, True) self.log.info("Lets omit 1 premature commitments") self.mninfo[0].node.quorum('dkgsimerror', 'complain-lie', '0') - self.mninfo[0].node.quorum('dkgsimerror', 'commit-omit', '1') + self.mninfo[0].node.quorum('dkgsimerror', 'commit-omit', '100') qh = self.mine_quorum(expected_contributions=3, expected_complaints=0, expected_justifications=0, expected_commitments=2) self.assert_member_valid(qh, self.mninfo[0].proTxHash, True) self.log.info("Lets lie in 1 premature commitments") self.mninfo[0].node.quorum('dkgsimerror', 'commit-omit', '0') - self.mninfo[0].node.quorum('dkgsimerror', 'commit-lie', '1') + self.mninfo[0].node.quorum('dkgsimerror', 'commit-lie', '100') qh = self.mine_quorum(expected_contributions=3, expected_complaints=0, expected_justifications=0, expected_commitments=2) self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)