fix LC data import `--only-new` regression (#5616)

Corrects LC server startup logic for `LightClientDataImportMode.OnlyNew`
after regression in #5607.
This commit is contained in:
Etan Kissling 2023-11-22 14:05:31 +01:00 committed by GitHub
parent 7554ca2583
commit b0b8f21223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 15 deletions

View File

@ -764,23 +764,22 @@ proc initLightClientDataCache*(dag: ChainDAGRef) =
initDur = lightClientEndTick - lightClientStartTick, res
if res.isErr:
return
if dag.lcDataStore.importMode == LightClientDataImportMode.OnDemand:
return
# Import historic data
dag.lcDataStore.cache.tailSlot = targetTailSlot
let targetTailPeriod = targetTailSlot.sync_committee_period
if targetTailPeriod < finalizedPeriod:
# `countdown` through 0 fails on distinct `uint64`
# https://github.com/nim-lang/Nim/pull/19926
var period = finalizedPeriod - 1
while period >= targetTailPeriod:
if dag.initLightClientDataForPeriod(period).isErr:
res.err()
if period <= targetTailPeriod:
break
dec period
debug "Historic LC data imported", res
if dag.lcDataStore.importMode == LightClientDataImportMode.Full:
dag.lcDataStore.cache.tailSlot = targetTailSlot
let targetTailPeriod = targetTailSlot.sync_committee_period
if targetTailPeriod < finalizedPeriod:
# `countdown` through 0 fails on distinct `uint64`
# https://github.com/nim-lang/Nim/pull/19926
var period = finalizedPeriod - 1
while period >= targetTailPeriod:
if dag.initLightClientDataForPeriod(period).isErr:
res.err()
if period <= targetTailPeriod:
break
dec period
debug "Historic LC data imported", res
proc processNewBlockForLightClient*(
dag: ChainDAGRef,