Created
July 4, 2023 13:01
-
-
Save mkalinin/37b69aa922c0d9c0d7237177f30ec81f to your computer and use it in GitHub Desktop.
MaxEB routines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```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