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:
parent
e56190c7aa
commit
8bd8ffe2bb
|
@ -5,6 +5,8 @@
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * 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.
|
# 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
|
# Everything needed to run a full Beacon Node
|
||||||
|
|
||||||
import
|
import
|
||||||
|
@ -103,9 +105,6 @@ type
|
||||||
processingDelay*: Opt[Duration]
|
processingDelay*: Opt[Duration]
|
||||||
lastValidAttestedBlock*: Opt[BlockSlot]
|
lastValidAttestedBlock*: Opt[BlockSlot]
|
||||||
|
|
||||||
const
|
|
||||||
MaxEmptySlotCount* = uint64(10*60) div SECONDS_PER_SLOT
|
|
||||||
|
|
||||||
# TODO stew/sequtils2
|
# TODO stew/sequtils2
|
||||||
template findIt*(s: openArray, predicate: untyped): int =
|
template findIt*(s: openArray, predicate: untyped): int =
|
||||||
var res = -1
|
var res = -1
|
||||||
|
|
|
@ -586,9 +586,9 @@ type
|
||||||
|
|
||||||
syncHorizon* {.
|
syncHorizon* {.
|
||||||
hidden
|
hidden
|
||||||
desc: "Number of empty slots to process before considering the client out of sync"
|
desc: "Number of empty slots to process before considering the client out of sync. Defaults to the number of slots in 10 minutes"
|
||||||
defaultValue: MaxEmptySlotCount
|
defaultValue: defaultSyncHorizon
|
||||||
defaultValueDesc: "50"
|
defaultValueDesc: $defaultSyncHorizon
|
||||||
name: "sync-horizon" .}: uint64
|
name: "sync-horizon" .}: uint64
|
||||||
|
|
||||||
terminalTotalDifficultyOverride* {.
|
terminalTotalDifficultyOverride* {.
|
||||||
|
|
|
@ -278,8 +278,6 @@ func isSynced(dag: ChainDAGRef, wallSlot: Slot): bool =
|
||||||
# the defaultSyncHorizon, it will start triggering in time so that potential
|
# the defaultSyncHorizon, it will start triggering in time so that potential
|
||||||
# discrepancies between the head here, and the head the DAG has (which might
|
# discrepancies between the head here, and the head the DAG has (which might
|
||||||
# not yet be updated) won't be visible.
|
# not yet be updated) won't be visible.
|
||||||
const defaultSyncHorizon = 50
|
|
||||||
|
|
||||||
if dag.head.slot + defaultSyncHorizon < wallSlot:
|
if dag.head.slot + defaultSyncHorizon < wallSlot:
|
||||||
false
|
false
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -278,3 +278,6 @@ chronicles.formatIt TimeDiff: it.shortLog
|
||||||
chronicles.formatIt Slot: it.shortLog
|
chronicles.formatIt Slot: it.shortLog
|
||||||
chronicles.formatIt Epoch: it.shortLog
|
chronicles.formatIt Epoch: it.shortLog
|
||||||
chronicles.formatIt SyncCommitteePeriod: it.shortLog
|
chronicles.formatIt SyncCommitteePeriod: it.shortLog
|
||||||
|
|
||||||
|
const defaultSyncHorizon* =
|
||||||
|
(uint64(10*60) + SECONDS_PER_SLOT - 1) div SECONDS_PER_SLOT
|
||||||
|
|
Loading…
Reference in New Issue