mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
Create network_utils crate (#7761)
Anchor currently depends on `lighthouse_network` for a few types and utilities that live within. As we use our own libp2p behaviours, we actually do not use the core logic in that crate. This makes us transitively depend on a bunch of unneeded crates (even a whole separate libp2p if the versions mismatch!) Move things we require into it's own lightweight crate. Co-Authored-By: Daniel Knopik <daniel@dknopik.de>
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
//! Implementation of Lighthouse's peer management system.
|
||||
|
||||
use crate::discovery::enr_ext::EnrExt;
|
||||
use crate::discovery::peer_id_to_node_id;
|
||||
use crate::rpc::{GoodbyeReason, MetaData, Protocol, RPCError, RpcErrorResponse};
|
||||
use crate::service::TARGET_SUBNET_PEERS;
|
||||
use crate::{Gossipsub, NetworkGlobals, PeerId, Subnet, SubnetDiscovery, metrics};
|
||||
@@ -26,6 +24,8 @@ pub mod peerdb;
|
||||
|
||||
use crate::peer_manager::peerdb::client::ClientKind;
|
||||
use libp2p::multiaddr;
|
||||
use network_utils::discovery_metrics;
|
||||
use network_utils::enr_ext::{EnrExt, peer_id_to_node_id};
|
||||
pub use peerdb::peer_info::{ConnectionDirection, PeerConnectionStatus, PeerInfo};
|
||||
use peerdb::score::{PeerAction, ReportSource};
|
||||
pub use peerdb::sync_status::{SyncInfo, SyncStatus};
|
||||
@@ -1111,7 +1111,7 @@ impl<E: EthSpec> PeerManager<E> {
|
||||
///
|
||||
/// Protection criteria:
|
||||
/// - Outbound peers: don't prune if it would drop below target outbound peer count
|
||||
/// - Data column sampling: ≤ MIN_SAMPLING_COLUMN_SUBNET_PEERS (2) peers per subnet
|
||||
/// - Data column sampling: ≤ MIN_SAMPLING_COLUMN_SUBNET_PEERS (2) peers per subnet
|
||||
/// - Sync committees: ≤ MIN_SYNC_COMMITTEE_PEERS (2) peers per committee
|
||||
/// - Attestation subnets: protect peers on the scarcest attestation subnets
|
||||
///
|
||||
@@ -1586,16 +1586,16 @@ impl<E: EthSpec> PeerManager<E> {
|
||||
|
||||
// Set ipv4 nat_open metric flag if threshold of peercount is met, unset if below threshold
|
||||
if inbound_ipv4_peers_connected >= LIBP2P_NAT_OPEN_THRESHOLD {
|
||||
metrics::set_gauge_vec(&metrics::NAT_OPEN, &["libp2p_ipv4"], 1);
|
||||
metrics::set_gauge_vec(&discovery_metrics::NAT_OPEN, &["libp2p_ipv4"], 1);
|
||||
} else {
|
||||
metrics::set_gauge_vec(&metrics::NAT_OPEN, &["libp2p_ipv4"], 0);
|
||||
metrics::set_gauge_vec(&discovery_metrics::NAT_OPEN, &["libp2p_ipv4"], 0);
|
||||
}
|
||||
|
||||
// Set ipv6 nat_open metric flag if threshold of peercount is met, unset if below threshold
|
||||
if inbound_ipv6_peers_connected >= LIBP2P_NAT_OPEN_THRESHOLD {
|
||||
metrics::set_gauge_vec(&metrics::NAT_OPEN, &["libp2p_ipv6"], 1);
|
||||
metrics::set_gauge_vec(&discovery_metrics::NAT_OPEN, &["libp2p_ipv6"], 1);
|
||||
} else {
|
||||
metrics::set_gauge_vec(&metrics::NAT_OPEN, &["libp2p_ipv6"], 0);
|
||||
metrics::set_gauge_vec(&discovery_metrics::NAT_OPEN, &["libp2p_ipv6"], 0);
|
||||
}
|
||||
|
||||
// PEERS_CONNECTED
|
||||
@@ -2780,7 +2780,7 @@ mod tests {
|
||||
///
|
||||
/// Create 6 peers with different sync statuses:
|
||||
/// Peer0: Behind
|
||||
/// Peer1: Unknown
|
||||
/// Peer1: Unknown
|
||||
/// Peer2: Synced
|
||||
/// Peer3: Advanced
|
||||
/// Peer4: Synced
|
||||
|
||||
Reference in New Issue
Block a user