From 6cb76f0fd56202b88dac50eaf90addff1e924db5 Mon Sep 17 00:00:00 2001 From: Cayman Date: Mon, 14 Aug 2023 15:35:35 -0400 Subject: [PATCH] feat: add yamux stream muxer --- packages/beacon-node/package.json | 1 + packages/beacon-node/src/network/libp2p/index.ts | 3 ++- yarn.lock | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/beacon-node/package.json b/packages/beacon-node/package.json index eddd66fce7a0..1d2453d72d66 100644 --- a/packages/beacon-node/package.json +++ b/packages/beacon-node/package.json @@ -102,6 +102,7 @@ "@chainsafe/discv5": "^5.0.0", "@chainsafe/libp2p-gossipsub": "^10.0.0", "@chainsafe/libp2p-noise": "^13.0.0", + "@chainsafe/libp2p-yamux": "^5.0.0", "@chainsafe/persistent-merkle-tree": "^0.5.0", "@chainsafe/prometheus-gc-stats": "^1.0.0", "@chainsafe/ssz": "^0.10.2", diff --git a/packages/beacon-node/src/network/libp2p/index.ts b/packages/beacon-node/src/network/libp2p/index.ts index cdbb3fb16224..afb9d1ed9637 100644 --- a/packages/beacon-node/src/network/libp2p/index.ts +++ b/packages/beacon-node/src/network/libp2p/index.ts @@ -7,6 +7,7 @@ import {bootstrap} from "@libp2p/bootstrap"; import {mdns} from "@libp2p/mdns"; import {createLibp2p} from "libp2p"; import {mplex} from "@libp2p/mplex"; +import {yamux} from "@chainsafe/libp2p-yamux"; import {prometheusMetrics} from "@libp2p/prometheus-metrics"; import {tcp} from "@libp2p/tcp"; import {defaultNetworkOptions, NetworkOptions} from "../options.js"; @@ -85,7 +86,7 @@ export async function createNodeJsLibp2p( }, }), ], - streamMuxers: [mplex({maxInboundStreams: 256})], + streamMuxers: [yamux({maxInboundStreams: 256}), mplex({maxInboundStreams: 256})], peerDiscovery, metrics: nodeJsLibp2pOpts.metrics ? prometheusMetrics({ diff --git a/yarn.lock b/yarn.lock index 090b220a6ad8..cedd3bbb4214 100644 --- a/yarn.lock +++ b/yarn.lock @@ -606,6 +606,19 @@ uint8arraylist "^2.4.3" uint8arrays "^4.0.4" +"@chainsafe/libp2p-yamux@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@chainsafe/libp2p-yamux/-/libp2p-yamux-5.0.0.tgz#c1016fc839870139b5c097daff9408b91c58f2a7" + integrity sha512-aWTnBPR2hJt0A2y579sMtZVB6IqgSSHlZ6Eg+WDxNZQ0zcexafuruZQDj+z3FUTNPz+E8IeuyCi7tjI4IEehjw== + dependencies: + "@libp2p/interface" "^0.1.0" + "@libp2p/logger" "^3.0.0" + abortable-iterator "^5.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"