-
Notifications
You must be signed in to change notification settings - Fork 474
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
In-browser Peer routing with DHT client not working #1621
Comments
Based on further investigation, the root cause of this problem is how multiaddrs are published to the DHT. It seems that non of the |
Thanks for digging into this @2color , but I don't have access to that slack archive, would you be able to post a screenshot of those findings here for reference? Thanks. |
@maschad : the discussion is in a public channel #ipfs-chatter on Filecoin slack (which is bridged to IPFS Discord/Matrix). |
Thanks for pointing that out @BigLep I will post a link here to the discord chat since that's a bit more accessible @2color have you also explored whether |
I haven't yet. Would love any tips on how to best debug/explore this with js-libp2p
Yeah that seems to be the case. There's a number of things happening here probably causing this:
|
Issue for upgrading bootstrap nodes to newer Kubo versions: https://github.com/protocol/bifrost-infra/issues/2409 |
@2color I think this can be closed, right? There's no change to js-libp2p necessary here, the remote peer needs to be running kubo 0.18.x to tell you its quic-v1 addresses.
js-libp2p has a .peerStore property that lets you see what your node knows about a remote peer. See the example in the jsdoc linked to for how to get that information. |
I want to verify this again today. I also realised that this is very different to delegated routing because this lookup isn't recursive and there are likely not many other nodes the browser can connect to (only WSS and Webtransport), to find the peer record. |
That's correct, and why delegated routing exists - to ask a node that can make more connections (via tcp, quic, etc) to do the lookup operation on your behalf. This will be less necessary over time, as more network non-browser nodes support listening on webtransport and webrtc addresses.
What do you mean by "recursive" in this context? |
Although the initial peer routing will rely on WSS nodes because both WebTransport and WebRTC multiaddrs are ephemeral, and you need to get those from somewhere.
A proper Kademlia search with multiple hops |
I saw a PR from achingbrain which disabled autodailing and delegated peer routing here. Did that solve this issue? |
Yeah, this is generally working and was likely a problem with the bootstrap nodes running an older version of Kubo. It's still hard to sometimes tell which connections are actually open in the browser, but that isn't directly related to this issue. |
Just popping in out of curiosity if you ever managed to get peer routing working in a browser by way of setting the dht to client mode instead of needing to rely on delegated peer routing? The screen cast video linked in the readme shows two form fields, one for find multiaddrs, and another to connect to a peer using a multiaddr. Currently the master branch's (https://github.com/libp2p/universal-connectivity) front end builds only with the later field so I get the impression peer routing from the browser was removed for the time being? It seems like this feature is either just recently doable, or still not quite possible, for browser based libp2p nodes. |
@AustinFoss : are you referring to https://github.com/libp2p/universal-connectivity ? |
@BigLep Yes, my bad should have been more explicit. Forgot, amidst all my tabs, this issue wasn't over in that repo. |
@AustinFoss the universal-connectivity app sets the browser node's DHT to client mode: So all browser nodes in the app function as clients. They rely on the rust-peer, which acts as the DHT server, to discover other peers. Does that help? |
@p-shahi This helps a bit I think. From what I understand from your response there's some feature of the rust implementation of the libp2p node that allows it to act as a kademlia server, and able to provide routing for the browser nodes with kadDHT set to client mode? Whereas in my test case, because I've only bootstrapped my browser node to the provided bootstrap peers found in all the libp2p examples, even with client mode set I can't utilize this method of peer routing because those default bootstrap nodes don't provide a DHT server? Is that correct? If so, do kubo/go-ipfs nodes have the ability to act as a DHT server but most just haven't toggled that flag yet? I'm not super fluent in rust but that line in the rust node's code you linked to I'm not sure where it's enabling the DHT server functionality. |
Yes that's right
No worries, the relevant point is the rust-libp2p peer has Kademlia enabled by default in the app. The line I shared shows the rust peer adding addresses to it's routing table.
I will direct this question to one of the kubo stewards, perhaps @aschmahmann or @Jorropo ? |
This is another step forward in my understanding, but for further clarity; is this a side effect of the rust implementation of Kademlia over the go implementation, or just a side effect of how the rust/go(kubo) implementations of libp2p use Kademlia? That question might need to wait for the two other contributors you tagged to make a comment. Something else that might need to wait for them is, if go-libp2p can offer peer routing to connected browser nodes operating with their DHTs set to client mode when will the default bootstrap nodes have this feature enabled? Specficially these ones:
Side note, I'm a aware this might not be the best place to be continuing this discussion; but it is the most relevant issue (open or closed) to what I'm trying to achieve, and with the aim of not fragmenting the discussion I'm just continuing to post replies here. |
Background
As a user, I want to be able to write browser-based applications that use PeerIDs, e.g.
12D3KooWRBy97UB99e3J6hiPesre1MZeuNQvfan4gBziswrRJsNK
to connect to server peers (kubo) over WebTransport.For js-libp2p to connect to a peer, it needs to resolve a string PeerID to a list of multi-addresses and establish a connection over a protocol supported by the browser, e.g. WebTransport
/ip4/77.191.236.66/udp/27432/quic-v1/webtransport/certhash/uEiCHJ1wdNQ6PuWY_q1fZ1xYBk02c8P8vzYKLUB37swCD3g/certhash/uEiCdUXNMurDDZbHMsIBD-wEwuXN1xqT3LuAaS1XyLtEjVQ/p2p/12D3KooWRBy97UB99e3J6hiPesre1MZeuNQvfan4gBziswrRJsNK
This issue is blocking libp2p/universal-connectivity#1
Problem encountered
The problem is that when a js-libp2p node is instantiated with DHT client mode in the browser, and a call is made to
libp2p.dht.findPeer('12D3KooWBdmLJjhpgJ9KZgLM3f894ff9xyBfPvPjFNn7MKJpyrC2')
, the response is missing the WebTransport multi addresses.Specifically, I get:
But why? 🙃
identify
protocol.Reproduction: https://js-libp2p-transports-example-nextjs.vercel.app/
Source: https://github.com/2color/js-libp2p-transports-example/
Package Versions
Platform
Chrome Version 110.0.5481.177 (Official Build) (arm64)
Subsystem: DHT
Severity:
High - The main functionality of the application does not work, API breakage, repo format breakage, etc.
Steps to reproduce the error:
See full reproduction: https://github.com/2color/js-libp2p-transports-example/tree/main/packages/nextjs
The text was updated successfully, but these errors were encountered: