Skip to content

Commit

Permalink
Merge pull request ethereum#3571 from etan-status/lc-periodhelpers
Browse files Browse the repository at this point in the history
Extract sync committee period <-> slot helpers to common LC test module
  • Loading branch information
hwwhww authored Jan 10, 2024
2 parents 0dcb3be + 6c6ed3e commit e42974e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
is_post_fork,
)
from eth2spec.test.helpers.light_client import (
compute_start_slot_at_next_sync_committee_period,
get_sync_aggregate,
upgrade_lc_bootstrap_to_new_spec,
upgrade_lc_update_to_new_spec,
Expand Down Expand Up @@ -196,15 +197,6 @@ def emit_upgrade_store(test, new_s_spec, phases=None):
})


def compute_start_slot_at_sync_committee_period(spec, sync_committee_period):
return spec.compute_start_slot_at_epoch(sync_committee_period * spec.EPOCHS_PER_SYNC_COMMITTEE_PERIOD)


def compute_start_slot_at_next_sync_committee_period(spec, state):
sync_committee_period = spec.compute_sync_committee_period_at_slot(state.slot)
return compute_start_slot_at_sync_committee_period(spec, sync_committee_period + 1)


@with_light_client
@spec_state_test_with_matching_config
@with_presets([MINIMAL], reason="too slow")
Expand Down
9 changes: 9 additions & 0 deletions tests/core/pyspec/eth2spec/test/helpers/light_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
from math import floor


def compute_start_slot_at_sync_committee_period(spec, sync_committee_period):
return spec.compute_start_slot_at_epoch(sync_committee_period * spec.EPOCHS_PER_SYNC_COMMITTEE_PERIOD)


def compute_start_slot_at_next_sync_committee_period(spec, state):
sync_committee_period = spec.compute_sync_committee_period_at_slot(state.slot)
return compute_start_slot_at_sync_committee_period(spec, sync_committee_period + 1)


def get_sync_aggregate(spec, state, num_participants=None, signature_slot=None):
# By default, the sync committee signs the previous slot
if signature_slot is None:
Expand Down

0 comments on commit e42974e

Please sign in to comment.