From 8bd8ffe2bb3f7c8815ae9b52cc65927cfd1d12d6 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Tue, 12 Mar 2024 21:51:18 +0100 Subject: [PATCH] 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. --- beacon_chain/beacon_node.nim | 5 ++--- beacon_chain/conf.nim | 6 +++--- beacon_chain/consensus_object_pools/consensus_manager.nim | 2 -- beacon_chain/spec/beacon_time.nim | 3 +++ 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 49c7d327e..a3a08ce32 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -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 diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index 6cca45e9a..59b8aeb4c 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -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* {. diff --git a/beacon_chain/consensus_object_pools/consensus_manager.nim b/beacon_chain/consensus_object_pools/consensus_manager.nim index acb63c14a..07100a2b6 100644 --- a/beacon_chain/consensus_object_pools/consensus_manager.nim +++ b/beacon_chain/consensus_object_pools/consensus_manager.nim @@ -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: diff --git a/beacon_chain/spec/beacon_time.nim b/beacon_chain/spec/beacon_time.nim index 19064e284..e165b59ad 100644 --- a/beacon_chain/spec/beacon_time.nim +++ b/beacon_chain/spec/beacon_time.nim @@ -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