Skip to content

Commit cbe1202

Browse files
PastaPastaPastaknst
authored andcommitted
Add option to AsyncSignIfMember to allow signing same requestID on different msgHashes
codereview suggestions continued
1 parent ee5cec1 commit cbe1202

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/llmq/ehf_signals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void CEHFSignalsHandler::trySignEHFSignal(int bit, const CBlockIndex* const pind
9494
LogPrint(BCLog::EHF, "CEHFSignalsHandler::trySignEHFSignal: msgHash=%s quorum=%s id=%s\n", msgHash.ToString(), quorum->qc->quorumHash.ToString(), requestId.ToString());
9595

9696
WITH_LOCK(cs, ids.insert(requestId));
97-
sigman.AsyncSignIfMember(llmqType, shareman, requestId, msgHash);
97+
sigman.AsyncSignIfMember(llmqType, shareman, requestId, msgHash, quorum->qc->quorumHash, false, true);
9898
}
9999

100100
void CEHFSignalsHandler::HandleNewRecoveredSig(const CRecoveredSig& recoveredSig)

src/llmq/signing.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,9 @@ void CSigningManager::UnregisterRecoveredSigsListener(CRecoveredSigsListener* l)
876876
recoveredSigsListeners.erase(itRem, recoveredSigsListeners.end());
877877
}
878878

879-
bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, CSigSharesManager& shareman, const uint256& id, const uint256& msgHash, const uint256& quorumHash, bool allowReSign)
879+
bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, CSigSharesManager& shareman, const uint256& id,
880+
const uint256& msgHash, const uint256& quorumHash, bool allowReSign,
881+
bool allowDiffMsgHashSigning)
880882
{
881883
LogPrintf("CSigningManager::AsyncSignIfMember id=%s\n", id.ToString());
882884
if (m_mn_activeman == nullptr) return false;
@@ -917,9 +919,15 @@ bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, CSigShares
917919
uint256 prevMsgHash;
918920
db.GetVoteForId(llmqType, id, prevMsgHash);
919921
if (msgHash != prevMsgHash) {
920-
LogPrintf("CSigningManager::%s -- already voted for id=%s and msgHash=%s. Not voting on conflicting msgHash=%s\n", __func__,
921-
id.ToString(), prevMsgHash.ToString(), msgHash.ToString());
922-
return false;
922+
if (allowDiffMsgHashSigning) {
923+
LogPrintf("CSigningManager::%s -- already voted for id=%s and msgHash=%s. Signing for different msgHash=%s\n",
924+
__func__, id.ToString(), prevMsgHash.ToString(), msgHash.ToString());
925+
hasVoted = false;
926+
} else {
927+
LogPrintf("CSigningManager::%s -- already voted for id=%s and msgHash=%s. Not voting on conflicting msgHash=%s\n",
928+
__func__, id.ToString(), prevMsgHash.ToString(), msgHash.ToString());
929+
return false;
930+
}
923931
} else if (allowReSign) {
924932
LogPrint(BCLog::LLMQ, "CSigningManager::%s -- already voted for id=%s and msgHash=%s. Resigning!\n", __func__,
925933
id.ToString(), prevMsgHash.ToString());

src/llmq/signing.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ class CSigningManager
218218
void RegisterRecoveredSigsListener(CRecoveredSigsListener* l);
219219
void UnregisterRecoveredSigsListener(CRecoveredSigsListener* l);
220220

221-
bool AsyncSignIfMember(Consensus::LLMQType llmqType, CSigSharesManager& shareman, const uint256& id, const uint256& msgHash, const uint256& quorumHash = uint256(), bool allowReSign = false);
221+
bool AsyncSignIfMember(Consensus::LLMQType llmqType, CSigSharesManager& shareman, const uint256& id,
222+
const uint256& msgHash, const uint256& quorumHash = uint256(), bool allowReSign = false,
223+
bool allowDiffMsgHashSigning = false);
222224
bool HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash) const;
223225
bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id) const;
224226
bool HasRecoveredSigForSession(const uint256& signHash) const;

0 commit comments

Comments
 (0)