mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Rename PendingPartialWithdraw index field to validator_index
This commit is contained in:
@@ -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;
|
||||
@@ -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)?,
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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,
|
||||
})?;
|
||||
|
||||
@@ -2193,7 +2193,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)?;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user