@@ -130,8 +130,6 @@ static constexpr double BLOCK_DOWNLOAD_TIMEOUT_BASE = 1;
130
130
static constexpr double BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 0.5 ;
131
131
/* * Maximum number of headers to announce when relaying blocks with headers message.*/
132
132
static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8 ;
133
- /* * Maximum number of unconnecting headers announcements before DoS score */
134
- static const int MAX_NUM_UNCONNECTING_HEADERS_MSGS = 10 ;
135
133
/* * Minimum blocks required to signal NODE_NETWORK_LIMITED */
136
134
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288 ;
137
135
/* * Window, in blocks, for connecting to NODE_NETWORK_LIMITED peers */
@@ -382,9 +380,6 @@ struct Peer {
382
380
/* * Whether we've sent our peer a sendheaders message. **/
383
381
std::atomic<bool > m_sent_sendheaders{false };
384
382
385
- /* * Length of current-streak of unconnecting headers announcements */
386
- int m_num_unconnecting_headers_msgs GUARDED_BY (NetEventsInterface::g_msgproc_mutex){0 };
387
-
388
383
/* * When to potentially disconnect peer for stalling headers download */
389
384
std::chrono::microseconds m_headers_sync_timeout GUARDED_BY (NetEventsInterface::g_msgproc_mutex){0us};
390
385
@@ -2719,37 +2714,24 @@ arith_uint256 PeerManagerImpl::GetAntiDoSWorkThreshold()
2719
2714
* announcement.
2720
2715
*
2721
2716
* We'll send a getheaders message in response to try to connect the chain.
2722
- *
2723
- * The peer can send up to MAX_NUM_UNCONNECTING_HEADERS_MSGS in a row that
2724
- * don't connect before given DoS points.
2725
- *
2726
- * Once a headers message is received that is valid and does connect,
2727
- * m_num_unconnecting_headers_msgs gets reset back to 0.
2728
2717
*/
2729
2718
void PeerManagerImpl::HandleFewUnconnectingHeaders (CNode& pfrom, Peer& peer,
2730
2719
const std::vector<CBlockHeader>& headers)
2731
2720
{
2732
- peer.m_num_unconnecting_headers_msgs ++;
2733
2721
// Try to fill in the missing headers.
2734
2722
const CBlockIndex* best_header{WITH_LOCK (cs_main, return m_chainman.m_best_header )};
2735
2723
if (MaybeSendGetHeaders (pfrom, GetLocator (best_header), peer)) {
2736
- LogPrint (BCLog::NET, " received header %s: missing prev block %s, sending getheaders (%d) to end (peer=%d, m_num_unconnecting_headers_msgs=%d )\n " ,
2724
+ LogPrint (BCLog::NET, " received header %s: missing prev block %s, sending getheaders (%d) to end (peer=%d)\n " ,
2737
2725
headers[0 ].GetHash ().ToString (),
2738
2726
headers[0 ].hashPrevBlock .ToString (),
2739
2727
best_header->nHeight ,
2740
- pfrom.GetId (), peer. m_num_unconnecting_headers_msgs );
2728
+ pfrom.GetId ());
2741
2729
}
2742
2730
2743
2731
// Set hashLastUnknownBlock for this peer, so that if we
2744
2732
// eventually get the headers - even from a different peer -
2745
2733
// we can use this peer to download.
2746
2734
WITH_LOCK (cs_main, UpdateBlockAvailability (pfrom.GetId (), headers.back ().GetHash ()));
2747
-
2748
- // The peer may just be broken, so periodically assign DoS points if this
2749
- // condition persists.
2750
- if (peer.m_num_unconnecting_headers_msgs % MAX_NUM_UNCONNECTING_HEADERS_MSGS == 0 ) {
2751
- Misbehaving (peer, 20 , strprintf (" %d non-connecting headers" , peer.m_num_unconnecting_headers_msgs ));
2752
- }
2753
2735
}
2754
2736
2755
2737
bool PeerManagerImpl::CheckHeadersAreContinuous (const std::vector<CBlockHeader>& headers) const
@@ -2991,11 +2973,6 @@ void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, c
2991
2973
void PeerManagerImpl::UpdatePeerStateForReceivedHeaders (CNode& pfrom, Peer& peer,
2992
2974
const CBlockIndex& last_header, bool received_new_header, bool may_have_more_headers)
2993
2975
{
2994
- if (peer.m_num_unconnecting_headers_msgs > 0 ) {
2995
- LogPrint (BCLog::NET, " peer=%d: resetting m_num_unconnecting_headers_msgs (%d -> 0)\n " , pfrom.GetId (), peer.m_num_unconnecting_headers_msgs );
2996
- }
2997
- peer.m_num_unconnecting_headers_msgs = 0 ;
2998
-
2999
2976
LOCK (cs_main);
3000
2977
CNodeState *nodestate = State (pfrom.GetId ());
3001
2978
@@ -3122,8 +3099,6 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
3122
3099
// special logic for handling headers that don't connect, as this
3123
3100
// could be benign.
3124
3101
HandleFewUnconnectingHeaders (pfrom, peer, headers);
3125
- } else {
3126
- Misbehaving (peer, 10 , " invalid header received" );
3127
3102
}
3128
3103
return ;
3129
3104
}
0 commit comments