update libp2p to version 0.54 (#6249)

* update libp2p to version 0.54.0

* address review

* Merge branch 'unstable' of github.com:sigp/lighthouse into update-libp2p

* Merge branch 'update-libp2p' of github.com:sigp/lighthouse into update-libp2p
This commit is contained in:
João Oliveira
2024-09-02 17:52:18 +01:00
committed by GitHub
parent 99e53b88c3
commit a685dde4ad
9 changed files with 273 additions and 163 deletions

View File

@@ -47,10 +47,10 @@ itertools = { workspace = true }
# Local dependencies
void = "1.0.2"
libp2p-mplex = "0.41"
libp2p-mplex = "0.42"
[dependencies.libp2p]
version = "0.53"
version = "0.54"
default-features = false
features = ["identify", "yamux", "noise", "dns", "tcp", "tokio", "plaintext", "secp256k1", "macros", "ecdsa", "metrics", "quic", "upnp"]

View File

@@ -27,7 +27,7 @@ futures-timer = "3.0.2"
getrandom = "0.2.12"
hashlink.workspace = true
hex_fmt = "0.3.0"
libp2p = { version = "0.53", default-features = false }
libp2p = { version = "0.54", default-features = false }
quick-protobuf = "0.8"
quick-protobuf-codec = "0.3"
rand = "0.8"

View File

@@ -35,7 +35,11 @@ use hashlink::LinkedHashMap;
use prometheus_client::registry::Registry;
use rand::{seq::SliceRandom, thread_rng};
use libp2p::core::{multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, Endpoint, Multiaddr};
use libp2p::core::{
multiaddr::Protocol::{Ip4, Ip6},
transport::PortUse,
Endpoint, Multiaddr,
};
use libp2p::identity::Keypair;
use libp2p::identity::PeerId;
use libp2p::swarm::{
@@ -3161,6 +3165,7 @@ where
peer_id: PeerId,
_: &Multiaddr,
_: Endpoint,
_: PortUse,
) -> Result<THandler<Self>, ConnectionDenied> {
// By default we assume a peer is only a floodsub peer.
//

View File

@@ -220,6 +220,7 @@ where
ConnectedPoint::Dialer {
address,
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
}
} else {
ConnectedPoint::Listener {
@@ -284,6 +285,7 @@ where
let fake_endpoint = ConnectedPoint::Dialer {
address: Multiaddr::empty(),
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
}; // this is not relevant
// peer_connections.connections should never be empty.
@@ -296,6 +298,7 @@ where
connection_id,
endpoint: &fake_endpoint,
remaining_established: active_connections,
cause: None,
}));
}
}
@@ -635,6 +638,7 @@ fn test_join() {
endpoint: &ConnectedPoint::Dialer {
address,
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
},
failed_addresses: &[],
other_established: 0,
@@ -4181,6 +4185,7 @@ fn test_scoring_p6() {
endpoint: &ConnectedPoint::Dialer {
address: addr.clone(),
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
},
failed_addresses: &[],
other_established: 0,
@@ -4202,6 +4207,7 @@ fn test_scoring_p6() {
endpoint: &ConnectedPoint::Dialer {
address: addr2.clone(),
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
},
failed_addresses: &[],
other_established: 1,
@@ -4232,6 +4238,7 @@ fn test_scoring_p6() {
endpoint: &ConnectedPoint::Dialer {
address: addr,
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
},
failed_addresses: &[],
other_established: 2,

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

@@ -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

@@ -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,