net_processing: make all Misbehaving increments = 100

This removes the need to actually track misbehavior score (see further commit), because any
Misbehaving node will immediately hit the discouragement threshold.
This commit is contained in:
Pieter Wuille
2024-03-05 08:28:14 -05:00
parent 5120ab1478
commit 6457c31197
7 changed files with 28 additions and 23 deletions

View File

@@ -1949,8 +1949,7 @@ bool PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
return true;
// Conflicting (but not necessarily invalid) data or different policy:
case BlockValidationResult::BLOCK_MISSING_PREV:
// TODO: Handle this much more gracefully (10 DoS points is super arbitrary)
if (peer) Misbehaving(*peer, 10, message);
if (peer) Misbehaving(*peer, 100, message);
return true;
case BlockValidationResult::BLOCK_RECENT_CONSENSUS_CHANGE:
case BlockValidationResult::BLOCK_TIME_FUTURE:
@@ -2690,7 +2689,7 @@ bool PeerManagerImpl::CheckHeadersPoW(const std::vector<CBlockHeader>& headers,
// Are these headers connected to each other?
if (!CheckHeadersAreContinuous(headers)) {
Misbehaving(peer, 20, "non-continuous headers sequence");
Misbehaving(peer, 100, "non-continuous headers sequence");
return false;
}
return true;
@@ -4107,7 +4106,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
if (vAddr.size() > MAX_ADDR_TO_SEND)
{
Misbehaving(*peer, 20, strprintf("%s message size = %u", msg_type, vAddr.size()));
Misbehaving(*peer, 100, strprintf("%s message size = %u", msg_type, vAddr.size()));
return;
}
@@ -4189,7 +4188,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
vRecv >> vInv;
if (vInv.size() > MAX_INV_SZ)
{
Misbehaving(*peer, 20, strprintf("inv message size = %u", vInv.size()));
Misbehaving(*peer, 100, strprintf("inv message size = %u", vInv.size()));
return;
}
@@ -4281,7 +4280,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
vRecv >> vInv;
if (vInv.size() > MAX_INV_SZ)
{
Misbehaving(*peer, 20, strprintf("getdata message size = %u", vInv.size()));
Misbehaving(*peer, 100, strprintf("getdata message size = %u", vInv.size()));
return;
}
@@ -4966,7 +4965,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// Bypass the normal CBlock deserialization, as we don't want to risk deserializing 2000 full blocks.
unsigned int nCount = ReadCompactSize(vRecv);
if (nCount > MAX_HEADERS_RESULTS) {
Misbehaving(*peer, 20, strprintf("headers message size = %u", nCount));
Misbehaving(*peer, 100, strprintf("headers message size = %u", nCount));
return;
}
headers.resize(nCount);