@@ -130,8 +130,6 @@ static constexpr double BLOCK_DOWNLOAD_TIMEOUT_BASE = 1;
130130static constexpr double BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 0.5 ;
131131/* * Maximum number of headers to announce when relaying blocks with headers message.*/
132132static 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 ;
135133/* * Minimum blocks required to signal NODE_NETWORK_LIMITED */
136134static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288 ;
137135/* * Window, in blocks, for connecting to NODE_NETWORK_LIMITED peers */
@@ -382,9 +380,6 @@ struct Peer {
382380 /* * Whether we've sent our peer a sendheaders message. **/
383381 std::atomic<bool > m_sent_sendheaders{false };
384382
385- /* * Length of current-streak of unconnecting headers announcements */
386- int m_num_unconnecting_headers_msgs GUARDED_BY (NetEventsInterface::g_msgproc_mutex){0 };
387-
388383 /* * When to potentially disconnect peer for stalling headers download */
389384 std::chrono::microseconds m_headers_sync_timeout GUARDED_BY (NetEventsInterface::g_msgproc_mutex){0us};
390385
@@ -2719,37 +2714,24 @@ arith_uint256 PeerManagerImpl::GetAntiDoSWorkThreshold()
27192714 * announcement.
27202715 *
27212716 * 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.
27282717 */
27292718void PeerManagerImpl::HandleFewUnconnectingHeaders (CNode& pfrom, Peer& peer,
27302719 const std::vector<CBlockHeader>& headers)
27312720{
2732- peer.m_num_unconnecting_headers_msgs ++;
27332721 // Try to fill in the missing headers.
27342722 const CBlockIndex* best_header{WITH_LOCK (cs_main, return m_chainman.m_best_header )};
27352723 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 " ,
27372725 headers[0 ].GetHash ().ToString (),
27382726 headers[0 ].hashPrevBlock .ToString (),
27392727 best_header->nHeight ,
2740- pfrom.GetId (), peer. m_num_unconnecting_headers_msgs );
2728+ pfrom.GetId ());
27412729 }
27422730
27432731 // Set hashLastUnknownBlock for this peer, so that if we
27442732 // eventually get the headers - even from a different peer -
27452733 // we can use this peer to download.
27462734 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- }
27532735}
27542736
27552737bool PeerManagerImpl::CheckHeadersAreContinuous (const std::vector<CBlockHeader>& headers) const
@@ -2991,11 +2973,6 @@ void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, c
29912973void PeerManagerImpl::UpdatePeerStateForReceivedHeaders (CNode& pfrom, Peer& peer,
29922974 const CBlockIndex& last_header, bool received_new_header, bool may_have_more_headers)
29932975{
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-
29992976 LOCK (cs_main);
30002977 CNodeState *nodestate = State (pfrom.GetId ());
30012978
@@ -3122,8 +3099,6 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
31223099 // special logic for handling headers that don't connect, as this
31233100 // could be benign.
31243101 HandleFewUnconnectingHeaders (pfrom, peer, headers);
3125- } else {
3126- Misbehaving (peer, 10 , " invalid header received" );
31273102 }
31283103 return ;
31293104 }
0 commit comments