From 23ad833747b69756c375c24cbd4e8f6fa58dab42 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Fri, 16 May 2025 12:04:30 -0700 Subject: [PATCH] Change default EngineState to online (#7417) Resolves https://github.com/sigp/lighthouse/issues/7414 The health endpoint returns a 503 if the engine state is offline. The default state for the engine is `Offline`. So until the first request to the EL is made and the state is updated, the health endpoint will keep returning 503s. This PR changes the default state to Online to avoid that. I don't think this causes any issues because in case the EL is actually offline, the first fcu will set the state to offline. Pending testing on kurtosis. --- beacon_node/execution_layer/src/engines.rs | 11 ++++++++--- beacon_node/http_api/tests/tests.rs | 10 +++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/beacon_node/execution_layer/src/engines.rs b/beacon_node/execution_layer/src/engines.rs index b9e030703d..c46a94c5af 100644 --- a/beacon_node/execution_layer/src/engines.rs +++ b/beacon_node/execution_layer/src/engines.rs @@ -26,8 +26,8 @@ const CACHED_RESPONSE_AGE_LIMIT: Duration = Duration::from_secs(900); // 15 minu /// Stores the remembered state of a engine. #[derive(Copy, Clone, PartialEq, Debug, Eq, Default)] enum EngineStateInternal { - Synced, #[default] + Synced, Offline, Syncing, AuthFailed, @@ -403,12 +403,17 @@ mod tests { async fn test_state_notifier() { let mut state = State::default(); let initial_state: EngineState = state.state.into(); - assert_eq!(initial_state, EngineState::Offline); - state.update(EngineStateInternal::Synced); + // default state is online + assert_eq!(initial_state, EngineState::Online); // a watcher that arrives after the first update. let mut watcher = state.watch(); let new_state = watcher.next().await.expect("Last state is always present"); assert_eq!(new_state, EngineState::Online); + + // update to offline + state.update(EngineStateInternal::Offline); + let new_state = watcher.next().await.expect("Last state is always present"); + assert_eq!(new_state, EngineState::Offline); } } diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 5c9504d4a5..b2b9ab8d09 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -2475,7 +2475,7 @@ impl ApiTester { is_syncing: false, is_optimistic: false, // these tests run without the Bellatrix fork enabled - el_offline: true, + el_offline: false, head_slot, sync_distance, }; @@ -2539,11 +2539,11 @@ impl ApiTester { pub async fn test_get_node_health(self) -> Self { let status = self.client.get_node_health().await; match status { - Ok(_) => { - panic!("should return 503 error status code"); + Ok(status) => { + assert_eq!(status, 200); } - Err(e) => { - assert_eq!(e.status().unwrap(), 503); + Err(_) => { + panic!("should return valid status"); } } self