Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert libp2p peer discovery #985

Closed
corverroos opened this issue Aug 17, 2022 · 0 comments
Closed

Invert libp2p peer discovery #985

corverroos opened this issue Aug 17, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@corverroos
Copy link
Contributor

corverroos commented Aug 17, 2022

Problem to be solved

We currently use libp2p routing.PeerRouting to integrate it with discv5 and static bootnodes. This is effectively a "pull" model where libp2p pulls addresses from outside if no addresses are known.

The problem with PeerRouting is that it is only called when the libp2p peer store has no addresses for a peer. Controlling addresses in the peer store is however complex and is affected by other libp2p services like Identify, AutoNat, AutoRelay, etc. Addresses in the peer store is controlled by TTLs. By updating and mutating TTL, the addresses are added, kept, expired, and removed from the peerstore by all these different services.

Most notably, when a connection to a peer is dropped, the Identify service updates the address of that connection/peer to RecentlyConnectedAddrTTL (30min). That means that after we had a connection to a peer, the PeerRouting will not be called for at least 30min. This prevents features like #952.

Proposed solution

Refactor the PeerRouting "pull" model to a "push" model by inserting discv5 or relay addresses directly into the peer store.

  • The peer store is built to support multiple addresses for a peer, it seems to manage that quite well.
  • We just need to ensure that resolved discv5 addresses/enrs are always present in the peer store.
  • We just need to ensure that relay addresses of resolved relays are always present in the peer store.
  • Add a lifecycle hook to p2p package that periodically resolves all peer addresses from discv5 and stores them in the peer store.
  • Use expbackoff for period, so we resolve stuff fast on startup by then slow down afterwards.
  • Add a function that adds all potential relay addresses to the peer store with TTL permanent.
  • Remove pull peer routing as an alpha feature (so keep both while we roll out pushed based routing)

Out of Scope

This is blocking #952.

@corverroos corverroos added the enhancement New feature or request label Aug 17, 2022
@corverroos corverroos self-assigned this Aug 17, 2022
obol-bulldozer bot pushed a commit that referenced this issue Aug 18, 2022
Inverts the integration between  discv5 and libp2p from pull to push.

category: refactor
ticket: #985 
feature_flag: invert_discv5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant