Skip to content

Commit f6393b6

Browse files
authored
Pass TimeConfig to nextSlot/EpochStartTime (#7621)
start_beacon_time depends on SECONDS_PER_SLOT so needs to be known eventually in nextSlotStartTime and nextEpochStartTime helpers.
1 parent 7f8a06e commit f6393b6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

beacon_chain/beacon_clock.nim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ func durationOrZero*(d: tuple[inFuture: bool, offset: Duration]): Duration =
9595
ZeroDuration
9696

9797
func nextSlotStartTime*(
98-
exSlot: tuple[afterGenesis: bool, slot: Slot]): BeaconTime =
98+
exSlot: tuple[afterGenesis: bool, slot: Slot],
99+
timeConfig: TimeConfig): BeaconTime =
99100
if exSlot.afterGenesis:
100101
(exSlot.slot + 1).start_beacon_time()
101102
else:
@@ -105,7 +106,8 @@ func nextSlotStartTime*(
105106
genesisTime - timeDiff
106107

107108
func nextEpochStartTime*(
108-
exSlot: tuple[afterGenesis: bool, slot: Slot]): BeaconTime =
109+
exSlot: tuple[afterGenesis: bool, slot: Slot],
110+
timeConfig: TimeConfig): BeaconTime =
109111
if exSlot.afterGenesis:
110112
(exSlot.slot.epoch + 1).start_slot.start_beacon_time()
111113
else:

beacon_chain/validator_client/common.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ proc waitForNextEpoch*(service: ClientServiceRef,
14681468
let
14691469
vc = service.client
14701470
currentSlot = vc.beaconClock.now().toSlot()
1471-
nextEpochTime = currentSlot.nextEpochStartTime()
1471+
nextEpochTime = currentSlot.nextEpochStartTime(vc.timeConfig)
14721472
sleepTime = vc.beaconClock.fromNow(nextEpochTime).durationOrZero() + delay
14731473
debug "Sleeping until next epoch", service = service.name,
14741474
sleep_time = sleepTime, delay = delay
@@ -1483,7 +1483,7 @@ proc waitForNextSlot*(
14831483
currentSlot: tuple[afterGenesis: bool, slot: Slot]
14841484
): Future[void] {.async: (raises: [CancelledError], raw: true).} =
14851485
let
1486-
nextSlotTime = currentSlot.nextSlotStartTime()
1486+
nextSlotTime = currentSlot.nextSlotStartTime(vc.timeConfig)
14871487
sleepTime = vc.beaconClock.fromNow(nextSlotTime).durationOrZero()
14881488
sleepAsync(sleepTime)
14891489

0 commit comments

Comments
 (0)