diff --git a/beacon_node/Cargo.toml b/beacon_node/Cargo.toml index cf0a1f719d..dd7416af54 100644 --- a/beacon_node/Cargo.toml +++ b/beacon_node/Cargo.toml @@ -33,6 +33,7 @@ http_api = { workspace = true } hyper = { workspace = true } lighthouse_network = { workspace = true } monitoring_api = { workspace = true } +network_utils = { workspace = true } sensitive_url = { workspace = true } serde_json = { workspace = true } slasher = { workspace = true } @@ -41,7 +42,6 @@ strum = { workspace = true } task_executor = { workspace = true } tracing = { workspace = true } types = { workspace = true } -network_utils = { workspace = true } [dev-dependencies] node_test_rig = { path = "../testing/node_test_rig" } diff --git a/beacon_node/lighthouse_network/src/discovery/mod.rs b/beacon_node/lighthouse_network/src/discovery/mod.rs index d419a3e988..949b1cbc77 100644 --- a/beacon_node/lighthouse_network/src/discovery/mod.rs +++ b/beacon_node/lighthouse_network/src/discovery/mod.rs @@ -32,6 +32,7 @@ pub use libp2p::{ }; use logging::crit; use lru::LruCache; +use network_utils::discovery_metrics; use ssz::Encode; use std::num::NonZeroUsize; use std::{ @@ -45,7 +46,6 @@ use std::{ }; use tokio::sync::mpsc; use tracing::{debug, error, info, trace, warn}; -use network_utils::discovery_metrics; use types::{ChainSpec, EnrForkId, EthSpec}; mod subnet_predicate; @@ -687,7 +687,10 @@ impl Discovery { min_ttl, retries, }); - metrics::set_gauge(&discovery_metrics::DISCOVERY_QUEUE, self.queued_queries.len() as i64); + metrics::set_gauge( + &discovery_metrics::DISCOVERY_QUEUE, + self.queued_queries.len() as i64, + ); } } @@ -722,7 +725,10 @@ impl Discovery { } } // Update the queue metric - metrics::set_gauge(&discovery_metrics::DISCOVERY_QUEUE, self.queued_queries.len() as i64); + metrics::set_gauge( + &discovery_metrics::DISCOVERY_QUEUE, + self.queued_queries.len() as i64, + ); processed } diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index e70d511535..dd9fc25d48 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -24,6 +24,7 @@ pub mod peerdb; use crate::peer_manager::peerdb::client::ClientKind; use libp2p::multiaddr; +use network_utils::discovery_metrics; use network_utils::enr_ext::{peer_id_to_node_id, EnrExt}; pub use peerdb::peer_info::{ ConnectionDirection, PeerConnectionStatus, PeerConnectionStatus::*, PeerInfo, @@ -33,7 +34,6 @@ pub use peerdb::sync_status::{SyncInfo, SyncStatus}; use std::collections::{hash_map::Entry, HashMap, HashSet}; use std::net::IpAddr; use strum::IntoEnumIterator; -use network_utils::discovery_metrics; use types::data_column_custody_group::{ compute_subnets_from_custody_group, get_custody_groups, CustodyIndex, }; diff --git a/boot_node/Cargo.toml b/boot_node/Cargo.toml index 1b2737eefb..d431dbeadf 100644 --- a/boot_node/Cargo.toml +++ b/boot_node/Cargo.toml @@ -10,12 +10,12 @@ bytes = { workspace = true } clap = { workspace = true } clap_utils = { workspace = true } eth2_network_config = { workspace = true } -network_utils = { workspace = true } ethereum_ssz = { workspace = true } hex = { workspace = true } lighthouse_network = { workspace = true } log = { workspace = true } logging = { workspace = true } +network_utils = { workspace = true } serde = { workspace = true } tokio = { workspace = true } tracing = { workspace = true } diff --git a/common/network_utils/Cargo.toml b/common/network_utils/Cargo.toml index ee93893621..5206249e6f 100644 --- a/common/network_utils/Cargo.toml +++ b/common/network_utils/Cargo.toml @@ -13,6 +13,5 @@ parking_lot = { workspace = true } serde = { workspace = true } tiny-keccak = { version = "2", features = ["keccak"] } - [dev-dependencies] -hex = { workspace = true } \ No newline at end of file +hex = { workspace = true } diff --git a/common/network_utils/src/discovery_metrics.rs b/common/network_utils/src/discovery_metrics.rs index c59b93d638..d105dee57a 100644 --- a/common/network_utils/src/discovery_metrics.rs +++ b/common/network_utils/src/discovery_metrics.rs @@ -1,5 +1,5 @@ -use std::sync::LazyLock; use metrics::*; +use std::sync::LazyLock; pub static NAT_OPEN: LazyLock> = LazyLock::new(|| { try_create_int_gauge_vec( diff --git a/common/network_utils/src/lib.rs b/common/network_utils/src/lib.rs index 52624abeb9..c3d6ee1e0c 100644 --- a/common/network_utils/src/lib.rs +++ b/common/network_utils/src/lib.rs @@ -1,4 +1,4 @@ +pub mod discovery_metrics; pub mod enr_ext; pub mod listen_addr; pub mod unused_port; -pub mod discovery_metrics; diff --git a/common/system_health/src/lib.rs b/common/system_health/src/lib.rs index 3db47e0786..703c6e0349 100644 --- a/common/system_health/src/lib.rs +++ b/common/system_health/src/lib.rs @@ -1,10 +1,10 @@ use lighthouse_network::{types::SyncState, NetworkGlobals}; +use network_utils::discovery_metrics; use parking_lot::RwLock; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; use std::sync::Arc; use sysinfo::{CpuExt, DiskExt, NetworkExt, NetworksExt, System, SystemExt}; -use network_utils::discovery_metrics; use types::EthSpec; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -220,33 +220,21 @@ impl NatState { /// Observes if NAT traversal is possible. pub fn observe_nat() -> NatState { - let discv5_ipv4 = metrics::get_int_gauge( - &discovery_metrics::NAT_OPEN, - &["discv5_ipv4"], - ) - .map(|g| g.get() == 1) - .unwrap_or_default(); + let discv5_ipv4 = metrics::get_int_gauge(&discovery_metrics::NAT_OPEN, &["discv5_ipv4"]) + .map(|g| g.get() == 1) + .unwrap_or_default(); - let discv5_ipv6 = metrics::get_int_gauge( - &discovery_metrics::NAT_OPEN, - &["discv5_ipv6"], - ) - .map(|g| g.get() == 1) - .unwrap_or_default(); + let discv5_ipv6 = metrics::get_int_gauge(&discovery_metrics::NAT_OPEN, &["discv5_ipv6"]) + .map(|g| g.get() == 1) + .unwrap_or_default(); - let libp2p_ipv4 = metrics::get_int_gauge( - &discovery_metrics::NAT_OPEN, - &["libp2p_ipv4"], - ) - .map(|g| g.get() == 1) - .unwrap_or_default(); + let libp2p_ipv4 = metrics::get_int_gauge(&discovery_metrics::NAT_OPEN, &["libp2p_ipv4"]) + .map(|g| g.get() == 1) + .unwrap_or_default(); - let libp2p_ipv6 = metrics::get_int_gauge( - &discovery_metrics::NAT_OPEN, - &["libp2p_ipv6"], - ) - .map(|g| g.get() == 1) - .unwrap_or_default(); + let libp2p_ipv6 = metrics::get_int_gauge(&discovery_metrics::NAT_OPEN, &["libp2p_ipv6"]) + .map(|g| g.get() == 1) + .unwrap_or_default(); NatState { discv5_ipv4, diff --git a/lcli/Cargo.toml b/lcli/Cargo.toml index 2178954b85..567f4d5e7f 100644 --- a/lcli/Cargo.toml +++ b/lcli/Cargo.toml @@ -30,10 +30,10 @@ ethereum_ssz = { workspace = true } execution_layer = { workspace = true } hex = { workspace = true } lighthouse_network = { workspace = true } -network_utils = { workspace = true } lighthouse_version = { workspace = true } log = { workspace = true } malloc_utils = { workspace = true } +network_utils = { workspace = true } rayon = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index 369acba1df..0d79026b95 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -58,6 +58,7 @@ lighthouse_version = { workspace = true } logging = { workspace = true } malloc_utils = { workspace = true } metrics = { workspace = true } +network_utils = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } serde_yaml = { workspace = true } @@ -67,7 +68,6 @@ task_executor = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } types = { workspace = true } -network_utils = { workspace = true } validator_client = { workspace = true } validator_manager = { path = "../validator_manager" } diff --git a/testing/execution_engine_integration/Cargo.toml b/testing/execution_engine_integration/Cargo.toml index fab881b7fe..eef13cfc73 100644 --- a/testing/execution_engine_integration/Cargo.toml +++ b/testing/execution_engine_integration/Cargo.toml @@ -18,6 +18,7 @@ fork_choice = { workspace = true } futures = { workspace = true } hex = { workspace = true } logging = { workspace = true } +network_utils = { workspace = true } reqwest = { workspace = true } sensitive_url = { workspace = true } serde_json = { workspace = true } @@ -25,4 +26,3 @@ task_executor = { workspace = true } tempfile = { workspace = true } tokio = { workspace = true } types = { workspace = true } -network_utils = { workspace = true }