Fair proposer selection probability

Note that as a side effect, proposer selection becomes less predictable, but I don't feel like this is a large downside.
This commit is contained in:
vbuterin 2019-03-13 21:42:49 -05:00 committed by GitHub
parent 15bf3c4258
commit 4442dfffb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -1014,7 +1014,13 @@ 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]
first_committee, _ = get_crosslink_committees_at_slot(state, slot, registry_change)[0] i = 0
while i < len(first_committee):
rand_byte = hash(generate_seed(get_current_epoch(state)) + int_to_bytes8(i // 32))[i % 32]
candidate = first_committee[(epoch % i) % len(first_committee)]
if get_effective_balance(state, candidate) * 256 > MAX_DEPOSIT_AMOUNT * rand_byte:
return candidate
i += 1
return first_committee[epoch % len(first_committee)]
```