So far, discouragement of peers triggers when their misbehavior score exceeds 100 points. Most types of misbehavior increment the score by 100, triggering immediate discouragement, but some types do not. This PR makes all increments equal to either 100 (meaning any misbehavior will immediately cause disconnection and discouragement) or 0 (making the behavior effectively unconditionally allowed), and then removes the logic for score accumulation.
This simplifies the code a bit, but also makes protocol expectations clearer: if a peer misbehaves, they get disconnected. There is no good reason why certain types of protocol violations should be permitted 4 times (howmuch=20) or 9 times (howmuch=10), while many others are never allowed. Furthermore, the distinction between these looks arbitrary.
The specific types of misbehavior that are changed to 100 are:
- Sending us a
block
which does not connect to our header tree (which necessarily must have been unsollicited). [used to be score 10] - Sending us a
headers
with a non-continuous headers sequence. [used to be score 20] - Sending us more than 1000 addresses in a single
addr
oraddrv2
message [used to be score 20] - Sending us more than 50000 invs in a single
inv
message [used to be score 20] - Sending us more than 2000 headers in a single
headers
message [used to be score 20]
The specific types of misbehavior that are changed to 0 are:
- Sending us 10 (*) separate BIP130 headers announcements that do not connect to our block tree [used to be score 20]
- Sending us more than 8 headers in a single
headers
message (which thus does not get treated as a BIP130 announcement) that does not connect to our block tree. [used to be score 10]
I believe that none of these behaviors are unavoidable, except for the one marked (*) which can in theory happen still due to interaction between BIP130 and variations in system clocks (the max 2 hour in the future rule). This one has been removed entirely. In order to remove the impact of the bug it was designed to deal with, without relying on misbehavior, a separate improvement is included that makes getheaders
-tracking more accurate.
In another unrelated improvement, this also gets rid of the 8 header limit heuristic to determine whether an incoming non-connecting headers
is a potential BIP130 announcement, as this rule is no longer needed to prevent spurious Misbehavior. Instead, any non-connecting headers
is now treated as a potential announcement.