align default `syncHorizon` computation logic across networks (#6066)

The `syncHorizon` describes the number of empty slots before the beacon
node considers itself to be out of sync. There are two places where we
currently set this to 50 slots, but it makes more sense to base it on
wall time, e.g., the 10 minutes that the default 50 are derived from.
This commit is contained in:
Etan Kissling 2024-03-12 21:51:18 +01:00 committed by GitHub
parent e56190c7aa
commit 8bd8ffe2bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 8 deletions

View File

@ -5,6 +5,8 @@
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [].}
# Everything needed to run a full Beacon Node
import
@ -103,9 +105,6 @@ type
processingDelay*: Opt[Duration]
lastValidAttestedBlock*: Opt[BlockSlot]
const
MaxEmptySlotCount* = uint64(10*60) div SECONDS_PER_SLOT
# TODO stew/sequtils2
template findIt*(s: openArray, predicate: untyped): int =
var res = -1

View File

@ -586,9 +586,9 @@ type
syncHorizon* {.
hidden
desc: "Number of empty slots to process before considering the client out of sync"
defaultValue: MaxEmptySlotCount
defaultValueDesc: "50"
desc: "Number of empty slots to process before considering the client out of sync. Defaults to the number of slots in 10 minutes"
defaultValue: defaultSyncHorizon
defaultValueDesc: $defaultSyncHorizon
name: "sync-horizon" .}: uint64
terminalTotalDifficultyOverride* {.

View File

@ -278,8 +278,6 @@ func isSynced(dag: ChainDAGRef, wallSlot: Slot): bool =
# the defaultSyncHorizon, it will start triggering in time so that potential
# discrepancies between the head here, and the head the DAG has (which might
# not yet be updated) won't be visible.
const defaultSyncHorizon = 50
if dag.head.slot + defaultSyncHorizon < wallSlot:
false
else:

View File

@ -278,3 +278,6 @@ chronicles.formatIt TimeDiff: it.shortLog
chronicles.formatIt Slot: it.shortLog
chronicles.formatIt Epoch: it.shortLog
chronicles.formatIt SyncCommitteePeriod: it.shortLog
const defaultSyncHorizon* =
(uint64(10*60) + SECONDS_PER_SLOT - 1) div SECONDS_PER_SLOT