Skip to content

Commit

Permalink
Update the @chainsafe/libp2p-identify
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Feb 5, 2024
1 parent cc0aed8 commit 06c697b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/beacon-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 4 additions & 13 deletions packages/beacon-node/src/network/libp2p/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -63,7 +64,7 @@ export async function createNodeJsLibp2p(
}
}

const libp2p = await createLibp2p({
return createLibp2p({
peerId,
addresses: {
listen: localMultiaddrs,
Expand All @@ -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({
Expand Down Expand Up @@ -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;
}
42 changes: 42 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 06c697b

Please sign in to comment.