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:
parent
15bf3c4258
commit
4442dfffb9
|
@ -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)]
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue