mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 22:38:34 +00:00
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:
@@ -26,7 +26,7 @@ use types::{
|
||||
ForkName, Hash256, Keypair, PublicKey, Validator,
|
||||
};
|
||||
|
||||
pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Result<(), String> {
|
||||
pub fn run<E: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Result<(), String> {
|
||||
let deposit_contract_address: Address = parse_required(matches, "deposit-contract-address")?;
|
||||
let deposit_contract_deploy_block = parse_required(matches, "deposit-contract-deploy-block")?;
|
||||
|
||||
@@ -39,7 +39,7 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
|
||||
));
|
||||
}
|
||||
|
||||
let mut spec = T::default_spec();
|
||||
let mut spec = E::default_spec();
|
||||
|
||||
// Update the spec value if the flag was defined. Otherwise, leave it as the default.
|
||||
macro_rules! maybe_update {
|
||||
@@ -101,7 +101,7 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
|
||||
}
|
||||
|
||||
let validator_count = parse_required(matches, "validator-count")?;
|
||||
let execution_payload_header: Option<ExecutionPayloadHeader<T>> =
|
||||
let execution_payload_header: Option<ExecutionPayloadHeader<E>> =
|
||||
parse_optional(matches, "execution-payload-header")?
|
||||
.map(|filename: String| {
|
||||
let mut bytes = vec![];
|
||||
@@ -115,19 +115,19 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
|
||||
"genesis fork must be post-merge".to_string(),
|
||||
)),
|
||||
ForkName::Merge => {
|
||||
ExecutionPayloadHeaderMerge::<T>::from_ssz_bytes(bytes.as_slice())
|
||||
ExecutionPayloadHeaderMerge::<E>::from_ssz_bytes(bytes.as_slice())
|
||||
.map(ExecutionPayloadHeader::Merge)
|
||||
}
|
||||
ForkName::Capella => {
|
||||
ExecutionPayloadHeaderCapella::<T>::from_ssz_bytes(bytes.as_slice())
|
||||
ExecutionPayloadHeaderCapella::<E>::from_ssz_bytes(bytes.as_slice())
|
||||
.map(ExecutionPayloadHeader::Capella)
|
||||
}
|
||||
ForkName::Deneb => {
|
||||
ExecutionPayloadHeaderDeneb::<T>::from_ssz_bytes(bytes.as_slice())
|
||||
ExecutionPayloadHeaderDeneb::<E>::from_ssz_bytes(bytes.as_slice())
|
||||
.map(ExecutionPayloadHeader::Deneb)
|
||||
}
|
||||
ForkName::Electra => {
|
||||
ExecutionPayloadHeaderElectra::<T>::from_ssz_bytes(bytes.as_slice())
|
||||
ExecutionPayloadHeaderElectra::<E>::from_ssz_bytes(bytes.as_slice())
|
||||
.map(ExecutionPayloadHeader::Electra)
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
|
||||
let keypairs = generate_deterministic_keypairs(validator_count);
|
||||
let keypairs: Vec<_> = keypairs.into_iter().map(|kp| (kp.clone(), kp)).collect();
|
||||
|
||||
let genesis_state = initialize_state_with_validators::<T>(
|
||||
let genesis_state = initialize_state_with_validators::<E>(
|
||||
&keypairs,
|
||||
genesis_time,
|
||||
eth1_block_hash.into_root(),
|
||||
@@ -194,7 +194,7 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
|
||||
(voting_keypair, withdrawal_keypair)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let genesis_state = initialize_state_with_validators::<T>(
|
||||
let genesis_state = initialize_state_with_validators::<E>(
|
||||
&keypairs,
|
||||
genesis_time,
|
||||
eth1_block_hash.into_root(),
|
||||
@@ -221,7 +221,7 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
|
||||
boot_enr: Some(vec![]),
|
||||
genesis_state_bytes: genesis_state_bytes.map(Into::into),
|
||||
genesis_state_source: GenesisStateSource::IncludedBytes,
|
||||
config: Config::from_chain_spec::<T>(&spec),
|
||||
config: Config::from_chain_spec::<E>(&spec),
|
||||
kzg_trusted_setup,
|
||||
};
|
||||
|
||||
@@ -237,15 +237,15 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
|
||||
///
|
||||
/// We need to ensure that `eth1_block_hash` is equal to the genesis block hash that is
|
||||
/// generated from the execution side `genesis.json`.
|
||||
fn initialize_state_with_validators<T: EthSpec>(
|
||||
fn initialize_state_with_validators<E: EthSpec>(
|
||||
keypairs: &[(Keypair, Keypair)], // Voting and Withdrawal keypairs
|
||||
genesis_time: u64,
|
||||
eth1_block_hash: Hash256,
|
||||
execution_payload_header: Option<ExecutionPayloadHeader<T>>,
|
||||
execution_payload_header: Option<ExecutionPayloadHeader<E>>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<BeaconState<T>, String> {
|
||||
) -> Result<BeaconState<E>, String> {
|
||||
// If no header is provided, then start from a Bellatrix state by default
|
||||
let default_header: ExecutionPayloadHeader<T> =
|
||||
let default_header: ExecutionPayloadHeader<E> =
|
||||
ExecutionPayloadHeader::Merge(ExecutionPayloadHeaderMerge {
|
||||
block_hash: ExecutionBlockHash::from_root(eth1_block_hash),
|
||||
parent_hash: ExecutionBlockHash::zero(),
|
||||
@@ -295,7 +295,7 @@ fn initialize_state_with_validators<T: EthSpec>(
|
||||
|
||||
if spec
|
||||
.altair_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == T::genesis_epoch())
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
upgrade_to_altair(&mut state, spec).unwrap();
|
||||
|
||||
@@ -305,7 +305,7 @@ fn initialize_state_with_validators<T: EthSpec>(
|
||||
// Similarly, perform an upgrade to Bellatrix if configured from genesis.
|
||||
if spec
|
||||
.bellatrix_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == T::genesis_epoch())
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
upgrade_to_bellatrix(&mut state, spec).unwrap();
|
||||
|
||||
@@ -324,7 +324,7 @@ fn initialize_state_with_validators<T: EthSpec>(
|
||||
// Similarly, perform an upgrade to Capella if configured from genesis.
|
||||
if spec
|
||||
.capella_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == T::genesis_epoch())
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
upgrade_to_capella(&mut state, spec).unwrap();
|
||||
|
||||
@@ -343,7 +343,7 @@ fn initialize_state_with_validators<T: EthSpec>(
|
||||
// Similarly, perform an upgrade to Deneb if configured from genesis.
|
||||
if spec
|
||||
.deneb_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == T::genesis_epoch())
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
upgrade_to_deneb(&mut state, spec).unwrap();
|
||||
|
||||
@@ -362,7 +362,7 @@ fn initialize_state_with_validators<T: EthSpec>(
|
||||
// Similarly, perform an upgrade to Electra if configured from genesis.
|
||||
if spec
|
||||
.electra_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == T::genesis_epoch())
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
upgrade_to_electra(&mut state, spec).unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user