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

Allow encouraging (or forcing) dials with specific properties #2412

Open
aschmahmann opened this issue Jul 7, 2023 · 2 comments
Open

Allow encouraging (or forcing) dials with specific properties #2412

aschmahmann opened this issue Jul 7, 2023 · 2 comments

Comments

@aschmahmann
Copy link
Collaborator

What

The current contract around Connect and NewStream delegates basically all control over how to form the connection to go-libp2p. This is a feature request for additional capabilities indicating a preference of how a connection might be formed.

Why

For example:

  • What if a user felt that for some workloads they'd prefer TCP over QUIC despite some of the tradeoffs (e.g. if TCP throughput exceeds QUICs for some data transfer heavy workloads)
  • What if a user knew that a particular network interface happened to be faster/cheaper for them (e.g. addresses in the same cloud provider network)
  • What if a user wanted to do some debugging using a node with lots of transports supported, but only wanted to use one of them

How

The three mechanisms I'm aware of that can enable this are:

  1. For pass/fail type behavior it might be possible for this to exist in user-space with some hackery around connection gaters, except for the fact that we might return if there is already a connection open.
  2. Information could be passed into the dialer via contexts, such as more versions of
    func WithForceDirectDial(ctx context.Context, reason string) context.Context {
  3. Using some overriding of the dialer logic with something explicit, like
    func DialRanker(d network.DialRanker) Option {
  4. More functions on the host that have explicit guarantees

None of these are enough as-is today to implement the above, however it seems likely some combination 2 + 3 would be able to get the job done.

For example, if either the DialRanker could take a context or the context could carry a custom dialer then most of the logic here could live in application space. There could also be a similar type of configuration around contexts for if a new connection should be used and a ConnectionRanker.

Why (file this issue) Now

I haven't heard a ton of requests for these features although they do come up from time to time. However, the coincidental timing of the linked kubo issue (from someone familiar with go-libp2p and kubo 😄) and the recent smart-dialer work made me think this could be useful to put on the radar in case it ends up being easier to make changes to now rather than later (e.g. should the DialRanker take a context, and should it be overridable on a per Connection/Stream basis).

@MarcoPolo
Copy link
Collaborator

Thanks for the detailed issue. Off the top of my head, having a context option that can override some dial ranking logic seems reasonable to me.

@marten-seemann
Copy link
Contributor

However, the coincidental timing of the linked kubo issue (from someone familiar with go-libp2p and kubo 😄)

I think I saw that issue ;)

This should probably be part of a larger redesign of the swarm (and the Connect) API. We definitely should make it possible to dial addresses without consulting the peerstore.

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

3 participants