use head slot instead of the target slot for the not_while_syncing fi… (#1802)
## 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
This commit is contained in:
parent
02d94a70b7
commit
fdb9744759
@ -290,7 +290,9 @@ pub fn serve<T: BeaconChainTypes>(
|
|||||||
.and_then(
|
.and_then(
|
||||||
|network_globals: Arc<NetworkGlobals<T::EthSpec>>, chain: Arc<BeaconChain<T>>| async move {
|
|network_globals: Arc<NetworkGlobals<T::EthSpec>>, chain: Arc<BeaconChain<T>>| async move {
|
||||||
match *network_globals.sync_state.read() {
|
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
|
let current_slot = chain
|
||||||
.slot_clock
|
.slot_clock
|
||||||
.now_or_genesis()
|
.now_or_genesis()
|
||||||
@ -302,12 +304,12 @@ pub fn serve<T: BeaconChainTypes>(
|
|||||||
|
|
||||||
let tolerance = SYNC_TOLERANCE_EPOCHS * T::EthSpec::slots_per_epoch();
|
let tolerance = SYNC_TOLERANCE_EPOCHS * T::EthSpec::slots_per_epoch();
|
||||||
|
|
||||||
if target_slot + tolerance >= current_slot {
|
if head_slot + tolerance >= current_slot {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(warp_utils::reject::not_synced(format!(
|
Err(warp_utils::reject::not_synced(format!(
|
||||||
"head slot is {}, current slot is {}",
|
"head slot is {}, current slot is {}",
|
||||||
target_slot, current_slot
|
head_slot, current_slot
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user