Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit e53cf32

Browse files
authored
Revert "chore: update libp2p to 0.52.1 (#14429)" (#14722)
* Revert "chore: update libp2p to 0.52.1 (#14429)" This reverts commit d38d176. * Fix dependencies * Update dependencies * Update Cargo.lock
1 parent 4553158 commit e53cf32

File tree

39 files changed

+2171
-1275
lines changed

39 files changed

+2171
-1275
lines changed

Cargo.lock

Lines changed: 1189 additions & 256 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/authority-discovery/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features =
2121
futures = "0.3.21"
2222
futures-timer = "3.0.1"
2323
ip_network = "0.4.1"
24-
libp2p = { version = "0.52.1", features = ["kad", "ed25519"] }
25-
multihash-codetable = { version = "0.1.0", features = ["sha2", "digest"] }
24+
libp2p = { version = "0.51.3", features = ["kad", "ed25519"] }
25+
multihash = { version = "0.17.0", default-features = false, features = ["std", "sha2"] }
2626
log = "0.4.17"
2727
prost = "0.11"
2828
rand = "0.8.5"

client/authority-discovery/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn get_addresses_and_authority_id() {
5656
let remote_addr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333"
5757
.parse::<Multiaddr>()
5858
.unwrap()
59-
.with(Protocol::P2p(remote_peer_id));
59+
.with(Protocol::P2p(remote_peer_id.into()));
6060

6161
let test_api = Arc::new(TestApi { authorities: vec![] });
6262

client/authority-discovery/src/worker.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ use futures::{channel::mpsc, future, stream::Fuse, FutureExt, Stream, StreamExt}
3434
use addr_cache::AddrCache;
3535
use codec::{Decode, Encode};
3636
use ip_network::IpNetwork;
37-
use libp2p::{core::multiaddr, identity::PublicKey, Multiaddr};
38-
use multihash_codetable::{Code, MultihashDigest};
37+
use libp2p::{core::multiaddr, identity::PublicKey, multihash::Multihash, Multiaddr, PeerId};
38+
use multihash::{Code, MultihashDigest};
3939

4040
use log::{debug, error, log_enabled};
4141
use prometheus_endpoint::{register, Counter, CounterVec, Gauge, Opts, U64};
@@ -304,7 +304,7 @@ where
304304
}
305305

306306
fn addresses_to_publish(&self) -> impl Iterator<Item = Multiaddr> {
307-
let peer_id = self.network.local_peer_id();
307+
let peer_id: Multihash = self.network.local_peer_id().into();
308308
let publish_non_global_ips = self.publish_non_global_ips;
309309
self.network
310310
.external_addresses()
@@ -529,7 +529,7 @@ where
529529
.map_err(Error::ParsingMultiaddress)?;
530530

531531
let get_peer_id = |a: &Multiaddr| match a.iter().last() {
532-
Some(multiaddr::Protocol::P2p(peer_id)) => Some(peer_id),
532+
Some(multiaddr::Protocol::P2p(key)) => PeerId::from_multihash(key).ok(),
533533
_ => None,
534534
};
535535

client/authority-discovery/src/worker/addr_cache.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ impl AddrCache {
162162

163163
fn peer_id_from_multiaddr(addr: &Multiaddr) -> Option<PeerId> {
164164
addr.iter().last().and_then(|protocol| {
165-
if let Protocol::P2p(peer_id) = protocol {
166-
Some(peer_id)
165+
if let Protocol::P2p(multihash) = protocol {
166+
PeerId::from_multihash(multihash).ok()
167167
} else {
168168
None
169169
}
@@ -178,8 +178,7 @@ fn addresses_to_peer_ids(addresses: &HashSet<Multiaddr>) -> HashSet<PeerId> {
178178
mod tests {
179179
use super::*;
180180

181-
use libp2p::multihash::Multihash;
182-
use multihash_codetable::Code;
181+
use libp2p::multihash::{self, Multihash};
183182
use quickcheck::{Arbitrary, Gen, QuickCheck, TestResult};
184183

185184
use sp_authority_discovery::{AuthorityId, AuthorityPair};
@@ -201,13 +200,14 @@ mod tests {
201200
impl Arbitrary for TestMultiaddr {
202201
fn arbitrary(g: &mut Gen) -> Self {
203202
let seed = (0..32).map(|_| u8::arbitrary(g)).collect::<Vec<_>>();
204-
let peer_id =
205-
PeerId::from_multihash(Multihash::wrap(Code::Sha2_256.into(), &seed).unwrap())
206-
.unwrap();
203+
let peer_id = PeerId::from_multihash(
204+
Multihash::wrap(multihash::Code::Sha2_256.into(), &seed).unwrap(),
205+
)
206+
.unwrap();
207207
let multiaddr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333"
208208
.parse::<Multiaddr>()
209209
.unwrap()
210-
.with(Protocol::P2p(peer_id));
210+
.with(Protocol::P2p(peer_id.into()));
211211

212212
TestMultiaddr(multiaddr)
213213
}
@@ -219,17 +219,18 @@ mod tests {
219219
impl Arbitrary for TestMultiaddrsSamePeerCombo {
220220
fn arbitrary(g: &mut Gen) -> Self {
221221
let seed = (0..32).map(|_| u8::arbitrary(g)).collect::<Vec<_>>();
222-
let peer_id =
223-
PeerId::from_multihash(Multihash::wrap(Code::Sha2_256.into(), &seed).unwrap())
224-
.unwrap();
222+
let peer_id = PeerId::from_multihash(
223+
Multihash::wrap(multihash::Code::Sha2_256.into(), &seed).unwrap(),
224+
)
225+
.unwrap();
225226
let multiaddr1 = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333"
226227
.parse::<Multiaddr>()
227228
.unwrap()
228-
.with(Protocol::P2p(peer_id));
229+
.with(Protocol::P2p(peer_id.into()));
229230
let multiaddr2 = "/ip6/2002:db8:0:0:0:0:0:2/tcp/30133"
230231
.parse::<Multiaddr>()
231232
.unwrap()
232-
.with(Protocol::P2p(peer_id));
233+
.with(Protocol::P2p(peer_id.into()));
233234
TestMultiaddrsSamePeerCombo(multiaddr1, multiaddr2)
234235
}
235236
}
@@ -366,7 +367,7 @@ mod tests {
366367
let mut addr_cache = AddrCache::new();
367368

368369
let peer_id = PeerId::random();
369-
let addr = Multiaddr::empty().with(Protocol::P2p(peer_id));
370+
let addr = Multiaddr::empty().with(Protocol::P2p(peer_id.into()));
370371

371372
let authority_id0 = AuthorityPair::generate().0.public();
372373
let authority_id1 = AuthorityPair::generate().0.public();

client/authority-discovery/src/worker/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ fn dont_stop_polling_dht_event_stream_after_bogus_event() {
415415
let peer_id = PeerId::random();
416416
let address: Multiaddr = "/ip6/2001:db8:0:0:0:0:0:1/tcp/30333".parse().unwrap();
417417

418-
address.with(multiaddr::Protocol::P2p(peer_id))
418+
address.with(multiaddr::Protocol::P2p(peer_id.into()))
419419
};
420420
let remote_key_store = MemoryKeystore::new();
421421
let remote_public_key: AuthorityId = remote_key_store
@@ -526,7 +526,7 @@ impl DhtValueFoundTester {
526526
let address: Multiaddr =
527527
format!("/ip6/2001:db8:0:0:0:0:0:{:x}/tcp/30333", idx).parse().unwrap();
528528

529-
address.with(multiaddr::Protocol::P2p(peer_id))
529+
address.with(multiaddr::Protocol::P2p(peer_id.into()))
530530
}
531531

532532
fn process_value_found(
@@ -749,7 +749,7 @@ fn lookup_throttling() {
749749
let peer_id = PeerId::random();
750750
let address: Multiaddr = "/ip6/2001:db8:0:0:0:0:0:1/tcp/30333".parse().unwrap();
751751

752-
address.with(multiaddr::Protocol::P2p(peer_id))
752+
address.with(multiaddr::Protocol::P2p(peer_id.into()))
753753
};
754754
let remote_key_store = MemoryKeystore::new();
755755
let remote_public_keys: Vec<AuthorityId> = (0..20)

client/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ chrono = "0.4.10"
1818
clap = { version = "4.2.5", features = ["derive", "string"] }
1919
fdlimit = "0.2.1"
2020
futures = "0.3.21"
21-
libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"]}
21+
libp2p-identity = { version = "0.1.2", features = ["peerid", "ed25519"]}
2222
log = "0.4.17"
2323
names = { version = "0.13.0", default-features = false }
2424
parity-scale-codec = "3.6.1"

client/consensus/common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1616
async-trait = "0.1.57"
1717
futures = { version = "0.3.21", features = ["thread-pool"] }
1818
futures-timer = "3.0.1"
19-
libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"] }
19+
libp2p-identity = { version = "0.1.2", features = ["peerid", "ed25519"] }
2020
log = "0.4.17"
2121
mockall = "0.11.3"
2222
parking_lot = "0.12.1"

client/network-gossip/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1717
ahash = "0.8.2"
1818
futures = "0.3.21"
1919
futures-timer = "3.0.1"
20-
libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"]}
21-
multiaddr = "0.18.0"
20+
libp2p = "0.51.3"
2221
log = "0.4.17"
2322
schnellru = "0.2.1"
2423
tracing = "0.1.29"

client/network-gossip/src/bridge.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use futures::{
2828
channel::mpsc::{channel, Receiver, Sender},
2929
prelude::*,
3030
};
31-
use libp2p_identity::PeerId;
31+
use libp2p::PeerId;
3232
use log::trace;
3333
use prometheus_endpoint::Registry;
3434
use sp_runtime::traits::Block as BlockT;
@@ -327,13 +327,12 @@ impl<B: BlockT> futures::future::FusedFuture for GossipEngine<B> {
327327
#[cfg(test)]
328328
mod tests {
329329
use super::*;
330-
use crate::{ValidationResult, ValidatorContext};
330+
use crate::{multiaddr::Multiaddr, ValidationResult, ValidatorContext};
331331
use futures::{
332332
channel::mpsc::{unbounded, UnboundedSender},
333333
executor::{block_on, block_on_stream},
334334
future::poll_fn,
335335
};
336-
use multiaddr::Multiaddr;
337336
use quickcheck::{Arbitrary, Gen, QuickCheck};
338337
use sc_network::{
339338
config::MultiaddrWithPeerId, NetworkBlock, NetworkEventStream, NetworkNotification,

0 commit comments

Comments
 (0)