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

kademlia: can't discover providers run by relayed peers #3005

Closed
fgimenez opened this issue Oct 10, 2022 · 4 comments
Closed

kademlia: can't discover providers run by relayed peers #3005

fgimenez opened this issue Oct 10, 2022 · 4 comments

Comments

@fgimenez
Copy link

Summary

A client connecting to a relayv2 server starts providing a key (by calling kademlia.start_providing), from other peers (even from the relay server itself) no providers for that key are found (by calling kademlia.get_providers). The client is listening on the relayed multiaddr and this multiaddr is explicitly added to kademlia with kademlia.add_address.

Expected behaviour

Providers run by relayed peers can be discovered.

Not sure if this is actually the excepted behaviour, please let me know if not.

Actual behaviour

Looks like the multiaddr including p2p-circuit are being filtered out or not included at all.

Debug Output on the relayed client:

    %cDEBUG%c src/network/relay_client.rs:231%c received event: Behaviour(Kademlia(OutboundQueryCompleted { id: QueryId(0), result: StartProviding(Ok(AddProviderOk { key: Key(b"12D3KooWP285Hw3CSTdr9oU6Ezz4hDoi6XS5vfDjjNeTJ1uFMGvp_info") })), stats: QueryStats { requests: 2, success: 2, failure: 0, start: Some(Instant(1.27222s)), end: Some(Instant(1.313394999s)) } }))          
    color: white; padding: 0 3px; background: blue;

Debug Output on the relay server:

[2022-10-10T11:13:18Z DEBUG wasm_net::network::relay_server] received event: Behaviour(Kademlia(OutboundQueryCompleted { id: QueryId(2), result: GetProviders(Ok(GetProvidersOk { key: Key(b"12D3KooWP285Hw3CSTdr9oU6Ezz4hDoi6XS5vfDjjNeTJ1uFMGvp_info"), providers: {}, closest_peers: [] })), stats: QueryStats { requests: 0, success: 0, failure: 0, start: Some(Instant { tv_sec: 16213, tv_nsec: 400116198 }), end: Some(Instant { tv_sec: 16213, tv_nsec: 400116198 }) } }))             

Version

  • libp2p version (version number, commit, or branch): aba5ccb

Would you like to work on fixing this bug?

Yes.

@mxinden
Copy link
Member

mxinden commented Oct 12, 2022

Expected behaviour

Providers run by relayed peers can be discovered.

Not sure if this is actually the excepted behaviour, please let me know if not.

I would expect the same behavior. (Note that this will not be the behavior once #2032 is fixed and enabled.)


Does the relay server add the client to its routing table? In other words do you get a KademliaEvent::RoutingUpdated before calling Kademlia::get_providers? The log below suggests that this is not the case.

> `QueryStats { requests: 0, success: 0, failure: 0,`

@fgimenez
Copy link
Author

Does the relay server add the client to its routing table? In other words do you get a KademliaEvent::RoutingUpdated before calling Kademlia::get_providers?

You are totally right, in the relay server log I don't see any KademliaEvent::RoutingUpdated event. How can I make sure the relayed peers are added to the server routing table?

Note that this will not be the behavior once #2032 is fixed and enabled.

Ok, thanks for the heads up, how will things work after #2032 is merged?

@mxinden
Copy link
Member

mxinden commented Oct 14, 2022

Does the relay server add the client to its routing table? In other words do you get a KademliaEvent::RoutingUpdated before calling Kademlia::get_providers?

You are totally right, in the relay server log I don't see any KademliaEvent::RoutingUpdated event. How can I make sure the relayed peers are added to the server routing table?

For now I suggest you run libp2p-identify. Once you identified a remote peer and that peer supports the Kademlia protocol, you can call Kademlia::add_address.

See https://github.com/mxinden/rust-libp2p-server/blob/3040de8f1f08d41171de7e9987483688383124e1/src/main.rs#L129-L156

This will improve once we have #2680.

Note that this will not be the behavior once #2032 is fixed and enabled.

Ok, thanks for the heads up, how will things work after #2032 is merged?

Unless you configure your clients to run in Kademlia client mode, nothing will change on your end.

@fgimenez
Copy link
Author

Awesome, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants