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

@@ -18,8 +18,8 @@ use PeerConnectionStatus::*;
/// Information about a given connected peer.
#[derive(Clone, Debug, Serialize)]
#[serde(bound = "T: EthSpec")]
pub struct PeerInfo<T: EthSpec> {
#[serde(bound = "E: EthSpec")]
pub struct PeerInfo<E: EthSpec> {
/// The peers reputation
score: Score,
/// Client managing this peer
@@ -37,7 +37,7 @@ pub struct PeerInfo<T: EthSpec> {
sync_status: SyncStatus,
/// The ENR subnet bitfield of the peer. This may be determined after it's initial
/// connection.
meta_data: Option<MetaData<T>>,
meta_data: Option<MetaData<E>>,
/// Subnets the peer is connected to.
subnets: HashSet<Subnet>,
/// The time we would like to retain this peer. After this time, the peer is no longer
@@ -53,8 +53,8 @@ pub struct PeerInfo<T: EthSpec> {
enr: Option<Enr>,
}
impl<TSpec: EthSpec> Default for PeerInfo<TSpec> {
fn default() -> PeerInfo<TSpec> {
impl<E: EthSpec> Default for PeerInfo<E> {
fn default() -> PeerInfo<E> {
PeerInfo {
score: Score::default(),
client: Client::default(),
@@ -72,7 +72,7 @@ impl<TSpec: EthSpec> Default for PeerInfo<TSpec> {
}
}
impl<T: EthSpec> PeerInfo<T> {
impl<E: EthSpec> PeerInfo<E> {
/// Return a PeerInfo struct for a trusted peer.
pub fn trusted_peer_info() -> Self {
PeerInfo {
@@ -120,7 +120,7 @@ impl<T: EthSpec> PeerInfo<T> {
}
/// Returns the metadata for the peer if currently known.
pub fn meta_data(&self) -> Option<&MetaData<T>> {
pub fn meta_data(&self) -> Option<&MetaData<E>> {
self.meta_data.as_ref()
}
@@ -151,7 +151,7 @@ impl<T: EthSpec> PeerInfo<T> {
if let Some(meta_data) = self.meta_data.as_ref() {
return meta_data.attnets().num_set_bits();
} else if let Some(enr) = self.enr.as_ref() {
if let Ok(attnets) = enr.attestation_bitfield::<T>() {
if let Ok(attnets) = enr.attestation_bitfield::<E>() {
return attnets.num_set_bits();
}
}
@@ -177,7 +177,7 @@ impl<T: EthSpec> PeerInfo<T> {
}
}
} else if let Some(enr) = self.enr.as_ref() {
if let Ok(attnets) = enr.attestation_bitfield::<T>() {
if let Ok(attnets) = enr.attestation_bitfield::<E>() {
for subnet in 0..=attnets.highest_set_bit().unwrap_or(0) {
if attnets.get(subnet).unwrap_or(false) {
long_lived_subnets.push(Subnet::Attestation((subnet as u64).into()));
@@ -185,7 +185,7 @@ impl<T: EthSpec> PeerInfo<T> {
}
}
if let Ok(syncnets) = enr.sync_committee_bitfield::<T>() {
if let Ok(syncnets) = enr.sync_committee_bitfield::<E>() {
for subnet in 0..=syncnets.highest_set_bit().unwrap_or(0) {
if syncnets.get(subnet).unwrap_or(false) {
long_lived_subnets.push(Subnet::SyncCommittee((subnet as u64).into()));
@@ -217,7 +217,7 @@ impl<T: EthSpec> PeerInfo<T> {
// We may not have the metadata but may have an ENR. Lets check that
if let Some(enr) = self.enr.as_ref() {
if let Ok(attnets) = enr.attestation_bitfield::<T>() {
if let Ok(attnets) = enr.attestation_bitfield::<E>() {
if !attnets.is_zero() && !self.subnets.is_empty() {
return true;
}
@@ -344,7 +344,7 @@ impl<T: EthSpec> PeerInfo<T> {
/// Sets an explicit value for the meta data.
// VISIBILITY: The peer manager is able to adjust the meta_data
pub(in crate::peer_manager) fn set_meta_data(&mut self, meta_data: MetaData<T>) {
pub(in crate::peer_manager) fn set_meta_data(&mut self, meta_data: MetaData<E>) {
self.meta_data = Some(meta_data)
}