Skip to content

Commit

Permalink
chore(*): merge master with mdns-high-cpu-tokio
Browse files Browse the repository at this point in the history
  • Loading branch information
gallegogt committed Aug 30, 2022
2 parents 0ec39f1 + 6855ab9 commit 90dc1a8
Show file tree
Hide file tree
Showing 38 changed files with 210 additions and 428 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Expand Up @@ -43,6 +43,30 @@

# `libp2p` facade crate

# 0.48.0 [unreleased]

- Update to [`libp2p-swarm-derive` `v0.30.0`](swarm-derive/CHANGELOG.md#0300).

- Update to [`libp2p-dcutr` `v0.6.0`](protocols/dcutr/CHANGELOG.md#060).

- Update to [`libp2p-rendezvous` `v0.9.0`](protocols/rendezvous/CHANGELOG.md#090).

- Update to [`libp2p-ping` `v0.39.0`](protocols/ping/CHANGELOG.md#0390).

- Update to [`libp2p-identify` `v0.39.0`](protocols/identify/CHANGELOG.md#0390).

- Update to [`libp2p-floodsub` `v0.39.0`](protocols/floodsub/CHANGELOG.md#0390).

- Update to [`libp2p-relay` `v0.12.0`](protocols/relay/CHANGELOG.md#0120).

- Update to [`libp2p-metrics` `v0.9.0`](misc/metrics/CHANGELOG.md#090).

- Update to [`libp2p-kad` `v0.40.0`](protocols/kad/CHANGELOG.md#0400).

- Update to [`libp2p-autonat` `v0.7.0`](protocols/autonat/CHANGELOG.md#070).

- Update to [`libp2p-request-response` `v0.21.0`](protocols/request-response/CHANGELOG.md#0210).

# 0.47.0

- Update to [`libp2p-dcutr` `v0.5.0`](protocols/dcutr/CHANGELOG.md#050).
Expand Down
30 changes: 15 additions & 15 deletions Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "libp2p"
edition = "2021"
rust-version = "1.60.0"
description = "Peer-to-peer networking library"
version = "0.47.0"
version = "0.48.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down Expand Up @@ -78,23 +78,23 @@ getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature
lazy_static = "1.2"

libp2p-autonat = { version = "0.6.0", path = "protocols/autonat", optional = true }
libp2p-autonat = { version = "0.7.0", path = "protocols/autonat", optional = true }
libp2p-core = { version = "0.35.0", path = "core", default-features = false }
libp2p-dcutr = { version = "0.5.0", path = "protocols/dcutr", optional = true }
libp2p-floodsub = { version = "0.38.0", path = "protocols/floodsub", optional = true }
libp2p-identify = { version = "0.38.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.39.0", path = "protocols/kad", optional = true }
libp2p-metrics = { version = "0.8.0", path = "misc/metrics", optional = true }
libp2p-dcutr = { version = "0.6.0", path = "protocols/dcutr", optional = true }
libp2p-floodsub = { version = "0.39.0", path = "protocols/floodsub", optional = true }
libp2p-identify = { version = "0.39.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.40.0", path = "protocols/kad", optional = true }
libp2p-metrics = { version = "0.9.0", path = "misc/metrics", optional = true }
libp2p-mplex = { version = "0.35.0", path = "muxers/mplex", optional = true }
libp2p-noise = { version = "0.38.0", path = "transports/noise", optional = true }
libp2p-ping = { version = "0.38.0", path = "protocols/ping", optional = true }
libp2p-ping = { version = "0.39.0", path = "protocols/ping", optional = true }
libp2p-plaintext = { version = "0.35.0", path = "transports/plaintext", optional = true }
libp2p-pnet = { version = "0.22.0", path = "transports/pnet", optional = true }
libp2p-relay = { version = "0.11.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.8.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.20.0", path = "protocols/request-response", optional = true }
libp2p-swarm = { version = "0.38.0", path = "swarm" }
libp2p-swarm-derive = { version = "0.29.0", path = "swarm-derive" }
libp2p-relay = { version = "0.12.0", path = "protocols/relay", optional = true }
libp2p-rendezvous = { version = "0.9.0", path = "protocols/rendezvous", optional = true }
libp2p-request-response = { version = "0.21.0", path = "protocols/request-response", optional = true }
libp2p-swarm = { version = "0.39.0", path = "swarm" }
libp2p-swarm-derive = { version = "0.30.0", path = "swarm-derive" }
libp2p-uds = { version = "0.34.0", path = "transports/uds", optional = true }
libp2p-wasm-ext = { version = "0.35.0", path = "transports/wasm-ext", default-features = false, optional = true }
libp2p-yamux = { version = "0.39.0", path = "muxers/yamux", optional = true }
Expand All @@ -107,12 +107,12 @@ smallvec = "1.6.1"
[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies]
libp2p-deflate = { version = "0.35.0", path = "transports/deflate", optional = true }
libp2p-dns = { version = "0.35.0", path = "transports/dns", optional = true, default-features = false }
libp2p-mdns = { version = "0.39.0", path = "protocols/mdns", optional = true, default-features = false }
libp2p-mdns = { version = "0.40.0", path = "protocols/mdns", optional = true, default-features = false }
libp2p-tcp = { version = "0.35.0", path = "transports/tcp", default-features = false, optional = true }
libp2p-websocket = { version = "0.37.0", path = "transports/websocket", optional = true }

[target.'cfg(not(target_os = "unknown"))'.dependencies]
libp2p-gossipsub = { version = "0.40.0", path = "protocols/gossipsub", optional = true }
libp2p-gossipsub = { version = "0.41.0", path = "protocols/gossipsub", optional = true }

[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
Expand Down
14 changes: 14 additions & 0 deletions docs/coding-guidelines.md
Expand Up @@ -10,6 +10,7 @@
- [Bound everything](#bound-everything)
- [Channels](#channels)
- [Local queues](#local-queues)
- [Tasks](#tasks)
- [Further reading](#further-reading)
- [No premature optimizations](#no-premature-optimizations)
- [Keep things sequential unless proven to be slow](#keep-things-sequential-unless-proven-to-be-slow)
Expand Down Expand Up @@ -201,6 +202,19 @@ growth and high latencies.
Note that rust-libp2p fails at this guideline, i.e. still has many unbounded
local queues.

### Tasks

Bound the number of
[tasks](https://docs.rs/futures/latest/futures/task/index.html) being spawned.
As an example, say we spawn one task per incoming request received from a
socket. If the number of pending requests is not bounded by some limit, a
misbehaving or malicious remote peer can send requests at a higher rate than the
local node can respond at. This results in unbounded growth in the number of
requests, and thus unbounded growth in the number of tasks and used memory.

Simply put, rust-libp2p spawns one task per connection but limits the overall
number of connections, thus adhering to this guideline.

### Further reading

- https://en.wikipedia.org/wiki/Bufferbloat
Expand Down
6 changes: 0 additions & 6 deletions examples/chat.rs
Expand Up @@ -85,11 +85,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
struct MyBehaviour {
floodsub: Floodsub,
mdns: Mdns,

// Struct fields which do not implement NetworkBehaviour need to be ignored
#[behaviour(ignore)]
#[allow(dead_code)]
ignored_member: bool,
}

#[allow(clippy::large_enum_variant)]
Expand Down Expand Up @@ -117,7 +112,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
let mut behaviour = MyBehaviour {
floodsub: Floodsub::new(local_peer_id),
mdns,
ignored_member: false,
};

behaviour.floodsub.subscribe(floodsub_topic.clone());
Expand Down
14 changes: 14 additions & 0 deletions misc/metrics/CHANGELOG.md
@@ -1,3 +1,17 @@
# 0.9.0 [unreleased]

- Update to `libp2p-swarm` `v0.39.0`.

- Update to `libp2p-dcutr` `v0.6.0`.

- Update to `libp2p-ping` `v0.39.0`.

- Update to `libp2p-identify` `v0.39.0`.

- Update to `libp2p-relay` `v0.12.0`.

- Update to `libp2p-kad` `v0.40.0`.

# 0.8.0

- Update to `libp2p-swarm` `v0.38.0`.
Expand Down
16 changes: 8 additions & 8 deletions misc/metrics/Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-metrics"
edition = "2021"
rust-version = "1.56.1"
description = "Metrics for libp2p"
version = "0.8.0"
version = "0.9.0"
authors = ["Max Inden <mail@max-inden.de>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -20,16 +20,16 @@ dcutr = ["libp2p-dcutr"]

[dependencies]
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-dcutr = { version = "0.5.0", path = "../../protocols/dcutr", optional = true }
libp2p-identify = { version = "0.38.0", path = "../../protocols/identify", optional = true }
libp2p-kad = { version = "0.39.0", path = "../../protocols/kad", optional = true }
libp2p-ping = { version = "0.38.0", path = "../../protocols/ping", optional = true }
libp2p-relay = { version = "0.11.0", path = "../../protocols/relay", optional = true }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-dcutr = { version = "0.6.0", path = "../../protocols/dcutr", optional = true }
libp2p-identify = { version = "0.39.0", path = "../../protocols/identify", optional = true }
libp2p-kad = { version = "0.40.0", path = "../../protocols/kad", optional = true }
libp2p-ping = { version = "0.39.0", path = "../../protocols/ping", optional = true }
libp2p-relay = { version = "0.12.0", path = "../../protocols/relay", optional = true }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
prometheus-client = "0.18.0"

[target.'cfg(not(target_os = "unknown"))'.dependencies]
libp2p-gossipsub = { version = "0.40.0", path = "../../protocols/gossipsub", optional = true }
libp2p-gossipsub = { version = "0.41.0", path = "../../protocols/gossipsub", optional = true }

[dev-dependencies]
log = "0.4.0"
Expand Down
6 changes: 6 additions & 0 deletions protocols/autonat/CHANGELOG.md
@@ -1,3 +1,9 @@
# 0.7.0 [unreleased]

- Update to `libp2p-swarm` `v0.39.0`.

- Update to `libp2p-request-response` `v0.21.0`.

# 0.6.0

- Update to `libp2p-swarm` `v0.38.0`.
Expand Down
6 changes: 3 additions & 3 deletions protocols/autonat/Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-autonat"
edition = "2021"
rust-version = "1.56.1"
description = "NAT and firewall detection for libp2p"
version = "0.6.0"
version = "0.7.0"
authors = ["David Craven <david@craven.ch>", "Elena Frank <elena.frank@protonmail.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -19,8 +19,8 @@ futures = "0.3"
futures-timer = "3.0"
instant = "0.1"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-request-response = { version = "0.20.0", path = "../request-response" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
libp2p-request-response = { version = "0.21.0", path = "../request-response" }
log = "0.4"
rand = "0.8"
prost = "0.11"
Expand Down
4 changes: 4 additions & 0 deletions protocols/dcutr/CHANGELOG.md
@@ -1,3 +1,7 @@
# 0.6.0 [unreleased]

- Update to `libp2p-swarm` `v0.39.0`.

# 0.5.1

- Make default features of `libp2p-core` optional. See [PR 2836].
Expand Down
4 changes: 2 additions & 2 deletions protocols/dcutr/Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-dcutr"
edition = "2021"
rust-version = "1.56.1"
description = "Direct connection upgrade through relay"
version = "0.5.1"
version = "0.6.0"
authors = ["Max Inden <mail@max-inden.de>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -18,7 +18,7 @@ futures = "0.3.1"
futures-timer = "3.0"
instant = "0.1.11"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4"
prost-codec = { version = "0.2", path = "../../misc/prost-codec" }
prost = "0.11"
Expand Down
4 changes: 4 additions & 0 deletions protocols/floodsub/CHANGELOG.md
@@ -1,3 +1,7 @@
# 0.39.0 [unreleased]

- Update to `libp2p-swarm` `v0.39.0`.

# 0.38.0

- Update to `libp2p-swarm` `v0.38.0`.
Expand Down
4 changes: 2 additions & 2 deletions protocols/floodsub/Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-floodsub"
edition = "2021"
rust-version = "1.56.1"
description = "Floodsub protocol for libp2p"
version = "0.38.0"
version = "0.39.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -15,7 +15,7 @@ cuckoofilter = "0.5.0"
fnv = "1.0"
futures = "0.3.1"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4"
prost = "0.11"
rand = "0.7"
Expand Down
4 changes: 4 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
@@ -1,3 +1,7 @@
# 0.41.0 [unreleased]

- Update to `libp2p-swarm` `v0.39.0`.

# 0.40.0

- Update to `libp2p-swarm` `v0.38.0`.
Expand Down
4 changes: 2 additions & 2 deletions protocols/gossipsub/Cargo.toml
Expand Up @@ -3,15 +3,15 @@ name = "libp2p-gossipsub"
edition = "2021"
rust-version = "1.56.1"
description = "Gossipsub protocol for libp2p"
version = "0.40.0"
version = "0.41.0"
authors = ["Age Manning <Age@AgeManning.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]

[dependencies]
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
bytes = "1.0"
byteorder = "1.3.4"
Expand Down
4 changes: 4 additions & 0 deletions protocols/identify/CHANGELOG.md
@@ -1,3 +1,7 @@
# 0.39.0 [unreleased]

- Update to `libp2p-swarm` `v0.39.0`.

# 0.38.0

- Update to `libp2p-swarm` `v0.38.0`.
Expand Down
4 changes: 2 additions & 2 deletions protocols/identify/Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-identify"
edition = "2021"
rust-version = "1.56.1"
description = "Nodes identifcation protocol for libp2p"
version = "0.38.0"
version = "0.39.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -15,7 +15,7 @@ asynchronous-codec = "0.6"
futures = "0.3.1"
futures-timer = "3.0.2"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4.1"
lru = "0.7.2"
prost-codec = { version = "0.2", path = "../../misc/prost-codec" }
Expand Down
4 changes: 4 additions & 0 deletions protocols/kad/CHANGELOG.md
@@ -1,3 +1,7 @@
# 0.40.0 [unreleased]

- Update to `libp2p-swarm` `v0.39.0`.

# 0.39.0

- Update to `libp2p-swarm` `v0.38.0`.
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-kad"
edition = "2021"
rust-version = "1.56.1"
description = "Kademlia protocol for libp2p"
version = "0.39.0"
version = "0.40.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -19,7 +19,7 @@ asynchronous-codec = "0.6"
futures = "0.3.1"
log = "0.4"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
prost = "0.11"
rand = "0.7.2"
sha2 = "0.10.0"
Expand Down
4 changes: 4 additions & 0 deletions protocols/mdns/CHANGELOG.md
@@ -1,3 +1,7 @@
# 0.40.0 [unreleased]

- Update to `libp2p-swarm` `v0.39.0`.

# 0.39.0

- Update to `libp2p-swarm` `v0.38.0`.
Expand Down
4 changes: 2 additions & 2 deletions protocols/mdns/Cargo.toml
Expand Up @@ -2,7 +2,7 @@
name = "libp2p-mdns"
edition = "2021"
rust-version = "1.56.1"
version = "0.39.0"
version = "0.40.0"
description = "Implementation of the libp2p mDNS discovery method"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
Expand All @@ -17,7 +17,7 @@ futures = "0.3.13"
if-watch = "1.1.1"
lazy_static = "1.4.0"
libp2p-core = { version = "0.35.0", path = "../../core", default-features = false }
libp2p-swarm = { version = "0.38.0", path = "../../swarm" }
libp2p-swarm = { version = "0.39.0", path = "../../swarm" }
log = "0.4.14"
rand = "0.8.3"
smallvec = "1.6.1"
Expand Down
4 changes: 4 additions & 0 deletions protocols/ping/CHANGELOG.md
@@ -1,3 +1,7 @@
# 0.39.0 [unreleased]

- Update to `libp2p-swarm` `v0.39.0`.

# 0.38.0

- Update to `libp2p-swarm` `v0.38.0`.
Expand Down

0 comments on commit 90dc1a8

Please sign in to comment.