Skip to content

Commit 7fee9d5

Browse files
committed
fixed all merge conflicts for the v3 release
2 parents 04f0369 + 9587611 commit 7fee9d5

File tree

566 files changed

+29233
-14749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

566 files changed

+29233
-14749
lines changed

.github/dictionary.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ additionals
1414
SECG
1515
Certicom
1616
RSAES
17+
unuse
18+
dialback
19+
chacha
20+
peerStore
21+
xxhandshake
22+
zerolen
23+
connmanager
1724
reprovide
1825
reprovider
1926
reproviding

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Close Stale Issues
1+
name: Close and mark stale issue
22

33
on:
44
schedule:

doc/GETTING_STARTED.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,28 @@ If you want to know more about libp2p peer discovery, you should read the follow
250250

251251
## Debugging
252252

253-
When running libp2p you may want to see what things are happening behind the scenes. You can see trace logs by setting the `DEBUG` environment variable when running in Node.js, and by setting `debug` as a localStorage item when running in the browser. Some examples:
253+
When running libp2p you may want to see what things are happening behind the scenes. You can see trace logs by setting the `DEBUG` environment variable when running in Node.js, and by setting `debug` as a localStorage item when running in the browser.
254+
255+
You may wish to start with trace logging, then narrow down the scope to just the components you are interested in.
256+
257+
Wildcards in components names are supported (`*`), and components can be excluded by prefxing their name with `-`.
258+
259+
Some examples:
254260

255261
### Node
256262

257263
```JavaScript
258264
# all libp2p debug logs
259265
DEBUG="libp2p:*" node my-script.js
260266

261-
# networking debug logs
262-
DEBUG="libp2p:tcp,libp2p:websockets,libp2p:webtransport,libp2p:kad-dht,libp2p:dialer" node my-script.js
267+
# all libp2p debug logs, maximum detail
268+
DEBUG="libp2p:*,*:trace" node my-script.js
269+
270+
# all libp2p debug logs including trace logs, exclude yamux
271+
DEBUG="libp2p:*,*:trace,-libp2p:yamux:*" node my-script.js
272+
273+
# networking debug logs (here TCP and WebSocket transports are configured)
274+
DEBUG="libp2p:tcp:*,libp2p:websockets:*,libp2p:kad-dht,libp2p:connection-manager:*" node my-script.js
263275
```
264276

265277
### Browser
@@ -269,9 +281,46 @@ DEBUG="libp2p:tcp,libp2p:websockets,libp2p:webtransport,libp2p:kad-dht,libp2p:di
269281
localStorage.setItem('debug', 'libp2p:*') // then refresh the page to ensure the libraries can read this when spinning up.
270282

271283
// networking debug logs
272-
localStorage.setItem('debug', 'libp2p:websockets,libp2p:webtransport,libp2p:kad-dht,libp2p:dialer')
284+
localStorage.setItem('debug', 'libp2p:websockets*,libp2p:webtransport*,libp2p:kad-dht*,libp2p:connection-manager*')
273285
```
274286

287+
### Prefix logger
288+
289+
If you are running multiple nodes in the same process (for example during a test run), separating their log output can be difficult.
290+
291+
In this situation you can use the `prefixLogger` from the `@libp2p/logger` module:
292+
293+
```ts
294+
import { prefixLogger } from '@libp2p/logger'
295+
import { createLibp2p } from 'libp2p'
296+
297+
const dialer = await createLibp2p({
298+
logger: prefixLogger('dialer')
299+
// ... other options
300+
})
301+
302+
const listener = await createLibp2p({
303+
logger: prefixLogger('listener')
304+
// ... other options
305+
})
306+
```
307+
308+
All logs will be prefixed by the string passed to the prefix logger, so later you can do:
309+
310+
```console
311+
DEBUG=dialer:*,listener:* node ./index.js
312+
listener:libp2p:transports adding transport @libp2p/tcp +0ms
313+
dialer:libp2p libp2p is starting +0ms
314+
listener:libp2p libp2p is starting +0ms
315+
dialer:libp2p:connection-manager started +0ms
316+
listener:libp2p:connection-manager started +0ms
317+
listener:libp2p:transports creating listener for @libp2p/tcp on /ip4/127.0.0.1/tcp/0 +6ms
318+
dialer:libp2p libp2p has started +7ms
319+
listener:libp2p libp2p has started +7ms
320+
```
321+
322+
...and apply component log filters via the `DEBUG` env var as normal, e.g. `DEBUG=listener:libp2p:tcp:*` to just see TCP transport logs for the listener node, etc.
323+
275324
## React Native
276325

277326
Libp2p can be used in React Native applications. However, there are some limitations and considerations to take into account as not all transports are supported and some of the underlying dependencies may not work as expected. There is on-going work to address these issues, particularly around the support of TCP. For a demo on how to use libp2p in a React Native application, see https://github.com/ipfs-shipyard/js-libp2p-react-native

doc/migrations/v0.43-v0.44.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ import { createLibp2p } from 'libp2p'
9292
const node = await createLibp2p({
9393
connectionGater: {
9494
denyDialMultiaddr: (multiaddr) => {
95-
if (multiaddr.getPeerId() != null) {
95+
if (multiaddr.findLast(c => c.code === CODE_P2P)?.value != null) {
9696
// there is a peer id present in the multiaddr
9797
}
9898

doc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"doc-check": "aegir doc-check"
1818
},
1919
"devDependencies": {
20-
"aegir": "^47.0.14"
20+
"aegir": "^47.0.21"
2121
},
2222
"private": true
2323
}

interop/node-version.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"onlyDial": true
1010
},
1111
"webrtc",
12-
"webrtc-direct",
13-
"quic-v1"
12+
"webrtc-direct"
1413
],
1514
"secureChannels": ["noise", "tls"],
1615
"muxers": ["yamux", "mplex"]

interop/package.json

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@
1111
"dep-check": "aegir dep-check"
1212
},
1313
"devDependencies": {
14-
"@chainsafe/libp2p-noise": "^16.1.3",
15-
"@chainsafe/libp2p-quic": "^1.1.1",
16-
"@chainsafe/libp2p-yamux": "^7.0.1",
17-
"@libp2p/circuit-relay-v2": "^3.2.14",
18-
"@libp2p/identify": "^3.0.32",
19-
"@libp2p/interface": "^2.10.2",
20-
"@libp2p/mplex": "^11.0.38",
21-
"@libp2p/ping": "^2.0.32",
22-
"@libp2p/tcp": "^10.1.13",
23-
"@libp2p/tls": "^2.2.3",
24-
"@libp2p/webrtc": "^5.2.15",
25-
"@libp2p/websockets": "^9.2.13",
26-
"@libp2p/webtransport": "^5.0.43",
27-
"@multiformats/multiaddr": "^12.4.4",
28-
"aegir": "^47.0.14",
29-
"libp2p": "^2.8.8",
14+
"@libp2p/noise": "^16.1.3",
15+
"@libp2p/yamux": "^7.0.1",
16+
"@libp2p/circuit-relay-v2": "^3.2.24",
17+
"@libp2p/identify": "^3.0.39",
18+
"@libp2p/interface": "^2.11.0",
19+
"@libp2p/mplex": "^11.0.47",
20+
"@libp2p/ping": "^2.0.37",
21+
"@libp2p/tcp": "^10.1.19",
22+
"@libp2p/tls": "^2.2.7",
23+
"@libp2p/webrtc": "^5.2.24",
24+
"@libp2p/websockets": "^9.2.19",
25+
"@libp2p/webtransport": "^5.0.51",
26+
"@multiformats/multiaddr": "^13.0.1",
27+
"aegir": "^47.0.21",
28+
"libp2p": "^2.10.0",
3029
"p-event": "^6.0.1",
3130
"redis": "^4.7.1"
3231
}

interop/test/dialer.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { multiaddr } from '@multiformats/multiaddr'
55
import { getLibp2p } from './fixtures/get-libp2p.js'
66
import { redisProxy } from './fixtures/redis-proxy.js'
77
import type { Libp2p } from '@libp2p/interface'
8-
import type { PingService } from '@libp2p/ping'
8+
import type { Ping } from '@libp2p/ping'
99

1010
const isDialer: boolean = process.env.is_dialer === 'true'
1111
const timeoutMs: number = parseInt(process.env.test_timeout_secs ?? '180') * 1000
@@ -17,7 +17,7 @@ describe('ping test (dialer)', function () {
1717

1818
// make the default timeout longer than the listener timeout
1919
this.timeout(timeoutMs + 30_000)
20-
let node: Libp2p<{ ping: PingService }>
20+
let node: Libp2p<{ ping: Ping }>
2121

2222
beforeEach(async () => {
2323
node = await getLibp2p()

interop/test/fixtures/get-libp2p.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/* eslint-disable complexity */
22

3-
import { noise } from '@chainsafe/libp2p-noise'
4-
import { quic } from '@chainsafe/libp2p-quic'
5-
import { yamux } from '@chainsafe/libp2p-yamux'
3+
// import { quic } from '@chainsafe/libp2p-quic'
64
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
75
import { identify } from '@libp2p/identify'
86
import { mplex } from '@libp2p/mplex'
7+
import { noise } from '@libp2p/noise'
98
import { ping } from '@libp2p/ping'
109
import { tcp } from '@libp2p/tcp'
1110
import { tls } from '@libp2p/tls'
1211
import { webRTC, webRTCDirect } from '@libp2p/webrtc'
1312
import { webSockets } from '@libp2p/websockets'
1413
import { webTransport } from '@libp2p/webtransport'
14+
import { yamux } from '@libp2p/yamux'
1515
import { createLibp2p } from 'libp2p'
1616
import type { Identify } from '@libp2p/identify'
1717
import type { Libp2p } from '@libp2p/interface'
@@ -83,12 +83,13 @@ export async function getLibp2p (): Promise<Libp2p<{ ping: PingService }>> {
8383
listen: isDialer ? [] : [`/ip4/${IP}/tcp/0/wss`]
8484
}
8585
break
86-
case 'quic-v1':
87-
options.transports = [quic()]
88-
options.addresses = {
89-
listen: isDialer ? [] : [`/ip4/${IP}/udp/0/quic-v1`]
90-
}
91-
break
86+
// TODO: re-enable quic after v3 release
87+
// case 'quic-v1':
88+
// options.transports = [quic()]
89+
// options.addresses = {
90+
// listen: isDialer ? [] : [`/ip4/${IP}/udp/0/quic-v1`]
91+
// }
92+
// break
9293
default:
9394
throw new Error(`Unknown transport: ${TRANSPORT ?? '???'}`)
9495
}
@@ -98,7 +99,8 @@ export async function getLibp2p (): Promise<Libp2p<{ ping: PingService }>> {
9899
switch (TRANSPORT) {
99100
case 'webtransport':
100101
case 'webrtc-direct':
101-
case 'quic-v1':
102+
// TODO: re-enable quic after v3 release
103+
// case 'quic-v1':
102104
skipSecureChannel = true
103105
skipMuxer = true
104106
break
@@ -122,7 +124,7 @@ export async function getLibp2p (): Promise<Libp2p<{ ping: PingService }>> {
122124
options.connectionEncrypters = [tls()]
123125
break
124126
default:
125-
throw new Error(`Unknown secure channel: ${SECURE_CHANNEL ?? ''}`)
127+
throw new Error(`Unknown secure channel: ${SECURE_CHANNEL ?? ''} for transport ${TRANSPORT ?? ''}`)
126128
}
127129
}
128130

interop/test/fixtures/relay.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { noise } from '@chainsafe/libp2p-noise'
2-
import { yamux } from '@chainsafe/libp2p-yamux'
31
import { circuitRelayServer } from '@libp2p/circuit-relay-v2'
42
import { identify } from '@libp2p/identify'
3+
import { noise } from '@libp2p/noise'
54
import { webSockets } from '@libp2p/websockets'
5+
import { yamux } from '@libp2p/yamux'
66
import { createLibp2p } from 'libp2p'
77
import type { Libp2p } from '@libp2p/interface'
88

0 commit comments

Comments
 (0)