You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
Problem to be solved
We currently use libp2p
routing.PeerRouting
to integrate it withdiscv5
andstatic 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 likeIdentify
,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 toRecentlyConnectedAddrTTL (30min)
. That means that after we had a connection to a peer, thePeerRouting
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.pull peer routing
as an alpha feature (so keep both while we roll out pushed based routing)Out of Scope
This is blocking #952.
The text was updated successfully, but these errors were encountered: