Identity rework (#49)

This commit is contained in:
Aleksey Proshutisnkiy
2021-04-15 21:07:50 +03:00
committed by GitHub
parent d1ed9e76bc
commit 43544e635a
31 changed files with 139 additions and 163 deletions

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p"
edition = "2018"
description = "Peer-to-peer networking library"
version = "0.36.0"
version = "0.36.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -64,40 +64,40 @@ atomic = "0.5.0"
bytes = "1"
futures = "0.3.1"
lazy_static = "1.2"
libp2p-core = { version = "0.27.1", path = "core", default-features = false, package = "fluence-fork-libp2p-core" }
libp2p-floodsub = { version = "0.28.0", path = "protocols/floodsub", optional = true, package = "fluence-fork-libp2p-floodsub" }
libp2p-gossipsub = { version = "0.29.0", path = "./protocols/gossipsub", optional = true, package = "fluence-fork-libp2p-gossipsub" }
libp2p-identify = { version = "0.28.0", path = "protocols/identify", optional = true, package = "fluence-fork-libp2p-identify" }
libp2p-kad = { version = "0.29.0", path = "protocols/kad", optional = true, package = "fluence-fork-libp2p-kad" }
libp2p-mplex = { version = "0.27.1", path = "muxers/mplex", optional = true, package = "fluence-fork-libp2p-mplex" }
libp2p-noise = { version = "0.29.0", path = "transports/noise", optional = true, package = "fluence-fork-libp2p-noise" }
libp2p-ping = { version = "0.28.0", path = "protocols/ping", optional = true, package = "fluence-fork-libp2p-ping" }
libp2p-plaintext = { version = "0.27.1", path = "transports/plaintext", optional = true, package = "fluence-fork-libp2p-plaintext" }
libp2p-pnet = { version = "0.20.0", path = "transports/pnet", optional = true, package = "fluence-fork-libp2p-pnet" }
libp2p-request-response = { version = "0.10.0", path = "protocols/request-response", optional = true, package = "fluence-fork-libp2p-request-response" }
libp2p-swarm = { version = "0.28.0", path = "swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-swarm-derive = { version = "0.22.0", path = "swarm-derive", package = "fluence-fork-libp2p-swarm-derive" }
libp2p-uds = { version = "0.27.0", path = "transports/uds", optional = true, package = "fluence-fork-libp2p-uds" }
libp2p-wasm-ext = { version = "0.27.0", path = "transports/wasm-ext", default-features = false, optional = true, package = "fluence-fork-libp2p-wasm-ext" }
libp2p-yamux = { version = "0.30.1", path = "muxers/yamux", optional = true, package = "fluence-fork-libp2p-yamux" }
multiaddr = { package = "fluence-fork-parity-multiaddr", version = "0.11.1", path = "misc/multiaddr" }
libp2p-core = { version = "0.27.2", path = "core", default-features = false, package = "fluence-fork-libp2p-core" }
libp2p-floodsub = { version = "0.28.1", path = "protocols/floodsub", optional = true, package = "fluence-fork-libp2p-floodsub" }
libp2p-gossipsub = { version = "0.29.1", path = "./protocols/gossipsub", optional = true, package = "fluence-fork-libp2p-gossipsub" }
libp2p-identify = { version = "0.28.1", path = "protocols/identify", optional = true, package = "fluence-fork-libp2p-identify" }
libp2p-kad = { version = "0.29.1", path = "protocols/kad", optional = true, package = "fluence-fork-libp2p-kad" }
libp2p-mplex = { version = "0.27.2", path = "muxers/mplex", optional = true, package = "fluence-fork-libp2p-mplex" }
libp2p-noise = { version = "0.29.1", path = "transports/noise", optional = true, package = "fluence-fork-libp2p-noise" }
libp2p-ping = { version = "0.28.1", path = "protocols/ping", optional = true, package = "fluence-fork-libp2p-ping" }
libp2p-plaintext = { version = "0.27.2", path = "transports/plaintext", optional = true, package = "fluence-fork-libp2p-plaintext" }
libp2p-pnet = { version = "0.20.2", path = "transports/pnet", optional = true, package = "fluence-fork-libp2p-pnet" }
libp2p-request-response = { version = "0.10.1", path = "protocols/request-response", optional = true, package = "fluence-fork-libp2p-request-response" }
libp2p-swarm = { version = "0.28.1", path = "swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-swarm-derive = { version = "0.22.1", path = "swarm-derive", package = "fluence-fork-libp2p-swarm-derive" }
libp2p-uds = { version = "0.27.1", path = "transports/uds", optional = true, package = "fluence-fork-libp2p-uds" }
libp2p-wasm-ext = { version = "0.27.1", path = "transports/wasm-ext", default-features = false, optional = true, package = "fluence-fork-libp2p-wasm-ext" }
libp2p-yamux = { version = "0.30.2", path = "muxers/yamux", optional = true, package = "fluence-fork-libp2p-yamux" }
multiaddr = { package = "fluence-fork-parity-multiaddr", version = "0.11.2", path = "misc/multiaddr" }
parking_lot = "0.11.0"
pin-project = "1.0.0"
smallvec = "1.0"
wasm-timer = "0.2.4"
[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies]
libp2p-deflate = { version = "0.27.1", path = "transports/deflate", optional = true, package = "fluence-fork-libp2p-deflate" }
libp2p-dns = { version = "0.27.0", path = "transports/dns", optional = true, package = "fluence-fork-libp2p-dns" }
libp2p-mdns = { version = "0.29.0", path = "protocols/mdns", optional = true, package = "fluence-fork-libp2p-mdns" }
libp2p-tcp = { version = "0.27.1", path = "transports/tcp", default-features = false, optional = true, package = "fluence-fork-libp2p-tcp" }
libp2p-websocket = { version = "0.28.0", path = "transports/websocket", optional = true, package = "fluence-fork-libp2p-websocket" }
libp2p-deflate = { version = "0.27.2", path = "transports/deflate", optional = true, package = "fluence-fork-libp2p-deflate" }
libp2p-dns = { version = "0.27.1", path = "transports/dns", optional = true, package = "fluence-fork-libp2p-dns" }
libp2p-mdns = { version = "0.29.1", path = "protocols/mdns", optional = true, package = "fluence-fork-libp2p-mdns" }
libp2p-tcp = { version = "0.27.3", path = "transports/tcp", default-features = false, optional = true, package = "fluence-fork-libp2p-tcp" }
libp2p-websocket = { version = "0.28.1", path = "transports/websocket", optional = true, package = "fluence-fork-libp2p-websocket" }
[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
env_logger = "0.8.1"
tokio = { version = "1.0.1", features = ["io-util", "io-std", "macros", "rt", "rt-multi-thread"] }
trust-graph = "0.2.5"
trust-graph = "0.2.7"
[workspace]
members = [
@@ -142,3 +142,7 @@ wasm-timer = { git = "https://github.com/fluencelabs/wasm-timer", branch = "satu
[package.metadata.workspaces]
independent = true
## uncomment this patch section if using git dependencies in trust graph
# [patch.'https://github.com/fluencelabs/rust-libp2p']
# libp2p-core = { package = "fluence-fork-libp2p-core", path = "core" }

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-core"
edition = "2018"
description = "Core traits and structs of libp2p"
version = "0.27.1"
version = "0.27.2"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"

View File

@@ -88,10 +88,7 @@ fn main() -> Result<(), Box<dyn Error>> {
fn inject_event(&mut self, event: MdnsEvent) {
if let MdnsEvent::Discovered(list) = event {
for (peer_id, multiaddr) in list {
let key = match peer_id.as_public_key().expect("peer id must inline public key") {
libp2p::identity::PublicKey::Ed25519(key) => key,
_ => unreachable!("only ed25519 supported"),
};
let key = peer_id.as_public_key().expect("peer id must inline public key");
self.kademlia.add_address(&peer_id, multiaddr, key);
}
}
@@ -155,10 +152,6 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut swarm = {
// Create a Kademlia behaviour.
let store = MemoryStore::new(local_peer_id.clone());
let local_key = match local_key {
libp2p::identity::Keypair::Ed25519(kp) => kp,
_ => unreachable!("only ed25519 supported"),
};
let trust = {
let storage = InMemoryStorage::new_in_memory(vec![]);
TrustGraph::new(storage)

View File

@@ -6,7 +6,7 @@ description = "Implementation of the multiaddr format"
homepage = "https://github.com/libp2p/rust-libp2p"
keywords = ["multiaddr", "ipfs"]
license = "MIT"
version = "0.11.1"
version = "0.11.2"
[features]
default = ["url"]

View File

@@ -1,7 +1,7 @@
[package]
name = "fluence-fork-multistream-select"
description = "Multistream-select negotiation protocol for libp2p"
version = "0.10.2"
version = "0.10.3"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-mplex"
edition = "2018"
description = "Mplex multiplexing protocol for libp2p"
version = "0.27.1"
version = "0.27.2"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -16,7 +16,7 @@ name = "libp2p_mplex"
bytes = "1"
futures = "0.3.1"
asynchronous-codec = "0.6"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
log = "0.4"
nohash-hasher = "0.2"
parking_lot = "0.11"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-yamux"
edition = "2018"
description = "Yamux multiplexing protocol for libp2p"
version = "0.30.1"
version = "0.30.2"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -14,7 +14,7 @@ name = "libp2p_yamux"
[dependencies]
futures = "0.3.1"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
parking_lot = "0.11"
thiserror = "1.0"
yamux = "0.8.1"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-floodsub"
edition = "2018"
description = "Floodsub protocol for libp2p"
version = "0.28.0"
version = "0.28.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -16,8 +16,8 @@ name = "libp2p_floodsub"
cuckoofilter = "0.5.0"
fnv = "1.0"
futures = "0.3.1"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.0", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.1", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
log = "0.4"
prost = "0.7"
rand = "0.7"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-gossipsub"
edition = "2018"
description = "Gossipsub protocol for libp2p"
version = "0.29.0"
version = "0.29.1"
authors = ["Age Manning <Age@AgeManning.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -13,8 +13,8 @@ categories = ["network-programming", "asynchronous"]
name = "libp2p_gossipsub"
[dependencies]
libp2p-swarm = { version = "0.28.0", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.1", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
bytes = "1.0"
byteorder = "1.3.4"
fnv = "1.0.7"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-identify"
edition = "2018"
description = "Nodes identifcation protocol for libp2p"
version = "0.28.0"
version = "0.28.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -14,8 +14,8 @@ name = "libp2p_identify"
[dependencies]
futures = "0.3.1"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.0", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.1", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
log = "0.4.1"
prost = "0.7"
smallvec = "1.0"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-kad"
edition = "2018"
description = "Kademlia protocol for libp2p"
version = "0.29.0"
version = "0.29.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -20,8 +20,8 @@ fnv = "1.0"
asynchronous-codec = "0.6"
futures = "0.3.1"
log = "0.4"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.0", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.1", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
prost = "0.7"
rand = "0.7.2"
sha2 = "0.9.1"
@@ -33,8 +33,8 @@ void = "1.0"
bs58 = "0.3.0"
derivative = "2.0.2"
trust-graph = "0.2.5"
fluence-identity = "0.2.4"
trust-graph = "0.2.7"
fluence-identity = "0.3.0"
prometheus = "0.9.0"
[dev-dependencies]

View File

@@ -40,7 +40,7 @@ use crate::query::{Query, QueryId, QueryPool, QueryConfig, QueryPoolState, Weigh
use crate::record::{self, store::{self, RecordStore}, Record, ProviderRecord};
use crate::contact::Contact;
use fnv::{FnvHashMap, FnvHashSet};
use libp2p_core::{ConnectedPoint, Multiaddr, PeerId, connection::ConnectionId, multiaddr};
use libp2p_core::{ConnectedPoint, Multiaddr, PeerId, connection::ConnectionId, multiaddr, identity::PublicKey, identity::Keypair};
use libp2p_swarm::{
DialPeerCondition,
NetworkBehaviour,
@@ -57,7 +57,6 @@ use std::num::NonZeroUsize;
use std::task::{Context, Poll};
use std::vec;
use wasm_timer::Instant;
use libp2p_core::identity::ed25519::{Keypair, PublicKey};
use trust_graph::{Certificate};
use derivative::Derivative;
use crate::metrics::Metrics;
@@ -928,10 +927,10 @@ where
};
let certificates = {
match node_id.as_public_key() {
Some(libp2p_core::identity::PublicKey::Ed25519(pk)) =>
Some(pk) =>
get_certificates(&trust, &pk),
key => {
log::warn!("Provider {} has a non-Ed25519 public key: {:?}", node_id, key);
None => {
log::warn!("Provider {} has a non-inlined public key: {:?}", node_id, key);
vec![]
}
}
@@ -1074,7 +1073,7 @@ where
debug!(
"Calculated weight for {} pk {}: {}",
entry.key().preimage(),
bs58::encode(contact.public_key.encode().to_vec().as_slice()).into_string(),
bs58::encode(contact.public_key.clone().into_protobuf_encoding()).into_string(),
weight
);
// TODO: how to avoid clone when bucket isn't Full?
@@ -1749,15 +1748,11 @@ where
}
fn get_certificates(trust: &TrustGraph, key: &PublicKey) -> Vec<Certificate> {
fluence_identity::PublicKey::from_libp2p(&key).map(|key|
trust.get_all_certs(&key, &[]).unwrap_or_default()
).unwrap_or_default()
trust.get_all_certs(fluence_identity::PublicKey::from(key.clone()), &[]).unwrap_or_default()
}
fn get_weight(trust: &TrustGraph, key: &PublicKey) -> u32 {
fluence_identity::PublicKey::from_libp2p(&key).map(|key|
trust.weight(&key).unwrap_or_default().unwrap_or_default()
).unwrap_or(0)
trust.weight(fluence_identity::PublicKey::from(key.clone())).unwrap_or_default().unwrap_or_default()
}
/// Exponentially decrease the given duration (base 2).
@@ -1967,18 +1962,7 @@ where
}));
let contact = contact.or({
let pk = source.as_public_key()
.and_then(|pk| {
match pk {
libp2p_core::identity::PublicKey::Ed25519(pk) => {
Some(pk)
}
_ => {
log::warn!("Cannot create contact with non-ed25519 key.");
None
}
}
});
let pk = source.as_public_key();
let address = new_address.map(Addresses::new);
address.zip(pk).map(|(addr, pk)| Contact::new(addr, pk))
});

View File

@@ -35,7 +35,6 @@ use libp2p_core::{
connection::{ConnectedPoint, ConnectionId},
PeerId,
Transport,
identity,
transport::MemoryTransport,
multiaddr::{Protocol, Multiaddr, multiaddr},
upgrade,
@@ -47,18 +46,17 @@ use libp2p_yamux as yamux;
use quickcheck::*;
use rand::{Rng, random, thread_rng, rngs::StdRng, SeedableRng};
use std::{collections::{HashSet, HashMap}, time::Duration, num::NonZeroUsize, u64};
use libp2p_core::identity::ed25519;
use trust_graph::InMemoryStorage;
type TestSwarm = Swarm<Kademlia<MemoryStore>>;
fn build_node() -> (ed25519::Keypair, Multiaddr, TestSwarm) {
fn build_node() -> (Keypair, Multiaddr, TestSwarm) {
build_node_with_config(Default::default())
}
fn build_node_with_config(cfg: KademliaConfig) -> (ed25519::Keypair, Multiaddr, TestSwarm) {
let ed25519_key = ed25519::Keypair::generate();
let local_key = identity::Keypair::Ed25519(ed25519_key.clone());
fn build_node_with_config(cfg: KademliaConfig) -> (Keypair, Multiaddr, TestSwarm) {
let ed25519_key = Keypair::generate_ed25519();
let local_key = ed25519_key.clone();
let local_public_key = local_key.public();
let noise_keys = noise::Keypair::<noise::X25519>::new().into_authentic(&local_key).unwrap();
let transport = MemoryTransport::default()
@@ -69,7 +67,7 @@ fn build_node_with_config(cfg: KademliaConfig) -> (ed25519::Keypair, Multiaddr,
let local_id = local_public_key.clone().into_peer_id();
let trust = {
let pk = fluence_identity::PublicKey::from_libp2p(&ed25519_key.public()).unwrap();
let pk = fluence_identity::PublicKey::from(ed25519_key.public());
let storage = InMemoryStorage::new_in_memory(vec![(pk, 1)]);
TrustGraph::new(storage)
};
@@ -85,21 +83,21 @@ fn build_node_with_config(cfg: KademliaConfig) -> (ed25519::Keypair, Multiaddr,
}
/// Builds swarms, each listening on a port. Does *not* connect the nodes together.
fn build_nodes(num: usize) -> Vec<(ed25519::Keypair, Multiaddr, TestSwarm)> {
fn build_nodes(num: usize) -> Vec<(Keypair, Multiaddr, TestSwarm)> {
build_nodes_with_config(num, Default::default())
}
/// Builds swarms, each listening on a port. Does *not* connect the nodes together.
fn build_nodes_with_config(num: usize, cfg: KademliaConfig) -> Vec<(ed25519::Keypair, Multiaddr, TestSwarm)> {
fn build_nodes_with_config(num: usize, cfg: KademliaConfig) -> Vec<(Keypair, Multiaddr, TestSwarm)> {
(0..num).map(|_| build_node_with_config(cfg.clone())).collect()
}
fn build_connected_nodes(total: usize, step: usize) -> Vec<(ed25519::Keypair, Multiaddr, TestSwarm)> {
fn build_connected_nodes(total: usize, step: usize) -> Vec<(Keypair, Multiaddr, TestSwarm)> {
build_connected_nodes_with_config(total, step, Default::default())
}
fn build_connected_nodes_with_config(total: usize, step: usize, cfg: KademliaConfig)
-> Vec<(ed25519::Keypair, Multiaddr, TestSwarm)>
-> Vec<(Keypair, Multiaddr, TestSwarm)>
{
let mut swarms = build_nodes_with_config(total, cfg);
let swarm_ids: Vec<_> = swarms.iter()
@@ -121,7 +119,7 @@ fn build_connected_nodes_with_config(total: usize, step: usize, cfg: KademliaCon
}
fn build_fully_connected_nodes_with_config(total: usize, cfg: KademliaConfig)
-> Vec<(ed25519::Keypair, Multiaddr, TestSwarm)>
-> Vec<(Keypair, Multiaddr, TestSwarm)>
{
let mut swarms = build_nodes_with_config(total, cfg);
let swarm_addr_and_peer_id: Vec<_> = swarms.iter()
@@ -1229,10 +1227,6 @@ mod certificates {
pub kp: Keypair,
}
fn bs(pk: PublicKey) -> String {
bs58::encode(pk.to_bytes()).into_string()
}
#[test]
pub fn certificate_dissemination() {
for _ in 1..10 {
@@ -1247,8 +1241,8 @@ mod certificates {
let weights = swarms.iter().map(|(kp, _, _)| (kp.public(), 1)).collect::<Vec<_>>();
for swarm in swarms.iter_mut() {
for (pk, weight) in weights.iter() {
let pk = fluence_identity::PublicKey::from_libp2p(&pk).unwrap();
swarm.2.trust.add_root_weight(pk, *weight);
let pk = fluence_identity::PublicKey::from(pk.clone());
swarm.2.trust.add_root_weight(pk, *weight).expect("trust.add_root_weight failed");
}
}
@@ -1256,7 +1250,7 @@ mod certificates {
let (first_kp, _, first) = swarms.next().unwrap();
// issue certs from each swarm to the first swarm, so all swarms trust the first one
let mut swarms = swarms.map(|(kp, _, mut swarm)| {
let pk = fluence_identity::PublicKey::from_libp2p(&first_kp.public()).unwrap();
let pk = fluence_identity::PublicKey::from(first_kp.public());
// root cert, its chain is [self-signed: swarm -> swarm, swarm -> first]
let root = gen_root_cert(&kp.clone().into(), pk);
swarm.trust.add(&root, current_time()).unwrap();
@@ -1270,12 +1264,12 @@ mod certificates {
// issue cert from the first swarm to the second (will be later disseminated via kademlia)
// chain: 0 -> 1
let cert_0_1 = {
let pk = fluence_identity::PublicKey::from_libp2p(&swarm1.kp.public()).unwrap();
let pk = fluence_identity::PublicKey::from(swarm1.kp.public());
gen_root_cert(&swarm0.kp.clone().into(), pk)
};
swarm0.swarm.trust.add(&cert_0_1, current_time()).unwrap();
let cert_0_1_check = {
let pk = fluence_identity::PublicKey::from_libp2p(&swarm1.kp.public()).unwrap();
let pk = fluence_identity::PublicKey::from(swarm1.kp.public());
swarm0.swarm.trust.get_all_certs(pk, &[]).unwrap()
};
assert_eq!(cert_0_1_check.len(), 1);
@@ -1285,7 +1279,7 @@ mod certificates {
// check that this certificate (with root prepended) can be added to trust graph of any other node
// chain: (2 -> 0)
let mut cert_2_0_1 = {
let pk = fluence_identity::PublicKey::from_libp2p(&swarm0.kp.public()).unwrap();
let pk = fluence_identity::PublicKey::from(swarm0.kp.public());
gen_root_cert(&swarm2.kp.clone().into(), pk)
};
// chain: (2 -> 0) ++ (0 -> 1)
@@ -1326,12 +1320,12 @@ mod certificates {
// check that certificates for `swarm[1].kp` were disseminated
for swarm in swarms.iter().skip(2) {
let disseminated = {
let pk = fluence_identity::PublicKey::from_libp2p(&kp_1).unwrap();
let pk = fluence_identity::PublicKey::from(kp_1.clone());
swarm.swarm.trust.get_all_certs(&pk, &[]).unwrap()
};
// take only certificate converging to current `swarm` public key
let disseminated = {
let pk = fluence_identity::PublicKey::from_libp2p(&swarm.kp.public()).unwrap();
let pk = fluence_identity::PublicKey::from(swarm.kp.public());
disseminated.into_iter().find(|c| &c.chain[0].issued_for == &pk).unwrap()
};
// swarm -> swarm0 -> swarm1
@@ -1340,9 +1334,9 @@ mod certificates {
assert_eq!(
pubkeys,
vec![
&fluence_identity::PublicKey::from_libp2p(&swarm.kp.public()).unwrap(),
&fluence_identity::PublicKey::from_libp2p(&swarms[0].kp.public()).unwrap(),
&fluence_identity::PublicKey::from_libp2p(&swarms[1].kp.public()).unwrap(),
&fluence_identity::PublicKey::from(swarm.kp.public()),
&fluence_identity::PublicKey::from(swarms[0].kp.public()),
&fluence_identity::PublicKey::from(swarms[1].kp.public()),
]
);

View File

@@ -17,7 +17,7 @@
use crate::protocol::KadPeer;
use crate::Addresses;
use bs58;
use libp2p_core::identity::ed25519::PublicKey;
use libp2p_core::identity::PublicKey;
use libp2p_core::Multiaddr;
use smallvec::SmallVec;
use std::fmt::Formatter;
@@ -77,7 +77,7 @@ impl std::fmt::Display for Contact {
write!(
f,
"Contact({}, addresses: {:?})",
bs58::encode(self.public_key.encode()).into_string(),
bs58::encode(self.public_key.clone().into_protobuf_encoding()).into_string(),
self.addresses // TODO: implement better display for addresses
)
}
@@ -88,7 +88,7 @@ impl std::fmt::Debug for Contact {
write!(
f,
"Contact {{ public_key: {}, addresses: {:?} }}",
bs58::encode(self.public_key.encode()).into_string(),
bs58::encode(self.public_key.clone().into_protobuf_encoding()).into_string(),
self.addresses // TODO: implement better display for addresses
)
}

View File

@@ -81,19 +81,21 @@ pub use sub_bucket::*;
use crate::kbucket::weighted_iter::WeightedIter;
use bucket::KBucket;
use libp2p_core::identity::ed25519;
use libp2p_core::identity::ed25519::{Keypair, PublicKey};
use libp2p_core::identity::{Keypair, PublicKey};
use log::debug;
use std::collections::VecDeque;
use std::fmt::Debug;
use std::time::Duration;
use derivative::Derivative;
/// Maximum number of k-buckets.
const NUM_BUCKETS: usize = 256;
/// A `KBucketsTable` represents a Kademlia routing table.
#[derive(Debug, Clone)]
#[derive(Derivative)]
#[derivative(Debug, Clone)]
pub struct KBucketsTable<TKey, TVal> {
#[derivative(Debug="ignore")]
local_kp: Keypair,
/// The key identifying the local peer that owns the routing table.
local_key: TKey,
@@ -164,7 +166,7 @@ where
/// The given `pending_timeout` specifies the duration after creation of
/// a [`PendingEntry`] after which it becomes eligible for insertion into
/// a full bucket, replacing the least-recently (dis)connected node.
pub fn new(local_kp: ed25519::Keypair, local_key: TKey, pending_timeout: Duration) -> Self {
pub fn new(local_kp: Keypair, local_key: TKey, pending_timeout: Duration) -> Self {
KBucketsTable {
local_kp,
local_key,
@@ -566,7 +568,6 @@ where
#[cfg(test)]
mod tests {
use super::*;
use libp2p_core::identity;
use libp2p_core::PeerId;
use quickcheck::*;
use rand::Rng;
@@ -576,8 +577,8 @@ mod tests {
impl Arbitrary for TestTable {
fn arbitrary<G: Gen>(g: &mut G) -> TestTable {
let keypair = ed25519::Keypair::generate();
let public_key = identity::PublicKey::Ed25519(keypair.public());
let keypair = Keypair::generate_ed25519();
let public_key = keypair.public();
let local_key = Key::from(PeerId::from(public_key));
let timeout = Duration::from_secs(g.gen_range(1, 360));
@@ -608,8 +609,8 @@ mod tests {
#[test]
fn buckets_are_non_overlapping_and_exhaustive() {
let keypair = ed25519::Keypair::generate();
let public_key = identity::PublicKey::Ed25519(keypair.public());
let keypair = Keypair::generate_ed25519();
let public_key = keypair.public();
let local_key = Key::from(PeerId::from(public_key));
let timeout = Duration::from_secs(0);
let mut table = KBucketsTable::<KeyBytes, ()>::new(keypair, local_key.into(), timeout);
@@ -665,8 +666,8 @@ mod tests {
#[test]
fn entry_inserted() {
let keypair = ed25519::Keypair::generate();
let public_key = identity::PublicKey::Ed25519(keypair.public());
let keypair = Keypair::generate_ed25519();
let public_key = keypair.public();
let local_key = Key::from(PeerId::from(public_key));
let other_id = Key::from(PeerId::random());
let other_weight = 0; // TODO: random weight
@@ -688,8 +689,8 @@ mod tests {
#[test]
fn entry_self() {
let keypair = ed25519::Keypair::generate();
let public_key = identity::PublicKey::Ed25519(keypair.public());
let keypair = Keypair::generate_ed25519();
let public_key = keypair.public();
let local_key = Key::from(PeerId::from(public_key));
let mut table =
KBucketsTable::<_, ()>::new(keypair, local_key.clone(), Duration::from_secs(5));
@@ -701,8 +702,8 @@ mod tests {
#[test]
fn closest() {
let keypair = ed25519::Keypair::generate();
let public_key = identity::PublicKey::Ed25519(keypair.public());
let keypair = Keypair::generate_ed25519();
let public_key = keypair.public();
let local_key = Key::from(PeerId::from(public_key));
let mut table = KBucketsTable::<_, ()>::new(keypair, local_key, Duration::from_secs(5));
let mut count = 0;
@@ -739,8 +740,8 @@ mod tests {
#[test]
fn applied_pending() {
let keypair = ed25519::Keypair::generate();
let public_key = identity::PublicKey::Ed25519(keypair.public());
let keypair = Keypair::generate_ed25519();
let public_key = keypair.public();
let local_key = Key::from(PeerId::from(public_key));
let mut table =
KBucketsTable::<_, ()>::new(keypair, local_key.clone(), Duration::from_millis(1));

View File

@@ -230,8 +230,8 @@ where
mod tests {
use std::time::Duration;
use libp2p_core::identity::ed25519;
use libp2p_core::{identity, PeerId};
use libp2p_core::PeerId;
use libp2p_core::identity::Keypair;
use crate::kbucket::{Entry, InsertResult, Key};
@@ -250,8 +250,8 @@ mod tests {
.try_init()
.ok();
let keypair = ed25519::Keypair::generate();
let public_key = identity::PublicKey::Ed25519(keypair.public());
let keypair = Keypair::generate_ed25519();
let public_key = keypair.public();
let local_key = Key::from(PeerId::from(public_key));
let mut table =

View File

@@ -41,7 +41,7 @@ use unsigned_varint::codec;
use wasm_timer::Instant;
use derivative::Derivative;
use libp2p_core::identity::ed25519::PublicKey;
use libp2p_core::identity::PublicKey;
use trust_graph::{Certificate, Trust};
/// The protocol name used for negotiating with multistream-select.
@@ -123,7 +123,7 @@ impl TryFrom<proto::message::Peer> for KadPeer {
.ok_or_else(|| invalid_data("unknown connection type"))?
.into();
let public_key = PublicKey::decode(peer.public_key.as_slice())
let public_key = PublicKey::from_protobuf_encoding(peer.public_key.as_slice())
.map_err(|e|
invalid_data(format!("invalid public key: {}", e).as_str())
)?;
@@ -133,13 +133,13 @@ impl TryFrom<proto::message::Peer> for KadPeer {
for cert in peer.certificates.into_iter() {
let mut chain = Vec::with_capacity(cert.chain.len());
for trust in cert.chain.into_iter() {
let issued_for = fluence_identity::PublicKey::from_bytes(trust.issued_for.as_slice())
let issued_for = fluence_identity::PublicKey::decode(&trust.issued_for)
.map_err(|e|
invalid_data(format!("invalid issued_for: {}", e).as_str())
)?;
let expires_at: Duration = Duration::from_secs(trust.expires_at_secs);
let issued_at: Duration = Duration::from_secs(trust.issued_at_secs);
let signature = fluence_identity::Signature::from_bytes(&trust.signature)
let signature = fluence_identity::Signature::decode(trust.signature)
.map_err(|e|
invalid_data(format!("invalid signature: {}", e).as_str())
)?;
@@ -166,9 +166,9 @@ impl Into<proto::message::Peer> for KadPeer {
proto::Certificate {
chain: cert.chain.into_iter().map(|trust| {
proto::Trust {
issued_for: trust.issued_for.to_bytes().to_vec(),
issued_for: trust.issued_for.encode(),
expires_at_secs: trust.expires_at.as_secs(),
signature: trust.signature.to_bytes().to_vec(),
signature: trust.signature.encode(),
issued_at_secs: trust.issued_at.as_secs(),
}
}).collect(),
@@ -182,7 +182,7 @@ impl Into<proto::message::Peer> for KadPeer {
let ct: proto::message::ConnectionType = self.connection_ty.into();
ct as i32
},
public_key: self.public_key.encode().to_vec(),
public_key: self.public_key.into_protobuf_encoding(),
certificates
}
}

View File

@@ -1,7 +1,7 @@
[package]
name = "fluence-fork-libp2p-mdns"
edition = "2018"
version = "0.29.0"
version = "0.29.1"
description = "Implementation of the libp2p mDNS discovery method"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
@@ -19,8 +19,8 @@ dns-parser = "0.8.0"
futures = "0.3.13"
if-watch = "0.2.0"
lazy_static = "1.4.0"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.0", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.1", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
log = "0.4.14"
rand = "0.8.3"
smallvec = "1.6.1"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-ping"
edition = "2018"
description = "Ping protocol for libp2p"
version = "0.28.0"
version = "0.28.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -14,8 +14,8 @@ name = "libp2p_ping"
[dependencies]
futures = "0.3.1"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.0", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.1", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
log = "0.4.1"
rand = "0.7.2"
void = "1.0"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-request-response"
edition = "2018"
description = "Generic Request/Response Protocols"
version = "0.10.0"
version = "0.10.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -16,8 +16,8 @@ name = "libp2p_request_response"
async-trait = "0.1"
bytes = "1"
futures = "0.3.1"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.0", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-swarm = { version = "0.28.1", path = "../../swarm", package = "fluence-fork-libp2p-swarm" }
log = "0.4.11"
lru = "0.6"
minicbor = { version = "0.7", features = ["std", "derive"] }

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-swarm-derive"
edition = "2018"
description = "Procedural macros of libp2p-core"
version = "0.22.0"
version = "0.22.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-swarm"
edition = "2018"
description = "The libp2p swarm"
version = "0.28.0"
version = "0.28.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -15,7 +15,7 @@ name = "libp2p_swarm"
[dependencies]
either = "1.6.0"
futures = "0.3.1"
libp2p-core = { version = "0.27.1", path = "../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../core", package = "fluence-fork-libp2p-core" }
log = "0.4"
rand = "0.7"
smallvec = "1.0"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-deflate"
edition = "2018"
description = "Deflate encryption protocol for libp2p"
version = "0.27.1"
version = "0.27.2"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -14,7 +14,7 @@ name = "libp2p_deflate"
[dependencies]
futures = "0.3.1"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
flate2 = "1.0"
[dev-dependencies]

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-dns"
edition = "2018"
description = "DNS transport implementation for libp2p"
version = "0.27.0"
version = "0.27.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"]
name = "libp2p_dns"
[dependencies]
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
log = "0.4.1"
futures = "0.3.1"

View File

@@ -1,7 +1,7 @@
[package]
name = "fluence-fork-libp2p-noise"
description = "Cryptographic handshake protocol using the noise framework."
version = "0.29.0"
version = "0.29.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -15,7 +15,7 @@ bytes = "1"
curve25519-dalek = "3.0.0"
futures = "0.3.1"
lazy_static = "1.2"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
log = "0.4"
prost = "0.7"
rand = "0.7.2"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-plaintext"
edition = "2018"
description = "Plaintext encryption dummy protocol for libp2p"
version = "0.27.1"
version = "0.27.2"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -16,7 +16,7 @@ name = "libp2p_plaintext"
bytes = "1"
futures = "0.3.1"
asynchronous-codec = "0.6"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
log = "0.4.8"
prost = "0.7"
unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-pnet"
edition = "2018"
description = "Private swarm support for libp2p"
version = "0.20.1"
version = "0.20.2"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-tcp"
edition = "2018"
description = "TCP/IP transport protocol for libp2p"
version = "0.27.2"
version = "0.27.3"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -20,7 +20,7 @@ if-watch = { version = "0.2.0", optional = true }
if-addrs = { version = "0.6.4", optional = true }
ipnet = "2.0.0"
libc = "0.2.80"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
log = "0.4.11"
socket2 = { version = "0.3.17", features = ["reuseport"] }
tokio-crate = { package = "tokio", version = "1.0.1", default-features = false, features = ["net"], optional = true }

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-uds"
edition = "2018"
description = "Unix domain sockets transport for libp2p"
version = "0.27.0"
version = "0.27.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"

View File

@@ -1,6 +1,6 @@
[package]
name = "fluence-fork-libp2p-wasm-ext"
version = "0.27.0"
version = "0.27.1"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"
description = "Allows passing in an external transport in a WASM environment"
@@ -15,7 +15,7 @@ name = "libp2p_wasm_ext"
[dependencies]
futures = "0.3.1"
js-sys = "0.3.19"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
parity-send-wrapper = "0.1.0"
wasm-bindgen = "0.2.42"
wasm-bindgen-futures = "0.4.4"

View File

@@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-websocket"
edition = "2018"
description = "WebSocket transport for libp2p"
version = "0.28.0"
version = "0.28.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@@ -16,7 +16,7 @@ name = "libp2p_websocket"
futures-rustls = "0.21"
either = "1.5.3"
futures = "0.3.1"
libp2p-core = { version = "0.27.1", path = "../../core", package = "fluence-fork-libp2p-core" }
libp2p-core = { version = "0.27.2", path = "../../core", package = "fluence-fork-libp2p-core" }
log = "0.4.8"
quicksink = "0.1"
rw-stream-sink = "0.2.0"