Skip to content

Commit

Permalink
Simplify/optimize process_registry_updates
Browse files Browse the repository at this point in the history
jtraglia committed Jan 13, 2025
1 parent da17461 commit 902c74e
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
@@ -816,27 +816,24 @@ def process_epoch(state: BeaconState) -> None:

#### Modified `process_registry_updates`

*Note*: The function `process_registry_updates` is modified to
use the updated definitions of `initiate_validator_exit` and `is_eligible_for_activation_queue`
and changes how the activation epochs are computed for eligible validators.
*Note*: The function `process_registry_updates` is modified to use the updated definitions of
`initiate_validator_exit` and `is_eligible_for_activation_queue`, changes how the activation epochs
are computed for eligible validators, and processes activations in the same loop as activation
eligibility updates and ejections.

```python
def process_registry_updates(state: BeaconState) -> None:
# Process activation eligibility and ejections
current_epoch = get_current_epoch(state)
activation_epoch = compute_activation_exit_epoch(current_epoch)

# Process activation eligibility, ejections, and activations
for index, validator in enumerate(state.validators):
if is_eligible_for_activation_queue(validator): # [Modified in Electra:EIP7251]
validator.activation_eligibility_epoch = get_current_epoch(state) + 1
validator.activation_eligibility_epoch = current_epoch + 1

if (
is_active_validator(validator, get_current_epoch(state))
and validator.effective_balance <= EJECTION_BALANCE
):
if is_active_validator(validator, current_epoch) and validator.effective_balance <= EJECTION_BALANCE:
initiate_validator_exit(state, ValidatorIndex(index)) # [Modified in Electra:EIP7251]

# Activate all eligible validators
# [Modified in Electra:EIP7251]
activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
for validator in state.validators:
if is_eligible_for_activation(state, validator):
validator.activation_epoch = activation_epoch
```

0 comments on commit 902c74e

Please sign in to comment.