avoid sending redundant LC finality updates (#4546)
When the epoch boundary block is missed, we incorrectly assume that the next couple blocks improve finality, leading to repeated pushes of the same light client finality update and incorrectly ignoring some gossip.
This commit is contained in:
parent
fe1a57c220
commit
efbd4e395a
|
@ -559,20 +559,29 @@ proc createLightClientUpdates(
|
|||
if is_later and latest.assign_attested_header_with_migration(attested_bid):
|
||||
template forkyLatest: untyped = latest.forky(data_fork)
|
||||
load_attested_data(attested_bid)
|
||||
let finalized_slot = attested_data.finalized_slot
|
||||
var finalized_slot = attested_data.finalized_slot
|
||||
if finalized_slot == forkyLatest.finalized_header.beacon.slot:
|
||||
forkyLatest.finality_branch = attested_data.finality_branch
|
||||
elif finalized_slot == GENESIS_SLOT:
|
||||
forkyLatest.finalized_header.reset()
|
||||
forkyLatest.finality_branch = attested_data.finality_branch
|
||||
elif finalized_slot >= dag.tail.slot and
|
||||
load_finalized_bid(finalized_slot) and
|
||||
forkyLatest.assign_finalized_header(finalized_bid):
|
||||
forkyLatest.finality_branch = attested_data.finality_branch
|
||||
newFinality = true
|
||||
else:
|
||||
elif finalized_slot < dag.tail.slot or
|
||||
not load_finalized_bid(finalized_slot):
|
||||
forkyLatest.finalized_header.reset()
|
||||
forkyLatest.finality_branch.reset()
|
||||
else:
|
||||
if finalized_bid.slot != finalized_slot:
|
||||
finalized_slot = finalized_bid.slot
|
||||
attested_data.finalized_slot = finalized_slot
|
||||
dag.lcDataStore.cache.data[attested_bid] = attested_data
|
||||
if finalized_slot == forkyLatest.finalized_header.beacon.slot:
|
||||
forkyLatest.finality_branch = attested_data.finality_branch
|
||||
elif finalized_slot == GENESIS_SLOT:
|
||||
forkyLatest.finalized_header.reset()
|
||||
forkyLatest.finality_branch = attested_data.finality_branch
|
||||
elif forkyLatest.assign_finalized_header(finalized_bid):
|
||||
forkyLatest.finality_branch = attested_data.finality_branch
|
||||
newFinality = true
|
||||
else:
|
||||
forkyLatest.finalized_header.reset()
|
||||
forkyLatest.finality_branch.reset()
|
||||
forkyLatest.sync_aggregate = sync_aggregate
|
||||
forkyLatest.signature_slot = signature_slot
|
||||
newOptimistic = true
|
||||
|
@ -648,7 +657,7 @@ proc createLightClientUpdates(
|
|||
withLcDataFork(dag.cfg.lcDataForkAtEpoch(parent_bid.slot.epoch)):
|
||||
when lcDataFork > LightClientDataFork.None:
|
||||
dag.createLightClientUpdates(state, blck, parent_bid, lcDataFork)
|
||||
|
||||
|
||||
proc initLightClientDataCache*(dag: ChainDAGRef) =
|
||||
## Initialize cached light client data
|
||||
if not dag.shouldImportLcData:
|
||||
|
|
|
@ -295,8 +295,7 @@ template withReportedProgress(
|
|||
obj: SomeForkedLightClientObject | Nothing, body: untyped): bool =
|
||||
block:
|
||||
let
|
||||
oldIsInitialized =
|
||||
self.store[].kind != LightClientDataFork.None
|
||||
oldIsInitialized = self.store[].kind > LightClientDataFork.None
|
||||
oldNextCommitteeKnown = withForkyStore(self.store[]):
|
||||
when lcDataFork > LightClientDataFork.None:
|
||||
forkyStore.is_next_sync_committee_known
|
||||
|
@ -324,7 +323,7 @@ template withReportedProgress(
|
|||
didProgress = false
|
||||
didSignificantProgress = false
|
||||
|
||||
let newIsInitialized = self.store[].kind != LightClientDataFork.None
|
||||
let newIsInitialized = self.store[].kind > LightClientDataFork.None
|
||||
if newIsInitialized > oldIsInitialized:
|
||||
didProgress = true
|
||||
didSignificantProgress = true
|
||||
|
|
Loading…
Reference in New Issue