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 safe_arith::SafeArith;
use types::{BeaconState, ChainSpec, 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>,
total_balances: &TotalBalances,
_spec: &ChainSpec,
) -> 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

@@ -2,8 +2,8 @@ use crate::EpochProcessingError;
use types::beacon_state::BeaconState;
use types::eth_spec::EthSpec;
pub fn process_participation_record_updates<T: EthSpec>(
state: &mut BeaconState<T>,
pub fn process_participation_record_updates<E: EthSpec>(
state: &mut BeaconState<E>,
) -> Result<(), EpochProcessingError> {
let base_state = state.as_base_mut()?;
base_state.previous_epoch_attestations =

View File

@@ -43,12 +43,12 @@ impl AttestationDelta {
}
/// Apply attester and proposer rewards.
pub fn process_rewards_and_penalties<T: EthSpec>(
state: &mut BeaconState<T>,
pub fn process_rewards_and_penalties<E: EthSpec>(
state: &mut BeaconState<E>,
validator_statuses: &ValidatorStatuses,
spec: &ChainSpec,
) -> Result<(), Error> {
if state.current_epoch() == T::genesis_epoch() {
if state.current_epoch() == E::genesis_epoch() {
return Ok(());
}
@@ -73,8 +73,8 @@ pub fn process_rewards_and_penalties<T: EthSpec>(
}
/// Apply rewards for participation in attestations during the previous epoch.
pub fn get_attestation_deltas_all<T: EthSpec>(
state: &BeaconState<T>,
pub fn get_attestation_deltas_all<E: EthSpec>(
state: &BeaconState<E>,
validator_statuses: &ValidatorStatuses,
spec: &ChainSpec,
) -> Result<Vec<AttestationDelta>, Error> {
@@ -83,8 +83,8 @@ pub fn get_attestation_deltas_all<T: EthSpec>(
/// Apply rewards for participation in attestations during the previous epoch, and only compute
/// rewards for a subset of validators.
pub fn get_attestation_deltas_subset<T: EthSpec>(
state: &BeaconState<T>,
pub fn get_attestation_deltas_subset<E: EthSpec>(
state: &BeaconState<E>,
validator_statuses: &ValidatorStatuses,
validators_subset: &Vec<usize>,
spec: &ChainSpec,
@@ -103,8 +103,8 @@ pub fn get_attestation_deltas_subset<T: EthSpec>(
/// returned, otherwise deltas for all validators are returned.
///
/// Returns a vec of validator indices to `AttestationDelta`.
fn get_attestation_deltas<T: EthSpec>(
state: &BeaconState<T>,
fn get_attestation_deltas<E: EthSpec>(
state: &BeaconState<E>,
validator_statuses: &ValidatorStatuses,
maybe_validators_subset: Option<&Vec<usize>>,
spec: &ChainSpec,

View File

@@ -188,8 +188,8 @@ impl ValidatorStatuses {
/// - Total balances for the current and previous epochs.
///
/// Spec v0.12.1
pub fn new<T: EthSpec>(
state: &BeaconState<T>,
pub fn new<E: EthSpec>(
state: &BeaconState<E>,
spec: &ChainSpec,
) -> Result<Self, BeaconStateError> {
let mut statuses = Vec::with_capacity(state.validators().len());
@@ -232,9 +232,9 @@ impl ValidatorStatuses {
/// `total_balances` fields.
///
/// Spec v0.12.1
pub fn process_attestations<T: EthSpec>(
pub fn process_attestations<E: EthSpec>(
&mut self,
state: &BeaconState<T>,
state: &BeaconState<E>,
) -> Result<(), BeaconStateError> {
let base_state = state.as_base()?;
for a in base_state
@@ -244,7 +244,7 @@ impl ValidatorStatuses {
{
let committee = state.get_beacon_committee(a.data.slot, a.data.index)?;
let attesting_indices =
get_attesting_indices::<T>(committee.committee, &a.aggregation_bits)?;
get_attesting_indices::<E>(committee.committee, &a.aggregation_bits)?;
let mut status = ValidatorStatus::default();
@@ -326,12 +326,12 @@ impl ValidatorStatuses {
/// beacon block in the given `epoch`.
///
/// Spec v0.12.1
fn target_matches_epoch_start_block<T: EthSpec>(
a: &PendingAttestation<T>,
state: &BeaconState<T>,
fn target_matches_epoch_start_block<E: EthSpec>(
a: &PendingAttestation<E>,
state: &BeaconState<E>,
epoch: Epoch,
) -> Result<bool, BeaconStateError> {
let slot = epoch.start_slot(T::slots_per_epoch());
let slot = epoch.start_slot(E::slots_per_epoch());
let state_boundary_root = *state.get_block_root(slot)?;
Ok(a.data.target.root == state_boundary_root)
@@ -341,9 +341,9 @@ fn target_matches_epoch_start_block<T: EthSpec>(
/// the current slot of the `PendingAttestation`.
///
/// Spec v0.12.1
fn has_common_beacon_block_root<T: EthSpec>(
a: &PendingAttestation<T>,
state: &BeaconState<T>,
fn has_common_beacon_block_root<E: EthSpec>(
a: &PendingAttestation<E>,
state: &BeaconState<E>,
) -> Result<bool, BeaconStateError> {
let state_block_root = *state.get_block_root(a.data.slot)?;