Skip to content

Commit 97eddb9

Browse files
committed
Revive mplex (#4619)
## Issue Addressed N/A ## Proposed Changes In #4431 , we seem to have removed support for mplex as it is being deprecated in libp2p. See libp2p/specs#553 . Related rust-libp2p PR libp2p/rust-libp2p#3920 However, since this isn't part of the official [consensus specs](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#multiplexing), we still need to support mplex. > Clients MUST support [mplex](https://github.com/libp2p/specs/tree/master/mplex) and MAY support [yamux](https://github.com/hashicorp/yamux/blob/master/spec.md). This PR adds back mplex support as before.
1 parent 382322e commit 97eddb9

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

Cargo.lock

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

beacon_node/lighthouse_network/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ prometheus-client = "0.21.0"
4444
unused_port = { path = "../../common/unused_port" }
4545
delay_map = "0.3.0"
4646
void = "1"
47+
libp2p-mplex = "0.40.0"
4748

4849
[dependencies.libp2p]
4950
version = "0.52"

beacon_node/lighthouse_network/src/service/utils.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,21 @@ pub fn build_transport(
5050
transport.or_transport(libp2p::websocket::WsConfig::new(trans_clone))
5151
};
5252

53+
// mplex config
54+
let mut mplex_config = libp2p_mplex::MplexConfig::new();
55+
mplex_config.set_max_buffer_size(256);
56+
mplex_config.set_max_buffer_behaviour(libp2p_mplex::MaxBufferBehaviour::Block);
57+
5358
// yamux config
5459
let mut yamux_config = yamux::Config::default();
5560
yamux_config.set_window_update_mode(yamux::WindowUpdateMode::on_read());
5661
let (transport, bandwidth) = transport
5762
.upgrade(core::upgrade::Version::V1)
5863
.authenticate(generate_noise_config(&local_private_key))
59-
.multiplex(yamux_config)
64+
.multiplex(core::upgrade::SelectUpgrade::new(
65+
yamux_config,
66+
mplex_config,
67+
))
6068
.timeout(Duration::from_secs(10))
6169
.boxed()
6270
.with_bandwidth_logging();

0 commit comments

Comments
 (0)