Compare commits

...

2 Commits

Author SHA1 Message Date
Konstantin Akimov
f0e7eb571e
fix: return operator public key as "pub key share" for compatibility to tenderdash 2024-12-17 23:42:12 +07:00
Konstantin Akimov
fd987f38bb
fix: add new quorum to cache for BuildQuorumFromCommitment 2024-12-17 15:59:15 +07:00
2 changed files with 25 additions and 6 deletions

View File

@ -411,6 +411,12 @@ CQuorumPtr CQuorumManager::BuildQuorumFromCommitment(const Consensus::LLMQType l
quorum->Init(std::move(qc), pQuorumBaseBlockIndex, minedBlockHash, members); quorum->Init(std::move(qc), pQuorumBaseBlockIndex, minedBlockHash, members);
if (populate_cache && llmq_params_opt->size == 1) {
WITH_LOCK(cs_map_quorums, mapQuorumsCache[llmqType].insert(quorumHash, quorum));
return quorum;
}
bool hasValidVvec = false; bool hasValidVvec = false;
if (WITH_LOCK(cs_db, return quorum->ReadContributions(*db))) { if (WITH_LOCK(cs_db, return quorum->ReadContributions(*db))) {
hasValidVvec = true; hasValidVvec = true;

View File

@ -179,7 +179,7 @@ static RPCHelpMan quorum_list_extended()
}; };
} }
static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumCPtr& quorum, bool includeMembers, bool includeSkShare) static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumCPtr& quorum, bool includeMembers, bool includeSkShare, bool single_node_quorum = false)
{ {
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
@ -210,9 +210,13 @@ static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_
mo.pushKV("pubKeyOperator", dmn->pdmnState->pubKeyOperator.ToString()); mo.pushKV("pubKeyOperator", dmn->pdmnState->pubKeyOperator.ToString());
mo.pushKV("valid", quorum->qc->validMembers[i]); mo.pushKV("valid", quorum->qc->validMembers[i]);
if (quorum->qc->validMembers[i]) { if (quorum->qc->validMembers[i]) {
CBLSPublicKey pubKey = quorum->GetPubKeyShare(i); if (single_node_quorum) {
if (pubKey.IsValid()) { mo.pushKV("pubKeyShare", dmn->pdmnState->pubKeyOperator.ToString());
mo.pushKV("pubKeyShare", pubKey.ToString()); } else {
CBLSPublicKey pubKey = quorum->GetPubKeyShare(i);
if (pubKey.IsValid()) {
mo.pushKV("pubKeyShare", pubKey.ToString());
}
} }
} }
membersArr.push_back(mo); membersArr.push_back(mo);
@ -225,6 +229,14 @@ static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_
if (includeSkShare && skShare.IsValid()) { if (includeSkShare && skShare.IsValid()) {
ret.pushKV("secretKeyShare", skShare.ToString()); ret.pushKV("secretKeyShare", skShare.ToString());
} }
/*
if (includeSkShare)
const CBLSSecretKey& skShare = !single_node_quorum ? quorum->GetSkShare() : ????
if (skShare.IsValid()) {
ret.pushKV("secretKeyShare", skShare.ToString());
}
}
*/
return ret; return ret;
} }
@ -245,7 +257,8 @@ static RPCHelpMan quorum_info()
const LLMQContext& llmq_ctx = EnsureLLMQContext(node); const LLMQContext& llmq_ctx = EnsureLLMQContext(node);
const Consensus::LLMQType llmqType{static_cast<Consensus::LLMQType>(ParseInt32V(request.params[0], "llmqType"))}; const Consensus::LLMQType llmqType{static_cast<Consensus::LLMQType>(ParseInt32V(request.params[0], "llmqType"))};
if (!Params().GetLLMQ(llmqType).has_value()) { auto llmq_opt = Params().GetLLMQ(llmqType);
if (!llmq_opt.has_value()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid LLMQ type"); throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid LLMQ type");
} }
@ -260,7 +273,7 @@ static RPCHelpMan quorum_info()
throw JSONRPCError(RPC_INVALID_PARAMETER, "quorum not found"); throw JSONRPCError(RPC_INVALID_PARAMETER, "quorum not found");
} }
return BuildQuorumInfo(*llmq_ctx.quorum_block_processor, quorum, true, includeSkShare); return BuildQuorumInfo(*llmq_ctx.quorum_block_processor, quorum, true, includeSkShare, llmq_opt->size == 1);
}, },
}; };
} }