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 73c0fb8e42..42a79a6830 100644 --- a/consensus/state_processing/src/per_block_processing/process_operations.rs +++ b/consensus/state_processing/src/per_block_processing/process_operations.rs @@ -656,7 +656,19 @@ fn is_valid_switch_to_compounding_request( 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; } diff --git a/consensus/types/src/validator.rs b/consensus/types/src/validator.rs index 3717297abc..159f2f48c7 100644 --- a/consensus/types/src/validator.rs +++ b/consensus/types/src/validator.rs @@ -181,17 +181,6 @@ impl Validator { .flatten() } - pub fn get_eth1_withdrawal_credential(&self, spec: &ChainSpec) -> Option
{ - 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!