Skip to content

[Feature] Sort peers by height #3844

@vicsn

Description

@vicsn

🚀 Feature

We need a few more pieced in order to tackle: #3580

Clients should make sure that they're communicating with the most advanced peers in order to always sync with the network.

Could we do something like the following, without breaking too many abstractions:

  1. We track a last_height_seen metric for each peer we connected to.
  2. Whenever we save to disk, attempt to order the peers not just by reputation but also by the optional last seen height.
  3. Whenever we submit a PeerResponse in fn peer_request, attempt to order the peers by reputation and by the optional last seen height. Whenever we receive a PeerResponse, insert in the peer_pool sorted by optional last_height_seen, so that when we fetch candidate_peers we choose:
    a. num_deficient - 1 peers which have the highest last seen height (assuming honest reporting)
    b. 1 peer randomly from the rest of the set (in order to protect against dishonest reporting)

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions