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

move the go-libp2p-swarm here #1414

Merged
merged 361 commits into from
Apr 22, 2022
Merged

move the go-libp2p-swarm here #1414

merged 361 commits into from
Apr 22, 2022

Conversation

marten-seemann
Copy link
Contributor

Part of #1187.

Stebalien and others added 30 commits September 20, 2017 17:24
use optimized 'HaveConnToPeer' checks
don't backoff dialing when the context is canceled
It doesn't exist anymore. This is now handled entirely though contexts.
don't pass the dial timeout option
We need a better solution (this is a memory hotspot when mass dialing) but that
will take some thought and effort. This is a simple fix that should reduce
memory usage a bit.
nil out references to finished dials
We call this method in `FindProvidersAsync`. Really, we shouldn't even be doing
that (but this is "good enough" for now).
clear out extra dial jobs after dial finishes
We already setup the connection from within the new connection handler. No need
to do it *again* on dial.
don't leak connections when canceling dials
Removes:

* go-libp2p-conn logic (moved to transports)
* go-libp2p-peerstream (moved here)

Changes:

* New transport interface.
* Explicit over implicit (the implicit automagic now all lives in go-libp2p):
  * No more default transports, muxers, etc.
  * No more fallback dialer. Transports are now *required*.
* Stream opening:
  * Connection picking logic (instead of just picking the first).
  * Tries harder to open a stream of some connections happen to be closed.
* Stream closing:
  * No longer treats half-closed streams as fully closed. Users *must* read the
    an EOF or reset the stream for it to be garbage collected.
* No more polling for dead connections.
* Multiplexers are now *non-optional*. Really, they haven't been optional for a
  while but we still pretended that they were.
* No more Network type alias. It added a bunch of code and didn't really provide
  anything but an alternative set of methods that do the same thing.
* Notifications:
  * New guarantee: connection open notifications will complete before connection
    close notifications begin.
  * Given that, notifications are now delivered in parallel. No more
    notification backlogs blocking connection closing/opening.
refactor for new transports
feat: lower timeout for local address dials
The global per-peer dial timeout had a significant drawback: When dialing many
peers, this timeout could cause libp2p to cancel dials while they were still
stuck in the limiter.

A better but more complicated approach is a time budget system but we can
implement that later.

This change simply applies the limit to each `DialPeer`/`NewStream` call
independently and makes it easy to override. While old timeout tried to
account for how much we're willing to spend dialing a single peer, this new
timeout tries to account for the amount of time a single "client" is willing to
wait for a dial to complete before they no longer care.
This timeout is already set by the dial limiter.
On trying to open a new stream against an empty peer ID, we get an
error saying that failed to dial a peer.

This commit changes that to a more informative error message:
`empty peer ID`
marten-seemann and others added 24 commits December 20, 2021 11:03
stop using the deprecated libp2p/go-maddr-filter
increment active dial counter in dial worker loop
remove dependency on go-addr-util
use the transport.Upgrader interface
add support for the resource manager
release the stream scope if the conn fails to open a new stream
It turns out it is not actually necessary if the limiter short-circuits.
Point being is that if the request channel has been closed, there is no active dial
any more, at which point we might as well consider it done.

This fixes the goroutine leak.
Refactor dial worker loop into an object and fix bug
sync: update CI config files
Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marten-seemann marten-seemann merged commit 456b36f into master Apr 22, 2022
@marten-seemann marten-seemann mentioned this pull request Apr 22, 2022
65 tasks
@marten-seemann marten-seemann deleted the merge-swarm branch April 22, 2022 16:14
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.