Merge pull request #3659 from ethDreamer/activation_rate_limiting

EIP-7251: Enforce Activation Rate Limit at Fork Transition
This commit is contained in:
Alex Stokes 2024-04-16 16:14:44 -06:00 committed by GitHub
commit a07e144adc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View File

@ -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

View File

@ -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):