Skip to content

Commit ebeb7e6

Browse files
authored
Pass TimeConfig to LightClientManager (#7625)
* Pass TimeConfig to LightClientManager nextLcSyncTaskDelay needs to compute time from slot so needs TimeConfig. * One more initialization
1 parent 7d293cf commit ebeb7e6

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

beacon_chain/libnimbus_lc/libnimbus_lc.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ proc ETHLightClientStoreGetMillisecondsToNextSyncTask(
467467
## * Number of milliseconds until `ETHLightClientStoreGetNextSyncTask`
468468
## should be called again to obtain the next light client sync task.
469469
asRef(rng).nextLcSyncTaskDelay(
470+
beaconClock[].timeConfig,
470471
wallTime = beaconClock[].now(),
471472
finalized = store[].finalized_header.beacon.slot.sync_committee_period,
472473
optimistic = store[].optimistic_header.beacon.slot.sync_committee_period,

beacon_chain/light_client.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ proc createLightClient(
175175
GENESIS_SLOT.sync_committee_period
176176

177177
lightClient.manager = LightClientManager.init(
178-
lightClient.network, rng, getTrustedBlockRoot,
178+
lightClient.network, rng, lightClient.cfg.time, getTrustedBlockRoot,
179179
bootstrapVerifier, updateVerifier, finalityVerifier, optimisticVerifier,
180180
isLightClientStoreInitialized, isNextSyncCommitteeKnown,
181181
getFinalizedPeriod, getOptimisticPeriod, getBeaconTime,

beacon_chain/sync/light_client_manager.nim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type
5555
LightClientManager* = object
5656
network: Eth2Node
5757
rng: ref HmacDrbgContext
58+
timeConfig: TimeConfig
5859
getTrustedBlockRoot: GetTrustedBlockRootCallback
5960
bootstrapVerifier: BootstrapVerifier
6061
updateVerifier: UpdateVerifier
@@ -72,6 +73,7 @@ func init*(
7273
T: type LightClientManager,
7374
network: Eth2Node,
7475
rng: ref HmacDrbgContext,
76+
timeConfig: TimeConfig,
7577
getTrustedBlockRoot: GetTrustedBlockRootCallback,
7678
bootstrapVerifier: BootstrapVerifier,
7779
updateVerifier: UpdateVerifier,
@@ -88,6 +90,7 @@ func init*(
8890
LightClientManager(
8991
network: network,
9092
rng: rng,
93+
timeConfig: timeConfig,
9194
getTrustedBlockRoot: getTrustedBlockRoot,
9295
bootstrapVerifier: bootstrapVerifier,
9396
updateVerifier: updateVerifier,
@@ -399,7 +402,8 @@ proc loop(self: LightClientManager) {.async: (raises: [CancelledError]).} =
399402
wallTime
400403
else:
401404
wallTime + self.rng.nextLcSyncTaskDelay(
402-
wallTime, finalized, optimistic, isNextSyncCommitteeKnown,
405+
self.timeConfig, wallTime,
406+
finalized, optimistic, isNextSyncCommitteeKnown,
403407
didLatestSyncTaskProgress = didProgress)
404408
wasGossipSupported = isGossipSupported
405409

beacon_chain/sync/light_client_sync_helpers.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# beacon_chain
2-
# Copyright (c) 2022-2024 Status Research & Development GmbH
2+
# Copyright (c) 2022-2025 Status Research & Development GmbH
33
# Licensed and distributed under either of
44
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
55
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -110,6 +110,7 @@ func computeDelayWithJitter*(
110110

111111
func nextLcSyncTaskDelay*(
112112
rng: ref HmacDrbgContext,
113+
timeConfig: TimeConfig,
113114
wallTime: BeaconTime,
114115
finalized: SyncCommitteePeriod,
115116
optimistic: SyncCommitteePeriod,

0 commit comments

Comments
 (0)