Page MenuHomePhabricator

Disconnect from outbound peers with bad headers chains
ClosedPublic

Authored by deadalnix on Sep 11 2018, 11:49.

Details

Summary
  • Disconnecting from bad outbound peers in IBD

When in IBD, we'd like to use all our outbound peers to help us
sync the chain. Disconnect any outbound peers whose headers have
insufficient work.

  • Permit disconnection of outbound peers on bad/slow chains

Currently we have no rotation of outbound peers. If an outbound peer
stops serving us blocks, or is on a consensus-incompatible chain with
less work than our tip (but otherwise valid headers), then we will never
disconnect that peer, even though that peer is using one of our 8
outbound connection slots. Because we rely on our outbound peers to
find an honest node in order to reach consensus, allowing an
incompatible peer to occupy one of those slots is undesirable,
particularly if it is possible for all such slots to be occupied by such
peers.

Protect against this by always checking to see if a peer's best known
block has less work than our tip, and if so, set a 20 minute timeout --
if the peer is still not known to have caught up to a chain with as much
work as ours after 20 minutes, then send a single getheaders message,
wait 2 more minutes, and if a better header hasn't been received by then,
disconnect that peer.

Note:

  • we do not require that our peer sync to the same tip as ours, just an

equal or greater work tip. (Doing otherwise would risk partitioning the
network in the event of a chain split, and is also unnecessary.)

  • we pick 4 of our outbound peers and do not subject them to this logic,

to be more conservative. We don't wish to permit temporary network
issues (or an attacker) to excessively disrupt network topology.

  • Add unit test for outbound peer eviction

This is a backport of Core PR11490

Depends on D1760 and D1763

Test Plan
make check

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Sep 16 2018, 23:37
This revision was automatically updated to reflect the committed changes.