mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04: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:
@@ -999,7 +999,7 @@ impl Notifications {
|
||||
|
||||
impl NetworkBehaviour for Notifications {
|
||||
type ConnectionHandler = NotifsHandler;
|
||||
type OutEvent = NotificationsOut;
|
||||
type ToSwarm = NotificationsOut;
|
||||
|
||||
fn handle_pending_inbound_connection(
|
||||
&mut self,
|
||||
@@ -1468,10 +1468,11 @@ impl NetworkBehaviour for Notifications {
|
||||
FromSwarm::ListenerClosed(_) => {},
|
||||
FromSwarm::ListenFailure(_) => {},
|
||||
FromSwarm::ListenerError(_) => {},
|
||||
FromSwarm::ExpiredExternalAddr(_) => {},
|
||||
FromSwarm::ExternalAddrExpired(_) => {},
|
||||
FromSwarm::NewListener(_) => {},
|
||||
FromSwarm::ExpiredListenAddr(_) => {},
|
||||
FromSwarm::NewExternalAddr(_) => {},
|
||||
FromSwarm::NewExternalAddrCandidate(_) => {},
|
||||
FromSwarm::ExternalAddrConfirmed(_) => {},
|
||||
FromSwarm::AddressChange(_) => {},
|
||||
FromSwarm::NewListenAddr(_) => {},
|
||||
}
|
||||
@@ -2008,7 +2009,7 @@ impl NetworkBehaviour for Notifications {
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
_params: &mut impl PollParameters,
|
||||
) -> Poll<ToSwarm<Self::OutEvent, THandlerInEvent<Self>>> {
|
||||
) -> Poll<ToSwarm<Self::ToSwarm, THandlerInEvent<Self>>> {
|
||||
if let Some(event) = self.events.pop_front() {
|
||||
return Poll::Ready(event)
|
||||
}
|
||||
@@ -2108,7 +2109,6 @@ impl NetworkBehaviour for Notifications {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{peerset::IncomingIndex, protocol::notifications::handler::tests::*};
|
||||
use libp2p::swarm::AddressRecord;
|
||||
use std::{collections::HashSet, iter};
|
||||
|
||||
impl PartialEq for ConnectionState {
|
||||
@@ -2127,31 +2127,14 @@ mod tests {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct MockPollParams {
|
||||
peer_id: PeerId,
|
||||
addr: Multiaddr,
|
||||
}
|
||||
struct MockPollParams {}
|
||||
|
||||
impl PollParameters for MockPollParams {
|
||||
type SupportedProtocolsIter = std::vec::IntoIter<Vec<u8>>;
|
||||
type ListenedAddressesIter = std::vec::IntoIter<Multiaddr>;
|
||||
type ExternalAddressesIter = std::vec::IntoIter<AddressRecord>;
|
||||
|
||||
fn supported_protocols(&self) -> Self::SupportedProtocolsIter {
|
||||
vec![].into_iter()
|
||||
}
|
||||
|
||||
fn listened_addresses(&self) -> Self::ListenedAddressesIter {
|
||||
vec![self.addr.clone()].into_iter()
|
||||
}
|
||||
|
||||
fn external_addresses(&self) -> Self::ExternalAddressesIter {
|
||||
vec![].into_iter()
|
||||
}
|
||||
|
||||
fn local_peer_id(&self) -> &PeerId {
|
||||
&self.peer_id
|
||||
}
|
||||
}
|
||||
|
||||
fn development_notifs() -> (Notifications, crate::peerset::PeersetHandle) {
|
||||
@@ -3015,7 +2998,7 @@ mod tests {
|
||||
|
||||
notif.on_swarm_event(FromSwarm::DialFailure(libp2p::swarm::behaviour::DialFailure {
|
||||
peer_id: Some(peer),
|
||||
error: &libp2p::swarm::DialError::Banned,
|
||||
error: &libp2p::swarm::DialError::Aborted,
|
||||
connection_id: ConnectionId::new_unchecked(1337),
|
||||
}));
|
||||
|
||||
@@ -3552,7 +3535,7 @@ mod tests {
|
||||
let now = Instant::now();
|
||||
notif.on_swarm_event(FromSwarm::DialFailure(libp2p::swarm::behaviour::DialFailure {
|
||||
peer_id: Some(peer),
|
||||
error: &libp2p::swarm::DialError::Banned,
|
||||
error: &libp2p::swarm::DialError::Aborted,
|
||||
connection_id: ConnectionId::new_unchecked(0),
|
||||
}));
|
||||
|
||||
@@ -3672,7 +3655,7 @@ mod tests {
|
||||
assert!(notif.peers.get(&(peer, set_id)).is_some());
|
||||
|
||||
if tokio::time::timeout(Duration::from_secs(5), async {
|
||||
let mut params = MockPollParams { peer_id: PeerId::random(), addr: Multiaddr::empty() };
|
||||
let mut params = MockPollParams {};
|
||||
|
||||
loop {
|
||||
futures::future::poll_fn(|cx| {
|
||||
@@ -3781,7 +3764,7 @@ mod tests {
|
||||
// verify that the code continues to keep the peer disabled by resetting the timer
|
||||
// after the first one expired.
|
||||
if tokio::time::timeout(Duration::from_secs(5), async {
|
||||
let mut params = MockPollParams { peer_id: PeerId::random(), addr: Multiaddr::empty() };
|
||||
let mut params = MockPollParams {};
|
||||
|
||||
loop {
|
||||
futures::future::poll_fn(|cx| {
|
||||
|
||||
Reference in New Issue
Block a user