libp2p / rust-libp2p

The Rust Implementation of the libp2p networking stack.
https://libp2p.io
MIT License
4.5k stars 932 forks source link

rendezvous: Refresh on external address changes #4627

Closed dariusc93 closed 11 months ago

dariusc93 commented 11 months ago

Description

Have the rendezvous behaviour refresh its registration upon any external address changes

Motivation

When there is ever a change in an external address, we would have to register to the namespace on the rendezvous node so that it can have the up-to-date address of the peer. This would could create some complexity and be redundant to do since it may require

a. A wrapper around rendezvous behaviour but track registered namespaces and monitor FromSwarm::ExternalAddrConfirmed and FromSwarm::ExternalAddrExpired for any changes to register to the existing namespaces.

b. To monitor for any changes to Swarm::external_addresses and register to any namespaces so the node can be up to date. This would require checking in a loop of sorts.

Although the spec is not specific on updating on every change, it does state

Peers can refresh their registrations at any time with a new `REGISTER` message

With this said, I do believe it would be appropriate to automate this upon external address changes.

Current Implementation

Current implementation does not register upon any changes to the external addresses, however it does have placeholders that would allow us to implement this easily due to it tracking the external addresses

https://github.com/libp2p/rust-libp2p/blob/c4ab04c57cb1f746430a3e3d972635e4c3fe3cc2/protocols/rendezvous/src/client.rs#L220-L224

While we do track discovered peers, we dont explicitly track namespaces we are successfully registered to based on the implementation client implementation so its hard to determine if we want to reuse discovered_peers keys when refreshing or if we want to have a separate field to track the successful registration to a given node.

https://github.com/libp2p/rust-libp2p/blob/c4ab04c57cb1f746430a3e3d972635e4c3fe3cc2/protocols/rendezvous/src/client.rs#L50

Are you planning to do it yourself in a pull request ?

Maybe

thomaseizinger commented 11 months ago

This makes sense.

While we do track discovered peers, we dont explicitly track namespaces we are successfully registered to based on the implementation client implementation so its hard to determine if we want to reuse discovered_peers keys when refreshing or if we want to have a separate field to track the successful registration to a given node.

I'd opt for a separate field. I am not even sure our own registration is part of the mentioned map.