Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,991 changes: 845 additions & 1,146 deletions Cargo.lock

Large diffs are not rendered by default.

57 changes: 28 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,26 @@ ssv_types = { path = "anchor/common/ssv_types" }
subnet_service = { path = "anchor/subnet_service" }
version = { path = "anchor/common/version" }

beacon_node_fallback = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
bls = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
eth2 = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
eth2_keystore = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
eth2_network_config = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
health_metrics = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
lighthouse_network = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
metrics = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
safe_arith = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
sensitive_url = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
slashing_protection = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
slot_clock = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
task_executor = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
types = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
unused_port = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
validator_metrics = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
validator_services = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
validator_store = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
workspace_members = { git = "https://github.com/sigp/lighthouse", rev = "9b84dac" }
beacon_node_fallback = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
bls = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
eth2 = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
eth2_keystore = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
eth2_network_config = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
health_metrics = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
metrics = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
network_utils = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
safe_arith = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
sensitive_url = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
slashing_protection = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
slot_clock = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
task_executor = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
types = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
validator_metrics = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
validator_services = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
validator_store = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }
workspace_members = { git = "https://github.com/sigp/lighthouse", rev = "0450cfc" }

alloy = { version = "0.12.0", features = [
alloy = { version = "1.0.22", features = [
"sol-types",
"transports",
"json",
Expand All @@ -107,21 +106,21 @@ derive_more = { version = "2.0.1", features = ["full"] }
dirs = "6.0.0"
discv5 = "0.9.0"
enr = "0.13.0"
ethereum_ssz = "0.8"
ethereum_ssz_derive = "0.8"
ethereum_ssz = "0.9"
ethereum_ssz_derive = "0.9"
futures = "0.3.30"
gossipsub = { package = "libp2p-gossipsub", git = "https://github.com/sigp/rust-libp2p.git", rev = "61b2820" }
gossipsub = { package = "libp2p-gossipsub", git = "https://github.com/sigp/rust-libp2p.git", rev = "2a726cd", features = ["metrics"] }
hex = "0.4.3"
hyper = "1.4"
indexmap = "2.7.0"
libp2p = { version = "0.55", default-features = false }
libp2p = { version = "0.56", default-features = false }
multiaddr = "0.18.2"
num_cpus = "1"
once_cell = "1.21.3"
openssl = "0.10.72"
parking_lot = "0.12"
pbkdf2 = "0.12.2"
prometheus-client = "0.22.0"
prometheus-client = "0.23.0"
r2d2 = "0.8.10"
r2d2_sqlite = "0.21.0"
rand = "0.9"
Expand All @@ -145,15 +144,15 @@ tower-http = { version = "0.6", features = ["cors"] }
tracing = "0.1.40"
tracing-appender = "0.2"
tracing-subscriber = { version = "0.3.18", features = ["fmt", "env-filter"] }
tree_hash = "0.9"
tree_hash_derive = "0.9"
tree_hash = "0.10"
tree_hash_derive = "0.10"
vsss-rs = "5.1.0"
zeroize = "1.8.1"

# todo: remove when there is a proper release for peer-store.
[patch.'https://github.com/libp2p/rust-libp2p.git']
libp2p-core = "0.43.0"
libp2p-swarm = "0.46.0"
libp2p-core = "0.43.1"
libp2p-swarm = "0.47.0"

[profile.maxperf]
inherits = "release"
Expand Down
2 changes: 1 addition & 1 deletion anchor/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ message_sender = { workspace = true }
message_validator = { workspace = true }
multiaddr = { workspace = true }
network = { workspace = true }
network_utils = { workspace = true }
openssl = { workspace = true }
operator_key = { workspace = true }
parking_lot = { workspace = true }
Expand All @@ -49,7 +50,6 @@ task_executor = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
types = { workspace = true }
unused_port = { workspace = true }
validator_metrics = { workspace = true }
validator_services = { workspace = true }
version = { workspace = true }
Expand Down
27 changes: 15 additions & 12 deletions anchor/client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use std::{net::IpAddr, path::PathBuf};
use global_config::GlobalConfig;
use multiaddr::{Multiaddr, Protocol};
use network::{DEFAULT_DISC_PORT, DEFAULT_TCP_PORT, ListenAddr, ListenAddress};
use network_utils::unused_port::{
unused_tcp4_port, unused_tcp6_port, unused_udp4_port, unused_udp6_port,
};
use sensitive_url::SensitiveUrl;
use ssv_types::OperatorId;
use tracing::{error, warn};
Expand Down Expand Up @@ -330,7 +333,7 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result<ListenAddress, Strin
// 3. If none of the above are set, use the default TCP port (DEFAULT_TCP_PORT).
let tcp_port = cli_args
.use_zero_ports
.then(unused_port::unused_tcp6_port)
.then(unused_tcp6_port)
.transpose()?
.or(cli_args.port)
.unwrap_or(DEFAULT_TCP_PORT);
Expand All @@ -342,7 +345,7 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result<ListenAddress, Strin
// 4. If none of the above are set, use the default discovery port (DEFAULT_DISC_PORT).
let disc_port = cli_args
.use_zero_ports
.then(unused_port::unused_udp6_port)
.then(unused_udp6_port)
.transpose()?
.or(cli_args.discovery_port)
.or(cli_args.port)
Expand All @@ -354,7 +357,7 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result<ListenAddress, Strin
// 3. If none of the above are set, use the selected TCP port + 1.
let quic_port = cli_args
.use_zero_ports
.then(unused_port::unused_udp6_port)
.then(unused_udp6_port)
.transpose()?
.or(cli_args.quic_port)
.unwrap_or(if tcp_port == 0 { 0 } else { tcp_port + 1 });
Expand All @@ -375,7 +378,7 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result<ListenAddress, Strin
// 3. If none of the above are set, use the default TCP port (DEFAULT_TCP_PORT).
let tcp_port = cli_args
.use_zero_ports
.then(unused_port::unused_tcp4_port)
.then(unused_tcp4_port)
.transpose()?
.or(cli_args.port)
.unwrap_or(DEFAULT_TCP_PORT);
Expand All @@ -386,7 +389,7 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result<ListenAddress, Strin
// 4. If none of the above are set, use the default discovery port (DEFAULT_DISC_PORT).
let disc_port = cli_args
.use_zero_ports
.then(unused_port::unused_udp4_port)
.then(unused_udp4_port)
.transpose()?
.or(cli_args.discovery_port)
.or(cli_args.port)
Expand All @@ -397,7 +400,7 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result<ListenAddress, Strin
// 3. If none of the above are set, use the selected TCP port + 1.
let quic_port = cli_args
.use_zero_ports
.then(unused_port::unused_udp4_port)
.then(unused_udp4_port)
.transpose()?
.or(cli_args.quic_port)
.unwrap_or(if tcp_port == 0 { 0 } else { tcp_port + 1 });
Expand All @@ -412,20 +415,20 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result<ListenAddress, Strin
(Some(ipv4), Some(ipv6)) => {
let ipv4_tcp_port = cli_args
.use_zero_ports
.then(unused_port::unused_tcp4_port)
.then(unused_tcp4_port)
.transpose()?
.or(cli_args.port)
.unwrap_or(DEFAULT_TCP_PORT);
let ipv4_disc_port = cli_args
.use_zero_ports
.then(unused_port::unused_udp4_port)
.then(unused_udp4_port)
.transpose()?
.or(cli_args.discovery_port)
.or(cli_args.port)
.unwrap_or(DEFAULT_DISC_PORT);
let ipv4_quic_port = cli_args
.use_zero_ports
.then(unused_port::unused_udp4_port)
.then(unused_udp4_port)
.transpose()?
.or(cli_args.quic_port)
.unwrap_or(if ipv4_tcp_port == 0 {
Expand All @@ -436,19 +439,19 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result<ListenAddress, Strin

let ipv6_tcp_port = cli_args
.use_zero_ports
.then(unused_port::unused_tcp6_port)
.then(unused_tcp6_port)
.transpose()?
.or(cli_args.port6)
.unwrap_or(ipv4_tcp_port);
let ipv6_disc_port = cli_args
.use_zero_ports
.then(unused_port::unused_udp6_port)
.then(unused_udp6_port)
.transpose()?
.or(cli_args.discovery_port6)
.unwrap_or(ipv4_disc_port);
let ipv6_quic_port = cli_args
.use_zero_ports
.then(unused_port::unused_udp6_port)
.then(unused_udp6_port)
.transpose()?
.or(cli_args.quic_port6)
.unwrap_or(if ipv6_tcp_port == 0 {
Expand Down
2 changes: 1 addition & 1 deletion anchor/eth/src/event_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ macro_rules! impl_event_decoder {
type Output = $event_type;

fn decode_from_log(log: &Log) -> Result<Self::Output, ExecutionError> {
let decoded = Self::decode_log(&log.inner, true)
let decoded = Self::decode_log(&log.inner)
.map_err(|e| {
ExecutionError::DecodeError(
format!("Failed to decode {} event: {}", stringify!($event_type), e)
Expand Down
18 changes: 12 additions & 6 deletions anchor/eth/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,15 @@ impl SsvEventSyncer {

// Construct Websocket Provider
let ws = WsConnect::new(config.ws_url.full.as_str());
let ws_client = ProviderBuilder::default().on_ws(ws).await.map_err(|e| {
ExecutionError::SyncError(format!("Failed to bind to WS: {}, {}", &config.ws_url, e))
})?;
let ws_client = ProviderBuilder::default()
.connect_ws(ws)
.await
.map_err(|e| {
ExecutionError::SyncError(format!(
"Failed to bind to WS: {}, {}",
&config.ws_url, e
))
})?;
debug!("Created ws client");

// Construct an EventProcessor with access to the DB
Expand Down Expand Up @@ -161,15 +167,15 @@ impl SsvEventSyncer {
network: SsvNetworkConfig,
) -> Self {
let http_url: Url = rpc_endpoint.parse().expect("Failed to parse HTTP URL");
let rpc_client = ProviderBuilder::default().on_http(http_url.clone());
let rpc_client = ProviderBuilder::default().connect_http(http_url.clone());

let event_processor = EventProcessor::new(db, Mode::KeySplit);

// This does not perform a live sync, so we just want to mock websocket fields. This helps
// so that we dont have to switch the ws fields to Option and clutter up the rest of the
// application unnecessarily
let ws_url = String::from("");
let ws_client = ProviderBuilder::default().on_http(http_url);
let ws_client = ProviderBuilder::default().connect_http(http_url);

Self {
rpc_client,
Expand Down Expand Up @@ -269,7 +275,7 @@ impl SsvEventSyncer {

loop {
let ws = WsConnect::new(&self.ws_url);
if let Ok(ws_client) = ProviderBuilder::default().on_ws(ws).await {
if let Ok(ws_client) = ProviderBuilder::default().connect_ws(ws).await {
self.ws_client = ws_client;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion anchor/eth/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn provider_from_transports(

// Construct the final client
let client = RpcClient::builder().transport(transport, false);
ProviderBuilder::default().on_client(client)
ProviderBuilder::default().connect_client(client)
}

#[cfg(test)]
Expand Down
4 changes: 3 additions & 1 deletion anchor/http_metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ authors = ["Sigma Prime <[email protected]>"]
anchor_validator_store = { workspace = true }
axum = { workspace = true }
health_metrics = { workspace = true }
lighthouse_network = { workspace = true }
libp2p = { workspace = true, default-features = false, features = ["metrics"] }
metrics = { workspace = true }
network_utils = { workspace = true }
parking_lot = { workspace = true }
prometheus-client = { workspace = true }
serde = { workspace = true }
slot_clock = { workspace = true }
tokio = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions anchor/http_metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ use axum::{
response::{IntoResponse, Response},
routing::get,
};
use lighthouse_network::{libp2p::metrics::Registry, prometheus_client::encoding::text::encode};
use libp2p::metrics::Registry;
use parking_lot::RwLock;
use prometheus_client::encoding::text::encode;
use serde::{Deserialize, Serialize};
use slot_clock::{SlotClock, SystemTimeSlotClock};
use tokio::net::TcpListener;
Expand Down Expand Up @@ -128,7 +129,7 @@ async fn metrics_handler<E: EthSpec>(
}

health_metrics::metrics::scrape_health_metrics();
lighthouse_network::metrics::scrape_discovery_metrics();
network_utils::discovery_metrics::scrape_discovery_metrics();

if let Err(e) = encoder.encode_utf8(&gather(), &mut buffer) {
return (
Expand Down
10 changes: 6 additions & 4 deletions anchor/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ libp2p = { workspace = true, default-features = false, features = [
"quic",
"ping",
"request-response",
"dns",
] }
lighthouse_network = { workspace = true }
message_receiver = { workspace = true }
peer-store = { package = "libp2p-peer-store", git = "https://github.com/libp2p/rust-libp2p.git", rev = "082eb16" }
metrics = { workspace = true }
network_utils = { workspace = true }
peer-store = { package = "libp2p-peer-store", git = "https://github.com/libp2p/rust-libp2p.git", rev = "ad9a1b2" }
prometheus-client = { workspace = true }
quick-protobuf = "0.8.1"
rand = { workspace = true }
serde = { workspace = true }
serde_json = "1.0.137"
ssv_types = { workspace = true }
ssz_types = "0.10"
ssz_types = "0.11.0"
subnet_service = { workspace = true }
task_executor = { workspace = true }
thiserror = { workspace = true }
Expand All @@ -44,7 +46,7 @@ types = { workspace = true }
version = { workspace = true }

[dev-dependencies]
libp2p-swarm-test = "0.5.0"
libp2p-swarm-test = "0.6.0"
message_receiver = { workspace = true }
tokio = { workspace = true, features = ["rt", "macros", "time", "test-util"] }
tracing-subscriber = { workspace = true }
16 changes: 7 additions & 9 deletions anchor/network/src/behaviour.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::time::Duration;

use discv5::enr::k256::sha2::{Digest, Sha256};
use gossipsub::{ConfigBuilderError, MessageAuthenticity, ValidationMode};
use libp2p::{identify, ping, swarm::NetworkBehaviour};
use lighthouse_network::{
discv5::enr::k256::sha2::{Digest, Sha256},
prometheus_client::registry::Registry,
};
use prometheus_client::registry::Registry;
use thiserror::Error;
use types::{ChainSpec, EthSpec};
use version::version_with_platform;
Expand Down Expand Up @@ -96,13 +94,13 @@ impl AnchorBehaviour {
.validate_messages()
.build()?;

let mut gossipsub = gossipsub::Behaviour::new_with_metrics(
MessageAuthenticity::RandomAuthor,
gossipsub_config,
let mut gossipsub =
gossipsub::Behaviour::new(MessageAuthenticity::RandomAuthor, gossipsub_config)
.map_err(|e| Gossipsub(e.to_string()))?;
gossipsub = gossipsub.with_metrics(
metrics_registry.sub_registry_with_prefix("gossipsub"),
gossipsub::MetricsConfig::default(),
)
.map_err(|e| Gossipsub(e.to_string()))?;
);

// Add peer scoring if not disabled
if !network_config.disable_gossipsub_peer_scoring {
Expand Down
2 changes: 1 addition & 1 deletion anchor/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
use discv5::Enr;
use global_config::data_dir::NetworkDir;
use libp2p::Multiaddr;
use lighthouse_network::{ListenAddr, ListenAddress};
use network_utils::listen_addr::{ListenAddr, ListenAddress};
use ssv_types::domain_type::DomainType;

/// This is a default network directory, but it will be overridden by the cli defaults.
Expand Down
Loading