This commit is contained in:
Pawan Dhananjay
2024-10-29 12:59:01 -07:00
parent 9f85074854
commit 707338d6ae
2 changed files with 13 additions and 12 deletions

View File

@@ -656,7 +656,19 @@ fn is_valid_switch_to_compounding_request<E: EthSpec>(
return false;
};
// Verify the source withdrawal credentials
if let Some(withdrawal_address) = source_validator.get_eth1_withdrawal_credential(spec) {
// Note: We need to specifically check for eth1 withdrawal credentials here
// If the validator is already compounding, the compounding request is not valid.
if let Some(withdrawal_address) = source_validator
.has_eth1_withdrawal_credential(spec)
.then(|| {
source_validator
.withdrawal_credentials
.as_slice()
.get(12..)
.map(Address::from_slice)
})
.flatten()
{
if withdrawal_address != consolidation_request.source_address {
return false;
}

View File

@@ -181,17 +181,6 @@ impl Validator {
.flatten()
}
pub fn get_eth1_withdrawal_credential(&self, spec: &ChainSpec) -> Option<Address> {
self.has_eth1_withdrawal_credential(spec)
.then(|| {
self.withdrawal_credentials
.as_slice()
.get(12..)
.map(Address::from_slice)
})
.flatten()
}
/// Changes withdrawal credentials to the provided eth1 execution address.
///
/// WARNING: this function does NO VALIDATION - it just does it!