Fair proposer sampling

I think we want `first_committee[epoch % len(first_committee)]` as opposed to `first_committee[slot % len(first_committee)]`. The reason is that if the shuffling happens infrequently and `len(first_committee)` is a multiple of `SLOTS_PER_EPOCH` then the proposers will not be sampled fairly.

Taking this logic further, we may want to avoiding always picking the proposer from `first_committee`, e.g.:

```
    validators_at_slot = []
    for crosslink_committee, _ in get_crosslink_committees_at_slot(state, slot, registry_change):
        validators_at_slot.append(crosslink_committee)

    return validators_at_slot[epoch % len(validators_at_slot)]
```
This commit is contained in:
Justin 2019-03-07 23:56:03 +01:00 committed by GitHub
parent 8e08e742dc
commit 33a05109ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -1002,7 +1002,7 @@ def get_beacon_proposer_index(state: BeaconState,
assert previous_epoch <= epoch <= next_epoch
first_committee, _ = get_crosslink_committees_at_slot(state, slot, registry_change)[0]
return first_committee[slot % len(first_committee)]
return first_committee[epoch % len(first_committee)]
```
### `merkle_root`