0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-09 10:43:19 -05:00

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.
This commit is contained in:
Pieter Wuille 2024-03-07 11:27:31 -05:00
parent 944c54290d
commit 5120ab1478

View file

@ -662,10 +662,10 @@ private:
bool CheckHeadersPoW(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams, Peer& peer); bool CheckHeadersPoW(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams, Peer& peer);
/** Calculate an anti-DoS work threshold for headers chains */ /** Calculate an anti-DoS work threshold for headers chains */
arith_uint256 GetAntiDoSWorkThreshold(); arith_uint256 GetAntiDoSWorkThreshold();
/** Deal with state tracking and headers sync for peers that send the /** Deal with state tracking and headers sync for peers that send
* occasional non-connecting header (this can happen due to BIP 130 headers * non-connecting headers (this can happen due to BIP 130 headers
* announcements for blocks interacting with the 2hr (MAX_FUTURE_BLOCK_TIME) rule). */ * announcements for blocks interacting with the 2hr (MAX_FUTURE_BLOCK_TIME) rule). */
void HandleFewUnconnectingHeaders(CNode& pfrom, Peer& peer, const std::vector<CBlockHeader>& headers) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex); void HandleUnconnectingHeaders(CNode& pfrom, Peer& peer, const std::vector<CBlockHeader>& headers) EXCLUSIVE_LOCKS_REQUIRED(g_msgproc_mutex);
/** Return true if the headers connect to each other, false otherwise */ /** Return true if the headers connect to each other, false otherwise */
bool CheckHeadersAreContinuous(const std::vector<CBlockHeader>& headers) const; bool CheckHeadersAreContinuous(const std::vector<CBlockHeader>& headers) const;
/** Try to continue a low-work headers sync that has already begun. /** Try to continue a low-work headers sync that has already begun.
@ -2715,7 +2715,7 @@ arith_uint256 PeerManagerImpl::GetAntiDoSWorkThreshold()
* *
* We'll send a getheaders message in response to try to connect the chain. * We'll send a getheaders message in response to try to connect the chain.
*/ */
void PeerManagerImpl::HandleFewUnconnectingHeaders(CNode& pfrom, Peer& peer, void PeerManagerImpl::HandleUnconnectingHeaders(CNode& pfrom, Peer& peer,
const std::vector<CBlockHeader>& headers) const std::vector<CBlockHeader>& headers)
{ {
// Try to fill in the missing headers. // Try to fill in the missing headers.
@ -3094,12 +3094,10 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
bool headers_connect_blockindex{chain_start_header != nullptr}; bool headers_connect_blockindex{chain_start_header != nullptr};
if (!headers_connect_blockindex) { if (!headers_connect_blockindex) {
if (nCount <= MAX_BLOCKS_TO_ANNOUNCE) { // This could be a BIP 130 block announcement, use
// If this looks like it could be a BIP 130 block announcement, use // special logic for handling headers that don't connect, as this
// special logic for handling headers that don't connect, as this // could be benign.
// could be benign. HandleUnconnectingHeaders(pfrom, peer, headers);
HandleFewUnconnectingHeaders(pfrom, peer, headers);
}
return; return;
} }