Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of libp2p dependency in sc-authority-discovery #5842

Merged
merged 134 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
51f9a34
Removed libp2p dependancy from sc_network_sync
ndkazu Jul 8, 2024
b4e3f5a
Preparing an alternative to libp2p dependant OutBoundFailure
ndkazu Jul 9, 2024
fa242e5
Merge branch 'master' into libp2p
ndkazu Jul 9, 2024
6a1fcf1
Agnostic sc-network-sync
ndkazu Jul 10, 2024
b20e332
Merge branch 'paritytech:master' into libp2p
ndkazu Jul 10, 2024
fdac723
Merge branch 'master' into libp2p
ndkazu Jul 15, 2024
b33728b
Update substrate/client/network/src/request_responses.rs
ndkazu Jul 16, 2024
d8fbc30
Remove crate libp2p from sc-authority-discovery
ndkazu Jul 16, 2024
86d50af
Merge branch 'libp2p' of github.com:ndkazu/polkadot-sdk into libp2p
ndkazu Jul 16, 2024
2f09ebd
Removed event
ndkazu Jul 17, 2024
d0e2084
Add a custom InboundFailure
ndkazu Jul 17, 2024
3f7e5ad
Removed the variant Network
ndkazu Jul 18, 2024
6dd1bd3
Changed the type of
ndkazu Jul 20, 2024
97a5453
Merge branch 'master' into libp2p
ndkazu Jul 20, 2024
12db7fa
Merge branch 'master' into libp2p
ndkazu Jul 22, 2024
02f0085
Merge branch 'paritytech:master' into libp2p
ndkazu Jul 24, 2024
372f9fc
Replaced Network2 by Network, and added comments to enums
ndkazu Jul 24, 2024
28830fe
Replaced Network2 by Network
ndkazu Jul 24, 2024
f02b17c
Removed Event0, Need to remove ToSwarm dependance to libp2p
ndkazu Jul 26, 2024
ccbc94a
Merge branch 'paritytech:master' into libp2p
ndkazu Aug 3, 2024
7229689
Merge branch 'master' into libp2p
ndkazu Sep 2, 2024
8609e59
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 3, 2024
54c54c5
Ready for review
ndkazu Sep 3, 2024
ae006e1
First corrections
ndkazu Sep 5, 2024
a52c9d4
Second round of corrections
ndkazu Sep 5, 2024
73860e6
cargo +nightly fmt
ndkazu Sep 5, 2024
7ed1124
Merge branch 'master' into libp2p
ndkazu Sep 6, 2024
db03bc5
Revert "cargo +nightly fmt"
ndkazu Sep 7, 2024
3dd3834
Merge branch 'master' into libp2p
ndkazu Sep 7, 2024
f194e5f
".git/.scripts/commands/fmt/fmt.sh"
Sep 9, 2024
6ac72b3
Removed all #[error(dial-failure)]
ndkazu Sep 9, 2024
104b1c4
Merge branch 'master' into libp2p
ndkazu Sep 9, 2024
e056e0e
Merge branch 'master' into libp2p
ndkazu Sep 11, 2024
53ea246
Replaced CustomOutboundFailure by OutboundFailure
ndkazu Sep 12, 2024
65c732e
Merge branch 'master' into libp2p
ndkazu Sep 12, 2024
da7adc3
first round of corrections
ndkazu Sep 13, 2024
7c916bc
Merge branch 'master' into libp2p
ndkazu Sep 13, 2024
aab8614
Reverted where it was necessary
ndkazu Sep 13, 2024
812734c
corrections
ndkazu Sep 13, 2024
35e884e
Merge branch 'master' into libp2p
ndkazu Sep 13, 2024
0062a74
Merge branch 'master' into libp2p
ndkazu Sep 13, 2024
dd08c06
Merge branch 'master' into libp2p
ndkazu Sep 13, 2024
cc0c400
Merge branch 'master' into libp2p
ndkazu Sep 14, 2024
67fe210
Created a prdoc
ndkazu Sep 16, 2024
c608293
Merge branch 'master' into libp2p
ndkazu Sep 16, 2024
a74ebd0
Merge branch 'master' into libp2p
ndkazu Sep 17, 2024
73d4005
implemented From<...> for OutbounFailure & InboundFailure
ndkazu Sep 17, 2024
2fcf160
Reverted changes unrelated to the purpose of the PR
ndkazu Sep 17, 2024
c2abf70
more revert
ndkazu Sep 17, 2024
9c8248b
Merge branch 'master' into libp2p
ndkazu Sep 17, 2024
34cdc57
".git/.scripts/commands/fmt/fmt.sh"
Sep 17, 2024
1ee40e1
Added newline at EOF
ndkazu Sep 17, 2024
a354c2e
Further corrections
ndkazu Sep 17, 2024
abc6f68
correcting format
ndkazu Sep 17, 2024
dfcc689
more format correction
ndkazu Sep 17, 2024
7bb250f
removed space
ndkazu Sep 17, 2024
ba729b5
".git/.scripts/commands/fmt/fmt.sh"
Sep 17, 2024
c969d26
Latest review corrections
ndkazu Sep 17, 2024
e226706
Manual Formatting
ndkazu Sep 17, 2024
f1e0164
Correct newline at EOF in prdoc
dmitry-markin Sep 18, 2024
27c8e13
Merge branch 'master' into libp2p
lexnv Sep 18, 2024
f578962
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 18, 2024
6a3a045
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 24, 2024
f44b2eb
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 25, 2024
b0e1fd1
Starting
ndkazu Sep 25, 2024
f4c798f
Merge branch 'libp2p' of github.com:ndkazu/polkadot-sdk into libp2p
ndkazu Sep 25, 2024
141fbbc
Preparing new types
ndkazu Sep 26, 2024
887c877
Merge branch 'paritytech:master' into libp2p
ndkazu Sep 26, 2024
086c976
libp2p still used in tests
ndkazu Sep 26, 2024
73b46ed
Merge branch 'master' into libp2p
ndkazu Sep 26, 2024
5c02af7
some corrections
ndkazu Sep 27, 2024
b13248f
License
ndkazu Sep 27, 2024
0ec6f2d
Merge branch 'master' into libp2p
ndkazu Sep 27, 2024
a1ed269
Fix clippy
ndkazu Sep 27, 2024
c0baae5
PRdoc
ndkazu Sep 28, 2024
c944af9
PRdoc
ndkazu Sep 28, 2024
bc2e56e
PRdoc
ndkazu Sep 28, 2024
1efb0b2
Removed libp2p from sc-authority-discovery
ndkazu Sep 28, 2024
f9e5edb
Removed libp2p from sc-authority-discovery
ndkazu Sep 28, 2024
568c1e6
Removed libp2p from sc-authority-discovery
ndkazu Sep 28, 2024
48fe9b4
Merge branch 'master' into libp2p
ndkazu Sep 28, 2024
f48a4e2
Merge branch 'master' into libp2p
ndkazu Sep 29, 2024
03e10b5
Merge branch 'master' into libp2p
ndkazu Sep 30, 2024
e3cc477
Merge branch 'master' into libp2p
ndkazu Sep 30, 2024
6052d78
cargo clippy
ndkazu Sep 30, 2024
f3cf4df
Clippy
ndkazu Sep 30, 2024
ddde1b1
Removed all libp2p dependency from sc-authority-discovery
ndkazu Oct 1, 2024
5b2d95e
Merge branch 'master' into libp2p
ndkazu Oct 1, 2024
128ae48
clippy
ndkazu Oct 1, 2024
75cdda4
Fix tests in sc-network
ndkazu Oct 1, 2024
008674c
".git/.scripts/commands/fmt/fmt.sh"
Oct 1, 2024
5f72326
Fixed prdoc
ndkazu Oct 1, 2024
bce2179
Merge branch 'libp2p' of github.com:ndkazu/polkadot-sdk into libp2p
ndkazu Oct 1, 2024
6ef6230
Merge branch 'master' into libp2p
ndkazu Oct 1, 2024
c2f1686
Merge branch 'master' into libp2p
ndkazu Oct 2, 2024
25e12d1
Merge branch 'master' into libp2p
ndkazu Oct 3, 2024
a22a330
Merge branch 'master' into libp2p
ndkazu Oct 4, 2024
afa7659
Merge branch 'master' into libp2p
ndkazu Oct 5, 2024
61926d7
Merge branch 'master' into libp2p
ndkazu Oct 6, 2024
d764d23
Merge branch 'master' into libp2p
ndkazu Oct 7, 2024
c96ace5
Update substrate/client/network/types/src/rec.rs
ndkazu Oct 7, 2024
a3210f5
Applied review corrections
ndkazu Oct 7, 2024
8b13128
Merge branch 'master' into libp2p
ndkazu Oct 7, 2024
0d5912e
Merge branch 'master' into libp2p
ndkazu Oct 8, 2024
d210aa5
Merge branch 'master' into libp2p
ndkazu Oct 9, 2024
c16b692
Merge branch 'master' into libp2p
ndkazu Oct 10, 2024
d59014a
Merge branch 'master' into libp2p
ndkazu Oct 13, 2024
010bbb8
Merge branch 'master' into libp2p
ndkazu Oct 16, 2024
42f5080
Merge branch 'master' into libp2p
ndkazu Oct 18, 2024
d5adbd7
Merge branch 'master' into libp2p
ndkazu Oct 22, 2024
e18a331
Merge branch 'master' into libp2p
ndkazu Oct 25, 2024
fc34928
Merge branch 'master' into libp2p
ndkazu Oct 29, 2024
0df8b33
changed file name from rec.rs to kad.rs
ndkazu Nov 2, 2024
596fcf9
Removed unnecessary into() and libp2p
ndkazu Nov 2, 2024
3ab3460
Removed unneeded conversions
ndkazu Nov 4, 2024
e7e5ccd
Started work on litep2p/mod.rs
ndkazu Nov 4, 2024
96302b0
Merge branch 'master' into libp2p
dmitry-markin Nov 8, 2024
04e74ff
".git/.scripts/commands/fmt/fmt.sh"
Nov 8, 2024
faf8ce8
Merge branch 'master' into libp2p
ndkazu Nov 9, 2024
d1a7df4
Update substrate/client/network/types/src/kad.rs
ndkazu Nov 9, 2024
35fc773
First round of corrections
ndkazu Nov 9, 2024
37d217a
2nd round of corrections
ndkazu Nov 9, 2024
0e60ca0
Corrected format
ndkazu Nov 9, 2024
349906a
Simplified function
ndkazu Nov 9, 2024
65f0af4
Simplified syntax
ndkazu Nov 11, 2024
7995de5
Merge branch 'master' into libp2p
ndkazu Nov 11, 2024
9043046
Merge branch 'master' into libp2p
ndkazu Nov 12, 2024
8618d00
Merge branch 'master' into libp2p
dmitry-markin Nov 12, 2024
e0bc0b6
minor: use `into()` to convert kad key
dmitry-markin Nov 12, 2024
7c402b2
Merge branch 'master' into libp2p
dmitry-markin Nov 12, 2024
7fafdd0
minor: simplify conversions
dmitry-markin Nov 12, 2024
91d2836
minor: simplify conversions (libp2p backend)
dmitry-markin Nov 12, 2024
c3b039f
empty, kick GitHub
dmitry-markin Nov 13, 2024
391047d
minor: more direct conversions in `NetworkWorker`
dmitry-markin Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions prdoc/pr_5842.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Get rid of libp2p dependency in sc-authority-discovery

doc:
- audience: Node Dev
description: |
Removes `libp2p` types in authority-discovery, and replace them with network backend agnostic types from `sc-network-types`.
The `sc-network` interface is therefore updated accordingly.

crates:
- name: sc-network
bump: patch
- name: sc-network-types
bump: patch
- name: sc-authority-discovery
bump: patch
1 change: 0 additions & 1 deletion substrate/client/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ codec = { workspace = true }
futures = { workspace = true }
futures-timer = { workspace = true }
ip_network = { workspace = true }
libp2p = { features = ["ed25519", "kad"], workspace = true }
multihash = { workspace = true }
linked_hash_set = { workspace = true }
log = { workspace = true, default-features = true }
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/authority-discovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
};

use futures::{channel::mpsc::channel, executor::LocalPool, task::LocalSpawn};
use libp2p::identity::ed25519;
use sc_network_types::ed25519;
use std::{collections::HashSet, sync::Arc};

use sc_network::{multiaddr::Protocol, Multiaddr, PeerId};
Expand Down
6 changes: 3 additions & 3 deletions substrate/client/authority-discovery/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use futures::{channel::mpsc, future, stream::Fuse, FutureExt, Stream, StreamExt}
use addr_cache::AddrCache;
use codec::{Decode, Encode};
use ip_network::IpNetwork;
use libp2p::kad::{PeerRecord, Record};
use linked_hash_set::LinkedHashSet;
use sc_network_types::kad::{Key, PeerRecord, Record};

use log::{debug, error, trace};
use prometheus_endpoint::{register, Counter, CounterVec, Gauge, Opts, U64};
Expand Down Expand Up @@ -682,7 +682,7 @@ where

async fn handle_put_record_requested(
&mut self,
record_key: KademliaKey,
record_key: Key,
record_value: Vec<u8>,
publisher: Option<PeerId>,
expires: Option<std::time::Instant>,
Expand Down Expand Up @@ -943,7 +943,7 @@ where
authority_id, new_record.creation_time, current_record_info.creation_time,
);
self.network.put_record_to(
current_record_info.record.clone(),
current_record_info.record.clone().into(),
new_record.peers_with_record.clone(),
// If this is empty it means we received the answer from our node local
// storage, so we need to update that as well.
Expand Down
14 changes: 7 additions & 7 deletions substrate/client/authority-discovery/src/worker/schema/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ mod schema_v2 {

use super::*;
use codec::Encode;
use libp2p::identity::Keypair;
use prost::Message;
use sc_network::{Multiaddr, PeerId};
use sc_network_types::ed25519::Keypair;

#[test]
fn v2_decodes_v1() {
Expand Down Expand Up @@ -61,7 +61,7 @@ fn v2_decodes_v1() {

#[test]
fn v1_decodes_v2() {
let peer_secret = Keypair::generate_ed25519();
let peer_secret = Keypair::generate();
let peer_public = peer_secret.public();
let peer_id = peer_public.to_peer_id();
let multiaddress: Multiaddr =
Expand All @@ -73,7 +73,7 @@ fn v1_decodes_v2() {
let record_v2 = schema_v2::AuthorityRecord { addresses: vec_addresses.clone() };
let mut vec_record_v2 = vec![];
record_v2.encode(&mut vec_record_v2).unwrap();
let vec_peer_public = peer_public.encode_protobuf();
let vec_peer_public = peer_public.to_bytes().to_vec();
let peer_signature_v2 =
PeerSignature { public_key: vec_peer_public, signature: vec_peer_signature };
let signed_record_v2 = SignedAuthorityRecord {
Expand All @@ -97,7 +97,7 @@ fn v1_decodes_v2() {

#[test]
fn v1_decodes_v3() {
let peer_secret = Keypair::generate_ed25519();
let peer_secret = Keypair::generate();
let peer_public = peer_secret.public();
let peer_id = peer_public.to_peer_id();
let multiaddress: Multiaddr =
Expand All @@ -112,7 +112,7 @@ fn v1_decodes_v3() {
};
let mut vec_record_v3 = vec![];
record_v3.encode(&mut vec_record_v3).unwrap();
let vec_peer_public = peer_public.encode_protobuf();
let vec_peer_public = peer_public.to_bytes().to_vec();
let peer_signature_v3 =
PeerSignature { public_key: vec_peer_public, signature: vec_peer_signature };
let signed_record_v3 = SignedAuthorityRecord {
Expand All @@ -136,7 +136,7 @@ fn v1_decodes_v3() {

#[test]
fn v3_decodes_v2() {
let peer_secret = Keypair::generate_ed25519();
let peer_secret = Keypair::generate();
let peer_public = peer_secret.public();
let peer_id = peer_public.to_peer_id();
let multiaddress: Multiaddr =
Expand All @@ -148,7 +148,7 @@ fn v3_decodes_v2() {
let record_v2 = schema_v2::AuthorityRecord { addresses: vec_addresses.clone() };
let mut vec_record_v2 = vec![];
record_v2.encode(&mut vec_record_v2).unwrap();
let vec_peer_public = peer_public.encode_protobuf();
let vec_peer_public = peer_public.to_bytes().to_vec();
let peer_signature_v2 =
schema_v2::PeerSignature { public_key: vec_peer_public, signature: vec_peer_signature };
let signed_record_v2 = schema_v2::SignedAuthorityRecord {
Expand Down
12 changes: 7 additions & 5 deletions substrate/client/authority-discovery/src/worker/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ use futures::{
sink::SinkExt,
task::LocalSpawn,
};
use libp2p::{identity::SigningError, kad::record::Key as KademliaKey};
use prometheus_endpoint::prometheus::default_registry;

use sc_client_api::HeaderBackend;
use sc_network::{service::signature::Keypair, Signature};
use sc_network::{
service::signature::{Keypair, SigningError},
PublicKey, Signature,
};
use sc_network_types::{
kad::Key as KademliaKey,
multiaddr::{Multiaddr, Protocol},
PeerId,
};
Expand Down Expand Up @@ -178,8 +180,8 @@ impl NetworkSigner for TestNetwork {
signature: &Vec<u8>,
message: &Vec<u8>,
) -> std::result::Result<bool, String> {
let public_key = libp2p::identity::PublicKey::try_decode_protobuf(&public_key)
.map_err(|error| error.to_string())?;
let public_key =
PublicKey::try_decode_protobuf(&public_key).map_err(|error| error.to_string())?;
let peer_id: PeerId = peer_id.into();
let remote: PeerId = public_key.to_peer_id().into();

Expand Down
10 changes: 5 additions & 5 deletions substrate/client/network/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,18 @@ impl From<DiscoveryOut> for BehaviourOut {
},
DiscoveryOut::Discovered(peer_id) => BehaviourOut::Discovered(peer_id),
DiscoveryOut::ValueFound(results, duration) =>
BehaviourOut::Dht(DhtEvent::ValueFound(results), Some(duration)),
BehaviourOut::Dht(DhtEvent::ValueFound(results.into()), Some(duration)),
DiscoveryOut::ValueNotFound(key, duration) =>
BehaviourOut::Dht(DhtEvent::ValueNotFound(key), Some(duration)),
BehaviourOut::Dht(DhtEvent::ValueNotFound(key.into()), Some(duration)),
DiscoveryOut::ValuePut(key, duration) =>
BehaviourOut::Dht(DhtEvent::ValuePut(key), Some(duration)),
BehaviourOut::Dht(DhtEvent::ValuePut(key.into()), Some(duration)),
DiscoveryOut::PutRecordRequest(record_key, record_value, publisher, expires) =>
BehaviourOut::Dht(
DhtEvent::PutRecordRequest(record_key, record_value, publisher, expires),
DhtEvent::PutRecordRequest(record_key.into(), record_value, publisher, expires),
None,
),
DiscoveryOut::ValuePutFailed(key, duration) =>
BehaviourOut::Dht(DhtEvent::ValuePutFailed(key), Some(duration)),
BehaviourOut::Dht(DhtEvent::ValuePutFailed(key.into()), Some(duration)),
DiscoveryOut::RandomKademliaStarted => BehaviourOut::RandomKademliaStarted,
}
}
Expand Down
8 changes: 4 additions & 4 deletions substrate/client/network/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
use crate::types::ProtocolName;

use bytes::Bytes;
use libp2p::{
kad::{record::Key, PeerRecord},
PeerId,
};

use sc_network_common::role::ObservedRole;
use sc_network_types::{
kad::{Key, PeerRecord},
PeerId,
};

/// Events generated by DHT as a response to get_value and put_value requests.
#[derive(Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/network/src/litep2p/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use array_bytes::bytes2hex;
use futures::{FutureExt, Stream};
use futures_timer::Delay;
use ip_network::IpNetwork;
use libp2p::kad::record::Key as KademliaKey;
use litep2p::{
protocol::{
libp2p::{
Expand All @@ -45,6 +44,7 @@ use litep2p::{
PeerId, ProtocolName,
};
use parking_lot::RwLock;
use sc_network_types::kad::Key as KademliaKey;
use schnellru::{ByLength, LruMap};

use std::{
Expand Down
16 changes: 8 additions & 8 deletions substrate/client/network/src/litep2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ use crate::{

use codec::Encode;
use futures::StreamExt;
use libp2p::kad::{PeerRecord, Record as P2PRecord, RecordKey};
use litep2p::{
config::ConfigBuilder,
crypto::ed25519::Keypair,
Expand All @@ -74,6 +73,7 @@ use litep2p::{
Litep2p, Litep2pEvent, ProtocolName as Litep2pProtocolName,
};
use prometheus_endpoint::Registry;
use sc_network_types::kad::{Key as RecordKey, PeerRecord, Record as P2PRecord};

use sc_client_api::BlockBackend;
use sc_network_common::{role::Roles, ExHashT};
Expand Down Expand Up @@ -711,8 +711,8 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> for Litep2pNetworkBac
self.pending_put_values.insert(query_id, (key, Instant::now()));
}
NetworkServiceCommand::PutValueTo { record, peers, update_local_storage} => {
let kademlia_key = record.key.to_vec().into();
let query_id = self.discovery.put_value_to_peers(record, peers, update_local_storage).await;
let kademlia_key = record.key.clone();
let query_id = self.discovery.put_value_to_peers(record.into(), peers, update_local_storage).await;
self.pending_put_values.insert(query_id, (kademlia_key, Instant::now()));
}

Expand Down Expand Up @@ -836,7 +836,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> for Litep2pNetworkBac
self.event_streams.send(
Event::Dht(
DhtEvent::ValueFound(
record
record.into()
)
)
);
Expand Down Expand Up @@ -864,7 +864,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> for Litep2pNetworkBac
);

self.event_streams.send(Event::Dht(
DhtEvent::ValuePut(libp2p::kad::RecordKey::new(&key))
DhtEvent::ValuePut(key)
));

if let Some(ref metrics) = self.metrics {
Expand All @@ -890,7 +890,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> for Litep2pNetworkBac
);

self.event_streams.send(Event::Dht(
DhtEvent::ValuePutFailed(libp2p::kad::RecordKey::new(&key))
DhtEvent::ValuePutFailed(key)
));

if let Some(ref metrics) = self.metrics {
Expand All @@ -908,7 +908,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> for Litep2pNetworkBac
);

self.event_streams.send(Event::Dht(
DhtEvent::ValueNotFound(libp2p::kad::RecordKey::new(&key))
DhtEvent::ValueNotFound(key)
));

if let Some(ref metrics) = self.metrics {
Expand Down Expand Up @@ -964,7 +964,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkBackend<B, H> for Litep2pNetworkBac
Some(DiscoveryEvent::IncomingRecord { record: Record { key, value, publisher, expires }} ) => {
self.event_streams.send(Event::Dht(
DhtEvent::PutRecordRequest(
libp2p::kad::RecordKey::new(&key),
key.into(),
value,
publisher.map(Into::into),
expires,
Expand Down
11 changes: 3 additions & 8 deletions substrate/client/network/src/litep2p/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ use crate::{
RequestFailure, Signature,
};

use crate::litep2p::Record;
use codec::DecodeAll;
use futures::{channel::oneshot, stream::BoxStream};
use libp2p::{identity::SigningError, kad::record::Key as KademliaKey};
use libp2p::identity::SigningError;
use litep2p::{
addresses::PublicAddresses, crypto::ed25519::Keypair,
types::multiaddr::Multiaddr as LiteP2pMultiaddr,
};
use parking_lot::RwLock;
use sc_network_types::kad::{Key as KademliaKey, Record};

use sc_network_common::{
role::{ObservedRole, Roles},
Expand Down Expand Up @@ -266,12 +266,7 @@ impl NetworkDHTProvider for Litep2pNetworkService {
let _ = self.cmd_tx.unbounded_send(NetworkServiceCommand::PutValue { key, value });
}

fn put_record_to(
&self,
record: libp2p::kad::Record,
peers: HashSet<PeerId>,
update_local_storage: bool,
) {
fn put_record_to(&self, record: Record, peers: HashSet<PeerId>, update_local_storage: bool) {
let _ = self.cmd_tx.unbounded_send(NetworkServiceCommand::PutValueTo {
record: Record {
key: record.key.to_vec().into(),
Expand Down
10 changes: 5 additions & 5 deletions substrate/client/network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ use libp2p::{
core::{upgrade, ConnectedPoint, Endpoint},
identify::Info as IdentifyInfo,
identity::ed25519,
kad::{record::Key as KademliaKey, Record},
multiaddr::{self, Multiaddr},
swarm::{
Config as SwarmConfig, ConnectionError, ConnectionId, DialError, Executor, ListenError,
Expand All @@ -80,6 +79,7 @@ use log::{debug, error, info, trace, warn};
use metrics::{Histogram, MetricSources, Metrics};
use parking_lot::Mutex;
use prometheus_endpoint::Registry;
use sc_network_types::kad::{Key as KademliaKey, Record};

use sc_client_api::BlockBackend;
use sc_network_common::{
Expand Down Expand Up @@ -1455,17 +1455,17 @@ where
fn handle_worker_message(&mut self, msg: ServiceToWorkerMsg) {
match msg {
ServiceToWorkerMsg::GetValue(key) =>
self.network_service.behaviour_mut().get_value(key),
self.network_service.behaviour_mut().get_value(key.into()),
ServiceToWorkerMsg::PutValue(key, value) =>
self.network_service.behaviour_mut().put_value(key, value),
self.network_service.behaviour_mut().put_value(key.into(), value),
ServiceToWorkerMsg::PutRecordTo { record, peers, update_local_storage } => self
.network_service
.behaviour_mut()
.put_record_to(record, peers, update_local_storage),
.put_record_to(record.into(), peers, update_local_storage),
ServiceToWorkerMsg::StoreRecord(key, value, publisher, expires) => self
.network_service
.behaviour_mut()
.store_record(key, value, publisher, expires),
.store_record(key.into(), value, publisher, expires),
ServiceToWorkerMsg::AddKnownAddress(peer_id, addr) =>
self.network_service.behaviour_mut().add_known_address(peer_id, addr),
ServiceToWorkerMsg::EventStream(sender) => self.event_streams.push(sender),
Expand Down
Loading
Loading