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

feat(DHT): Ping neighbors and ring contacts in layer1 #2501

Merged
merged 4 commits into from
Apr 22, 2024

Conversation

juslesan
Copy link
Contributor

@juslesan juslesan commented Apr 16, 2024

Summary

Added configuration to periodically ping neighbors and ring contacts. This ensures that the peers in the nodes' structures are periodically refreshed. This ensures that ungracefully leaving peers are eventually detected.

Changes

  • Added utility function to ping contacts.
  • Added two new configurations to the DhtNode to enable periodic pinging.
  • Query random neighbors in the PeerDiscovery's Recovery interval

Limitations

There needs to be new mechanisms implemented to ensure that nodes that lose connectivity to the internet can rejoin the layer1 DHT. Previously the contacts and nodes in the buckets would remain there if internet connectivity was lost. Nodes will no longer be able to rejoin the streams properly. Publishing this feature before such mechanisms are in place could be detrimental to the system in the long run.

@juslesan juslesan requested review from harbu, ptesavol and teogeb April 16, 2024 10:40
@github-actions github-actions bot added network Related to Network Package dht Related to DHT package labels Apr 16, 2024
packages/dht/src/dht/DhtNode.ts Outdated Show resolved Hide resolved
packages/dht/src/dht/DhtNode.ts Outdated Show resolved Hide resolved
@juslesan juslesan merged commit 468524f into main Apr 22, 2024
23 checks passed
@juslesan juslesan deleted the ping-neighbors-and-ring branch April 22, 2024 07:00
juslesan added a commit that referenced this pull request Apr 22, 2024
#2502)

## Summary

Manually trigger a rejoin to the layer 1 DHTs if connectivity is lost.
This is a required feature after #2501 as the nodes in layer1 will lose
contacts when disconnected from the internet. This is also an
improvement for rejoining streams in general after lost connectivity.

This is achieved by reating to a new event the DhtNode that is emitted
if the number of neighbors drops to 0 and there are no configured
entrypoints. When a layer1 DhtNode emits the event, the network node
will attempt to query entry points to a stream from the Layer0 DHT. It
will then call `joinDht` on the layer1 node with the queried entry
points. This operation is ran in an interval until the node finds at
least one neighbor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dht Related to DHT package network Related to Network Package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants