mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 17:26:04 +00:00
Move notifier and latency service to validator_services
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -9819,6 +9819,7 @@ dependencies = [
|
|||||||
"parking_lot 0.12.3",
|
"parking_lot 0.12.3",
|
||||||
"safe_arith",
|
"safe_arith",
|
||||||
"slot_clock",
|
"slot_clock",
|
||||||
|
"task_executor",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tree_hash",
|
"tree_hash",
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
pub mod cli;
|
pub mod cli;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
mod latency;
|
|
||||||
mod notifier;
|
|
||||||
|
|
||||||
use crate::cli::ValidatorClient;
|
use crate::cli::ValidatorClient;
|
||||||
pub use config::Config;
|
pub use config::Config;
|
||||||
@@ -20,7 +18,6 @@ use doppelganger_service::DoppelgangerService;
|
|||||||
use environment::RuntimeContext;
|
use environment::RuntimeContext;
|
||||||
use eth2::{reqwest::ClientBuilder, BeaconNodeHttpClient, StatusCode, Timeouts};
|
use eth2::{reqwest::ClientBuilder, BeaconNodeHttpClient, StatusCode, Timeouts};
|
||||||
use initialized_validators::Error::UnableToOpenVotingKeystore;
|
use initialized_validators::Error::UnableToOpenVotingKeystore;
|
||||||
use notifier::spawn_notifier;
|
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use reqwest::Certificate;
|
use reqwest::Certificate;
|
||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
@@ -39,10 +36,12 @@ use tokio::{
|
|||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, info, warn};
|
||||||
use types::{EthSpec, Hash256};
|
use types::{EthSpec, Hash256};
|
||||||
use validator_http_api::ApiSecret;
|
use validator_http_api::ApiSecret;
|
||||||
|
use validator_services::notifier_service::spawn_notifier;
|
||||||
use validator_services::{
|
use validator_services::{
|
||||||
attestation_service::{AttestationService, AttestationServiceBuilder},
|
attestation_service::{AttestationService, AttestationServiceBuilder},
|
||||||
block_service::{BlockService, BlockServiceBuilder},
|
block_service::{BlockService, BlockServiceBuilder},
|
||||||
duties_service::{self, DutiesService},
|
duties_service::{self, DutiesService},
|
||||||
|
latency_service,
|
||||||
preparation_service::{PreparationService, PreparationServiceBuilder},
|
preparation_service::{PreparationService, PreparationServiceBuilder},
|
||||||
sync::SyncDutiesMap,
|
sync::SyncDutiesMap,
|
||||||
sync_committee_service::SyncCommitteeService,
|
sync_committee_service::SyncCommitteeService,
|
||||||
@@ -600,11 +599,17 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
|
|||||||
info!("Doppelganger protection disabled.")
|
info!("Doppelganger protection disabled.")
|
||||||
}
|
}
|
||||||
|
|
||||||
spawn_notifier(self).map_err(|e| format!("Failed to start notifier: {}", e))?;
|
let context = self.context.service_context("notifier".into());
|
||||||
|
spawn_notifier(
|
||||||
|
self.duties_service.clone(),
|
||||||
|
context.executor,
|
||||||
|
&self.context.eth2_config.spec,
|
||||||
|
)
|
||||||
|
.map_err(|e| format!("Failed to start notifier: {}", e))?;
|
||||||
|
|
||||||
if self.config.enable_latency_measurement_service {
|
if self.config.enable_latency_measurement_service {
|
||||||
latency::start_latency_service(
|
latency_service::start_latency_service(
|
||||||
self.context.clone(),
|
self.context.executor.clone(),
|
||||||
self.duties_service.slot_clock.clone(),
|
self.duties_service.slot_clock.clone(),
|
||||||
self.duties_service.beacon_nodes.clone(),
|
self.duties_service.beacon_nodes.clone(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ logging = { workspace = true }
|
|||||||
parking_lot = { workspace = true }
|
parking_lot = { workspace = true }
|
||||||
safe_arith = { workspace = true }
|
safe_arith = { workspace = true }
|
||||||
slot_clock = { workspace = true }
|
slot_clock = { workspace = true }
|
||||||
|
task_executor = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
tree_hash = { workspace = true }
|
tree_hash = { workspace = true }
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use beacon_node_fallback::BeaconNodeFallback;
|
use beacon_node_fallback::BeaconNodeFallback;
|
||||||
use environment::RuntimeContext;
|
|
||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use task_executor::TaskExecutor;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use types::EthSpec;
|
use types::EthSpec;
|
||||||
@@ -13,7 +13,7 @@ pub const SLOT_DELAY_DENOMINATOR: u32 = 12;
|
|||||||
/// Starts a service that periodically checks the latency between the VC and the
|
/// Starts a service that periodically checks the latency between the VC and the
|
||||||
/// candidate BNs.
|
/// candidate BNs.
|
||||||
pub fn start_latency_service<T: SlotClock + 'static, E: EthSpec>(
|
pub fn start_latency_service<T: SlotClock + 'static, E: EthSpec>(
|
||||||
context: RuntimeContext<E>,
|
executor: TaskExecutor,
|
||||||
slot_clock: T,
|
slot_clock: T,
|
||||||
beacon_nodes: Arc<BeaconNodeFallback<T, E>>,
|
beacon_nodes: Arc<BeaconNodeFallback<T, E>>,
|
||||||
) {
|
) {
|
||||||
@@ -57,5 +57,5 @@ pub fn start_latency_service<T: SlotClock + 'static, E: EthSpec>(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
context.executor.spawn(future, "latency");
|
executor.spawn(future, "latency");
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
pub mod attestation_service;
|
pub mod attestation_service;
|
||||||
pub mod block_service;
|
pub mod block_service;
|
||||||
pub mod duties_service;
|
pub mod duties_service;
|
||||||
|
pub mod latency_service;
|
||||||
|
pub mod notifier_service;
|
||||||
pub mod preparation_service;
|
pub mod preparation_service;
|
||||||
pub mod sync;
|
pub mod sync;
|
||||||
pub mod sync_committee_service;
|
pub mod sync_committee_service;
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
use crate::{DutiesService, ProductionValidatorClient};
|
use crate::duties_service::DutiesService;
|
||||||
use metrics::set_gauge;
|
|
||||||
use slot_clock::SlotClock;
|
use slot_clock::SlotClock;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use task_executor::TaskExecutor;
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
use tracing::{debug, error, info};
|
use tracing::{debug, error, info};
|
||||||
use types::EthSpec;
|
use types::{ChainSpec, EthSpec};
|
||||||
|
use validator_metrics::set_gauge;
|
||||||
|
|
||||||
/// Spawns a notifier service which periodically logs information about the node.
|
/// Spawns a notifier service which periodically logs information about the node.
|
||||||
pub fn spawn_notifier<E: EthSpec>(client: &ProductionValidatorClient<E>) -> Result<(), String> {
|
pub fn spawn_notifier<T: SlotClock + 'static, E: EthSpec>(
|
||||||
let context = client.context.service_context("notifier".into());
|
duties_service: Arc<DutiesService<T, E>>,
|
||||||
let executor = context.executor.clone();
|
executor: TaskExecutor,
|
||||||
let duties_service = client.duties_service.clone();
|
spec: &ChainSpec,
|
||||||
|
) -> Result<(), String> {
|
||||||
let slot_duration = Duration::from_secs(context.eth2_config.spec.seconds_per_slot);
|
let slot_duration = Duration::from_secs(spec.seconds_per_slot);
|
||||||
|
|
||||||
let interval_fut = async move {
|
let interval_fut = async move {
|
||||||
loop {
|
loop {
|
||||||
Reference in New Issue
Block a user