chore: upgrade libp2p and related packages (#2084)

* chore: upgrade libp2p and related packages

* fix: public key on peer id can now be undefined

* chore: upgrade remainder packages

* chore: fix tests

* chore: address comments

* chore: upgrade playwright and proto
This commit is contained in:
Danish Arora 2024-08-14 04:23:04 +05:30 committed by GitHub
parent 5ce36c8f18
commit 409642d7d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 8509 additions and 6039 deletions

View File

@ -20,7 +20,7 @@ jobs:
timeout-minutes: 60 timeout-minutes: 60
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: mcr.microsoft.com/playwright:v1.43.0-jammy image: mcr.microsoft.com/playwright:v1.46.0-jammy
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3

14460
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -68,7 +68,7 @@
"node": ">=18" "node": ">=18"
}, },
"dependencies": { "dependencies": {
"@libp2p/ping": "^1.0.12", "@libp2p/ping": "^1.1.2",
"@waku/enr": "^0.0.24", "@waku/enr": "^0.0.24",
"@waku/interfaces": "0.0.25", "@waku/interfaces": "0.0.25",
"@waku/proto": "0.0.7", "@waku/proto": "0.0.7",
@ -103,7 +103,7 @@
}, },
"peerDependencies": { "peerDependencies": {
"@multiformats/multiaddr": "^12.0.0", "@multiformats/multiaddr": "^12.0.0",
"libp2p": "^1.1.2", "libp2p": "^1.8.1",
"@waku/enr": "^0.0.24", "@waku/enr": "^0.0.24",
"@waku/interfaces": "0.0.25", "@waku/interfaces": "0.0.25",
"@waku/proto": "0.0.7", "@waku/proto": "0.0.7",

View File

@ -62,9 +62,9 @@
"uint8arrays": "^5.0.1" "uint8arrays": "^5.0.1"
}, },
"devDependencies": { "devDependencies": {
"@libp2p/peer-id": "^4.0.4", "@libp2p/peer-id": "^4.2.1",
"@libp2p/peer-id-factory": "^4.0.5", "@libp2p/peer-id-factory": "^4.2.1",
"@multiformats/multiaddr": "^12.0.0", "@multiformats/multiaddr": "^12.3.0",
"@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-node-resolve": "^15.2.3",
@ -86,7 +86,7 @@
"@waku/interfaces": "0.0.25", "@waku/interfaces": "0.0.25",
"@waku/proto": "0.0.7", "@waku/proto": "0.0.7",
"@waku/utils": "0.0.18", "@waku/utils": "0.0.18",
"@libp2p/interface": "^1.1.2" "@libp2p/interface": "^1.6.3"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"@waku/interfaces": { "@waku/interfaces": {

View File

@ -52,8 +52,8 @@
}, },
"dependencies": { "dependencies": {
"@ethersproject/rlp": "^5.7.0", "@ethersproject/rlp": "^5.7.0",
"@libp2p/crypto": "^4.0.0", "@libp2p/crypto": "^4.1.6",
"@libp2p/peer-id": "^4.0.4", "@libp2p/peer-id": "^4.2.1",
"@multiformats/multiaddr": "^12.0.0", "@multiformats/multiaddr": "^12.0.0",
"@noble/secp256k1": "^1.7.1", "@noble/secp256k1": "^1.7.1",
"@waku/utils": "0.0.18", "@waku/utils": "0.0.18",
@ -61,7 +61,7 @@
"js-sha3": "^0.9.2" "js-sha3": "^0.9.2"
}, },
"devDependencies": { "devDependencies": {
"@libp2p/peer-id-factory": "^4.0.5", "@libp2p/peer-id-factory": "^4.2.1",
"@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-node-resolve": "^15.2.3",

View File

@ -15,6 +15,10 @@ export function getPublicKeyFromPeerId(peerId: PeerId): Uint8Array {
throw new Error("Unsupported peer id type"); throw new Error("Unsupported peer id type");
} }
if (!peerId.publicKey) {
throw new Error("Public key not present on peer id");
}
return unmarshalPublicKey(peerId.publicKey).marshal(); return unmarshalPublicKey(peerId.publicKey).marshal();
} }

View File

@ -47,11 +47,11 @@
"node": ">=18" "node": ">=18"
}, },
"devDependencies": { "devDependencies": {
"@chainsafe/libp2p-gossipsub": "^12.0.0", "@chainsafe/libp2p-gossipsub": "^13.1.0",
"@multiformats/multiaddr": "^12.0.0", "@multiformats/multiaddr": "^12.0.0",
"cspell": "^8.6.1", "cspell": "^8.6.1",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"libp2p": "^1.1.2" "libp2p": "^1.8.1"
}, },
"files": [ "files": [
"dist", "dist",

View File

@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */ /* eslint-disable @typescript-eslint/no-empty-interface */
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime' import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, MaxLengthError, message } from 'protons-runtime'
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc' import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
import type { Uint8ArrayList } from 'uint8arraylist' import type { Uint8ArrayList } from 'uint8arraylist'
@ -127,7 +127,7 @@ export namespace FilterRequest {
} }
case 3: { case 3: {
if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) { if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {
throw new CodeError('decode error - map field "contentFilters" had too many elements', 'ERR_MAX_LENGTH') throw new MaxLengthError('Decode error - map field "contentFilters" had too many elements')
} }
obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32(), { obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32(), {
@ -195,7 +195,7 @@ export namespace MessagePush {
switch (tag >>> 3) { switch (tag >>> 3) {
case 1: { case 1: {
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) { if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
throw new CodeError('decode error - map field "messages" had too many elements', 'ERR_MAX_LENGTH') throw new MaxLengthError('Decode error - map field "messages" had too many elements')
} }
obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), { obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), {

View File

@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */ /* eslint-disable @typescript-eslint/no-empty-interface */
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, enumeration, message } from 'protons-runtime' import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, enumeration, MaxLengthError, message } from 'protons-runtime'
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc' import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
import type { Uint8ArrayList } from 'uint8arraylist' import type { Uint8ArrayList } from 'uint8arraylist'
@ -97,7 +97,7 @@ export namespace FilterSubscribeRequest {
} }
case 11: { case 11: {
if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) { if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) {
throw new CodeError('decode error - map field "contentTopics" had too many elements', 'ERR_MAX_LENGTH') throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements')
} }
obj.contentTopics.push(reader.string()) obj.contentTopics.push(reader.string())

View File

@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */ /* eslint-disable @typescript-eslint/no-empty-interface */
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime' import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, MaxLengthError, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist' import type { Uint8ArrayList } from 'uint8arraylist'
export interface WakuMetadataRequest { export interface WakuMetadataRequest {
@ -54,7 +54,7 @@ export namespace WakuMetadataRequest {
} }
case 2: { case 2: {
if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) { if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {
throw new CodeError('decode error - map field "shards" had too many elements', 'ERR_MAX_LENGTH') throw new MaxLengthError('Decode error - map field "shards" had too many elements')
} }
obj.shards.push(reader.uint32()) obj.shards.push(reader.uint32())
@ -130,7 +130,7 @@ export namespace WakuMetadataResponse {
} }
case 2: { case 2: {
if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) { if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {
throw new CodeError('decode error - map field "shards" had too many elements', 'ERR_MAX_LENGTH') throw new MaxLengthError('Decode error - map field "shards" had too many elements')
} }
obj.shards.push(reader.uint32()) obj.shards.push(reader.uint32())

View File

@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */ /* eslint-disable @typescript-eslint/no-empty-interface */
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime' import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, MaxLengthError, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist' import type { Uint8ArrayList } from 'uint8arraylist'
export interface PeerInfo { export interface PeerInfo {
@ -160,7 +160,7 @@ export namespace PeerExchangeResponse {
switch (tag >>> 3) { switch (tag >>> 3) {
case 1: { case 1: {
if (opts.limits?.peerInfos != null && obj.peerInfos.length === opts.limits.peerInfos) { if (opts.limits?.peerInfos != null && obj.peerInfos.length === opts.limits.peerInfos) {
throw new CodeError('decode error - map field "peerInfos" had too many elements', 'ERR_MAX_LENGTH') throw new MaxLengthError('Decode error - map field "peerInfos" had too many elements')
} }
obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32(), { obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32(), {

View File

@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */ /* eslint-disable @typescript-eslint/no-empty-interface */
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime' import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, MaxLengthError, message } from 'protons-runtime'
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc' import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
import type { Uint8ArrayList } from 'uint8arraylist' import type { Uint8ArrayList } from 'uint8arraylist'
@ -197,7 +197,7 @@ export namespace StoreQueryRequest {
} }
case 11: { case 11: {
if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) { if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) {
throw new CodeError('decode error - map field "contentTopics" had too many elements', 'ERR_MAX_LENGTH') throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements')
} }
obj.contentTopics.push(reader.string()) obj.contentTopics.push(reader.string())
@ -213,7 +213,7 @@ export namespace StoreQueryRequest {
} }
case 20: { case 20: {
if (opts.limits?.messageHashes != null && obj.messageHashes.length === opts.limits.messageHashes) { if (opts.limits?.messageHashes != null && obj.messageHashes.length === opts.limits.messageHashes) {
throw new CodeError('decode error - map field "messageHashes" had too many elements', 'ERR_MAX_LENGTH') throw new MaxLengthError('Decode error - map field "messageHashes" had too many elements')
} }
obj.messageHashes.push(reader.bytes()) obj.messageHashes.push(reader.bytes())
@ -328,7 +328,7 @@ export namespace StoreQueryResponse {
} }
case 20: { case 20: {
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) { if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
throw new CodeError('decode error - map field "messages" had too many elements', 'ERR_MAX_LENGTH') throw new MaxLengthError('Decode error - map field "messages" had too many elements')
} }
obj.messages.push(WakuMessageKeyValue.codec().decode(reader, reader.uint32(), { obj.messages.push(WakuMessageKeyValue.codec().decode(reader, reader.uint32(), {

View File

@ -49,7 +49,7 @@
"node": ">=18" "node": ">=18"
}, },
"dependencies": { "dependencies": {
"@chainsafe/libp2p-gossipsub": "^12.0.0", "@chainsafe/libp2p-gossipsub": "^13.1.0",
"@noble/hashes": "^1.3.2", "@noble/hashes": "^1.3.2",
"@waku/core": "0.0.30", "@waku/core": "0.0.30",
"@waku/interfaces": "0.0.25", "@waku/interfaces": "0.0.25",

View File

@ -61,12 +61,12 @@
"node": ">=18" "node": ">=18"
}, },
"dependencies": { "dependencies": {
"@chainsafe/libp2p-noise": "^14.1.0", "@chainsafe/libp2p-noise": "^15.1.0",
"@libp2p/bootstrap": "^10.0.16", "@libp2p/bootstrap": "^10.1.2",
"@libp2p/identify": "^1.0.11", "@libp2p/identify": "^2.1.2",
"@libp2p/mplex": "^10.0.12", "@libp2p/mplex": "^10.1.2",
"@libp2p/ping": "^1.0.12", "@libp2p/ping": "^1.1.2",
"@libp2p/websockets": "^8.0.11", "@libp2p/websockets": "^8.1.4",
"@noble/hashes": "^1.3.3", "@noble/hashes": "^1.3.3",
"@waku/core": "0.0.30", "@waku/core": "0.0.30",
"@waku/discovery": "0.0.3", "@waku/discovery": "0.0.3",
@ -74,10 +74,10 @@
"@waku/proto": "^0.0.7", "@waku/proto": "^0.0.7",
"@waku/relay": "0.0.13", "@waku/relay": "0.0.13",
"@waku/utils": "0.0.18", "@waku/utils": "0.0.18",
"libp2p": "^1.1.2" "libp2p": "^1.8.1"
}, },
"devDependencies": { "devDependencies": {
"@chainsafe/libp2p-gossipsub": "^12.0.0", "@chainsafe/libp2p-gossipsub": "^13.1.0",
"@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-node-resolve": "^15.2.3",

View File

@ -50,8 +50,8 @@
"node": ">=18" "node": ">=18"
}, },
"dependencies": { "dependencies": {
"@libp2p/interface-compliance-tests": "^5.2.0", "@libp2p/interface-compliance-tests": "^5.4.9",
"@libp2p/peer-id": "^4.0.4", "@libp2p/peer-id": "^4.2.1",
"@waku/core": "*", "@waku/core": "*",
"@waku/enr": "*", "@waku/enr": "*",
"@waku/interfaces": "*", "@waku/interfaces": "*",
@ -68,7 +68,7 @@
"tail": "^2.2.6" "tail": "^2.2.6"
}, },
"devDependencies": { "devDependencies": {
"@libp2p/bootstrap": "^10.0.11", "@libp2p/bootstrap": "^10.1.2",
"@types/chai": "^4.3.11", "@types/chai": "^4.3.11",
"@types/dockerode": "^3.3.19", "@types/dockerode": "^3.3.19",
"@types/mocha": "^10.0.6", "@types/mocha": "^10.0.6",
@ -84,7 +84,7 @@
"datastore-core": "^9.2.7", "datastore-core": "^9.2.7",
"debug": "^4.3.4", "debug": "^4.3.4",
"interface-datastore": "^8.2.10", "interface-datastore": "^8.2.10",
"libp2p": "^1.1.2", "libp2p": "^1.8.1",
"mocha": "^10.3.0", "mocha": "^10.3.0",
"mocha-multi-reporters": "^1.5.1", "mocha-multi-reporters": "^1.5.1",
"npm-run-all": "^4.1.5" "npm-run-all": "^4.1.5"

View File

@ -194,6 +194,10 @@ export default class Dockerode {
if (err) { if (err) {
reject(err); reject(err);
} }
if (stream === undefined) {
reject(new Error("Stream is undefined"));
return;
}
this.docker.modem.followProgress(stream, (err, result) => { this.docker.modem.followProgress(stream, (err, result) => {
if (err) { if (err) {
reject(err); reject(err);

View File

@ -77,7 +77,7 @@ describe("Waku Relay, Subscribe", function () {
} catch (err) { } catch (err) {
if ( if (
!(err instanceof Error) || !(err instanceof Error) ||
!err.message.includes("PublishError.InsufficientPeers") !err.message.includes("PublishError.NoPeersSubscribedToTopic")
) { ) {
throw err; throw err;
} }