Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
02c139b
feat(validator): check each beacon node's sync status before every sl…
MegaRedHand Nov 24, 2026
a65fcaf
fix(validator): keep a slot open for a synced node still answering it…
MegaRedHand Nov 25, 2026
3c95556
fix(validator): ask the ungated calls only of a node whose probe answ…
MegaRedHand Nov 25, 2026
cded590
feat(validator): rank beacon nodes by health and broadcast signed mes…
MegaRedHand Nov 25, 2026
c418811
fix(validator): rank a syncing node last inside its tier, send a blob…
MegaRedHand Nov 25, 2026
f92a870
fix(validator): stop a broadcast waiting on a hung node, keep the bar…
MegaRedHand Nov 25, 2026
dd613c2
feat(validator): make /health report whether the client can do its du…
MegaRedHand Nov 25, 2026
8d4e5bf
fix(validator): report unhealthy once the last duty schedule has run out
MegaRedHand Nov 25, 2026
0256e84
fix(validator): judge the health schedule check by the epochs actuall…
MegaRedHand Nov 25, 2026
0e4626e
fix(validator): keep a client with no resolved validator schedule-cur…
MegaRedHand Nov 25, 2026
8d99164
feat(validator): warn when the local clock disagrees with a beacon no…
MegaRedHand Nov 25, 2026
21e9310
fix(validator): age out old Date samples, drop a silent node's offset…
MegaRedHand Nov 25, 2026
5325408
fix(validator): ignore slot disagreements of a few milliseconds, corr…
MegaRedHand Nov 25, 2026
3cc79bb
Merge remote-tracking branch 'origin/main' into feat/validator-per-sl…
MegaRedHand Nov 25, 2026
4a3b4b7
Merge branch 'feat/validator-per-slot-sync-check' into feat/validator…
MegaRedHand Nov 25, 2026
e28158a
Merge branch 'feat/validator-node-ranking' into feat/validator-health…
MegaRedHand Nov 25, 2026
c196d62
Merge branch 'feat/validator-health-endpoint' into feat/validator-clo…
MegaRedHand Nov 25, 2026
7dd7430
test(validator): load a key in the sync-gate issue-case tests
pablodeymo Nov 25, 2026
db433ad
Merge remote-tracking branch 'origin/main' into feat/validator-per-sl…
pablodeymo Nov 25, 2026
37dd4b4
Merge remote-tracking branch 'origin/feat/validator-per-slot-sync-che…
pablodeymo Nov 25, 2026
69077e0
Merge branch 'feat/validator-node-ranking' into feat/validator-health…
pablodeymo Nov 25, 2026
aedcc4b
Merge branch 'feat/validator-health-endpoint' into feat/validator-clo…
pablodeymo Nov 25, 2026
f008f6b
Merge remote-tracking branch 'origin/main' into feat/validator-node-r…
pablodeymo Nov 25, 2026
e438896
Merge branch 'feat/validator-node-ranking' into feat/validator-health…
MegaRedHand Nov 25, 2026
ce00942
Merge branch 'feat/validator-health-endpoint' into feat/validator-clo…
MegaRedHand Nov 25, 2026
fd499a0
fix(validator): don't rank a slow node failing after a broadcast cuts…
pablodeymo Nov 26, 2026
4993d76
Merge remote-tracking branch 'origin/main' into feat/validator-node-r…
pablodeymo Nov 26, 2026
6e5c922
Merge remote-tracking branch 'origin/main' into feat/validator-node-r…
pablodeymo Nov 26, 2026
42dcaa3
Merge branch 'feat/validator-node-ranking' into feat/validator-health…
MegaRedHand Nov 26, 2026
2937205
Merge branch 'feat/validator-health-endpoint' into feat/validator-clo…
MegaRedHand Nov 26, 2026
cb0f391
Merge branch 'main' into feat/validator-clock-skew
MegaRedHand Nov 26, 2026
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
8 changes: 4 additions & 4 deletions crates/common/metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ pub mod timing;

// Re-export prometheus types and macros we use
pub use prometheus::{
Encoder, Error as PrometheusError, Histogram, HistogramVec, IntCounter, IntCounterVec,
IntGauge, IntGaugeVec, TextEncoder, core::Collector, gather, register_histogram,
register_histogram_vec, register_int_counter, register_int_counter_vec, register_int_gauge,
register_int_gauge_vec,
Encoder, Error as PrometheusError, GaugeVec, Histogram, HistogramVec, IntCounter,
IntCounterVec, IntGauge, IntGaugeVec, TextEncoder, core::Collector, gather, register_gauge_vec,
register_histogram, register_histogram_vec, register_int_counter, register_int_counter_vec,
register_int_gauge, register_int_gauge_vec,
};

// Re-export commonly used items
Expand Down
25 changes: 20 additions & 5 deletions crates/validator/src/beacon_node/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ use crate::beacon_node::dto::{
CommitteeSubscriptionDto, ProposerPreparationDto, SingleAttestationDto,
SyncCommitteeSubscriptionDto, SyncDutyDto,
};
use crate::beacon_node::health::{NodeHealth, Probe, Standing, SyncStatus, SyncVerdict, Tier};
use crate::beacon_node::health::{
NodeHealth, Probe, Reply, Standing, SyncStatus, SyncVerdict, Tier,
};
use crate::beacon_node::{
AggregateAttestation, AttesterDuties, BeaconNodeApi, BlockRequest, Delivery, Genesis, Liveness,
ProposerDuties, PtcDuties, Published, SignedAggregates, ValidatorDetails, ValidatorEntry,
Expand Down Expand Up @@ -382,11 +384,24 @@ impl<B: BeaconNodeApi> FallbackBeaconNode<B> {
let health = &self.health;
let asks = self.usable_nodes().map(|(position, node)| async move {
let at = SystemTime::now();
let outcome = match tokio::time::timeout(budget, node.sync_status()).await {
Ok(answer) => answer.map_err(|err| err.to_string()),
Err(_) => Err(format!("no answer within {} ms", budget.as_millis())),
let answer = tokio::time::timeout(budget, node.sync_status_with_date()).await;
// Stamped here, as the answer lands, for the clock check.
let received = SystemTime::now();
let (outcome, reply) = match answer {
Ok(Ok((status, date))) => (Ok(status), Some(Reply { received, date })),
Ok(Err(err)) => (Err(err.to_string()), None),
Err(_) => (
Err(format!("no answer within {} ms", budget.as_millis())),
None,
),
};
let probe = Probe {
slot,
at,
outcome,
reply,
};
health.record(position, Probe { slot, at, outcome });
health.record(position, probe);
});
futures_util::future::join_all(asks).await;
}
Expand Down
24 changes: 22 additions & 2 deletions crates/validator/src/beacon_node/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@
//! `is_syncing` and `is_optimistic`, nothing else. `sync_distance`, which is the
//! node's own clock against its head, only orders the walk: in a stall every
//! node is behind by about as much, so they share a tier and keep command-line
//! order. A record older than two slots is no longer read for routing, which
//! only ever moves a node back to plain command-line order.
//! order. The clock check ([`crate::clock_check`]) reads `head_slot` and
//! `sync_distance` too, after each round, to compare the node's clock with
//! this client's, and only warns. A record older than two slots is no longer
//! read for routing, which only ever moves a node back to plain command-line
//! order.

use std::sync::{Arc, OnceLock, PoisonError, RwLock};
use std::time::{Duration, SystemTime};
Expand All @@ -64,6 +67,7 @@ use tracing::{info, warn};

use crate::beacon_node::BeaconNodeApi;
use crate::beacon_node::fallback::FallbackBeaconNode;
use crate::clock_check::ClockWatch;
use crate::error::{BeaconNodeFailure, Error};
use crate::slot_clock::SlotClock;

Expand Down Expand Up @@ -132,6 +136,19 @@ pub struct Probe {
/// The node's answer, or why there is none: an error, or no answer within
/// the probe's budget.
pub outcome: Result<SyncStatus, String>,
/// When the answer came back, and the `Date` header it carried, for the
/// clock check ([`crate::clock_check`]). `None` when there was no answer.
pub reply: Option<Reply>,
}

/// When a probe's answer came back, and what time the node's HTTP server said
/// it was.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Reply {
pub received: SystemTime,
/// The answer's `Date` header. `None` when it carried none, or one that is
/// not an IMF-fixdate.
pub date: Option<SystemTime>,
}

impl Probe {
Expand Down Expand Up @@ -614,6 +631,7 @@ pub async fn run<B: BeaconNodeApi>(beacon_node: Arc<FallbackBeaconNode<B>>, cloc
beacon_node
.health()
.expire_after(clock.slot_duration() * ROUTING_SLOTS);
let mut clocks = ClockWatch::new(clock.clone());
let mut last = None;
loop {
let (slot, wait) = next_probe(&clock, last, SystemTime::now());
Expand All @@ -624,6 +642,7 @@ pub async fn run<B: BeaconNodeApi>(beacon_node: Arc<FallbackBeaconNode<B>>, cloc
.duration_since(SystemTime::now())
.unwrap_or_default();
beacon_node.probe(slot, budget).await;
clocks.observe(slot, &beacon_node.health().snapshot());
last = Some(slot);
}
}
Expand Down Expand Up @@ -676,6 +695,7 @@ mod tests {
slot,
at: SystemTime::now(),
outcome,
reply: None,
}
}

Expand Down
52 changes: 50 additions & 2 deletions crates/validator/src/beacon_node/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
//! `Error::Decode`. Reading through `reqwest`'s own `json` would let its
//! `is_decode` compete with `Error::Decode` for the same failure.

use std::time::Duration;
use std::time::{Duration, SystemTime};

use async_trait::async_trait;
use ethlambda_types::beacon::builder::SignedValidatorRegistrationV1;
Expand Down Expand Up @@ -253,6 +253,16 @@ impl HttpBeaconNode {
}

async fn get<T: serde::de::DeserializeOwned>(&self, path: &str) -> Result<T> {
self.get_dated(path).await.map(|(value, _)| value)
}

/// [`Self::get`], with the answer's `Date` header when it is an
/// IMF-fixdate. Read on the sync probe's request alone (see
/// [`crate::clock_check`]).
async fn get_dated<T: serde::de::DeserializeOwned>(
&self,
path: &str,
) -> Result<(T, Option<SystemTime>)> {
let url = format!("{}{path}", self.base_url);
debug!(%url, "Beacon API GET");
let response = self
Expand All @@ -265,7 +275,12 @@ impl HttpBeaconNode {
failure: BeaconNodeFailure::classify(&err),
detail: err.to_string(),
})?;
Self::decode(response).await
let date = response
.headers()
.get(reqwest::header::DATE)
.and_then(|value| value.to_str().ok())
.and_then(crate::clock_check::parse_http_date);
Ok((Self::decode(response).await?, date))
}

async fn post<B: Serialize, T: serde::de::DeserializeOwned>(
Expand Down Expand Up @@ -1033,6 +1048,13 @@ impl BeaconNodeApi for HttpBeaconNode {
Ok(response.data.into())
}

/// Logs nothing, as [`Self::sync_status`].
async fn sync_status_with_date(&self) -> Result<(SyncStatus, Option<SystemTime>)> {
let (response, date): (DataResponse<SyncingDto>, _) =
self.get_dated("/eth/v1/node/syncing").await?;
Ok((response.data.into(), date))
}

/// Resolves each pubkey to its validator index and current status.
async fn validator_indices(&self, pubkeys: &[BlsPubkey]) -> Result<Vec<ValidatorEntry>> {
// See the contract on the trait: an empty list means "every validator"
Expand Down Expand Up @@ -2759,6 +2781,32 @@ mod tests {
assert!(!status.el_offline);
}

/// The probe's request reads the answer's `Date`, and one that is not an
/// IMF-fixdate is no `Date`.
#[tokio::test]
async fn the_sync_status_with_date_reads_the_date_header() {
let reply = br#"{"data":{"head_slot":"640","sync_distance":"0","is_syncing":false}}"#;
let headers = vec![
("content-type", "application/json"),
("date", "Sun, 06 Nov 1994 08:49:37 GMT"),
];
let served = serve(200, headers, reply.to_vec()).await;
let (status, date) = served.node.sync_status_with_date().await.expect("decodes");
assert_eq!(status.head_slot, Some(640));
assert_eq!(
date,
Some(std::time::UNIX_EPOCH + Duration::from_secs(784_111_777))
);

let headers = vec![
("content-type", "application/json"),
("date", "Sunday, 06-Nov-94 08:49:37 GMT"),
];
let served = serve(200, headers, reply.to_vec()).await;
let (_, date) = served.node.sync_status_with_date().await.expect("decodes");
assert_eq!(date, None);
}

#[tokio::test]
async fn v2_proposer_duties_use_the_v2_path() {
let reply = br#"{"dependent_root":"0x0909090909090909090909090909090909090909090909090909090909090909","execution_optimistic":false,"data":[]}"#.to_vec();
Expand Down
11 changes: 11 additions & 0 deletions crates/validator/src/beacon_node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//! `reqwest` from inside the duty logic, makes the interesting behaviour
//! (a reorg invalidating duties, a node failing mid-slot) untestable.

use std::time::SystemTime;

use async_trait::async_trait;
use ethlambda_types::beacon::builder::SignedValidatorRegistrationV1;
use ethlambda_types::beacon::config::Config;
Expand Down Expand Up @@ -440,6 +442,15 @@ pub trait BeaconNodeApi: Send + Sync {
/// node.
async fn sync_status(&self) -> Result<SyncStatus>;

/// [`Self::sync_status`], with the answer's `Date` header when it carried
/// an IMF-fixdate: what [`health`]'s per-slot probe actually asks, so
/// [`crate::clock_check`] can compare this client's clock with the node's.
/// A node with no such header to give answers `None`, which leaves that
/// node to the slot comparison alone.
async fn sync_status_with_date(&self) -> Result<(SyncStatus, Option<SystemTime>)> {
Ok((self.sync_status().await?, None))
}

/// Resolves each pubkey to its current validator index and status, so the
/// rest of the client can address validators by index, as the Beacon API
/// does everywhere except this one lookup.
Expand Down
1 change: 1 addition & 0 deletions crates/validator/src/client_health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ mod tests {
slot: 10,
at: SystemTime::now(),
outcome,
reply: None,
}
}

Expand Down
Loading
Loading