@@ -279,7 +279,7 @@ func get_safety_threshold*(store: ForkyLightClientStore): uint64 =
279
279
store.current_max_active_participants
280
280
) div 2
281
281
282
- # https://github.com/ethereum/consensus-specs/blob/v1.4 .0-beta.5 /specs/altair/light-client/sync-protocol.md#is_better_update
282
+ # https://github.com/ethereum/consensus-specs/blob/v1.5 .0-beta.3 /specs/altair/light-client/sync-protocol.md#is_better_update
283
283
type LightClientUpdateMetadata * = object
284
284
attested_slot* , finalized_slot* , signature_slot* : Slot
285
285
has_sync_committee* , has_finality* : bool
@@ -326,10 +326,10 @@ func is_better_data*(new_meta, old_meta: LightClientUpdateMetadata): bool =
326
326
old_has_supermajority =
327
327
hasSupermajoritySyncParticipation (old_meta.num_active_participants)
328
328
if new_has_supermajority != old_has_supermajority:
329
- return new_has_supermajority > old_has_supermajority
330
- if not new_has_supermajority:
331
- if new_meta.num_active_participants != old_meta.num_active_participants:
332
- return new_meta.num_active_participants > old_meta.num_active_participants
329
+ return new_has_supermajority
330
+ if not new_has_supermajority and
331
+ new_meta.num_active_participants != old_meta.num_active_participants:
332
+ return new_meta.num_active_participants > old_meta.num_active_participants
333
333
334
334
# Compare presence of relevant sync committee
335
335
let
@@ -340,11 +340,11 @@ func is_better_data*(new_meta, old_meta: LightClientUpdateMetadata): bool =
340
340
old_meta.attested_slot.sync_committee_period ==
341
341
old_meta.signature_slot.sync_committee_period
342
342
if new_has_relevant_sync_committee != old_has_relevant_sync_committee:
343
- return new_has_relevant_sync_committee > old_has_relevant_sync_committee
343
+ return new_has_relevant_sync_committee
344
344
345
345
# Compare indication of any finality
346
346
if new_meta.has_finality != old_meta.has_finality:
347
- return new_meta.has_finality > old_meta.has_finality
347
+ return new_meta.has_finality
348
348
349
349
# Compare sync committee finality
350
350
if new_meta.has_finality:
@@ -356,14 +356,18 @@ func is_better_data*(new_meta, old_meta: LightClientUpdateMetadata): bool =
356
356
old_meta.finalized_slot.sync_committee_period ==
357
357
old_meta.attested_slot.sync_committee_period
358
358
if new_has_sync_committee_finality != old_has_sync_committee_finality:
359
- return new_has_sync_committee_finality > old_has_sync_committee_finality
359
+ return new_has_sync_committee_finality
360
360
361
361
# Tiebreaker 1: Sync committee participation beyond supermajority
362
362
if new_meta.num_active_participants != old_meta.num_active_participants:
363
363
return new_meta.num_active_participants > old_meta.num_active_participants
364
364
365
- # Tiebreaker 2: Prefer older data (fewer changes to best data)
366
- new_meta.attested_slot < old_meta.attested_slot
365
+ # Tiebreaker 2: Prefer older data (fewer changes to best)
366
+ if new_meta.attested_slot != old_meta.attested_slot:
367
+ return new_meta.attested_slot < old_meta.attested_slot
368
+
369
+ # Tiebreaker 3: Prefer updates with earlier signature slots
370
+ new_meta.signature_slot < old_meta.signature_slot
367
371
368
372
template is_better_update * [
369
373
A, B: SomeForkyLightClientUpdate | ForkedLightClientUpdate ](
0 commit comments