refactor: remove retBan flag from ReceiveMessage

This commit is contained in:
Konstantin Akimov 2024-09-20 15:36:35 +07:00
parent d26d4ab0bc
commit fb78b0cc94
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
3 changed files with 9 additions and 23 deletions

View File

@ -259,12 +259,10 @@ bool CDKGSession::PreVerifyMessage(const CDKGContribution& qc, bool& retBan) con
return true; return true;
} }
void CDKGSession::ReceiveMessage(const CDKGContribution& qc, bool& retBan) void CDKGSession::ReceiveMessage(const CDKGContribution& qc)
{ {
CDKGLogger logger(*this, __func__, __LINE__); CDKGLogger logger(*this, __func__, __LINE__);
retBan = false;
auto* member = GetMember(qc.proTxHash); auto* member = GetMember(qc.proTxHash);
cxxtimer::Timer t1(true); cxxtimer::Timer t1(true);
@ -569,12 +567,10 @@ bool CDKGSession::PreVerifyMessage(const CDKGComplaint& qc, bool& retBan) const
return true; return true;
} }
void CDKGSession::ReceiveMessage(const CDKGComplaint& qc, bool& retBan) void CDKGSession::ReceiveMessage(const CDKGComplaint& qc)
{ {
CDKGLogger logger(*this, __func__, __LINE__); CDKGLogger logger(*this, __func__, __LINE__);
retBan = false;
logger.Batch("received complaint from %s", qc.proTxHash.ToString()); logger.Batch("received complaint from %s", qc.proTxHash.ToString());
auto* member = GetMember(qc.proTxHash); auto* member = GetMember(qc.proTxHash);
@ -780,12 +776,10 @@ bool CDKGSession::PreVerifyMessage(const CDKGJustification& qj, bool& retBan) co
return true; return true;
} }
void CDKGSession::ReceiveMessage(const CDKGJustification& qj, bool& retBan) void CDKGSession::ReceiveMessage(const CDKGJustification& qj)
{ {
CDKGLogger logger(*this, __func__, __LINE__); CDKGLogger logger(*this, __func__, __LINE__);
retBan = false;
logger.Batch("received justification from %s", qj.proTxHash.ToString()); logger.Batch("received justification from %s", qj.proTxHash.ToString());
auto* member = GetMember(qj.proTxHash); auto* member = GetMember(qj.proTxHash);
@ -1095,12 +1089,10 @@ bool CDKGSession::PreVerifyMessage(const CDKGPrematureCommitment& qc, bool& retB
return true; return true;
} }
void CDKGSession::ReceiveMessage(const CDKGPrematureCommitment& qc, bool& retBan) void CDKGSession::ReceiveMessage(const CDKGPrematureCommitment& qc)
{ {
CDKGLogger logger(*this, __func__, __LINE__); CDKGLogger logger(*this, __func__, __LINE__);
retBan = false;
cxxtimer::Timer t1(true); cxxtimer::Timer t1(true);
logger.Batch("received premature commitment from %s. validMembers=%d", qc.proTxHash.ToString(), qc.CountValidMembers()); logger.Batch("received premature commitment from %s. validMembers=%d", qc.proTxHash.ToString(), qc.CountValidMembers());

View File

@ -350,7 +350,7 @@ public:
void Contribute(CDKGPendingMessages& pendingMessages); void Contribute(CDKGPendingMessages& pendingMessages);
void SendContributions(CDKGPendingMessages& pendingMessages); void SendContributions(CDKGPendingMessages& pendingMessages);
bool PreVerifyMessage(const CDKGContribution& qc, bool& retBan) const; 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); void VerifyPendingContributions() EXCLUSIVE_LOCKS_REQUIRED(cs_pending);
// Phase 2: complaint // Phase 2: complaint
@ -358,19 +358,19 @@ public:
void VerifyConnectionAndMinProtoVersions() const; void VerifyConnectionAndMinProtoVersions() const;
void SendComplaint(CDKGPendingMessages& pendingMessages); void SendComplaint(CDKGPendingMessages& pendingMessages);
bool PreVerifyMessage(const CDKGComplaint& qc, bool& retBan) const; bool PreVerifyMessage(const CDKGComplaint& qc, bool& retBan) const;
void ReceiveMessage(const CDKGComplaint& qc, bool& retBan); void ReceiveMessage(const CDKGComplaint& qc);
// Phase 3: justification // Phase 3: justification
void VerifyAndJustify(CDKGPendingMessages& pendingMessages); void VerifyAndJustify(CDKGPendingMessages& pendingMessages);
void SendJustification(CDKGPendingMessages& pendingMessages, const std::set<uint256>& forMembers); void SendJustification(CDKGPendingMessages& pendingMessages, const std::set<uint256>& forMembers);
bool PreVerifyMessage(const CDKGJustification& qj, bool& retBan) const; bool PreVerifyMessage(const CDKGJustification& qj, bool& retBan) const;
void ReceiveMessage(const CDKGJustification& qj, bool& retBan); void ReceiveMessage(const CDKGJustification& qj);
// Phase 4: commit // Phase 4: commit
void VerifyAndCommit(CDKGPendingMessages& pendingMessages); void VerifyAndCommit(CDKGPendingMessages& pendingMessages);
void SendCommitment(CDKGPendingMessages& pendingMessages); void SendCommitment(CDKGPendingMessages& pendingMessages);
bool PreVerifyMessage(const CDKGPrematureCommitment& qc, bool& retBan) const; bool PreVerifyMessage(const CDKGPrematureCommitment& qc, bool& retBan) const;
void ReceiveMessage(const CDKGPrematureCommitment& qc, bool& retBan); void ReceiveMessage(const CDKGPrematureCommitment& qc);
// Phase 5: aggregate/finalize // Phase 5: aggregate/finalize
std::vector<CFinalCommitment> FinalizeCommitments(); std::vector<CFinalCommitment> FinalizeCommitments();

View File

@ -489,13 +489,7 @@ bool ProcessPendingMessageBatch(CDKGSession& session, CDKGPendingMessages& pendi
if (badNodes.count(nodeId)) { if (badNodes.count(nodeId)) {
continue; continue;
} }
bool ban = false; session.ReceiveMessage(*p.second);
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);
}
} }
return true; return true;