diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index ee619142b..28cb38a24 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -290,7 +290,9 @@ pub fn serve( .and_then( |network_globals: Arc>, chain: Arc>| async move { match *network_globals.sync_state.read() { - SyncState::SyncingFinalized { target_slot, .. } => { + SyncState::SyncingFinalized { .. } => { + let head_slot = chain.best_slot().map_err(warp_utils::reject::beacon_chain_error)?; + let current_slot = chain .slot_clock .now_or_genesis() @@ -302,12 +304,12 @@ pub fn serve( let tolerance = SYNC_TOLERANCE_EPOCHS * T::EthSpec::slots_per_epoch(); - if target_slot + tolerance >= current_slot { + if head_slot + tolerance >= current_slot { Ok(()) } else { Err(warp_utils::reject::not_synced(format!( "head slot is {}, current slot is {}", - target_slot, current_slot + head_slot, current_slot ))) } }