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

@@ -154,7 +154,7 @@ enum EventStream {
/// The main discovery service. This can be disabled via CLI arguements. When disabled the
/// underlying processes are not started, but this struct still maintains our current ENR.
pub struct Discovery<TSpec: EthSpec> {
pub struct Discovery<E: EthSpec> {
/// A collection of seen live ENRs for quick lookup and to map peer-id's to ENRs.
cached_enrs: LruCache<PeerId, Enr>,
@@ -168,7 +168,7 @@ pub struct Discovery<TSpec: EthSpec> {
discv5: Discv5,
/// A collection of network constants that can be read from other threads.
network_globals: Arc<NetworkGlobals<TSpec>>,
network_globals: Arc<NetworkGlobals<E>>,
/// Indicates if we are actively searching for peers. We only allow a single FindPeers query at
/// a time, regardless of the query concurrency.
@@ -194,12 +194,12 @@ pub struct Discovery<TSpec: EthSpec> {
log: slog::Logger,
}
impl<TSpec: EthSpec> Discovery<TSpec> {
impl<E: EthSpec> Discovery<E> {
/// NOTE: Creating discovery requires running within a tokio execution environment.
pub async fn new(
local_key: Keypair,
config: &NetworkConfig,
network_globals: Arc<NetworkGlobals<TSpec>>,
network_globals: Arc<NetworkGlobals<E>>,
log: &slog::Logger,
) -> error::Result<Self> {
let log = log.clone();
@@ -448,7 +448,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
match subnet {
Subnet::Attestation(id) => {
let id = *id as usize;
let mut current_bitfield = local_enr.attestation_bitfield::<TSpec>()?;
let mut current_bitfield = local_enr.attestation_bitfield::<E>()?;
if id >= current_bitfield.len() {
return Err(format!(
"Subnet id: {} is outside the ENR bitfield length: {}",
@@ -481,7 +481,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
}
Subnet::SyncCommittee(id) => {
let id = *id as usize;
let mut current_bitfield = local_enr.sync_committee_bitfield::<TSpec>()?;
let mut current_bitfield = local_enr.sync_committee_bitfield::<E>()?;
if id >= current_bitfield.len() {
return Err(format!(
@@ -718,7 +718,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
// Only start a discovery query if we have a subnet to look for.
if !filtered_subnet_queries.is_empty() {
// build the subnet predicate as a combination of the eth2_fork_predicate and the subnet predicate
let subnet_predicate = subnet_predicate::<TSpec>(filtered_subnets, &self.log);
let subnet_predicate = subnet_predicate::<E>(filtered_subnets, &self.log);
debug!(
self.log,
@@ -845,7 +845,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
// Check the specific subnet against the enr
let subnet_predicate =
subnet_predicate::<TSpec>(vec![query.subnet], &self.log);
subnet_predicate::<E>(vec![query.subnet], &self.log);
r.clone()
.into_iter()
@@ -916,7 +916,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
/* NetworkBehaviour Implementation */
impl<TSpec: EthSpec> NetworkBehaviour for Discovery<TSpec> {
impl<E: EthSpec> NetworkBehaviour for Discovery<E> {
// Discovery is not a real NetworkBehaviour...
type ConnectionHandler = ConnectionHandler;
type ToSwarm = DiscoveredPeers;
@@ -1116,7 +1116,7 @@ impl<TSpec: EthSpec> NetworkBehaviour for Discovery<TSpec> {
}
}
impl<TSpec: EthSpec> Discovery<TSpec> {
impl<E: EthSpec> Discovery<E> {
fn on_dial_failure(&mut self, peer_id: Option<PeerId>, error: &DialError) {
if let Some(peer_id) = peer_id {
match error {