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

gossipsub peer sharing #2391

Closed
Frederik-Baetens opened this issue Dec 17, 2021 · 9 comments
Closed

gossipsub peer sharing #2391

Frederik-Baetens opened this issue Dec 17, 2021 · 9 comments

Comments

@Frederik-Baetens
Copy link
Contributor

Frederik-Baetens commented Dec 17, 2021

I'm trying to build a system where nodes connect to a set of known nodes to join the gossipsub network.

However, it seems like these peers don't reach out to eachother after establishing a connection to the known nodes.

Is there any way to get some sort of peer sharing & automatic connection handling?

I saw this pr and it mentions peer eXchange being held up by an addition to the spec which has been merged for a while now, but i'm not sure if that spec has been implemented yet.

An example of what i'm trying to do (adapted from the libp2p examples): https://github.com/Frederik-Baetens/libp2p-tokiochat

It allows starting the first node with cargo run. The following nodes are then connected with cargo run -- *multiaddr of first node*

I'd like the additional nodes to find eachother, and for the chat application to keep working after the first node has been shut down. Currently I get an insufficientpeers error after the original node gets shut down.

Am I supposed to implement this functionality myself based on things like https://docs.rs/libp2p/latest/libp2p/core/struct.Network.html#method.connected_peers ? Or could this be made to work of the box?

Older issue about this: #1559

@mxinden
Copy link
Member

mxinden commented Dec 19, 2021

Thanks for the detailed issue @Frederik-Baetens. Are you calling GossipsubConfig::do_px?

@Frederik-Baetens
Copy link
Contributor Author

Frederik-Baetens commented Dec 19, 2021

I'm constructing my config as follows:

        // Set a custom gossipsub
        let gossipsub_config = gossipsub::GossipsubConfigBuilder::default()
            .heartbeat_interval(Duration::from_secs(10)) // This is set to aid debugging by not cluttering the log space
            .validation_mode(ValidationMode::Strict) // This sets the kind of message validation. The default is Strict (enforce message signing)
            .message_id_fn(message_id_fn) // content-address messages. No two messages of the
            // same content will be propagated.
            .build()
            .expect("Valid config");

So i think it should be enabled, since it says that it's enabled by default in the docs. I tried adding .do_px() explicitly to the configbuilder, but that doesn't seem to make a difference. Should I do something for peer exchange when calling the eventloop/handling gossipsub events?

@Frederik-Baetens
Copy link
Contributor Author

I've pushed an update to my example repository with the explicit do_px(). It still doesn't seem to work.

I made a small recording of what happens:

screencast.mp4

@AgeManning
Copy link
Contributor

Yes. Sorry this was not documented well. Gossipsub currently does not support peer exchange because rust-libp2p did not support signed peer records.

I've not been up to date with the current state of the peer records, but we will add this feature when we can.

@AgeManning
Copy link
Contributor

Please see this for more details: #2397

@thomaseizinger
Copy link
Contributor

thomaseizinger commented Dec 21, 2021

I've not been up to date with the current state of the peer records, but we will add this feature when we can.

We have peer records now! They were added as part of the rendezvous protocol!

See: https://github.com/libp2p/rust-libp2p/blob/master/core/src/peer_record.rs

@Frederik-Baetens
Copy link
Contributor Author

So should this feature work? Does do_px actually do anything?

@mxinden
Copy link
Member

mxinden commented Dec 21, 2021

So should this feature work? Does do_px actually do anything?

Unfortunately it does not, thus for now you need to rely on a different discovery mechanism (e.g. libp2p-kad, libp2p-rendezvous or libp2p-mdns).

Tracked here #2398. Contributions are welcome, right @AgeManning?

@AgeManning
Copy link
Contributor

Tracked here #2398. Contributions are welcome, right @AgeManning?

Absolutely.

If you dont want to build this yourself. We will get to it, its just going to take some time, pretty flat out at the moment :).

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

4 participants