File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 4242 - [ ` BeaconState ` ] ( #beaconstate )
4343- [ Helper functions] ( #helper-functions )
4444 - [ Predicates] ( #predicates )
45+ - [ Updated ` compute_proposer_index ` ] ( #updated-compute_proposer_index )
4546 - [ Updated ` is_eligible_for_activation_queue ` ] ( #updated-is_eligible_for_activation_queue )
4647 - [ New ` is_compounding_withdrawal_credential ` ] ( #new-is_compounding_withdrawal_credential )
4748 - [ New ` has_compounding_withdrawal_credential ` ] ( #new-has_compounding_withdrawal_credential )
@@ -438,6 +439,27 @@ class BeaconState(Container):
438439
439440### Predicates
440441
442+ #### Updated ` compute_proposer_index `
443+
444+ ``` python
445+ def compute_proposer_index (state : BeaconState, indices : Sequence[ValidatorIndex], seed : Bytes32) -> ValidatorIndex:
446+ """
447+ Return from ``indices`` a random index sampled by effective balance.
448+ """
449+ assert len (indices) > 0
450+ MAX_RANDOM_BYTE = 2 ** 8 - 1
451+ i = uint64(0 )
452+ total = uint64(len (indices))
453+ while True :
454+ candidate_index = indices[compute_shuffled_index(i % total, total, seed)]
455+ random_byte = hash (seed + uint_to_bytes(uint64(i // 32 )))[i % 32 ]
456+ effective_balance = state.validators[candidate_index].effective_balance
457+ # [Modified in Electra:EIP7251]
458+ if effective_balance * MAX_RANDOM_BYTE >= MAX_EFFECTIVE_BALANCE_ELECTRA * random_byte:
459+ return candidate_index
460+ i += 1
461+ ```
462+
441463#### Updated ` is_eligible_for_activation_queue `
442464
443465``` python
You can’t perform that action at this time.
0 commit comments