Skip to content

Commit

Permalink
fix: assert in signing_shares - amount of members can match with amou…
Browse files Browse the repository at this point in the history
…nt of attempts

Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com>
  • Loading branch information
knst and UdjinM6 committed Sep 18, 2024
1 parent d754799 commit 8286bdf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/llmq/signing_shares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/signing_shares.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class CSigSharesManager : public CRecoveredSigsListener

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)
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 8286bdf

Please sign in to comment.