diff --git a/beacon_node/lighthouse_network/src/discovery/mod.rs b/beacon_node/lighthouse_network/src/discovery/mod.rs index 939eca3b946..38a6a84b44e 100644 --- a/beacon_node/lighthouse_network/src/discovery/mod.rs +++ b/beacon_node/lighthouse_network/src/discovery/mod.rs @@ -264,47 +264,62 @@ impl Discovery { 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 - let mut fut_coll = config + let discv5_eligible_addrs = config .boot_nodes_multiaddr .iter() - .map(|addr| addr.to_string()) - // request the ENR for this multiaddr and keep the original for logging - .map(|addr| { - futures::future::join( - discv5.request_enr(addr.clone()), - futures::future::ready(addr), - ) - }) - .collect::>(); + // Filter out multiaddrs without UDP or P2P protocols required for discv5 ENR requests + .filter(|addr| { + addr.iter().any(|proto| matches!(proto, Protocol::Udp(_))) + && addr.iter().any(|proto| matches!(proto, Protocol::P2p(_))) + }); - 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| { + if config.disable_discovery { + if discv5_eligible_addrs.count() > 0 { + warn!( + "Boot node multiaddrs requiring discv5 ENR lookup will be ignored because discovery is disabled" + ); + } + } else { + let mut fut_coll = discv5_eligible_addrs + .map(|addr| addr.to_string()) + // request the ENR for this multiaddr and keep the original for logging + .map(|addr| { + futures::future::join( + discv5.request_enr(addr.clone()), + futures::future::ready(addr), + ) + }) + .collect::>(); + + 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!( - addr = original_addr.to_string(), + multiaddr = original_addr.to_string(), error = e.to_string(), - "Could not add peer to the local routing table" + "Error getting mapping to ENR" ) - }); - } - Err(e) => { - error!( - multiaddr = original_addr.to_string(), - error = e.to_string(), - "Error getting mapping to ENR" - ) + } } } } diff --git a/beacon_node/lighthouse_network/src/service/mod.rs b/beacon_node/lighthouse_network/src/service/mod.rs index 4eebda1decb..e812dd10b81 100644 --- a/beacon_node/lighthouse_network/src/service/mod.rs +++ b/beacon_node/lighthouse_network/src/service/mod.rs @@ -574,6 +574,7 @@ impl Network { }; // 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 { dial(multiaddr.clone()); } diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index e4c7c6ff1fe..9553fe60ba2 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -364,7 +364,7 @@ pub fn cli_app() -> Command { .long("libp2p-addresses") .value_name("MULTIADDR") .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) .display_order(0) ) diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index 26dd3b6642e..d5fdc1c979e 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -15,7 +15,7 @@ use directory::{DEFAULT_BEACON_NODE_DIR, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR}; use environment::RuntimeContext; use execution_layer::DEFAULT_JWT_FILE; 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 sensitive_url::SensitiveUrl; use std::collections::HashSet; @@ -28,7 +28,7 @@ use std::num::NonZeroU16; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::time::Duration; -use tracing::{error, info, warn}; +use tracing::{info, warn}; use types::graffiti::GraffitiString; use types::{Checkpoint, Epoch, EthSpec, Hash256}; @@ -1196,12 +1196,6 @@ pub fn set_network_config( let multi: Multiaddr = addr .parse() .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); } } @@ -1210,7 +1204,9 @@ pub fn set_network_config( 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::("libp2p-addresses") { + warn!("The --libp2p-addresses flag is deprecated and replaced by --boot-nodes"); config.libp2p_nodes = libp2p_addresses_str .split(',') .map(|multiaddr| { diff --git a/book/src/help_bn.md b/book/src/help_bn.md index 5f3c43a7e42..d3aa27c8a77 100644 --- a/book/src/help_bn.md +++ b/book/src/help_bn.md @@ -225,7 +225,8 @@ Options: be careful to avoid filling up their disks. --libp2p-addresses 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 [
...] The address lighthouse will listen for UDP and TCP connections. To listen over IPv4 and IPv6 set this flag twice with the different