From 06c697b419c6987f2c495be98b855145facf1122 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Mon, 5 Feb 2024 16:39:26 +0100 Subject: [PATCH] Update the @chainsafe/libp2p-identify --- packages/beacon-node/package.json | 1 + .../beacon-node/src/network/libp2p/index.ts | 17 ++------ yarn.lock | 42 +++++++++++++++++++ 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/packages/beacon-node/package.json b/packages/beacon-node/package.json index 90f2026e1873..f24963622d93 100644 --- a/packages/beacon-node/package.json +++ b/packages/beacon-node/package.json @@ -102,6 +102,7 @@ "@chainsafe/enr": "^3.0.0", "@chainsafe/libp2p-gossipsub": "^11.2.0", "@chainsafe/libp2p-noise": "^14.1.0", + "@chainsafe/libp2p-identify": "^1.0.0", "@chainsafe/persistent-merkle-tree": "^0.6.1", "@chainsafe/prometheus-gc-stats": "^1.0.0", "@chainsafe/ssz": "^0.14.0", diff --git a/packages/beacon-node/src/network/libp2p/index.ts b/packages/beacon-node/src/network/libp2p/index.ts index 7ad631f09ce2..8a8cca38c167 100644 --- a/packages/beacon-node/src/network/libp2p/index.ts +++ b/packages/beacon-node/src/network/libp2p/index.ts @@ -1,7 +1,8 @@ import {PeerId} from "@libp2p/interface"; import {Registry} from "prom-client"; import {ENR} from "@chainsafe/enr"; -import {identify} from "@libp2p/identify"; +// TODO: We should use this fork until https://github.com/libp2p/js-libp2p/pull/2387 +import {identify} from "@chainsafe/libp2p-identify"; import {bootstrap} from "@libp2p/bootstrap"; import {mdns} from "@libp2p/mdns"; import {createLibp2p} from "libp2p"; @@ -63,7 +64,7 @@ export async function createNodeJsLibp2p( } } - const libp2p = await createLibp2p({ + return createLibp2p({ peerId, addresses: { listen: localMultiaddrs, @@ -84,9 +85,7 @@ export async function createNodeJsLibp2p( }, }), ], - // libp2p:mplex rate limit hit when receiving messages for streams that do not exist - closing remote connection - // libp2p:gossipsub:error Error: Too many messages for missing streams - streamMuxers: [mplex({maxInboundStreams: 256, disconnectThreshold: 50})], + streamMuxers: [mplex({maxInboundStreams: 256})], peerDiscovery, metrics: nodeJsLibp2pOpts.metrics ? prometheusMetrics({ @@ -136,12 +135,4 @@ export async function createNodeJsLibp2p( }), }, }); - - // TODO: Remove this once https://github.com/libp2p/js-libp2p/pull/2387 is published - // We use `/ipfs/id/1.0.0` protocol and `/ipfs/id/push/1.0.0` is causing following errors - // libp2p:mplex initiator stream with id 8 and protocol undefined ended - // libp2p:mplex:stream:initiator:8 selected protocol /ipfs/id/push/1.0.0 - await libp2p.unhandle(["/ipfs/id/push/1.0.0"]); - - return libp2p; } diff --git a/yarn.lock b/yarn.lock index 839c0dce5e90..0780e0bc2ef8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -385,6 +385,23 @@ uint8arraylist "^2.4.8" uint8arrays "^5.0.1" +"@chainsafe/libp2p-identify@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@chainsafe/libp2p-identify/-/libp2p-identify-1.0.0.tgz#28191e619715a87c140d8b516ee85cb7d39e41e0" + integrity sha512-X+VWUC0xeCFIulE4BU5M8FmTxZ/OKzku+9/1UaX2EG1LcqQkCDrPi6CCODbE0SraqImG4aVHRbiCFWxKEfE8wQ== + dependencies: + "@libp2p/interface" "^1.1.2" + "@libp2p/interface-internal" "^1.0.7" + "@libp2p/peer-id" "^4.0.5" + "@libp2p/peer-record" "^7.0.7" + "@multiformats/multiaddr" "^12.1.10" + "@multiformats/multiaddr-matcher" "^1.1.0" + it-protobuf-stream "^1.1.1" + protons-runtime "^5.0.0" + uint8arraylist "^2.4.7" + uint8arrays "^5.0.0" + wherearewe "^2.0.1" + "@chainsafe/libp2p-noise@^14.1.0": version "14.1.0" resolved "https://registry.yarnpkg.com/@chainsafe/libp2p-noise/-/libp2p-noise-14.1.0.tgz#4084a448cec73a941fddfc94751f6ce2e23c07cd" @@ -1629,6 +1646,21 @@ uint8arraylist "^2.4.3" uint8arrays "^5.0.0" +"@libp2p/peer-record@^7.0.7": + version "7.0.7" + resolved "https://registry.yarnpkg.com/@libp2p/peer-record/-/peer-record-7.0.7.tgz#e55145b2509592696f42ff73c38f813efbbbc688" + integrity sha512-RsggFJVAWQBA2z+ZJsK5nKHDKLmSd89IhFiE5GyImedQFiMkJz/gDFROzfNF2NdOyEBNdRy5SmC9scNFRQQD9A== + dependencies: + "@libp2p/crypto" "^4.0.1" + "@libp2p/interface" "^1.1.2" + "@libp2p/peer-id" "^4.0.5" + "@libp2p/utils" "^5.2.3" + "@multiformats/multiaddr" "^12.1.10" + protons-runtime "^5.0.0" + uint8-varint "^2.0.2" + uint8arraylist "^2.4.7" + uint8arrays "^5.0.0" + "@libp2p/peer-store@^10.0.5": version "10.0.5" resolved "https://registry.yarnpkg.com/@libp2p/peer-store/-/peer-store-10.0.5.tgz#b969d1707f5dcbf4d110e099270de285b075aa02" @@ -8054,6 +8086,16 @@ it-protobuf-stream@^1.0.2: protons-runtime "^5.0.0" uint8arraylist "^2.4.1" +it-protobuf-stream@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/it-protobuf-stream/-/it-protobuf-stream-1.1.2.tgz#4444d78fcae0fce949b4cbea622bf1d92667e64f" + integrity sha512-epZBuG+7cPaTxCR/Lf3ApshBdA9qfflGPQLfLLrp9VQ0w67Z2xo4H+SLLetav57/29oPtAXwVaoyemg99JOWzA== + dependencies: + it-length-prefixed-stream "^1.0.0" + it-stream-types "^2.0.1" + protons-runtime "^5.0.0" + uint8arraylist "^2.4.1" + it-pushable@^3.0.0, it-pushable@^3.1.2, it-pushable@^3.2.0, it-pushable@^3.2.1, it-pushable@^3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/it-pushable/-/it-pushable-3.2.3.tgz#e2b80aed90cfbcd54b620c0a0785e546d4e5f334"