libp2p / specs

Technical specifications for the libp2p networking stack
https://libp2p.io
1.58k stars 275 forks source link

[Rendezvous protocol] Is TTL always relative? #330

Closed thomaseizinger closed 3 years ago

thomaseizinger commented 3 years ago

The rendezvous protocol specifies that TTL is always in seconds which implies that it is a relative value.

Am I correct that a rendezvous server would only return the remaining TTL within each discover response? Alternatively, the value inside the discover response could also be an absolute unix timestamp at which the registration expires.

For example:

12:00 A -> R: REGISTER{ns: my-app, ttl: 4h}

14:00 B -> R: DISCOVER{ns: my-app}
      R -> B: {[REGISTER{my-app, {QmA, Addr, ttl: 2h}}], c1}
mxinden commented 3 years ago

@vasco-santos can you help here?

vasco-santos commented 3 years ago

The rendezvous protocol specifies that TTL is always in seconds which implies that it is a relative value.

It is a relative value. The server will create a timestamp (sum current_time + ttl)

12:00 A -> R: DISCOVER{ns: my-app, ttl: 4h}

Be careful that Discover Message does not have ttl

Am I correct that a rendezvous server would only return the remaining TTL within each discover response

That is correct

Alternatively, the value inside the discover response could also be an absolute unix timestamp at which the registration expires.

I was not involved in the protocol design. But an absolute timestamp might create problems for machines in different timezones. As a consequence, we could for example return registrations that are already invalid. This is probably the main reason for being the Rendezvous server to be responsible for the exact time of validity

thomaseizinger commented 3 years ago

Cool, thanks for confirming that!

Be careful that Discover Message does not have ttl

Yep that was just a copy-paste error :) I've edited the original post.