cleanup LC data helpers (#3746)
Use more general `lowSlot` in LC data helpers, and avoid using `earliestSlot` variable name as that one has a different meaning.
This commit is contained in:
parent
cba041ddfa
commit
0c00b85782
|
@ -526,12 +526,12 @@ proc currentSyncCommitteeForPeriod*(
|
|||
period: SyncCommitteePeriod): Opt[SyncCommittee] =
|
||||
## Fetch a `SyncCommittee` for a given sync committee period.
|
||||
## For non-finalized periods, follow the chain as selected by fork choice.
|
||||
let earliestSlot = max(dag.tail.slot, dag.cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||
if period < earliestSlot.sync_committee_period:
|
||||
let lowSlot = max(dag.tail.slot, dag.cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||
if period < lowSlot.sync_committee_period:
|
||||
return err()
|
||||
let
|
||||
periodStartSlot = period.start_slot
|
||||
syncCommitteeSlot = max(periodStartSlot, earliestSlot)
|
||||
syncCommitteeSlot = max(periodStartSlot, lowSlot)
|
||||
bsi = ? dag.getBlockIdAtSlot(syncCommitteeSlot)
|
||||
dag.withUpdatedState(tmpState, bsi) do:
|
||||
withState(state):
|
||||
|
|
|
@ -131,11 +131,12 @@ proc syncCommitteeRootForPeriod(
|
|||
## Compute a root to uniquely identify `current_sync_committee` and
|
||||
## `next_sync_committee` for a given sync committee period.
|
||||
## For non-finalized periods, follow the chain as selected by fork choice.
|
||||
let earliestSlot = dag.computeEarliestLightClientSlot
|
||||
doAssert period >= earliestSlot.sync_committee_period
|
||||
let lowSlot = max(dag.tail.slot, dag.cfg.ALTAIR_FORK_EPOCH.start_slot)
|
||||
if period < lowSlot.sync_committee_period:
|
||||
return err()
|
||||
let
|
||||
periodStartSlot = period.start_slot
|
||||
syncCommitteeSlot = max(periodStartSlot, earliestSlot)
|
||||
syncCommitteeSlot = max(periodStartSlot, lowSlot)
|
||||
bsi = ? dag.getExistingBlockIdAtSlot(syncCommitteeSlot)
|
||||
dag.withUpdatedExistingState(tmpState, bsi) do:
|
||||
withState(state):
|
||||
|
|
Loading…
Reference in New Issue