Address some review comments

This commit is contained in:
Pawan Dhananjay
2024-10-29 12:40:13 -07:00
parent 37c765809a
commit 9f85074854
2 changed files with 14 additions and 13 deletions

View File

@@ -636,10 +636,10 @@ fn is_valid_switch_to_compounding_request<E: EthSpec>(
state: &BeaconState<E>,
consolidation_request: &ConsolidationRequest,
spec: &ChainSpec,
) -> Result<bool, Error> {
) -> bool {
// Switch to compounding requires source and target be equal
if consolidation_request.source_pubkey != consolidation_request.target_pubkey {
return Ok(false);
return false;
}
// Verify pubkey exists
@@ -648,31 +648,34 @@ fn is_valid_switch_to_compounding_request<E: EthSpec>(
.get(&consolidation_request.source_pubkey)
else {
// source validator doesn't exist
return Ok(false);
return false;
};
let source_validator = state.get_validator(source_index)?;
let Ok(source_validator) = state.get_validator(source_index) else {
// Validator must exist in the state else it wouldn't exist in the pubkey cache either
return false;
};
// Verify the source withdrawal credentials
if let Some(withdrawal_address) = source_validator.get_eth1_withdrawal_credential(spec) {
if withdrawal_address != consolidation_request.source_address {
return Ok(false);
return false;
}
} else {
// Source doen't have execution withdrawal credentials
return Ok(false);
// Source doesn't have eth1 withdrawal credentials
return false;
}
// Verify the source is active
let current_epoch = state.current_epoch();
if !source_validator.is_active_at(current_epoch) {
return Ok(false);
return false;
}
// Verify exits for source has not been initiated
if source_validator.exit_epoch != spec.far_future_epoch {
return Ok(false);
return false;
}
Ok(true)
true
}
pub fn process_consolidation_request<E: EthSpec>(
@@ -680,8 +683,7 @@ pub fn process_consolidation_request<E: EthSpec>(
consolidation_request: &ConsolidationRequest,
spec: &ChainSpec,
) -> Result<(), BlockProcessingError> {
dbg!("here");
if is_valid_switch_to_compounding_request(state, consolidation_request, spec)? {
if is_valid_switch_to_compounding_request(state, consolidation_request, spec) {
let Some(source_index) = state
.pubkey_cache()
.get(&consolidation_request.source_pubkey)