Skip to content

Commit 5120ab1

Browse files
committed
net_processing: drop 8 headers threshold for incoming BIP130
With the Misbehavior score gone for non-connecting headers (see previous commit), there is no need to only treat headers messages with up to 8 headers as potential BIP130 announcements. BIP130 does not specify such a limit; it was purely a heuristic.
1 parent 944c542 commit 5120ab1

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/net_processing.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,10 @@ class PeerManagerImpl final : public PeerManager
662662
bool CheckHeadersPoW(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams, Peer& peer);
663663
/** Calculate an anti-DoS work threshold for headers chains */
664664
arith_uint256 GetAntiDoSWorkThreshold();
665-
/** Deal with state tracking and headers sync for peers that send the
666-
* occasional non-connecting header (this can happen due to BIP 130 headers
665+
/** Deal with state tracking and headers sync for peers that send
666+
* non-connecting headers (this can happen due to BIP 130 headers
667667
* announcements for blocks interacting with the 2hr (MAX_FUTURE_BLOCK_TIME) rule). */
668-
void HandleFewUnconnectingHeaders(CNode& pfrom, Peer& peer, const std::vector<CBlockHeader>& headers) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
668+
void HandleUnconnectingHeaders(CNode& pfrom, Peer& peer, const std::vector<CBlockHeader>& headers) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
669669
/** Return true if the headers connect to each other, false otherwise */
670670
bool CheckHeadersAreContinuous(const std::vector<CBlockHeader>& headers) const;
671671
/** Try to continue a low-work headers sync that has already begun.
@@ -2715,7 +2715,7 @@ arith_uint256 PeerManagerImpl::GetAntiDoSWorkThreshold()
27152715
*
27162716
* We'll send a getheaders message in response to try to connect the chain.
27172717
*/
2718-
void PeerManagerImpl::HandleFewUnconnectingHeaders(CNode& pfrom, Peer& peer,
2718+
void PeerManagerImpl::HandleUnconnectingHeaders(CNode& pfrom, Peer& peer,
27192719
const std::vector<CBlockHeader>& headers)
27202720
{
27212721
// Try to fill in the missing headers.
@@ -3094,12 +3094,10 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
30943094
bool headers_connect_blockindex{chain_start_header != nullptr};
30953095

30963096
if (!headers_connect_blockindex) {
3097-
if (nCount <= MAX_BLOCKS_TO_ANNOUNCE) {
3098-
// If this looks like it could be a BIP 130 block announcement, use
3099-
// special logic for handling headers that don't connect, as this
3100-
// could be benign.
3101-
HandleFewUnconnectingHeaders(pfrom, peer, headers);
3102-
}
3097+
// This could be a BIP 130 block announcement, use
3098+
// special logic for handling headers that don't connect, as this
3099+
// could be benign.
3100+
HandleUnconnectingHeaders(pfrom, peer, headers);
31033101
return;
31043102
}
31053103

0 commit comments

Comments
 (0)