Skip to content

Commit 91d392d

Browse files
authored
chore: update go-libp2p 0.46 (#11105)
* fix: update go-libp2p to v0.46.0 - reduced WebRTC log noise (go-libp2p#3426) - fixed mDNS discovery on Windows/macOS (go-libp2p#3434) - includes quic-go v0.57.1 (v0.56.0 + v0.57.0) * fix(example): kubo-as-a-library test timeout - use custom ports (4010/4011) to avoid conflicts with default 4001 - add 2-minute context timeout to fail fast - get peer addresses dynamically instead of hardcoding wrong port - wait for peer connection synchronously instead of fire-and-forget - update comments to reference autoconf.FallbackBootstrapPeers * chore: update p2p-forge to v0.7.0 * fix(test): wait for DHT readiness in GetClosestPeers test the test was failing for `routing_type=auto` because it only waited for swarm connections but not for the DHT routing table to be populated. added a separate probe loop that waits for GetClosestPeers to succeed before running the actual test assertions.
1 parent ab44726 commit 91d392d

File tree

9 files changed

+112
-431
lines changed

9 files changed

+112
-431
lines changed

docs/changelogs/v0.40.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ This release was brought to you by the [Shipyard](https://ipshipyard.com/) team.
1111
- [Overview](#overview)
1212
- [🔦 Highlights](#-highlights)
1313
- [Routing V1 HTTP API now exposed by default](#routing-v1-http-api-now-exposed-by-default)
14-
- [Track total size when adding pins](#track-total-size-when-adding-pins]
14+
- [Track total size when adding pins](#track-total-size-when-adding-pins)
15+
- [📦️ Dependency updates](#-dependency-updates)
1516
- [📝 Changelog](#-changelog)
1617
- [👨‍👩‍👧‍👦 Contributors](#-contributors)
1718

@@ -32,6 +33,14 @@ Example output:
3233
Fetched/Processed 336 nodes (83 MB)
3334
```
3435

36+
#### 📦️ Dependency updates
37+
38+
- update `go-libp2p` to [v0.46.0](https://github.com/libp2p/go-libp2p/releases/tag/v0.46.0)
39+
- Reduced WebRTC log noise by using debug level for pion errors ([go-libp2p#3426](https://github.com/libp2p/go-libp2p/pull/3426)).
40+
- Fixed mDNS discovery on Windows and macOS by filtering addresses to reduce packet size ([go-libp2p#3434](https://github.com/libp2p/go-libp2p/pull/3434)).
41+
- update `quic-go` to [v0.57.1](https://github.com/quic-go/quic-go/releases/tag/v0.57.1) (incl. [v0.56.0](https://github.com/quic-go/quic-go/releases/tag/v0.56.0) + [v0.57.0](https://github.com/quic-go/quic-go/releases/tag/v0.57.0))
42+
- update `p2p-forge` to [v0.7.0](https://github.com/ipshipyard/p2p-forge/releases/tag/v0.7.0)
43+
3544
### 📝 Changelog
3645

3746
### 👨‍👩‍👧‍👦 Contributors

docs/examples/kubo-as-a-library/go.mod

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ replace github.com/ipfs/kubo => ./../../..
99
require (
1010
github.com/ipfs/boxo v0.35.3-0.20251202220026-0842ad274a0c
1111
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
12-
github.com/libp2p/go-libp2p v0.45.0
12+
github.com/libp2p/go-libp2p v0.46.0
1313
github.com/multiformats/go-multiaddr v0.16.1
1414
)
1515

@@ -49,8 +49,7 @@ require (
4949
github.com/felixge/httpsnoop v1.0.4 // indirect
5050
github.com/filecoin-project/go-clock v0.1.0 // indirect
5151
github.com/flynn/noise v1.1.0 // indirect
52-
github.com/francoispqt/gojay v1.2.13 // indirect
53-
github.com/fsnotify/fsnotify v1.7.0 // indirect
52+
github.com/fsnotify/fsnotify v1.9.0 // indirect
5453
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
5554
github.com/gammazero/chanqueue v1.1.1 // indirect
5655
github.com/gammazero/deque v1.2.0 // indirect
@@ -101,7 +100,7 @@ require (
101100
github.com/ipld/go-car/v2 v2.16.0 // indirect
102101
github.com/ipld/go-codec-dagpb v1.7.0 // indirect
103102
github.com/ipld/go-ipld-prime v0.21.0 // indirect
104-
github.com/ipshipyard/p2p-forge v0.6.1 // indirect
103+
github.com/ipshipyard/p2p-forge v0.7.0 // indirect
105104
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
106105
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
107106
github.com/klauspost/compress v1.18.0 // indirect
@@ -176,8 +175,8 @@ require (
176175
github.com/prometheus/client_model v0.6.2 // indirect
177176
github.com/prometheus/common v0.66.1 // indirect
178177
github.com/prometheus/procfs v0.17.0 // indirect
179-
github.com/quic-go/qpack v0.5.1 // indirect
180-
github.com/quic-go/quic-go v0.55.0 // indirect
178+
github.com/quic-go/qpack v0.6.0 // indirect
179+
github.com/quic-go/quic-go v0.57.1 // indirect
181180
github.com/quic-go/webtransport-go v0.9.0 // indirect
182181
github.com/rogpeppe/go-internal v1.14.1 // indirect
183182
github.com/spaolacci/murmur3 v1.1.0 // indirect

docs/examples/kubo-as-a-library/go.sum

Lines changed: 10 additions & 114 deletions
Large diffs are not rendered by default.

docs/examples/kubo-as-a-library/main.go

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"path/filepath"
1111
"strings"
1212
"sync"
13+
"time"
1314

1415
"github.com/ipfs/boxo/files"
1516
"github.com/ipfs/boxo/path"
@@ -46,7 +47,7 @@ func setupPlugins(externalPluginsPath string) error {
4647
return nil
4748
}
4849

49-
func createTempRepo() (string, error) {
50+
func createTempRepo(swarmPort int) (string, error) {
5051
repoPath, err := os.MkdirTemp("", "ipfs-shell")
5152
if err != nil {
5253
return "", fmt.Errorf("failed to get temp dir: %s", err)
@@ -58,6 +59,15 @@ func createTempRepo() (string, error) {
5859
return "", err
5960
}
6061

62+
// Configure custom ports to avoid conflicts with other IPFS instances.
63+
// This demonstrates how to customize the node's network addresses.
64+
cfg.Addresses.Swarm = []string{
65+
fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", swarmPort),
66+
fmt.Sprintf("/ip4/0.0.0.0/udp/%d/quic-v1", swarmPort),
67+
fmt.Sprintf("/ip4/0.0.0.0/udp/%d/quic-v1/webtransport", swarmPort),
68+
fmt.Sprintf("/ip4/0.0.0.0/udp/%d/webrtc-direct", swarmPort),
69+
}
70+
6171
// When creating the repository, you can define custom settings on the repository, such as enabling experimental
6272
// features (See experimental-features.md) or customizing the gateway endpoint.
6373
// To do such things, you should modify the variable `cfg`. For example:
@@ -108,7 +118,8 @@ func createNode(ctx context.Context, repoPath string) (*core.IpfsNode, error) {
108118
var loadPluginsOnce sync.Once
109119

110120
// Spawns a node to be used just for this run (i.e. creates a tmp repo).
111-
func spawnEphemeral(ctx context.Context) (icore.CoreAPI, *core.IpfsNode, error) {
121+
// The swarmPort parameter specifies the port for libp2p swarm listeners.
122+
func spawnEphemeral(ctx context.Context, swarmPort int) (icore.CoreAPI, *core.IpfsNode, error) {
112123
var onceErr error
113124
loadPluginsOnce.Do(func() {
114125
onceErr = setupPlugins("")
@@ -118,7 +129,7 @@ func spawnEphemeral(ctx context.Context) (icore.CoreAPI, *core.IpfsNode, error)
118129
}
119130

120131
// Create a Temporary Repo
121-
repoPath, err := createTempRepo()
132+
repoPath, err := createTempRepo(swarmPort)
122133
if err != nil {
123134
return nil, nil, fmt.Errorf("failed to create temp repo: %s", err)
124135
}
@@ -192,11 +203,12 @@ func main() {
192203

193204
fmt.Println("-- Getting an IPFS node running -- ")
194205

195-
ctx, cancel := context.WithCancel(context.Background())
206+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
196207
defer cancel()
197208

198209
// Spawn a local peer using a temporary path, for testing purposes
199-
ipfsA, nodeA, err := spawnEphemeral(ctx)
210+
// Using port 4010 to avoid conflict with default IPFS port 4001
211+
ipfsA, nodeA, err := spawnEphemeral(ctx, 4010)
200212
if err != nil {
201213
panic(fmt.Errorf("failed to spawn peer node: %s", err))
202214
}
@@ -210,8 +222,9 @@ func main() {
210222
fmt.Printf("Added file to peer with CID %s\n", peerCidFile.String())
211223

212224
// Spawn a node using a temporary path, creating a temporary repo for the run
225+
// Using port 4011 (different from nodeA's port 4010)
213226
fmt.Println("Spawning Kubo node on a temporary repo")
214-
ipfsB, _, err := spawnEphemeral(ctx)
227+
ipfsB, _, err := spawnEphemeral(ctx, 4011)
215228
if err != nil {
216229
panic(fmt.Errorf("failed to spawn ephemeral node: %s", err))
217230
}
@@ -288,37 +301,34 @@ func main() {
288301

289302
fmt.Println("\n-- Going to connect to a few nodes in the Network as bootstrappers --")
290303

291-
peerMa := fmt.Sprintf("/ip4/127.0.0.1/udp/4010/p2p/%s", nodeA.Identity.String())
304+
// Get nodeA's address so we can fetch the file we added to it
305+
peerAddrs, err := ipfsA.Swarm().LocalAddrs(ctx)
306+
if err != nil {
307+
panic(fmt.Errorf("could not get peer addresses: %s", err))
308+
}
309+
peerMa := peerAddrs[0].String() + "/p2p/" + nodeA.Identity.String()
292310

293311
bootstrapNodes := []string{
294-
// IPFS Bootstrapper nodes.
312+
// In production, use autoconf.FallbackBootstrapPeers from boxo/autoconf
313+
// which includes well-known IPFS bootstrap peers like:
295314
// "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
296315
// "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
297-
// "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
298-
// "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
299-
300-
// IPFS Cluster Pinning nodes
301-
// "/ip4/138.201.67.219/tcp/4001/p2p/QmUd6zHcbkbcs7SMxwLs48qZVX3vpcM8errYS7xEczwRMA",
302-
// "/ip4/138.201.67.219/udp/4001/quic/p2p/QmUd6zHcbkbcs7SMxwLs48qZVX3vpcM8errYS7xEczwRMA",
303-
// "/ip4/138.201.67.220/tcp/4001/p2p/QmNSYxZAiJHeLdkBg38roksAR9So7Y5eojks1yjEcUtZ7i",
304-
// "/ip4/138.201.67.220/udp/4001/quic/p2p/QmNSYxZAiJHeLdkBg38roksAR9So7Y5eojks1yjEcUtZ7i",
305-
// "/ip4/138.201.68.74/tcp/4001/p2p/QmdnXwLrC8p1ueiq2Qya8joNvk3TVVDAut7PrikmZwubtR",
306-
// "/ip4/138.201.68.74/udp/4001/quic/p2p/QmdnXwLrC8p1ueiq2Qya8joNvk3TVVDAut7PrikmZwubtR",
307-
// "/ip4/94.130.135.167/tcp/4001/p2p/QmUEMvxS2e7iDrereVYc5SWPauXPyNwxcy9BXZrC1QTcHE",
308-
// "/ip4/94.130.135.167/udp/4001/quic/p2p/QmUEMvxS2e7iDrereVYc5SWPauXPyNwxcy9BXZrC1QTcHE",
309-
310-
// You can add more nodes here, for example, another IPFS node you might have running locally, mine was:
311-
// "/ip4/127.0.0.1/tcp/4010/p2p/QmZp2fhDLxjYue2RiUvLwT9MWdnbDxam32qYFnGmxZDh5L",
312-
// "/ip4/127.0.0.1/udp/4010/quic/p2p/QmZp2fhDLxjYue2RiUvLwT9MWdnbDxam32qYFnGmxZDh5L",
316+
// "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
317+
318+
// You can add custom peers here. For example, another IPFS node:
319+
// "/ip4/192.0.2.1/tcp/4001/p2p/QmYourPeerID...",
320+
// "/ip4/192.0.2.1/udp/4001/quic-v1/p2p/QmYourPeerID...",
321+
322+
// nodeA's address (the peer we created above that has our test file)
313323
peerMa,
314324
}
315325

316-
go func() {
317-
err := connectToPeers(ctx, ipfsB, bootstrapNodes)
318-
if err != nil {
319-
log.Printf("failed connect to peers: %s", err)
320-
}
321-
}()
326+
fmt.Println("Connecting to peers...")
327+
err = connectToPeers(ctx, ipfsB, bootstrapNodes)
328+
if err != nil {
329+
panic(fmt.Errorf("failed to connect to peers: %s", err))
330+
}
331+
fmt.Println("Connected to peers")
322332

323333
exampleCIDStr := peerCidFile.RootCid().String()
324334

go.mod

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/elgris/jsondiff v0.0.0-20160530203242-765b5c24c302
1818
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5
1919
github.com/filecoin-project/go-clock v0.1.0
20-
github.com/fsnotify/fsnotify v1.7.0
20+
github.com/fsnotify/fsnotify v1.9.0
2121
github.com/google/uuid v1.6.0
2222
github.com/hashicorp/go-version v1.7.0
2323
github.com/ipfs-shipyard/nopfs v0.0.14
@@ -47,11 +47,11 @@ require (
4747
github.com/ipld/go-car/v2 v2.16.0
4848
github.com/ipld/go-codec-dagpb v1.7.0
4949
github.com/ipld/go-ipld-prime v0.21.0
50-
github.com/ipshipyard/p2p-forge v0.6.1
50+
github.com/ipshipyard/p2p-forge v0.7.0
5151
github.com/jbenet/go-temp-err-catcher v0.1.0
5252
github.com/julienschmidt/httprouter v1.3.0
5353
github.com/libp2p/go-doh-resolver v0.5.0
54-
github.com/libp2p/go-libp2p v0.45.0
54+
github.com/libp2p/go-libp2p v0.46.0
5555
github.com/libp2p/go-libp2p-http v0.5.0
5656
github.com/libp2p/go-libp2p-kad-dht v0.36.0
5757
github.com/libp2p/go-libp2p-kbucket v0.8.0
@@ -127,7 +127,6 @@ require (
127127
github.com/fatih/color v1.15.0 // indirect
128128
github.com/felixge/httpsnoop v1.0.4 // indirect
129129
github.com/flynn/noise v1.1.0 // indirect
130-
github.com/francoispqt/gojay v1.2.13 // indirect
131130
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
132131
github.com/gammazero/chanqueue v1.1.1 // indirect
133132
github.com/gammazero/deque v1.2.0 // indirect
@@ -220,8 +219,8 @@ require (
220219
github.com/prometheus/common v0.66.1 // indirect
221220
github.com/prometheus/procfs v0.17.0 // indirect
222221
github.com/prometheus/statsd_exporter v0.27.1 // indirect
223-
github.com/quic-go/qpack v0.5.1 // indirect
224-
github.com/quic-go/quic-go v0.55.0 // indirect
222+
github.com/quic-go/qpack v0.6.0 // indirect
223+
github.com/quic-go/quic-go v0.57.1 // indirect
225224
github.com/quic-go/webtransport-go v0.9.0 // indirect
226225
github.com/rivo/uniseg v0.4.4 // indirect
227226
github.com/rogpeppe/go-internal v1.14.1 // indirect

0 commit comments

Comments
 (0)