-
Notifications
You must be signed in to change notification settings - Fork 964
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
Clearer Kademlia client lifecycle and internals #2122
Comments
Thanks for reaching out @izolyomi.
I wish I had more time to work on this. Contributions in any form, especially on documentation and tutorials are very much appreciated.
When spawning a request to a rust-libp2p/protocols/request-response/src/lib.rs Lines 389 to 394 in c1ef4bf
Depends on your use-case. In tiny setups (e.g.
Can you run with |
@mxinden thanks for the answer. Investigating some more, I can confirm that all problems regarding sending requests are caused by having no known addresses of the target peer. Meanwhile I've managed upgrading to the unreleased 0.39, it seems to be much more stable in practice with the kademlia Unfortunately, I still experience a behaviour that I think is a deterministic bug somewhere around Kademlia. Whenever a Kademlia query (typically I'll try to prepare and attach some usable logs here showing this pattern as you asked. |
Please find the logs attached, there's quite a lot of messages in about 5MBs. My sample codebase goes by |
I am not quite sure I follow. I am having difficulties deducing this behavior from the logs. Do I understand correctly that the addresses you add via |
Sorry for the unclear explanation. Your understanding is mostly right above, but the whole point of my experimentation is to somehow automate address discovery, i.e. to contact a peer without its address known in advance. Hence I don't manually add addresses, but leave address discovery to However, once the external address is discovered and the peer is connected, request/response messages are sent and everything seems to work as expected, as soon as the This is deterministic behaviour even with the latest 0.39 patched with the Soon we are about to release new versions of some open source crates I'm using, so I'll probably be able to share sources for reproducing this a bit easier if needed. Until then, I'll try to give the relevant parts of the log, but that lacks the internal debug details that you'd probably need for fixing. |
The remote peer
|
Thank you @izolyomi for the distilled logs! Indeed, this is surprising.
That would be great. Some vague conjecture: The In order to confirm or refute the above conjecture, could you log all of the Kademlia events? More particularly we would need the As a more general thought, when using
Also, take a look at #2133, which I would expect would simplify your use-case once implemented. |
@mxinden thank you for the detailed description. Based on your feedback, I did some more investigation.
Function I've also checked the topic of #2133 and I agree that it might make address handling more intuitive. Besides manual address book handling, I'd expect a swarm/behaviour configuration option that enables automated filling and updating the address book with all newly discovered addresses and changes. But I agree that collected data might really consume a lot of memory and the automation might cause more implementation complexity, so it makes sense to skip this feature. I've also tried creating a smaller code example from my experiments showing the same symptoms. Doing so, I've found that dropping I'm unsure if this worths more investigation, if so I can now share the codebase and maybe we can hunt down the root cause. |
Thank you for the detailed comment.
Unless you or anyone else is still facing the issues, I would not dig deeper. |
Closing as resolved. Please comment if there is still something actionable here. |
I've been experimenting with creating a sample application that discovers its peers with Kademlia, nodes start with a peerid to connect to for encrypted "chatting". Though the libp2p variant of Kademlia is documented here, I've found only minimal tutorial and blog article on working with the Rust library and nearly nothing on its Rust implementation details, so I might have misconceptions how it works.
I'm using
tcp
transport withnoise
and a customNetworkBehaviour
composing theidentify
protocol to report external addresses,kademlia
for peer discovery and initially therequest-response
protocol for ping-pong style sample messaging. Though I managed to have the "chat" working, I still don't get the whole picture of the experienced behaviour. As far as I understand, sending a request withrequest-response
to a specific peerid always triggers dialing the peer if not connected yet.Though I always drive the event loop by polling
swarm.next_event()
, dialing a peer always fails immediately withDialFailure
unless some active Kademlia query is being executed likeget_providers()
. Not all queries work however, e.g. runningbootstrap()
is not enough, dial attempts always fail. Btw, tutorials simply ignore bootstrapping Kademlia, so I'm not completely sure when it is needed at all.Is this expected behaviour in any way? Is there any documentation how I should drive the client to work properly? Is there something I can do for easier debugging?
I know the description above is quite vague. I'm not yet sure how to provide a usable minimal codebase for reproducing the same behaviour, e.g. I'm testing in a real world environment and not using circuit-relays yet, so currently the peer to connect to must not be behind NAT. Is there any way I can help with more details to make my issue clearer?
The text was updated successfully, but these errors were encountered: