From 030a7b8fd5ef03e4da466e65ce8fe92e3cff90e4 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Date: Thu, 2 May 2024 13:54:57 +0300 Subject: [PATCH] cargo: Update experimental litep2p to latest version (#4344) This PR updates the litep2p crate to the latest version. This fixes the build for developers that want to perform `cargo update` on all their dependencies: https://github.com/paritytech/polkadot-sdk/pull/4343, by porting the latest changes. The peer records were introduced to litep2p to be able to distinguish and update peers with outdated records. It is going to be properly used in substrate via: https://github.com/paritytech/polkadot-sdk/pull/3786, however that is pending the commit to merge on litep2p master: https://github.com/paritytech/litep2p/pull/96. Closes: https://github.com/paritytech/polkadot-sdk/pull/4343 --------- Signed-off-by: Alexandru Vasile --- Cargo.lock | 39 +++---------------- substrate/client/network/Cargo.toml | 2 +- .../client/network/src/litep2p/discovery.rs | 5 ++- substrate/client/network/types/Cargo.toml | 2 +- 4 files changed, 12 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f35d93ccecca4..a46a16bd2807b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8215,7 +8215,7 @@ dependencies = [ [[package]] name = "litep2p" version = "0.3.0" -source = "git+https://github.com/paritytech/litep2p?branch=master#34f64350a4e7cc28a0190c48b270234dff82e29c" +source = "git+https://github.com/paritytech/litep2p?rev=e03a6023882db111beeb24d8c0ceaac0721d3f0f#e03a6023882db111beeb24d8c0ceaac0721d3f0f" dependencies = [ "async-trait", "bs58 0.4.0", @@ -8227,7 +8227,7 @@ dependencies = [ "hex-literal", "indexmap 2.2.6", "libc", - "mockall 0.12.1", + "mockall", "multiaddr", "multihash 0.17.0", "network-interface", @@ -8701,26 +8701,11 @@ dependencies = [ "downcast", "fragile", "lazy_static", - "mockall_derive 0.11.4", + "mockall_derive", "predicates 2.1.5", "predicates-tree", ] -[[package]] -name = "mockall" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43766c2b5203b10de348ffe19f7e54564b64f3d6018ff7648d1e2d6d3a0f0a48" -dependencies = [ - "cfg-if", - "downcast", - "fragile", - "lazy_static", - "mockall_derive 0.12.1", - "predicates 3.1.0", - "predicates-tree", -] - [[package]] name = "mockall_derive" version = "0.11.4" @@ -8733,18 +8718,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "mockall_derive" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cbce79ec385a1d4f54baa90a76401eb15d9cab93685f62e7e9f942aa00ae2" -dependencies = [ - "cfg-if", - "proc-macro2 1.0.82", - "quote 1.0.36", - "syn 2.0.61", -] - [[package]] name = "multiaddr" version = "0.17.1" @@ -16599,7 +16572,7 @@ dependencies = [ "futures", "futures-timer", "log", - "mockall 0.11.4", + "mockall", "parking_lot 0.12.2", "sc-client-api", "sc-network-types", @@ -17124,7 +17097,7 @@ dependencies = [ "linked_hash_set", "litep2p", "log", - "mockall 0.11.4", + "mockall", "multistream-select", "once_cell", "parity-scale-codec", @@ -17262,7 +17235,7 @@ dependencies = [ "futures-timer", "libp2p", "log", - "mockall 0.11.4", + "mockall", "parity-scale-codec", "prost 0.12.4", "prost-build", diff --git a/substrate/client/network/Cargo.toml b/substrate/client/network/Cargo.toml index 0879481a41993..cda652d4f65a3 100644 --- a/substrate/client/network/Cargo.toml +++ b/substrate/client/network/Cargo.toml @@ -59,7 +59,7 @@ sp-blockchain = { path = "../../primitives/blockchain" } sp-core = { path = "../../primitives/core" } sp-runtime = { path = "../../primitives/runtime" } wasm-timer = "0.2" -litep2p = { git = "https://github.com/paritytech/litep2p", branch = "master" } +litep2p = { git = "https://github.com/paritytech/litep2p", rev = "e03a6023882db111beeb24d8c0ceaac0721d3f0f" } once_cell = "1.18.0" void = "1.0.2" schnellru = "0.2.1" diff --git a/substrate/client/network/src/litep2p/discovery.rs b/substrate/client/network/src/litep2p/discovery.rs index 27f4d54737221..47a620db132e1 100644 --- a/substrate/client/network/src/litep2p/discovery.rs +++ b/substrate/client/network/src/litep2p/discovery.rs @@ -462,7 +462,10 @@ impl Stream for Discovery { "`GET_RECORD` succeeded for {query_id:?}: {record:?}", ); - return Poll::Ready(Some(DiscoveryEvent::GetRecordSuccess { query_id, record })); + return Poll::Ready(Some(DiscoveryEvent::GetRecordSuccess { + query_id, + record: record.record, + })); }, Poll::Ready(Some(KademliaEvent::PutRecordSucess { query_id, key: _ })) => return Poll::Ready(Some(DiscoveryEvent::PutRecordSuccess { query_id })), diff --git a/substrate/client/network/types/Cargo.toml b/substrate/client/network/types/Cargo.toml index d8f03939ab96c..e36d34b86fc1e 100644 --- a/substrate/client/network/types/Cargo.toml +++ b/substrate/client/network/types/Cargo.toml @@ -12,7 +12,7 @@ documentation = "https://docs.rs/sc-network-types" [dependencies] bs58 = "0.4.0" libp2p-identity = { version = "0.1.3", features = ["ed25519", "peerid"] } -litep2p = { git = "https://github.com/paritytech/litep2p", branch = "master" } +litep2p = { git = "https://github.com/paritytech/litep2p", rev = "e03a6023882db111beeb24d8c0ceaac0721d3f0f" } multiaddr = "0.17.0" multihash = { version = "0.17.0", default-features = false, features = ["identity", "multihash-impl", "sha2", "std"] } rand = "0.8.5"