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

@@ -9,7 +9,7 @@ use types::{
};
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
pub struct ConsensusContext<T: EthSpec> {
pub struct ConsensusContext<E: EthSpec> {
/// Slot to act as an identifier/safeguard
slot: Slot,
/// Proposer index of the block at `slot`.
@@ -20,7 +20,7 @@ pub struct ConsensusContext<T: EthSpec> {
/// We can skip serializing / deserializing this as the cache will just be rebuilt
#[ssz(skip_serializing, skip_deserializing)]
indexed_attestations:
HashMap<(AttestationData, BitList<T::MaxValidatorsPerCommittee>), IndexedAttestation<T>>,
HashMap<(AttestationData, BitList<E::MaxValidatorsPerCommittee>), IndexedAttestation<E>>,
}
#[derive(Debug, PartialEq, Clone)]
@@ -36,7 +36,7 @@ impl From<BeaconStateError> for ContextError {
}
}
impl<T: EthSpec> ConsensusContext<T> {
impl<E: EthSpec> ConsensusContext<E> {
pub fn new(slot: Slot) -> Self {
Self {
slot,
@@ -58,7 +58,7 @@ impl<T: EthSpec> ConsensusContext<T> {
/// required. If the slot check is too restrictive, see `get_proposer_index_from_epoch_state`.
pub fn get_proposer_index(
&mut self,
state: &BeaconState<T>,
state: &BeaconState<E>,
spec: &ChainSpec,
) -> Result<u64, ContextError> {
self.check_slot(state.slot())?;
@@ -72,7 +72,7 @@ impl<T: EthSpec> ConsensusContext<T> {
/// we want to extract the proposer index from a single state for every slot in the epoch.
pub fn get_proposer_index_from_epoch_state(
&mut self,
state: &BeaconState<T>,
state: &BeaconState<E>,
spec: &ChainSpec,
) -> Result<u64, ContextError> {
self.check_epoch(state.current_epoch())?;
@@ -81,7 +81,7 @@ impl<T: EthSpec> ConsensusContext<T> {
fn get_proposer_index_no_checks(
&mut self,
state: &BeaconState<T>,
state: &BeaconState<E>,
spec: &ChainSpec,
) -> Result<u64, ContextError> {
if let Some(proposer_index) = self.proposer_index {
@@ -98,9 +98,9 @@ impl<T: EthSpec> ConsensusContext<T> {
self
}
pub fn get_current_block_root<Payload: AbstractExecPayload<T>>(
pub fn get_current_block_root<Payload: AbstractExecPayload<E>>(
&mut self,
block: &SignedBeaconBlock<T, Payload>,
block: &SignedBeaconBlock<E, Payload>,
) -> Result<Hash256, ContextError> {
self.check_slot(block.slot())?;
@@ -125,7 +125,7 @@ impl<T: EthSpec> ConsensusContext<T> {
}
fn check_epoch(&self, epoch: Epoch) -> Result<(), ContextError> {
let expected = self.slot.epoch(T::slots_per_epoch());
let expected = self.slot.epoch(E::slots_per_epoch());
if epoch == expected {
Ok(())
} else {
@@ -135,9 +135,9 @@ impl<T: EthSpec> ConsensusContext<T> {
pub fn get_indexed_attestation(
&mut self,
state: &BeaconState<T>,
attestation: &Attestation<T>,
) -> Result<&IndexedAttestation<T>, BlockOperationError<AttestationInvalid>> {
state: &BeaconState<E>,
attestation: &Attestation<E>,
) -> Result<&IndexedAttestation<E>, BlockOperationError<AttestationInvalid>> {
let key = (
attestation.data.clone(),
attestation.aggregation_bits.clone(),