Skip to content

Commit db82817

Browse files
Merge #6106: feat: create new composite quorum-command platformsign
2db69d7 chore: add release notes for "quorum platformsign" (Konstantin Akimov) 283c5f8 feat: create new composite command "quorum platformsign" (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented It splits from #6100 With just whitelist it is impossible to limit the RPC `quorum sign` to use only one specific quorum type, this PR aim to provide ability for quorum signing for platform quorum only. ## What was done? Implemented a new composite command "quorum platformsign" This composite command let to limit quorum type for signing for case of whitelist. After that old way to limit platform commands can be deprecated - #6105 ## How Has This Been Tested? Updated a functional tests to use platform signing for Asset Unlocks feature. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: UdjinM6: utACK 2db69d7 PastaPastaPasta: utACK 2db69d7 Tree-SHA512: b0dff9934137c4faa85664058e1e77f85067cc8d931e6d76ee5b9e610164ac8b0609736d5f09475256cb78d65bf92466624d784f0b13d20136df7e75613662cb
1 parent a45e6df commit db82817

File tree

4 files changed

+67
-25
lines changed

4 files changed

+67
-25
lines changed

doc/release-notes-6106.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Remote Procedure Call (RPC) Changes
2+
3+
### The new RPCs are:
4+
5+
- `quorum signplatform` This RPC is added for Platform needs. This composite command let to limit quorum type for signing by platform. It is equivalent of `quorum sign <platform type>`.
6+

src/rpc/quorums.cpp

+55-22
Original file line numberDiff line numberDiff line change
@@ -427,42 +427,27 @@ static RPCHelpMan quorum_memberof()
427427
};
428428
}
429429

430-
static RPCHelpMan quorum_sign()
431-
{
432-
return RPCHelpMan{"quorum sign",
433-
"Threshold-sign a message\n",
434-
{
435-
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."},
436-
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
437-
{"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."},
438-
{"quorumHash", RPCArg::Type::STR_HEX, /* default */ "", "The quorum identifier."},
439-
{"submit", RPCArg::Type::BOOL, /* default */ "true", "Submits the signature share to the network if this is true. "
440-
"Returns an object containing the signature share if this is false."},
441-
},
442-
RPCResults{},
443-
RPCExamples{""},
444-
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
430+
static UniValue quorum_sign_helper(const JSONRPCRequest& request, Consensus::LLMQType llmqType)
445431
{
446432
const NodeContext& node = EnsureAnyNodeContext(request.context);
447433
const ChainstateManager& chainman = EnsureChainman(node);
448434
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
449435

450-
const Consensus::LLMQType llmqType{static_cast<Consensus::LLMQType>(ParseInt32V(request.params[0], "llmqType"))};
451436
const auto llmq_params_opt = Params().GetLLMQ(llmqType);
452437
if (!llmq_params_opt.has_value()) {
453438
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid LLMQ type");
454439
}
455440

456-
const uint256 id(ParseHashV(request.params[1], "id"));
457-
const uint256 msgHash(ParseHashV(request.params[2], "msgHash"));
441+
const uint256 id(ParseHashV(request.params[0], "id"));
442+
const uint256 msgHash(ParseHashV(request.params[1], "msgHash"));
458443

459444
uint256 quorumHash;
460-
if (!request.params[3].isNull() && !request.params[3].get_str().empty()) {
461-
quorumHash = ParseHashV(request.params[3], "quorumHash");
445+
if (!request.params[2].isNull() && !request.params[2].get_str().empty()) {
446+
quorumHash = ParseHashV(request.params[2], "quorumHash");
462447
}
463448
bool fSubmit{true};
464-
if (!request.params[4].isNull()) {
465-
fSubmit = ParseBoolV(request.params[4], "submit");
449+
if (!request.params[3].isNull()) {
450+
fSubmit = ParseBoolV(request.params[3], "submit");
466451
}
467452
if (fSubmit) {
468453
return llmq_ctx.sigman->AsyncSignIfMember(llmqType, *llmq_ctx.shareman, id, msgHash, quorumHash);
@@ -496,6 +481,53 @@ static RPCHelpMan quorum_sign()
496481

497482
return obj;
498483
}
484+
}
485+
486+
static RPCHelpMan quorum_sign()
487+
{
488+
return RPCHelpMan{"quorum sign",
489+
"Threshold-sign a message\n",
490+
{
491+
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."},
492+
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
493+
{"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."},
494+
{"quorumHash", RPCArg::Type::STR_HEX, /* default */ "", "The quorum identifier."},
495+
{"submit", RPCArg::Type::BOOL, /* default */ "true", "Submits the signature share to the network if this is true. "
496+
"Returns an object containing the signature share if this is false."},
497+
},
498+
RPCResults{},
499+
RPCExamples{""},
500+
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
501+
{
502+
const Consensus::LLMQType llmqType{static_cast<Consensus::LLMQType>(ParseInt32V(request.params[0], "llmqType"))};
503+
504+
JSONRPCRequest new_request{request};
505+
new_request.params.setArray();
506+
for (unsigned int i = 1; i < request.params.size(); ++i) {
507+
new_request.params.push_back(request.params[i]);
508+
}
509+
return quorum_sign_helper(new_request, llmqType);
510+
},
511+
};
512+
}
513+
514+
static RPCHelpMan quorum_platformsign()
515+
{
516+
return RPCHelpMan{"quorum platformsign",
517+
"Threshold-sign a message. It signs messages only for platform quorums\n",
518+
{
519+
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
520+
{"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."},
521+
{"quorumHash", RPCArg::Type::STR_HEX, /* default */ "", "The quorum identifier."},
522+
{"submit", RPCArg::Type::BOOL, /* default */ "true", "Submits the signature share to the network if this is true. "
523+
"Returns an object containing the signature share if this is false."},
524+
},
525+
RPCResults{},
526+
RPCExamples{""},
527+
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
528+
{
529+
const Consensus::LLMQType llmqType{Params().GetConsensus().llmqTypePlatform};
530+
return quorum_sign_helper(request, llmqType);
499531
},
500532
};
501533
}
@@ -1110,6 +1142,7 @@ static const CRPCCommand commands[] =
11101142
{ "evo", "quorum", "dkgstatus", &quorum_dkgstatus, {"detail_level"} },
11111143
{ "evo", "quorum", "memberof", &quorum_memberof, {"proTxHash", "scanQuorumsCount"} },
11121144
{ "evo", "quorum", "sign", &quorum_sign, {"llmqType", "id", "msgHash", "quorumHash", "submit"} },
1145+
{ "evo", "quorum", "platformsign", &quorum_platformsign, {"id", "msgHash", "quorumHash", "submit"} },
11131146
{ "evo", "quorum", "verify", &quorum_verify, {"llmqType", "id", "msgHash", "signature", "quorumHash", "signHeight"} },
11141147
{ "evo", "quorum", "hasrecsig", &quorum_hasrecsig, {"llmqType", "id", "msgHash"} },
11151148
{ "evo", "quorum", "getrecsig", &quorum_getrecsig, {"llmqType", "id", "msgHash"} },

test/functional/feature_asset_locks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def create_assetunlock(self, index, withdrawal, pubkey=None, fee=tiny_amount):
119119
unlock_tx.calc_sha256()
120120
msgHash = format(unlock_tx.sha256, '064x')
121121

122-
recsig = self.get_recovered_sig(request_id, msgHash, llmq_type=llmq_type_test)
122+
recsig = self.get_recovered_sig(request_id, msgHash, llmq_type=llmq_type_test, use_platformsign=True)
123123

124124
unlockTx_payload.quorumSig = bytearray.fromhex(recsig["sig"])
125125
unlock_tx.vExtraPayload = unlockTx_payload.serialize()

test/functional/test_framework/test_framework.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2033,13 +2033,16 @@ def check_recovered_sig():
20332033
return True
20342034
wait_until_helper(check_recovered_sig, timeout=timeout, sleep=1)
20352035

2036-
def get_recovered_sig(self, rec_sig_id, rec_sig_msg_hash, llmq_type=100):
2036+
def get_recovered_sig(self, rec_sig_id, rec_sig_msg_hash, llmq_type=100, use_platformsign=False):
20372037
# Note: recsigs aren't relayed to regular nodes by default,
20382038
# make sure to pick a mn as a node to query for recsigs.
20392039
try:
20402040
quorumHash = self.mninfo[0].node.quorum("selectquorum", llmq_type, rec_sig_id)["quorumHash"]
20412041
for mn in self.mninfo:
2042-
mn.node.quorum("sign", llmq_type, rec_sig_id, rec_sig_msg_hash, quorumHash)
2042+
if use_platformsign:
2043+
mn.node.quorum("platformsign", rec_sig_id, rec_sig_msg_hash, quorumHash)
2044+
else:
2045+
mn.node.quorum("sign", llmq_type, rec_sig_id, rec_sig_msg_hash, quorumHash)
20432046
self.wait_for_recovered_sig(rec_sig_id, rec_sig_msg_hash, llmq_type, 10)
20442047
return self.mninfo[0].node.quorum("getrecsig", llmq_type, rec_sig_id, rec_sig_msg_hash)
20452048
except JSONRPCException as e:

0 commit comments

Comments
 (0)