diff --git a/specs/electra/beacon-chain.md b/specs/electra/beacon-chain.md index b78ebf796..551a41af1 100644 --- a/specs/electra/beacon-chain.md +++ b/specs/electra/beacon-chain.md @@ -61,6 +61,7 @@ - [Updated `initiate_validator_exit`](#updated--initiate_validator_exit) - [New `switch_to_compounding_validator`](#new-switch_to_compounding_validator) - [New `queue_excess_active_balance`](#new-queue_excess_active_balance) + - [New `queue_entire_balance_and_reset_validator`](#new-queue_entire_balance_and_reset_validator) - [New `compute_exit_epoch_and_update_churn`](#new-compute_exit_epoch_and_update_churn) - [New `compute_consolidation_epoch_and_update_churn`](#new-compute_consolidation_epoch_and_update_churn) - [Updated `slash_validator`](#updated-slash_validator) @@ -639,6 +640,19 @@ def queue_excess_active_balance(state: BeaconState, index: ValidatorIndex) -> No ) ``` +#### New `queue_entire_balance_and_reset_validator` +```python +def queue_entire_balance_and_reset_validator(state: BeaconState, index: ValidatorIndex) -> None: + balance = state.balances[index] + state.balances[index] = 0 + validator = state.validators[index] + validator.effective_balance = 0 + validator.activation_eligibility_epoch = FAR_FUTURE_EPOCH + state.pending_balance_deposits.append( + PendingBalanceDeposit(index=index, amount=balance) + ) +``` + #### New `compute_exit_epoch_and_update_churn` ```python diff --git a/specs/electra/fork.md b/specs/electra/fork.md index b3e4202ff..590c34bee 100644 --- a/specs/electra/fork.md +++ b/specs/electra/fork.md @@ -159,6 +159,18 @@ def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState: ) # [New in Electra:EIP7251] + # add validators that are not yet active to pending balance deposits + pre_activation = sorted([ + index for index, validator in enumerate(post.validators) + if validator.activation_epoch == FAR_FUTURE_EPOCH + ], key=lambda index: ( + post.validators[index].activation_eligibility_epoch, + index + )) + + for index in pre_activation: + queue_entire_balance_and_reset_validator(post, ValidatorIndex(index)) + # Ensure early adopters of compounding credentials go through the activation churn for index, validator in enumerate(post.validators): if has_compounding_withdrawal_credential(validator):