Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify validator activation flow #3983

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
- [Helper functions](#helper-functions)
- [Predicates](#predicates)
- [Modified `compute_proposer_index`](#modified-compute_proposer_index)
- [Modified `is_eligible_for_activation_queue`](#modified-is_eligible_for_activation_queue)
- [Modified `is_eligible_for_activation`](#modified-is_eligible_for_activation)
- [New `is_compounding_withdrawal_credential`](#new-is_compounding_withdrawal_credential)
- [New `has_compounding_withdrawal_credential`](#new-has_compounding_withdrawal_credential)
- [New `has_execution_withdrawal_credential`](#new-has_execution_withdrawal_credential)
Expand Down Expand Up @@ -419,18 +419,21 @@ def compute_proposer_index(state: BeaconState, indices: Sequence[ValidatorIndex]
i += 1
```

#### Modified `is_eligible_for_activation_queue`
#### Modified `is_eligible_for_activation`

*Note*: The function `is_eligible_for_activation_queue` is modified to use `MIN_ACTIVATION_BALANCE` instead of `MAX_EFFECTIVE_BALANCE`.
*Note*: The function `is_eligible_for_activation` is modified to directly use `effective_balance`
instead of `activation_eligibility_epoch` as one of the eligibility criteria.

```python
def is_eligible_for_activation_queue(validator: Validator) -> bool:
def is_eligible_for_activation(validator: Validator) -> bool:
"""
Check if ``validator`` is eligible to be placed into the activation queue.
Check if ``validator`` is eligible for activation.
"""
return (
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH
and validator.effective_balance >= MIN_ACTIVATION_BALANCE # [Modified in Electra:EIP7251]
# Has sufficient effective balance
validator.effective_balance >= MIN_ACTIVATION_BALANCE
# Has not yet been activated
and validator.activation_epoch == FAR_FUTURE_EPOCH
)
```

Expand Down Expand Up @@ -778,27 +781,28 @@ def process_epoch(state: BeaconState) -> None:

#### Modified `process_registry_updates`

*Note*: The function `process_registry_updates` is modified to use the updated definition of `initiate_validator_exit`
and changes how the activation epochs are computed for eligible validators.
*Note*: The function `process_registry_updates` is modified to use the updated definition of `initiate_validator_exit`,
changes how `activation_epoch` and `activation_eligibility_epoch` are computed for an eligible validator.

```python
def process_registry_updates(state: BeaconState) -> None:
# Process activation eligibility and ejections
# Process ejections
for index, validator in enumerate(state.validators):
if is_eligible_for_activation_queue(validator):
validator.activation_eligibility_epoch = get_current_epoch(state) + 1

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

# Activate all eligible validators
# Activate all eligible validators [Modified in Electra:EIP7251]
activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
activation_eligibility_epoch = get_current_epoch(state) + 1
for validator in state.validators:
if is_eligible_for_activation(state, validator):
if is_eligible_for_activation(validator):
validator.activation_epoch = activation_epoch
# Set activation eligibility epoch for backwards compatibility,
# to be deprecated in one of the future upgrades
validator.activation_eligibility_epoch = activation_eligibility_epoch
```

#### Modified `process_slashings`
Expand Down
Loading