From fb78b0cc94c7ea5b637b79b4c24f7fd8dc9550c9 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 20 Sep 2024 15:36:35 +0700 Subject: [PATCH] refactor: remove retBan flag from ReceiveMessage --- src/llmq/dkgsession.cpp | 16 ++++------------ src/llmq/dkgsession.h | 8 ++++---- src/llmq/dkgsessionhandler.cpp | 8 +------- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/llmq/dkgsession.cpp b/src/llmq/dkgsession.cpp index b5f393d4d2..c3416df3fa 100644 --- a/src/llmq/dkgsession.cpp +++ b/src/llmq/dkgsession.cpp @@ -259,12 +259,10 @@ bool CDKGSession::PreVerifyMessage(const CDKGContribution& qc, bool& retBan) con return true; } -void CDKGSession::ReceiveMessage(const CDKGContribution& qc, bool& retBan) +void CDKGSession::ReceiveMessage(const CDKGContribution& qc) { CDKGLogger logger(*this, __func__, __LINE__); - retBan = false; - auto* member = GetMember(qc.proTxHash); cxxtimer::Timer t1(true); @@ -569,12 +567,10 @@ bool CDKGSession::PreVerifyMessage(const CDKGComplaint& qc, bool& retBan) const return true; } -void CDKGSession::ReceiveMessage(const CDKGComplaint& qc, bool& retBan) +void CDKGSession::ReceiveMessage(const CDKGComplaint& qc) { CDKGLogger logger(*this, __func__, __LINE__); - retBan = false; - logger.Batch("received complaint from %s", qc.proTxHash.ToString()); auto* member = GetMember(qc.proTxHash); @@ -780,12 +776,10 @@ bool CDKGSession::PreVerifyMessage(const CDKGJustification& qj, bool& retBan) co return true; } -void CDKGSession::ReceiveMessage(const CDKGJustification& qj, bool& retBan) +void CDKGSession::ReceiveMessage(const CDKGJustification& qj) { CDKGLogger logger(*this, __func__, __LINE__); - retBan = false; - logger.Batch("received justification from %s", qj.proTxHash.ToString()); auto* member = GetMember(qj.proTxHash); @@ -1095,12 +1089,10 @@ bool CDKGSession::PreVerifyMessage(const CDKGPrematureCommitment& qc, bool& retB return true; } -void CDKGSession::ReceiveMessage(const CDKGPrematureCommitment& qc, bool& retBan) +void CDKGSession::ReceiveMessage(const CDKGPrematureCommitment& qc) { CDKGLogger logger(*this, __func__, __LINE__); - retBan = false; - cxxtimer::Timer t1(true); logger.Batch("received premature commitment from %s. validMembers=%d", qc.proTxHash.ToString(), qc.CountValidMembers()); diff --git a/src/llmq/dkgsession.h b/src/llmq/dkgsession.h index c16a741874..8a874f555d 100644 --- a/src/llmq/dkgsession.h +++ b/src/llmq/dkgsession.h @@ -350,7 +350,7 @@ public: void Contribute(CDKGPendingMessages& pendingMessages); void SendContributions(CDKGPendingMessages& pendingMessages); bool PreVerifyMessage(const CDKGContribution& qc, bool& retBan) const; - void ReceiveMessage(const CDKGContribution& qc, bool& retBan); + void ReceiveMessage(const CDKGContribution& qc); void VerifyPendingContributions() EXCLUSIVE_LOCKS_REQUIRED(cs_pending); // Phase 2: complaint @@ -358,19 +358,19 @@ public: void VerifyConnectionAndMinProtoVersions() const; void SendComplaint(CDKGPendingMessages& pendingMessages); bool PreVerifyMessage(const CDKGComplaint& qc, bool& retBan) const; - void ReceiveMessage(const CDKGComplaint& qc, bool& retBan); + void ReceiveMessage(const CDKGComplaint& qc); // Phase 3: justification void VerifyAndJustify(CDKGPendingMessages& pendingMessages); void SendJustification(CDKGPendingMessages& pendingMessages, const std::set& forMembers); bool PreVerifyMessage(const CDKGJustification& qj, bool& retBan) const; - void ReceiveMessage(const CDKGJustification& qj, bool& retBan); + void ReceiveMessage(const CDKGJustification& qj); // Phase 4: commit void VerifyAndCommit(CDKGPendingMessages& pendingMessages); void SendCommitment(CDKGPendingMessages& pendingMessages); bool PreVerifyMessage(const CDKGPrematureCommitment& qc, bool& retBan) const; - void ReceiveMessage(const CDKGPrematureCommitment& qc, bool& retBan); + void ReceiveMessage(const CDKGPrematureCommitment& qc); // Phase 5: aggregate/finalize std::vector FinalizeCommitments(); diff --git a/src/llmq/dkgsessionhandler.cpp b/src/llmq/dkgsessionhandler.cpp index 0df07a1653..c68cf8758a 100644 --- a/src/llmq/dkgsessionhandler.cpp +++ b/src/llmq/dkgsessionhandler.cpp @@ -489,13 +489,7 @@ bool ProcessPendingMessageBatch(CDKGSession& session, CDKGPendingMessages& pendi if (badNodes.count(nodeId)) { continue; } - bool ban = false; - session.ReceiveMessage(*p.second, ban); - if (ban) { - LogPrint(BCLog::LLMQ_DKG, "%s -- banning node after ReceiveMessage failed, peer=%d\n", __func__, nodeId); - pendingMessages.Misbehaving(nodeId, 100); - badNodes.emplace(nodeId); - } + session.ReceiveMessage(*p.second); } return true;