diff --git a/consensus/state_processing/src/per_block_processing.rs b/consensus/state_processing/src/per_block_processing.rs index 4be4ac9581..b70579c826 100644 --- a/consensus/state_processing/src/per_block_processing.rs +++ b/consensus/state_processing/src/per_block_processing.rs @@ -547,7 +547,13 @@ pub fn get_expected_withdrawals( withdrawals.push(Withdrawal { index: withdrawal_index, validator_index: withdrawal.index, - address: Address::from_slice(&validator.withdrawal_credentials[12..]), + address: Address::from_slice( + validator + .withdrawal_credentials + .0 + .get(12..) + .ok_or(BeaconStateError::IndexNotSupported(12))?, + ), amount: withdrawable_balance, }); withdrawal_index.safe_add_assign(1)?; @@ -634,12 +640,9 @@ pub fn process_withdrawals>( if let Some(partial_withdrawals_count) = partial_withdrawals_count { let new_partial_withdrawals = state .pending_partial_withdrawals()? - .to_vec() - .get(partial_withdrawals_count..) - .ok_or(BeaconStateError::PartialWithdrawalCountInvalid( - partial_withdrawals_count, - ))? - .to_vec(); + .iter_from(partial_withdrawals_count)? + .cloned() + .collect::>(); *state.pending_partial_withdrawals_mut()? = List::new(new_partial_withdrawals)?; }