Skip to content

fix: do not dial bootstrap nodes #3087

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions packages/integration-tests/test/bootstrap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import { bootstrap } from '@libp2p/bootstrap'
import { generateKeyPair } from '@libp2p/crypto/keys'
import { TypedEventEmitter, peerDiscoverySymbol } from '@libp2p/interface'
import { mplex } from '@libp2p/mplex'
import { peerIdFromPrivateKey } from '@libp2p/peer-id'
import { plaintext } from '@libp2p/plaintext'
import { webSockets } from '@libp2p/websockets'
import { multiaddr } from '@multiformats/multiaddr'
import { expect } from 'aegir/chai'
Expand Down Expand Up @@ -104,50 +102,4 @@ describe('bootstrap', () => {

return deferred.promise
})

it('bootstrap should dial all peers in the list', async () => {
const deferred = defer()

const list = [
`${process.env.RELAY_MULTIADDR}`
]

libp2p = await createLibp2p({
connectionEncrypters: [
plaintext()
],
transports: [
webSockets()
],
streamMuxers: [
mplex()
],
peerDiscovery: [
bootstrap({
list
})
],
connectionGater: {
denyDialMultiaddr: () => false
}
})

const expectedPeers = new Set(
list.map(ma => multiaddr(ma).getPeerId())
)

libp2p.addEventListener('connection:open', (evt) => {
const { remotePeer } = evt.detail

expectedPeers.delete(remotePeer.toString())
if (expectedPeers.size === 0) {
libp2p.removeEventListener('connection:open')
deferred.resolve()
}
})

await libp2p.start()

return deferred.promise
})
})
2 changes: 1 addition & 1 deletion packages/peer-discovery-bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
},
"dependencies": {
"@libp2p/interface": "^2.9.0",
"@libp2p/interface-internal": "^2.3.11",
"@libp2p/peer-id": "^5.1.2",
"@multiformats/mafmt": "^12.1.6",
"@multiformats/multiaddr": "^12.3.3"
},
"devDependencies": {
"@libp2p/interface-compliance-tests": "^6.4.5",
"@libp2p/interface-internal": "^2.3.11",
"@libp2p/logger": "^5.1.15",
"aegir": "^45.1.1",
"sinon-ts": "^2.0.0"
Expand Down
6 changes: 0 additions & 6 deletions packages/peer-discovery-bootstrap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { peerIdFromString } from '@libp2p/peer-id'
import { P2P } from '@multiformats/mafmt'
import { multiaddr } from '@multiformats/multiaddr'
import type { ComponentLogger, Logger, PeerDiscovery, PeerDiscoveryEvents, PeerInfo, PeerStore, Startable } from '@libp2p/interface'
import type { ConnectionManager } from '@libp2p/interface-internal'

const DEFAULT_BOOTSTRAP_TAG_NAME = 'bootstrap'
const DEFAULT_BOOTSTRAP_TAG_VALUE = 50
Expand Down Expand Up @@ -77,7 +76,6 @@ export interface BootstrapInit {
export interface BootstrapComponents {
peerStore: PeerStore
logger: ComponentLogger
connectionManager: ConnectionManager
}

/**
Expand Down Expand Up @@ -183,10 +181,6 @@ class Bootstrap extends TypedEventEmitter<PeerDiscoveryEvents> implements PeerDi
}

this.safeDispatchEvent('peer', { detail: peerData })
this.components.connectionManager.openConnection(peerData.id)
.catch(err => {
this.log.error('could not dial bootstrap peer %p', peerData.id, err)
})
}
}

Expand Down
21 changes: 0 additions & 21 deletions packages/peer-discovery-bootstrap/test/bootstrap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,6 @@ describe('bootstrap', () => {
await stop(r)
})

it('should dial bootstrap peers', async function () {
this.timeout(5 * 1000)
const r = bootstrap({
list: peerList,
timeout: 100
})(components)

await start(r)

await new Promise<void>(resolve => {
const interval = setInterval(() => {
if (components.connectionManager.openConnection.callCount === 1) {
clearInterval(interval)
resolve()
}
}, 100)
})

await stop(r)
})

it('should tag bootstrap peers', async function () {
this.timeout(5 * 1000)

Expand Down
Loading