Skip to content

Commit

Permalink
Merge pull request #4124 from bshastry/test_lc_update_sig_slot
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored Feb 11, 2025
2 parents 6803ea3 + ea74634 commit 044f22d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions specs/altair/light-client/sync-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ def is_better_update(new_update: LightClientUpdate, old_update: LightClientUpdat
# Tiebreaker 2: Prefer older data (fewer changes to best)
if new_update.attested_header.beacon.slot != old_update.attested_header.beacon.slot:
return new_update.attested_header.beacon.slot < old_update.attested_header.beacon.slot

# Tiebreaker 3: Prefer updates with earlier signature slots
return new_update.signature_slot < old_update.signature_slot
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)


def create_test_update(spec, test, with_next, with_finality, participation_rate):
def create_test_update(spec, test, with_next, with_finality, participation_rate, signature_slot=None):
attested_state, attested_block, finalized_block = test
return create_update(
spec,
Expand All @@ -26,6 +26,7 @@ def create_test_update(spec, test, with_next, with_finality, participation_rate)
with_next,
with_finality,
participation_rate,
signature_slot=signature_slot,
)


Expand Down Expand Up @@ -132,6 +133,15 @@ def test_update_ranking(spec, state):
create_test_update(spec, att, with_next=0, with_finality=0, participation_rate=0.2),
create_test_update(spec, fin, with_next=0, with_finality=0, participation_rate=0.2),
create_test_update(spec, lat, with_next=0, with_finality=0, participation_rate=0.2),
# Test signature_slot tiebreaker: identical update but with later signature_slot
create_test_update(
spec,
lat,
with_next=0,
with_finality=0,
participation_rate=0.2,
signature_slot=lat_attested_state.slot + 2,
),
]
yield "updates", updates

Expand Down
5 changes: 3 additions & 2 deletions tests/core/pyspec/eth2spec/test/helpers/light_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def create_update(spec,
finalized_block,
with_next,
with_finality,
participation_rate):
participation_rate,
signature_slot=None):
num_participants = floor(spec.SYNC_COMMITTEE_SIZE * participation_rate)

update = spec.LightClientUpdate()
Expand All @@ -104,7 +105,7 @@ def create_update(spec,
attested_state, latest_finalized_root_gindex(spec))

update.sync_aggregate, update.signature_slot = get_sync_aggregate(
spec, attested_state, num_participants)
spec, attested_state, num_participants, signature_slot=signature_slot)

return update

Expand Down

0 comments on commit 044f22d

Please sign in to comment.