mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
rpc: switch to taking an integer for rate
in quorum dkgsimerror
This is required in order to backport bitcoin#23156, which gets rid of `ParseDouble` (used by `ParseDoubleV`), which is last used by `quorum dkgsimerror`.
This commit is contained in:
parent
8598a3fbb8
commit
18fff7e3d3
5
doc/release-notes-6297.md
Normal file
5
doc/release-notes-6297.md
Normal file
@ -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.
|
@ -750,24 +750,24 @@ static RPCHelpMan quorum_dkgsimerror()
|
|||||||
"as you will get yourself very likely PoSe banned for this.\n",
|
"as you will get yourself very likely PoSe banned for this.\n",
|
||||||
{
|
{
|
||||||
{"type", RPCArg::Type::STR, RPCArg::Optional::NO, "Error type."},
|
{"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{},
|
RPCResults{},
|
||||||
RPCExamples{""},
|
RPCExamples{""},
|
||||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||||
{
|
{
|
||||||
std::string type_str = request.params[0].get_str();
|
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) {
|
if (rate < 0 || rate > 100) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid rate. Must be between 0 and 1");
|
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);
|
if (const llmq::DKGError::type type = llmq::DKGError::from_string(type_str);
|
||||||
type == llmq::DKGError::type::_COUNT) {
|
type == llmq::DKGError::type::_COUNT) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid type. See DKGError class implementation");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid type. See DKGError class implementation");
|
||||||
} else {
|
} else {
|
||||||
llmq::SetSimulatedDKGErrorRate(type, rate);
|
llmq::SetSimulatedDKGErrorRate(type, static_cast<double>(rate) / 100);
|
||||||
return UniValue();
|
return UniValue();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -139,15 +139,6 @@ int64_t ParseInt64V(const UniValue& v, const std::string &strName)
|
|||||||
return num;
|
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)
|
bool ParseBoolV(const UniValue& v, const std::string &strName)
|
||||||
{
|
{
|
||||||
std::string strBool;
|
std::string strBool;
|
||||||
|
@ -25,18 +25,18 @@ class LLMQDKGErrors(DashTestFramework):
|
|||||||
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
||||||
|
|
||||||
self.log.info("Lets omit the contribution")
|
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)
|
qh = self.mine_quorum(expected_contributions=2)
|
||||||
self.assert_member_valid(qh, self.mninfo[0].proTxHash, False)
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, False)
|
||||||
|
|
||||||
self.log.info("Lets lie in the contribution but provide a correct justification")
|
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-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)
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=2, expected_justifications=1)
|
||||||
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
||||||
|
|
||||||
self.log.info("Lets lie in the contribution and then omit the justification")
|
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)
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=2)
|
||||||
self.assert_member_valid(qh, self.mninfo[0].proTxHash, False)
|
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.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-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)
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=2, expected_justifications=1)
|
||||||
self.assert_member_valid(qh, self.mninfo[0].proTxHash, False)
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, False)
|
||||||
|
|
||||||
self.log.info("Lets lie about another MN")
|
self.log.info("Lets lie about another MN")
|
||||||
self.mninfo[0].node.quorum('dkgsimerror', 'contribution-lie', '0')
|
self.mninfo[0].node.quorum('dkgsimerror', 'contribution-lie', '0')
|
||||||
self.mninfo[0].node.quorum('dkgsimerror', 'justify-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)
|
qh = self.mine_quorum(expected_contributions=3, expected_complaints=1, expected_justifications=2)
|
||||||
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
self.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
||||||
|
|
||||||
self.log.info("Lets omit 1 premature commitments")
|
self.log.info("Lets omit 1 premature commitments")
|
||||||
self.mninfo[0].node.quorum('dkgsimerror', 'complain-lie', '0')
|
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)
|
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.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
||||||
|
|
||||||
self.log.info("Lets lie in 1 premature commitments")
|
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-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)
|
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.assert_member_valid(qh, self.mninfo[0].proTxHash, True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user