Skip to content

Commit a07e144

Browse files
authored
Merge pull request #3659 from ethDreamer/activation_rate_limiting
EIP-7251: Enforce Activation Rate Limit at Fork Transition
2 parents 3b259b6 + 38dfd4a commit a07e144

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

specs/electra/beacon-chain.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
- [Updated `initiate_validator_exit`](#updated--initiate_validator_exit)
6262
- [New `switch_to_compounding_validator`](#new-switch_to_compounding_validator)
6363
- [New `queue_excess_active_balance`](#new-queue_excess_active_balance)
64+
- [New `queue_entire_balance_and_reset_validator`](#new-queue_entire_balance_and_reset_validator)
6465
- [New `compute_exit_epoch_and_update_churn`](#new-compute_exit_epoch_and_update_churn)
6566
- [New `compute_consolidation_epoch_and_update_churn`](#new-compute_consolidation_epoch_and_update_churn)
6667
- [Updated `slash_validator`](#updated-slash_validator)
@@ -639,6 +640,19 @@ def queue_excess_active_balance(state: BeaconState, index: ValidatorIndex) -> No
639640
)
640641
```
641642

643+
#### New `queue_entire_balance_and_reset_validator`
644+
```python
645+
def queue_entire_balance_and_reset_validator(state: BeaconState, index: ValidatorIndex) -> None:
646+
balance = state.balances[index]
647+
state.balances[index] = 0
648+
validator = state.validators[index]
649+
validator.effective_balance = 0
650+
validator.activation_eligibility_epoch = FAR_FUTURE_EPOCH
651+
state.pending_balance_deposits.append(
652+
PendingBalanceDeposit(index=index, amount=balance)
653+
)
654+
```
655+
642656
#### New `compute_exit_epoch_and_update_churn`
643657

644658
```python

specs/electra/fork.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState:
159159
)
160160

161161
# [New in Electra:EIP7251]
162+
# add validators that are not yet active to pending balance deposits
163+
pre_activation = sorted([
164+
index for index, validator in enumerate(post.validators)
165+
if validator.activation_epoch == FAR_FUTURE_EPOCH
166+
], key=lambda index: (
167+
post.validators[index].activation_eligibility_epoch,
168+
index
169+
))
170+
171+
for index in pre_activation:
172+
queue_entire_balance_and_reset_validator(post, ValidatorIndex(index))
173+
162174
# Ensure early adopters of compounding credentials go through the activation churn
163175
for index, validator in enumerate(post.validators):
164176
if has_compounding_withdrawal_credential(validator):

0 commit comments

Comments
 (0)