From 4c55b033faf23442fdfe2f1ab56c8533670b22a4 Mon Sep 17 00:00:00 2001 From: Mac L Date: Fri, 23 Aug 2024 00:41:11 +1000 Subject: [PATCH] Allow VC to detect when BN comes online --- validator_client/src/beacon_node_fallback.rs | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/validator_client/src/beacon_node_fallback.rs b/validator_client/src/beacon_node_fallback.rs index fe825c757a..cf3f6c71f5 100644 --- a/validator_client/src/beacon_node_fallback.rs +++ b/validator_client/src/beacon_node_fallback.rs @@ -195,14 +195,18 @@ impl CandidateBeaconNode { match check_node_health(&self.beacon_node, log).await { Ok((head, is_optimistic, el_offline)) => { let Some(slot_clock_head) = slot_clock.now() else { - match slot_clock.is_prior_to_genesis() { - Some(true) => return Err(CandidateError::PreGenesis), - _ => return Err(CandidateError::Uninitialized), - } + let e = match slot_clock.is_prior_to_genesis() { + Some(true) => CandidateError::PreGenesis, + _ => CandidateError::Uninitialized, + }; + *self.health.write().await = Err(e); + return Err(e); }; if head > slot_clock_head + FUTURE_SLOT_TOLERANCE { - return Err(CandidateError::TimeDiscrepancy); + let e = CandidateError::TimeDiscrepancy; + *self.health.write().await = Err(e); + return Err(e); } let sync_distance = slot_clock_head.saturating_sub(head); @@ -239,8 +243,9 @@ impl CandidateBeaconNode { } } else { // Slot clock will only be `None` at startup. - // Assume compatible nodes are available. - Ok(()) + let e = CandidateError::Uninitialized; + *self.health.write().await = Err(e); + Err(e) } } @@ -449,7 +454,7 @@ impl BeaconNodeFallback { if *e != CandidateError::PreGenesis { warn!( self.log, - "A connected beacon node errored during routine health check."; + "A connected beacon node errored during routine health check"; "error" => ?e, "endpoint" => node, );