mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +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>,
|
state: &BeaconState<E>,
|
||||||
consolidation_request: &ConsolidationRequest,
|
consolidation_request: &ConsolidationRequest,
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
) -> Result<bool, Error> {
|
) -> bool {
|
||||||
// Switch to compounding requires source and target be equal
|
// Switch to compounding requires source and target be equal
|
||||||
if consolidation_request.source_pubkey != consolidation_request.target_pubkey {
|
if consolidation_request.source_pubkey != consolidation_request.target_pubkey {
|
||||||
return Ok(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify pubkey exists
|
// Verify pubkey exists
|
||||||
@@ -648,31 +648,34 @@ fn is_valid_switch_to_compounding_request<E: EthSpec>(
|
|||||||
.get(&consolidation_request.source_pubkey)
|
.get(&consolidation_request.source_pubkey)
|
||||||
else {
|
else {
|
||||||
// source validator doesn't exist
|
// 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
|
// Verify the source withdrawal credentials
|
||||||
if let Some(withdrawal_address) = source_validator.get_eth1_withdrawal_credential(spec) {
|
if let Some(withdrawal_address) = source_validator.get_eth1_withdrawal_credential(spec) {
|
||||||
if withdrawal_address != consolidation_request.source_address {
|
if withdrawal_address != consolidation_request.source_address {
|
||||||
return Ok(false);
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Source doen't have execution withdrawal credentials
|
// Source doesn't have eth1 withdrawal credentials
|
||||||
return Ok(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the source is active
|
// Verify the source is active
|
||||||
let current_epoch = state.current_epoch();
|
let current_epoch = state.current_epoch();
|
||||||
if !source_validator.is_active_at(current_epoch) {
|
if !source_validator.is_active_at(current_epoch) {
|
||||||
return Ok(false);
|
return false;
|
||||||
}
|
}
|
||||||
// Verify exits for source has not been initiated
|
// Verify exits for source has not been initiated
|
||||||
if source_validator.exit_epoch != spec.far_future_epoch {
|
if source_validator.exit_epoch != spec.far_future_epoch {
|
||||||
return Ok(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(true)
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_consolidation_request<E: EthSpec>(
|
pub fn process_consolidation_request<E: EthSpec>(
|
||||||
@@ -680,8 +683,7 @@ pub fn process_consolidation_request<E: EthSpec>(
|
|||||||
consolidation_request: &ConsolidationRequest,
|
consolidation_request: &ConsolidationRequest,
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
) -> Result<(), BlockProcessingError> {
|
) -> 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
|
let Some(source_index) = state
|
||||||
.pubkey_cache()
|
.pubkey_cache()
|
||||||
.get(&consolidation_request.source_pubkey)
|
.get(&consolidation_request.source_pubkey)
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ pub fn upgrade_to_electra<E: EthSpec>(
|
|||||||
validator.activation_eligibility_epoch = spec.far_future_epoch;
|
validator.activation_eligibility_epoch = spec.far_future_epoch;
|
||||||
let pubkey = validator.pubkey;
|
let pubkey = validator.pubkey;
|
||||||
let withdrawal_credentials = validator.withdrawal_credentials;
|
let withdrawal_credentials = validator.withdrawal_credentials;
|
||||||
dbg!("is this getting hit");
|
|
||||||
|
|
||||||
post.pending_deposits_mut()?
|
post.pending_deposits_mut()?
|
||||||
.push(PendingDeposit {
|
.push(PendingDeposit {
|
||||||
|
|||||||
Reference in New Issue
Block a user