Skip to content

Commit ee07e25

Browse files
committed
feat!: remove autodialer
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
1 parent 944935f commit ee07e25

27 files changed

+113
-895
lines changed

doc/CONFIGURATION.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,7 @@ const node = await createLibp2p({
626626
noise()
627627
],
628628
connectionManager: {
629-
maxConnections: Infinity,
630-
minConnections: 0
629+
maxConnections: Infinity
631630
}
632631
})
633632
```

doc/LIMITS.md

-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ const node = await createLibp2p({
3838
*/
3939
maxConnections: 100,
4040

41-
/**
42-
* If the number of open connections goes below this number, the node
43-
* will try to connect to randomly selected peers from the peer store
44-
*/
45-
minConnections: 50,
46-
4741
/**
4842
* How many connections can be open but not yet upgraded
4943
*/

interop/test/fixtures/get-libp2p.ts

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ const IP = process.env.ip ?? '0.0.0.0'
2525
export async function getLibp2p (): Promise<Libp2p<{ ping: PingService }>> {
2626
const options: Libp2pOptions<{ ping: PingService, identify: Identify }> = {
2727
start: true,
28-
connectionManager: {
29-
minConnections: 0
30-
},
3128
connectionGater: {
3229
denyDialMultiaddr: async () => false
3330
},

packages/integration-tests/.aegir.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ export default {
2424
const peerId = await createEd25519PeerId()
2525
const libp2p = await createLibp2p({
2626
connectionManager: {
27-
inboundConnectionThreshold: Infinity,
28-
minConnections: 0
27+
inboundConnectionThreshold: Infinity
2928
},
3029
addresses: {
3130
listen: [

packages/integration-tests/test/bootstrap.spec.ts

+51
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
import { bootstrap } from '@libp2p/bootstrap'
44
import { TypedEventEmitter, peerDiscoverySymbol } from '@libp2p/interface'
5+
import { mplex } from '@libp2p/mplex'
56
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
7+
import { plaintext } from '@libp2p/plaintext'
68
import { webSockets } from '@libp2p/websockets'
9+
import * as Filter from '@libp2p/websockets/filters'
710
import { multiaddr } from '@multiformats/multiaddr'
811
import { expect } from 'aegir/chai'
912
import { createLibp2p } from 'libp2p'
@@ -103,4 +106,52 @@ describe('bootstrap', () => {
103106

104107
return deferred.promise
105108
})
109+
110+
it('bootstrap should dial all peers in the list', async () => {
111+
const deferred = defer()
112+
113+
const bootstrappers = [
114+
`${process.env.RELAY_MULTIADDR}`
115+
]
116+
117+
libp2p = await createLibp2p({
118+
connectionEncryption: [
119+
plaintext()
120+
],
121+
transports: [
122+
webSockets({
123+
filter: Filter.all
124+
})
125+
],
126+
streamMuxers: [
127+
mplex()
128+
],
129+
peerDiscovery: [
130+
bootstrap({
131+
list: bootstrappers
132+
})
133+
],
134+
connectionGater: {
135+
denyDialMultiaddr: () => false
136+
}
137+
})
138+
139+
const expectedPeers = new Set(
140+
bootstrappers.map(ma => multiaddr(ma).getPeerId())
141+
)
142+
143+
libp2p.addEventListener('connection:open', (evt) => {
144+
const { remotePeer } = evt.detail
145+
146+
expectedPeers.delete(remotePeer.toString())
147+
if (expectedPeers.size === 0) {
148+
libp2p.removeEventListener('connection:open')
149+
deferred.resolve()
150+
}
151+
})
152+
153+
await libp2p.start()
154+
155+
return deferred.promise
156+
})
106157
})

packages/integration-tests/test/circuit-relay.node.ts

-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ async function createClient (options: Libp2pOptions = {}): Promise<Libp2p> {
4242
connectionEncryption: [
4343
plaintext()
4444
],
45-
connectionManager: {
46-
minConnections: 0
47-
},
4845
services: {
4946
identify: identify()
5047
},

packages/integration-tests/test/fetch.spec.ts

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ async function createNode (): Promise<Libp2p<{ fetch: Fetch }>> {
1212
return createLibp2p(createBaseOptions({
1313
services: {
1414
fetch: fetch()
15-
},
16-
connectionManager: {
17-
minConnections: 0
1815
}
1916
}))
2017
}

packages/integration-tests/test/interop.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ async function createJsPeer (options: SpawnOptions): Promise<Daemon> {
134134
},
135135
transports: [tcp(), circuitRelayTransport()],
136136
streamMuxers: [],
137-
connectionEncryption: [noise()],
138-
connectionManager: {
139-
minConnections: 0
140-
}
137+
connectionEncryption: [noise()]
141138
}
142139

143140
if (options.noListen !== true) {

packages/libp2p/.aegir.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ export default {
2020
const peerId = await createEd25519PeerId()
2121
const libp2p = await createLibp2p({
2222
connectionManager: {
23-
inboundConnectionThreshold: Infinity,
24-
minConnections: 0
23+
inboundConnectionThreshold: Infinity
2524
},
2625
addresses: {
2726
listen: [

0 commit comments

Comments
 (0)