From e35a96cc1c3ff99942e185c8fbca45a746a6a6a7 Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sun, 21 Jun 2026 17:36:47 +0300 Subject: [PATCH] Fix builder top up bug --- .../per_block_processing/process_operations.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/consensus/state_processing/src/per_block_processing/process_operations.rs b/consensus/state_processing/src/per_block_processing/process_operations.rs index 0ab66a3224..cb305d6127 100644 --- a/consensus/state_processing/src/per_block_processing/process_operations.rs +++ b/consensus/state_processing/src/per_block_processing/process_operations.rs @@ -1031,12 +1031,21 @@ pub fn apply_deposit_for_builder( } } Some(builder_index) => { - state + let current_epoch = state.current_epoch(); + let builder = state .builders_mut()? .get_mut(builder_index as usize) - .ok_or(BeaconStateError::UnknownBuilder(builder_index))? - .balance - .safe_add_assign(amount)?; + .ok_or(BeaconStateError::UnknownBuilder(builder_index))?; + + // Increase balance by deposit amount + builder.balance.safe_add_assign(amount)?; + + // If exited, reset the withdrawable epoch + if builder.withdrawable_epoch != spec.far_future_epoch { + builder.withdrawable_epoch = + current_epoch.safe_add(spec.min_builder_withdrawability_delay)?; + } + Ok(Some(builder_index)) } }