libp2p / go-libp2p-kad-dht

A Kademlia DHT implementation on go-libp2p
https://github.com/libp2p/specs/tree/master/kad-dht
MIT License
516 stars 221 forks source link

V2: Review usage of mockable clock in DHT #892

Closed iand closed 9 months ago

iand commented 10 months ago

The DHT allows a mock clock to be specified in configuration which can be used to create tests that control the passage of time. This causes problems when interacting with lower level libp2p components that are not aware of the fake clock. For example, setting deadlines using the clock results in times that are far in the past causing the stream to be immediately reset.

Example: https://github.com/libp2p/go-libp2p-kad-dht/blob/v2-develop/v2/stream.go#L86-L88

guillaumemichel commented 10 months ago

The mock clock should be used in tests and simulations where another endpoint / Router than the libp2p Router is used. As soon as we use the libp2p network stack, sequentiality is lost, so it doesn't really make sense to use a mock clock.

We should implement an alternative in memory Router in order to conduct reproducible tests and simulations using the mock clock.

iand commented 9 months ago

Closing as resolved as we have the in memory router implementation now