From 6f5cc4baf5e6b8cb9b753085fb9738c540147b8a Mon Sep 17 00:00:00 2001 From: Mikhail Kalinin Date: Wed, 27 Mar 2024 17:35:27 +0600 Subject: [PATCH] Replace MIN_ACTIVATION_BALANCE with MAX_EFFECTIVE_BALANCE --- specs/_features/eip7251/beacon-chain.md | 28 +++++++++---------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/specs/_features/eip7251/beacon-chain.md b/specs/_features/eip7251/beacon-chain.md index 19fb7a91d..b7c2ffdb1 100644 --- a/specs/_features/eip7251/beacon-chain.md +++ b/specs/_features/eip7251/beacon-chain.md @@ -373,7 +373,7 @@ def get_validator_max_effective_balance(validator: Validator) -> Gwei: if has_compounding_withdrawal_credential(validator): return MAX_EFFECTIVE_BALANCE_EIP7251 else: - return MIN_ACTIVATION_BALANCE + return MAX_EFFECTIVE_BALANCE ``` #### New `get_churn_limit` @@ -411,12 +411,8 @@ def get_consolidation_churn_limit(state: BeaconState) -> Gwei: ```python def get_active_balance(state: BeaconState, validator_index: ValidatorIndex) -> Gwei: - active_balance_ceil = ( - MIN_ACTIVATION_BALANCE - if has_eth1_withdrawal_credential(state.validators[validator_index]) - else MAX_EFFECTIVE_BALANCE_EIP7251 - ) - return min(state.balances[validator_index], active_balance_ceil) + max_effective_balance = get_validator_max_effective_balance(state.validators[validator_index]) + return min(state.balances[validator_index], max_effective_balance) ``` ### Beacon state mutators @@ -649,16 +645,12 @@ def process_effective_balance_updates(state: BeaconState) -> None: HYSTERESIS_INCREMENT = uint64(EFFECTIVE_BALANCE_INCREMENT // HYSTERESIS_QUOTIENT) DOWNWARD_THRESHOLD = HYSTERESIS_INCREMENT * HYSTERESIS_DOWNWARD_MULTIPLIER UPWARD_THRESHOLD = HYSTERESIS_INCREMENT * HYSTERESIS_UPWARD_MULTIPLIER - EFFECTIVE_BALANCE_LIMIT = ( - MAX_EFFECTIVE_BALANCE_EIP7251 if has_compounding_withdrawal_credential(validator) - else MIN_ACTIVATION_BALANCE - ) - + max_effective_balance = get_validator_max_effective_balance(validator) if ( balance + DOWNWARD_THRESHOLD < validator.effective_balance or validator.effective_balance + UPWARD_THRESHOLD < balance ): - validator.effective_balance = min(balance - balance % EFFECTIVE_BALANCE_INCREMENT, EFFECTIVE_BALANCE_LIMIT) + validator.effective_balance = min(balance - balance % EFFECTIVE_BALANCE_INCREMENT, max_effective_balance) # [Modified in EIP7251] ``` ### Block processing @@ -689,8 +681,8 @@ def get_expected_withdrawals(state: BeaconState) -> Tuple[Sequence[Withdrawal], break validator = state.validators[withdrawal.index] - if validator.exit_epoch == FAR_FUTURE_EPOCH and state.balances[withdrawal.index] > MIN_ACTIVATION_BALANCE: - withdrawable_balance = min(state.balances[withdrawal.index] - MIN_ACTIVATION_BALANCE, withdrawal.amount) + if validator.exit_epoch == FAR_FUTURE_EPOCH and state.balances[withdrawal.index] > MAX_EFFECTIVE_BALANCE: + withdrawable_balance = min(state.balances[withdrawal.index] - MAX_EFFECTIVE_BALANCE, withdrawal.amount) withdrawals.append(Withdrawal( index=withdrawal_index, validator_index=withdrawal.index, @@ -909,12 +901,12 @@ def process_execution_layer_withdraw_request( return - has_excess_balance = state.balances[index] > MIN_ACTIVATION_BALANCE + pending_balance_to_withdraw + has_excess_balance = state.balances[index] > MAX_EFFECTIVE_BALANCE + pending_balance_to_withdraw # Only allow partial withdrawals with compounding withdrawal credentials if has_compounding_withdrawal_credential(validator) and has_excess_balance: to_withdraw = min( - state.balances[index] - MIN_ACTIVATION_BALANCE - pending_balance_to_withdraw, + state.balances[index] - MAX_EFFECTIVE_BALANCE - pending_balance_to_withdraw, amount ) exit_queue_epoch = compute_exit_epoch_and_update_churn(state, to_withdraw) @@ -935,7 +927,7 @@ def process_consolidation(state: BeaconState, signed_consolidation: SignedConsol # If the pending consolidations queue is full, no consolidations are allowed in the block assert len(state.pending_consolidations) < PENDING_CONSOLIDATIONS_LIMIT # If there is too little available consolidation churn limit, no consolidations are allowed in the block - assert get_consolidation_churn_limit(state) > MIN_ACTIVATION_BALANCE + assert get_consolidation_churn_limit(state) > MAX_EFFECTIVE_BALANCE consolidation = signed_consolidation.message # Verify that source != target, so a consolidation cannot be used as an exit. assert consolidation.source_index != consolidation.target_index