@@ -816,27 +816,24 @@ def process_epoch(state: BeaconState) -> None:
816
816
817
817
#### Modified ` process_registry_updates `
818
818
819
- * Note* : The function ` process_registry_updates ` is modified to
820
- use the updated definitions of ` initiate_validator_exit ` and ` is_eligible_for_activation_queue `
821
- and changes how the activation epochs are computed for eligible validators.
819
+ * Note* : The function ` process_registry_updates ` is modified to use the updated definitions of
820
+ ` initiate_validator_exit ` and ` is_eligible_for_activation_queue ` , changes how the activation epochs
821
+ are computed for eligible validators, and processes activations in the same loop as activation
822
+ eligibility updates and ejections.
822
823
823
824
``` python
824
825
def process_registry_updates (state : BeaconState) -> None :
825
- # Process activation eligibility and ejections
826
+ current_epoch = get_current_epoch(state)
827
+ activation_epoch = compute_activation_exit_epoch(current_epoch)
828
+
829
+ # Process activation eligibility, ejections, and activations
826
830
for index, validator in enumerate (state.validators):
827
831
if is_eligible_for_activation_queue(validator): # [Modified in Electra:EIP7251]
828
- validator.activation_eligibility_epoch = get_current_epoch(state) + 1
832
+ validator.activation_eligibility_epoch = current_epoch + 1
829
833
830
- if (
831
- is_active_validator(validator, get_current_epoch(state))
832
- and validator.effective_balance <= EJECTION_BALANCE
833
- ):
834
+ if is_active_validator(validator, current_epoch) and validator.effective_balance <= EJECTION_BALANCE :
834
835
initiate_validator_exit(state, ValidatorIndex(index)) # [Modified in Electra:EIP7251]
835
836
836
- # Activate all eligible validators
837
- # [Modified in Electra:EIP7251]
838
- activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
839
- for validator in state.validators:
840
837
if is_eligible_for_activation(state, validator):
841
838
validator.activation_epoch = activation_epoch
842
839
```
0 commit comments