From 8286bdf611949e248dd5cc3e090634577512c070 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 5 Sep 2024 16:58:14 +0700 Subject: [PATCH] fix: assert in signing_shares - amount of members can match with amount of attempts Co-Authored-By: UdjinM6 --- src/llmq/signing_shares.cpp | 6 +++--- src/llmq/signing_shares.h | 2 +- src/rpc/quorums.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/llmq/signing_shares.cpp b/src/llmq/signing_shares.cpp index 3667e593bc3a9..da63536c9969a 100644 --- a/src/llmq/signing_shares.cpp +++ b/src/llmq/signing_shares.cpp @@ -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> 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>& sigSharesToRequest) diff --git a/src/llmq/signing_shares.h b/src/llmq/signing_shares.h index 3725d295be806..b1f0acbf310b7 100644 --- a/src/llmq/signing_shares.h +++ b/src/llmq/signing_shares.h @@ -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) diff --git a/src/rpc/quorums.cpp b/src/rpc/quorums.cpp index b33d42e4f4260..0ccff814a9465 100644 --- a/src/rpc/quorums.cpp +++ b/src/rpc/quorums.cpp @@ -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()); }