fix: assert in signing_shares - amount of members can match with amount of attempts

Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
Konstantin Akimov 2024-09-05 16:58:14 +07:00
parent d754799580
commit 8286bdf611
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
3 changed files with 5 additions and 5 deletions

View File

@ -807,9 +807,9 @@ void CSigSharesManager::TryRecoverSig(const CQuorumCPtr& quorum, const uint256&
sigman.ProcessRecoveredSig(rs);
}
CDeterministicMNCPtr CSigSharesManager::SelectMemberForRecovery(const CQuorumCPtr& quorum, const uint256 &id, size_t attempt)
CDeterministicMNCPtr CSigSharesManager::SelectMemberForRecovery(const CQuorumCPtr& quorum, const uint256 &id, int attempt)
{
assert(size_t(attempt) < quorum->members.size());
assert(attempt < quorum->params.recoveryMembers);
std::vector<std::pair<uint256, CDeterministicMNCPtr>> v;
v.reserve(quorum->members.size());
@ -819,7 +819,7 @@ CDeterministicMNCPtr CSigSharesManager::SelectMemberForRecovery(const CQuorumCPt
}
std::sort(v.begin(), v.end());
return v[attempt].second;
return v[attempt % v.size()].second;
}
void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher>>& sigSharesToRequest)

View File

@ -434,7 +434,7 @@ public:
void HandleNewRecoveredSig(const CRecoveredSig& recoveredSig) override;
static CDeterministicMNCPtr SelectMemberForRecovery(const CQuorumCPtr& quorum, const uint256& id, size_t attempt);
static CDeterministicMNCPtr SelectMemberForRecovery(const CQuorumCPtr& quorum, const uint256& id, int attempt);
private:
// all of these return false when the currently processed message should be aborted (as each message actually contains multiple messages)

View File

@ -732,7 +732,7 @@ static RPCHelpMan quorum_selectquorum()
ret.pushKV("quorumHash", quorum->qc->quorumHash.ToString());
UniValue recoveryMembers(UniValue::VARR);
for (size_t i = 0; i < size_t(quorum->params.recoveryMembers); i++) {
for (int i = 0; i < quorum->params.recoveryMembers; ++i) {
auto dmn = llmq_ctx.shareman->SelectMemberForRecovery(quorum, id, i);
recoveryMembers.push_back(dmn->proTxHash.ToString());
}