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

@@ -14,16 +14,16 @@ use std::{marker::PhantomData, path::PathBuf};
use types::EthSpec;
/// A set of configuration parameters for the bootnode, established from CLI arguments.
pub struct BootNodeConfig<T: EthSpec> {
pub struct BootNodeConfig<E: EthSpec> {
// TODO: Generalise to multiaddr
pub boot_nodes: Vec<Enr>,
pub local_enr: Enr,
pub local_key: CombinedKey,
pub discv5_config: discv5::Config,
phantom: PhantomData<T>,
phantom: PhantomData<E>,
}
impl<T: EthSpec> BootNodeConfig<T> {
impl<E: EthSpec> BootNodeConfig<E> {
pub async fn new(
matches: &ArgMatches<'_>,
eth2_network_config: &Eth2NetworkConfig,
@@ -94,7 +94,7 @@ impl<T: EthSpec> BootNodeConfig<T> {
} else {
// build the enr_fork_id and add it to the local_enr if it exists
let enr_fork = {
let spec = eth2_network_config.chain_spec::<T>()?;
let spec = eth2_network_config.chain_spec::<E>()?;
let genesis_state_url: Option<String> =
clap_utils::parse_optional(matches, "genesis-state-url")?;
@@ -104,14 +104,14 @@ impl<T: EthSpec> BootNodeConfig<T> {
if eth2_network_config.genesis_state_is_known() {
let genesis_state = eth2_network_config
.genesis_state::<T>(genesis_state_url.as_deref(), genesis_state_url_timeout, &logger).await?
.genesis_state::<E>(genesis_state_url.as_deref(), genesis_state_url_timeout, &logger).await?
.ok_or_else(|| {
"The genesis state for this network is not known, this is an unsupported mode"
.to_string()
})?;
slog::info!(logger, "Genesis state found"; "root" => genesis_state.canonical_root().to_string());
let enr_fork = spec.enr_fork_id::<T>(
let enr_fork = spec.enr_fork_id::<E>(
types::Slot::from(0u64),
genesis_state.genesis_validators_root(),
);
@@ -188,7 +188,7 @@ pub struct BootNodeConfigSerialization {
impl BootNodeConfigSerialization {
/// Returns a `BootNodeConfigSerialization` obtained from copying resp. cloning the
/// relevant fields of `config`
pub fn from_config_ref<T: EthSpec>(config: &BootNodeConfig<T>) -> Self {
pub fn from_config_ref<E: EthSpec>(config: &BootNodeConfig<E>) -> Self {
let BootNodeConfig {
boot_nodes,
local_enr,

View File

@@ -66,7 +66,7 @@ pub fn run(
}
}
fn main<T: EthSpec>(
fn main<E: EthSpec>(
lh_matches: &ArgMatches<'_>,
bn_matches: &ArgMatches<'_>,
eth2_network_config: &Eth2NetworkConfig,
@@ -79,7 +79,7 @@ fn main<T: EthSpec>(
.map_err(|e| format!("Failed to build runtime: {}", e))?;
// Run the boot node
runtime.block_on(server::run::<T>(
runtime.block_on(server::run::<E>(
lh_matches,
bn_matches,
eth2_network_config,

View File

@@ -11,21 +11,21 @@ use lighthouse_network::{
use slog::info;
use types::EthSpec;
pub async fn run<T: EthSpec>(
pub async fn run<E: EthSpec>(
lh_matches: &ArgMatches<'_>,
bn_matches: &ArgMatches<'_>,
eth2_network_config: &Eth2NetworkConfig,
log: slog::Logger,
) -> Result<(), String> {
// parse the CLI args into a useable config
let config: BootNodeConfig<T> = BootNodeConfig::new(bn_matches, eth2_network_config).await?;
let config: BootNodeConfig<E> = BootNodeConfig::new(bn_matches, eth2_network_config).await?;
// Dump configs if `dump-config` or `dump-chain-config` flags are set
let config_sz = BootNodeConfigSerialization::from_config_ref(&config);
clap_utils::check_dump_configs::<_, T>(
clap_utils::check_dump_configs::<_, E>(
lh_matches,
&config_sz,
&eth2_network_config.chain_spec::<T>()?,
&eth2_network_config.chain_spec::<E>()?,
)?;
if lh_matches.is_present("immediate-shutdown") {