Skip to content

Commit

Permalink
Update ethereum-consensus/src/capella/block_processing.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Stokes <[email protected]>
  • Loading branch information
distributedstatemachine and ralexstokes committed Sep 25, 2023
1 parent 2c9d9f7 commit c689eeb
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions ethereum-consensus/src/capella/block_processing.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
use crate::{
capella::{
compute_domain, compute_timestamp_at_slot, decrease_balance,
get_current_epoch, get_randao_mix, is_fully_withdrawable_validator,
is_partially_withdrawable_validator, process_attestation, process_attester_slashing,
process_block_header, process_deposit, process_eth1_data, process_proposer_slashing,
process_randao, process_sync_aggregate, process_voluntary_exit, BeaconBlock,
BeaconBlockBody, BeaconState, DomainType, ExecutionAddress, ExecutionEngine,
ExecutionPayload, ExecutionPayloadHeader, NewPayloadRequest, SignedBlsToExecutionChange,
Withdrawal,
compute_domain, compute_timestamp_at_slot, decrease_balance, get_current_epoch,
get_randao_mix, is_fully_withdrawable_validator, is_partially_withdrawable_validator,
process_attestation, process_attester_slashing, process_block_header, process_deposit,
process_eth1_data, process_proposer_slashing, process_randao, process_sync_aggregate,
process_voluntary_exit, BeaconBlock, BeaconBlockBody, BeaconState, BlsPublicKey,
DomainType, ExecutionAddress, ExecutionEngine, ExecutionPayload, ExecutionPayloadHeader,
NewPayloadRequest, SignedBlsToExecutionChange, Withdrawal,
},
primitives::{BLS_WITHDRAWAL_PREFIX, ETH1_ADDRESS_WITHDRAWAL_PREFIX},
signing::verify_signed_data,
ssz::prelude::*,
state_transition::{
invalid_operation_error, Context, InvalidDeposit, InvalidExecutionPayload,
InvalidOperation, InvalidWithdrawals, Result,
},
};

use super::verify_signed_data;

pub fn process_bls_to_execution_change<
const SLOTS_PER_HISTORICAL_ROOT: usize,
const HISTORICAL_ROOTS_LIMIT: usize,
Expand Down Expand Up @@ -52,7 +50,7 @@ pub fn process_bls_to_execution_change<
if address_change.validator_index >= state.validators.len() {
return Err(invalid_operation_error(InvalidOperation::ValidatorIndex(
address_change.validator_index,
)))
)));
}

let withdrawal_credentials_prefix =
Expand All @@ -61,7 +59,7 @@ pub fn process_bls_to_execution_change<
if withdrawal_credentials_prefix != BLS_WITHDRAWAL_PREFIX {
return Err(invalid_operation_error(InvalidOperation::WithdrawalCredentialsPrefix(
state.validators[address_change.validator_index].withdrawal_credentials[0],
)))
)));
}

let domain = compute_domain(
Expand All @@ -76,7 +74,7 @@ pub fn process_bls_to_execution_change<
if signed_data.is_err() {
return Err(invalid_operation_error(InvalidOperation::ExecutionChange(
signed_address_change.signature.clone(),
)))
)));
}

let validator = &mut state.validators[address_change.validator_index];
Expand Down Expand Up @@ -152,7 +150,7 @@ pub fn process_operations<
expected: expected_deposit_count,
count: body.deposits.len(),
},
)))
)));
}
body.proposer_slashings
.iter_mut()
Expand Down Expand Up @@ -224,7 +222,7 @@ pub fn process_execution_payload<
expected: state.latest_execution_payload_header.block_hash.clone(),
}
.into(),
))
));
}

let current_epoch = get_current_epoch(state, context);
Expand All @@ -236,7 +234,7 @@ pub fn process_execution_payload<
expected: randao_mix.clone(),
}
.into(),
))
));
}

let timestamp = compute_timestamp_at_slot(state, state.slot, context)?;
Expand All @@ -247,7 +245,7 @@ pub fn process_execution_payload<
expected: timestamp,
}
.into(),
))
));
}

let new_payload_request = NewPayloadRequest(payload);
Expand Down

0 comments on commit c689eeb

Please sign in to comment.