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

@@ -25,11 +25,11 @@ impl From<ArithError> for Error {
/// If the root of the supplied `state` is known, then it can be passed as `state_root`. If
/// `state_root` is `None`, the root of `state` will be computed using a cached tree hash.
/// Providing the `state_root` makes this function several orders of magnitude faster.
pub fn per_slot_processing<T: EthSpec>(
state: &mut BeaconState<T>,
pub fn per_slot_processing<E: EthSpec>(
state: &mut BeaconState<E>,
state_root: Option<Hash256>,
spec: &ChainSpec,
) -> Result<Option<EpochProcessingSummary<T>>, Error> {
) -> Result<Option<EpochProcessingSummary<E>>, Error> {
// Verify that the `BeaconState` instantiation matches the fork at `state.slot()`.
state
.fork_name(spec)
@@ -38,7 +38,7 @@ pub fn per_slot_processing<T: EthSpec>(
cache_state(state, state_root)?;
let summary = if state.slot() > spec.genesis_slot
&& state.slot().safe_add(1)?.safe_rem(T::slots_per_epoch())? == 0
&& state.slot().safe_add(1)?.safe_rem(E::slots_per_epoch())? == 0
{
Some(per_epoch_processing(state, spec)?)
} else {
@@ -49,7 +49,7 @@ pub fn per_slot_processing<T: EthSpec>(
// Process fork upgrades here. Note that multiple upgrades can potentially run
// in sequence if they are scheduled in the same Epoch (common in testnets)
if state.slot().safe_rem(T::slots_per_epoch())? == 0 {
if state.slot().safe_rem(E::slots_per_epoch())? == 0 {
// If the Altair fork epoch is reached, perform an irregular state upgrade.
if spec.altair_fork_epoch == Some(state.current_epoch()) {
upgrade_to_altair(state, spec)?;
@@ -75,8 +75,8 @@ pub fn per_slot_processing<T: EthSpec>(
Ok(summary)
}
fn cache_state<T: EthSpec>(
state: &mut BeaconState<T>,
fn cache_state<E: EthSpec>(
state: &mut BeaconState<E>,
state_root: Option<Hash256>,
) -> Result<(), Error> {
let previous_state_root = if let Some(root) = state_root {