Skip to content

Commit 23ad833

Browse files
authored
Change default EngineState to online (#7417)
Resolves #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.
1 parent 1d27855 commit 23ad833

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

beacon_node/execution_layer/src/engines.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const CACHED_RESPONSE_AGE_LIMIT: Duration = Duration::from_secs(900); // 15 minu
2626
/// Stores the remembered state of a engine.
2727
#[derive(Copy, Clone, PartialEq, Debug, Eq, Default)]
2828
enum EngineStateInternal {
29-
Synced,
3029
#[default]
30+
Synced,
3131
Offline,
3232
Syncing,
3333
AuthFailed,
@@ -403,12 +403,17 @@ mod tests {
403403
async fn test_state_notifier() {
404404
let mut state = State::default();
405405
let initial_state: EngineState = state.state.into();
406-
assert_eq!(initial_state, EngineState::Offline);
407-
state.update(EngineStateInternal::Synced);
406+
// default state is online
407+
assert_eq!(initial_state, EngineState::Online);
408408

409409
// a watcher that arrives after the first update.
410410
let mut watcher = state.watch();
411411
let new_state = watcher.next().await.expect("Last state is always present");
412412
assert_eq!(new_state, EngineState::Online);
413+
414+
// update to offline
415+
state.update(EngineStateInternal::Offline);
416+
let new_state = watcher.next().await.expect("Last state is always present");
417+
assert_eq!(new_state, EngineState::Offline);
413418
}
414419
}

beacon_node/http_api/tests/tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,7 +2475,7 @@ impl ApiTester {
24752475
is_syncing: false,
24762476
is_optimistic: false,
24772477
// these tests run without the Bellatrix fork enabled
2478-
el_offline: true,
2478+
el_offline: false,
24792479
head_slot,
24802480
sync_distance,
24812481
};
@@ -2539,11 +2539,11 @@ impl ApiTester {
25392539
pub async fn test_get_node_health(self) -> Self {
25402540
let status = self.client.get_node_health().await;
25412541
match status {
2542-
Ok(_) => {
2543-
panic!("should return 503 error status code");
2542+
Ok(status) => {
2543+
assert_eq!(status, 200);
25442544
}
2545-
Err(e) => {
2546-
assert_eq!(e.status().unwrap(), 503);
2545+
Err(_) => {
2546+
panic!("should return valid status");
25472547
}
25482548
}
25492549
self

0 commit comments

Comments
 (0)