Skip to content

Commit fe14f5f

Browse files
committed
[Output] Properly log reason(s) for increasing a peer's DoS score.
Many of the MN related DoS checks had their log messages output only if the client was running in debug mode, leading to unexplained peer bans.
1 parent 9985266 commit fe14f5f

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

src/masternode-budget.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,8 +1147,10 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
11471147

11481148
mapSeenMasternodeBudgetVotes.insert(make_pair(vote.GetHash(), vote));
11491149
if (!vote.SignatureValid(true)) {
1150-
LogPrint("mnbudget","mvote - signature invalid\n");
1151-
if (masternodeSync.IsSynced()) Misbehaving(pfrom->GetId(), 20);
1150+
if (masternodeSync.IsSynced()) {
1151+
LogPrintf("CBudgetManager::ProcessMessage() : mvote - signature invalid\n");
1152+
Misbehaving(pfrom->GetId(), 20);
1153+
}
11521154
// it could just be a non-synced masternode
11531155
mnodeman.AskForMN(pfrom, vote.vin);
11541156
return;
@@ -1219,8 +1221,10 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
12191221

12201222
mapSeenFinalizedBudgetVotes.insert(make_pair(vote.GetHash(), vote));
12211223
if (!vote.SignatureValid(true)) {
1222-
LogPrint("mnbudget","fbvote - signature invalid\n");
1223-
if (masternodeSync.IsSynced()) Misbehaving(pfrom->GetId(), 20);
1224+
if (masternodeSync.IsSynced()) {
1225+
LogPrintf("CBudgetManager::ProcessMessage() : fbvote - signature invalid\n");
1226+
Misbehaving(pfrom->GetId(), 20);
1227+
}
12241228
// it could just be a non-synced masternode
12251229
mnodeman.AskForMN(pfrom, vote.vin);
12261230
return;

src/masternode-payments.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
366366

367367
if (Params().NetworkID() == CBaseChainParams::MAIN) {
368368
if (pfrom->HasFulfilledRequest("mnget")) {
369-
LogPrint("masternode","mnget - peer already asked me for the list\n");
369+
LogPrintf("CMasternodePayments::ProcessMessageMasternodePayments() : mnget - peer already asked me for the list\n");
370370
Misbehaving(pfrom->GetId(), 20);
371371
return;
372372
}
@@ -413,8 +413,10 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
413413
}
414414

415415
if (!winner.SignatureValid()) {
416-
// LogPrint("masternode","mnw - invalid signature\n");
417-
if (masternodeSync.IsSynced()) Misbehaving(pfrom->GetId(), 20);
416+
if (masternodeSync.IsSynced()) {
417+
LogPrintf("CMasternodePayments::ProcessMessageMasternodePayments() : mnw - invalid signature\n");
418+
Misbehaving(pfrom->GetId(), 20);
419+
}
418420
// it could just be a non-synced masternode
419421
mnodeman.AskForMN(pfrom, winner.vinMasternode);
420422
return;

src/masternodeman.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
751751
// make sure the vout that was signed is related to the transaction that spawned the Masternode
752752
// - this is expensive, so it's only done once per Masternode
753753
if (!obfuScationSigner.IsVinAssociatedWithPubkey(mnb.vin, mnb.pubKeyCollateralAddress)) {
754-
LogPrint("masternode","mnb - Got mismatched pubkey and vin\n");
754+
LogPrintf("CMasternodeMan::ProcessMessage() : mnb - Got mismatched pubkey and vin\n");
755755
Misbehaving(pfrom->GetId(), 33);
756756
return;
757757
}
@@ -810,8 +810,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
810810
if (i != mAskedUsForMasternodeList.end()) {
811811
int64_t t = (*i).second;
812812
if (GetTime() < t) {
813+
LogPrintf("CMasternodeMan::ProcessMessage() : dseg - peer already asked me for the list\n");
813814
Misbehaving(pfrom->GetId(), 34);
814-
LogPrint("masternode","dseg - peer already asked me for the list\n");
815815
return;
816816
}
817817
}
@@ -877,7 +877,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
877877

878878
// make sure signature isn't in the future (past is OK)
879879
if (sigTime > GetAdjustedTime() + 60 * 60) {
880-
LogPrint("masternode","dsee - Signature rejected, too far into the future %s\n", vin.prevout.hash.ToString());
880+
LogPrintf("CMasternodeMan::ProcessMessage() : dsee - Signature rejected, too far into the future %s\n", vin.prevout.hash.ToString());
881881
Misbehaving(pfrom->GetId(), 1);
882882
return;
883883
}
@@ -888,7 +888,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
888888
strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(protocolVersion) + donationAddress.ToString() + boost::lexical_cast<std::string>(donationPercentage);
889889

890890
if (protocolVersion < masternodePayments.GetMinMasternodePaymentsProto()) {
891-
LogPrint("masternode","dsee - ignoring outdated Masternode %s protocol version %d < %d\n", vin.prevout.hash.ToString(), protocolVersion, masternodePayments.GetMinMasternodePaymentsProto());
891+
LogPrintf("CMasternodeMan::ProcessMessage() : dsee - ignoring outdated Masternode %s protocol version %d < %d\n", vin.prevout.hash.ToString(), protocolVersion, masternodePayments.GetMinMasternodePaymentsProto());
892892
Misbehaving(pfrom->GetId(), 1);
893893
return;
894894
}
@@ -897,7 +897,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
897897
pubkeyScript = GetScriptForDestination(pubkey.GetID());
898898

899899
if (pubkeyScript.size() != 25) {
900-
LogPrint("masternode","dsee - pubkey the wrong size\n");
900+
LogPrintf("CMasternodeMan::ProcessMessage() : dsee - pubkey the wrong size\n");
901901
Misbehaving(pfrom->GetId(), 100);
902902
return;
903903
}
@@ -906,20 +906,20 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
906906
pubkeyScript2 = GetScriptForDestination(pubkey2.GetID());
907907

908908
if (pubkeyScript2.size() != 25) {
909-
LogPrint("masternode","dsee - pubkey2 the wrong size\n");
909+
LogPrintf("CMasternodeMan::ProcessMessage() : dsee - pubkey2 the wrong size\n");
910910
Misbehaving(pfrom->GetId(), 100);
911911
return;
912912
}
913913

914914
if (!vin.scriptSig.empty()) {
915-
LogPrint("masternode","dsee - Ignore Not Empty ScriptSig %s\n", vin.prevout.hash.ToString());
915+
LogPrintf("CMasternodeMan::ProcessMessage() : dsee - Ignore Not Empty ScriptSig %s\n", vin.prevout.hash.ToString());
916916
Misbehaving(pfrom->GetId(), 100);
917917
return;
918918
}
919919

920920
std::string errorMessage = "";
921921
if (!obfuScationSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)) {
922-
LogPrint("masternode","dsee - Got bad Masternode address signature\n");
922+
LogPrintf("CMasternodeMan::ProcessMessage() : dsee - Got bad Masternode address signature\n");
923923
Misbehaving(pfrom->GetId(), 100);
924924
return;
925925
}
@@ -973,7 +973,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
973973
// make sure the vout that was signed is related to the transaction that spawned the Masternode
974974
// - this is expensive, so it's only done once per Masternode
975975
if (!obfuScationSigner.IsVinAssociatedWithPubkey(vin, pubkey)) {
976-
LogPrint("masternode","dsee - Got mismatched pubkey and vin\n");
976+
LogPrintf("CMasternodeMan::ProcessMessage() : dsee - Got mismatched pubkey and vin\n");
977977
Misbehaving(pfrom->GetId(), 100);
978978
return;
979979
}
@@ -999,7 +999,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
999999

10001000
if (fAcceptable) {
10011001
if (GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS) {
1002-
LogPrint("masternode","dsee - Input must have least %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS);
1002+
LogPrintf("CMasternodeMan::ProcessMessage() : dsee - Input must have least %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS);
10031003
Misbehaving(pfrom->GetId(), 20);
10041004
return;
10051005
}
@@ -1073,13 +1073,13 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
10731073
//LogPrint("masternode","dseep - Received: vin: %s sigTime: %lld stop: %s\n", vin.ToString().c_str(), sigTime, stop ? "true" : "false");
10741074

10751075
if (sigTime > GetAdjustedTime() + 60 * 60) {
1076-
LogPrint("masternode","dseep - Signature rejected, too far into the future %s\n", vin.prevout.hash.ToString());
1076+
LogPrintf("CMasternodeMan::ProcessMessage() : dseep - Signature rejected, too far into the future %s\n", vin.prevout.hash.ToString());
10771077
Misbehaving(pfrom->GetId(), 1);
10781078
return;
10791079
}
10801080

10811081
if (sigTime <= GetAdjustedTime() - 60 * 60) {
1082-
LogPrint("masternode","dseep - Signature rejected, too far into the past %s - %d %d \n", vin.prevout.hash.ToString(), sigTime, GetAdjustedTime());
1082+
LogPrintf("CMasternodeMan::ProcessMessage() : dseep - Signature rejected, too far into the past %s - %d %d \n", vin.prevout.hash.ToString(), sigTime, GetAdjustedTime());
10831083
Misbehaving(pfrom->GetId(), 1);
10841084
return;
10851085
}

0 commit comments

Comments
 (0)