mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 19:02:42 +00:00
Address some review comments
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user