avoid pruning LC data pre dag.tail.slot (#4702)
When using `--history=prune`, `dag.tail.slot` may advance beyond the configured light client data retention period. Update the LC logic so that the `dag.tail.slot` is no longer considered for LC pruning. It is still considered to check whether new data can be produced.
This commit is contained in:
parent
90640cce05
commit
e499c709f4
|
@ -150,7 +150,7 @@ func targetLightClientTailSlot(dag: ChainDAGRef): Slot =
|
||||||
let
|
let
|
||||||
maxPeriods = dag.lcDataStore.maxPeriods
|
maxPeriods = dag.lcDataStore.maxPeriods
|
||||||
headPeriod = dag.head.slot.sync_committee_period
|
headPeriod = dag.head.slot.sync_committee_period
|
||||||
lowSlot = max(dag.tail.slot, dag.cfg.ALTAIR_FORK_EPOCH.start_slot)
|
lowSlot = dag.cfg.ALTAIR_FORK_EPOCH.start_slot
|
||||||
tail = max(headPeriod + 1, maxPeriods.SyncCommitteePeriod) - maxPeriods
|
tail = max(headPeriod + 1, maxPeriods.SyncCommitteePeriod) - maxPeriods
|
||||||
max(tail.start_slot, lowSlot)
|
max(tail.start_slot, lowSlot)
|
||||||
|
|
||||||
|
@ -182,7 +182,8 @@ proc initLightClientBootstrapForPeriod(
|
||||||
let
|
let
|
||||||
periodStartSlot = period.start_slot
|
periodStartSlot = period.start_slot
|
||||||
periodEndSlot = periodStartSlot + SLOTS_PER_SYNC_COMMITTEE_PERIOD - 1
|
periodEndSlot = periodStartSlot + SLOTS_PER_SYNC_COMMITTEE_PERIOD - 1
|
||||||
lowSlot = max(periodStartSlot, dag.targetLightClientTailSlot)
|
tailSlot = max(dag.targetLightClientTailSlot, dag.tail.slot)
|
||||||
|
lowSlot = max(periodStartSlot, tailSlot)
|
||||||
highSlot = min(periodEndSlot, dag.finalizedHead.blck.slot)
|
highSlot = min(periodEndSlot, dag.finalizedHead.blck.slot)
|
||||||
lowBoundarySlot = lowSlot.nextEpochBoundarySlot
|
lowBoundarySlot = lowSlot.nextEpochBoundarySlot
|
||||||
highBoundarySlot = highSlot.nextEpochBoundarySlot
|
highBoundarySlot = highSlot.nextEpochBoundarySlot
|
||||||
|
@ -286,7 +287,8 @@ proc initLightClientUpdateForPeriod(
|
||||||
let
|
let
|
||||||
periodStartSlot = period.start_slot
|
periodStartSlot = period.start_slot
|
||||||
periodEndSlot = periodStartSlot + SLOTS_PER_SYNC_COMMITTEE_PERIOD - 1
|
periodEndSlot = periodStartSlot + SLOTS_PER_SYNC_COMMITTEE_PERIOD - 1
|
||||||
lowSlot = max(periodStartSlot, dag.targetLightClientTailSlot)
|
tailSlot = max(dag.targetLightClientTailSlot, dag.tail.slot)
|
||||||
|
lowSlot = max(periodStartSlot, tailSlot)
|
||||||
highSlot = min(periodEndSlot, dag.finalizedHead.blck.slot)
|
highSlot = min(periodEndSlot, dag.finalizedHead.blck.slot)
|
||||||
fullPeriodCovered = (dag.finalizedHead.slot > periodEndSlot)
|
fullPeriodCovered = (dag.finalizedHead.slot > periodEndSlot)
|
||||||
highBsi = dag.getExistingBlockIdAtSlot(highSlot).valueOr:
|
highBsi = dag.getExistingBlockIdAtSlot(highSlot).valueOr:
|
||||||
|
@ -677,7 +679,7 @@ proc initLightClientDataCache*(dag: ChainDAGRef) =
|
||||||
dag.lcDataStore.db.delNonFinalizedPeriodsFrom(dag.firstNonFinalizedPeriod)
|
dag.lcDataStore.db.delNonFinalizedPeriodsFrom(dag.firstNonFinalizedPeriod)
|
||||||
|
|
||||||
# Initialize tail slot
|
# Initialize tail slot
|
||||||
let targetTailSlot = dag.targetLightClientTailSlot
|
let targetTailSlot = max(dag.targetLightClientTailSlot, dag.tail.slot)
|
||||||
dag.lcDataStore.cache.tailSlot = max(dag.head.slot, targetTailSlot)
|
dag.lcDataStore.cache.tailSlot = max(dag.head.slot, targetTailSlot)
|
||||||
|
|
||||||
# Import head state
|
# Import head state
|
||||||
|
|
Loading…
Reference in New Issue