From 9f850748548612f004ff009dc3e8fce7d6829898 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 29 Oct 2024 12:40:13 -0700 Subject: [PATCH] Address some review comments --- .../process_operations.rs | 26 ++++++++++--------- .../state_processing/src/upgrade/electra.rs | 1 - 2 files changed, 14 insertions(+), 13 deletions(-) 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 a405156acb..73c0fb8e42 100644 --- a/consensus/state_processing/src/per_block_processing/process_operations.rs +++ b/consensus/state_processing/src/per_block_processing/process_operations.rs @@ -636,10 +636,10 @@ fn is_valid_switch_to_compounding_request( state: &BeaconState, consolidation_request: &ConsolidationRequest, spec: &ChainSpec, -) -> Result { +) -> 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( .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( @@ -680,8 +683,7 @@ pub fn process_consolidation_request( 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) diff --git a/consensus/state_processing/src/upgrade/electra.rs b/consensus/state_processing/src/upgrade/electra.rs index 7287bbff08..c69c8df5a1 100644 --- a/consensus/state_processing/src/upgrade/electra.rs +++ b/consensus/state_processing/src/upgrade/electra.rs @@ -73,7 +73,6 @@ pub fn upgrade_to_electra( validator.activation_eligibility_epoch = spec.far_future_epoch; let pubkey = validator.pubkey; let withdrawal_credentials = validator.withdrawal_credentials; - dbg!("is this getting hit"); post.pending_deposits_mut()? .push(PendingDeposit {