Merge branch 'unstable' into max-blobs-preset

This commit is contained in:
Pawan Dhananjay
2024-09-03 16:08:59 -07:00
181 changed files with 1688 additions and 1244 deletions

View File

@@ -18,6 +18,7 @@ pub use libp2p::identity::{Keypair, PublicKey};
use enr::{ATTESTATION_BITFIELD_ENR_KEY, ETH2_ENR_KEY, SYNC_COMMITTEE_BITFIELD_ENR_KEY};
use futures::prelude::*;
use futures::stream::FuturesUnordered;
use libp2p::core::transport::PortUse;
use libp2p::multiaddr::Protocol;
use libp2p::swarm::behaviour::{DialFailure, FromSwarm};
use libp2p::swarm::THandlerInEvent;
@@ -983,6 +984,7 @@ impl<E: EthSpec> NetworkBehaviour for Discovery<E> {
_peer: PeerId,
_addr: &Multiaddr,
_role_override: libp2p::core::Endpoint,
_port_use: PortUse,
) -> Result<libp2p::swarm::THandler<Self>, libp2p::swarm::ConnectionDenied> {
Ok(ConnectionHandler)
}

View File

@@ -41,7 +41,7 @@ where
.map_or(false, |b| b.get(*s.deref() as usize).unwrap_or(false)),
Subnet::DataColumn(s) => {
let mut subnets = DataColumnSubnetId::compute_custody_subnets::<E>(
enr.node_id().raw().into(),
enr.node_id().raw(),
custody_subnet_count,
&spec,
);

View File

@@ -4,6 +4,7 @@ use std::net::IpAddr;
use std::task::{Context, Poll};
use futures::StreamExt;
use libp2p::core::transport::PortUse;
use libp2p::core::ConnectedPoint;
use libp2p::identity::PeerId;
use libp2p::swarm::behaviour::{ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm};
@@ -214,6 +215,7 @@ impl<E: EthSpec> NetworkBehaviour for PeerManager<E> {
peer_id: PeerId,
addr: &libp2p::Multiaddr,
_role_override: libp2p::core::Endpoint,
_port_use: PortUse,
) -> Result<libp2p::swarm::THandler<Self>, libp2p::swarm::ConnectionDenied> {
trace!(self.log, "Outbound connection"; "peer_id" => %peer_id, "multiaddr" => %addr);
match self.ban_status(&peer_id) {

View File

@@ -791,10 +791,9 @@ impl<E: EthSpec> PeerDB<E> {
) => {
// Update the ENR if one exists, and compute the custody subnets
if let Some(enr) = enr {
let node_id = enr.node_id().raw().into();
let custody_subnet_count = enr.custody_subnet_count::<E>(&self.spec);
let custody_subnets = DataColumnSubnetId::compute_custody_subnets::<E>(
node_id,
enr.node_id().raw(),
custody_subnet_count,
&self.spec,
)

View File

@@ -374,7 +374,7 @@ impl<E: EthSpec> PeerInfo<E> {
if self.custody_subnets.is_empty() {
if let Ok(custody_subnet_count) = meta_data.custody_subnet_count() {
let custody_subnets = DataColumnSubnetId::compute_custody_subnets::<E>(
node_id.raw().into(),
node_id.raw(),
std::cmp::min(*custody_subnet_count, spec.data_column_sidecar_subnet_count),
spec,
)

View File

@@ -176,7 +176,7 @@ mod tests {
use crate::rpc::protocol::*;
use std::sync::Arc;
use types::{Epoch, ForkContext, ForkName, Hash256, Slot};
use types::{Epoch, FixedBytesExtended, ForkContext, ForkName, Hash256, Slot};
use unsigned_varint::codec::Uvi;
type Spec = types::MainnetEthSpec;

View File

@@ -426,11 +426,12 @@ fn context_bytes<E: EthSpec>(
RPCResponse::BlobsByRange(_) | RPCResponse::BlobsByRoot(_) => {
return fork_context.to_context_bytes(ForkName::Deneb);
}
RPCResponse::DataColumnsByRoot(_) | RPCResponse::DataColumnsByRange(_) => {
RPCResponse::DataColumnsByRoot(d) | RPCResponse::DataColumnsByRange(d) => {
// TODO(das): Remove deneb fork after `peerdas-devnet-2`.
return if fork_context.spec.eip7594_fork_epoch
== fork_context.spec.deneb_fork_epoch
{
return if matches!(
fork_context.spec.fork_name_at_slot::<E>(d.slot()),
ForkName::Deneb
) {
fork_context.to_context_bytes(ForkName::Deneb)
} else {
fork_context.to_context_bytes(ForkName::Electra)
@@ -834,8 +835,8 @@ mod tests {
use crate::types::{EnrAttestationBitfield, EnrSyncCommitteeBitfield};
use types::{
blob_sidecar::BlobIdentifier, BeaconBlock, BeaconBlockAltair, BeaconBlockBase,
BeaconBlockBellatrix, DataColumnIdentifier, EmptyBlock, Epoch, FullPayload, Signature,
Slot,
BeaconBlockBellatrix, DataColumnIdentifier, EmptyBlock, Epoch, FixedBytesExtended,
FullPayload, Signature, Slot,
};
type Spec = types::MainnetEthSpec;
@@ -925,9 +926,9 @@ mod tests {
fn status_message() -> StatusMessage {
StatusMessage {
fork_digest: [0; 4],
finalized_root: Hash256::from_low_u64_be(0),
finalized_root: Hash256::zero(),
finalized_epoch: Epoch::new(1),
head_root: Hash256::from_low_u64_be(0),
head_root: Hash256::zero(),
head_slot: Slot::new(1),
}
}
@@ -1686,9 +1687,9 @@ mod tests {
// Status message is 84 bytes uncompressed. `max_compressed_len` is 32 + 84 + 84/6 = 130.
let status_message_bytes = StatusMessage {
fork_digest: [0; 4],
finalized_root: Hash256::from_low_u64_be(0),
finalized_root: Hash256::zero(),
finalized_epoch: Epoch::new(1),
head_root: Hash256::from_low_u64_be(0),
head_root: Hash256::zero(),
head_slot: Slot::new(1),
}
.as_ssz_bytes();
@@ -1809,9 +1810,9 @@ mod tests {
// Status message is 84 bytes uncompressed. `max_compressed_len` is 32 + 84 + 84/6 = 130.
let status_message_bytes = StatusMessage {
fork_digest: [0; 4],
finalized_root: Hash256::from_low_u64_be(0),
finalized_root: Hash256::zero(),
finalized_epoch: Epoch::new(1),
head_root: Hash256::from_low_u64_be(0),
head_root: Hash256::zero(),
head_slot: Slot::new(1),
}
.as_ssz_bytes();

View File

@@ -6,6 +6,7 @@
use futures::future::FutureExt;
use handler::RPCHandler;
use libp2p::core::transport::PortUse;
use libp2p::swarm::{
handler::ConnectionHandler, CloseConnection, ConnectionId, NetworkBehaviour, NotifyHandler,
ToSwarm,
@@ -259,6 +260,7 @@ where
peer_id: PeerId,
_addr: &libp2p::Multiaddr,
_role_override: libp2p::core::Endpoint,
_port_use: PortUse,
) -> Result<libp2p::swarm::THandler<Self>, libp2p::swarm::ConnectionDenied> {
let protocol = SubstreamProtocol::new(
RPCProtocol {

View File

@@ -1661,7 +1661,11 @@ impl<E: EthSpec> Network<E> {
/// Handle an identify event.
fn inject_identify_event(&mut self, event: identify::Event) -> Option<NetworkEvent<E>> {
match event {
identify::Event::Received { peer_id, mut info } => {
identify::Event::Received {
peer_id,
mut info,
connection_id: _,
} => {
if info.listen_addrs.len() > MAX_IDENTIFY_ADDRESSES {
debug!(
self.log,

View File

@@ -121,18 +121,24 @@ impl<E: EthSpec> NetworkGlobals<E> {
/// Compute custody data columns the node is assigned to custody.
pub fn custody_columns(&self) -> Vec<ColumnIndex> {
let enr = self.local_enr();
let node_id = enr.node_id().raw().into();
let custody_subnet_count = enr.custody_subnet_count::<E>(&self.spec);
DataColumnSubnetId::compute_custody_columns::<E>(node_id, custody_subnet_count, &self.spec)
.collect()
DataColumnSubnetId::compute_custody_columns::<E>(
enr.node_id().raw(),
custody_subnet_count,
&self.spec,
)
.collect()
}
/// Compute custody data column subnets the node is assigned to custody.
pub fn custody_subnets(&self) -> impl Iterator<Item = DataColumnSubnetId> {
let enr = self.local_enr();
let node_id = enr.node_id().raw().into();
let custody_subnet_count = enr.custody_subnet_count::<E>(&self.spec);
DataColumnSubnetId::compute_custody_subnets::<E>(node_id, custody_subnet_count, &self.spec)
DataColumnSubnetId::compute_custody_subnets::<E>(
enr.node_id().raw(),
custody_subnet_count,
&self.spec,
)
}
/// Returns a connected peer that: