HomePhabricator

net_processing: do not treat non-connecting headers as response

Description

net_processing: do not treat non-connecting headers as response

Summary:
Since https://github.com/bitcoin/bitcoin/pull/25454 we keep track of the last
GETHEADERS request that was sent and wasn't responded to. So far, every incoming
HEADERS message is treated as a response to whatever GETHEADERS was last sent,
regardless of its contents.

This commit makes this tracking more accurate, by only treating HEADERS messages
which (1) are empty, (2) connect to our existing block header tree, or (3) are a
continuation of a low-work headers sync as responses that clear the "outstanding
GETHEADERS" state (m_last_getheaders_timestamp).

That means that HEADERS messages which do not satisfy any of the above criteria
will be ignored, not triggering a GETHEADERS, and potentially (for now, but see
later commit) increase misbehavior score.

This is a partial backport of core#29575
https://github.com/bitcoin/bitcoin/pull/29575/commits/9f66ac7cf1931c4d7c36abbb000b7de306d83a4c

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D18029

Details

Provenance
Pieter Wuille <pieter@wuille.net>Authored on Mar 12 2024, 17:18
PiRKCommitted on Thu, May 1, 13:40
PiRKPushed on Thu, May 1, 13:40
Reviewer
Restricted Project
Differential Revision
D18029: net_processing: do not treat non-connecting headers as response
Parents
rABC4642b1e2a62a: [Automated] Update electrum checkpoints
Branches
Unknown
Tags
Unknown