Merge pull request #3659 from ethDreamer/activation_rate_limiting
EIP-7251: Enforce Activation Rate Limit at Fork Transition
This commit is contained in:
commit
a07e144adc
|
@ -61,6 +61,7 @@
|
||||||
- [Updated `initiate_validator_exit`](#updated--initiate_validator_exit)
|
- [Updated `initiate_validator_exit`](#updated--initiate_validator_exit)
|
||||||
- [New `switch_to_compounding_validator`](#new-switch_to_compounding_validator)
|
- [New `switch_to_compounding_validator`](#new-switch_to_compounding_validator)
|
||||||
- [New `queue_excess_active_balance`](#new-queue_excess_active_balance)
|
- [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_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)
|
- [New `compute_consolidation_epoch_and_update_churn`](#new-compute_consolidation_epoch_and_update_churn)
|
||||||
- [Updated `slash_validator`](#updated-slash_validator)
|
- [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`
|
#### New `compute_exit_epoch_and_update_churn`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
@ -159,6 +159,18 @@ def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState:
|
||||||
)
|
)
|
||||||
|
|
||||||
# [New in Electra:EIP7251]
|
# [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
|
# Ensure early adopters of compounding credentials go through the activation churn
|
||||||
for index, validator in enumerate(post.validators):
|
for index, validator in enumerate(post.validators):
|
||||||
if has_compounding_withdrawal_credential(validator):
|
if has_compounding_withdrawal_credential(validator):
|
||||||
|
|
Loading…
Reference in New Issue