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

fix!: remove autodialer #2639

Merged
merged 5 commits into from
Aug 15, 2024
Merged

fix!: remove autodialer #2639

merged 5 commits into from
Aug 15, 2024

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Jul 29, 2024

The autodialer is a feature from an older time when the DHT was less reliable and we didn't have things like the random walk component.

There's not a lot of benefit in opening connections to any old peer, instead protocols now have better ways of targetting the kind of peers they require.

Actively dialing peers harms platforms where connections are extremely expensive such as react-native so this feature has been removed.

Closes #2621
Fixes #2418

BREAKING CHANGE: the autodialer has been removed as well as the corresponding config keys

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@achingbrain achingbrain added the version-2.0 PRs that will be released in libp2p v2 label Jul 29, 2024
@achingbrain achingbrain requested a review from a team as a code owner July 29, 2024 11:36
@achingbrain achingbrain mentioned this pull request Jul 29, 2024
27 tasks
@achingbrain achingbrain changed the title feat!: remove autodialer fix!: remove autodialer Jul 29, 2024
Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

First pass, but shouldn't we be basing this off a release-v2.0 branch? Similar to what we did with release-v1.0 ?

@achingbrain achingbrain changed the base branch from main to release-v2.0 July 31, 2024 11:16
@achingbrain achingbrain force-pushed the feat/remove-autodialler branch 2 times, most recently from cf95a57 to ee07e25 Compare July 31, 2024 11:57
The autodialer is a feature from an older time when the DHT was less
reliable and we didn't have things like the random walk component.

There's not a lot of benefit in opening connections to any old peer,
instead protocols now have better ways of targetting the kind of
peers they require.

Actively dialing peers harms platforms where connections are extremely
expensive such as react-native so this feature has been removed.

Closes #2621

BREAKING CHANGE: the autodialer has been removed as well as the corresponding config keys
Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

Nice work 🚀 there are just a few little things to be addressed.

  • The Peer Discovery docs still have a few references to minConnections
  • The autoDialInterval is now irrelevant
  • We should include a migration guide essentially stating which configurations i.e. the autoDial params, have been removed and why.

@achingbrain
Copy link
Member Author

Need to double check the reconnect on disconnect for KEEP_ALIVE tagged peers still works.

Copy link
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

one potential debug log UX, or functional bug, if maxConnections isn't supposed to be set to zero.

Comment on lines -52 to -54
* Proactively tries to connect to known peers stored in the PeerStore.
* It will keep the number of connections below the upper limit and sort
* the peers to connect based on whether we know their keys and protocols.
Copy link
Member

Choose a reason for hiding this comment

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

do we have this peer sorting functionality elsewhere? anything we need to keep in here?

Also kind of related to @maschad 's original ask about potentially keeping this for some users: There may be a need to have an auto-dialer for swarm-like functionality, where you want to stay connected to a specific set of peers? Can users accomplish that without auto-dial today?

Copy link
Member Author

@achingbrain achingbrain Aug 14, 2024

Choose a reason for hiding this comment

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

There may be a need ... to stay connected to a specific set of peers? Can users accomplish that without auto-dial today?

Yes, tag them with KEEP_ALIVE.


this.running = true

this.log('not enough connections %d/%d - will dial peers to increase the number of connections', numConnections, this.minConnections)
Copy link
Member

Choose a reason for hiding this comment

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

IIRC, we already have logic somewhere that prevents the need to dial bootstrappers if we have highly rated "close" peers in the peer store.. if it's elsewhere other than the auto-dialer, then this can all probably go away.

Question: does the auto-dialer tag/modify peers in the peer store that could change behavior for other services/components? It doesn't look like it does, but I could be missing something.

Copy link
Member

Choose a reason for hiding this comment

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

i think the peer-discovery-bootstrap component does this..?

Copy link
Member Author

Choose a reason for hiding this comment

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

does the auto-dialer tag/modify peers in the peer store

No, it only reads peers from the peer store.

IIRC, we already have logic somewhere that prevents the need to dial bootstrappers if we have highly rated "close" peers in the peer store

The notion of "close" is down to the protocol that defines it.

For example KAD-DHT already populates it's routing tables with peer store peers on startup, but it doesn't need to actively dial those peers, only during an actual query.

In the case where those peers have gone away between restarts, the KAD paper defines how to ping old peers to make sure they're still contactable during routing table maintenance.

packages/libp2p/test/connection-manager/index.spec.ts Outdated Show resolved Hide resolved
packages/libp2p/src/connection-manager/index.ts Outdated Show resolved Hide resolved
@achingbrain achingbrain merged commit 5b046c0 into release-v2.0 Aug 15, 2024
24 checks passed
@achingbrain achingbrain deleted the feat/remove-autodialler branch August 15, 2024 08:24
achingbrain added a commit that referenced this pull request Sep 6, 2024
The autodialer is a feature from an older time when the DHT was less reliable and we didn't have things like the random walk component.

There's not a lot of benefit in opening connections to any old peer, instead protocols now have better ways of targetting the kind of peers they require.

Actively dialing peers harms platforms where connections are extremely expensive such as react-native so this feature has been removed.

Closes #2621
Fixes #2418

BREAKING CHANGE: the autodialer has been removed as well as the corresponding config keys

---------

Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
achingbrain added a commit that referenced this pull request Sep 6, 2024
The autodialer is a feature from an older time when the DHT was less reliable and we didn't have things like the random walk component.

There's not a lot of benefit in opening connections to any old peer, instead protocols now have better ways of targetting the kind of peers they require.

Actively dialing peers harms platforms where connections are extremely expensive such as react-native so this feature has been removed.

Closes #2621
Fixes #2418

BREAKING CHANGE: the autodialer has been removed as well as the corresponding config keys

---------

Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
achingbrain added a commit that referenced this pull request Sep 6, 2024
The autodialer is a feature from an older time when the DHT was less reliable and we didn't have things like the random walk component.

There's not a lot of benefit in opening connections to any old peer, instead protocols now have better ways of targetting the kind of peers they require.

Actively dialing peers harms platforms where connections are extremely expensive such as react-native so this feature has been removed.

Closes #2621
Fixes #2418

BREAKING CHANGE: the autodialer has been removed as well as the corresponding config keys

---------

Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
@achingbrain achingbrain mentioned this pull request Sep 6, 2024
@ZababurinSergei
Copy link

After extending autoDial, the module stopped working for me js-libp2p-pubsub-peer-discovery

https://github.com/libp2p/js-libp2p-pubsub-peer-discovery

How can I make the search start working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version-2.0 PRs that will be released in libp2p v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the autodialer? AutoDial retries creeps up CPU usage over time
4 participants