Skip to content

Commit

Permalink
update libp2p to version 0.54 (sigp#6249)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jxs authored and chong-he committed Nov 26, 2024
1 parent c88c3d7 commit 6c799e0
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 162 deletions.
402 changes: 245 additions & 157 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions beacon_node/lighthouse_network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 6 additions & 1 deletion beacon_node/lighthouse_network/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ where
ConnectedPoint::Dialer {
address,
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
}
} else {
ConnectedPoint::Listener {
Expand Down Expand Up @@ -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.

Expand All @@ -296,6 +298,7 @@ where
connection_id,
endpoint: &fake_endpoint,
remaining_established: active_connections,
cause: None,
}));
}
}
Expand Down Expand Up @@ -635,6 +638,7 @@ fn test_join() {
endpoint: &ConnectedPoint::Dialer {
address,
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
},
failed_addresses: &[],
other_established: 0,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions beacon_node/lighthouse_network/src/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions beacon_node/lighthouse_network/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion beacon_node/lighthouse_network/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6c799e0

Please sign in to comment.