Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions consensus/state_processing/src/per_block_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ pub fn get_expected_withdrawals<E: EthSpec>(
break;
}

let withdrawal_balance = state.get_balance(withdrawal.index as usize)?;
let validator = state.get_validator(withdrawal.index as usize)?;
let withdrawal_balance = state.get_balance(withdrawal.validator_index as usize)?;
let validator = state.get_validator(withdrawal.validator_index as usize)?;

let has_sufficient_effective_balance =
validator.effective_balance >= spec.min_activation_balance;
Expand All @@ -539,7 +539,7 @@ pub fn get_expected_withdrawals<E: EthSpec>(
);
withdrawals.push(Withdrawal {
index: withdrawal_index,
validator_index: withdrawal.index,
validator_index: withdrawal.validator_index,
address: validator
.get_execution_withdrawal_address(spec)
.ok_or(BeaconStateError::NonExecutionAddresWithdrawalCredential)?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ pub fn process_withdrawal_requests<E: EthSpec>(
}

// Verify pubkey exists
let Some(index) = state.pubkey_cache().get(&request.validator_pubkey) else {
let Some(validator_index) = state.pubkey_cache().get(&request.validator_pubkey) else {
continue;
};

let validator = state.get_validator(index)?;
let validator = state.get_validator(validator_index)?;
// Verify withdrawal credentials
let has_correct_credential = validator.has_execution_withdrawal_credential(spec);
let is_correct_source_address = validator
Expand Down Expand Up @@ -549,16 +549,16 @@ pub fn process_withdrawal_requests<E: EthSpec>(
continue;
}

let pending_balance_to_withdraw = state.get_pending_balance_to_withdraw(index)?;
let pending_balance_to_withdraw = state.get_pending_balance_to_withdraw(validator_index)?;
if is_full_exit_request {
// Only exit validator if it has no pending withdrawals in the queue
if pending_balance_to_withdraw == 0 {
initiate_validator_exit(state, index, spec)?
initiate_validator_exit(state, validator_index, spec)?
}
continue;
}

let balance = state.get_balance(index)?;
let balance = state.get_balance(validator_index)?;
let has_sufficient_effective_balance =
validator.effective_balance >= spec.min_activation_balance;
let has_excess_balance = balance
Expand All @@ -583,7 +583,7 @@ pub fn process_withdrawal_requests<E: EthSpec>(
state
.pending_partial_withdrawals_mut()?
.push(PendingPartialWithdrawal {
index: index as u64,
validator_index: validator_index as u64,
amount: to_withdraw,
withdrawable_epoch,
})?;
Expand Down
2 changes: 1 addition & 1 deletion consensus/types/src/beacon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,7 @@ impl<E: EthSpec> BeaconState<E> {
for withdrawal in self
.pending_partial_withdrawals()?
.iter()
.filter(|withdrawal| withdrawal.index as usize == validator_index)
.filter(|withdrawal| withdrawal.validator_index as usize == validator_index)
{
pending_balance.safe_add_assign(withdrawal.amount)?;
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/types/src/pending_partial_withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tree_hash_derive::TreeHash;
)]
pub struct PendingPartialWithdrawal {
#[serde(with = "serde_utils::quoted_u64")]
pub index: u64,
pub validator_index: u64,
#[serde(with = "serde_utils::quoted_u64")]
pub amount: u64,
pub withdrawable_epoch: Epoch,
Expand Down
Loading