Skip to content

Instantly share code, notes, and snippets.

@mkalinin
Created July 4, 2023 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkalinin/37b69aa922c0d9c0d7237177f30ec81f to your computer and use it in GitHub Desktop.
Save mkalinin/37b69aa922c0d9c0d7237177f30ec81f to your computer and use it in GitHub Desktop.
MaxEB routines
```python
def process_pending_balance_exits(state: BeaconState) -> None:
state.withdrawal_balance_to_consume += get_validator_churn_limit(state)
for pending_balance_withdrawal in state.pending_balance_withdrawals:
if pending_balance_withdrawal.withdrawable_epoch != FAR_FUTURE_EPOCH:
continue
validator = state.validators[pending_balance_withdrawal.index]
exiting_balance = Gwei(0)
if pending_balance_withdrawal.is_exit:
exiting_balance = state.balances[validator.index]
else:
partially_withdrawable_balance = state.balances[validator.index] - MIN_ACTIVATION_BALANCE
exiting_balance = min(partially_withdrawable_balance, pending_balance_withdrawal.amount)
if state.withdrawal_balance_to_consume < exiting_balance:
break
exit_epoch = compute_activation_exit_epoch(get_current_epoch(state))
pending_balance_withdrawal.withdrawable_epoch = Epoch(exit_epoch + config.MIN_VALIDATOR_WITHDRAWABILITY_DELAY)
if pending_balance_withdrawal.is_exit:
validator.exit_epoch = exit_epoch
validator.withdrawable_epoch = pending_balance_withdrawal.withdrawable_epoch
state.withdrawal_balance_to_consume -= exiting_balance
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment