Skip to content

Commit fd87b46

Browse files
authored
Merge pull request #4081 from jtraglia/simplify-registry-updates
Simplify/optimize `process_registry_updates`
2 parents da17461 + 902c74e commit fd87b46

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

specs/electra/beacon-chain.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -816,27 +816,24 @@ def process_epoch(state: BeaconState) -> None:
816816

817817
#### Modified `process_registry_updates`
818818

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.
822823

823824
```python
824825
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
826830
for index, validator in enumerate(state.validators):
827831
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
829833

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:
834835
initiate_validator_exit(state, ValidatorIndex(index)) # [Modified in Electra:EIP7251]
835836

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:
840837
if is_eligible_for_activation(state, validator):
841838
validator.activation_epoch = activation_epoch
842839
```

0 commit comments

Comments
 (0)