Cherry-pick commits from master to stable-futures (#1296)

* Implement Debug for (ed25519|secp256k1)::(Keypair|SecretKey) (#1285)

* Fix possible arithmetic overflow in libp2p-kad. (#1291)

When the number of active queries exceeds the (internal)
JOBS_MAX_QUERIES limit, which is only supposed to bound
the number of concurrent queries relating to background
jobs, an arithmetic overflow occurs. This is fixed by
using saturating subtraction.

* protocols/plaintext: Add example on how to upgrade with PlainTextConfig1 (#1286)

* [mdns] - Support for long mDNS names (Bug #1232) (#1287)

* Dead code -- commenting out with a note referencing future implementation

* Adding "std" feature so that cargo can build in other directories (notably `misc/mdns`, so that I could run these tests)

* Permitting `PeerID` to be built from an `Identity` multihash

* The length limit for DNS labels is 63 characters, as per RFC1035

* Allocates the vector with capacity for the service name plus additional QNAME encoding bytes

* Added support for encoding/decoding peer IDs with an encoded length greater than 63 characters

* Removing "std" from ring features

Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>

* Retaining MAX_INLINE_KEY_LENGTH with comment about future usage

* `segment_peer_id` consumes `peer_id` ... plus an early return for IDs that don't need to be segmented

* Fixing logic

* Bump most dependencies (#1268)

* Bump most dependencies

This actually builds 😊.

* Bump all dependencies

Includes the excellent work of @rschulman in #1265.

* Remove use of ed25519-dalek fork

* Monomorphize more dependencies

* Add compatibility hack for rand

Cargo allows a crate to depend on multiple versions of another, but
`cargo-web` panics in that situation.  Use a wrapper crate to work
around the panic.

* Use @tomaka’s idea for using a newer `rand`

instead of my own ugly hack.

* Switch to Parity master

as its dependency-bumping PR has been merged.

* Update some depenendencies again

* Remove unwraps and `#[allow(deprecated)]`.

* Remove spurious changes to dependencies

Bumping minor or patch versions is not needed, and increases likelyhood
of merge conflicts.

* Remove some redundant Cargo.toml changes

* Replace a retry loop with an expect

`ed25519::SecretKey::from_bytes` will never fail for 32-byte inputs.

* Revert changes that don’t belong in this PR

* Remove using void to bypass ICE (#1295)

* Publish 0.13.0 (#1294)
This commit is contained in:
Pierre Krieger
2019-11-06 16:09:15 +01:00
committed by GitHub
parent 7eb4165d44
commit c1226b203a
36 changed files with 322 additions and 170 deletions

View File

@ -2,7 +2,7 @@
name = "libp2p-deflate"
edition = "2018"
description = "Deflate encryption protocol for libp2p"
version = "0.4.0"
version = "0.5.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -11,12 +11,12 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
flate2 = "1.0"
[dev-dependencies]
async-std = "0.99"
env_logger = "0.6"
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
env_logger = "0.7.1"
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
rand = "0.7"
quickcheck = "0.8"
quickcheck = "0.9.0"

View File

@ -2,7 +2,7 @@
name = "libp2p-floodsub"
edition = "2018"
description = "Floodsub protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -10,13 +10,13 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[dependencies]
bs58 = "0.2.0"
bs58 = "0.3.0"
bytes = "0.4"
cuckoofilter = "0.3.2"
fnv = "1.0"
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-swarm = { version = "0.2.0", path = "../../swarm" }
libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" }
protobuf = "2.8"
rand = "0.6"
smallvec = "0.6.5"

View File

@ -2,7 +2,7 @@
name = "libp2p-identify"
edition = "2018"
description = "Nodes identifcation protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -13,18 +13,17 @@ categories = ["network-programming", "asynchronous"]
bytes = "0.4"
futures_codec = "0.3.0"
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-swarm = { version = "0.2.0", path = "../../swarm" }
libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" }
log = "0.4.1"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" }
protobuf = "2.8"
smallvec = "0.6"
wasm-timer = "0.2"
unsigned-varint = { version = "0.2.3", features = ["futures-codec"] }
void = "1.0"
[dev-dependencies]
libp2p-mplex = { version = "0.12.0", path = "../../muxers/mplex" }
libp2p-secio = { version = "0.12.0", path = "../../protocols/secio" }
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
libp2p-mplex = { version = "0.13.0", path = "../../muxers/mplex" }
libp2p-secio = { version = "0.13.0", path = "../../protocols/secio" }
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
rand = "0.6"

View File

@ -36,7 +36,6 @@ use libp2p_swarm::{
use smallvec::SmallVec;
use std::{marker::PhantomData, pin::Pin, task::Context, task::Poll, time::Duration};
use wasm_timer::Delay;
use void::Void;
/// Delay between the moment we connect and the first time we identify.
const DELAY_TO_FIRST_ID: Duration = Duration::from_millis(500);
@ -95,7 +94,7 @@ impl<TSubstream> ProtocolsHandler for IdentifyHandler<TSubstream>
where
TSubstream: AsyncRead + AsyncWrite + Unpin + 'static,
{
type InEvent = Void;
type InEvent = ();
type OutEvent = IdentifyHandlerEvent<TSubstream>;
type Error = ReadOneError;
type Substream = TSubstream;

View File

@ -36,7 +36,6 @@ use libp2p_swarm::{
ProtocolsHandlerUpgrErr
};
use std::{collections::HashMap, collections::VecDeque, io, pin::Pin, task::Context, task::Poll};
use void::Void;
/// Network behaviour that automatically identifies nodes periodically, returns information
/// about them, and answers identify queries from other nodes.
@ -52,7 +51,7 @@ pub struct Identify<TSubstream> {
/// Pending replies to send.
pending_replies: VecDeque<Reply<TSubstream>>,
/// Pending events to be emitted when polled.
events: VecDeque<NetworkBehaviourAction<Void, IdentifyEvent>>,
events: VecDeque<NetworkBehaviourAction<(), IdentifyEvent>>,
}
/// A pending reply to an inbound identification request.

View File

@ -2,7 +2,7 @@
name = "libp2p-kad"
edition = "2018"
description = "Kademlia protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -10,19 +10,19 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[dependencies]
arrayvec = "0.4.7"
arrayvec = "0.5.1"
bytes = "0.4"
either = "1.5"
fnv = "1.0"
futures_codec = "0.3.0"
futures-preview = "0.3.0-alpha.18"
log = "0.4"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-swarm = { version = "0.2.0", path = "../../swarm" }
libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" }
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" }
multihash = { package = "parity-multihash", version = "0.1.0", path = "../../misc/multihash" }
multihash = { package = "parity-multihash", version = "0.1.4", path = "../../misc/multihash" }
protobuf = "2.8"
rand = "0.6.0"
rand = "0.7.2"
sha2 = "0.8.0"
smallvec = "0.6"
wasm-timer = "0.2"
@ -31,8 +31,8 @@ unsigned-varint = { version = "0.2.3", features = ["futures-codec"] }
void = "1.0"
[dev-dependencies]
libp2p-secio = { version = "0.12.0", path = "../secio" }
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
libp2p-yamux = { version = "0.12.0", path = "../../muxers/yamux" }
quickcheck = "0.8"
rand = "0.6.0"
libp2p-secio = { version = "0.13.0", path = "../secio" }
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
libp2p-yamux = { version = "0.13.0", path = "../../muxers/yamux" }
quickcheck = "0.9.0"
rand = "0.7.2"

View File

@ -1313,7 +1313,7 @@ where
let now = Instant::now();
// Calculate the available capacity for queries triggered by background jobs.
let mut jobs_query_capacity = JOBS_MAX_QUERIES - self.queries.size();
let mut jobs_query_capacity = JOBS_MAX_QUERIES.saturating_sub(self.queries.size());
// Run the periodic provider announcement job.
if let Some(mut job) = self.add_provider_job.take() {

View File

@ -623,3 +623,34 @@ fn add_provider() {
QuickCheck::new().tests(3).quickcheck(prop as fn(_,_))
}
/// User code should be able to start queries beyond the internal
/// query limit for background jobs. Originally this even produced an
/// arithmetic overflow, see https://github.com/libp2p/rust-libp2p/issues/1290.
#[test]
fn exceed_jobs_max_queries() {
let (_, mut swarms) = build_nodes(1);
let num = JOBS_MAX_QUERIES + 1;
for _ in 0 .. num {
swarms[0].bootstrap();
}
assert_eq!(swarms[0].queries.size(), num);
current_thread::run(
future::poll_fn(move || {
for _ in 0 .. num {
// There are no other nodes, so the queries finish instantly.
if let Ok(Async::Ready(Some(e))) = swarms[0].poll() {
if let KademliaEvent::BootstrapResult(r) = e {
assert!(r.is_ok(), "Unexpected error")
} else {
panic!("Unexpected event: {:?}", e)
}
} else {
panic!("Expected event")
}
}
Ok(Async::Ready(()))
}))
}

View File

@ -1,7 +1,7 @@
[package]
name = "libp2p-noise"
description = "Cryptographic handshake protocol using the noise framework."
version = "0.10.0"
version = "0.11.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -12,19 +12,19 @@ bytes = "0.4"
curve25519-dalek = "1"
futures-preview = "0.3.0-alpha.18"
lazy_static = "1.2"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4"
protobuf = "2.8"
rand = "^0.7"
ring = { version = "^0.16", features = ["alloc"], default-features = false }
rand = "^0.7.2"
ring = { version = "0.16.9", features = ["alloc"], default-features = false }
snow = { version = "0.6.1", features = ["ring-resolver"], default-features = false }
tokio-io = "0.1"
x25519-dalek = "0.5"
zeroize = "1"
[dev-dependencies]
env_logger = "0.6"
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
quickcheck = "0.8"
env_logger = "0.7.1"
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
quickcheck = "0.9.0"
tokio = "0.1"
sodiumoxide = "^0.2.5"

View File

@ -252,4 +252,3 @@ impl rand::RngCore for Rng {
impl rand::CryptoRng for Rng {}
impl snow::types::Random for Rng {}

View File

@ -2,7 +2,7 @@
name = "libp2p-ping"
edition = "2018"
description = "Ping protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -11,19 +11,19 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
bytes = "0.4"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-swarm = { version = "0.2.0", path = "../../swarm" }
libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" }
log = "0.4.1"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" }
futures-preview = "0.3.0-alpha.18"
rand = "0.6"
rand = "0.7.2"
wasm-timer = "0.2"
void = "1.0"
[dev-dependencies]
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
libp2p-secio = { version = "0.12.0", path = "../../protocols/secio" }
libp2p-yamux = { version = "0.12.0", path = "../../muxers/yamux" }
quickcheck = "0.8"
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
libp2p-secio = { version = "0.13.0", path = "../../protocols/secio" }
libp2p-yamux = { version = "0.13.0", path = "../../muxers/yamux" }
quickcheck = "0.9.0"
tokio = "0.1"
tokio-tcp = "0.1"

View File

@ -2,7 +2,7 @@
name = "libp2p-plaintext"
edition = "2018"
description = "Plaintext encryption dummy protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -10,11 +10,11 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[dependencies]
bytes = "0.4"
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
log = "0.4.6"
void = "1"
libp2p-core = { version = "0.13.0", path = "../../core" }
bytes = "0.4.12"
log = "0.4.8"
void = "1.0.2"
tokio-io = "0.1.12"
protobuf = "2.3"
protobuf = "2.8.1"
rw-stream-sink = { version = "0.1.1", path = "../../misc/rw-stream-sink" }

View File

@ -32,6 +32,32 @@ mod error;
mod handshake;
mod pb;
/// `PlainText1Config` is an insecure connection handshake for testing purposes only.
///
/// > **Note**: Given that `PlainText1Config` has no notion of exchanging peer identity information it is not compatible
/// > with the `libp2p_core::transport::upgrade::Builder` pattern. See
/// > [`PlainText2Config`](struct.PlainText2Config.html) if compatibility is needed. Even though not compatible with the
/// > Builder pattern one can still do an upgrade *manually*:
///
/// ```
/// # use libp2p_core::transport::{ Transport, memory::MemoryTransport };
/// # use libp2p_plaintext::PlainText1Config;
/// #
/// MemoryTransport::default()
/// .and_then(move |io, endpoint| {
/// libp2p_core::upgrade::apply(
/// io,
/// PlainText1Config{},
/// endpoint,
/// libp2p_core::transport::upgrade::Version::V1,
/// )
/// })
/// .map(|plaintext, _endpoint| {
/// unimplemented!();
/// // let peer_id = somehow_derive_peer_id();
/// // return (peer_id, plaintext);
/// });
/// ```
#[derive(Debug, Copy, Clone)]
pub struct PlainText1Config;
@ -64,6 +90,8 @@ impl<C> OutboundUpgrade<C> for PlainText1Config {
}
}
/// `PlainText2Config` is an insecure connection handshake for testing purposes only, implementing
/// the libp2p plaintext connection handshake specification.
#[derive(Clone)]
pub struct PlainText2Config {
pub local_public_key: identity::PublicKey,

View File

@ -2,7 +2,7 @@
name = "libp2p-secio"
edition = "2018"
description = "Secio encryption protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"]
bytes = "0.4"
futures-preview = "0.3.0-alpha.18"
futures_codec = "0.3.0"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.6"
protobuf = "2.8"
rand = "0.6.5"
@ -28,8 +28,8 @@ hmac = "0.7.0"
unsigned-varint = { version = "0.2.3", features = ["futures-codec"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
ring = { version = "^0.16", features = ["alloc"], default-features = false }
untrusted = { version = "0.6" }
ring = { version = "0.16.9", features = ["alloc"], default-features = false }
untrusted = "0.7.0"
[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = "0.3.10"
@ -45,9 +45,9 @@ aes-all = ["aesni"]
[dev-dependencies]
async-std = "0.99"
criterion = "0.2"
libp2p-mplex = { version = "0.12.0", path = "../../muxers/mplex" }
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
criterion = "0.3.0"
libp2p-mplex = { version = "0.13.0", path = "../../muxers/mplex" }
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
[[bench]]
name = "bench"