Skip to content

Commit 4739dad

Browse files
authored
Process/keep messages/connections from PoSe-banned MNs (#2967)
* Process/keep/count votes from PoSe-banned MNs * Process dstx from PoSe-banned MNs * Recognize PoSe-banned MNs as MNs
1 parent 8648566 commit 4739dad

File tree

7 files changed

+20
-10
lines changed

7 files changed

+20
-10
lines changed

src/evo/deterministicmns.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,20 @@ CDeterministicMNCPtr CDeterministicMNList::GetValidMNByCollateral(const COutPoin
168168
return dmn;
169169
}
170170

171-
CDeterministicMNCPtr CDeterministicMNList::GetValidMNByService(const CService& service) const
171+
CDeterministicMNCPtr CDeterministicMNList::GetMNByService(const CService& service) const
172172
{
173173
return GetUniquePropertyMN(service);
174174
}
175175

176+
CDeterministicMNCPtr CDeterministicMNList::GetValidMNByService(const CService& service) const
177+
{
178+
auto dmn = GetUniquePropertyMN(service);
179+
if (dmn && !IsMNValid(dmn)) {
180+
return nullptr;
181+
}
182+
return dmn;
183+
}
184+
176185
static int CompareByLastPaid_GetHeight(const CDeterministicMN& dmn)
177186
{
178187
int height = dmn.pdmnState->nLastPaidHeight;

src/evo/deterministicmns.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ class CDeterministicMNList
306306
CDeterministicMNCPtr GetMNByOperatorKey(const CBLSPublicKey& pubKey);
307307
CDeterministicMNCPtr GetMNByCollateral(const COutPoint& collateralOutpoint) const;
308308
CDeterministicMNCPtr GetValidMNByCollateral(const COutPoint& collateralOutpoint) const;
309+
CDeterministicMNCPtr GetMNByService(const CService& service) const;
309310
CDeterministicMNCPtr GetValidMNByService(const CService& service) const;
310311
CDeterministicMNCPtr GetMNPayee() const;
311312

src/evo/mnauth.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void CMNAuth::ProcessMessage(CNode* pnode, const std::string& strCommand, CDataS
7272
}
7373

7474
auto mnList = deterministicMNManager->GetListAtChainTip();
75-
auto dmn = mnList.GetValidMN(mnauth.proRegTxHash);
75+
auto dmn = mnList.GetMN(mnauth.proRegTxHash);
7676
if (!dmn) {
7777
LOCK(cs_main);
7878
// in case he was unlucky and not up to date, just let him be connected as a regular node, which gives him

src/governance/governance-object.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ bool CGovernanceObject::ProcessVote(CNode* pfrom,
118118
}
119119

120120
auto mnList = deterministicMNManager->GetListAtChainTip();
121-
auto dmn = mnList.GetValidMNByCollateral(vote.GetMasternodeOutpoint());
121+
auto dmn = mnList.GetMNByCollateral(vote.GetMasternodeOutpoint());
122122

123123
if (!dmn) {
124124
std::ostringstream ostr;
@@ -227,7 +227,7 @@ void CGovernanceObject::ClearMasternodeVotes()
227227

228228
vote_m_it it = mapCurrentMNVotes.begin();
229229
while (it != mapCurrentMNVotes.end()) {
230-
if (!mnList.HasValidMNByCollateral(it->first)) {
230+
if (!mnList.HasMNByCollateral(it->first)) {
231231
fileVotes.RemoveVotesFromMasternode(it->first);
232232
mapCurrentMNVotes.erase(it++);
233233
} else {

src/governance/governance.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,11 @@ std::vector<CGovernanceVote> CGovernanceManager::GetCurrentVotes(const uint256&
474474
auto mnList = deterministicMNManager->GetListAtChainTip();
475475
std::map<COutPoint, CDeterministicMNCPtr> mapMasternodes;
476476
if (mnCollateralOutpointFilter.IsNull()) {
477-
mnList.ForEachMN(true, [&](const CDeterministicMNCPtr& dmn) {
477+
mnList.ForEachMN(false, [&](const CDeterministicMNCPtr& dmn) {
478478
mapMasternodes.emplace(dmn->collateralOutpoint, dmn);
479479
});
480480
} else {
481-
auto dmn = mnList.GetValidMNByCollateral(mnCollateralOutpointFilter);
481+
auto dmn = mnList.GetMNByCollateral(mnCollateralOutpointFilter);
482482
if (dmn) {
483483
mapMasternodes.emplace(dmn->collateralOutpoint, dmn);
484484
}

src/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ void CConnman::ThreadOpenConnections()
18891889
{
18901890
CAddrInfo addr = addrman.Select(fFeeler);
18911891

1892-
bool isMasternode = mnList.GetValidMNByService(addr) != nullptr;
1892+
bool isMasternode = mnList.GetMNByService(addr) != nullptr;
18931893

18941894
// if we selected an invalid address, restart
18951895
if (!addr.IsValid() || setConnected.count(addr.GetGroup()))
@@ -2081,7 +2081,7 @@ void CConnman::ThreadOpenMasternodeConnections()
20812081
std::vector<CService> pending;
20822082
for (const auto& group : masternodeQuorumNodes) {
20832083
for (const auto& proRegTxHash : group.second) {
2084-
auto dmn = mnList.GetValidMN(proRegTxHash);
2084+
auto dmn = mnList.GetMN(proRegTxHash);
20852085
if (!dmn) {
20862086
continue;
20872087
}
@@ -2792,7 +2792,7 @@ bool CConnman::IsMasternodeQuorumNode(const CNode* pnode)
27922792
uint256 assumedProTxHash;
27932793
if (pnode->verifiedProRegTxHash.IsNull() && !pnode->fInbound) {
27942794
auto mnList = deterministicMNManager->GetListAtChainTip();
2795-
auto dmn = mnList.GetValidMNByService(pnode->addr);
2795+
auto dmn = mnList.GetMNByService(pnode->addr);
27962796
if (dmn == nullptr) {
27972797
// This is definitely not a masternode
27982798
return false;

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
21672167
return true; // not an error
21682168
}
21692169

2170-
auto dmn = deterministicMNManager->GetListAtChainTip().GetValidMNByCollateral(dstx.masternodeOutpoint);
2170+
auto dmn = deterministicMNManager->GetListAtChainTip().GetMNByCollateral(dstx.masternodeOutpoint);
21712171
if(!dmn) {
21722172
LogPrint(BCLog::PRIVATESEND, "DSTX -- Can't find masternode %s to verify %s\n", dstx.masternodeOutpoint.ToStringShort(), hashTx.ToString());
21732173
return false;

0 commit comments

Comments
 (0)