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

[DRAFT] feat: conntracker #3032

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Conversation

MarcoPolo
Copy link
Collaborator

This PR attempts to refactor how NewStream works. Instead of having the swarm be responsible for picking the best connection, and then waiting on identify to run on that connection. We have a separate service that subscribes to connection events and identify events, and the NewStream asks for the best connection that has been identified.

This has a couple of advantages:

  1. We can wait for a Identify to complete on any connection. Not just the one we happen to pick.
  2. It moves connection tracking code out of the swarm into a smaller service that can be tested independently.
    a. I'd even like to run a fuzz test on the conntracker service itself.
  3. It attaches a peer's supported protocols to the connection itself rather than the peer.
    a. This allows a peer to say they support protocol X and Y over a connection, and only support Z over another one. This solves a similar problem to labelling connections as "limited", but lets the remote have a say in how we use the connection rather than the local side assuming something. But note that we aren't actually using this just yet. See also Per-connection protocol list #2693

This is a draft for now as there are a couple of TODOs in the code, some more tests I want to add, and some thought in how to roll this out (maybe default on, but can disable with an ENV flag for debugging purposes.)

This is also how I think we should build on and improve go-libp2p moving forward. Simple services that share information over an eventbus or channels (depending on the use case).

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

Successfully merging this pull request may close these issues.

1 participant