Remove libp2p multiaddress (#8683)

Co-Authored-By: João Oliveira <hello@jxs.pt>

Co-Authored-By: ackintosh <sora.akatsuki@gmail.com>
This commit is contained in:
João Oliveira
2026-02-09 23:31:49 +00:00
committed by GitHub
parent a3f04bd2d2
commit 0c9f97f015
5 changed files with 59 additions and 46 deletions

View File

@@ -264,47 +264,62 @@ impl<E: EthSpec> Discovery<E> {
info!("Contacting Multiaddr boot-nodes for their ENR"); info!("Contacting Multiaddr boot-nodes for their ENR");
} }
// get futures for requesting the Enrs associated to these multiaddr and wait for their // get futures for requesting the ENRs associated to these multiaddr and wait for their
// completion // completion
let mut fut_coll = config let discv5_eligible_addrs = config
.boot_nodes_multiaddr .boot_nodes_multiaddr
.iter() .iter()
.map(|addr| addr.to_string()) // Filter out multiaddrs without UDP or P2P protocols required for discv5 ENR requests
// request the ENR for this multiaddr and keep the original for logging .filter(|addr| {
.map(|addr| { addr.iter().any(|proto| matches!(proto, Protocol::Udp(_)))
futures::future::join( && addr.iter().any(|proto| matches!(proto, Protocol::P2p(_)))
discv5.request_enr(addr.clone()), });
futures::future::ready(addr),
)
})
.collect::<FuturesUnordered<_>>();
while let Some((result, original_addr)) = fut_coll.next().await { if config.disable_discovery {
match result { if discv5_eligible_addrs.count() > 0 {
Ok(enr) => { warn!(
debug!( "Boot node multiaddrs requiring discv5 ENR lookup will be ignored because discovery is disabled"
node_id = %enr.node_id(), );
peer_id = %enr.peer_id(), }
ip4 = ?enr.ip4(), } else {
udp4 = ?enr.udp4(), let mut fut_coll = discv5_eligible_addrs
tcp4 = ?enr.tcp4(), .map(|addr| addr.to_string())
quic4 = ?enr.quic4(), // request the ENR for this multiaddr and keep the original for logging
"Adding node to routing table" .map(|addr| {
); futures::future::join(
let _ = discv5.add_enr(enr).map_err(|e| { discv5.request_enr(addr.clone()),
error!( futures::future::ready(addr),
addr = original_addr.to_string(),
error = e.to_string(),
"Could not add peer to the local routing table"
)
});
}
Err(e) => {
error!(
multiaddr = original_addr.to_string(),
error = e.to_string(),
"Error getting mapping to ENR"
) )
})
.collect::<FuturesUnordered<_>>();
while let Some((result, original_addr)) = fut_coll.next().await {
match result {
Ok(enr) => {
debug!(
node_id = %enr.node_id(),
peer_id = %enr.peer_id(),
ip4 = ?enr.ip4(),
udp4 = ?enr.udp4(),
tcp4 = ?enr.tcp4(),
quic4 = ?enr.quic4(),
"Adding node to routing table"
);
let _ = discv5.add_enr(enr).map_err(|e| {
error!(
addr = original_addr.to_string(),
error = e.to_string(),
"Could not add peer to the local routing table"
)
});
}
Err(e) => {
error!(
multiaddr = original_addr.to_string(),
error = e.to_string(),
"Error getting mapping to ENR"
)
}
} }
} }
} }

View File

@@ -573,6 +573,7 @@ impl<E: EthSpec> Network<E> {
}; };
// attempt to connect to user-input libp2p nodes // attempt to connect to user-input libp2p nodes
// DEPRECATED: can be removed in v8.2.0./v9.0.0
for multiaddr in &config.libp2p_nodes { for multiaddr in &config.libp2p_nodes {
dial(multiaddr.clone()); dial(multiaddr.clone());
} }

View File

@@ -364,7 +364,7 @@ pub fn cli_app() -> Command {
.long("libp2p-addresses") .long("libp2p-addresses")
.value_name("MULTIADDR") .value_name("MULTIADDR")
.help("One or more comma-delimited multiaddrs to manually connect to a libp2p peer \ .help("One or more comma-delimited multiaddrs to manually connect to a libp2p peer \
without an ENR.") without an ENR. DEPRECATED. The --libp2p-addresses flag is deprecated and replaced by --boot-nodes")
.action(ArgAction::Set) .action(ArgAction::Set)
.display_order(0) .display_order(0)
) )

View File

@@ -15,7 +15,7 @@ use directory::{DEFAULT_BEACON_NODE_DIR, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR};
use environment::RuntimeContext; use environment::RuntimeContext;
use execution_layer::DEFAULT_JWT_FILE; use execution_layer::DEFAULT_JWT_FILE;
use http_api::TlsConfig; use http_api::TlsConfig;
use lighthouse_network::{Enr, Multiaddr, NetworkConfig, PeerIdSerialized, multiaddr::Protocol}; use lighthouse_network::{Enr, Multiaddr, NetworkConfig, PeerIdSerialized};
use network_utils::listen_addr::ListenAddress; use network_utils::listen_addr::ListenAddress;
use sensitive_url::SensitiveUrl; use sensitive_url::SensitiveUrl;
use std::collections::HashSet; use std::collections::HashSet;
@@ -28,7 +28,7 @@ use std::num::NonZeroU16;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str::FromStr; use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
use tracing::{error, info, warn}; use tracing::{info, warn};
use types::graffiti::GraffitiString; use types::graffiti::GraffitiString;
use types::{Checkpoint, Epoch, EthSpec, Hash256}; use types::{Checkpoint, Epoch, EthSpec, Hash256};
@@ -1193,12 +1193,6 @@ pub fn set_network_config(
let multi: Multiaddr = addr let multi: Multiaddr = addr
.parse() .parse()
.map_err(|_| format!("Not valid as ENR nor Multiaddr: {}", addr))?; .map_err(|_| format!("Not valid as ENR nor Multiaddr: {}", addr))?;
if !multi.iter().any(|proto| matches!(proto, Protocol::Udp(_))) {
error!(multiaddr = multi.to_string(), "Missing UDP in Multiaddr");
}
if !multi.iter().any(|proto| matches!(proto, Protocol::P2p(_))) {
error!(multiaddr = multi.to_string(), "Missing P2P in Multiaddr");
}
multiaddrs.push(multi); multiaddrs.push(multi);
} }
} }
@@ -1207,7 +1201,9 @@ pub fn set_network_config(
config.boot_nodes_multiaddr = multiaddrs; config.boot_nodes_multiaddr = multiaddrs;
} }
// DEPRECATED: can be removed in v8.2.0./v9.0.0
if let Some(libp2p_addresses_str) = cli_args.get_one::<String>("libp2p-addresses") { if let Some(libp2p_addresses_str) = cli_args.get_one::<String>("libp2p-addresses") {
warn!("The --libp2p-addresses flag is deprecated and replaced by --boot-nodes");
config.libp2p_nodes = libp2p_addresses_str config.libp2p_nodes = libp2p_addresses_str
.split(',') .split(',')
.map(|multiaddr| { .map(|multiaddr| {

View File

@@ -225,7 +225,8 @@ Options:
be careful to avoid filling up their disks. be careful to avoid filling up their disks.
--libp2p-addresses <MULTIADDR> --libp2p-addresses <MULTIADDR>
One or more comma-delimited multiaddrs to manually connect to a libp2p One or more comma-delimited multiaddrs to manually connect to a libp2p
peer without an ENR. peer without an ENR. DEPRECATED. The --libp2p-addresses flag is
deprecated and replaced by --boot-nodes
--listen-address [<ADDRESS>...] --listen-address [<ADDRESS>...]
The address lighthouse will listen for UDP and TCP connections. To The address lighthouse will listen for UDP and TCP connections. To
listen over IPv4 and IPv6 set this flag twice with the different listen over IPv4 and IPv6 set this flag twice with the different