Skip to content

Commit

Permalink
[WIP] refactor: update libp2p-yamux and fix breaking changes
Browse files Browse the repository at this point in the history
NOTE: The following issues must be addressed before this is merged:

libp2p/interface is currently held at version 0.1.2:

 - Passing a logger to MuxerInit is now required (should be optional?): libp2p/js-libp2p#2275

@chainsafe/libp2p-yamux is currently held at version 5.0.4:

 - Passing a logger to yamux()({logger:...}) is now required (should be optional?): ChainSafe/js-libp2p-yamux#69
 - The integration test for rpcstream fails with 6.x vs. 5.x: ChainSafe/js-libp2p-yamux#71 and https://github.com/aperturerobotics/starpc/actions/runs/7055030516/job/19204891175

See: #120

---

Update dependencies and fix various breaking changes introduced by those
dependency updates:

- Change type of Conn to Duplex<Uint8Array | Uint8ArrayList>
- Pass a logger stub to yamux as it's now required.

The logger stub should not be necessary once these are fixed:

- ChainSafe/js-libp2p-yamux#69
- libp2p/js-libp2p#2275
- ChainSafe/js-libp2p-yamux#70

Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed Dec 1, 2023
1 parent 1bb5b5e commit 9e30f9d
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
"utf-8-validate": "^6.0.3"
},
"dependencies": {
"@chainsafe/libp2p-yamux": "^5.0.0",
"@libp2p/interface": "^0.1.2",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/interface": "^1.0.1",
"event-iterator": "^2.0.0",
"is-promise": "^4.0.0",
"isomorphic-ws": "^5.0.0",
Expand Down
8 changes: 7 additions & 1 deletion srpc/conn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
prependLengthPrefixTransform,
} from './packet.js'
import { buildPushableSink } from './pushable.js'
import { createDisabledComponentLogger } from './log.js'

// ConnParams are parameters that can be passed to the Conn constructor.
export interface ConnParams {
Expand Down Expand Up @@ -73,7 +74,12 @@ export class Conn
if (server) {
this.server = server
}
const muxerFactory = connParams?.muxerFactory ?? yamux()()
const muxerFactory =
connParams?.muxerFactory ??
yamux()({
// https://github.com/ChainSafe/js-libp2p-yamux/issues/69
logger: createDisabledComponentLogger(),
})
this.muxer = muxerFactory.createStreamMuxer({
onIncomingStream: this.handleIncomingStream.bind(this),
direction: connParams?.direction || 'outbound',
Expand Down
98 changes: 93 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"

"@chainsafe/is-ip@^2.0.1":
"@chainsafe/is-ip@^2.0.1", "@chainsafe/is-ip@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@chainsafe/is-ip/-/is-ip-2.0.2.tgz#7311e7403f11d8c5cfa48111f56fcecaac37c9f6"
integrity sha512-ndGqEMG1W5WkGagaqOZHpPU172AGdxr+LD15sv3WIUvT5oCFUrG1Y0CW/v2Egwj4JXEvSibaIIIqImsm98y1nA==
Expand All @@ -138,6 +138,19 @@
it-pushable "^3.2.0"
uint8arraylist "^2.4.3"

"@chainsafe/libp2p-yamux@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/@chainsafe/libp2p-yamux/-/libp2p-yamux-6.0.1.tgz#3be7dfe0f49d18d066978a93e9bc68f0a9b4d349"
integrity sha512-8ar6jph9ZuUUxQ8t8W1MaZqH7f7KvGK2wR7TDGnN0r4QtZc07ICNgVjnolnI9/8bclrI5Um4uMa8QCYKTrdvDQ==
dependencies:
"@libp2p/interface" "^1.0.0"
"@libp2p/utils" "^5.0.0"
get-iterator "^2.0.1"
it-foreach "^2.0.3"
it-pipe "^3.0.1"
it-pushable "^3.2.0"
uint8arraylist "^2.4.3"

"@chainsafe/netmask@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@chainsafe/netmask/-/netmask-2.0.0.tgz#0d4a75f47919f65011da4327a3845c9661f1038a"
Expand Down Expand Up @@ -364,7 +377,7 @@
race-signal "^1.0.0"
uint8arraylist "^2.4.3"

"@libp2p/interface@^1.0.0":
"@libp2p/interface@^1.0.0", "@libp2p/interface@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@libp2p/interface/-/interface-1.0.1.tgz#97d55b3920a938c245776728df5cd85ef1241b28"
integrity sha512-TRo1YxJ+AVjt5ms+mTOp8xcoCis5HAUMzv0XfCvxtIw77Bog6TPR5VdkGutlEQOKUMzXtLP0lW88fTQBeiiOnA==
Expand All @@ -386,7 +399,34 @@
interface-datastore "^8.2.0"
multiformats "^12.0.1"

"@multiformats/multiaddr@^12.1.10", "@multiformats/multiaddr@^12.1.5":
"@libp2p/utils@^5.0.0":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@libp2p/utils/-/utils-5.0.1.tgz#6348eb3e34199d75ed292defa0deb9d59c55f332"
integrity sha512-skgRzYthAaaYis8FleHSvp23UGV9xd8HNLNRKp5sbNCVyTO5IertayFExADs1ElQMco7xYzHV7MN75p/nO/hwQ==
dependencies:
"@chainsafe/is-ip" "^2.0.2"
"@libp2p/interface" "^1.0.1"
"@multiformats/multiaddr" "^12.1.10"
"@multiformats/multiaddr-matcher" "^1.1.0"
get-iterator "^2.0.1"
is-loopback-addr "^2.0.1"
it-pushable "^3.2.2"
it-stream-types "^2.0.1"
p-queue "^7.4.1"
private-ip "^3.0.1"
race-signal "^1.0.1"
uint8arraylist "^2.4.3"

"@multiformats/multiaddr-matcher@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@multiformats/multiaddr-matcher/-/multiaddr-matcher-1.1.0.tgz#27e14a549a00594c24d85897c4b0b7e83df3e59d"
integrity sha512-B/QbKpAxaHYVXFnbTdTgYqPDxmqoF2RYffwYoOv1MWfi2vBCZLdzmEKUBKv6fQr6s+LJFSHn2j2vczmwMFCQIA==
dependencies:
"@chainsafe/is-ip" "^2.0.1"
"@multiformats/multiaddr" "^12.0.0"
multiformats "^12.0.1"

"@multiformats/multiaddr@^12.0.0", "@multiformats/multiaddr@^12.1.10", "@multiformats/multiaddr@^12.1.5":
version "12.1.11"
resolved "https://registry.yarnpkg.com/@multiformats/multiaddr/-/multiaddr-12.1.11.tgz#53d857ef61aa56996792c28163a4c320111e7ccb"
integrity sha512-CWG9kETEGTTMdr1T+/JEuMwFld3r3fHNP8LkLoUcLvHRy6yr8sWdotVGEDNEdDO/vrKhuD7bQBws3xMSMMyylg==
Expand Down Expand Up @@ -1171,6 +1211,11 @@ event-iterator@^2.0.0:
resolved "https://registry.yarnpkg.com/event-iterator/-/event-iterator-2.0.0.tgz#10f06740cc1e9fd6bc575f334c2bc1ae9d2dbf62"
integrity sha512-KGft0ldl31BZVV//jj+IAIGCxkvvUkkON+ScH6zfoX+l+omX6001ggyRSpI0Io2Hlro0ThXotswCtfzS8UkIiQ==

eventemitter3@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4"
integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==

expand-tilde@^2.0.0, expand-tilde@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-2.0.2.tgz#97e801aa052df02454de46b02bf621642cdc8502"
Expand Down Expand Up @@ -1501,6 +1546,16 @@ interface-store@^5.0.0:
resolved "https://registry.yarnpkg.com/interface-store/-/interface-store-5.1.5.tgz#0c8c4001624d728789e43d01f977689705ac136f"
integrity sha512-X0KnJBk3o+YL13MxZBMwa88/b3Mdrpm0yPzkSTKDDVn9BSPH7UK6W+ZtIPO2bxKOQVmq7zqOwAnYnpfqWjb6/g==

ip-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-5.0.0.tgz#cd313b2ae9c80c07bd3851e12bf4fa4dc5480632"
integrity sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==

ipaddr.js@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.1.0.tgz#2119bc447ff8c257753b196fc5f1ce08a4cdf39f"
integrity sha512-LlbxQ7xKzfBusov6UMi4MFpEg0m+mAm9xyNGEduwXMEDuf4WfzB/RZwMVYEd7IKGvh4IUkEXYxtAVu9T3OelJQ==

is-arrayish@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
Expand Down Expand Up @@ -1535,6 +1590,11 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3:
dependencies:
is-extglob "^2.1.1"

is-loopback-addr@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/is-loopback-addr/-/is-loopback-addr-2.0.2.tgz#70a6668fa3555d47caebdcee045745ab80adf5e4"
integrity sha512-26POf2KRCno/KTNL5Q0b/9TYnL00xEsSaLfiFRmjM7m7Lw7ZMmFybzzuX4CcsLAluZGd+niLUiMRxEooVE3aqg==

is-number@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
Expand Down Expand Up @@ -1627,7 +1687,7 @@ it-pipe@^3.0.1:
it-pushable "^3.1.2"
it-stream-types "^2.0.1"

it-pushable@^3.1.2, it-pushable@^3.2.0, it-pushable@^3.2.1, it-pushable@^3.2.3:
it-pushable@^3.1.2, it-pushable@^3.2.0, it-pushable@^3.2.1, it-pushable@^3.2.2, it-pushable@^3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/it-pushable/-/it-pushable-3.2.3.tgz#e2b80aed90cfbcd54b620c0a0785e546d4e5f334"
integrity sha512-gzYnXYK8Y5t5b/BnJUr7glfQLO4U5vyb05gPx/TyTw+4Bv1zM9gFk4YsOrnulWefMewlphCjKkakFvj1y99Tcg==
Expand Down Expand Up @@ -1900,6 +1960,11 @@ natural-compare@^1.4.0:
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==

netmask@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7"
integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==

node-gyp-build@^4.3.0:
version "4.7.1"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.7.1.tgz#cd7d2eb48e594874053150a9418ac85af83ca8f7"
Expand Down Expand Up @@ -1961,6 +2026,19 @@ p-locate@^5.0.0:
dependencies:
p-limit "^3.0.2"

p-queue@^7.4.1:
version "7.4.1"
resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-7.4.1.tgz#7f86f853048beca8272abdbb7cec1ed2afc0f265"
integrity sha512-vRpMXmIkYF2/1hLBKisKeVYJZ8S2tZ0zEAmIJgdVKP2nq0nh4qCdf8bgw+ZgKrkh71AOCaqzwbJJk1WtdcF3VA==
dependencies:
eventemitter3 "^5.0.1"
p-timeout "^5.0.2"

p-timeout@^5.0.2:
version "5.1.0"
resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-5.1.0.tgz#b3c691cf4415138ce2d9cfe071dba11f0fee085b"
integrity sha512-auFDyzzzGZZZdHz3BtET9VEz0SE/uMEAx7uWfGPucfzEwwe/xH0iVeZibQmANYE/hp9T2+UUZT5m+BKyrDp3Ew==

parent-module@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
Expand Down Expand Up @@ -2073,6 +2151,16 @@ prettier@^3.0.3:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.0.tgz#c6d16474a5f764ea1a4a373c593b779697744d5e"
integrity sha512-TQLvXjq5IAibjh8EpBIkNKxO749UEWABoiIZehEPiY4GNpVdhaFKqSTu+QrlU6D2dPAfubRmtJTi4K4YkQ5eXw==

private-ip@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/private-ip/-/private-ip-3.0.1.tgz#1fa8108f53512c6b82f79d4d2ac665140dee5da5"
integrity sha512-Ezc16ANuhSHmWAE6lbXUKburNzGpR0J5X0Zh5Um/PZ/s57Fp+HYqYe6BYPH2QbqKr/5WebfzJQ1jq6Kj5dbRmA==
dependencies:
"@chainsafe/is-ip" "^2.0.1"
ip-regex "^5.0.0"
ipaddr.js "^2.1.0"
netmask "^2.0.2"

protobufjs@^7.2.4, protobufjs@^7.2.5:
version "7.2.5"
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.2.5.tgz#45d5c57387a6d29a17aab6846dcc283f9b8e7f2d"
Expand Down Expand Up @@ -2101,7 +2189,7 @@ queue-microtask@^1.2.2:
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==

race-signal@^1.0.0:
race-signal@^1.0.0, race-signal@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/race-signal/-/race-signal-1.0.2.tgz#e42379fba0cec4ee8dab7c9bbbd4aa6e0d14c25f"
integrity sha512-o3xNv0iTcIDQCXFlF6fPAMEBRjFxssgGoRqLbg06m+AdzEXXLUmoNOoUHTVz2NoBI8hHwKFKoC6IqyNtWr2bww==
Expand Down

0 comments on commit 9e30f9d

Please sign in to comment.