mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-18 18:42:35 +00:00
Obtain extra LightClientFinalityUpdate
after LC sync (#6752)
To avoid having to wait several minutes for LC finality gossip, obtain extra finality update once LC sync finishes.
This commit is contained in:
parent
c3ef7fe2d7
commit
0ae7bcfff9
@ -332,7 +332,10 @@ template query[E](
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.9/specs/altair/light-client/light-client.md#light-client-sync-process
|
||||
proc loop(self: LightClientManager) {.async: (raises: [CancelledError]).} =
|
||||
var nextSyncTaskTime = self.getBeaconTime()
|
||||
var
|
||||
nextSyncTaskTime = self.getBeaconTime()
|
||||
wasGossipSupported = false
|
||||
haveFinalityUpdate = false
|
||||
while true:
|
||||
# Periodically wake and check for changes
|
||||
let wallTime = self.getBeaconTime()
|
||||
@ -373,16 +376,32 @@ proc loop(self: LightClientManager) {.async: (raises: [CancelledError]).} =
|
||||
await self.query(UpdatesByRange,
|
||||
(startPeriod: syncTask.startPeriod, count: syncTask.count))
|
||||
of LcSyncKind.FinalityUpdate:
|
||||
haveFinalityUpdate = true
|
||||
await self.query(FinalityUpdate)
|
||||
of LcSyncKind.OptimisticUpdate:
|
||||
await self.query(OptimisticUpdate)
|
||||
if not haveFinalityUpdate:
|
||||
haveFinalityUpdate = true
|
||||
await self.query(FinalityUpdate)
|
||||
else:
|
||||
await self.query(OptimisticUpdate)
|
||||
|
||||
nextSyncTaskTime = wallTime + self.rng.nextLcSyncTaskDelay(
|
||||
wallTime,
|
||||
finalized = self.getFinalizedPeriod(),
|
||||
optimistic = self.getOptimisticPeriod(),
|
||||
isNextSyncCommitteeKnown = self.isNextSyncCommitteeKnown(),
|
||||
didLatestSyncTaskProgress = didProgress)
|
||||
let
|
||||
finalized = self.getFinalizedPeriod()
|
||||
optimistic = self.getOptimisticPeriod()
|
||||
isNextSyncCommitteeKnown = self.isNextSyncCommitteeKnown()
|
||||
isGossipSupported =
|
||||
current.isGossipSupported(finalized, isNextSyncCommitteeKnown)
|
||||
nextSyncTaskTime =
|
||||
if not wasGossipSupported and isGossipSupported:
|
||||
# Obtain an extra finality update after finishing sync
|
||||
# to avoid having to wait several minutes for finality gossip
|
||||
haveFinalityUpdate = false
|
||||
wallTime
|
||||
else:
|
||||
wallTime + self.rng.nextLcSyncTaskDelay(
|
||||
wallTime, finalized, optimistic, isNextSyncCommitteeKnown,
|
||||
didLatestSyncTaskProgress = didProgress)
|
||||
wasGossipSupported = isGossipSupported
|
||||
|
||||
proc start*(self: var LightClientManager) =
|
||||
## Start light client manager's loop.
|
||||
|
Loading…
x
Reference in New Issue
Block a user