use current_Epoch seed when calculating next_sync_committee

This commit is contained in:
Danny Ryan 2021-05-11 15:18:18 -06:00
parent 5074fcad17
commit 2747882776
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
2 changed files with 10 additions and 4 deletions

View File

@ -304,7 +304,7 @@ def get_sync_committee_indices(state: BeaconState, epoch: Epoch) -> Sequence[Val
```python
def get_sync_committee(state: BeaconState, epoch: Epoch) -> SyncCommittee:
"""
Return the sync committee for a given ``state`` and ``epoch``.
Return the *next* sync committee for a given ``state`` and ``epoch``.
``SyncCommittee`` contains an aggregate pubkey that enables
resource-constrained clients to save some computation when verifying
@ -690,7 +690,7 @@ def process_sync_committee_updates(state: BeaconState) -> None:
next_epoch = get_current_epoch(state) + Epoch(1)
if next_epoch % EPOCHS_PER_SYNC_COMMITTEE_PERIOD == 0:
state.current_sync_committee = state.next_sync_committee
state.next_sync_committee = get_sync_committee(state, next_epoch + EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
state.next_sync_committee = get_sync_committee(state, next_epoch)
```
## Initialize state for pure Altair testnets and test vectors

View File

@ -80,8 +80,14 @@ def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:
# Inactivity
inactivity_scores=[uint64(0) for _ in range(len(pre.validators))],
)
# Fill in sync committees
post.current_sync_committee = get_sync_committee(post, get_current_epoch(post))
post.next_sync_committee = get_sync_committee(post, get_current_epoch(post) + EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
current_period = epoch // EPOCHS_PER_SYNC_COMMITTEE_PERIOD
previous_period = current_period - min(1, current_period)
current_base_epoch = current_period * EPOCHS_PER_SYNC_COMMITTEE_PERIOD
previous_base_epoch = previous_period * EPOCHS_PER_SYNC_COMMITTEE_PERIOD
post.current_sync_committee = get_sync_committee(post, previous_base_epoch)
post.next_sync_committee = get_sync_committee(post, current_base_epoch)
return post
```