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

39 files changed

+2171
-1275
lines changed

Cargo.lock

+1,189-256
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/authority-discovery/Cargo.toml

+2-2
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

+1-1
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

+4-4
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

+15-14
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

+3-3
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

+1-1
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

+1-1
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

+1-2
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

+2-3
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,

client/network-gossip/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ pub use self::{
6767
validator::{DiscardAll, MessageIntent, ValidationResult, Validator, ValidatorContext},
6868
};
6969

70-
use libp2p_identity::PeerId;
71-
use multiaddr::{Multiaddr, Protocol};
70+
use libp2p::{multiaddr, PeerId};
7271
use sc_network::{
7372
types::ProtocolName, NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers,
7473
};
@@ -83,7 +82,8 @@ mod validator;
8382
/// Abstraction over a network.
8483
pub trait Network<B: BlockT>: NetworkPeers + NetworkEventStream + NetworkNotification {
8584
fn add_set_reserved(&self, who: PeerId, protocol: ProtocolName) {
86-
let addr = Multiaddr::empty().with(Protocol::P2p(who));
85+
let addr =
86+
iter::once(multiaddr::Protocol::P2p(who.into())).collect::<multiaddr::Multiaddr>();
8787
let result = self.add_peers_to_reserved_set(protocol, iter::once(addr).collect());
8888
if let Err(err) = result {
8989
log::error!(target: "gossip", "add_set_reserved failed: {}", err);

client/network-gossip/src/state_machine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use crate::{MessageIntent, Network, ValidationResult, Validator, ValidatorContext};
2020

2121
use ahash::AHashSet;
22-
use libp2p_identity::PeerId;
22+
use libp2p::PeerId;
2323
use schnellru::{ByLength, LruMap};
2424

2525
use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64};
@@ -521,8 +521,8 @@ impl Metrics {
521521
#[cfg(test)]
522522
mod tests {
523523
use super::*;
524+
use crate::multiaddr::Multiaddr;
524525
use futures::prelude::*;
525-
use multiaddr::Multiaddr;
526526
use sc_network::{
527527
config::MultiaddrWithPeerId, event::Event, NetworkBlock, NetworkEventStream,
528528
NetworkNotification, NetworkPeers, NotificationSenderError,

client/network-gossip/src/validator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// You should have received a copy of the GNU General Public License
1717
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1818

19-
use libp2p_identity::PeerId;
19+
use libp2p::PeerId;
2020
use sc_network_common::role::ObservedRole;
2121
use sp_runtime::traits::Block as BlockT;
2222

client/network/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ fnv = "1.0.6"
2525
futures = "0.3.21"
2626
futures-timer = "3.0.2"
2727
ip_network = "0.4.1"
28-
libp2p = { version = "0.52.1", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] }
29-
libp2p-kad = { version = "0.44.2" }
28+
libp2p = { version = "0.51.3", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] }
3029
linked_hash_set = "0.1.3"
3130
log = "0.4.17"
3231
mockall = "0.11.3"
@@ -39,7 +38,6 @@ serde_json = "1.0.85"
3938
smallvec = "1.11.0"
4039
thiserror = "1.0"
4140
unsigned-varint = { version = "0.7.1", features = ["futures", "asynchronous_codec"] }
42-
void = "1"
4341
zeroize = "1.4.3"
4442
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
4543
sc-client-api = { version = "4.0.0-dev", path = "../api" }
@@ -54,7 +52,7 @@ wasm-timer = "0.2"
5452
[dev-dependencies]
5553
assert_matches = "1.3"
5654
mockall = "0.11.3"
57-
multistream-select = "0.13.0"
55+
multistream-select = "0.12.1"
5856
rand = "0.8.5"
5957
tempfile = "3.1.0"
6058
tokio = { version = "1.22.0", features = ["macros"] }

client/network/bitswap/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ prost-build = "0.11"
1919
async-channel = "1.8.0"
2020
cid = "0.9.0"
2121
futures = "0.3.21"
22-
libp2p-identity = { version = "0.2.0", features = ["peerid"] }
22+
libp2p-identity = { version = "0.1.2", features = ["peerid"] }
2323
log = "0.4.17"
2424
prost = "0.11"
2525
thiserror = "1.0"

client/network/common/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ codec = { package = "parity-scale-codec", version = "3.6.1", features = [
2222
"derive",
2323
] }
2424
futures = "0.3.21"
25-
libp2p-identity = { version = "0.2.0", features = ["peerid"] }
25+
libp2p-identity = { version = "0.1.2", features = ["peerid"] }
2626
sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" }
2727
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
2828
sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/consensus/grandpa" }

client/network/light/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ codec = { package = "parity-scale-codec", version = "3.6.1", features = [
2222
"derive",
2323
] }
2424
futures = "0.3.21"
25-
libp2p-identity = { version = "0.2.0", features = ["peerid"] }
25+
libp2p-identity = { version = "0.1.2", features = ["peerid"] }
2626
log = "0.4.16"
2727
prost = "0.11"
2828
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }

client/network/src/behaviour.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use crate::{
3030
use bytes::Bytes;
3131
use futures::channel::oneshot;
3232
use libp2p::{
33-
connection_limits::ConnectionLimits, core::Multiaddr, identify::Info as IdentifyInfo,
34-
identity::PublicKey, kad::RecordKey, swarm::NetworkBehaviour, PeerId,
33+
core::Multiaddr, identify::Info as IdentifyInfo, identity::PublicKey, kad::RecordKey,
34+
swarm::NetworkBehaviour, PeerId,
3535
};
3636

3737
use parking_lot::Mutex;
@@ -43,7 +43,7 @@ pub use crate::request_responses::{InboundFailure, OutboundFailure, RequestId, R
4343

4444
/// General behaviour of the network. Combines all protocols together.
4545
#[derive(NetworkBehaviour)]
46-
#[behaviour(to_swarm = "BehaviourOut")]
46+
#[behaviour(out_event = "BehaviourOut")]
4747
pub struct Behaviour<B: BlockT> {
4848
/// All the substrate-specific protocols.
4949
substrate: Protocol<B>,
@@ -52,8 +52,6 @@ pub struct Behaviour<B: BlockT> {
5252
peer_info: peer_info::PeerInfoBehaviour,
5353
/// Discovers nodes of the network.
5454
discovery: DiscoveryBehaviour,
55-
/// Connection limits.
56-
connection_limits: libp2p::connection_limits::Behaviour,
5755
/// Generic request-response protocols.
5856
request_responses: request_responses::RequestResponsesBehaviour,
5957
}
@@ -174,7 +172,6 @@ impl<B: BlockT> Behaviour<B> {
174172
disco_config: DiscoveryConfig,
175173
request_response_protocols: Vec<ProtocolConfig>,
176174
peer_store_handle: PeerStoreHandle,
177-
connection_limits: ConnectionLimits,
178175
external_addresses: Arc<Mutex<HashSet<Multiaddr>>>,
179176
) -> Result<Self, request_responses::RegisterError> {
180177
Ok(Self {
@@ -185,7 +182,6 @@ impl<B: BlockT> Behaviour<B> {
185182
external_addresses,
186183
),
187184
discovery: disco_config.finish(),
188-
connection_limits: libp2p::connection_limits::Behaviour::new(connection_limits),
189185
request_responses: request_responses::RequestResponsesBehaviour::new(
190186
request_response_protocols.into_iter(),
191187
Box::new(peer_store_handle),
@@ -257,7 +253,7 @@ impl<B: BlockT> Behaviour<B> {
257253
pub fn add_self_reported_address_to_dht(
258254
&mut self,
259255
peer_id: &PeerId,
260-
supported_protocols: &[impl AsRef<str>],
256+
supported_protocols: &[impl AsRef<[u8]>],
261257
addr: Multiaddr,
262258
) {
263259
self.discovery.add_self_reported_address(peer_id, supported_protocols, addr);
@@ -361,9 +357,3 @@ impl From<DiscoveryOut> for BehaviourOut {
361357
}
362358
}
363359
}
364-
365-
impl From<void::Void> for BehaviourOut {
366-
fn from(e: void::Void) -> Self {
367-
void::unreachable(e)
368-
}
369-
}

0 commit comments

Comments
 (0)