Disable Mplex by default (#9365)

Co-Authored-By: João Oliveira <hello@jxs.pt>
This commit is contained in:
João Oliveira
2026-06-03 09:05:31 +01:00
committed by GitHub
parent d7d56e6312
commit c2ac519c69
6 changed files with 52 additions and 17 deletions

View File

@@ -125,6 +125,9 @@ pub struct Config {
/// Whether light client protocols should be enabled.
pub enable_light_client_server: bool,
/// Whether to enable the deprecated mplex multiplexer alongside yamux.
pub enable_mplex: bool,
/// Configuration for the outbound rate limiter (requests made by this node).
pub outbound_rate_limiter_config: Option<OutboundRateLimiterConfig>,
@@ -362,6 +365,7 @@ impl Default for Config {
proposer_only: false,
metrics_enabled: false,
enable_light_client_server: true,
enable_mplex: false,
outbound_rate_limiter_config: None,
invalid_block_storage: None,
inbound_rate_limiter_config: None,

View File

@@ -466,9 +466,13 @@ impl<E: EthSpec> Network<E> {
}
};
// Set up the transport - tcp/quic with noise and mplex
let transport = build_transport(local_keypair.clone(), !config.disable_quic_support)
.map_err(|e| format!("Failed to build transport: {:?}", e))?;
// Set up the transport - tcp/quic with noise and yamux (mplex optional)
let transport = build_transport(
local_keypair.clone(),
!config.disable_quic_support,
config.enable_mplex,
)
.map_err(|e| format!("Failed to build transport: {:?}", e))?;
// use the executor for libp2p
struct Executor(task_executor::TaskExecutor);

View File

@@ -34,27 +34,39 @@ pub struct Context<'a> {
type BoxedTransport = Boxed<(PeerId, StreamMuxerBox)>;
/// The implementation supports TCP/IP, QUIC (experimental) over UDP, noise as the encryption layer, and
/// mplex/yamux as the multiplexing layer (when using TCP).
/// yamux as the multiplexing layer (when using TCP). Mplex can be optionally enabled.
pub fn build_transport(
local_private_key: Keypair,
quic_support: bool,
enable_mplex: bool,
) -> std::io::Result<BoxedTransport> {
// mplex config
let mut mplex_config = libp2p_mplex::Config::new();
mplex_config.set_max_buffer_size(256);
mplex_config.set_max_buffer_behaviour(libp2p_mplex::MaxBufferBehaviour::Block);
// yamux config
let yamux_config = yamux::Config::default();
// Creates the TCP transport layer
let tcp = libp2p::tcp::tokio::Transport::new(libp2p::tcp::Config::default().nodelay(true))
.upgrade(core::upgrade::Version::V1)
.authenticate(generate_noise_config(&local_private_key))
.multiplex(core::upgrade::SelectUpgrade::new(
yamux_config,
mplex_config,
))
.timeout(Duration::from_secs(10));
let tcp: BoxedTransport = if enable_mplex {
// Enable both yamux and mplex.
let mut mplex_config = libp2p_mplex::Config::new();
mplex_config.set_max_num_streams(32);
mplex_config.set_max_buffer_behaviour(libp2p_mplex::MaxBufferBehaviour::ResetStream);
libp2p::tcp::tokio::Transport::new(libp2p::tcp::Config::default().nodelay(true))
.upgrade(core::upgrade::Version::V1)
.authenticate(generate_noise_config(&local_private_key))
.multiplex(core::upgrade::SelectUpgrade::new(
yamux_config,
mplex_config,
))
.timeout(Duration::from_secs(10))
.boxed()
} else {
// Yamux only
libp2p::tcp::tokio::Transport::new(libp2p::tcp::Config::default().nodelay(true))
.upgrade(core::upgrade::Version::V1)
.authenticate(generate_noise_config(&local_private_key))
.multiplex(yamux_config)
.timeout(Duration::from_secs(10))
.boxed()
};
let transport = if quic_support {
// Enables Quic
// The default quic configuration suits us for now.

View File

@@ -387,6 +387,14 @@ pub fn cli_app() -> Command {
.help("Disables the quic transport. The node will rely solely on the TCP transport for libp2p connections.")
.display_order(0)
)
.arg(
Arg::new("enable-mplex")
.long("enable-mplex")
.action(ArgAction::SetTrue)
.help_heading(FLAG_HEADER)
.help("Enables mplex multiplexer alongside yamux. Yamux is preferred when both are available.")
.display_order(0)
)
.arg(
Arg::new("disable-peer-scoring")
.long("disable-peer-scoring")

View File

@@ -1443,6 +1443,10 @@ pub fn set_network_config(
config.disable_quic_support = true;
}
if parse_flag(cli_args, "enable-mplex") {
config.enable_mplex = true;
}
if parse_flag(cli_args, "disable-upnp") {
config.upnp_enabled = false;
}

View File

@@ -494,6 +494,9 @@ Flags:
Sets the local ENR IP address and port to match those set for
lighthouse. Specifically, the IP address will be the value of
--listen-address and the UDP port will be --discovery-port.
--enable-mplex
Enables mplex multiplexer alongside yamux. Yamux is preferred when
both are available.
--enable-partial-columns
Enable partial messages for data columns. This can reduce the amount
of data sent over the network. Enabled by default on Hoodi and