Make sync horizon configurable (#3113)

Currently, we don't have a good answer to the question "are we synced
yet" - the sync manager syncs based on the peers it's connected to, but
just because some peer looks like it should be synced from doesn't mean
we're out of sync.

Instead, we use a very silly time-based heuristic - the problem with
that is that the network can go into a rut where nobody produces blocks
- better heuristics would be needed here, but in the meantime, a command
line option can get us out of a tight spot - this PR places such an
option in the client, in the unlikely event it should be needed (most
likely in a testnet).
This commit is contained in:
Jacek Sieka 2021-11-18 20:35:26 +01:00 committed by GitHub
parent f19a497eec
commit 95dd846a9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -348,6 +348,13 @@ type
name: "doppelganger-detection" name: "doppelganger-detection"
}: bool }: bool
syncHorizon* {.
hidden
desc: "Number of empty slots to process before considering the client out of sync"
defaultValue: MaxEmptySlotCount
defaultValueDesc: "50"
name: "sync-horizon" }: uint64
of createTestnet: of createTestnet:
testnetDepositsFile* {. testnetDepositsFile* {.
desc: "A LaunchPad deposits file for the genesis state validators" desc: "A LaunchPad deposits file for the genesis state validators"

View File

@ -171,12 +171,10 @@ proc isSynced*(node: BeaconNode, head: BlockRef): bool =
beaconTime = node.beaconClock.now() beaconTime = node.beaconClock.now()
wallSlot = beaconTime.toSlot() wallSlot = beaconTime.toSlot()
# TODO: MaxEmptySlotCount should likely involve the weak subjectivity period.
# TODO if everyone follows this logic, the network will not recover from a # TODO if everyone follows this logic, the network will not recover from a
# halt: nobody will be producing blocks because everone expects someone # halt: nobody will be producing blocks because everone expects someone
# else to do it # else to do it
if wallSlot.afterGenesis and head.slot + MaxEmptySlotCount < wallSlot.slot: if wallSlot.afterGenesis and head.slot + node.config.syncHorizon < wallSlot.slot:
false false
else: else:
true true