From 860fa5a10bc836976526abc9b5d8016d35616df2 Mon Sep 17 00:00:00 2001 From: furszy Date: Sat, 30 Oct 2021 13:12:04 -0300 Subject: [PATCH] TierTwo: do not ask for single MN items if the node is in initial synchronization state. if it happens before or while the node's tier two initial synchronization is being executed, the peer will move to single items requests instead of requesting the full list. Plus, decrease the DoS score for a bad mnb signature during the initial synchronization process, so we don't end up banning pre v5.3.3 nodes too fast for an invalidly serialized mnb (this issue was solved in #2611 removing the mnb BIP155 flag, this is only an extra guard to give a bit more time to non-updated peers to upgrade while the network is upgrading). --- src/budget/budgetmanager.cpp | 10 ++++------ src/masternode.cpp | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/budget/budgetmanager.cpp b/src/budget/budgetmanager.cpp index 3aa206d3e8a4..8b1da09d830c 100644 --- a/src/budget/budgetmanager.cpp +++ b/src/budget/budgetmanager.cpp @@ -1074,7 +1074,8 @@ bool CBudgetManager::ProcessProposalVote(CBudgetVote& vote, CNode* pfrom, CValid CMasternode* pmn = mnodeman.Find(voteVin.prevout); if (!pmn) { err = strprintf("unknown masternode - vin: %s", voteVin.prevout.ToString()); - mnodeman.AskForMN(pfrom, voteVin); + // Ask for MN only if we finished syncing the MN list. + if (pfrom && masternodeSync.IsMasternodeListSynced()) mnodeman.AskForMN(pfrom, voteVin); return state.DoS(0, false, REJECT_INVALID, "bad-mvote", false, err); } @@ -1085,8 +1086,6 @@ bool CBudgetManager::ProcessProposalVote(CBudgetVote& vote, CNode* pfrom, CValid err = strprintf("signature from masternode %s invalid", voteVin.prevout.ToString()); return state.DoS(20, false, REJECT_INVALID, "bad-fbvote", false, err); } - // it could just be a non-synced masternode - mnodeman.AskForMN(pfrom, voteVin); return false; } @@ -1175,7 +1174,8 @@ bool CBudgetManager::ProcessFinalizedBudgetVote(CFinalizedBudgetVote& vote, CNod CMasternode* pmn = mnodeman.Find(voteVin.prevout); if (!pmn) { err = strprintf("unknown masternode - vin: %s", voteVin.prevout.ToString()); - mnodeman.AskForMN(pfrom, voteVin); + // Ask for MN only if we finished syncing the MN list. + if (pfrom && masternodeSync.IsMasternodeListSynced()) mnodeman.AskForMN(pfrom, voteVin); return state.DoS(0, false, REJECT_INVALID, "bad-fbvote", false, err); } @@ -1186,8 +1186,6 @@ bool CBudgetManager::ProcessFinalizedBudgetVote(CFinalizedBudgetVote& vote, CNod err = strprintf("signature from masternode %s invalid", voteVin.prevout.ToString()); return state.DoS(20, false, REJECT_INVALID, "bad-fbvote", false, err); } - // it could just be a non-synced masternode - mnodeman.AskForMN(pfrom, voteVin); return false; } diff --git a/src/masternode.cpp b/src/masternode.cpp index 1f1f5d4f9332..892bdfd3d119 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -420,7 +420,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos) if (!CheckSignature()) { // For now (till v6.0), let's be "naive" and not fully ban nodes when the node is syncing // This could be a bad parsed BIP155 address that got stored on db on an old software version. - nDos = masternodeSync.IsSynced() ? 100 : 10; + nDos = masternodeSync.IsSynced() ? 100 : 5; return error("%s : Got bad Masternode address signature", __func__); }