mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-31 05:07:12 +00:00
Merge branch 'unstable' of https://github.com/sigp/lighthouse into gloas-data-availability-checker
This commit is contained in:
@@ -22,11 +22,11 @@ fixed_bytes = { workspace = true }
|
||||
fnv = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
if-addrs = "0.14"
|
||||
itertools = { workspace = true }
|
||||
libp2p = { workspace = true }
|
||||
libp2p-mplex = { git = "https://github.com/libp2p/rust-libp2p.git" }
|
||||
lighthouse_version = { workspace = true }
|
||||
local-ip-address = "0.6"
|
||||
logging = { workspace = true }
|
||||
lru = { workspace = true }
|
||||
lru_cache = { workspace = true }
|
||||
|
||||
@@ -5,8 +5,8 @@ use crate::{Enr, PeerIdSerialized};
|
||||
use directory::{
|
||||
DEFAULT_BEACON_NODE_DIR, DEFAULT_HARDCODED_NETWORK, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR,
|
||||
};
|
||||
use if_addrs::get_if_addrs;
|
||||
use libp2p::{Multiaddr, gossipsub};
|
||||
use local_ip_address::local_ipv6;
|
||||
use network_utils::listen_addr::{ListenAddr, ListenAddress};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -262,13 +262,13 @@ impl Config {
|
||||
/// A helper function to check if the local host has a globally routeable IPv6 address. If so,
|
||||
/// returns true.
|
||||
pub fn is_ipv6_supported() -> bool {
|
||||
// If IPv6 is supported
|
||||
let Ok(std::net::IpAddr::V6(local_ip)) = local_ipv6() else {
|
||||
let Ok(addrs) = get_if_addrs() else {
|
||||
return false;
|
||||
};
|
||||
|
||||
// If its globally routable, return true
|
||||
is_global_ipv6(&local_ip)
|
||||
addrs.iter().any(
|
||||
|iface| matches!(iface.addr, if_addrs::IfAddr::V6(ref v6) if is_global_ipv6(&v6.ip)),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn listen_addrs(&self) -> &ListenAddress {
|
||||
|
||||
@@ -264,47 +264,62 @@ impl<E: EthSpec> Discovery<E> {
|
||||
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::<FuturesUnordered<_>>();
|
||||
// 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| {
|
||||
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"
|
||||
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::<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"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,6 +573,7 @@ impl<E: EthSpec> Network<E> {
|
||||
};
|
||||
|
||||
// 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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user