From fdb9744759245f1df5df4d5b25a27bbfef70aebe Mon Sep 17 00:00:00 2001 From: realbigsean Date: Wed, 21 Oct 2020 22:02:25 +0000 Subject: [PATCH] =?UTF-8?q?use=20head=20slot=20instead=20of=20the=20target?= =?UTF-8?q?=20slot=20for=20the=20not=5Fwhile=5Fsyncing=20fi=E2=80=A6=20(#1?= =?UTF-8?q?802)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Issue Addressed Resolves #1792 ## Proposed Changes Use `chain.best_slot()` instead of the sync state's target slot in the `not_while_syncing_filter` ## Additional Info N/A --- beacon_node/http_api/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 ))) } }