From f6359f9afbb1b3d4835198b4d12d8db1ed62a280 Mon Sep 17 00:00:00 2001 From: Mark Mackey Date: Tue, 19 Mar 2024 13:31:55 -0500 Subject: [PATCH] Fix Bug in process_pending_balance_deposits --- specs/_features/eip7251/beacon-chain.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/specs/_features/eip7251/beacon-chain.md b/specs/_features/eip7251/beacon-chain.md index ef86dd177..b70be3866 100644 --- a/specs/_features/eip7251/beacon-chain.md +++ b/specs/_features/eip7251/beacon-chain.md @@ -533,17 +533,23 @@ def process_registry_updates(state: BeaconState) -> None: ```python def process_pending_balance_deposits(state: BeaconState) -> None: - state.deposit_balance_to_consume += get_activation_exit_churn_limit(state) - next_pending_deposit_index = 0 - for pending_balance_deposit in state.pending_balance_deposits: - if state.deposit_balance_to_consume < pending_balance_deposit.amount: + available_for_processing = state.deposit_balance_to_consume + get_activation_exit_churn_limit(state) + processed_amount = 0 + next_deposit_index = 0 + + for deposit in state.pending_balance_deposits: + if processed_amount + deposit.amount > available_for_processing: break + increase_balance(state, deposit.index, deposit.amount) + processed_amount += deposit.amount + next_deposit_index += 1 - state.deposit_balance_to_consume -= pending_balance_deposit.amount - increase_balance(state, pending_balance_deposit.index, pending_balance_deposit.amount) - next_pending_deposit_index += 1 + state.pending_balance_deposits = state.pending_balance_deposits[next_deposit_index:] - state.pending_balance_deposits = state.pending_balance_deposits[next_pending_deposit_index:] + if len(state.pending_balance_deposits) == 0: + state.deposit_balance_to_consume = 0 + else: + state.deposit_balance_to_consume = available_for_processing - processed_amount ``` #### New `process_pending_consolidations`