Use E for EthSpec globally (#5264)

* Use `E` for `EthSpec` globally

* Fix tests

* Merge branch 'unstable' into e-ethspec

* Merge branch 'unstable' into e-ethspec

# Conflicts:
#	beacon_node/execution_layer/src/engine_api.rs
#	beacon_node/execution_layer/src/engine_api/http.rs
#	beacon_node/execution_layer/src/engine_api/json_structures.rs
#	beacon_node/execution_layer/src/test_utils/handle_rpc.rs
#	beacon_node/store/src/partial_beacon_state.rs
#	consensus/types/src/beacon_block.rs
#	consensus/types/src/beacon_block_body.rs
#	consensus/types/src/beacon_state.rs
#	consensus/types/src/config_and_preset.rs
#	consensus/types/src/execution_payload.rs
#	consensus/types/src/execution_payload_header.rs
#	consensus/types/src/light_client_optimistic_update.rs
#	consensus/types/src/payload.rs
#	lcli/src/parse_ssz.rs
This commit is contained in:
Mac L
2024-04-03 02:12:25 +11:00
committed by GitHub
parent f8fdb71f50
commit 969d12dc6f
230 changed files with 2743 additions and 2792 deletions

View File

@@ -7,14 +7,14 @@ use types::chain_spec::ChainSpec;
use types::consts::altair::TIMELY_TARGET_FLAG_INDEX;
use types::eth_spec::EthSpec;
pub fn process_inactivity_updates<T: EthSpec>(
state: &mut BeaconState<T>,
pub fn process_inactivity_updates<E: EthSpec>(
state: &mut BeaconState<E>,
participation_cache: &ParticipationCache,
spec: &ChainSpec,
) -> Result<(), EpochProcessingError> {
let previous_epoch = state.previous_epoch();
// Score updates based on previous epoch participation, skip genesis epoch
if state.current_epoch() == T::genesis_epoch() {
if state.current_epoch() == E::genesis_epoch() {
return Ok(());
}

View File

@@ -8,13 +8,13 @@ use types::consts::altair::TIMELY_TARGET_FLAG_INDEX;
use types::{BeaconState, EthSpec};
/// Update the justified and finalized checkpoints for matching target attestations.
pub fn process_justification_and_finalization<T: EthSpec>(
state: &BeaconState<T>,
pub fn process_justification_and_finalization<E: EthSpec>(
state: &BeaconState<E>,
participation_cache: &ParticipationCache,
) -> Result<JustificationAndFinalizationState<T>, Error> {
) -> Result<JustificationAndFinalizationState<E>, Error> {
let justification_and_finalization_state = JustificationAndFinalizationState::new(state);
if state.current_epoch() <= T::genesis_epoch().safe_add(1)? {
if state.current_epoch() <= E::genesis_epoch().safe_add(1)? {
return Ok(justification_and_finalization_state);
}

View File

@@ -50,7 +50,7 @@ struct SingleEpochParticipationCache {
}
impl SingleEpochParticipationCache {
fn new<T: EthSpec>(state: &BeaconState<T>, spec: &ChainSpec) -> Self {
fn new<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSpec) -> Self {
let num_validators = state.validators().len();
let zero_balance = Balance::zero(spec.effective_balance_increment);
@@ -104,10 +104,10 @@ impl SingleEpochParticipationCache {
/// - The provided `state` **must** be Altair. An error will be returned otherwise.
/// - An error will be returned if the `val_index` validator is inactive at the given
/// `relative_epoch`.
fn process_active_validator<T: EthSpec>(
fn process_active_validator<E: EthSpec>(
&mut self,
val_index: usize,
state: &BeaconState<T>,
state: &BeaconState<E>,
current_epoch: Epoch,
relative_epoch: RelativeEpoch,
) -> Result<(), BeaconStateError> {
@@ -173,8 +173,8 @@ impl ParticipationCache {
/// ## Errors
///
/// - The provided `state` **must** be an Altair state. An error will be returned otherwise.
pub fn new<T: EthSpec>(
state: &BeaconState<T>,
pub fn new<E: EthSpec>(
state: &BeaconState<E>,
spec: &ChainSpec,
) -> Result<Self, BeaconStateError> {
let current_epoch = state.current_epoch();

View File

@@ -4,8 +4,8 @@ use types::eth_spec::EthSpec;
use types::participation_flags::ParticipationFlags;
use types::VariableList;
pub fn process_participation_flag_updates<T: EthSpec>(
state: &mut BeaconState<T>,
pub fn process_participation_flag_updates<E: EthSpec>(
state: &mut BeaconState<E>,
) -> Result<(), EpochProcessingError> {
*state.previous_epoch_participation_mut()? =
std::mem::take(state.current_epoch_participation_mut()?);

View File

@@ -15,12 +15,12 @@ use crate::per_epoch_processing::{Delta, Error};
/// Apply attester and proposer rewards.
///
/// Spec v1.1.0
pub fn process_rewards_and_penalties<T: EthSpec>(
state: &mut BeaconState<T>,
pub fn process_rewards_and_penalties<E: EthSpec>(
state: &mut BeaconState<E>,
participation_cache: &ParticipationCache,
spec: &ChainSpec,
) -> Result<(), Error> {
if state.current_epoch() == T::genesis_epoch() {
if state.current_epoch() == E::genesis_epoch() {
return Ok(());
}
@@ -54,9 +54,9 @@ pub fn process_rewards_and_penalties<T: EthSpec>(
/// Return the deltas for a given flag index by scanning through the participation flags.
///
/// Spec v1.1.0
pub fn get_flag_index_deltas<T: EthSpec>(
pub fn get_flag_index_deltas<E: EthSpec>(
deltas: &mut [Delta],
state: &BeaconState<T>,
state: &BeaconState<E>,
flag_index: usize,
total_active_balance: u64,
participation_cache: &ParticipationCache,
@@ -104,9 +104,9 @@ pub fn get_flag_weight(flag_index: usize) -> Result<u64, Error> {
.ok_or(Error::InvalidFlagIndex(flag_index))
}
pub fn get_inactivity_penalty_deltas<T: EthSpec>(
pub fn get_inactivity_penalty_deltas<E: EthSpec>(
deltas: &mut [Delta],
state: &BeaconState<T>,
state: &BeaconState<E>,
participation_cache: &ParticipationCache,
spec: &ChainSpec,
) -> Result<(), Error> {

View File

@@ -5,8 +5,8 @@ use types::beacon_state::BeaconState;
use types::chain_spec::ChainSpec;
use types::eth_spec::EthSpec;
pub fn process_sync_committee_updates<T: EthSpec>(
state: &mut BeaconState<T>,
pub fn process_sync_committee_updates<E: EthSpec>(
state: &mut BeaconState<E>,
spec: &ChainSpec,
) -> Result<(), EpochProcessingError> {
let next_epoch = state.next_epoch()?;