-
Notifications
You must be signed in to change notification settings - Fork 453
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
Peer-And-Content-Routing example: Remove or better document 100ms delay #950
Comments
Also interested in this info. I've tracked my experimentations on that topic through a dedicated repo: https://github.com/Alexis-ROYER/js-libp2p-content-routing-delay According to my observations:
Has anyone pointed out a formal event that should be awaited from the DHT before providing to / querying from it? |
In a system designed to operate with intermittent network connectivity, giving an error because you have no peers currently seems odd ? Would a PR be accepted on this topic, if it added an abortable smart retry whenever there were no peers ? For example, if no peers are found, we cache the request, and await the internal event (which is not exposed, but can be seen from enabling DEBUG='libp2p:*') for a new peer appearing, and then keep on trying whenever a new peer appears until we get acceptable success ? This would close this ticket, because there would no longer be any delay required before using the DHT. If acceptable, we would seek to do the same for pubsub - transient periods of no peers is expected behavior of this library - it says so on the tin |
Or, is the design intent of libp2p that retry functionality should be left up to the user, in which case we would aim to provide a module that could wrap the dht implementation by offering local persistence with retry ? @vasco-santos what are your thoughts ? Our opinion is that if a repo was supplied to libp2p, the user intends for long term persistence, and that this implicitly means long term retry and refresh of dht operations, which would be started and stopped via |
We've had a chat about this, and would like to present a summary here. Our belief is that libp2p presents a virtualized model of the conventional network as an ideal network node. The turmoil of the real world is gracefully abstracted away by libp2p and the developer can concentrate on the application logic, trusting that libp2p will eventually do what the developer asked. The tradeoff for this idealization of the network is time. In fact, 3 of the front page claims for libp2p imply eventuality of completion: Native Roaming, Work Offline, and Good For High Latency Scenarios. To achieve this, libp2p has some memory, namely the peerstore, that can help accelerate the performance of its assurances to the developer. But two areas where it fails, due to no memory, is with the dht and pubsub modules. Our expectation of an ideal dht is that it should:
Our expectation of an ideal pubsub is that it should:
@achingbrain may we please have some guidance on:
Our suggestion would be to implement a Startable interface class for both dht and pubsub, and intercept all calls to the backing dht or pubsub modules, performing long retry and other tasks, along with reload tasks. The storage we would use would be datastore keys with prefix |
This PR from @achingbrain helps show what is being waited for: https://github.com/libp2p/js-libp2p/pull/1549/files |
Sir this delay is still in the code for the example:
May we pretty please have some event that fires when the tables have propagated instead of polling for population ? |
I think there is a fundamental misunderstanding with how Kademlia works. When looking for a peer, the local node contacts the k closest nodes to the remote peer’s ID asking them for closer nodes. The local node repeats the process until it finds the peer or determines that it is not in the network. This means that if you are unable to find the content you are looking for, the node needs to await more peers being discovered as opposed to continuously querying the DHT. In this particular example we could await the connection to be established for the remote, so that PR could be opened as a less hacky fix. Now once a substantial amount of nodes are connected to the node, there is a PR that could introduce progress events to assess each query on the DHT but that still would not solve this issue. |
This example
https://github.com/libp2p/js-libp2p/blob/master/examples/peer-and-content-routing
Involves running two scripts simultaneously; they then connect to each other. Each one does this before calling findPeers
This is fine for an example/test but is not good enough for production code. There's no indication how to modify this 100ms delay when moving the example code into production code.
Expected behavior: There should be some other type of event— for example, js-libp2p-kad-dht announcing it has finished negotiating dht with the remote server— that can be
await
ed on, and the example should use it.The text was updated successfully, but these errors were encountered: