mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 23:41:02 +00:00
chore: update libp2p to 0.52.1 (#14429)
* update libp2p to 0.52.0 * proto name now must implement `AsRef<str>` * update libp2p version everywhere * ToSwarm, FromBehaviour, ToBehaviour also LocalProtocolsChange and RemoteProtocolsChange * new NetworkBehaviour invariants * replace `Vec<u8>` with `StreamProtocol` * rename ConnectionHandlerEvent::Custom to NotifyBehaviour * remove DialError & ListenError invariants also fix pending_events * use connection_limits::Behaviour See https://github.com/libp2p/rust-libp2p/pull/3885 * impl `void::Void` for `BehaviourOut` also use `Behaviour::with_codec` * KademliaHandler no longer public * fix StreamProtocol construction * update libp2p-identify to 0.2.0 * remove non-existing methods from PollParameters rename ConnectionHandlerUpgrErr to StreamUpgradeError * `P2p` now contains `PeerId`, not `Multihash` * use multihash-codetable crate * update Cargo.lock * reformat text * comment out tests for now * remove `.into()` from P2p * confirm observed addr manually See https://github.com/libp2p/rust-libp2p/blob/master/protocols/identify/CHANGELOG.md#0430 * remove SwarmEvent::Banned since we're not using `ban_peer_id`, this can be safely removed. we may want to introduce `libp2p::allow_block_list` module in the future. * fix imports * replace `libp2p` with smaller deps in network-gossip * bring back tests * finish rewriting tests * uncomment handler tests * Revert "uncomment handler tests" This reverts commit 720a06815887f4e10767c62b58864a7ec3a48e50. * add a fixme * update Cargo.lock * remove extra From * make void uninhabited * fix discovery test * use autonat protocols confirming external addresses manually is unsafe in open networks * fix SyncNotificationsClogged invariant * only set server mode manually in tests doubt that we need to set it on node since we're adding public addresses * address @dmitry-markin comments * remove autonat * removed unused var * fix EOL * update smallvec and sha2 in attempt to compile polkadot * bump k256 in attempt to build cumulus --------- Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -31,13 +31,13 @@ use libp2p::{
|
||||
Info as IdentifyInfo,
|
||||
},
|
||||
identity::PublicKey,
|
||||
ping::{Behaviour as Ping, Config as PingConfig, Event as PingEvent, Success as PingSuccess},
|
||||
ping::{Behaviour as Ping, Config as PingConfig, Event as PingEvent},
|
||||
swarm::{
|
||||
behaviour::{
|
||||
AddressChange, ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm,
|
||||
ListenFailure,
|
||||
},
|
||||
ConnectionDenied, ConnectionHandler, ConnectionId, IntoConnectionHandlerSelect,
|
||||
ConnectionDenied, ConnectionHandler, ConnectionHandlerSelect, ConnectionId,
|
||||
NetworkBehaviour, PollParameters, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm,
|
||||
},
|
||||
Multiaddr, PeerId,
|
||||
@@ -121,13 +121,18 @@ impl PeerInfoBehaviour {
|
||||
|
||||
/// Inserts a ping time in the cache. Has no effect if we don't have any entry for that node,
|
||||
/// which shouldn't happen.
|
||||
fn handle_ping_report(&mut self, peer_id: &PeerId, ping_time: Duration) {
|
||||
trace!(target: "sub-libp2p", "Ping time with {:?}: {:?}", peer_id, ping_time);
|
||||
fn handle_ping_report(
|
||||
&mut self,
|
||||
peer_id: &PeerId,
|
||||
ping_time: Duration,
|
||||
connection: ConnectionId,
|
||||
) {
|
||||
trace!(target: "sub-libp2p", "Ping time with {:?} via {:?}: {:?}", peer_id, connection, ping_time);
|
||||
if let Some(entry) = self.nodes_info.get_mut(peer_id) {
|
||||
entry.latest_ping = Some(ping_time);
|
||||
} else {
|
||||
error!(target: "sub-libp2p",
|
||||
"Received ping from node we're not connected to {:?}", peer_id);
|
||||
"Received ping from node we're not connected to {:?} via {:?}", peer_id, connection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,11 +186,11 @@ pub enum PeerInfoEvent {
|
||||
}
|
||||
|
||||
impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
type ConnectionHandler = IntoConnectionHandlerSelect<
|
||||
type ConnectionHandler = ConnectionHandlerSelect<
|
||||
<Ping as NetworkBehaviour>::ConnectionHandler,
|
||||
<Identify as NetworkBehaviour>::ConnectionHandler,
|
||||
>;
|
||||
type OutEvent = PeerInfoEvent;
|
||||
type ToSwarm = PeerInfoEvent;
|
||||
|
||||
fn handle_pending_inbound_connection(
|
||||
&mut self,
|
||||
@@ -351,9 +356,9 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
self.ping.on_swarm_event(FromSwarm::ListenerError(e));
|
||||
self.identify.on_swarm_event(FromSwarm::ListenerError(e));
|
||||
},
|
||||
FromSwarm::ExpiredExternalAddr(e) => {
|
||||
self.ping.on_swarm_event(FromSwarm::ExpiredExternalAddr(e));
|
||||
self.identify.on_swarm_event(FromSwarm::ExpiredExternalAddr(e));
|
||||
FromSwarm::ExternalAddrExpired(e) => {
|
||||
self.ping.on_swarm_event(FromSwarm::ExternalAddrExpired(e));
|
||||
self.identify.on_swarm_event(FromSwarm::ExternalAddrExpired(e));
|
||||
},
|
||||
FromSwarm::NewListener(e) => {
|
||||
self.ping.on_swarm_event(FromSwarm::NewListener(e));
|
||||
@@ -363,9 +368,13 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
self.ping.on_swarm_event(FromSwarm::ExpiredListenAddr(e));
|
||||
self.identify.on_swarm_event(FromSwarm::ExpiredListenAddr(e));
|
||||
},
|
||||
FromSwarm::NewExternalAddr(e) => {
|
||||
self.ping.on_swarm_event(FromSwarm::NewExternalAddr(e));
|
||||
self.identify.on_swarm_event(FromSwarm::NewExternalAddr(e));
|
||||
FromSwarm::NewExternalAddrCandidate(e) => {
|
||||
self.ping.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e));
|
||||
self.identify.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e));
|
||||
},
|
||||
FromSwarm::ExternalAddrConfirmed(e) => {
|
||||
self.ping.on_swarm_event(FromSwarm::ExternalAddrConfirmed(e));
|
||||
self.identify.on_swarm_event(FromSwarm::ExternalAddrConfirmed(e));
|
||||
},
|
||||
FromSwarm::AddressChange(e @ AddressChange { peer_id, old, new, .. }) => {
|
||||
self.ping.on_swarm_event(FromSwarm::AddressChange(e));
|
||||
@@ -408,13 +417,13 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<ToSwarm<Self::OutEvent, THandlerInEvent<Self>>> {
|
||||
) -> Poll<ToSwarm<Self::ToSwarm, THandlerInEvent<Self>>> {
|
||||
loop {
|
||||
match self.ping.poll(cx, params) {
|
||||
Poll::Pending => break,
|
||||
Poll::Ready(ToSwarm::GenerateEvent(ev)) => {
|
||||
if let PingEvent { peer, result: Ok(PingSuccess::Ping { rtt }) } = ev {
|
||||
self.handle_ping_report(&peer, rtt)
|
||||
if let PingEvent { peer, result: Ok(rtt), connection } = ev {
|
||||
self.handle_ping_report(&peer, rtt, connection)
|
||||
}
|
||||
},
|
||||
Poll::Ready(ToSwarm::Dial { opts }) => return Poll::Ready(ToSwarm::Dial { opts }),
|
||||
@@ -424,10 +433,18 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
handler,
|
||||
event: Either::Left(event),
|
||||
}),
|
||||
Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) =>
|
||||
return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }),
|
||||
Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) =>
|
||||
return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }),
|
||||
Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)) =>
|
||||
return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)),
|
||||
Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)) =>
|
||||
return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)),
|
||||
Poll::Ready(ToSwarm::ExternalAddrExpired(addr)) =>
|
||||
return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)),
|
||||
Poll::Ready(ToSwarm::ListenOn { opts }) =>
|
||||
return Poll::Ready(ToSwarm::ListenOn { opts }),
|
||||
Poll::Ready(ToSwarm::RemoveListener { id }) =>
|
||||
return Poll::Ready(ToSwarm::RemoveListener { id }),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,10 +470,18 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
handler,
|
||||
event: Either::Right(event),
|
||||
}),
|
||||
Poll::Ready(ToSwarm::ReportObservedAddr { address, score }) =>
|
||||
return Poll::Ready(ToSwarm::ReportObservedAddr { address, score }),
|
||||
Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) =>
|
||||
return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }),
|
||||
Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)) =>
|
||||
return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)),
|
||||
Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)) =>
|
||||
return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)),
|
||||
Poll::Ready(ToSwarm::ExternalAddrExpired(addr)) =>
|
||||
return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)),
|
||||
Poll::Ready(ToSwarm::ListenOn { opts }) =>
|
||||
return Poll::Ready(ToSwarm::ListenOn { opts }),
|
||||
Poll::Ready(ToSwarm::RemoveListener { id }) =>
|
||||
return Poll::Ready(ToSwarm::RemoveListener { id }),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user