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

@@ -12,17 +12,17 @@ use types::{
};
#[derive(Debug, Clone)]
pub struct AttMaxCover<'a, T: EthSpec> {
pub struct AttMaxCover<'a, E: EthSpec> {
/// Underlying attestation.
pub att: AttestationRef<'a, T>,
pub att: AttestationRef<'a, E>,
/// Mapping of validator indices and their rewards.
pub fresh_validators_rewards: HashMap<u64, u64>,
}
impl<'a, T: EthSpec> AttMaxCover<'a, T> {
impl<'a, E: EthSpec> AttMaxCover<'a, E> {
pub fn new(
att: AttestationRef<'a, T>,
state: &BeaconState<T>,
att: AttestationRef<'a, E>,
state: &BeaconState<E>,
reward_cache: &'a RewardCache,
total_active_balance: u64,
spec: &ChainSpec,
@@ -36,9 +36,9 @@ impl<'a, T: EthSpec> AttMaxCover<'a, T> {
/// Initialise an attestation cover object for base/phase0 hard fork.
pub fn new_for_base(
att: AttestationRef<'a, T>,
state: &BeaconState<T>,
base_state: &BeaconStateBase<T>,
att: AttestationRef<'a, E>,
state: &BeaconState<E>,
base_state: &BeaconStateBase<E>,
total_active_balance: u64,
spec: &ChainSpec,
) -> Option<Self> {
@@ -46,7 +46,7 @@ impl<'a, T: EthSpec> AttMaxCover<'a, T> {
let committee = state
.get_beacon_committee(att.data.slot, att.data.index)
.ok()?;
let indices = get_attesting_indices::<T>(committee.committee, &fresh_validators).ok()?;
let indices = get_attesting_indices::<E>(committee.committee, &fresh_validators).ok()?;
let fresh_validators_rewards: HashMap<u64, u64> = indices
.iter()
.copied()
@@ -70,8 +70,8 @@ impl<'a, T: EthSpec> AttMaxCover<'a, T> {
/// Initialise an attestation cover object for Altair or later.
pub fn new_for_altair_deneb(
att: AttestationRef<'a, T>,
state: &BeaconState<T>,
att: AttestationRef<'a, E>,
state: &BeaconState<E>,
reward_cache: &'a RewardCache,
total_active_balance: u64,
spec: &ChainSpec,
@@ -123,16 +123,16 @@ impl<'a, T: EthSpec> AttMaxCover<'a, T> {
}
}
impl<'a, T: EthSpec> MaxCover for AttMaxCover<'a, T> {
type Object = Attestation<T>;
type Intermediate = AttestationRef<'a, T>;
impl<'a, E: EthSpec> MaxCover for AttMaxCover<'a, E> {
type Object = Attestation<E>;
type Intermediate = AttestationRef<'a, E>;
type Set = HashMap<u64, u64>;
fn intermediate(&self) -> &AttestationRef<'a, T> {
fn intermediate(&self) -> &AttestationRef<'a, E> {
&self.att
}
fn convert_to_object(att_ref: &AttestationRef<'a, T>) -> Attestation<T> {
fn convert_to_object(att_ref: &AttestationRef<'a, E>) -> Attestation<E> {
att_ref.clone_as_attestation()
}
@@ -152,7 +152,7 @@ impl<'a, T: EthSpec> MaxCover for AttMaxCover<'a, T> {
/// of slashable voting, which is rare.
fn update_covering_set(
&mut self,
best_att: &AttestationRef<'a, T>,
best_att: &AttestationRef<'a, E>,
covered_validators: &HashMap<u64, u64>,
) {
if self.att.data.slot == best_att.data.slot && self.att.data.index == best_att.data.index {
@@ -175,11 +175,11 @@ impl<'a, T: EthSpec> MaxCover for AttMaxCover<'a, T> {
/// removed from the `aggregation_bits` before returning it.
///
/// This isn't optimal, but with the Altair fork this code is obsolete and not worth upgrading.
pub fn earliest_attestation_validators<T: EthSpec>(
attestation: &AttestationRef<T>,
state: &BeaconState<T>,
base_state: &BeaconStateBase<T>,
) -> BitList<T::MaxValidatorsPerCommittee> {
pub fn earliest_attestation_validators<E: EthSpec>(
attestation: &AttestationRef<E>,
state: &BeaconState<E>,
base_state: &BeaconStateBase<E>,
) -> BitList<E::MaxValidatorsPerCommittee> {
// Bitfield of validators whose attestations are new/fresh.
let mut new_validators = attestation.indexed.aggregation_bits.clone();