Skip to content

Commit

Permalink
Merge pull request #699 from ethereum/start_shard_bug
Browse files Browse the repository at this point in the history
fix committee assignment bugs
  • Loading branch information
djrtwo authored Mar 3, 2019
2 parents d293b12 + dbbfb93 commit 146aef3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -877,19 +877,22 @@ def get_crosslink_committees_at_slot(state: BeaconState,
shuffling_epoch = state.previous_shuffling_epoch
shuffling_start_shard = state.previous_shuffling_start_shard
elif epoch == next_epoch:
current_committees_per_epoch = get_current_epoch_committee_count(state)
committees_per_epoch = get_next_epoch_committee_count(state)
shuffling_epoch = next_epoch

epochs_since_last_registry_update = current_epoch - state.validator_registry_update_epoch
if registry_change:
committees_per_epoch = get_next_epoch_committee_count(state)
seed = generate_seed(state, next_epoch)
shuffling_epoch = next_epoch
current_committees_per_epoch = get_current_epoch_committee_count(state)
shuffling_start_shard = (state.current_shuffling_start_shard + current_committees_per_epoch) % SHARD_COUNT
elif epochs_since_last_registry_update > 1 and is_power_of_two(epochs_since_last_registry_update):
committees_per_epoch = get_next_epoch_committee_count(state)
seed = generate_seed(state, next_epoch)
shuffling_epoch = next_epoch
shuffling_start_shard = state.current_shuffling_start_shard
else:
committees_per_epoch = get_current_epoch_committee_count(state)
seed = state.current_shuffling_seed
shuffling_epoch = state.current_shuffling_epoch
shuffling_start_shard = state.current_shuffling_start_shard

shuffling = get_shuffling(
Expand Down Expand Up @@ -2093,8 +2096,8 @@ def update_validator_registry(state: BeaconState) -> None:

and perform the following updates:

* Set `state.current_shuffling_epoch = next_epoch`
* Set `state.current_shuffling_start_shard = (state.current_shuffling_start_shard + get_current_epoch_committee_count(state)) % SHARD_COUNT`
* Set `state.current_shuffling_epoch = next_epoch`
* Set `state.current_shuffling_seed = generate_seed(state, state.current_shuffling_epoch)`

If a validator registry update does _not_ happen do the following:
Expand Down

0 comments on commit 146aef3

Please sign in to comment.