mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Verify min proto version and open ports of LLMQ members and vote on bad ones
This commit is contained in:
parent
f43cdbc586
commit
32c83b432b
@ -12,6 +12,7 @@
|
||||
#include <evo/specialtx.h>
|
||||
|
||||
#include <masternode/activemasternode.h>
|
||||
#include <masternode/masternode-meta.h>
|
||||
#include <chainparams.h>
|
||||
#include <init.h>
|
||||
#include <net.h>
|
||||
@ -437,9 +438,47 @@ void CDKGSession::VerifyAndComplain(CDKGPendingMessages& pendingMessages)
|
||||
logger.Batch("verified contributions. time=%d", t1.count());
|
||||
logger.Flush();
|
||||
|
||||
if (sporkManager.IsSporkActive(SPORK_21_QUORUM_ALL_CONNECTED)) {
|
||||
VerifyConnectionAndMinProtoVersions();
|
||||
}
|
||||
|
||||
SendComplaint(pendingMessages);
|
||||
}
|
||||
|
||||
void CDKGSession::VerifyConnectionAndMinProtoVersions()
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
|
||||
std::unordered_map<uint256, int, StaticSaltedHasher> protoMap;
|
||||
g_connman->ForEachNode([&](const CNode* pnode) {
|
||||
if (pnode->verifiedProRegTxHash.IsNull()) {
|
||||
return;
|
||||
}
|
||||
protoMap.emplace(pnode->verifiedProRegTxHash, pnode->nVersion);
|
||||
});
|
||||
|
||||
for (auto& m : members) {
|
||||
if (m->dmn->proTxHash == myProTxHash) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto it = protoMap.find(m->dmn->proTxHash);
|
||||
if (it == protoMap.end()) {
|
||||
m->badConnection = true;
|
||||
logger.Batch("%s is not connected to us", m->dmn->proTxHash.ToString());
|
||||
} else if (it != protoMap.end() && it->second < MIN_MASTERNODE_PROTO_VERSION) {
|
||||
m->badConnection = true;
|
||||
logger.Batch("%s does not have min proto version %d (has %d)", m->dmn->proTxHash.ToString(), MIN_MASTERNODE_PROTO_VERSION, it->second);
|
||||
}
|
||||
|
||||
auto lastOutbound = mmetaman.GetMetaInfo(m->dmn->proTxHash)->GetLastOutboundSuccess();
|
||||
if (GetAdjustedTime() - lastOutbound > 60 * 60) {
|
||||
m->badConnection = true;
|
||||
logger.Batch("%s no outbound connection since %d seconds", m->dmn->proTxHash.ToString(), GetAdjustedTime() - lastOutbound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDKGSession::SendComplaint(CDKGPendingMessages& pendingMessages)
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
@ -455,7 +494,7 @@ void CDKGSession::SendComplaint(CDKGPendingMessages& pendingMessages)
|
||||
int complaintCount = 0;
|
||||
for (size_t i = 0; i < members.size(); i++) {
|
||||
auto& m = members[i];
|
||||
if (m->bad) {
|
||||
if (m->bad || m->badConnection) {
|
||||
qc.badMembers[i] = true;
|
||||
badCount++;
|
||||
} else if (m->weComplain) {
|
||||
|
@ -217,6 +217,7 @@ public:
|
||||
std::set<uint256> complaintsFromOthers;
|
||||
|
||||
bool bad{false};
|
||||
bool badConnection{false};
|
||||
bool weComplain{false};
|
||||
bool someoneComplain{false};
|
||||
};
|
||||
@ -310,6 +311,7 @@ public:
|
||||
|
||||
// Phase 2: complaint
|
||||
void VerifyAndComplain(CDKGPendingMessages& pendingMessages);
|
||||
void VerifyConnectionAndMinProtoVersions();
|
||||
void SendComplaint(CDKGPendingMessages& pendingMessages);
|
||||
bool PreVerifyMessage(const uint256& hash, const CDKGComplaint& qc, bool& retBan) const;
|
||||
void ReceiveMessage(const uint256& hash, const CDKGComplaint& qc, bool& retBan);
|
||||
|
@ -22,6 +22,9 @@ static const int GETHEADERS_VERSION = 70077;
|
||||
//! disconnect from peers older than this proto version
|
||||
static const int MIN_PEER_PROTO_VERSION = 70213;
|
||||
|
||||
//! minimum proto version of masternode to accept in DKGs
|
||||
static const int MIN_MASTERNODE_PROTO_VERSION = 70217;
|
||||
|
||||
//! nTime field added to CAddress, starting with this version;
|
||||
//! if possible, avoid requesting addresses nodes older than this
|
||||
static const int CADDR_TIME_VERSION = 31402;
|
||||
|
Loading…
Reference in New Issue
Block a user