From fca30e32a9618b317bb5ece9d944f51544a10eaf Mon Sep 17 00:00:00 2001 From: drHuangMHT Date: Mon, 18 Mar 2024 20:40:25 +0800 Subject: [PATCH 001/246] introduce logging --- Cargo.lock | 8 ++++++++ Cargo.toml | 1 + misc/logging/Cargo.toml | 18 ++++++++++++++++++ misc/logging/src/lib.rs | 8 ++++++++ 4 files changed, 35 insertions(+) create mode 100644 misc/logging/Cargo.toml create mode 100644 misc/logging/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index bfc291828b0..19ac5fca9d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3575,6 +3575,14 @@ dependencies = [ "value-bag", ] +[[package]] +name = "logging" +version = "0.0.0" +dependencies = [ + "tracing", + "tracing-subscriber", +] + [[package]] name = "lru" version = "0.12.2" diff --git a/Cargo.toml b/Cargo.toml index 8982a65537e..e51dcd66f49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ members = [ "misc/rw-stream-sink", "misc/server", "misc/webrtc-utils", + "misc/logging", "muxers/mplex", "muxers/test-harness", "muxers/yamux", diff --git a/misc/logging/Cargo.toml b/misc/logging/Cargo.toml new file mode 100644 index 00000000000..a9671c3f637 --- /dev/null +++ b/misc/logging/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "logging" +version = "0.0.0" +edition = "2021" +authors = ["drHuangMHT "] +license = "MIT" +repository = "https://github.com/libp2p/rust-libp2p" +publish = false + +[package.metadata.release] +release = false + +[dependencies] +tracing = "0.1.37" +tracing-subscriber = {version = "0.3", features = ["env-filter"]} + +[lints] +workspace = true diff --git a/misc/logging/src/lib.rs b/misc/logging/src/lib.rs new file mode 100644 index 00000000000..646adbeb8e1 --- /dev/null +++ b/misc/logging/src/lib.rs @@ -0,0 +1,8 @@ +use tracing_subscriber::EnvFilter; + +pub fn with_env_filter(){ + let _ = tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .with_writer(||std::io::stderr()) + .try_init(); +} \ No newline at end of file From 2f5ce0a97decec2b895157b2457e69d24687ea8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 21 Mar 2024 10:27:34 +0000 Subject: [PATCH 002/246] deps: bump opentelemetry dependency (#5181) ## Description Updates `opentelemetry-otlp` from 0.13.0 to 0.14.0 Changes `opentelemetry` to `opentelemetry_sdk` dependency and updates to 0.21.0 Changes `opentelemetry_api` to `opentelemetry` and updates to 0.21.0 see https://github.com/open-telemetry/opentelemetry-rust/issues/1186 for more info superseeds https://github.com/libp2p/rust-libp2p/pull/4858 --- Cargo.lock | 92 ++++++++++++++++-------------------- examples/metrics/Cargo.toml | 8 ++-- examples/metrics/src/main.rs | 14 ++---- 3 files changed, 50 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52913f9796e..c872cdb48ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3672,7 +3672,7 @@ dependencies = [ "libp2p", "opentelemetry", "opentelemetry-otlp", - "opentelemetry_api", + "opentelemetry_sdk", "prometheus-client", "tokio", "tracing", @@ -4050,26 +4050,32 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9591d937bc0e6d2feb6f71a559540ab300ea49955229c347a517a28d27784c54" +checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" dependencies = [ - "opentelemetry_api", - "opentelemetry_sdk", + "futures-core", + "futures-sink", + "indexmap 2.2.1", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", + "urlencoding", ] [[package]] name = "opentelemetry-otlp" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e5e5a5c4135864099f3faafbe939eb4d7f9b80ebf68a8448da961b32a7c1275" +checksum = "f24cda83b20ed2433c68241f918d0f6fdec8b1d43b7a9590ab4420c5095ca930" dependencies = [ "async-trait", "futures-core", "http 0.2.9", + "opentelemetry", "opentelemetry-proto", "opentelemetry-semantic-conventions", - "opentelemetry_api", "opentelemetry_sdk", "prost", "thiserror", @@ -4079,11 +4085,11 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e3f814aa9f8c905d0ee4bde026afd3b2577a97c10e1699912e3e44f0c4cbeb" +checksum = "a2e155ce5cc812ea3d1dffbd1539aed653de4bf4882d60e6e04dcf0901d674e1" dependencies = [ - "opentelemetry_api", + "opentelemetry", "opentelemetry_sdk", "prost", "tonic", @@ -4091,47 +4097,30 @@ dependencies = [ [[package]] name = "opentelemetry-semantic-conventions" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73c9f9340ad135068800e7f1b24e9e09ed9e7143f5bf8518ded3d3ec69789269" +checksum = "f5774f1ef1f982ef2a447f6ee04ec383981a3ab99c8e77a1a7b30182e65bbc84" dependencies = [ "opentelemetry", ] -[[package]] -name = "opentelemetry_api" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a81f725323db1b1206ca3da8bb19874bbd3f57c3bcd59471bfb04525b265b9b" -dependencies = [ - "futures-channel", - "futures-util", - "indexmap 1.9.3", - "js-sys", - "once_cell", - "pin-project-lite", - "thiserror", - "urlencoding", -] - [[package]] name = "opentelemetry_sdk" -version = "0.20.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8e705a0612d48139799fcbaba0d4a90f06277153e43dd2bdc16c6f0edd8026" +checksum = "2f16aec8a98a457a52664d69e0091bac3a0abd18ead9b641cb00202ba4e0efe4" dependencies = [ "async-trait", "crossbeam-channel", "futures-channel", "futures-executor", "futures-util", + "glob", "once_cell", - "opentelemetry_api", + "opentelemetry", "ordered-float", "percent-encoding", "rand 0.8.5", - "regex", - "serde_json", "thiserror", "tokio", "tokio-stream", @@ -4139,9 +4128,9 @@ dependencies = [ [[package]] name = "ordered-float" -version = "3.9.2" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" dependencies = [ "num-traits", ] @@ -6041,17 +6030,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - [[package]] name = "tracing-log" version = "0.2.0" @@ -6065,18 +6043,20 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75327c6b667828ddc28f5e3f169036cb793c3f588d83bf0f262a7f062ffed3c8" +checksum = "c67ac25c5407e7b961fafc6f7e9aa5958fd297aada2d20fa2ae1737357e55596" dependencies = [ + "js-sys", "once_cell", "opentelemetry", "opentelemetry_sdk", "smallvec", "tracing", "tracing-core", - "tracing-log 0.1.3", + "tracing-log", "tracing-subscriber", + "web-time", ] [[package]] @@ -6094,7 +6074,7 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log 0.2.0", + "tracing-log", ] [[package]] @@ -6470,6 +6450,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "0.25.2" diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index 39412d29aea..499e1fb7f4b 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -12,13 +12,13 @@ release = false futures = "0.3.30" hyper = { version = "0.14", features = ["server", "tcp", "http1"] } libp2p = { path = "../../libp2p", features = ["tokio", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] } -opentelemetry = { version = "0.20.0", features = ["rt-tokio", "metrics"] } -opentelemetry-otlp = { version = "0.13.0", features = ["metrics"]} -opentelemetry_api = "0.20.0" +opentelemetry = { version = "0.21.0", features = ["metrics"] } +opentelemetry-otlp = { version = "0.14.0", features = ["metrics"] } +opentelemetry_sdk = { version = "0.21.2", features = ["rt-tokio", "metrics"] } prometheus-client = { workspace = true } tokio = { version = "1", features = ["full"] } tracing = "0.1.37" -tracing-opentelemetry = "0.21.0" +tracing-opentelemetry = "0.22.0" tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/metrics/src/main.rs b/examples/metrics/src/main.rs index 3ab6815cb32..6b7ad9cedfb 100644 --- a/examples/metrics/src/main.rs +++ b/examples/metrics/src/main.rs @@ -25,8 +25,7 @@ use libp2p::core::Multiaddr; use libp2p::metrics::{Metrics, Recorder}; use libp2p::swarm::{NetworkBehaviour, SwarmEvent}; use libp2p::{identify, identity, noise, ping, tcp, yamux}; -use opentelemetry::sdk; -use opentelemetry_api::KeyValue; +use opentelemetry::KeyValue; use prometheus_client::registry::Registry; use std::error::Error; use std::time::Duration; @@ -87,13 +86,10 @@ fn setup_tracing() -> Result<(), Box> { let tracer = opentelemetry_otlp::new_pipeline() .tracing() .with_exporter(opentelemetry_otlp::new_exporter().tonic()) - .with_trace_config( - sdk::trace::Config::default().with_resource(sdk::Resource::new(vec![KeyValue::new( - "service.name", - "libp2p", - )])), - ) - .install_batch(opentelemetry::runtime::Tokio)?; + .with_trace_config(opentelemetry_sdk::trace::Config::default().with_resource( + opentelemetry_sdk::Resource::new(vec![KeyValue::new("service.name", "libp2p")]), + )) + .install_batch(opentelemetry_sdk::runtime::Tokio)?; tracing_subscriber::registry() .with(tracing_subscriber::fmt::layer().with_filter(EnvFilter::from_default_env())) From 46a043e8cba256c6c3f0e77cec4aa751f546df81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:40:53 +0000 Subject: [PATCH 003/246] deps: bump obi1kenobi/cargo-semver-checks-action from 2.3 to 2.4 Pull-Request: #5249. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24a211966a8..a489fec1f1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -319,7 +319,7 @@ jobs: - uses: actions/checkout@v4 - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.27.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin shell: bash - - uses: obi1kenobi/cargo-semver-checks-action@48f4ef7da6d907d69d18249e0ba79aa98c61b9db # v2 + - uses: obi1kenobi/cargo-semver-checks-action@c7306483f698c511eaf7416d1bf2e1958c90140f # v2 rustfmt: runs-on: ubuntu-latest From 4a6d59c51b9a36540b2ddb29303088622def01a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:13:38 +0000 Subject: [PATCH 004/246] deps: bump wasm-bindgen-test from 0.3.41 to 0.3.42 Pull-Request: #5241. --- Cargo.lock | 8 ++++---- wasm-tests/webtransport-tests/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c872cdb48ca..a6ba0896894 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6406,9 +6406,9 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-bindgen-test" -version = "0.3.41" +version = "0.3.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143ddeb4f833e2ed0d252e618986e18bfc7b0e52f2d28d77d05b2f045dd8eb61" +checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" dependencies = [ "console_error_panic_hook", "js-sys", @@ -6420,9 +6420,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.41" +version = "0.3.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5211b7550606857312bba1d978a8ec75692eae187becc5e680444fffc5e6f89" +checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", diff --git a/wasm-tests/webtransport-tests/Cargo.toml b/wasm-tests/webtransport-tests/Cargo.toml index b98e56440b1..918df42bef7 100644 --- a/wasm-tests/webtransport-tests/Cargo.toml +++ b/wasm-tests/webtransport-tests/Cargo.toml @@ -19,7 +19,7 @@ multiaddr = { workspace = true } multihash = { workspace = true } wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.42" -wasm-bindgen-test = "0.3.41" +wasm-bindgen-test = "0.3.42" web-sys = { version = "0.3.68", features = ["Response", "Window"] } [lints] From cdafe0e63a9e4fd9cd58d35f28f716c9f8edef3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:25:25 +0000 Subject: [PATCH 005/246] deps: bump heck from 0.4.1 to 0.5.0 Pull-Request: #5240. --- Cargo.lock | 14 ++++++++++---- swarm-derive/Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6ba0896894..d02ad913326 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -933,7 +933,7 @@ version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 2.0.52", @@ -1421,7 +1421,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "syn 2.0.52", @@ -1895,6 +1895,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.2" @@ -3260,7 +3266,7 @@ dependencies = [ name = "libp2p-swarm-derive" version = "0.34.3" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.52", @@ -5547,7 +5553,7 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index b2906e9de96..d2d8796acb3 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] proc-macro = true [dependencies] -heck = "0.4" +heck = "0.5" quote = "1.0" syn = { version = "2.0.52", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" From a579e691c46a8efd2e38ebafca1c59a9b58fc56c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 15:14:00 +0000 Subject: [PATCH 006/246] deps: bump reqwest from 0.11.25 to 0.11.26 Pull-Request: #5239. --- Cargo.lock | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d02ad913326..4554147f4e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2274,7 +2274,7 @@ dependencies = [ "log", "rtnetlink", "smol", - "system-configuration 0.5.1", + "system-configuration", "tokio", "windows", ] @@ -4804,9 +4804,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.25" +version = "0.11.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eea5a9eb898d3783f17c6407670e3592fd174cb81a10e51d4c37f49450b9946" +checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" dependencies = [ "base64 0.21.7", "bytes", @@ -4833,7 +4833,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration 0.6.0", + "system-configuration", "tokio", "tokio-native-tls", "tokio-rustls", @@ -5657,18 +5657,7 @@ checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", "core-foundation", - "system-configuration-sys 0.5.0", -] - -[[package]] -name = "system-configuration" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" -dependencies = [ - "bitflags 2.4.1", - "core-foundation", - "system-configuration-sys 0.6.0", + "system-configuration-sys", ] [[package]] @@ -5681,16 +5670,6 @@ dependencies = [ "libc", ] -[[package]] -name = "system-configuration-sys" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tempfile" version = "3.10.1" From 404a62281238ed53069e73072ab5cb535b4fdb3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Mon, 25 Mar 2024 00:33:12 +0000 Subject: [PATCH 007/246] chore: address clippy lints and bump ci clippy stable superseeds #5248, sorry @drHuangMHT only saw yours now, can you review this one? https://github.com/libp2p/rust-libp2p/actions/runs/8377129630/job/22938498078?pr=5253#step:6:843 is a bug, see [here](https://github.com/rust-lang/rust-clippy/issues/12377) Thanks! Pull-Request: #5253. --- .github/workflows/ci.yml | 4 +- core/src/peer_record.rs | 1 - core/src/translation.rs | 2 +- core/src/transport/memory.rs | 8 +-- core/src/upgrade/apply.rs | 2 +- examples/autonat/src/bin/autonat_client.rs | 19 ------- examples/autonat/src/bin/autonat_server.rs | 19 ------- identity/src/ed25519.rs | 1 - identity/src/keypair.rs | 14 +++-- identity/src/lib.rs | 3 +- identity/src/peer_id.rs | 2 +- misc/metrics/src/identify.rs | 7 +-- .../multistream-select/src/listener_select.rs | 1 - misc/multistream-select/src/protocol.rs | 1 - misc/quick-protobuf-codec/src/lib.rs | 1 - misc/rw-stream-sink/src/lib.rs | 2 +- muxers/mplex/src/lib.rs | 2 +- muxers/yamux/src/lib.rs | 2 +- protocols/autonat/src/protocol.rs | 10 ++-- protocols/dcutr/src/behaviour.rs | 6 +-- protocols/dcutr/src/protocol/inbound.rs | 1 - protocols/dcutr/src/protocol/outbound.rs | 1 - protocols/gossipsub/src/behaviour.rs | 4 +- protocols/gossipsub/src/behaviour/tests.rs | 27 ++++------ protocols/gossipsub/src/config.rs | 2 - protocols/gossipsub/src/mcache.rs | 4 +- protocols/gossipsub/src/peer_score.rs | 6 +-- protocols/gossipsub/src/protocol.rs | 1 - .../gossipsub/src/subscription_filter.rs | 1 - protocols/identify/src/protocol.rs | 1 - protocols/kad/src/behaviour/test.rs | 18 ++----- protocols/kad/src/kbucket.rs | 2 +- protocols/kad/src/kbucket/bucket.rs | 1 - protocols/kad/src/kbucket/entry.rs | 2 +- protocols/kad/src/protocol.rs | 2 +- protocols/kad/src/query/peers/closest.rs | 6 +-- .../kad/src/query/peers/closest/disjoint.rs | 19 +------ protocols/kad/src/query/peers/fixed.rs | 1 - protocols/kad/src/record/store/memory.rs | 3 -- protocols/mdns/src/behaviour/iface/dns.rs | 1 - protocols/mdns/src/behaviour/socket.rs | 1 - protocols/mdns/src/behaviour/timer.rs | 5 +- protocols/ping/src/protocol.rs | 2 - protocols/relay/src/behaviour/rate_limiter.rs | 2 - protocols/relay/src/copy_future.rs | 6 +-- protocols/rendezvous/src/codec.rs | 2 - protocols/rendezvous/src/server.rs | 2 - protocols/rendezvous/tests/rendezvous.rs | 1 - protocols/request-response/src/cbor.rs | 1 - protocols/request-response/src/json.rs | 1 - protocols/request-response/tests/ping.rs | 2 +- swarm/src/behaviour/peer_addresses.rs | 2 +- swarm/src/connection.rs | 29 +++++----- swarm/src/connection/pool.rs | 27 +--------- swarm/src/handler/multi.rs | 2 +- swarm/src/handler/one_shot.rs | 2 +- swarm/src/lib.rs | 9 +--- swarm/tests/swarm_derive.rs | 53 +++++++++---------- transports/dns/src/lib.rs | 8 +-- transports/noise/src/io/handshake.rs | 2 +- transports/noise/src/protocol.rs | 2 - transports/noise/tests/smoke.rs | 2 +- transports/quic/src/transport.rs | 4 +- transports/tcp/src/lib.rs | 6 +-- transports/tcp/src/provider/tokio.rs | 1 - transports/uds/src/lib.rs | 2 +- .../src/stream/poll_data_channel.rs | 2 +- transports/webrtc/src/tokio/transport.rs | 6 +-- transports/websocket-websys/src/lib.rs | 2 +- .../websocket-websys/src/web_context.rs | 2 +- transports/websocket/src/framed.rs | 2 +- transports/websocket/src/quicksink.rs | 2 +- transports/websocket/src/tls.rs | 1 - 73 files changed, 111 insertions(+), 292 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a489fec1f1f..9069b2eecf1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: - name: Extract version from manifest run: | CRATE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .version') - + echo "CRATE_VERSION=$CRATE_VERSION" >> $GITHUB_ENV - name: Enforce version in `workspace.dependencies` matches latest version @@ -234,7 +234,7 @@ jobs: fail-fast: false matrix: rust-version: [ - 1.75.0, # current stable + 1.77.0, # current stable beta, ] steps: diff --git a/core/src/peer_record.rs b/core/src/peer_record.rs index 2fd6a39ef2b..d5fc86c391e 100644 --- a/core/src/peer_record.rs +++ b/core/src/peer_record.rs @@ -5,7 +5,6 @@ use libp2p_identity::Keypair; use libp2p_identity::PeerId; use libp2p_identity::SigningError; use quick_protobuf::{BytesReader, Writer}; -use std::convert::TryInto; const PAYLOAD_TYPE: &str = "/libp2p/routing-state-record"; const DOMAIN_SEP: &str = "libp2p-routing-state"; diff --git a/core/src/translation.rs b/core/src/translation.rs index 70700ca6ae8..efddae31052 100644 --- a/core/src/translation.rs +++ b/core/src/translation.rs @@ -65,7 +65,7 @@ mod tests { expected: Multiaddr, } - let tests = vec![ + let tests = [ // Basic ipv4. Test { original: "/ip4/192.0.2.1/tcp/1".parse().unwrap(), diff --git a/core/src/transport/memory.rs b/core/src/transport/memory.rs index bf88215dd43..6e4b9322ee5 100644 --- a/core/src/transport/memory.rs +++ b/core/src/transport/memory.rs @@ -20,13 +20,7 @@ use crate::transport::{ListenerId, Transport, TransportError, TransportEvent}; use fnv::FnvHashMap; -use futures::{ - channel::mpsc, - future::{self, Ready}, - prelude::*, - task::Context, - task::Poll, -}; +use futures::{channel::mpsc, future::Ready, prelude::*, task::Context, task::Poll}; use multiaddr::{Multiaddr, Protocol}; use once_cell::sync::Lazy; use parking_lot::Mutex; diff --git a/core/src/upgrade/apply.rs b/core/src/upgrade/apply.rs index 15cb0348cf3..f84aaaac9fa 100644 --- a/core/src/upgrade/apply.rs +++ b/core/src/upgrade/apply.rs @@ -21,7 +21,7 @@ use crate::upgrade::{InboundConnectionUpgrade, OutboundConnectionUpgrade, UpgradeError}; use crate::{connection::ConnectedPoint, Negotiated}; use futures::{future::Either, prelude::*}; -use multistream_select::{self, DialerSelectFuture, ListenerSelectFuture}; +use multistream_select::{DialerSelectFuture, ListenerSelectFuture}; use std::{mem, pin::Pin, task::Context, task::Poll}; pub(crate) use multistream_select::Version; diff --git a/examples/autonat/src/bin/autonat_client.rs b/examples/autonat/src/bin/autonat_client.rs index 3fb25aa6222..def66c4823b 100644 --- a/examples/autonat/src/bin/autonat_client.rs +++ b/examples/autonat/src/bin/autonat_client.rs @@ -110,22 +110,3 @@ impl Behaviour { } } } - -#[derive(Debug)] -#[allow(clippy::large_enum_variant)] -enum Event { - AutoNat(autonat::Event), - Identify(identify::Event), -} - -impl From for Event { - fn from(v: identify::Event) -> Self { - Self::Identify(v) - } -} - -impl From for Event { - fn from(v: autonat::Event) -> Self { - Self::AutoNat(v) - } -} diff --git a/examples/autonat/src/bin/autonat_server.rs b/examples/autonat/src/bin/autonat_server.rs index 44a53f0d17f..389cc0fa26f 100644 --- a/examples/autonat/src/bin/autonat_server.rs +++ b/examples/autonat/src/bin/autonat_server.rs @@ -94,22 +94,3 @@ impl Behaviour { } } } - -#[derive(Debug)] -#[allow(clippy::large_enum_variant)] -enum Event { - AutoNat(autonat::Event), - Identify(identify::Event), -} - -impl From for Event { - fn from(v: identify::Event) -> Self { - Self::Identify(v) - } -} - -impl From for Event { - fn from(v: autonat::Event) -> Self { - Self::AutoNat(v) - } -} diff --git a/identity/src/ed25519.rs b/identity/src/ed25519.rs index 529a4dddea1..d77c44547d6 100644 --- a/identity/src/ed25519.rs +++ b/identity/src/ed25519.rs @@ -25,7 +25,6 @@ use core::cmp; use core::fmt; use core::hash; use ed25519_dalek::{self as ed25519, Signer as _, Verifier as _}; -use std::convert::TryFrom; use zeroize::Zeroize; /// An Ed25519 keypair. diff --git a/identity/src/keypair.rs b/identity/src/keypair.rs index bdfb68c0091..f1e8a7c2142 100644 --- a/identity/src/keypair.rs +++ b/identity/src/keypair.rs @@ -24,32 +24,30 @@ feature = "ed25519", feature = "rsa" ))] -use crate::error::OtherVariantError; -use crate::error::{DecodingError, SigningError}; +#[cfg(feature = "ed25519")] +use crate::ed25519; #[cfg(any( feature = "ecdsa", feature = "secp256k1", feature = "ed25519", feature = "rsa" ))] -use crate::proto; +use crate::error::OtherVariantError; +use crate::error::{DecodingError, SigningError}; #[cfg(any( feature = "ecdsa", feature = "secp256k1", feature = "ed25519", feature = "rsa" ))] -use quick_protobuf::{BytesReader, Writer}; +use crate::proto; #[cfg(any( feature = "ecdsa", feature = "secp256k1", feature = "ed25519", feature = "rsa" ))] -use std::convert::TryFrom; - -#[cfg(feature = "ed25519")] -use crate::ed25519; +use quick_protobuf::{BytesReader, Writer}; #[cfg(all(feature = "rsa", not(target_arch = "wasm32")))] use crate::rsa; diff --git a/identity/src/lib.rs b/identity/src/lib.rs index c78e68d1652..4f4313e8f17 100644 --- a/identity/src/lib.rs +++ b/identity/src/lib.rs @@ -34,7 +34,7 @@ //! All key types have functions to enable conversion to/from their binary representations. #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] - +#![allow(unreachable_pub)] #[cfg(any( feature = "ecdsa", feature = "secp256k1", @@ -42,7 +42,6 @@ feature = "rsa" ))] mod proto { - #![allow(unreachable_pub)] include!("generated/mod.rs"); pub(crate) use self::keys_proto::*; } diff --git a/identity/src/peer_id.rs b/identity/src/peer_id.rs index 1d85fe66ffa..7b3f799f612 100644 --- a/identity/src/peer_id.rs +++ b/identity/src/peer_id.rs @@ -21,7 +21,7 @@ #[cfg(feature = "rand")] use rand::Rng; use sha2::Digest as _; -use std::{convert::TryFrom, fmt, str::FromStr}; +use std::{fmt, str::FromStr}; use thiserror::Error; /// Local type-alias for multihash. diff --git a/misc/metrics/src/identify.rs b/misc/metrics/src/identify.rs index b1d4e9f0c89..03ac3f9634e 100644 --- a/misc/metrics/src/identify.rs +++ b/misc/metrics/src/identify.rs @@ -22,7 +22,7 @@ use crate::protocol_stack; use libp2p_identity::PeerId; use libp2p_swarm::StreamProtocol; use prometheus_client::collector::Collector; -use prometheus_client::encoding::{DescriptorEncoder, EncodeLabelSet, EncodeMetric}; +use prometheus_client::encoding::{DescriptorEncoder, EncodeMetric}; use prometheus_client::metrics::counter::Counter; use prometheus_client::metrics::gauge::ConstGauge; use prometheus_client::metrics::MetricType; @@ -138,11 +138,6 @@ impl super::Recorder> for Metrics { } } -#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)] -struct AddressLabels { - protocols: String, -} - #[derive(Default, Debug, Clone)] struct Peers(Arc>>); diff --git a/misc/multistream-select/src/listener_select.rs b/misc/multistream-select/src/listener_select.rs index 21c507096e2..b4236310a1d 100644 --- a/misc/multistream-select/src/listener_select.rs +++ b/misc/multistream-select/src/listener_select.rs @@ -28,7 +28,6 @@ use futures::prelude::*; use smallvec::SmallVec; use std::{ convert::TryFrom as _, - iter::FromIterator, mem, pin::Pin, task::{Context, Poll}, diff --git a/misc/multistream-select/src/protocol.rs b/misc/multistream-select/src/protocol.rs index aef9f16c4cf..2189c50e697 100644 --- a/misc/multistream-select/src/protocol.rs +++ b/misc/multistream-select/src/protocol.rs @@ -31,7 +31,6 @@ use crate::Version; use bytes::{BufMut, Bytes, BytesMut}; use futures::{io::IoSlice, prelude::*, ready}; use std::{ - convert::TryFrom, error::Error, fmt, io, pin::Pin, diff --git a/misc/quick-protobuf-codec/src/lib.rs b/misc/quick-protobuf-codec/src/lib.rs index c50b1264af6..166ee82ff08 100644 --- a/misc/quick-protobuf-codec/src/lib.rs +++ b/misc/quick-protobuf-codec/src/lib.rs @@ -182,7 +182,6 @@ impl From for io::Error { #[cfg(test)] mod tests { use super::*; - use crate::proto; use asynchronous_codec::FramedRead; use futures::io::Cursor; use futures::{FutureExt, StreamExt}; diff --git a/misc/rw-stream-sink/src/lib.rs b/misc/rw-stream-sink/src/lib.rs index ee05196bfb4..f10e683ad33 100644 --- a/misc/rw-stream-sink/src/lib.rs +++ b/misc/rw-stream-sink/src/lib.rs @@ -117,7 +117,7 @@ where mod tests { use super::RwStreamSink; use async_std::task; - use futures::{channel::mpsc, prelude::*, stream}; + use futures::{channel::mpsc, prelude::*}; use std::{ pin::Pin, task::{Context, Poll}, diff --git a/muxers/mplex/src/lib.rs b/muxers/mplex/src/lib.rs index c67e0e3baec..17ca9ad46f6 100644 --- a/muxers/mplex/src/lib.rs +++ b/muxers/mplex/src/lib.rs @@ -30,7 +30,7 @@ pub use config::{MaxBufferBehaviour, MplexConfig}; use bytes::Bytes; use codec::LocalStreamId; -use futures::{future, prelude::*, ready}; +use futures::{prelude::*, ready}; use libp2p_core::muxing::{StreamMuxer, StreamMuxerEvent}; use libp2p_core::upgrade::{InboundConnectionUpgrade, OutboundConnectionUpgrade, UpgradeInfo}; use parking_lot::Mutex; diff --git a/muxers/yamux/src/lib.rs b/muxers/yamux/src/lib.rs index 2b5eb52a11e..bcfeb62fccf 100644 --- a/muxers/yamux/src/lib.rs +++ b/muxers/yamux/src/lib.rs @@ -23,7 +23,7 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use either::Either; -use futures::{future, prelude::*, ready}; +use futures::{prelude::*, ready}; use libp2p_core::muxing::{StreamMuxer, StreamMuxerEvent}; use libp2p_core::upgrade::{InboundConnectionUpgrade, OutboundConnectionUpgrade, UpgradeInfo}; use std::collections::VecDeque; diff --git a/protocols/autonat/src/protocol.rs b/protocols/autonat/src/protocol.rs index c1862058400..2ce538fddf4 100644 --- a/protocols/autonat/src/protocol.rs +++ b/protocols/autonat/src/protocol.rs @@ -27,7 +27,7 @@ use libp2p_core::Multiaddr; use libp2p_identity::PeerId; use libp2p_request_response::{self as request_response}; use libp2p_swarm::StreamProtocol; -use std::{convert::TryFrom, io}; +use std::io; /// The protocol name used for negotiating with multistream-select. pub const DEFAULT_PROTOCOL_NAME: StreamProtocol = StreamProtocol::new("/libp2p/autonat/1.0.0"); @@ -121,12 +121,8 @@ impl DialRequest { } let peer_id_result = msg.dial.and_then(|dial| { - dial.peer.and_then(|peer_info| { - let Some(peer_id) = peer_info.id else { - return None; - }; - Some((peer_id, peer_info.addrs)) - }) + dial.peer + .and_then(|peer_info| peer_info.id.map(|peer_id| (peer_id, peer_info.addrs))) }); let (peer_id, addrs) = peer_id_result diff --git a/protocols/dcutr/src/behaviour.rs b/protocols/dcutr/src/behaviour.rs index 3742eb512f5..4409b5f6a64 100644 --- a/protocols/dcutr/src/behaviour.rs +++ b/protocols/dcutr/src/behaviour.rs @@ -191,9 +191,9 @@ impl NetworkBehaviour for Behaviour { .insert(connection_id); assert!( - self.direct_to_relayed_connections - .get(&connection_id) - .is_none(), + !self + .direct_to_relayed_connections + .contains_key(&connection_id), "state mismatch" ); diff --git a/protocols/dcutr/src/protocol/inbound.rs b/protocols/dcutr/src/protocol/inbound.rs index b8f90daf3a1..005d8394f5e 100644 --- a/protocols/dcutr/src/protocol/inbound.rs +++ b/protocols/dcutr/src/protocol/inbound.rs @@ -23,7 +23,6 @@ use asynchronous_codec::Framed; use futures::prelude::*; use libp2p_core::{multiaddr::Protocol, Multiaddr}; use libp2p_swarm::Stream; -use std::convert::TryFrom; use std::io; use thiserror::Error; diff --git a/protocols/dcutr/src/protocol/outbound.rs b/protocols/dcutr/src/protocol/outbound.rs index d9cb60a01f6..dc46442fae5 100644 --- a/protocols/dcutr/src/protocol/outbound.rs +++ b/protocols/dcutr/src/protocol/outbound.rs @@ -26,7 +26,6 @@ use futures_timer::Delay; use instant::Instant; use libp2p_core::{multiaddr::Protocol, Multiaddr}; use libp2p_swarm::Stream; -use std::convert::TryFrom; use std::io; use thiserror::Error; diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index 24a32de4cc7..f2515c3c564 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -528,7 +528,7 @@ where return Err(SubscriptionError::NotAllowed); } - if self.mesh.get(&topic_hash).is_some() { + if self.mesh.contains_key(&topic_hash) { tracing::debug!(%topic, "Topic is already in the mesh"); return Ok(false); } @@ -554,7 +554,7 @@ where tracing::debug!(%topic, "Unsubscribing from topic"); let topic_hash = topic.hash(); - if self.mesh.get(&topic_hash).is_none() { + if !self.mesh.contains_key(&topic_hash) { tracing::debug!(topic=%topic_hash, "Already unsubscribed from topic"); // we are not subscribed return Ok(false); diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index 2bf1c90c5c8..1a63b52541f 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -22,17 +22,12 @@ use super::*; use crate::subscription_filter::WhitelistSubscriptionFilter; -use crate::transform::{DataTransform, IdentityTransform}; -use crate::ValidationError; -use crate::{ - config::Config, config::ConfigBuilder, types::Rpc, IdentTopic as Topic, TopicScoreParams, -}; +use crate::{config::ConfigBuilder, types::Rpc, IdentTopic as Topic}; use async_std::net::Ipv4Addr; use byteorder::{BigEndian, ByteOrder}; -use libp2p_core::{ConnectedPoint, Endpoint}; +use libp2p_core::ConnectedPoint; use rand::Rng; use std::thread::sleep; -use std::time::Duration; #[derive(Default, Debug)] struct InjectNodes @@ -396,7 +391,7 @@ fn test_subscribe() { .create_network(); assert!( - gs.mesh.get(&topic_hashes[0]).is_some(), + gs.mesh.contains_key(&topic_hashes[0]), "Subscribe should add a new entry to the mesh[topic] hashmap" ); @@ -442,11 +437,11 @@ fn test_unsubscribe() { for topic_hash in &topic_hashes { assert!( - gs.topic_peers.get(topic_hash).is_some(), + gs.topic_peers.contains_key(topic_hash), "Topic_peers contain a topic entry" ); assert!( - gs.mesh.get(topic_hash).is_some(), + gs.mesh.contains_key(topic_hash), "mesh should contain a topic entry" ); } @@ -479,7 +474,7 @@ fn test_unsubscribe() { // check we clean up internal structures for topic_hash in &topic_hashes { assert!( - gs.mesh.get(topic_hash).is_none(), + !gs.mesh.contains_key(topic_hash), "All topics should have been removed from the mesh" ); } @@ -624,7 +619,7 @@ fn test_publish_without_flood_publishing() { .create_network(); assert!( - gs.mesh.get(&topic_hashes[0]).is_some(), + gs.mesh.contains_key(&topic_hashes[0]), "Subscribe should add a new entry to the mesh[topic] hashmap" ); @@ -703,7 +698,7 @@ fn test_fanout() { .create_network(); assert!( - gs.mesh.get(&topic_hashes[0]).is_some(), + gs.mesh.contains_key(&topic_hashes[0]), "Subscribe should add a new entry to the mesh[topic] hashmap" ); // Unsubscribe from topic @@ -873,7 +868,7 @@ fn test_handle_received_subscriptions() { ); assert!( - gs.peer_topics.get(&unknown_peer).is_none(), + !gs.peer_topics.contains_key(&unknown_peer), "Unknown peer should not have been added" ); @@ -1272,7 +1267,7 @@ fn test_handle_graft_multiple_topics() { } assert!( - gs.mesh.get(&topic_hashes[2]).is_none(), + !gs.mesh.contains_key(&topic_hashes[2]), "Expected the second topic to not be in the mesh" ); } @@ -5100,7 +5095,7 @@ fn test_graft_without_subscribe() { .create_network(); assert!( - gs.mesh.get(&topic_hashes[0]).is_some(), + gs.mesh.contains_key(&topic_hashes[0]), "Subscribe should add a new entry to the mesh[topic] hashmap" ); diff --git a/protocols/gossipsub/src/config.rs b/protocols/gossipsub/src/config.rs index 7e79912cc4a..cd2326279eb 100644 --- a/protocols/gossipsub/src/config.rs +++ b/protocols/gossipsub/src/config.rs @@ -860,10 +860,8 @@ impl std::fmt::Debug for Config { mod test { use super::*; use crate::topic::IdentityHash; - use crate::types::PeerKind; use crate::Topic; use libp2p_core::UpgradeInfo; - use libp2p_swarm::StreamProtocol; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; diff --git a/protocols/gossipsub/src/mcache.rs b/protocols/gossipsub/src/mcache.rs index ef4a93bc936..aa65e3b7f1d 100644 --- a/protocols/gossipsub/src/mcache.rs +++ b/protocols/gossipsub/src/mcache.rs @@ -221,9 +221,7 @@ impl MessageCache { #[cfg(test)] mod tests { use super::*; - use crate::types::RawMessage; - use crate::{IdentTopic as Topic, TopicHash}; - use libp2p_identity::PeerId; + use crate::IdentTopic as Topic; fn gen_testm(x: u64, topic: TopicHash) -> (MessageId, RawMessage) { let default_id = |message: &RawMessage| { diff --git a/protocols/gossipsub/src/peer_score.rs b/protocols/gossipsub/src/peer_score.rs index b1ea9bfae95..386cc85bd3c 100644 --- a/protocols/gossipsub/src/peer_score.rs +++ b/protocols/gossipsub/src/peer_score.rs @@ -99,7 +99,7 @@ impl PeerStats { topic_hash: TopicHash, params: &PeerScoreParams, ) -> Option<&mut TopicStats> { - if params.topics.get(&topic_hash).is_some() { + if params.topics.contains_key(&topic_hash) { Some(self.topics.entry(topic_hash).or_default()) } else { self.topics.get_mut(&topic_hash) @@ -307,7 +307,7 @@ impl PeerScore { // P6: IP collocation factor for ip in peer_stats.known_ips.iter() { - if self.params.ip_colocation_factor_whitelist.get(ip).is_some() { + if self.params.ip_colocation_factor_whitelist.contains(ip) { continue; } @@ -680,7 +680,7 @@ impl PeerScore { ) { let record = self.deliveries.entry(msg_id.clone()).or_default(); - if record.peers.get(from).is_some() { + if record.peers.contains(from) { // we have already seen this duplicate! return; } diff --git a/protocols/gossipsub/src/protocol.rs b/protocols/gossipsub/src/protocol.rs index e9600a4d8d8..01a38562c02 100644 --- a/protocols/gossipsub/src/protocol.rs +++ b/protocols/gossipsub/src/protocol.rs @@ -29,7 +29,6 @@ use crate::ValidationError; use asynchronous_codec::{Decoder, Encoder, Framed}; use byteorder::{BigEndian, ByteOrder}; use bytes::BytesMut; -use futures::future; use futures::prelude::*; use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use libp2p_identity::{PeerId, PublicKey}; diff --git a/protocols/gossipsub/src/subscription_filter.rs b/protocols/gossipsub/src/subscription_filter.rs index 09c323d7904..02bb9b4eab6 100644 --- a/protocols/gossipsub/src/subscription_filter.rs +++ b/protocols/gossipsub/src/subscription_filter.rs @@ -212,7 +212,6 @@ impl TopicSubscriptionFilter for RegexSubscriptionFilter { mod test { use super::*; use crate::types::SubscriptionAction::*; - use std::iter::FromIterator; #[test] fn test_filter_incoming_allow_all_with_duplicates() { diff --git a/protocols/identify/src/protocol.rs b/protocols/identify/src/protocol.rs index c6b22b00c0a..f4dfd544dd1 100644 --- a/protocols/identify/src/protocol.rs +++ b/protocols/identify/src/protocol.rs @@ -25,7 +25,6 @@ use libp2p_core::{multiaddr, Multiaddr}; use libp2p_identity as identity; use libp2p_identity::PublicKey; use libp2p_swarm::StreamProtocol; -use std::convert::TryFrom; use std::io; use thiserror::Error; diff --git a/protocols/kad/src/behaviour/test.rs b/protocols/kad/src/behaviour/test.rs index b879084c54f..7005f39e5e6 100644 --- a/protocols/kad/src/behaviour/test.rs +++ b/protocols/kad/src/behaviour/test.rs @@ -22,32 +22,22 @@ use super::*; -use crate::kbucket::Distance; use crate::record::{store::MemoryStore, Key}; -use crate::{K_VALUE, PROTOCOL_NAME, SHA_256_MH}; +use crate::{PROTOCOL_NAME, SHA_256_MH}; use futures::{executor::block_on, future::poll_fn, prelude::*}; use futures_timer::Delay; use libp2p_core::{ - connection::ConnectedPoint, - multiaddr::{multiaddr, Multiaddr, Protocol}, + multiaddr::{multiaddr, Protocol}, multihash::Multihash, transport::MemoryTransport, - upgrade, Endpoint, Transport, + upgrade, Transport, }; use libp2p_identity as identity; -use libp2p_identity::PeerId; use libp2p_noise as noise; -use libp2p_swarm::behaviour::ConnectionEstablished; -use libp2p_swarm::{self as swarm, ConnectionId, Swarm, SwarmEvent}; +use libp2p_swarm::{self as swarm, Swarm, SwarmEvent}; use libp2p_yamux as yamux; use quickcheck::*; use rand::{random, rngs::StdRng, thread_rng, Rng, SeedableRng}; -use std::{ - collections::{HashMap, HashSet}, - num::NonZeroUsize, - time::Duration, - u64, -}; type TestSwarm = Swarm>; diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index a0d272c31f1..cf5591c5cf6 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -75,7 +75,7 @@ mod key; pub use bucket::NodeStatus; pub use entry::*; -use arrayvec::{self, ArrayVec}; +use arrayvec::ArrayVec; use bucket::KBucket; use std::collections::VecDeque; use std::time::{Duration, Instant}; diff --git a/protocols/kad/src/kbucket/bucket.rs b/protocols/kad/src/kbucket/bucket.rs index d70161919e1..5e65bc15a37 100644 --- a/protocols/kad/src/kbucket/bucket.rs +++ b/protocols/kad/src/kbucket/bucket.rs @@ -431,7 +431,6 @@ mod tests { use super::*; use libp2p_identity::PeerId; use quickcheck::*; - use std::collections::VecDeque; impl Arbitrary for KBucket, ()> { fn arbitrary(g: &mut Gen) -> KBucket, ()> { diff --git a/protocols/kad/src/kbucket/entry.rs b/protocols/kad/src/kbucket/entry.rs index 02c90fdfcc7..d89853b1761 100644 --- a/protocols/kad/src/kbucket/entry.rs +++ b/protocols/kad/src/kbucket/entry.rs @@ -21,7 +21,7 @@ //! The `Entry` API for quering and modifying the entries of a `KBucketsTable` //! representing the nodes participating in the Kademlia DHT. -pub(crate) use super::bucket::{AppliedPending, InsertResult, Node, NodeStatus, K_VALUE}; +pub(crate) use super::bucket::{AppliedPending, InsertResult, Node, K_VALUE}; pub use super::key::*; use super::*; diff --git a/protocols/kad/src/protocol.rs b/protocols/kad/src/protocol.rs index 5abe2089852..9803af00579 100644 --- a/protocols/kad/src/protocol.rs +++ b/protocols/kad/src/protocol.rs @@ -37,7 +37,7 @@ use libp2p_core::Multiaddr; use libp2p_identity::PeerId; use libp2p_swarm::StreamProtocol; use std::marker::PhantomData; -use std::{convert::TryFrom, time::Duration}; +use std::time::Duration; use std::{io, iter}; use tracing::debug; diff --git a/protocols/kad/src/query/peers/closest.rs b/protocols/kad/src/query/peers/closest.rs index dc913f1bbca..537da6a9d7d 100644 --- a/protocols/kad/src/query/peers/closest.rs +++ b/protocols/kad/src/query/peers/closest.rs @@ -23,9 +23,8 @@ use super::*; use crate::kbucket::{Distance, Key, KeyBytes}; use crate::{ALPHA_VALUE, K_VALUE}; use instant::Instant; -use libp2p_identity::PeerId; use std::collections::btree_map::{BTreeMap, Entry}; -use std::{iter::FromIterator, num::NonZeroUsize, time::Duration}; +use std::{num::NonZeroUsize, time::Duration}; pub(crate) mod disjoint; /// A peer iterator for a dynamically changing list of peers, sorted by increasing @@ -477,10 +476,9 @@ mod tests { use super::*; use crate::SHA_256_MH; use libp2p_core::multihash::Multihash; - use libp2p_identity::PeerId; use quickcheck::*; use rand::{rngs::StdRng, Rng, SeedableRng}; - use std::{iter, time::Duration}; + use std::iter; fn random_peers(n: usize, g: &mut R) -> Vec { (0..n) diff --git a/protocols/kad/src/query/peers/closest/disjoint.rs b/protocols/kad/src/query/peers/closest/disjoint.rs index 68721f93d7c..e8309a2deda 100644 --- a/protocols/kad/src/query/peers/closest/disjoint.rs +++ b/protocols/kad/src/query/peers/closest/disjoint.rs @@ -19,9 +19,6 @@ // DEALINGS IN THE SOFTWARE. use super::*; -use crate::kbucket::{Key, KeyBytes}; -use instant::Instant; -use libp2p_identity::PeerId; use std::{ collections::HashMap, iter::{Cycle, Map, Peekable}, @@ -438,7 +435,7 @@ impl>> Iterator for ResultIter { mod tests { use super::*; - use crate::{K_VALUE, SHA_256_MH}; + use crate::SHA_256_MH; use libp2p_core::multihash::Multihash; use quickcheck::*; use std::collections::HashSet; @@ -602,20 +599,6 @@ mod tests { } } - #[derive(Debug, Clone)] - struct PeerVec(Vec>); - - impl Arbitrary for PeerVec { - fn arbitrary(g: &mut Gen) -> Self { - PeerVec( - (0..g.gen_range(1..60u8)) - .map(|_| ArbitraryPeerId::arbitrary(g).0) - .map(Key::from) - .collect(), - ) - } - } - #[test] fn s_kademlia_disjoint_paths() { let now = Instant::now(); diff --git a/protocols/kad/src/query/peers/fixed.rs b/protocols/kad/src/query/peers/fixed.rs index 50a969380a3..b34f7516801 100644 --- a/protocols/kad/src/query/peers/fixed.rs +++ b/protocols/kad/src/query/peers/fixed.rs @@ -21,7 +21,6 @@ use super::*; use fnv::FnvHashMap; -use libp2p_identity::PeerId; use std::{collections::hash_map::Entry, num::NonZeroUsize, vec}; /// A peer iterator for a fixed set of peers. diff --git a/protocols/kad/src/record/store/memory.rs b/protocols/kad/src/record/store/memory.rs index edeae188ac6..86c136ebeda 100644 --- a/protocols/kad/src/record/store/memory.rs +++ b/protocols/kad/src/record/store/memory.rs @@ -21,9 +21,7 @@ use super::*; use crate::kbucket; -use libp2p_identity::PeerId; use smallvec::SmallVec; -use std::borrow::Cow; use std::collections::{hash_map, hash_set, HashMap, HashSet}; use std::iter; @@ -217,7 +215,6 @@ impl RecordStore for MemoryStore { mod tests { use super::*; use crate::SHA_256_MH; - use libp2p_core::multihash::Multihash; use quickcheck::*; use rand::Rng; diff --git a/protocols/mdns/src/behaviour/iface/dns.rs b/protocols/mdns/src/behaviour/iface/dns.rs index 6cc5550dbe5..41ce9efa714 100644 --- a/protocols/mdns/src/behaviour/iface/dns.rs +++ b/protocols/mdns/src/behaviour/iface/dns.rs @@ -397,7 +397,6 @@ mod tests { use super::*; use hickory_proto::op::Message; use libp2p_identity as identity; - use std::time::Duration; #[test] fn build_query_correct() { diff --git a/protocols/mdns/src/behaviour/socket.rs b/protocols/mdns/src/behaviour/socket.rs index fa9e0fbaf1e..ebaad17e45f 100644 --- a/protocols/mdns/src/behaviour/socket.rs +++ b/protocols/mdns/src/behaviour/socket.rs @@ -20,7 +20,6 @@ use std::{ io::Error, - marker::Unpin, net::{SocketAddr, UdpSocket}, task::{Context, Poll}, }; diff --git a/protocols/mdns/src/behaviour/timer.rs b/protocols/mdns/src/behaviour/timer.rs index 29622be9a38..4f6ceec306d 100644 --- a/protocols/mdns/src/behaviour/timer.rs +++ b/protocols/mdns/src/behaviour/timer.rs @@ -18,10 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use std::{ - marker::Unpin, - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; /// Simple wrapper for the different type of timers #[derive(Debug)] diff --git a/protocols/ping/src/protocol.rs b/protocols/ping/src/protocol.rs index 28549e1c198..fe84cb4ea59 100644 --- a/protocols/ping/src/protocol.rs +++ b/protocols/ping/src/protocol.rs @@ -89,8 +89,6 @@ mod tests { multiaddr::multiaddr, transport::{memory::MemoryTransport, ListenerId, Transport}, }; - use rand::{thread_rng, Rng}; - use std::time::Duration; #[test] fn ping_pong() { diff --git a/protocols/relay/src/behaviour/rate_limiter.rs b/protocols/relay/src/behaviour/rate_limiter.rs index 9c4f67d04a8..73c164c121c 100644 --- a/protocols/relay/src/behaviour/rate_limiter.rs +++ b/protocols/relay/src/behaviour/rate_limiter.rs @@ -22,7 +22,6 @@ use instant::Instant; use libp2p_core::multiaddr::{Multiaddr, Protocol}; use libp2p_identity::PeerId; use std::collections::{HashMap, VecDeque}; -use std::convert::TryInto; use std::hash::Hash; use std::net::IpAddr; use std::num::NonZeroU32; @@ -173,7 +172,6 @@ impl GenericRateLimiter { mod tests { use super::*; use quickcheck::{QuickCheck, TestResult}; - use std::num::NonZeroU32; #[test] fn first() { diff --git a/protocols/relay/src/copy_future.rs b/protocols/relay/src/copy_future.rs index 755344cd698..91415065d2c 100644 --- a/protocols/relay/src/copy_future.rs +++ b/protocols/relay/src/copy_future.rs @@ -30,7 +30,6 @@ use futures::io::{AsyncBufRead, BufReader}; use futures::io::{AsyncRead, AsyncWrite}; use futures::ready; use futures_timer::Delay; -use std::convert::TryInto; use std::io; use std::pin::Pin; use std::task::{Context, Poll}; @@ -164,12 +163,9 @@ fn forward_data( mod tests { use super::*; use futures::executor::block_on; - use futures::io::{AsyncRead, AsyncWrite, BufReader, BufWriter}; + use futures::io::BufWriter; use quickcheck::QuickCheck; use std::io::ErrorKind; - use std::pin::Pin; - use std::task::{Context, Poll}; - use std::time::Duration; #[test] fn quickcheck() { diff --git a/protocols/rendezvous/src/codec.rs b/protocols/rendezvous/src/codec.rs index 41432a91d8c..cad3688e00b 100644 --- a/protocols/rendezvous/src/codec.rs +++ b/protocols/rendezvous/src/codec.rs @@ -27,7 +27,6 @@ use libp2p_core::{peer_record, signed_envelope, PeerRecord, SignedEnvelope}; use libp2p_swarm::StreamProtocol; use quick_protobuf_codec::Codec as ProtobufCodec; use rand::RngCore; -use std::convert::{TryFrom, TryInto}; use std::{fmt, io}; pub type Ttl = u64; @@ -642,7 +641,6 @@ mod proto { #[cfg(test)] mod tests { use super::*; - use crate::Namespace; #[test] fn cookie_wire_encoding_roundtrip() { diff --git a/protocols/rendezvous/src/server.rs b/protocols/rendezvous/src/server.rs index 667c71e20e3..0ed1b6523d1 100644 --- a/protocols/rendezvous/src/server.rs +++ b/protocols/rendezvous/src/server.rs @@ -34,7 +34,6 @@ use libp2p_swarm::{ }; use std::collections::{HashMap, HashSet}; use std::iter; -use std::iter::FromIterator; use std::task::{ready, Context, Poll}; use std::time::Duration; @@ -529,7 +528,6 @@ pub struct CookieNamespaceMismatch; #[cfg(test)] mod tests { use instant::SystemTime; - use std::option::Option::None; use libp2p_core::PeerRecord; use libp2p_identity as identity; diff --git a/protocols/rendezvous/tests/rendezvous.rs b/protocols/rendezvous/tests/rendezvous.rs index c2de88fd615..d9200780ece 100644 --- a/protocols/rendezvous/tests/rendezvous.rs +++ b/protocols/rendezvous/tests/rendezvous.rs @@ -27,7 +27,6 @@ use libp2p_rendezvous as rendezvous; use libp2p_rendezvous::client::RegisterError; use libp2p_swarm::{DialError, Swarm, SwarmEvent}; use libp2p_swarm_test::SwarmExt; -use std::convert::TryInto; use std::time::Duration; use tracing_subscriber::EnvFilter; diff --git a/protocols/request-response/src/cbor.rs b/protocols/request-response/src/cbor.rs index f371f6149dc..44d82be2630 100644 --- a/protocols/request-response/src/cbor.rs +++ b/protocols/request-response/src/cbor.rs @@ -47,7 +47,6 @@ mod codec { use async_trait::async_trait; use cbor4ii::core::error::DecodeError; use futures::prelude::*; - use futures::{AsyncRead, AsyncWrite}; use libp2p_swarm::StreamProtocol; use serde::{de::DeserializeOwned, Serialize}; use std::{collections::TryReserveError, convert::Infallible, io, marker::PhantomData}; diff --git a/protocols/request-response/src/json.rs b/protocols/request-response/src/json.rs index 0b3d634573b..85e78e7ddda 100644 --- a/protocols/request-response/src/json.rs +++ b/protocols/request-response/src/json.rs @@ -45,7 +45,6 @@ pub type Behaviour = crate::Behaviour>; mod codec { use async_trait::async_trait; use futures::prelude::*; - use futures::{AsyncRead, AsyncWrite}; use libp2p_swarm::StreamProtocol; use serde::{de::DeserializeOwned, Serialize}; use std::{io, marker::PhantomData}; diff --git a/protocols/request-response/tests/ping.rs b/protocols/request-response/tests/ping.rs index b9e7878a78b..827afae249c 100644 --- a/protocols/request-response/tests/ping.rs +++ b/protocols/request-response/tests/ping.rs @@ -26,7 +26,7 @@ use libp2p_request_response as request_response; use libp2p_request_response::ProtocolSupport; use libp2p_swarm::{StreamProtocol, Swarm, SwarmEvent}; use libp2p_swarm_test::SwarmExt; -use rand::{self, Rng}; +use rand::Rng; use serde::{Deserialize, Serialize}; use std::{io, iter}; use tracing_subscriber::EnvFilter; diff --git a/swarm/src/behaviour/peer_addresses.rs b/swarm/src/behaviour/peer_addresses.rs index a011867dcdf..1eeead56ca1 100644 --- a/swarm/src/behaviour/peer_addresses.rs +++ b/swarm/src/behaviour/peer_addresses.rs @@ -101,7 +101,7 @@ mod tests { use super::*; use std::io; - use crate::{ConnectionId, DialError}; + use crate::ConnectionId; use libp2p_core::{ multiaddr::Protocol, transport::{memory::MemoryTransportError, TransportError}, diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index 15c49bb7bd5..a6e8e1c6851 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -373,7 +373,7 @@ where match shutdown { Shutdown::None => {} Shutdown::Asap => return Poll::Ready(Err(ConnectionError::KeepAliveTimeout)), - Shutdown::Later(delay, _) => match Future::poll(Pin::new(delay), cx) { + Shutdown::Later(delay) => match Future::poll(Pin::new(delay), cx) { Poll::Ready(_) => { return Poll::Ready(Err(ConnectionError::KeepAliveTimeout)) } @@ -470,15 +470,12 @@ fn compute_new_shutdown( ) -> Option { match (current_shutdown, handler_keep_alive) { (_, false) if idle_timeout == Duration::ZERO => Some(Shutdown::Asap), - (Shutdown::Later(_, _), false) => None, // Do nothing, i.e. let the shutdown timer continue to tick. + (Shutdown::Later(_), false) => None, // Do nothing, i.e. let the shutdown timer continue to tick. (_, false) => { let now = Instant::now(); let safe_keep_alive = checked_add_fraction(now, idle_timeout); - Some(Shutdown::Later( - Delay::new(safe_keep_alive), - now + safe_keep_alive, - )) + Some(Shutdown::Later(Delay::new(safe_keep_alive))) } (_, true) => Some(Shutdown::None), } @@ -734,7 +731,7 @@ enum Shutdown { /// A shut down is planned as soon as possible. Asap, /// A shut down is planned for when a `Delay` has elapsed. - Later(Delay, Instant), + Later(Delay), } #[cfg(test)] @@ -947,11 +944,10 @@ mod tests { let shutdown = match self.0 { Shutdown::None => Shutdown::None, Shutdown::Asap => Shutdown::Asap, - Shutdown::Later(_, instant) => Shutdown::Later( + Shutdown::Later(_) => Shutdown::Later( // compute_new_shutdown does not touch the delay. Delay does not // implement Clone. Thus use a placeholder delay. Delay::new(Duration::from_secs(1)), - instant, ), }; @@ -964,12 +960,7 @@ mod tests { let shutdown = match g.gen_range(1u8..4) { 1 => Shutdown::None, 2 => Shutdown::Asap, - 3 => Shutdown::Later( - Delay::new(Duration::from_secs(u32::arbitrary(g) as u64)), - Instant::now() - .checked_add(Duration::arbitrary(g)) - .unwrap_or(Instant::now()), - ), + 3 => Shutdown::Later(Delay::new(Duration::from_secs(u32::arbitrary(g) as u64))), _ => unreachable!(), }; @@ -1000,7 +991,9 @@ mod tests { self: Pin<&mut Self>, _: &mut Context<'_>, ) -> Poll> { - Poll::Ready(Ok(PendingSubstream(Arc::downgrade(&self.counter)))) + Poll::Ready(Ok(PendingSubstream { + _weak: Arc::downgrade(&self.counter), + })) } fn poll_outbound( @@ -1055,7 +1048,9 @@ mod tests { } } - struct PendingSubstream(Weak<()>); + struct PendingSubstream { + _weak: Weak<()>, + } impl AsyncRead for PendingSubstream { fn poll_read( diff --git a/swarm/src/connection/pool.rs b/swarm/src/connection/pool.rs index 9bcd1b446d3..f876c39f12c 100644 --- a/swarm/src/connection/pool.rs +++ b/swarm/src/connection/pool.rs @@ -42,7 +42,7 @@ use libp2p_core::connection::Endpoint; use libp2p_core::muxing::{StreamMuxerBox, StreamMuxerExt}; use std::task::Waker; use std::{ - collections::{hash_map, HashMap}, + collections::HashMap, fmt, num::{NonZeroU8, NonZeroUsize}, pin::Pin, @@ -1029,28 +1029,3 @@ impl PoolConfig { self } } - -trait EntryExt<'a, K, V> { - fn expect_occupied(self, msg: &'static str) -> hash_map::OccupiedEntry<'a, K, V>; -} - -impl<'a, K: 'a, V: 'a> EntryExt<'a, K, V> for hash_map::Entry<'a, K, V> { - fn expect_occupied(self, msg: &'static str) -> hash_map::OccupiedEntry<'a, K, V> { - match self { - hash_map::Entry::Occupied(entry) => entry, - hash_map::Entry::Vacant(_) => panic!("{}", msg), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use futures::future::Future; - - struct Dummy; - - impl Executor for Dummy { - fn exec(&self, _: Pin + Send>>) {} - } -} diff --git a/swarm/src/handler/multi.rs b/swarm/src/handler/multi.rs index 96a77626c01..5efcde5c2bb 100644 --- a/swarm/src/handler/multi.rs +++ b/swarm/src/handler/multi.rs @@ -35,7 +35,7 @@ use std::{ error, fmt::{self, Debug}, hash::Hash, - iter::{self, FromIterator}, + iter, task::{Context, Poll}, time::Duration, }; diff --git a/swarm/src/handler/one_shot.rs b/swarm/src/handler/one_shot.rs index b1fc41e9098..fc1074b31e4 100644 --- a/swarm/src/handler/one_shot.rs +++ b/swarm/src/handler/one_shot.rs @@ -232,6 +232,6 @@ mod tests { } })); - assert!(matches!(handler.connection_keep_alive(), false)); + assert!(!handler.connection_keep_alive()); } } diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 2f02e43348d..dac380855aa 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -146,7 +146,6 @@ use std::collections::{HashMap, HashSet, VecDeque}; use std::num::{NonZeroU32, NonZeroU8, NonZeroUsize}; use std::time::Duration; use std::{ - convert::TryFrom, error, fmt, io, pin::Pin, task::{Context, Poll}, @@ -1771,14 +1770,10 @@ impl NetworkInfo { #[cfg(test)] mod tests { use super::*; - use crate::dummy; use crate::test::{CallTraceBehaviour, MockBehaviour}; - use futures::future; use libp2p_core::multiaddr::multiaddr; use libp2p_core::transport::memory::MemoryTransportError; - use libp2p_core::transport::TransportEvent; - use libp2p_core::Endpoint; - use libp2p_core::{multiaddr, transport, upgrade}; + use libp2p_core::{multiaddr, upgrade}; use libp2p_identity as identity; use libp2p_plaintext as plaintext; use libp2p_yamux as yamux; @@ -1832,7 +1827,7 @@ mod tests { && swarm2.is_connected(swarm1.local_peer_id()) } - fn swarms_disconnected( + fn swarms_disconnected( swarm1: &Swarm>, swarm2: &Swarm>, ) -> bool diff --git a/swarm/tests/swarm_derive.rs b/swarm/tests/swarm_derive.rs index 707abb03d6e..12f0d0a5ba8 100644 --- a/swarm/tests/swarm_derive.rs +++ b/swarm/tests/swarm_derive.rs @@ -133,19 +133,19 @@ fn custom_event() { #[allow(clippy::large_enum_variant)] enum MyEvent { - Ping(ping::Event), - Identify(identify::Event), + Ping, + Identify, } impl From for MyEvent { - fn from(event: ping::Event) -> Self { - MyEvent::Ping(event) + fn from(_event: ping::Event) -> Self { + MyEvent::Ping } } impl From for MyEvent { - fn from(event: identify::Event) -> Self { - MyEvent::Identify(event) + fn from(_event: identify::Event) -> Self { + MyEvent::Identify } } @@ -167,19 +167,19 @@ fn custom_event_mismatching_field_names() { #[allow(clippy::large_enum_variant)] enum MyEvent { - Ping(ping::Event), - Identify(identify::Event), + Ping, + Identify, } impl From for MyEvent { - fn from(event: ping::Event) -> Self { - MyEvent::Ping(event) + fn from(_event: ping::Event) -> Self { + MyEvent::Ping } } impl From for MyEvent { - fn from(event: identify::Event) -> Self { - MyEvent::Identify(event) + fn from(_event: identify::Event) -> Self { + MyEvent::Identify } } @@ -252,19 +252,19 @@ fn nested_derives_with_import() { fn custom_event_emit_event_through_poll() { #[allow(clippy::large_enum_variant)] enum BehaviourOutEvent { - Ping(ping::Event), - Identify(identify::Event), + Ping, + Identify, } impl From for BehaviourOutEvent { - fn from(event: ping::Event) -> Self { - BehaviourOutEvent::Ping(event) + fn from(_event: ping::Event) -> Self { + BehaviourOutEvent::Ping } } impl From for BehaviourOutEvent { - fn from(event: identify::Event) -> Self { - BehaviourOutEvent::Identify(event) + fn from(_event: identify::Event) -> Self { + BehaviourOutEvent::Identify } } @@ -293,8 +293,8 @@ fn custom_event_emit_event_through_poll() { // check that the event is bubbled up all the way to swarm loop { match _swarm.select_next_some().await { - SwarmEvent::Behaviour(BehaviourOutEvent::Ping(_)) => break, - SwarmEvent::Behaviour(BehaviourOutEvent::Identify(_)) => break, + SwarmEvent::Behaviour(BehaviourOutEvent::Ping) => break, + SwarmEvent::Behaviour(BehaviourOutEvent::Identify) => break, _ => {} } } @@ -460,21 +460,20 @@ fn with_generics_constrained() { fn custom_event_with_either() { use either::Either; - #[allow(clippy::large_enum_variant)] enum BehaviourOutEvent { - Kad(libp2p_kad::Event), - PingOrIdentify(Either), + Kad, + PingOrIdentify, } impl From for BehaviourOutEvent { - fn from(event: libp2p_kad::Event) -> Self { - BehaviourOutEvent::Kad(event) + fn from(_event: libp2p_kad::Event) -> Self { + BehaviourOutEvent::Kad } } impl From> for BehaviourOutEvent { - fn from(event: Either) -> Self { - BehaviourOutEvent::PingOrIdentify(event) + fn from(_event: Either) -> Self { + BehaviourOutEvent::PingOrIdentify } } diff --git a/transports/dns/src/lib.rs b/transports/dns/src/lib.rs index be847e568ed..a0fdaf53bdf 100644 --- a/transports/dns/src/lib.rs +++ b/transports/dns/src/lib.rs @@ -157,7 +157,6 @@ use smallvec::SmallVec; use std::io; use std::net::{Ipv4Addr, Ipv6Addr}; use std::{ - convert::TryFrom, error, fmt, iter, ops::DerefMut, pin::Pin, @@ -628,12 +627,7 @@ where #[cfg(all(test, any(feature = "tokio", feature = "async-std")))] mod tests { use super::*; - use futures::future::BoxFuture; - use libp2p_core::{ - multiaddr::{Multiaddr, Protocol}, - transport::{TransportError, TransportEvent}, - Transport, - }; + use libp2p_core::Transport; use libp2p_identity::PeerId; #[test] diff --git a/transports/noise/src/io/handshake.rs b/transports/noise/src/io/handshake.rs index 7cc0f859e6e..5c1fa806b6d 100644 --- a/transports/noise/src/io/handshake.rs +++ b/transports/noise/src/io/handshake.rs @@ -248,7 +248,7 @@ where ..Default::default() }; - pb.identity_sig = state.identity.signature.clone(); + pb.identity_sig.clone_from(&state.identity.signature); // If this is the responder then send WebTransport certhashes to initiator, if any. if state.io.codec().is_responder() { diff --git a/transports/noise/src/protocol.rs b/transports/noise/src/protocol.rs index e37c55c7f10..29d0c81e2e4 100644 --- a/transports/noise/src/protocol.rs +++ b/transports/noise/src/protocol.rs @@ -292,8 +292,6 @@ impl snow::types::Dh for Keypair { #[cfg(test)] mod tests { use super::*; - use crate::protocol::PARAMS_XX; - use once_cell::sync::Lazy; #[test] fn handshake_hashes_disagree_if_prologue_differs() { diff --git a/transports/noise/tests/smoke.rs b/transports/noise/tests/smoke.rs index 7100e7c7a8d..62b5d41d6b9 100644 --- a/transports/noise/tests/smoke.rs +++ b/transports/noise/tests/smoke.rs @@ -25,7 +25,7 @@ use libp2p_core::upgrade::{InboundConnectionUpgrade, OutboundConnectionUpgrade}; use libp2p_identity as identity; use libp2p_noise as noise; use quickcheck::*; -use std::{convert::TryInto, io}; +use std::io; use tracing_subscriber::EnvFilter; #[allow(dead_code)] diff --git a/transports/quic/src/transport.rs b/transports/quic/src/transport.rs index aea3c91093f..c33931fc798 100644 --- a/transports/quic/src/transport.rs +++ b/transports/quic/src/transport.rs @@ -754,10 +754,8 @@ fn socketaddr_to_multiaddr(socket_addr: &SocketAddr, version: ProtocolVersion) - #[cfg(test)] #[cfg(any(feature = "async-std", feature = "tokio"))] mod tests { - use futures::future::poll_fn; - use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; - use super::*; + use futures::future::poll_fn; #[test] fn multiaddr_to_udp_conversion() { diff --git a/transports/tcp/src/lib.rs b/transports/tcp/src/lib.rs index fbb7008aa5b..c8f0410d9e5 100644 --- a/transports/tcp/src/lib.rs +++ b/transports/tcp/src/lib.rs @@ -36,11 +36,7 @@ pub use provider::async_io; #[cfg(feature = "tokio")] pub use provider::tokio; -use futures::{ - future::{self, Ready}, - prelude::*, - stream::SelectAll, -}; +use futures::{future::Ready, prelude::*, stream::SelectAll}; use futures_timer::Delay; use if_watch::IfEvent; use libp2p_core::{ diff --git a/transports/tcp/src/provider/tokio.rs b/transports/tcp/src/provider/tokio.rs index b991c6bdae1..ec2d098e3fb 100644 --- a/transports/tcp/src/provider/tokio.rs +++ b/transports/tcp/src/provider/tokio.rs @@ -24,7 +24,6 @@ use futures::{ future::{BoxFuture, FutureExt}, prelude::*, }; -use std::convert::TryFrom; use std::io; use std::net; use std::pin::Pin; diff --git a/transports/uds/src/lib.rs b/transports/uds/src/lib.rs index 075cbadb80a..4b1c7a1670d 100644 --- a/transports/uds/src/lib.rs +++ b/transports/uds/src/lib.rs @@ -263,7 +263,7 @@ mod tests { transport::ListenerId, Transport, }; - use std::{self, borrow::Cow, path::Path}; + use std::{borrow::Cow, path::Path}; #[test] fn multiaddr_to_path_conversion() { diff --git a/transports/webrtc-websys/src/stream/poll_data_channel.rs b/transports/webrtc-websys/src/stream/poll_data_channel.rs index 0ee4f7920c9..f323d542eaf 100644 --- a/transports/webrtc-websys/src/stream/poll_data_channel.rs +++ b/transports/webrtc-websys/src/stream/poll_data_channel.rs @@ -10,7 +10,7 @@ use bytes::BytesMut; use futures::task::AtomicWaker; use futures::{AsyncRead, AsyncWrite}; use libp2p_webrtc_utils::MAX_MSG_LEN; -use wasm_bindgen::{prelude::*, JsCast}; +use wasm_bindgen::prelude::*; use web_sys::{Event, MessageEvent, RtcDataChannel, RtcDataChannelEvent, RtcDataChannelState}; /// [`PollDataChannel`] is a wrapper around around [`RtcDataChannel`] which implements [`AsyncRead`] and [`AsyncWrite`]. diff --git a/transports/webrtc/src/tokio/transport.rs b/transports/webrtc/src/tokio/transport.rs index 02cfa6f7296..2e73ac9c459 100644 --- a/transports/webrtc/src/tokio/transport.rs +++ b/transports/webrtc/src/tokio/transport.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use futures::{future::BoxFuture, prelude::*, stream::SelectAll, stream::Stream}; +use futures::{future::BoxFuture, prelude::*, stream::SelectAll}; use if_watch::{tokio::IfWatcher, IfEvent}; use libp2p_core::{ multiaddr::{Multiaddr, Protocol}, @@ -431,9 +431,9 @@ fn parse_webrtc_listen_addr(addr: &Multiaddr) -> Option { mod tests { use super::*; use futures::future::poll_fn; - use libp2p_core::{multiaddr::Protocol, Transport as _}; + use libp2p_core::Transport as _; use rand::thread_rng; - use std::net::{IpAddr, Ipv6Addr}; + use std::net::Ipv6Addr; #[test] fn missing_webrtc_protocol() { diff --git a/transports/websocket-websys/src/lib.rs b/transports/websocket-websys/src/lib.rs index 5c1a6ebf1c4..02b6bc837eb 100644 --- a/transports/websocket-websys/src/lib.rs +++ b/transports/websocket-websys/src/lib.rs @@ -36,7 +36,7 @@ use std::rc::Rc; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Mutex; use std::{pin::Pin, task::Context, task::Poll}; -use wasm_bindgen::{prelude::*, JsCast}; +use wasm_bindgen::prelude::*; use web_sys::{CloseEvent, Event, MessageEvent, WebSocket}; use crate::web_context::WebContext; diff --git a/transports/websocket-websys/src/web_context.rs b/transports/websocket-websys/src/web_context.rs index c514435d2bb..2b5d7b46431 100644 --- a/transports/websocket-websys/src/web_context.rs +++ b/transports/websocket-websys/src/web_context.rs @@ -1,4 +1,4 @@ -use wasm_bindgen::{prelude::*, JsCast}; +use wasm_bindgen::prelude::*; use web_sys::window; /// Web context that abstract the window vs web worker API diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index 3593e1eaff2..584bb2b5058 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -34,7 +34,7 @@ use soketto::{ handshake, }; use std::{collections::HashMap, ops::DerefMut, sync::Arc}; -use std::{convert::TryInto, fmt, io, mem, pin::Pin, task::Context, task::Poll}; +use std::{fmt, io, mem, pin::Pin, task::Context, task::Poll}; use url::Url; /// Max. number of payload bytes of a single frame. diff --git a/transports/websocket/src/quicksink.rs b/transports/websocket/src/quicksink.rs index d9edb4dfe0d..cb2c98b078f 100644 --- a/transports/websocket/src/quicksink.rs +++ b/transports/websocket/src/quicksink.rs @@ -294,7 +294,7 @@ where mod tests { use crate::quicksink::{make_sink, Action}; use async_std::{io, task}; - use futures::{channel::mpsc, prelude::*, stream}; + use futures::{channel::mpsc, prelude::*}; #[test] fn smoke_test() { diff --git a/transports/websocket/src/tls.rs b/transports/websocket/src/tls.rs index 5bff818f34c..24b0df97db3 100644 --- a/transports/websocket/src/tls.rs +++ b/transports/websocket/src/tls.rs @@ -19,7 +19,6 @@ // DEALINGS IN THE SOFTWARE. use futures_rustls::{rustls, TlsAcceptor, TlsConnector}; -use std::convert::TryFrom; use std::{fmt, io, sync::Arc}; /// TLS configuration. From b890b2962018c86dc68bed38ea0abf7799d91406 Mon Sep 17 00:00:00 2001 From: cui fliter Date: Mon, 25 Mar 2024 20:09:00 +0800 Subject: [PATCH 008/246] docs: fix typos in some comments The same as https://github.com/libp2p/rust-libp2p/pull/5196 There are some problem when merging #5196, resubmit this mr. Pull-Request: #5255. --- core/src/transport.rs | 4 ++-- deny.toml | 4 ++-- examples/stream/README.md | 2 +- identity/src/secp256k1.rs | 2 +- protocols/gossipsub/src/behaviour/tests.rs | 2 +- protocols/gossipsub/src/config.rs | 8 ++++---- protocols/kad/src/behaviour.rs | 2 +- protocols/kad/src/kbucket.rs | 2 +- swarm/src/connection.rs | 2 +- transports/websocket/src/framed.rs | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/src/transport.rs b/core/src/transport.rs index 22e7a0532fa..db8c083bd0a 100644 --- a/core/src/transport.rs +++ b/core/src/transport.rs @@ -311,7 +311,7 @@ pub enum TransportEvent { impl TransportEvent { /// In case this [`TransportEvent`] is an upgrade, apply the given function - /// to the upgrade and produce another transport event based the the function's result. + /// to the upgrade and produce another transport event based the function's result. pub fn map_upgrade(self, map: impl FnOnce(TUpgr) -> U) -> TransportEvent { match self { TransportEvent::Incoming { @@ -530,7 +530,7 @@ pub enum TransportError { } impl TransportError { - /// Applies a function to the the error in [`TransportError::Other`]. + /// Applies a function to the error in [`TransportError::Other`]. pub fn map(self, map: impl FnOnce(TErr) -> TNewErr) -> TransportError { match self { TransportError::MultiaddrNotSupported(addr) => { diff --git a/deny.toml b/deny.toml index 6634887128e..dedcb7a3a95 100644 --- a/deny.toml +++ b/deny.toml @@ -37,7 +37,7 @@ ignore = [ [licenses] # The lint level for crates which do not have a detectable license unlicensed = "deny" -# List of explictly allowed licenses +# List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.7 short identifier (+ optional exception)]. allow = [ @@ -46,7 +46,7 @@ allow = [ "MIT", "Unlicense", ] -# List of explictly disallowed licenses +# List of explicitly disallowed licenses # See https://spdx.org/licenses/ for list of possible licenses # [possible values: any SPDX 3.7 short identifier (+ optional exception)]. deny = [] diff --git a/examples/stream/README.md b/examples/stream/README.md index 8437a5ea21e..3b0325519f7 100644 --- a/examples/stream/README.md +++ b/examples/stream/README.md @@ -23,7 +23,7 @@ To run the example, follow these steps: cargo run --bin stream-example --
``` -3. Both terminals should now continuosly print messages. +3. Both terminals should now continuously print messages. ## Conclusion diff --git a/identity/src/secp256k1.rs b/identity/src/secp256k1.rs index 5e1fda2933b..a6e9e923268 100644 --- a/identity/src/secp256k1.rs +++ b/identity/src/secp256k1.rs @@ -214,7 +214,7 @@ impl PublicKey { self.0.serialize() } - /// Decode a public key from a byte slice in the the format produced + /// Decode a public key from a byte slice in the format produced /// by `encode`. pub fn try_from_bytes(k: &[u8]) -> Result { libsecp256k1::PublicKey::parse_slice(k, Some(libsecp256k1::PublicKeyFormat::Compressed)) diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index 1a63b52541f..077a1bd22fb 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -2392,7 +2392,7 @@ fn test_dont_graft_to_negative_scored_peers() { } ///Note that in this test also without a penalty the px would be ignored because of the -/// acceptPXThreshold, but the spec still explicitely states the rule that px from negative +/// acceptPXThreshold, but the spec still explicitly states the rule that px from negative /// peers should get ignored, therefore we test it here. #[test] fn test_ignore_px_from_negative_scored_peer() { diff --git a/protocols/gossipsub/src/config.rs b/protocols/gossipsub/src/config.rs index cd2326279eb..8d7d11802ad 100644 --- a/protocols/gossipsub/src/config.rs +++ b/protocols/gossipsub/src/config.rs @@ -262,9 +262,9 @@ impl Config { self.unsubscribe_backoff } - /// Number of heartbeat slots considered as slack for backoffs. This gurantees that we wait + /// Number of heartbeat slots considered as slack for backoffs. This guarantees that we wait /// at least backoff_slack heartbeats after a backoff is over before we try to graft. This - /// solves problems occuring through high latencies. In particular if + /// solves problems occurring through high latencies. In particular if /// `backoff_slack * heartbeat_interval` is longer than any latencies between processing /// prunes on our side and processing prunes on the receiving side this guarantees that we /// get not punished for too early grafting. The default is 1. @@ -660,9 +660,9 @@ impl ConfigBuilder { self } - /// Number of heartbeat slots considered as slack for backoffs. This gurantees that we wait + /// Number of heartbeat slots considered as slack for backoffs. This guarantees that we wait /// at least backoff_slack heartbeats after a backoff is over before we try to graft. This - /// solves problems occuring through high latencies. In particular if + /// solves problems occurring through high latencies. In particular if /// `backoff_slack * heartbeat_interval` is longer than any latencies between processing /// prunes on our side and processing prunes on the receiving side this guarantees that we /// get not punished for too early grafting. The default is 1. diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 31568b0f9a8..b1701ed9339 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -2203,7 +2203,7 @@ where Some(peer) => peer, }; - // We should order addresses from decreasing likelyhood of connectivity, so start with + // We should order addresses from decreasing likelihood of connectivity, so start with // the addresses of that peer in the k-buckets. let key = kbucket::Key::from(peer_id); let mut peer_addrs = diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index cf5591c5cf6..5a110fd7c3f 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -344,7 +344,7 @@ enum ClosestBucketsIterState { /// The starting state of the iterator yields the first bucket index and /// then transitions to `ZoomIn`. Start(BucketIndex), - /// The iterator "zooms in" to to yield the next bucket cotaining nodes that + /// The iterator "zooms in" to yield the next bucket cotaining nodes that /// are incrementally closer to the local node but further from the `target`. /// These buckets are identified by a `1` in the corresponding bit position /// of the distance bit string. When bucket `0` is reached, the iterator diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index a6e8e1c6851..c701f1773e6 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -717,7 +717,7 @@ impl Future for SubstreamRequested { /// The options for a planned connection & handler shutdown. /// -/// A shutdown is planned anew based on the the return value of +/// A shutdown is planned anew based on the return value of /// [`ConnectionHandler::connection_keep_alive`] of the underlying handler /// after every invocation of [`ConnectionHandler::poll`]. /// diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index 584bb2b5058..ab7bfda43db 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -521,7 +521,7 @@ fn parse_ws_dial_addr(addr: Multiaddr) -> Result> { }; // The original address, stripped of the `/ws` and `/wss` protocols, - // makes up the the address for the inner TCP-based transport. + // makes up the address for the inner TCP-based transport. let tcp_addr = match p2p { Some(p) => protocols.with(p), None => protocols, From 0687385eb48ac06787dd686537babbb0c665a72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Schwert?= Date: Mon, 25 Mar 2024 14:20:13 +0100 Subject: [PATCH 009/246] fix(websocket-websys): change close code in drop implementation to 1000 In browsers, only the code 1000 and codes between 3000-4999 are allowed to be set by userland code: https://websockets.spec.whatwg.org/#dom-websocket-close I found this while debugging use-after-free errors in our WASM application. Turns out, when connections are timing out, libp2p in rust drops them, but does not seem to close them explicitly (we are using libp2p-swarm). This led to these WebSockets still emitting events, the handlers of which were already dropped on the rust side, though. A long investigation led me to have a look into the `Result` that gets returned from `close_with_code_and_reason`, and it turns out it's an error! Specifically: ``` InvalidAccessError: Failed to execute 'close' on 'WebSocket': The code must be either 1000, or between 3000 and 4999. 1001 is neither. ``` This PR only fixes the failing closing of the WebSocket, not the remaining use-after-free problem. Pull-Request: #5229. --- Cargo.lock | 2 +- Cargo.toml | 2 +- transports/websocket-websys/CHANGELOG.md | 7 +++++++ transports/websocket-websys/Cargo.toml | 2 +- transports/websocket-websys/src/lib.rs | 5 +++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4554147f4e4..4c739c2f5ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3450,7 +3450,7 @@ dependencies = [ [[package]] name = "libp2p-websocket-websys" -version = "0.3.1" +version = "0.3.2" dependencies = [ "bytes", "futures", diff --git a/Cargo.toml b/Cargo.toml index b6508a3d3f2..ce33cec2ba0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,7 +112,7 @@ libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.2.0", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.43.0", path = "transports/websocket" } -libp2p-websocket-websys = { version = "0.3.1", path = "transports/websocket-websys" } +libp2p-websocket-websys = { version = "0.3.2", path = "transports/websocket-websys" } libp2p-webtransport-websys = { version = "0.2.0", path = "transports/webtransport-websys" } libp2p-yamux = { version = "0.45.1", path = "muxers/yamux" } multiaddr = "0.18.1" diff --git a/transports/websocket-websys/CHANGELOG.md b/transports/websocket-websys/CHANGELOG.md index 3cfb1b2fbf9..f92b76ebeaa 100644 --- a/transports/websocket-websys/CHANGELOG.md +++ b/transports/websocket-websys/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.3.2 + +- Change close code in drop implementation to `1000` given that in browsers only + the code `1000` and codes between `3000` and `4999` are allowed to be set by + userland code. + See [PR 5229](https://github.com/libp2p/rust-libp2p/pull/5229). + ## 0.3.1 - Add support for different WASM environments by introducing a `WebContext` that diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 5855b582c80..c73c753e7b4 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-websocket-websys" edition = "2021" rust-version = "1.60.0" description = "WebSocket for libp2p under WASM environment" -version = "0.3.1" +version = "0.3.2" authors = ["Vince Vasta "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/websocket-websys/src/lib.rs b/transports/websocket-websys/src/lib.rs index 02b6bc837eb..ca56d5727a5 100644 --- a/transports/websocket-websys/src/lib.rs +++ b/transports/websocket-websys/src/lib.rs @@ -434,13 +434,14 @@ impl AsyncWrite for Connection { impl Drop for Connection { fn drop(&mut self) { - const GO_AWAY_STATUS_CODE: u16 = 1001; // See https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1. + // In browsers, userland code is not allowed to use any other status code than 1000: https://websockets.spec.whatwg.org/#dom-websocket-close + const REGULAR_CLOSE: u16 = 1000; // See https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1. if let ReadyState::Connecting | ReadyState::Open = self.inner.ready_state() { let _ = self .inner .socket - .close_with_code_and_reason(GO_AWAY_STATUS_CODE, "connection dropped"); + .close_with_code_and_reason(REGULAR_CLOSE, "connection dropped"); } WebContext::new() From edaa2d857060a69ff4bbaf2cfca0cf9fa39096df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Mon, 25 Mar 2024 14:39:34 +0000 Subject: [PATCH 010/246] chore: re-enable mergify for dependabot & trivial (#5264) ## Description mergify automatic approval for dependabot PR's was disabled on https://github.com/libp2p/rust-libp2p/pull/5208 following malfunctioning. This PR re-enables mergify's automatic merge of Dependabot PR's and the `trivial` label with the syntax [suggested on mergify's doc](https://docs.mergify.com/integrations/dependabot/#2-pr-approval) --- .github/mergify.yml | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/mergify.yml b/.github/mergify.yml index b464c9aba87..91cd8881237 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -52,22 +52,24 @@ pull_request_rules: message: Approvals have been dismissed because the PR was updated after the `send-it` label was applied. changes_requested: false - # - name: Approve trivial maintainer PRs - # conditions: - # - base=master - # - label=trivial - # - author=@libp2p/rust-libp2p-maintainers - # actions: - # review: + - name: Approve trivial maintainer PRs + conditions: + - base=master + - label=trivial + - author=@libp2p/rust-libp2p-maintainers + actions: + review: + type: APPROVE - # - name: Approve dependabot PRs of semver-compatible updates - # conditions: - # - author=dependabot[bot] - # - or: - # - title~=bump [^\s]+ from ([1-9]+)\..+ to \1\. # For major >= 1 versions, only approve updates with the same major version. - # - title~=bump [^\s]+ from 0\.([\d]+)\..+ to 0\.\1\. # For major == 0 versions, only approve updates with the same minor version. - # actions: - # review: + - name: Approve dependabot PRs of semver-compatible updates + conditions: + - author=dependabot[bot] + - or: + - title~=bump [^\s]+ from ([1-9]+)\..+ to \1\. # For major >= 1 versions, only approve updates with the same major version. + - title~=bump [^\s]+ from 0\.([\d]+)\..+ to 0\.\1\. # For major == 0 versions, only approve updates with the same minor version. + actions: + review: + type: APPROVE queue_rules: - name: default From e004e28a792f7f9bfce9f0c1d33626e1ced63cfb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:57:10 +0000 Subject: [PATCH 011/246] deps: bump bs58 from 0.5.0 to 0.5.1 Pull-Request: #5257. --- Cargo.lock | 4 ++-- identity/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c739c2f5ab..db94ee49392 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -742,9 +742,9 @@ dependencies = [ [[package]] name = "bs58" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ "tinyvec", ] diff --git a/identity/Cargo.toml b/identity/Cargo.toml index 920b9a990e4..1f025353af5 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -13,7 +13,7 @@ categories = ["cryptography"] [dependencies] asn1_der = { version = "0.7.6", optional = true } -bs58 = { version = "0.5.0", optional = true } +bs58 = { version = "0.5.1", optional = true } ed25519-dalek = { version = "2.1", optional = true } hkdf = { version = "0.12.4", optional = true } libsecp256k1 = { version = "0.7.0", optional = true } From b6f70de57b81cc80f053a1223a82a936a9d7b967 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:10:10 +0000 Subject: [PATCH 012/246] deps: bump reqwest from 0.11.26 to 0.11.27 Pull-Request: #5258. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db94ee49392..f14f326a2d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4804,9 +4804,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.26" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64 0.21.7", "bytes", From d41350ebad7ddd8827febb5a42408431f7155062 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:22:16 +0000 Subject: [PATCH 013/246] deps: bump regex from 1.10.3 to 1.10.4 Pull-Request: #5261. --- Cargo.lock | 4 ++-- protocols/gossipsub/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f14f326a2d7..1e83c240be4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4734,9 +4734,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick 1.0.2", "memchr", diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index f44d3f97fa0..83c1ec0bac4 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -31,7 +31,7 @@ libp2p-swarm = { workspace = true } quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" -regex = "1.10.3" +regex = "1.10.4" serde = { version = "1", optional = true, features = ["derive"] } sha2 = "0.10.8" smallvec = "1.13.1" From 81f5d75f640e3da219f9737b41a01789bd7aaa2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:34:54 +0000 Subject: [PATCH 014/246] deps: bump bytes from 1.5.0 to 1.6.0 Pull-Request: #5262. --- Cargo.lock | 4 ++-- protocols/floodsub/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e83c240be4..807124bf53f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -773,9 +773,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" dependencies = [ "serde", ] diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 06277273a90..5d109cdedc1 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] asynchronous-codec = { workspace = true } cuckoofilter = "0.5.0" fnv = "1.0" -bytes = "1.5" +bytes = "1.6" futures = "0.3.30" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 83c1ec0bac4..383673bc086 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -17,7 +17,7 @@ wasm-bindgen = ["getrandom/js", "instant/wasm-bindgen"] asynchronous-codec = { workspace = true } base64 = "0.21.7" byteorder = "1.5.0" -bytes = "1.5" +bytes = "1.6" either = "1.9" fnv = "1.0.7" futures = "0.3.30" diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index abfbf0742f4..8642761701f 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] async-std = { version = "1.12.0", optional = true } -bytes = "1.5.0" +bytes = "1.6.0" futures = "0.3.30" futures-timer = "3.0.3" if-watch = "3.2.0" diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index c73c753e7b4..7347ac71f17 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -bytes = "1.4.0" +bytes = "1.6.0" futures = "0.3.30" js-sys = "0.3.67" libp2p-core = { workspace = true } From c5975142980094b7b8086b812b751a0dcde0aebf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:47:29 +0000 Subject: [PATCH 015/246] deps: bump smallvec from 1.13.1 to 1.13.2 Pull-Request: #5263. --- Cargo.lock | 4 ++-- core/Cargo.toml | 2 +- misc/multistream-select/Cargo.toml | 2 +- muxers/mplex/Cargo.toml | 2 +- protocols/floodsub/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- protocols/identify/Cargo.toml | 2 +- protocols/kad/Cargo.toml | 2 +- protocols/mdns/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- swarm/Cargo.toml | 2 +- transports/dns/Cargo.toml | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 807124bf53f..54fa7ab3ae8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5399,9 +5399,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smol" diff --git a/core/Cargo.toml b/core/Cargo.toml index 054627bed38..1ef40505aac 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -27,7 +27,7 @@ quick-protobuf = "0.8" rand = "0.8" rw-stream-sink = { workspace = true } serde = { version = "1", optional = true, features = ["derive"] } -smallvec = "1.13.1" +smallvec = "1.13.2" thiserror = "1.0" tracing = "0.1.37" unsigned-varint = { workspace = true } diff --git a/misc/multistream-select/Cargo.toml b/misc/multistream-select/Cargo.toml index b6287505ae4..ea11cb299d2 100644 --- a/misc/multistream-select/Cargo.toml +++ b/misc/multistream-select/Cargo.toml @@ -15,7 +15,7 @@ bytes = "1" futures = "0.3" tracing = "0.1.37" pin-project = "1.1.4" -smallvec = "1.13.1" +smallvec = "1.13.2" unsigned-varint = { workspace = true } [dev-dependencies] diff --git a/muxers/mplex/Cargo.toml b/muxers/mplex/Cargo.toml index 7cb4befa22b..3ce7dc5c02f 100644 --- a/muxers/mplex/Cargo.toml +++ b/muxers/mplex/Cargo.toml @@ -19,7 +19,7 @@ libp2p-identity = { workspace = true } nohash-hasher = "0.2" parking_lot = "0.12" rand = "0.8" -smallvec = "1.13.1" +smallvec = "1.13.2" tracing = "0.1.37" unsigned-varint = { workspace = true, features = ["asynchronous_codec"] } diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 5d109cdedc1..a10d60c5c5c 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -22,7 +22,7 @@ libp2p-identity = { workspace = true } quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" -smallvec = "1.13.1" +smallvec = "1.13.2" thiserror = "1.0.57" tracing = "0.1.37" diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 383673bc086..52ffb675d4b 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -34,7 +34,7 @@ rand = "0.8" regex = "1.10.4" serde = { version = "1", optional = true, features = ["derive"] } sha2 = "0.10.8" -smallvec = "1.13.1" +smallvec = "1.13.2" tracing = "0.1.37" void = "1.0.2" diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 340df99e4dc..77d90875dfe 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -21,7 +21,7 @@ libp2p-identity = { workspace = true } lru = "0.12.2" quick-protobuf-codec = { workspace = true } quick-protobuf = "0.8" -smallvec = "1.13.1" +smallvec = "1.13.2" thiserror = "1.0" tracing = "0.1.37" void = "1.0" diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 3a91955cc06..ed7f255ccd8 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -25,7 +25,7 @@ quick-protobuf-codec = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } rand = "0.8" sha2 = "0.10.8" -smallvec = "1.13.1" +smallvec = "1.13.2" uint = "0.9" void = "1.0" futures-timer = "3.0.3" diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 0d03a839a6f..15c26c34131 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -20,7 +20,7 @@ libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } rand = "0.8.3" -smallvec = "1.13.1" +smallvec = "1.13.2" socket2 = { version = "0.5.6", features = ["all"] } tokio = { version = "1.36", default-features = false, features = ["net", "time"], optional = true} tracing = "0.1.37" diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 4b4021285a4..639f4d7b56a 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -21,7 +21,7 @@ libp2p-identity = { workspace = true } rand = "0.8" serde = { version = "1.0", optional = true} serde_json = { version = "1.0.114", optional = true } -smallvec = "1.13.1" +smallvec = "1.13.2" tracing = "0.1.37" void = "1.0.2" futures-timer = "3.0.3" diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 3fdf06aa19f..81a029bc014 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -24,7 +24,7 @@ lru = "0.12.2" multistream-select = { workspace = true } once_cell = "1.19.0" rand = "0.8" -smallvec = "1.13.1" +smallvec = "1.13.2" tracing = "0.1.37" void = "1" wasm-bindgen-futures = { version = "0.4.42", optional = true } diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index f026aac5157..22f6650e0ed 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -18,7 +18,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true } parking_lot = "0.12.0" hickory-resolver = { version = "0.24.0", default-features = false, features = ["system-config"] } -smallvec = "1.13.1" +smallvec = "1.13.2" tracing = "0.1.37" [dev-dependencies] From f05e5247cd426b7b0b1bc07dd129b8c0484ebf39 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:59:36 +0000 Subject: [PATCH 016/246] deps: bump the axum group with 1 update Pull-Request: #5256. --- Cargo.lock | 54 +++++++++++------------------- examples/browser-webrtc/Cargo.toml | 2 +- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54fa7ab3ae8..315de03de68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -498,7 +498,7 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper", + "sync_wrapper 0.1.2", "tower", "tower-layer", "tower-service", @@ -506,9 +506,9 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core 0.4.3", @@ -530,7 +530,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.0", "tokio", "tower", "tower-layer", @@ -570,7 +570,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", "tracing", @@ -719,7 +719,7 @@ name = "browser-webrtc-example" version = "0.1.0" dependencies = [ "anyhow", - "axum 0.7.4", + "axum 0.7.5", "futures", "js-sys", "libp2p", @@ -1848,25 +1848,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "h2" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 1.0.0", - "indexmap 2.2.1", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "half" version = "1.8.2" @@ -2127,7 +2108,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.24", + "h2", "http 0.2.9", "http-body 0.4.5", "httparse", @@ -2150,7 +2131,6 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.2", "http 1.0.0", "http-body 1.0.0", "httparse", @@ -2201,12 +2181,11 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" dependencies = [ "bytes", - "futures-channel", "futures-util", "http 1.0.0", "http-body 1.0.0", @@ -2214,7 +2193,6 @@ dependencies = [ "pin-project-lite", "socket2 0.5.6", "tokio", - "tracing", ] [[package]] @@ -2364,7 +2342,7 @@ name = "interop-tests" version = "0.1.0" dependencies = [ "anyhow", - "axum 0.7.4", + "axum 0.7.5", "console_error_panic_hook", "either", "futures", @@ -4813,7 +4791,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.3.24", + "h2", "http 0.2.9", "http-body 0.4.5", "hyper 0.14.27", @@ -4832,7 +4810,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tokio-native-tls", @@ -5622,6 +5600,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384595c11a4e2969895cad5a8c4029115f5ab956a9e5ef4de79d11a426e5f20c" + [[package]] name = "synstructure" version = "0.12.6" @@ -5909,7 +5893,7 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "h2 0.3.24", + "h2", "http 0.2.9", "http-body 0.4.5", "hyper 0.14.27", diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index 322ae2b8348..bbe2df646f4 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -23,7 +23,7 @@ tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -axum = "0.7.4" +axum = "0.7.5" libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "tokio"] } libp2p-webrtc = { workspace = true, features = ["tokio"] } rust-embed = { version = "8.3.0", features = ["include-exclude", "interpolate-folder-path"] } From c150c021484431b5cbdd3a824201f18fab0239dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:12:15 +0000 Subject: [PATCH 017/246] deps: bump proc-macro2 from 1.0.78 to 1.0.79 Pull-Request: #5234. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 315de03de68..e159fa1afba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4396,9 +4396,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] From 3b5fd35c090fc6b64e5d899a7473f20a7bbe2d15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:31:04 +0000 Subject: [PATCH 018/246] deps: bump the opentelemetry group with 4 updates Pull-Request: #5259. --- Cargo.lock | 71 +++++++++++++++++++++++-------------- examples/metrics/Cargo.toml | 8 ++--- 2 files changed, 48 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e159fa1afba..5a8380af0e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -411,6 +411,28 @@ dependencies = [ "socket2 0.5.6", ] +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "async-task" version = "4.4.0" @@ -4034,13 +4056,12 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" +checksum = "900d57987be3f2aeb70d385fff9b27fb74c5723cc9a52d904d4f9c807a0667bf" dependencies = [ "futures-core", "futures-sink", - "indexmap 2.2.1", "js-sys", "once_cell", "pin-project-lite", @@ -4050,9 +4071,9 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f24cda83b20ed2433c68241f918d0f6fdec8b1d43b7a9590ab4420c5095ca930" +checksum = "1a016b8d9495c639af2145ac22387dcb88e44118e45320d9238fbf4e7889abcb" dependencies = [ "async-trait", "futures-core", @@ -4069,9 +4090,9 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2e155ce5cc812ea3d1dffbd1539aed653de4bf4882d60e6e04dcf0901d674e1" +checksum = "3a8fddc9b68f5b80dae9d6f510b88e02396f006ad48cac349411fbecc80caae4" dependencies = [ "opentelemetry", "opentelemetry_sdk", @@ -4081,18 +4102,15 @@ dependencies = [ [[package]] name = "opentelemetry-semantic-conventions" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5774f1ef1f982ef2a447f6ee04ec383981a3ab99c8e77a1a7b30182e65bbc84" -dependencies = [ - "opentelemetry", -] +checksum = "f9ab5bd6c42fb9349dcf28af2ba9a0667f697f9bdcca045d39f2cec5543e2910" [[package]] name = "opentelemetry_sdk" -version = "0.21.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f16aec8a98a457a52664d69e0091bac3a0abd18ead9b641cb00202ba4e0efe4" +checksum = "9e90c7113be649e31e9a0f8b5ee24ed7a16923b322c3c5ab6367469c049d6b7e" dependencies = [ "async-trait", "crossbeam-channel", @@ -4428,9 +4446,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.9" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" dependencies = [ "bytes", "prost-derive", @@ -4438,15 +4456,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.9" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" dependencies = [ "anyhow", "itertools", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.52", ] [[package]] @@ -5883,16 +5901,15 @@ dependencies = [ [[package]] name = "tonic" -version = "0.9.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" dependencies = [ + "async-stream", "async-trait", "axum 0.6.20", "base64 0.21.7", "bytes", - "futures-core", - "futures-util", "h2", "http 0.2.9", "http-body 0.4.5", @@ -6012,9 +6029,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c67ac25c5407e7b961fafc6f7e9aa5958fd297aada2d20fa2ae1737357e55596" +checksum = "a9be14ba1bbe4ab79e9229f7f89fab8d120b865859f10527f31c033e599d2284" dependencies = [ "js-sys", "once_cell", @@ -6421,9 +6438,9 @@ dependencies = [ [[package]] name = "web-time" -version = "0.2.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index 499e1fb7f4b..188121fb7d0 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -12,13 +12,13 @@ release = false futures = "0.3.30" hyper = { version = "0.14", features = ["server", "tcp", "http1"] } libp2p = { path = "../../libp2p", features = ["tokio", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] } -opentelemetry = { version = "0.21.0", features = ["metrics"] } -opentelemetry-otlp = { version = "0.14.0", features = ["metrics"] } -opentelemetry_sdk = { version = "0.21.2", features = ["rt-tokio", "metrics"] } +opentelemetry = { version = "0.22.0", features = ["metrics"] } +opentelemetry-otlp = { version = "0.15.0", features = ["metrics"] } +opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio", "metrics"] } prometheus-client = { workspace = true } tokio = { version = "1", features = ["full"] } tracing = "0.1.37" -tracing-opentelemetry = "0.22.0" +tracing-opentelemetry = "0.23.0" tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] From 461b7878474bb241dcff36558e8a5e4673a57b3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:44:53 +0000 Subject: [PATCH 019/246] deps: bump thiserror from 1.0.57 to 1.0.58 Pull-Request: #5237. --- Cargo.lock | 8 ++++---- protocols/floodsub/Cargo.toml | 2 +- transports/noise/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/tls/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/webtransport-websys/Cargo.toml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a8380af0e1..52e7642c2d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5733,18 +5733,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index a10d60c5c5c..98e7cc7fd49 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -23,7 +23,7 @@ quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" smallvec = "1.13.2" -thiserror = "1.0.57" +thiserror = "1.0.58" tracing = "0.1.37" # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 83bb6de8c0e..02bd46550e5 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -22,7 +22,7 @@ quick-protobuf = "0.8" rand = "0.8.3" sha2 = "0.10.8" static_assertions = "1" -thiserror = "1.0.57" +thiserror = "1.0.58" tracing = "0.1.37" x25519-dalek = "2" zeroize = "1" diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 8642761701f..ca6fdf6b779 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -21,7 +21,7 @@ parking_lot = "0.12.0" quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls", "futures-io"] } rand = "0.8.5" rustls = { version = "0.21.9", default-features = false } -thiserror = "1.0.57" +thiserror = "1.0.58" tokio = { version = "1.36.0", default-features = false, features = ["net", "rt", "time"], optional = true } tracing = "0.1.37" socket2 = "0.5.6" diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 0ca134d418b..fd7f1a57409 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -15,7 +15,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true } rcgen = "0.11.3" ring = "0.16.20" -thiserror = "1.0.57" +thiserror = "1.0.58" webpki = { version = "0.101.4", package = "rustls-webpki", features = ["std"] } x509-parser = "0.15.1" yasna = "0.5.2" diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 7347ac71f17..0ee6808a3ca 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -18,7 +18,7 @@ libp2p-core = { workspace = true } tracing = "0.1.37" parking_lot = "0.12.1" send_wrapper = "0.6.0" -thiserror = "1.0.57" +thiserror = "1.0.58" wasm-bindgen = "0.2.90" web-sys = { version = "0.3.68", features = ["BinaryType", "CloseEvent", "MessageEvent", "WebSocket", "Window", "WorkerGlobalScope"] } diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index f71b6db5d87..faeb8c24d15 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -22,7 +22,7 @@ libp2p-noise = { workspace = true } multiaddr = { workspace = true } multihash = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } -thiserror = "1.0.57" +thiserror = "1.0.58" tracing = "0.1.37" wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.42" From 5bbec49b3ec28c8cc353411ef16e15e8b3d089d7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:16:56 +0000 Subject: [PATCH 020/246] deps: bump async-trait from 0.1.77 to 0.1.78 Pull-Request: #5235. --- Cargo.lock | 4 ++-- swarm-test/Cargo.toml | 2 +- transports/dns/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52e7642c2d5..050911e4985 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -441,9 +441,9 @@ checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote", diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index ab27e141a4b..3d20ecd625e 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -async-trait = "0.1.77" +async-trait = "0.1.78" libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-plaintext = { workspace = true } diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index 22f6650e0ed..fb176bbd1ad 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-std-resolver = { version = "0.24", optional = true } -async-trait = "0.1.77" +async-trait = "0.1.78" futures = "0.3.30" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } From 38e2f7a360b4304f6084e58f3adc674a7ba8039b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:20:27 +0000 Subject: [PATCH 021/246] deps: bump syn from 2.0.52 to 2.0.55 Pull-Request: #5265. --- Cargo.lock | 52 ++++++++++++++++++++--------------------- swarm-derive/Cargo.toml | 2 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 050911e4985..27ed826accb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -430,7 +430,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -447,7 +447,7 @@ checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -958,7 +958,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1224,7 +1224,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1341,7 +1341,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1446,7 +1446,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -1682,7 +1682,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -3269,7 +3269,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -4033,7 +4033,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -4244,7 +4244,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -4441,7 +4441,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -4464,7 +4464,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -4983,7 +4983,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.52", + "syn 2.0.55", "walkdir", ] @@ -5244,7 +5244,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -5277,7 +5277,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -5553,7 +5553,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -5603,9 +5603,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" dependencies = [ "proc-macro2", "quote", @@ -5748,7 +5748,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -5850,7 +5850,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -6003,7 +6003,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -6345,7 +6345,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", "wasm-bindgen-shared", ] @@ -6379,7 +6379,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6412,7 +6412,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -6975,7 +6975,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] @@ -6995,5 +6995,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index d2d8796acb3..0fb2dac8198 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true [dependencies] heck = "0.5" quote = "1.0" -syn = { version = "2.0.52", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.55", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" # Passing arguments to the docsrs builder in order to properly document cfg's. From b75c643b9e3146ae0c6a4725df6aba482de49ea1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:39:36 +0000 Subject: [PATCH 022/246] deps: bump anyhow from 1.0.80 to 1.0.81 Pull-Request: #5236. --- Cargo.lock | 4 ++-- examples/browser-webrtc/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27ed826accb..341d462a428 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "arbitrary" diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index bbe2df646f4..ae86b99e447 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -16,7 +16,7 @@ release = false crate-type = ["cdylib"] [dependencies] -anyhow = "1.0.80" +anyhow = "1.0.81" futures = "0.3.30" rand = "0.8" tracing = "0.1.37" diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index 5581728794e..9536d8d1916 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" clap = { version = "4.4.16", features = ["derive"] } env_logger = "0.10" futures = "0.3.30" -anyhow = "1.0.80" +anyhow = "1.0.81" libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "yamux", "rsa"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 639f4d7b56a..4fa225dc3cd 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -32,7 +32,7 @@ json = ["dep:serde", "dep:serde_json", "libp2p-swarm/macros"] cbor = ["dep:serde", "dep:cbor4ii", "libp2p-swarm/macros"] [dev-dependencies] -anyhow = "1.0.80" +anyhow = "1.0.81" async-std = { version = "1.6.2", features = ["attributes"] } libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } From 1c5a527796be07fd913f497069dc8b47126b9fa4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 22:36:43 +0000 Subject: [PATCH 023/246] deps: bump trybuild from 1.0.89 to 1.0.90 Pull-Request: #5233. --- Cargo.lock | 67 +++++++++++++++++++++++++++++++++++++++--------- swarm/Cargo.toml | 2 +- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 341d462a428..517562ba923 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -649,15 +649,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "basic-toml" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5" -dependencies = [ - "serde", -] - [[package]] name = "bimap" version = "0.6.3" @@ -5280,6 +5271,15 @@ dependencies = [ "syn 2.0.55", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -5899,6 +5899,40 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" +dependencies = [ + "indexmap 2.2.1", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tonic" version = "0.11.0" @@ -6082,17 +6116,17 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "trybuild" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9d3ba662913483d6722303f619e75ea10b7855b0f8e0d72799cf8621bb488f" +checksum = "2aa6f84ec205ebf87fb7a0abdbcd1467fa5af0e86878eb6d888b78ecbb10b6d5" dependencies = [ - "basic-toml", "glob", "once_cell", "serde", "serde_derive", "serde_json", "termcolor", + "toml", ] [[package]] @@ -6863,6 +6897,15 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +[[package]] +name = "winnow" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 81a029bc014..da4b09487f7 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -54,7 +54,7 @@ libp2p-yamux = { path = "../muxers/yamux" } # Using `pat quickcheck = { workspace = true } void = "1" once_cell = "1.19.0" -trybuild = "1.0.89" +trybuild = "1.0.90" tokio = { version = "1.36.0", features = ["time", "rt", "macros", "rt-multi-thread"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } From a372723f327f842e4ff6fa66658c6ec303dab22a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 22:59:28 +0000 Subject: [PATCH 024/246] deps: bump pin-project from 1.1.4 to 1.1.5 Pull-Request: #5216. --- Cargo.lock | 8 ++++---- core/Cargo.toml | 2 +- misc/metrics/Cargo.toml | 2 +- misc/multistream-select/Cargo.toml | 2 +- misc/rw-stream-sink/Cargo.toml | 2 +- transports/pnet/Cargo.toml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 517562ba923..671b05ce61c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4220,18 +4220,18 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", diff --git a/core/Cargo.toml b/core/Cargo.toml index 1ef40505aac..582746d4037 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -22,7 +22,7 @@ multihash = { workspace = true } multistream-select = { workspace = true } once_cell = "1.19.0" parking_lot = "0.12.0" -pin-project = "1.1.4" +pin-project = "1.1.5" quick-protobuf = "0.8" rand = "0.8" rw-stream-sink = { workspace = true } diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index 38c4777d4a6..b9952e36ba3 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -30,7 +30,7 @@ libp2p-kad = { workspace = true, optional = true } libp2p-ping = { workspace = true, optional = true } libp2p-relay = { workspace = true, optional = true } libp2p-swarm = { workspace = true } -pin-project = "1.1.4" +pin-project = "1.1.5" prometheus-client = { workspace = true } [dev-dependencies] diff --git a/misc/multistream-select/Cargo.toml b/misc/multistream-select/Cargo.toml index ea11cb299d2..37b5f7753f2 100644 --- a/misc/multistream-select/Cargo.toml +++ b/misc/multistream-select/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] bytes = "1" futures = "0.3" tracing = "0.1.37" -pin-project = "1.1.4" +pin-project = "1.1.5" smallvec = "1.13.2" unsigned-varint = { workspace = true } diff --git a/misc/rw-stream-sink/Cargo.toml b/misc/rw-stream-sink/Cargo.toml index f8f103bd6d9..8de0555582c 100644 --- a/misc/rw-stream-sink/Cargo.toml +++ b/misc/rw-stream-sink/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures = "0.3.30" -pin-project = "1.1.4" +pin-project = "1.1.5" static_assertions = "1" [dev-dependencies] diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index bdefa76bbd1..43a9da2fba9 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -16,7 +16,7 @@ salsa20 = "0.10" sha3 = "0.10" tracing = "0.1.37" rand = "0.8" -pin-project = "1.1.4" +pin-project = "1.1.5" [dev-dependencies] libp2p-core = { workspace = true } From 89c684aa92dc43acaf86a01881c8467ba79b7df7 Mon Sep 17 00:00:00 2001 From: June Han Date: Thu, 28 Mar 2024 02:54:42 +0900 Subject: [PATCH 025/246] fix(kad): compute `jobs_query_capacity` accurately Fixes: #4191. Pull-Request: #5148. --- protocols/kad/CHANGELOG.md | 2 ++ protocols/kad/src/behaviour.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 0e781c18916..055dde94234 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -5,6 +5,8 @@ - Make it mandatory to provide protocol names when creating a `kad::Config`. Deprecate `kad::Config::default()`, replaced by `kad::Config::new(StreamProtocol)`. See [PR 5122](https://github.com/libp2p/rust-libp2p/pull/5122). +- Compute `jobs_query_capacity` accurately. + See [PR 5148](https://github.com/libp2p/rust-libp2p/pull/5148). ## 0.45.3 diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index b1701ed9339..6b526edccfe 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -2502,14 +2502,14 @@ where // Run the periodic provider announcement job. if let Some(mut job) = self.add_provider_job.take() { let num = usize::min(JOBS_MAX_NEW_QUERIES, jobs_query_capacity); - for _ in 0..num { + for i in 0..num { if let Poll::Ready(r) = job.poll(cx, &mut self.store, now) { self.start_add_provider(r.key, AddProviderContext::Republish) } else { + jobs_query_capacity -= i; break; } } - jobs_query_capacity -= num; self.add_provider_job = Some(job); } From 695404d56bf51cd86d983e3c699d71bdbd9e87d1 Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Thu, 28 Mar 2024 13:48:08 +0100 Subject: [PATCH 026/246] feat(kad): FIND_NODE for own peer id returns closest peers Fixes https://github.com/libp2p/rust-libp2p/issues/5269. Pull-Request: #5270. --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- libp2p/CHANGELOG.md | 6 ++++++ libp2p/Cargo.toml | 2 +- protocols/kad/CHANGELOG.md | 5 +++++ protocols/kad/Cargo.toml | 2 +- protocols/kad/src/behaviour.rs | 16 ++++++---------- 7 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 671b05ce61c..a48e6570cb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2521,7 +2521,7 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libp2p" -version = "0.53.2" +version = "0.54.0" dependencies = [ "async-std", "async-trait", @@ -2819,7 +2819,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.45.4" +version = "0.46.0" dependencies = [ "arrayvec", "async-std", diff --git a/Cargo.toml b/Cargo.toml index ce33cec2ba0..d0234747e06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,7 +73,7 @@ rust-version = "1.73.0" [workspace.dependencies] asynchronous-codec = { version = "0.7.0" } futures-bounded = { version = "0.2.3" } -libp2p = { version = "0.53.2", path = "libp2p" } +libp2p = { version = "0.54.0", path = "libp2p" } libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" } libp2p-autonat = { version = "0.12.0", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.3.1", path = "misc/connection-limits" } @@ -84,7 +84,7 @@ libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.46.1", path = "protocols/gossipsub" } libp2p-identify = { version = "0.44.2", path = "protocols/identify" } libp2p-identity = { version = "0.2.8" } -libp2p-kad = { version = "0.45.4", path = "protocols/kad" } +libp2p-kad = { version = "0.46.0", path = "protocols/kad" } libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.14.1", path = "misc/metrics" } diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index 80b32c35643..afb7f7444f8 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.54.0 -- unreleased + +- Update individual crates. + - Update to [`libp2p-kad` `v0.46.0`](protocols/kad/CHANGELOG.md#0460). + + ## 0.53.2 - Allow `SwarmBuilder::with_bandwidth_metrics` after `SwarmBuilder::with_websocket`. diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index 9dc9667be10..fcec353e3f6 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p" edition = "2021" rust-version = { workspace = true } description = "Peer-to-peer networking library" -version = "0.53.2" +version = "0.54.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 055dde94234..a6578a5882b 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.46.0 -- unreleased + +- Changed `FIND_NODE` response: now includes a list of closest peers when querying the recipient peer ID. Previously, this request yielded an empty response. + See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270) + ## 0.45.4 - Add periodic and automatic bootstrap. diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index ed7f255ccd8..5b46642d1ea 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-kad" edition = "2021" rust-version = { workspace = true } description = "Kademlia protocol for libp2p" -version = "0.45.4" +version = "0.46.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 6b526edccfe..742ae1e4bd1 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -1180,16 +1180,12 @@ where target: &kbucket::Key, source: &PeerId, ) -> Vec { - if target == self.kbuckets.local_key() { - Vec::new() - } else { - self.kbuckets - .closest(target) - .filter(|e| e.node.key.preimage() != source) - .take(self.queries.config().replication_factor.get()) - .map(KadPeer::from) - .collect() - } + self.kbuckets + .closest(target) + .filter(|e| e.node.key.preimage() != source) + .take(self.queries.config().replication_factor.get()) + .map(KadPeer::from) + .collect() } /// Collects all peers who are known to be providers of the value for a given `Multihash`. From 9805339e384068537b8970031d5b13dff8586a1c Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 29 Mar 2024 12:34:30 +0100 Subject: [PATCH 027/246] feat(dht)!: update republish interval and expiration time defaults This patch applies changes from https://github.com/libp2p/specs/pull/451. In particular, the new defaults are: - Record Expiration: 48h - Record Republish Interval: 22h Closes #3229. Pull-Request: #3230. --- protocols/kad/CHANGELOG.md | 2 ++ protocols/kad/src/behaviour.rs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index a6578a5882b..c300b3127da 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -2,6 +2,8 @@ - Changed `FIND_NODE` response: now includes a list of closest peers when querying the recipient peer ID. Previously, this request yielded an empty response. See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270) +- Update to DHT republish interval and expiration time defaults to 22h and 48h respectively, rationale in [libp2p/specs#451](https://github.com/libp2p/specs/pull/451) + See [PR 3230](https://github.com/libp2p/rust-libp2p/pull/3230) ## 0.45.4 diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 742ae1e4bd1..77ce78da237 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -220,12 +220,12 @@ impl Config { kbucket_pending_timeout: Duration::from_secs(60), query_config: QueryConfig::default(), protocol_config: ProtocolConfig::new(protocol_name), - record_ttl: Some(Duration::from_secs(36 * 60 * 60)), + record_ttl: Some(Duration::from_secs(48 * 60 * 60)), record_replication_interval: Some(Duration::from_secs(60 * 60)), - record_publication_interval: Some(Duration::from_secs(24 * 60 * 60)), + record_publication_interval: Some(Duration::from_secs(22 * 60 * 60)), record_filtering: StoreInserts::Unfiltered, provider_publication_interval: Some(Duration::from_secs(12 * 60 * 60)), - provider_record_ttl: Some(Duration::from_secs(24 * 60 * 60)), + provider_record_ttl: Some(Duration::from_secs(48 * 60 * 60)), kbucket_inserts: BucketInserts::OnConnected, caching: Caching::Enabled { max_peers: 1 }, periodic_bootstrap_interval: Some(Duration::from_secs(5 * 60)), From a5439861447c6bd0cc014ed99fa61e04ab5ade04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:36:04 +0000 Subject: [PATCH 028/246] chore(deps): bump golang.org/x/net from 0.10.0 to 0.17.0 Pull-Request: #5275. --- wasm-tests/webtransport-tests/echo-server/go.mod | 2 +- wasm-tests/webtransport-tests/echo-server/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wasm-tests/webtransport-tests/echo-server/go.mod b/wasm-tests/webtransport-tests/echo-server/go.mod index 12804780d8b..5022d4d2a7b 100644 --- a/wasm-tests/webtransport-tests/echo-server/go.mod +++ b/wasm-tests/webtransport-tests/echo-server/go.mod @@ -55,7 +55,7 @@ require ( golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect golang.org/x/mod v0.10.0 // indirect - golang.org/x/net v0.10.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.7.0 // indirect diff --git a/wasm-tests/webtransport-tests/echo-server/go.sum b/wasm-tests/webtransport-tests/echo-server/go.sum index 61dfda6a67d..4140abf9a53 100644 --- a/wasm-tests/webtransport-tests/echo-server/go.sum +++ b/wasm-tests/webtransport-tests/echo-server/go.sum @@ -251,8 +251,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From 855ff8cbe42bed471a507258849a673e6a3e8cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 29 Mar 2024 16:06:01 +0000 Subject: [PATCH 029/246] chore: raise MSRV to 1.75 To allow merging https://github.com/libp2p/rust-libp2p/pull/5232 CC @SuperFluffy since you commented on https://github.com/libp2p/rust-libp2p/pull/4692 Pull-Request: #5266. --- Cargo.toml | 2 +- hole-punching-tests/Dockerfile | 2 +- interop-tests/Dockerfile.chromium | 2 +- interop-tests/Dockerfile.native | 2 +- libp2p/CHANGELOG.md | 2 ++ 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d0234747e06..6b6c4033aca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ members = [ resolver = "2" [workspace.package] -rust-version = "1.73.0" +rust-version = "1.75.0" [workspace.dependencies] asynchronous-codec = { version = "0.7.0" } diff --git a/hole-punching-tests/Dockerfile b/hole-punching-tests/Dockerfile index 864f058799e..af00ef2272f 100644 --- a/hole-punching-tests/Dockerfile +++ b/hole-punching-tests/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.73.0 as builder +FROM rust:1.75.0 as builder # Run with access to the target cache to speed up builds WORKDIR /workspace diff --git a/interop-tests/Dockerfile.chromium b/interop-tests/Dockerfile.chromium index 5ec46e313aa..04af84fdc46 100644 --- a/interop-tests/Dockerfile.chromium +++ b/interop-tests/Dockerfile.chromium @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.73.0 as chef +FROM rust:1.75.0 as chef RUN rustup target add wasm32-unknown-unknown RUN wget -q -O- https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz | tar -zx -C /usr/local/bin --strip-components 1 --wildcards "wasm-pack-*/wasm-pack" RUN wget -q -O- https://github.com/WebAssembly/binaryen/releases/download/version_115/binaryen-version_115-x86_64-linux.tar.gz | tar -zx -C /usr/local/bin --strip-components 2 --wildcards "binaryen-version_*/bin/wasm-opt" diff --git a/interop-tests/Dockerfile.native b/interop-tests/Dockerfile.native index 91e6cf8893e..b122ac72991 100644 --- a/interop-tests/Dockerfile.native +++ b/interop-tests/Dockerfile.native @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM lukemathwalker/cargo-chef:0.1.62-rust-1.73.0 as chef +FROM lukemathwalker/cargo-chef:0.1.62-rust-1.75.0 as chef WORKDIR /app FROM chef AS planner diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index afb7f7444f8..e7b1f8e4fab 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -3,6 +3,8 @@ - Update individual crates. - Update to [`libp2p-kad` `v0.46.0`](protocols/kad/CHANGELOG.md#0460). +- Raise MSRV to 1.73. + See [PR 5266](https://github.com/libp2p/rust-libp2p/pull/5266). ## 0.53.2 From 098dd0275e656adc9266fd5da3fb34846cf4f0e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:41:56 +0000 Subject: [PATCH 030/246] deps: bump clap from 4.4.16 to 4.5.4 Pull-Request: #5279. --- Cargo.lock | 22 +++++++++++----------- examples/autonat/Cargo.toml | 2 +- examples/dcutr/Cargo.toml | 2 +- examples/file-sharing/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- examples/relay-server/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- protocols/dcutr/Cargo.toml | 2 +- protocols/perf/Cargo.toml | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a48e6570cb1..404165edf75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -920,9 +920,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.16" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e54881c004cec7895b0068a0a954cd5d62da01aef83fa35b1e594497bf5445" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -930,9 +930,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.16" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59cb82d7f531603d2fd1f507441cdd35184fa81beff7bd489570de7f773460bb" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", @@ -942,11 +942,11 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.55", @@ -954,9 +954,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" @@ -5530,9 +5530,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index 642e621c257..99a0a9c99e5 100644 --- a/examples/autonat/Cargo.toml +++ b/examples/autonat/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] tokio = { version = "1.36", features = ["full"] } -clap = { version = "4.4.16", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] } tracing = "0.1.37" diff --git a/examples/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml index 8443e9a59c7..abcb9511f76 100644 --- a/examples/dcutr/Cargo.toml +++ b/examples/dcutr/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -clap = { version = "4.4.16", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" futures-timer = "3.0" libp2p = { path = "../../libp2p", features = [ "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] } diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index 8d20a702718..62987ea1724 100644 --- a/examples/file-sharing/Cargo.toml +++ b/examples/file-sharing/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] serde = { version = "1.0", features = ["derive"] } tokio = { version = "1.36.0", features = ["full"] } -clap = { version = "4.4.16", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "tokio", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } tracing = "0.1.37" diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index 9536d8d1916..442d38511f6 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] tokio = { version = "1.36", features = ["rt-multi-thread", "macros"] } async-trait = "0.1" -clap = { version = "4.4.16", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } env_logger = "0.10" futures = "0.3.30" anyhow = "1.0.81" diff --git a/examples/relay-server/Cargo.toml b/examples/relay-server/Cargo.toml index 65c7c707087..b06b4adc11f 100644 --- a/examples/relay-server/Cargo.toml +++ b/examples/relay-server/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -clap = { version = "4.4.16", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" futures = "0.3.30" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 9fe9e926d76..4ba3457b270 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -13,7 +13,7 @@ publish = false release = false [dependencies] -clap = { version = "4.4.16", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } zeroize = "1" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 3f46de701e2..2f14e534e14 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT" [dependencies] base64 = "0.21" -clap = { version = "4.4.16", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } futures = "0.3" futures-timer = "3" hyper = { version = "0.14", features = ["server", "tcp", "http1"] } diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 8444dc70756..1d29ac22b74 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -29,7 +29,7 @@ futures-bounded = { workspace = true } [dev-dependencies] async-std = { version = "1.12.0", features = ["attributes"] } -clap = { version = "4.4.16", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } libp2p-dns = { workspace = true, features = ["async-std"] } libp2p-identify = { workspace = true } libp2p-noise = { workspace = true } diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 68b1088a42c..1352f756b5d 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] anyhow = "1" -clap = { version = "4.4.16", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" futures-bounded = { workspace = true } futures-timer = "3.0" From a94e94384b59fbeeefecd3c2378ead02288bc968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 29 Mar 2024 20:21:38 +0000 Subject: [PATCH 031/246] fix(upnp): don't panic when gateway is dropped There seems to be a situation when the `Behaviour` and therefore it's `Gateway` is dropped leaving the `tokio` loop to panic. It has been reported on https://github.com/sigp/lighthouse/issues/5498, this attempts to fix it. Cc @dariusc93 can you review this please Darius? Thanks! Pull-Request: #5273. --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/upnp/CHANGELOG.md | 5 +++++ protocols/upnp/Cargo.toml | 2 +- protocols/upnp/src/tokio.rs | 8 ++++---- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 404165edf75..c8b5437cc84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3334,7 +3334,7 @@ dependencies = [ [[package]] name = "libp2p-upnp" -version = "0.2.1" +version = "0.2.2" dependencies = [ "futures", "futures-timer", diff --git a/Cargo.toml b/Cargo.toml index 6b6c4033aca..a8c99e340f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,7 +107,7 @@ libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } libp2p-tcp = { version = "0.41.0", path = "transports/tcp" } libp2p-tls = { version = "0.3.0", path = "transports/tls" } libp2p-uds = { version = "0.40.0", path = "transports/uds" } -libp2p-upnp = { version = "0.2.1", path = "protocols/upnp" } +libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.2.0", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } diff --git a/protocols/upnp/CHANGELOG.md b/protocols/upnp/CHANGELOG.md index ba031264a0f..9472c7153c6 100644 --- a/protocols/upnp/CHANGELOG.md +++ b/protocols/upnp/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.2 +- Fix a panic caused when `upnp::Gateway` is dropped and its events queue receiver is no longer +available. + See [PR 5273](https://github.com/libp2p/rust-libp2p/pull/5273). + ## 0.2.1 - Fix a panic caused when dropping `upnp::Behaviour` such as when used together with `Toggle`. See [PR 5096](https://github.com/libp2p/rust-libp2p/pull/5096). diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index 3119804bf60..0ecc2c84b23 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-upnp" edition = "2021" rust-version = "1.60.0" description = "UPnP support for libp2p transports" -version = "0.2.1" +version = "0.2.2" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] diff --git a/protocols/upnp/src/tokio.rs b/protocols/upnp/src/tokio.rs index 9c8b2cafef9..b2cad6fa5a7 100644 --- a/protocols/upnp/src/tokio.rs +++ b/protocols/upnp/src/tokio.rs @@ -158,10 +158,10 @@ pub(crate) fn search_gateway() -> oneshot::Receiver Date: Mon, 1 Apr 2024 08:41:30 +0000 Subject: [PATCH 032/246] deps: bump lru from 0.12.2 to 0.12.3 Pull-Request: #5219. --- Cargo.lock | 4 ++-- protocols/dcutr/Cargo.toml | 2 +- protocols/identify/Cargo.toml | 2 +- swarm/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8b5437cc84..464a66e2a62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3580,9 +3580,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2c024b41519440580066ba82aab04092b333e09066a5eb86c7c4890df31f22" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ "hashbrown 0.14.3", ] diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 1d29ac22b74..c6975337557 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -24,7 +24,7 @@ quick-protobuf-codec = { workspace = true } thiserror = "1.0" tracing = "0.1.37" void = "1" -lru = "0.12.2" +lru = "0.12.3" futures-bounded = { workspace = true } [dev-dependencies] diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 77d90875dfe..db42f4b9df2 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -18,7 +18,7 @@ futures-bounded = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } -lru = "0.12.2" +lru = "0.12.3" quick-protobuf-codec = { workspace = true } quick-protobuf = "0.8" smallvec = "1.13.2" diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index da4b09487f7..1efb65f1624 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -20,7 +20,7 @@ instant = "0.1.12" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } libp2p-swarm-derive = { workspace = true, optional = true } -lru = "0.12.2" +lru = "0.12.3" multistream-select = { workspace = true } once_cell = "1.19.0" rand = "0.8" From 896344f6bd9f321e3d448ccb1320412e117adde5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:32:01 +0000 Subject: [PATCH 033/246] deps: bump syn from 2.0.55 to 2.0.57 Pull-Request: #5282. --- Cargo.lock | 52 ++++++++++++++++++++--------------------- swarm-derive/Cargo.toml | 2 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 464a66e2a62..c5c071676c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -430,7 +430,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -447,7 +447,7 @@ checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -949,7 +949,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -1215,7 +1215,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -1332,7 +1332,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -1437,7 +1437,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -1673,7 +1673,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -3260,7 +3260,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -4024,7 +4024,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -4235,7 +4235,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -4432,7 +4432,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -4455,7 +4455,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -4974,7 +4974,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.55", + "syn 2.0.57", "walkdir", ] @@ -5235,7 +5235,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -5268,7 +5268,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -5553,7 +5553,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -5603,9 +5603,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" dependencies = [ "proc-macro2", "quote", @@ -5748,7 +5748,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -5850,7 +5850,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -6037,7 +6037,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -6379,7 +6379,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", "wasm-bindgen-shared", ] @@ -6413,7 +6413,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6446,7 +6446,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -7018,7 +7018,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] [[package]] @@ -7038,5 +7038,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.57", ] diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index 0fb2dac8198..153c812e19e 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true [dependencies] heck = "0.5" quote = "1.0" -syn = { version = "2.0.55", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.57", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" # Passing arguments to the docsrs builder in order to properly document cfg's. From ab4f664e0437ce486b0aa3401f6eccaf3bcdb541 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:46:14 +0000 Subject: [PATCH 034/246] deps: bump trybuild from 1.0.90 to 1.0.91 Pull-Request: #5283. --- Cargo.lock | 4 ++-- swarm/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c5c071676c2..39c13831470 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6116,9 +6116,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "trybuild" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aa6f84ec205ebf87fb7a0abdbcd1467fa5af0e86878eb6d888b78ecbb10b6d5" +checksum = "8ad7eb6319ebadebca3dacf1f85a93bc54b73dd81b9036795f73de7ddfe27d5a" dependencies = [ "glob", "once_cell", diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 1efb65f1624..d7e78bf112e 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -54,7 +54,7 @@ libp2p-yamux = { path = "../muxers/yamux" } # Using `pat quickcheck = { workspace = true } void = "1" once_cell = "1.19.0" -trybuild = "1.0.90" +trybuild = "1.0.91" tokio = { version = "1.36.0", features = ["time", "rt", "macros", "rt-multi-thread"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } From c34c48d4e32269fd633eca1a957c7ae7ef436860 Mon Sep 17 00:00:00 2001 From: crazeteam <164632007+crazeteam@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:23:09 +0800 Subject: [PATCH 035/246] docs: fix typos in some comments (#5271) fix typos in some comments --- core/CHANGELOG.md | 2 +- libp2p/CHANGELOG.md | 2 +- protocols/gossipsub/src/behaviour.rs | 2 +- protocols/gossipsub/src/behaviour/tests.rs | 2 +- swarm/CHANGELOG.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index a7cd7fd46b4..73f377a8aa5 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -304,7 +304,7 @@ - Add `From<&PublicKey> for PeerId` (see [PR 2145]). -- Remove `TInEvent` and `TOutEvent` trait paramters on most public types. +- Remove `TInEvent` and `TOutEvent` trait parameters on most public types. `TInEvent` and `TOutEvent` are implied through `THandler` and thus superflucious. Both are removed in favor of a derivation through `THandler` (see [PR 2183]). diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index e7b1f8e4fab..7acd4ab602d 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -1193,7 +1193,7 @@ must not be skipped! - Merged `PeriodicPing` and `PingListen` into one `Ping` behaviour. - `Floodsub` now generates `FloodsubEvent`s instead of direct floodsub messages. - Added `ProtocolsHandler::connection_keep_alive`. If all the handlers return `false`, then the connection to the remote node will automatically be gracefully closed after a few seconds. -- The crate now successfuly compiles for the `wasm32-unknown-unknown` target. +- The crate now successfully compiles for the `wasm32-unknown-unknown` target. - Updated `ring` to version 0.13. - Updated `secp256k1` to version 0.12. - The enum returned by `RawSwarm::peer()` can now return `LocalNode`. This makes it impossible to accidentally attempt to dial the local node. diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index f2515c3c564..6da2aceaa08 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -1297,7 +1297,7 @@ where for id in iwant_msgs { // If we have it and the IHAVE count is not above the threshold, - // foward the message. + // forward the message. if let Some((msg, count)) = self .mcache .get_with_iwant_counts(&id, peer_id) diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index 077a1bd22fb..3cf61f9bb41 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -1146,7 +1146,7 @@ fn test_handle_ihave_subscribed_and_msg_not_cached() { assert!( iwant_exists, - "Expected to send an IWANT control message for unkown message id" + "Expected to send an IWANT control message for unknown message id" ); } diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 3d8e3981c96..75e18a6a5af 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -605,7 +605,7 @@ ## 0.34.0 [2022-02-22] - Rename `ProtocolsHandler` to `ConnectionHandler`. Upgrade should be as simple as renaming all - occurences of `ProtocolsHandler` to `ConnectionHandler` with your favorite text manipulation tool + occurrences of `ProtocolsHandler` to `ConnectionHandler` with your favorite text manipulation tool across your codebase. See [PR 2527]. - Fold `libp2p-core`'s `Network` into `Swarm`. See [PR 2492]. From ad510f3114f6d0bf5691a171ca7d9412d5a3b5c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:12:23 +0000 Subject: [PATCH 036/246] deps: bump web-sys from 0.3.68 to 0.3.69 Pull-Request: #5218. --- Cargo.lock | 4 ++-- transports/webrtc-websys/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/webtransport-websys/Cargo.toml | 2 +- wasm-tests/webtransport-tests/Cargo.toml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 39c13831470..95d84ce526f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6462,9 +6462,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/transports/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index 3c212e195c1..eb41d1fa3d4 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -25,7 +25,7 @@ thiserror = "1" tracing = "0.1.37" wasm-bindgen = { version = "0.2.90" } wasm-bindgen-futures = { version = "0.4.42" } -web-sys = { version = "0.3.68", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] } +web-sys = { version = "0.3.69", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] } [lints] workspace = true diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 0ee6808a3ca..7933eda8566 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -20,7 +20,7 @@ parking_lot = "0.12.1" send_wrapper = "0.6.0" thiserror = "1.0.58" wasm-bindgen = "0.2.90" -web-sys = { version = "0.3.68", features = ["BinaryType", "CloseEvent", "MessageEvent", "WebSocket", "Window", "WorkerGlobalScope"] } +web-sys = { version = "0.3.69", features = ["BinaryType", "CloseEvent", "MessageEvent", "WebSocket", "Window", "WorkerGlobalScope"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index faeb8c24d15..0de0c206401 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -26,7 +26,7 @@ thiserror = "1.0.58" tracing = "0.1.37" wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.42" -web-sys = { version = "0.3.68", features = [ +web-sys = { version = "0.3.69", features = [ "ReadableStreamDefaultReader", "WebTransport", "WebTransportBidirectionalStream", diff --git a/wasm-tests/webtransport-tests/Cargo.toml b/wasm-tests/webtransport-tests/Cargo.toml index 918df42bef7..8b0cb85c3be 100644 --- a/wasm-tests/webtransport-tests/Cargo.toml +++ b/wasm-tests/webtransport-tests/Cargo.toml @@ -20,7 +20,7 @@ multihash = { workspace = true } wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.42" wasm-bindgen-test = "0.3.42" -web-sys = { version = "0.3.68", features = ["Response", "Window"] } +web-sys = { version = "0.3.69", features = ["Response", "Window"] } [lints] workspace = true From 0cc520ba5e1b9fe44f9d964c022e4ffb82525804 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:27:36 +0000 Subject: [PATCH 037/246] deps: bump pin-project-lite from 0.2.13 to 0.2.14 Pull-Request: #5285. --- Cargo.lock | 4 ++-- transports/websocket/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95d84ce526f..a7b50bcd119 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4240,9 +4240,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 473aeb2c8ff..01a094f2e14 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -17,7 +17,7 @@ futures = "0.3.30" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } parking_lot = "0.12.0" -pin-project-lite = "0.2.13" +pin-project-lite = "0.2.14" rw-stream-sink = { workspace = true } soketto = "0.8.0" tracing = "0.1.37" From 1bc6c0710ecfe0c51b69e73560caa9ee9e2a8f3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:41:53 +0000 Subject: [PATCH 038/246] deps: bump async-trait from 0.1.78 to 0.1.79 Pull-Request: #5286. --- Cargo.lock | 4 ++-- swarm-test/Cargo.toml | 2 +- transports/dns/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7b50bcd119..6dd78a37f00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -441,9 +441,9 @@ checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" [[package]] name = "async-trait" -version = "0.1.78" +version = "0.1.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index 3d20ecd625e..8fff18b5d0c 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -async-trait = "0.1.78" +async-trait = "0.1.79" libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-plaintext = { workspace = true } diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index fb176bbd1ad..a6061339197 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-std-resolver = { version = "0.24", optional = true } -async-trait = "0.1.78" +async-trait = "0.1.79" futures = "0.3.30" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } From 6130cd61e67d63d33500ac4da0441ccb70cd527c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:53:31 +0000 Subject: [PATCH 039/246] deps: bump serde_json from 1.0.114 to 1.0.115 Pull-Request: #5287. --- Cargo.lock | 4 ++-- hole-punching-tests/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6dd78a37f00..94e4fe236b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5240,9 +5240,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "indexmap 2.2.1", "itoa", diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index c8e6cde98e0..5b95f3851b2 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -14,5 +14,5 @@ tracing = "0.1.37" redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { version = "1.36.0", features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } -serde_json = "1.0.114" +serde_json = "1.0.115" either = "1.9.0" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 4ba3457b270..4e6aaa8ddfd 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -16,7 +16,7 @@ release = false clap = { version = "4.5.4", features = ["derive"] } zeroize = "1" serde = { version = "1.0.197", features = ["derive"] } -serde_json = "1.0.114" +serde_json = "1.0.115" libp2p-core = { workspace = true } base64 = "0.21.7" libp2p-identity = { workspace = true } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 4fa225dc3cd..ecfd01be945 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -20,7 +20,7 @@ libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } rand = "0.8" serde = { version = "1.0", optional = true} -serde_json = { version = "1.0.114", optional = true } +serde_json = { version = "1.0.115", optional = true } smallvec = "1.13.2" tracing = "0.1.37" void = "1.0.2" From 7580147d675e250d1ae1a38eaecff43e6bc00921 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 15:10:14 +0000 Subject: [PATCH 040/246] deps: bump js-sys from 0.3.68 to 0.3.69 Pull-Request: #5222. --- examples/browser-webrtc/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/webtransport-websys/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index ae86b99e447..c9f8f2707aa 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -34,7 +34,7 @@ tower-http = { version = "0.5.2", features = ["cors"] } mime_guess = "2.0.4" [target.'cfg(target_arch = "wasm32")'.dependencies] -js-sys = "0.3.67" +js-sys = "0.3.69" libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "wasm-bindgen"] } libp2p-webrtc-websys = { workspace = true } tracing-wasm = "0.2.1" diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 7933eda8566..59807509c8b 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] bytes = "1.6.0" futures = "0.3.30" -js-sys = "0.3.67" +js-sys = "0.3.69" libp2p-core = { workspace = true } tracing = "0.1.37" parking_lot = "0.12.1" diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index 0de0c206401..671f377d1d9 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -15,7 +15,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures = "0.3.30" -js-sys = "0.3.67" +js-sys = "0.3.69" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } libp2p-noise = { workspace = true } From 367d2a12bfc8a43c722e6139a98bbbfcd164401d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 15:23:28 +0000 Subject: [PATCH 041/246] deps: bump tokio from 1.36.0 to 1.37.0 Pull-Request: #5288. --- Cargo.lock | 4 ++-- examples/autonat/Cargo.toml | 2 +- examples/browser-webrtc/Cargo.toml | 2 +- examples/chat/Cargo.toml | 2 +- examples/dcutr/Cargo.toml | 2 +- examples/file-sharing/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- examples/ipfs-private/Cargo.toml | 2 +- examples/ping/Cargo.toml | 2 +- examples/rendezvous/Cargo.toml | 2 +- examples/stream/Cargo.toml | 2 +- hole-punching-tests/Cargo.toml | 2 +- interop-tests/Cargo.toml | 2 +- protocols/mdns/Cargo.toml | 4 ++-- protocols/perf/Cargo.toml | 2 +- protocols/rendezvous/Cargo.toml | 2 +- protocols/upnp/Cargo.toml | 2 +- swarm/Cargo.toml | 4 ++-- transports/pnet/Cargo.toml | 2 +- transports/quic/Cargo.toml | 4 ++-- transports/tcp/Cargo.toml | 4 ++-- transports/tls/Cargo.toml | 2 +- transports/uds/Cargo.toml | 2 +- transports/webrtc/Cargo.toml | 4 ++-- 24 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 94e4fe236b4..e8fbfb84274 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5815,9 +5815,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index 99a0a9c99e5..b5c314414f7 100644 --- a/examples/autonat/Cargo.toml +++ b/examples/autonat/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -tokio = { version = "1.36", features = ["full"] } +tokio = { version = "1.37", features = ["full"] } clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] } diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index c9f8f2707aa..ef7fab331a3 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -27,7 +27,7 @@ axum = "0.7.5" libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "tokio"] } libp2p-webrtc = { workspace = true, features = ["tokio"] } rust-embed = { version = "8.3.0", features = ["include-exclude", "interpolate-folder-path"] } -tokio = { version = "1.36", features = ["macros", "net", "rt", "signal"] } +tokio = { version = "1.37", features = ["macros", "net", "rt", "signal"] } tokio-util = { version = "0.7", features = ["compat"] } tower = "0.4" tower-http = { version = "0.5.2", features = ["cors"] } diff --git a/examples/chat/Cargo.toml b/examples/chat/Cargo.toml index a16c930e5b3..4fb0243dd90 100644 --- a/examples/chat/Cargo.toml +++ b/examples/chat/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -tokio = { version = "1.36", features = ["full"] } +tokio = { version = "1.37", features = ["full"] } async-trait = "0.1" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic"] } diff --git a/examples/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml index abcb9511f76..17227586951 100644 --- a/examples/dcutr/Cargo.toml +++ b/examples/dcutr/Cargo.toml @@ -14,7 +14,7 @@ futures = "0.3.30" futures-timer = "3.0" libp2p = { path = "../../libp2p", features = [ "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] } log = "0.4" -tokio = { version = "1.36", features = ["macros", "net", "rt", "signal"] } +tokio = { version = "1.37", features = ["macros", "net", "rt", "signal"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index 62987ea1724..fdade7933cc 100644 --- a/examples/file-sharing/Cargo.toml +++ b/examples/file-sharing/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] serde = { version = "1.0", features = ["derive"] } -tokio = { version = "1.36.0", features = ["full"] } +tokio = { version = "1.37.0", features = ["full"] } clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "tokio", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index 442d38511f6..106faff77b6 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -tokio = { version = "1.36", features = ["rt-multi-thread", "macros"] } +tokio = { version = "1.37", features = ["rt-multi-thread", "macros"] } async-trait = "0.1" clap = { version = "4.5.4", features = ["derive"] } env_logger = "0.10" diff --git a/examples/ipfs-private/Cargo.toml b/examples/ipfs-private/Cargo.toml index daa68cd8f5a..ccfe7484f6a 100644 --- a/examples/ipfs-private/Cargo.toml +++ b/examples/ipfs-private/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -tokio = { version = "1.36", features = ["rt-multi-thread", "macros", "io-std"] } +tokio = { version = "1.37", features = ["rt-multi-thread", "macros", "io-std"] } async-trait = "0.1" either = "1.9" futures = "0.3.30" diff --git a/examples/ping/Cargo.toml b/examples/ping/Cargo.toml index db47e4e2d8e..3ba28b54a5c 100644 --- a/examples/ping/Cargo.toml +++ b/examples/ping/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] futures = "0.3.30" libp2p = { path = "../../libp2p", features = ["noise", "ping", "tcp", "tokio", "yamux"] } -tokio = { version = "1.36.0", features = ["full"] } +tokio = { version = "1.37.0", features = ["full"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/rendezvous/Cargo.toml b/examples/rendezvous/Cargo.toml index edd5b8031a4..14ce7d58012 100644 --- a/examples/rendezvous/Cargo.toml +++ b/examples/rendezvous/Cargo.toml @@ -13,7 +13,7 @@ async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] } -tokio = { version = "1.36", features = ["rt-multi-thread", "macros", "time"] } +tokio = { version = "1.37", features = ["rt-multi-thread", "macros", "time"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/stream/Cargo.toml b/examples/stream/Cargo.toml index 37f84e6ed62..64ca12fbb46 100644 --- a/examples/stream/Cargo.toml +++ b/examples/stream/Cargo.toml @@ -14,7 +14,7 @@ futures = "0.3.29" libp2p = { path = "../../libp2p", features = [ "tokio", "quic"] } libp2p-stream = { path = "../../protocols/stream", version = "0.1.0-alpha" } rand = "0.8" -tokio = { version = "1.36", features = ["full"] } +tokio = { version = "1.37", features = ["full"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 5b95f3851b2..7c372e23bee 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -12,7 +12,7 @@ futures = "0.3.30" libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] } tracing = "0.1.37" redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } -tokio = { version = "1.36.0", features = ["full"] } +tokio = { version = "1.37.0", features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.115" either = "1.9.0" diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 410d3dbce2b..fe6c53a13c2 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -34,7 +34,7 @@ redis = { version = "0.23.3", default-features = false, features = [ rust-embed = "8.3" serde_json = "1" thirtyfour = "=0.32.0-rc.10" # https://github.com/stevepryde/thirtyfour/issues/169 -tokio = { version = "1.36.0", features = ["full"] } +tokio = { version = "1.37.0", features = ["full"] } tower-http = { version = "0.5", features = ["cors", "fs", "trace"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 15c26c34131..3d40e2dfe71 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -22,7 +22,7 @@ libp2p-identity = { workspace = true } rand = "0.8.3" smallvec = "1.13.2" socket2 = { version = "0.5.6", features = ["all"] } -tokio = { version = "1.36", default-features = false, features = ["net", "time"], optional = true} +tokio = { version = "1.37", default-features = false, features = ["net", "time"], optional = true} tracing = "0.1.37" hickory-proto = { version = "0.24.0", default-features = false, features = ["mdns"] } void = "1.0.2" @@ -37,7 +37,7 @@ libp2p-noise = { workspace = true } libp2p-swarm = { workspace = true, features = ["tokio", "async-std"] } libp2p-tcp = { workspace = true, features = ["tokio", "async-io"] } libp2p-yamux = { workspace = true } -tokio = { version = "1.36", default-features = false, features = ["macros", "rt", "rt-multi-thread", "time"] } +tokio = { version = "1.37", default-features = false, features = ["macros", "rt", "rt-multi-thread", "time"] } libp2p-swarm-test = { path = "../../swarm-test" } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 1352f756b5d..599c8c21fb2 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -31,7 +31,7 @@ serde_json = "1.0" thiserror = "1.0" tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tokio = { version = "1.36", default-features = false, features = ["macros", "rt", "rt-multi-thread"] } +tokio = { version = "1.37", default-features = false, features = ["macros", "rt", "rt-multi-thread"] } void = "1" [dev-dependencies] diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index e588c6d7a6b..5c7d69810b3 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -37,7 +37,7 @@ libp2p-swarm-test = { path = "../../swarm-test" } libp2p-tcp = { workspace = true, features = ["tokio"] } libp2p-yamux = { workspace = true } rand = "0.8" -tokio = { version = "1.36", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] } +tokio = { version = "1.37", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index 0ecc2c84b23..d1fec8651d5 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -16,7 +16,7 @@ futures-timer = "3.0.3" igd-next = "0.14.3" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } -tokio = { version = "1.36", default-features = false, features = ["rt"], optional = true } +tokio = { version = "1.37", default-features = false, features = ["rt"], optional = true } tracing = "0.1.37" void = "1.0.2" diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index d7e78bf112e..fc4094f16ab 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -31,7 +31,7 @@ wasm-bindgen-futures = { version = "0.4.42", optional = true } [target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies] async-std = { version = "1.6.2", optional = true } -tokio = { version = "1.36", features = ["rt"], optional = true } +tokio = { version = "1.37", features = ["rt"], optional = true } [features] macros = ["dep:libp2p-swarm-derive"] @@ -55,7 +55,7 @@ quickcheck = { workspace = true } void = "1" once_cell = "1.19.0" trybuild = "1.0.91" -tokio = { version = "1.36.0", features = ["time", "rt", "macros", "rt-multi-thread"] } +tokio = { version = "1.37.0", features = ["time", "rt", "macros", "rt-multi-thread"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [[test]] diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index 43a9da2fba9..294d11af14e 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -27,7 +27,7 @@ libp2p-tcp = { workspace = true, features = ["tokio"] } libp2p-websocket = { workspace = true } libp2p-yamux = { workspace = true } quickcheck = { workspace = true } -tokio = { version = "1.36.0", features = ["full"] } +tokio = { version = "1.37.0", features = ["full"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index ca6fdf6b779..52483cbcccd 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -22,7 +22,7 @@ quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls" rand = "0.8.5" rustls = { version = "0.21.9", default-features = false } thiserror = "1.0.58" -tokio = { version = "1.36.0", default-features = false, features = ["net", "rt", "time"], optional = true } +tokio = { version = "1.37.0", default-features = false, features = ["net", "rt", "time"], optional = true } tracing = "0.1.37" socket2 = "0.5.6" ring = "0.16.20" @@ -46,7 +46,7 @@ libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-yamux = { workspace = true } quickcheck = "1" -tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread", "time"] } +tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread", "time"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [[test]] diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 6fd4aec73fe..9cedec22374 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -19,7 +19,7 @@ libc = "0.2.153" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } socket2 = { version = "0.5.6", features = ["all"] } -tokio = { version = "1.36.0", default-features = false, features = ["net"], optional = true } +tokio = { version = "1.37.0", default-features = false, features = ["net"], optional = true } tracing = "0.1.37" [features] @@ -29,7 +29,7 @@ async-io = ["dep:async-io", "if-watch/smol"] [dev-dependencies] async-std = { version = "1.6.5", features = ["attributes"] } libp2p-identity = { workspace = true, features = ["rand"] } -tokio = { version = "1.36.0", default-features = false, features = ["full"] } +tokio = { version = "1.37.0", default-features = false, features = ["full"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index fd7f1a57409..6fee65f322d 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -33,7 +33,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["ed25519", "rsa", "secp256k1", "ecdsa", "rand"] } libp2p-swarm = { workspace = true, features = ["tokio"] } libp2p-yamux = { workspace = true } -tokio = { version = "1.36.0", features = ["full"] } +tokio = { version = "1.37.0", features = ["full"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index 7b01e0e38d5..b9ae6af7425 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] async-std = { version = "1.6.2", optional = true } libp2p-core = { workspace = true } futures = "0.3.30" -tokio = { version = "1.36", default-features = false, features = ["net"], optional = true } +tokio = { version = "1.37", default-features = false, features = ["net"], optional = true } tracing = "0.1.37" [dev-dependencies] diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index 1bd1bd57a61..883d5c92a6c 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -28,7 +28,7 @@ serde = { version = "1.0", features = ["derive"] } stun = "0.5" thiserror = "1" tinytemplate = "1.2" -tokio = { version = "1.36", features = ["net"], optional = true } +tokio = { version = "1.37", features = ["net"], optional = true } tokio-util = { version = "0.7", features = ["compat"], optional = true } tracing = "0.1.37" webrtc = { version = "0.9.0", optional = true } @@ -39,7 +39,7 @@ pem = ["webrtc?/pem"] [dev-dependencies] libp2p-identity = { workspace = true, features = ["rand"] } -tokio = { version = "1.36", features = ["full"] } +tokio = { version = "1.37", features = ["full"] } quickcheck = "1.0.3" tracing-subscriber = { version = "0.3", features = ["env-filter"] } From 9560261077296ee293701beb2cd57531e15945f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:58:59 +0000 Subject: [PATCH 042/246] deps: bump reqwest from 0.11.27 to 0.12.2 Pull-Request: #5284. --- Cargo.lock | 89 +++++++++++++++++++++++++++++++++++----- interop-tests/Cargo.toml | 2 +- 2 files changed, 79 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8fbfb84274..fa14ee1f847 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1861,6 +1861,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "h2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", + "indexmap 2.2.1", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "1.8.2" @@ -2121,7 +2140,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.24", "http 0.2.9", "http-body 0.4.5", "httparse", @@ -2144,6 +2163,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", + "h2 0.4.3", "http 1.0.0", "http-body 1.0.0", "httparse", @@ -2151,6 +2171,7 @@ dependencies = [ "itoa", "pin-project-lite", "tokio", + "want", ] [[package]] @@ -2181,15 +2202,18 @@ dependencies = [ [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", - "hyper 0.14.27", + "http-body-util", + "hyper 1.1.0", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", ] [[package]] @@ -2199,6 +2223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" dependencies = [ "bytes", + "futures-channel", "futures-util", "http 1.0.0", "http-body 1.0.0", @@ -2206,6 +2231,9 @@ dependencies = [ "pin-project-lite", "socket2 0.5.6", "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -2370,7 +2398,7 @@ dependencies = [ "mime_guess", "rand 0.8.5", "redis", - "reqwest", + "reqwest 0.12.2", "rust-embed", "serde", "serde_json", @@ -4800,17 +4828,15 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", + "h2 0.3.24", "http 0.2.9", "http-body 0.4.5", "hyper 0.14.27", "hyper-rustls", - "hyper-tls", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -4822,7 +4848,6 @@ dependencies = [ "sync_wrapper 0.1.2", "system-configuration", "tokio", - "tokio-native-tls", "tokio-rustls", "tower-service", "url", @@ -4833,6 +4858,48 @@ dependencies = [ "winreg", ] +[[package]] +name = "reqwest" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d66674f2b6fb864665eea7a3c1ac4e3dfacd2fda83cf6f935a612e01b0e3338" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.4.3", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.1.0", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 0.1.2", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "resolv-conf" version = "0.7.0" @@ -5706,7 +5773,7 @@ dependencies = [ "indexmap 2.2.1", "parking_lot", "paste", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "serde_repr", @@ -5944,7 +6011,7 @@ dependencies = [ "axum 0.6.20", "base64 0.21.7", "bytes", - "h2", + "h2 0.3.24", "http 0.2.9", "http-body 0.4.5", "hyper 0.14.27", diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index fe6c53a13c2..5d15fd5a9f0 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -47,7 +47,7 @@ wasm-bindgen = { version = "0.2" } wasm-bindgen-futures = { version = "0.4" } wasm-logger = { version = "0.2.0" } instant = "0.1.12" -reqwest = { version = "0.11", features = ["json"] } +reqwest = { version = "0.12", features = ["json"] } console_error_panic_hook = { version = "0.1.7" } futures-timer = "3.0.3" From 9785dcae9c8634dc6dcd91a07553a9d7b13d8e86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:26:16 +0000 Subject: [PATCH 043/246] deps: bump x509-parser from 0.15.1 to 0.16.0 Pull-Request: #5205. --- Cargo.lock | 114 ++++++++++++++++++++++++++++++++++---- transports/tls/Cargo.toml | 2 +- 2 files changed, 103 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa14ee1f847..84aae921d7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -178,8 +178,24 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" dependencies = [ - "asn1-rs-derive", - "asn1-rs-impl", + "asn1-rs-derive 0.4.0", + "asn1-rs-impl 0.1.0", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ad1373757efa0f70ec53939aabc7152e1591cb485208052993070ac8d2429d" +dependencies = [ + "asn1-rs-derive 0.5.0", + "asn1-rs-impl 0.2.0", "displaydoc", "nom", "num-traits", @@ -197,7 +213,19 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.57", + "synstructure 0.13.1", ] [[package]] @@ -211,6 +239,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.57", +] + [[package]] name = "asn1_der" version = "0.7.6" @@ -1275,7 +1314,21 @@ version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" dependencies = [ - "asn1-rs", + "asn1-rs 0.5.2", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "der-parser" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" +dependencies = [ + "asn1-rs 0.6.1", "displaydoc", "nom", "num-bigint", @@ -3344,7 +3397,7 @@ dependencies = [ "rustls-webpki", "thiserror", "tokio", - "x509-parser", + "x509-parser 0.16.0", "yasna", ] @@ -4008,7 +4061,16 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" dependencies = [ - "asn1-rs", + "asn1-rs 0.5.2", +] + +[[package]] +name = "oid-registry" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c958dd45046245b9c3c2547369bb634eb461670b2e7e0de552905801a648d1d" +dependencies = [ + "asn1-rs 0.6.1", ] [[package]] @@ -4695,7 +4757,7 @@ dependencies = [ "pem", "ring 0.16.20", "time", - "x509-parser", + "x509-parser 0.15.1", "yasna", ] @@ -5703,6 +5765,17 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.57", +] + [[package]] name = "sysinfo" version = "0.29.11" @@ -6624,7 +6697,7 @@ dependencies = [ "byteorder", "cbc", "ccm", - "der-parser", + "der-parser 8.2.0", "hkdf", "hmac 0.12.1", "log", @@ -6645,7 +6718,7 @@ dependencies = [ "tokio", "webrtc-util", "x25519-dalek", - "x509-parser", + "x509-parser 0.15.1", ] [[package]] @@ -7001,18 +7074,35 @@ version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7069fba5b66b9193bd2c5d3d4ff12b839118f6bcbef5328efafafb5395cf63da" dependencies = [ - "asn1-rs", + "asn1-rs 0.5.2", "data-encoding", - "der-parser", + "der-parser 8.2.0", "lazy_static", "nom", - "oid-registry", + "oid-registry 0.6.1", "ring 0.16.20", "rusticata-macros", "thiserror", "time", ] +[[package]] +name = "x509-parser" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" +dependencies = [ + "asn1-rs 0.6.1", + "data-encoding", + "der-parser 9.0.0", + "lazy_static", + "nom", + "oid-registry 0.7.0", + "rusticata-macros", + "thiserror", + "time", +] + [[package]] name = "xml-rs" version = "0.8.17" diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 6fee65f322d..4fed28c64d4 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -17,7 +17,7 @@ rcgen = "0.11.3" ring = "0.16.20" thiserror = "1.0.58" webpki = { version = "0.101.4", package = "rustls-webpki", features = ["std"] } -x509-parser = "0.15.1" +x509-parser = "0.16.0" yasna = "0.5.2" # Exposed dependencies. Breaking changes to these are breaking changes to us. From 3d16353ef972fe072d167bc198cb81c898e9198d Mon Sep 17 00:00:00 2001 From: maqi Date: Wed, 3 Apr 2024 15:39:39 +0800 Subject: [PATCH 044/246] fix(kad): close progress whenever closer in range Pull-Request: #4934. --- protocols/kad/CHANGELOG.md | 2 ++ protocols/kad/src/query/peers/closest.rs | 25 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index c300b3127da..0a561b14448 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -4,6 +4,8 @@ See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270) - Update to DHT republish interval and expiration time defaults to 22h and 48h respectively, rationale in [libp2p/specs#451](https://github.com/libp2p/specs/pull/451) See [PR 3230](https://github.com/libp2p/rust-libp2p/pull/3230) +- QueryClose progress whenever closer in range, instead of having to be the closest. + See [PR 4934](https://github.com/libp2p/rust-libp2p/pull/4934). ## 0.45.4 diff --git a/protocols/kad/src/query/peers/closest.rs b/protocols/kad/src/query/peers/closest.rs index 537da6a9d7d..3ee12b98244 100644 --- a/protocols/kad/src/query/peers/closest.rs +++ b/protocols/kad/src/query/peers/closest.rs @@ -174,6 +174,20 @@ impl ClosestPeersIter { }, } + let mut cur_range = distance; + let num_results = self.config.num_results.get(); + // furthest_peer is the furthest peer in range among the closest_peers + let furthest_peer = self + .closest_peers + .iter() + .enumerate() + .nth(num_results - 1) + .map(|(_, peer)| peer) + .or_else(|| self.closest_peers.iter().last()); + if let Some((dist, _)) = furthest_peer { + cur_range = *dist; + } + // Incorporate the reported closer peers into the iterator. // // The iterator makes progress if: @@ -189,9 +203,16 @@ impl ClosestPeersIter { key, state: PeerState::NotContacted, }; - self.closest_peers.entry(distance).or_insert(peer); - progress = self.closest_peers.keys().next() == Some(&distance) || progress; + let is_first_insert = match self.closest_peers.entry(distance) { + Entry::Occupied(_) => false, + Entry::Vacant(entry) => { + entry.insert(peer); + true + } + }; + + progress = (is_first_insert && distance < cur_range) || progress; } // Update the iterator state. From 6be653faf7310047c5935762702ebddd14ab33b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Wed, 3 Apr 2024 11:34:40 +0100 Subject: [PATCH 045/246] chore(deps): update wasm tests go dependencies group Pull-Request: #5290. --- .../webtransport-tests/echo-server/Dockerfile | 2 +- .../webtransport-tests/echo-server/go.mod | 93 ++++++--- .../webtransport-tests/echo-server/go.sum | 189 ++++++++++++++++-- .../webtransport-tests/echo-server/main.go | 3 +- 4 files changed, 236 insertions(+), 51 deletions(-) diff --git a/wasm-tests/webtransport-tests/echo-server/Dockerfile b/wasm-tests/webtransport-tests/echo-server/Dockerfile index f498e2baa1b..2d973c49041 100644 --- a/wasm-tests/webtransport-tests/echo-server/Dockerfile +++ b/wasm-tests/webtransport-tests/echo-server/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM docker.io/library/golang:1.20 AS builder +FROM docker.io/library/golang:1.22 AS builder WORKDIR /workspace ADD . . RUN CGO_ENABLED=0 go build . diff --git a/wasm-tests/webtransport-tests/echo-server/go.mod b/wasm-tests/webtransport-tests/echo-server/go.mod index 5022d4d2a7b..1df54d5dbea 100644 --- a/wasm-tests/webtransport-tests/echo-server/go.mod +++ b/wasm-tests/webtransport-tests/echo-server/go.mod @@ -1,64 +1,91 @@ module echo-server -go 1.20 +go 1.22 require ( - github.com/libp2p/go-libp2p v0.27.8 - github.com/multiformats/go-multiaddr v0.9.0 + github.com/libp2p/go-libp2p v0.33.1 + github.com/multiformats/go-multiaddr v0.12.2 ) require ( - github.com/benbjohnson/clock v1.3.0 // indirect + github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/containerd/cgroups v1.1.0 // indirect + github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect - github.com/flynn/noise v1.0.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/docker/go-units v0.5.0 // indirect + github.com/elastic/gosigar v0.14.2 // indirect + github.com/flynn/noise v1.1.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect - github.com/golang/mock v1.6.0 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/gopacket v1.1.19 // indirect - github.com/google/pprof v0.0.0-20230405160723-4a4c7d95572b // indirect + github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect + github.com/gorilla/websocket v1.5.1 // indirect + github.com/huin/goupnp v1.3.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-log/v2 v2.5.1 // indirect + github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect - github.com/klauspost/compress v1.16.4 // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/klauspost/compress v1.17.6 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/koron/go-ssdp v0.0.4 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect + github.com/libp2p/go-flow-metrics v0.1.0 // indirect + github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect + github.com/libp2p/go-msgio v0.3.0 // indirect + github.com/libp2p/go-nat v0.2.0 // indirect github.com/libp2p/go-netroute v0.2.1 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/libp2p/go-reuseport v0.4.0 // indirect + github.com/libp2p/go-yamux/v4 v4.0.1 // indirect + github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/minio/sha256-simd v1.0.0 // indirect + github.com/miekg/dns v1.1.58 // indirect + github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect + github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect + github.com/minio/sha256-simd v1.0.1 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.2.0 // indirect + github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect + github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect github.com/multiformats/go-multibase v0.2.0 // indirect - github.com/multiformats/go-multicodec v0.8.1 // indirect - github.com/multiformats/go-multihash v0.2.1 // indirect - github.com/multiformats/go-multistream v0.4.1 // indirect + github.com/multiformats/go-multicodec v0.9.0 // indirect + github.com/multiformats/go-multihash v0.2.3 // indirect + github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect - github.com/onsi/ginkgo/v2 v2.9.2 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/onsi/ginkgo/v2 v2.15.0 // indirect + github.com/opencontainers/runtime-spec v1.2.0 // indirect + github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_model v0.6.0 // indirect + github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/qtls-go1-19 v0.3.3 // indirect - github.com/quic-go/qtls-go1-20 v0.2.3 // indirect - github.com/quic-go/quic-go v0.33.0 // indirect - github.com/quic-go/webtransport-go v0.5.2 // indirect + github.com/quic-go/quic-go v0.42.0 // indirect + github.com/quic-go/webtransport-go v0.6.0 // indirect + github.com/raulk/go-watchdog v1.3.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - go.uber.org/atomic v1.10.0 // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/dig v1.17.1 // indirect + go.uber.org/fx v1.20.1 // indirect + go.uber.org/mock v0.4.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect - golang.org/x/mod v0.10.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.15.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/crypto v0.19.0 // indirect + golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect + golang.org/x/mod v0.15.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sync v0.6.0 // indirect + golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.7.0 // indirect + golang.org/x/tools v0.18.0 // indirect google.golang.org/protobuf v1.33.0 // indirect - lukechampine.com/blake3 v1.1.7 // indirect + lukechampine.com/blake3 v1.2.1 // indirect ) diff --git a/wasm-tests/webtransport-tests/echo-server/go.sum b/wasm-tests/webtransport-tests/echo-server/go.sum index 4140abf9a53..7cb38f3e7e2 100644 --- a/wasm-tests/webtransport-tests/echo-server/go.sum +++ b/wasm-tests/webtransport-tests/echo-server/go.sum @@ -12,6 +12,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= +github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= @@ -19,8 +21,18 @@ github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBT github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE= +github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= +github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= +github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d h1:t5Wuyh53qYyg9eqn4BbnlIT+vmhyww0TatL+zT3uWgI= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -29,26 +41,42 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6Uh github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= +github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4= +github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= +github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg= +github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= @@ -57,6 +85,7 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= @@ -67,27 +96,43 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20230405160723-4a4c7d95572b h1:Qcx5LM0fSiks9uCyFZwDBUasd3lxd1RM0GYpL+Li5o4= github.com/google/pprof v0.0.0-20230405160723-4a4c7d95572b/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 h1:E/LAvt58di64hlYjx7AsNS6C/ysHWYo+2qPCZKTQhRo= +github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.16.4 h1:91KN02FnsOYhuunwU4ssRe8lc2JosWmizWa91B5v1PU= github.com/klauspost/compress v1.16.4/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= +github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= +github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -97,76 +142,139 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= +github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= +github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= github.com/libp2p/go-libp2p v0.27.8 h1:IX5x/4yKwyPQeVS2AXHZ3J4YATM9oHBGH1gBc23jBAI= github.com/libp2p/go-libp2p v0.27.8/go.mod h1:eCFFtd0s5i/EVKR7+5Ki8bM7qwkNW3TPTTSSW9sz8NE= +github.com/libp2p/go-libp2p v0.33.1 h1:tvJl9b9M6nSLBtZSXSguq+/lRhRj2oLRkyhBmQNMFLA= +github.com/libp2p/go-libp2p v0.33.1/go.mod h1:zOUTMjG4I7TXwMndNyOBn/CNtVBLlvBlnxfi+8xzx+E= +github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= +github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= +github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= +github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= +github.com/libp2p/go-nat v0.2.0/go.mod h1:3MJr+GRpRkyT65EpVPBstXLvOlAPzUVlG6Pwg9ohLJk= github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= github.com/libp2p/go-netroute v0.2.1/go.mod h1:hraioZr0fhBjG0ZRXJJ6Zj2IVEVNx6tDTFQfSmcq7mQ= +github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQscQm2s= +github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU= github.com/libp2p/go-yamux/v4 v4.0.0 h1:+Y80dV2Yx/kv7Y7JKu0LECyVdMXm1VUoko+VQ9rBfZQ= +github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ= +github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk= +github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= +github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= +github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c/go.mod h1:0SQS9kMwD2VsyFEB++InYyBJroV/FRmBgcydeSUcJms= +github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= +github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU= +github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc= +github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s= +github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= +github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= +github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= +github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= +github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo= +github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= github.com/multiformats/go-multiaddr v0.9.0 h1:3h4V1LHIk5w4hJHekMKWALPXErDfz/sggzwC/NcqbDQ= github.com/multiformats/go-multiaddr v0.9.0/go.mod h1:mI67Lb1EeTOYb8GQfL/7wpIZwc46ElrvzhYnoJOmTT0= +github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= +github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= +github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= +github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= +github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= +github.com/multiformats/go-multiaddr-fmt v0.1.0/go.mod h1:hGtDIW4PU4BqJ50gW2quDuPVjyWNZxToGUh/HwTZYJo= github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= github.com/multiformats/go-multicodec v0.8.1 h1:ycepHwavHafh3grIbR1jIXnKCsFm0fqsfEOsJ8NtKE8= github.com/multiformats/go-multicodec v0.8.1/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= +github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= +github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= +github.com/multiformats/go-multihash v0.0.8/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108= github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= +github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= +github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo= github.com/multiformats/go-multistream v0.4.1/go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q= +github.com/multiformats/go-multistream v0.5.0 h1:5htLSLl7lvJk3xx3qT/8Zm9J4K8vEOf/QGkvOGQAyiE= +github.com/multiformats/go-multistream v0.5.0/go.mod h1:n6tMZiwiP2wUsR8DgfDWw1dydlEqV3l6N3/GBsX6ILA= +github.com/multiformats/go-varint v0.0.1/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= -github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= -github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= +github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= +github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= +github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= +github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= +github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= +github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= +github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= +github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/qtls-go1-19 v0.3.3 h1:wznEHvJwd+2X3PqftRha0SUKmGsnb6dfArMhy9PeJVE= -github.com/quic-go/qtls-go1-19 v0.3.3/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= -github.com/quic-go/qtls-go1-20 v0.2.3 h1:m575dovXn1y2ATOb1XrRFcrv0F+EQmlowTkoraNkDPI= -github.com/quic-go/qtls-go1-20 v0.2.3/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= -github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA= +github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= +github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= github.com/quic-go/webtransport-go v0.5.2 h1:GA6Bl6oZY+g/flt00Pnu0XtivSD8vukOu3lYhJjnGEk= github.com/quic-go/webtransport-go v0.5.2/go.mod h1:OhmmgJIzTTqXK5xvtuX0oBpLV2GkLWNDA+UeTGJXErU= +github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY= +github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc= +github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= +github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= @@ -188,8 +296,10 @@ github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ= github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -197,47 +307,70 @@ github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= +github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/dig v1.17.1 h1:Tga8Lz8PcYNsWsyHMZ1Vm0OQOUaJNDyvPImgbAu9YSc= +go.uber.org/dig v1.17.1/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= +go.uber.org/fx v1.20.1 h1:zVwVQGS8zYvhh9Xxcu4w1M6ESyeMzebzj2NbSayZ4Mk= +go.uber.org/fx v1.20.1/go.mod h1:iSYNbHf2y55acNCwCXKx7LbWb5WG1Bnue5RDXz1OREg= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= +golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -249,10 +382,15 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -263,22 +401,34 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -287,18 +437,23 @@ golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -340,5 +495,7 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= +lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= +lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/wasm-tests/webtransport-tests/echo-server/main.go b/wasm-tests/webtransport-tests/echo-server/main.go index def4151bd1b..f5e36692bd0 100644 --- a/wasm-tests/webtransport-tests/echo-server/main.go +++ b/wasm-tests/webtransport-tests/echo-server/main.go @@ -12,6 +12,7 @@ import ( "github.com/libp2p/go-libp2p/core/transport" "github.com/libp2p/go-libp2p/p2p/transport/quicreuse" webtransport "github.com/libp2p/go-libp2p/p2p/transport/webtransport" + "github.com/quic-go/quic-go" "github.com/multiformats/go-multiaddr" ) @@ -69,7 +70,7 @@ func main() { panic(err) } - connManager, err := quicreuse.NewConnManager([32]byte{}) + connManager, err := quicreuse.NewConnManager(quic.StatelessResetKey{}, quic.TokenGeneratorKey{}) if err != nil { panic(err) } From 4a61847da9bb1f833a353ae2256d11ce0785587d Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Wed, 3 Apr 2024 17:44:08 +0200 Subject: [PATCH 046/246] fix(kad): moving changelog entries `libp2p-kad` `v0.45.4` won't be released. Moving changes to `v0.46.0`. Pull-Request: #5292. --- protocols/kad/CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 0a561b14448..38809b8aafa 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -6,9 +6,6 @@ See [PR 3230](https://github.com/libp2p/rust-libp2p/pull/3230) - QueryClose progress whenever closer in range, instead of having to be the closest. See [PR 4934](https://github.com/libp2p/rust-libp2p/pull/4934). - -## 0.45.4 - - Add periodic and automatic bootstrap. See [PR 4838](https://github.com/libp2p/rust-libp2p/pull/4838). - Make it mandatory to provide protocol names when creating a `kad::Config`. From 9af02ca0e4ed7eb42335452f84b06945df2ba6f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:25:59 +0000 Subject: [PATCH 047/246] deps: bump base64 from 0.21.7 to 0.22.0 Pull-Request: #5202. --- Cargo.lock | 8 ++++---- identity/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84aae921d7a..6e2a21f740f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2570,7 +2570,7 @@ dependencies = [ name = "keygen" version = "0.1.0" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "clap", "libp2p-core", "libp2p-identity", @@ -2814,7 +2814,7 @@ version = "0.46.1" dependencies = [ "async-std", "asynchronous-codec", - "base64 0.21.7", + "base64 0.22.0", "byteorder", "bytes", "either", @@ -2874,7 +2874,7 @@ name = "libp2p-identity" version = "0.2.8" dependencies = [ "asn1_der", - "base64 0.21.7", + "base64 0.22.0", "bs58", "criterion", "ed25519-dalek", @@ -3268,7 +3268,7 @@ dependencies = [ name = "libp2p-server" version = "0.12.7" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "clap", "futures", "futures-timer", diff --git a/identity/Cargo.toml b/identity/Cargo.toml index 1f025353af5..e4d3b1f4dc2 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -42,7 +42,7 @@ rand = ["dep:rand", "ed25519-dalek?/rand_core"] [dev-dependencies] quickcheck = { workspace = true } -base64 = "0.21.7" +base64 = "0.22.0" serde_json = "1.0" rmp-serde = "1.1" criterion = "0.5" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 4e6aaa8ddfd..cefd28ff6e4 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -18,7 +18,7 @@ zeroize = "1" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.115" libp2p-core = { workspace = true } -base64 = "0.21.7" +base64 = "0.22.0" libp2p-identity = { workspace = true } [lints] diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 2f14e534e14..6f9f37571a7 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -11,7 +11,7 @@ license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -base64 = "0.21" +base64 = "0.22" clap = { version = "4.5.4", features = ["derive"] } futures = "0.3" futures-timer = "3" diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 52ffb675d4b..8615b99f7e5 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -15,7 +15,7 @@ wasm-bindgen = ["getrandom/js", "instant/wasm-bindgen"] [dependencies] asynchronous-codec = { workspace = true } -base64 = "0.21.7" +base64 = "0.22.0" byteorder = "1.5.0" bytes = "1.6" either = "1.9" From 945209a00cafa9353446b89ffd333032468b5691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 4 Apr 2024 15:26:13 +0100 Subject: [PATCH 048/246] fix: update Cargo.lock and address [RUSTSEC-2024-0332](https://rustsec.org/advisories/RUSTSEC-2024-0332). More info [here](https://seanmonstar.com/blog/hyper-http2-continuation-flood/) Pull-Request: #5293. --- Cargo.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e2a21f740f..3a9af41a24f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1897,9 +1897,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -1916,9 +1916,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" dependencies = [ "bytes", "fnv", @@ -2193,7 +2193,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.24", + "h2 0.3.26", "http 0.2.9", "http-body 0.4.5", "httparse", @@ -2216,7 +2216,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.3", + "h2 0.4.4", "http 1.0.0", "http-body 1.0.0", "httparse", @@ -4890,7 +4890,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.3.24", + "h2 0.3.26", "http 0.2.9", "http-body 0.4.5", "hyper 0.14.27", @@ -4931,7 +4931,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.4.3", + "h2 0.4.4", "http 1.0.0", "http-body 1.0.0", "http-body-util", @@ -6084,7 +6084,7 @@ dependencies = [ "axum 0.6.20", "base64 0.21.7", "bytes", - "h2 0.3.24", + "h2 0.3.26", "http 0.2.9", "http-body 0.4.5", "hyper 0.14.27", From 67ebcdeb05c4189db4ff820a974f84779ed3e81d Mon Sep 17 00:00:00 2001 From: joshuef Date: Thu, 4 Apr 2024 23:44:08 +0900 Subject: [PATCH 049/246] feat(kad): only dial if not connected AND not dialing Pull-Request: #4957. --- protocols/kad/CHANGELOG.md | 7 +++++-- protocols/kad/src/behaviour.rs | 9 ++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 38809b8aafa..b2a06dc691c 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -4,6 +4,8 @@ See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270) - Update to DHT republish interval and expiration time defaults to 22h and 48h respectively, rationale in [libp2p/specs#451](https://github.com/libp2p/specs/pull/451) See [PR 3230](https://github.com/libp2p/rust-libp2p/pull/3230) +- Use default dial conditions more consistently. + See [PR 4957](https://github.com/libp2p/rust-libp2p/pull/4957) - QueryClose progress whenever closer in range, instead of having to be the closest. See [PR 4934](https://github.com/libp2p/rust-libp2p/pull/4934). - Add periodic and automatic bootstrap. @@ -67,6 +69,7 @@ --> ## 0.44.5 + - Migrate to `quick-protobuf-codec` crate for codec logic. See [PR 4501]. @@ -192,7 +195,7 @@ - Instead of a single event `OutboundQueryCompleted`, there are now multiple events emitted, allowing the user to process them as they come in (via the new `OutboundQueryProgressed`). See `ProgressStep` to identify the final `OutboundQueryProgressed` of a single query. - To finish a query early, i.e. before the final `OutboundQueryProgressed` of the query, a caller needs to call `query.finish()`. - There is no more automatic caching of records. The user has to manually call `put_record_to` on the `QueryInfo::GetRecord.cache_candidates` to cache a record to a close peer that did not return the record on the foregone query. - See [PR 2712]. + See [PR 2712]. [PR 3085]: https://github.com/libp2p/rust-libp2p/pull/3085 [PR 3011]: https://github.com/libp2p/rust-libp2p/pull/3011 @@ -271,7 +274,7 @@ - Require owned key in `get_record()` method (see [PR 2477]). -- Merge NetworkBehaviour's inject_\* paired methods (see PR 2445). +- Merge NetworkBehaviour's inject\_\* paired methods (see PR 2445). [PR 2477]: https://github.com/libp2p/rust-libp2p/pull/2477 [PR 2445]: https://github.com/libp2p/rust-libp2p/pull/2445 diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 77ce78da237..7f47f93bb39 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -628,9 +628,7 @@ where } kbucket::InsertResult::Pending { disconnected } => { self.queued_events.push_back(ToSwarm::Dial { - opts: DialOpts::peer_id(disconnected.into_preimage()) - .condition(dial_opts::PeerCondition::NotDialing) - .build(), + opts: DialOpts::peer_id(disconnected.into_preimage()).build(), }); RoutingUpdate::Pending } @@ -1375,7 +1373,6 @@ where if !self.connected_peers.contains(disconnected.preimage()) { self.queued_events.push_back(ToSwarm::Dial { opts: DialOpts::peer_id(disconnected.into_preimage()) - .condition(dial_opts::PeerCondition::NotDialing) .build(), }) } @@ -2595,9 +2592,7 @@ where } else if &peer_id != self.kbuckets.local_key().preimage() { query.inner.pending_rpcs.push((peer_id, event)); self.queued_events.push_back(ToSwarm::Dial { - opts: DialOpts::peer_id(peer_id) - .condition(dial_opts::PeerCondition::NotDialing) - .build(), + opts: DialOpts::peer_id(peer_id).build(), }); } } From fdddacc75f70b26e2da24f9e8815eb77a3d6fbdd Mon Sep 17 00:00:00 2001 From: DrHuangMHT Date: Fri, 5 Apr 2024 00:08:59 +0800 Subject: [PATCH 050/246] fix: allow relay to forward unlimited bytes Allow relay to forward unlimited bytes from one peer to another by checking if `max_circuit_bytes` equals to 0 before checking if `bytes_sent` exceeds `max_circuit_bytes`. This will make current implementation follow the spec. May close #5170. Pull-Request: #5244. --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/relay/CHANGELOG.md | 5 +++++ protocols/relay/Cargo.toml | 2 +- protocols/relay/src/copy_future.rs | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a9af41a24f..82280a5e86a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3178,7 +3178,7 @@ dependencies = [ [[package]] name = "libp2p-relay" -version = "0.17.1" +version = "0.17.2" dependencies = [ "asynchronous-codec", "bytes", diff --git a/Cargo.toml b/Cargo.toml index a8c99e340f2..f8645b32123 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,7 +96,7 @@ libp2p-ping = { version = "0.44.0", path = "protocols/ping" } libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } libp2p-quic = { version = "0.10.2", path = "transports/quic" } -libp2p-relay = { version = "0.17.1", path = "protocols/relay" } +libp2p-relay = { version = "0.17.2", path = "protocols/relay" } libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.26.2", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index aaade5e48f9..b88dd7784f2 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.17.2 + +- Fix support for unlimited relay connection according to spec. + See [PR 5244](https://github.com/libp2p/rust-libp2p/pull/5244). + ## 0.17.1 - Automatically register relayed addresses as external addresses. diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 94b9deb1a64..b3e9fe4d8dd 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-relay" edition = "2021" rust-version = { workspace = true } description = "Communications relaying for libp2p" -version = "0.17.1" +version = "0.17.2" authors = ["Parity Technologies ", "Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/relay/src/copy_future.rs b/protocols/relay/src/copy_future.rs index 91415065d2c..c0039c29534 100644 --- a/protocols/relay/src/copy_future.rs +++ b/protocols/relay/src/copy_future.rs @@ -72,7 +72,7 @@ where let this = &mut *self; loop { - if this.bytes_sent > this.max_circuit_bytes { + if this.max_circuit_bytes > 0 && this.bytes_sent > this.max_circuit_bytes { return Poll::Ready(Err(io::Error::new( io::ErrorKind::Other, "Max circuit bytes reached.", From 47e19f7175edb6954bf69bd2a61edaaf4f521ea9 Mon Sep 17 00:00:00 2001 From: DrHuangMHT Date: Fri, 5 Apr 2024 21:38:55 +0800 Subject: [PATCH 051/246] feat(ping): impose `Sync` bound to `ping::Failure::Other` Allow `ping::Event` to be shared between threads, instead of only sending between threads but no sharing. This make it possible to send `ping::Event` through broadcast-style channels, like `tokio::sync::broadcast`. Pull-Request: #5250. --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/ping/CHANGELOG.md | 8 ++++++++ protocols/ping/Cargo.toml | 2 +- protocols/ping/src/handler.rs | 4 ++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82280a5e86a..579416ac740 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3090,7 +3090,7 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.44.0" +version = "0.44.1" dependencies = [ "async-std", "either", diff --git a/Cargo.toml b/Cargo.toml index f8645b32123..c1f39ec74c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" } libp2p-muxer-test-harness = { path = "muxers/test-harness" } libp2p-noise = { version = "0.44.0", path = "transports/noise" } libp2p-perf = { version = "0.3.0", path = "protocols/perf" } -libp2p-ping = { version = "0.44.0", path = "protocols/ping" } +libp2p-ping = { version = "0.44.1", path = "protocols/ping" } libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } libp2p-quic = { version = "0.10.2", path = "transports/quic" } diff --git a/protocols/ping/CHANGELOG.md b/protocols/ping/CHANGELOG.md index 33e0139b996..17338a4ba9a 100644 --- a/protocols/ping/CHANGELOG.md +++ b/protocols/ping/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.44.1 - unreleased + +- Impose `Sync` on `ping::Failure::Other`. + `ping::Event` can now be shared between threads. + See [PR 5250] + +[PR 5250]: https://github.com/libp2p/rust-libp2p/pull/5250 + ## 0.44.0 diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index 5f08ac6fbbd..da67b894963 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-ping" edition = "2021" rust-version = { workspace = true } description = "Ping protocol for libp2p" -version = "0.44.0" +version = "0.44.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/ping/src/handler.rs b/protocols/ping/src/handler.rs index 5e6fc2cd2cf..b9bd25c52ea 100644 --- a/protocols/ping/src/handler.rs +++ b/protocols/ping/src/handler.rs @@ -95,12 +95,12 @@ pub enum Failure { Unsupported, /// The ping failed for reasons other than a timeout. Other { - error: Box, + error: Box, }, } impl Failure { - fn other(e: impl std::error::Error + Send + 'static) -> Self { + fn other(e: impl std::error::Error + Send + Sync + 'static) -> Self { Self::Other { error: Box::new(e) } } } From c92966d7843e5a107dcb77f2fd75166a6039730e Mon Sep 17 00:00:00 2001 From: DrHuangMHT Date: Sun, 7 Apr 2024 00:23:45 +0800 Subject: [PATCH 052/246] deps: Promote tracing to workspace dependency Promote tracing to workspace dependency to make mananging depencencies easier. Pull-Request: #5231. --- Cargo.toml | 1 + core/Cargo.toml | 2 +- examples/autonat/Cargo.toml | 2 +- examples/browser-webrtc/Cargo.toml | 2 +- examples/chat/Cargo.toml | 2 +- examples/dcutr/Cargo.toml | 2 +- examples/distributed-key-value-store/Cargo.toml | 2 +- examples/file-sharing/Cargo.toml | 2 +- examples/identify/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- examples/ipfs-private/Cargo.toml | 2 +- examples/metrics/Cargo.toml | 2 +- examples/ping/Cargo.toml | 2 +- examples/relay-server/Cargo.toml | 2 +- examples/rendezvous/Cargo.toml | 2 +- examples/stream/Cargo.toml | 2 +- hole-punching-tests/Cargo.toml | 2 +- identity/Cargo.toml | 2 +- interop-tests/Cargo.toml | 4 ++-- misc/memory-connection-limits/Cargo.toml | 2 +- misc/multistream-select/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- misc/webrtc-utils/Cargo.toml | 2 +- muxers/mplex/Cargo.toml | 2 +- muxers/test-harness/Cargo.toml | 2 +- muxers/yamux/Cargo.toml | 2 +- protocols/autonat/Cargo.toml | 2 +- protocols/dcutr/Cargo.toml | 2 +- protocols/floodsub/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- protocols/identify/Cargo.toml | 2 +- protocols/kad/Cargo.toml | 2 +- protocols/mdns/Cargo.toml | 2 +- protocols/perf/Cargo.toml | 2 +- protocols/ping/Cargo.toml | 2 +- protocols/relay/Cargo.toml | 2 +- protocols/rendezvous/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- protocols/stream/Cargo.toml | 2 +- protocols/upnp/Cargo.toml | 2 +- swarm-test/Cargo.toml | 2 +- swarm/Cargo.toml | 2 +- transports/dns/Cargo.toml | 2 +- transports/noise/Cargo.toml | 2 +- transports/plaintext/Cargo.toml | 2 +- transports/pnet/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/tcp/Cargo.toml | 2 +- transports/uds/Cargo.toml | 2 +- transports/webrtc-websys/Cargo.toml | 2 +- transports/webrtc/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/websocket/Cargo.toml | 2 +- transports/webtransport-websys/Cargo.toml | 2 +- 54 files changed, 55 insertions(+), 54 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c1f39ec74c5..da05125aa2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -123,6 +123,7 @@ quick-protobuf-codec = { version = "0.3.1", path = "misc/quick-protobuf-codec" } quickcheck = { package = "quickcheck-ext", path = "misc/quickcheck-ext" } rw-stream-sink = { version = "0.4.0", path = "misc/rw-stream-sink" } unsigned-varint = { version = "0.8.0" } +tracing = "0.1.37" [patch.crates-io] diff --git a/core/Cargo.toml b/core/Cargo.toml index 582746d4037..65b7728b7ba 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -29,7 +29,7 @@ rw-stream-sink = { workspace = true } serde = { version = "1", optional = true, features = ["derive"] } smallvec = "1.13.2" thiserror = "1.0" -tracing = "0.1.37" +tracing = { workspace = true } unsigned-varint = { workspace = true } void = "1" diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index b5c314414f7..f128347bf04 100644 --- a/examples/autonat/Cargo.toml +++ b/examples/autonat/Cargo.toml @@ -13,7 +13,7 @@ tokio = { version = "1.37", features = ["full"] } clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index ef7fab331a3..f5a70cfd865 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -19,7 +19,7 @@ crate-type = ["cdylib"] anyhow = "1.0.81" futures = "0.3.30" rand = "0.8" -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/examples/chat/Cargo.toml b/examples/chat/Cargo.toml index 4fb0243dd90..d6f083962f7 100644 --- a/examples/chat/Cargo.toml +++ b/examples/chat/Cargo.toml @@ -13,7 +13,7 @@ tokio = { version = "1.37", features = ["full"] } async-trait = "0.1" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml index 17227586951..3d4d3a5c154 100644 --- a/examples/dcutr/Cargo.toml +++ b/examples/dcutr/Cargo.toml @@ -15,7 +15,7 @@ futures-timer = "3.0" libp2p = { path = "../../libp2p", features = [ "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] } log = "0.4" tokio = { version = "1.37", features = ["macros", "net", "rt", "signal"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/distributed-key-value-store/Cargo.toml b/examples/distributed-key-value-store/Cargo.toml index a7efe3c0697..809a573cc08 100644 --- a/examples/distributed-key-value-store/Cargo.toml +++ b/examples/distributed-key-value-store/Cargo.toml @@ -13,7 +13,7 @@ async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "async-std", "dns", "kad", "mdns", "noise", "macros", "tcp", "yamux"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index fdade7933cc..fdc4c7b26fd 100644 --- a/examples/file-sharing/Cargo.toml +++ b/examples/file-sharing/Cargo.toml @@ -14,7 +14,7 @@ tokio = { version = "1.37.0", features = ["full"] } clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "tokio", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } void = "1.0.2" diff --git a/examples/identify/Cargo.toml b/examples/identify/Cargo.toml index 2dcc780ac22..cf2996e45cd 100644 --- a/examples/identify/Cargo.toml +++ b/examples/identify/Cargo.toml @@ -13,7 +13,7 @@ async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" futures = "0.3.30" libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio","yamux"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index 106faff77b6..d27c68c0e59 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -16,7 +16,7 @@ env_logger = "0.10" futures = "0.3.30" anyhow = "1.0.81" libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "yamux", "rsa"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/ipfs-private/Cargo.toml b/examples/ipfs-private/Cargo.toml index ccfe7484f6a..cf0d2689ced 100644 --- a/examples/ipfs-private/Cargo.toml +++ b/examples/ipfs-private/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" either = "1.9" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "dns", "identify", "kad", "macros", "noise", "ping", "pnet", "tcp", "websocket", "yamux"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index 188121fb7d0..e84b4819897 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -17,7 +17,7 @@ opentelemetry-otlp = { version = "0.15.0", features = ["metrics"] } opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio", "metrics"] } prometheus-client = { workspace = true } tokio = { version = "1", features = ["full"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-opentelemetry = "0.23.0" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/ping/Cargo.toml b/examples/ping/Cargo.toml index 3ba28b54a5c..6c74f4619fd 100644 --- a/examples/ping/Cargo.toml +++ b/examples/ping/Cargo.toml @@ -12,7 +12,7 @@ release = false futures = "0.3.30" libp2p = { path = "../../libp2p", features = ["noise", "ping", "tcp", "tokio", "yamux"] } tokio = { version = "1.37.0", features = ["full"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/relay-server/Cargo.toml b/examples/relay-server/Cargo.toml index b06b4adc11f..664c52351cb 100644 --- a/examples/relay-server/Cargo.toml +++ b/examples/relay-server/Cargo.toml @@ -14,7 +14,7 @@ async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay", "quic"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/rendezvous/Cargo.toml b/examples/rendezvous/Cargo.toml index 14ce7d58012..aecacbd7fa6 100644 --- a/examples/rendezvous/Cargo.toml +++ b/examples/rendezvous/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] } tokio = { version = "1.37", features = ["rt-multi-thread", "macros", "time"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/examples/stream/Cargo.toml b/examples/stream/Cargo.toml index 64ca12fbb46..1e33991f27e 100644 --- a/examples/stream/Cargo.toml +++ b/examples/stream/Cargo.toml @@ -15,7 +15,7 @@ libp2p = { path = "../../libp2p", features = [ "tokio", "quic"] } libp2p-stream = { path = "../../protocols/stream", version = "0.1.0-alpha" } rand = "0.8" tokio = { version = "1.37", features = ["full"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 7c372e23bee..75ed1e31ebe 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -10,7 +10,7 @@ anyhow = "1" env_logger = "0.10.2" futures = "0.3.30" libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] } -tracing = "0.1.37" +tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { version = "1.37.0", features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } diff --git a/identity/Cargo.toml b/identity/Cargo.toml index e4d3b1f4dc2..217044d0fcd 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -17,7 +17,7 @@ bs58 = { version = "0.5.1", optional = true } ed25519-dalek = { version = "2.1", optional = true } hkdf = { version = "0.12.4", optional = true } libsecp256k1 = { version = "0.7.0", optional = true } -tracing = "0.1.37" +tracing = { workspace = true } multihash = { version = "0.19.1", optional = true } p256 = { version = "0.13", default-features = false, features = [ "ecdsa", "std", "pem"], optional = true } quick-protobuf = "0.8.1" diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 5d15fd5a9f0..9bb08682d6f 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -17,7 +17,7 @@ either = "1.9.0" futures = "0.3.30" rand = "0.8.5" serde = { version = "1", features = ["derive"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -36,7 +36,7 @@ serde_json = "1" thirtyfour = "=0.32.0-rc.10" # https://github.com/stevepryde/thirtyfour/issues/169 tokio = { version = "1.37.0", features = ["full"] } tower-http = { version = "0.5", features = ["cors", "fs", "trace"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/misc/memory-connection-limits/Cargo.toml b/misc/memory-connection-limits/Cargo.toml index ae6bb386373..5f8d9b91613 100644 --- a/misc/memory-connection-limits/Cargo.toml +++ b/misc/memory-connection-limits/Cargo.toml @@ -15,7 +15,7 @@ libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true, features = ["peerid"] } sysinfo = "0.29" -tracing = "0.1.37" +tracing = { workspace = true } void = "1" [dev-dependencies] diff --git a/misc/multistream-select/Cargo.toml b/misc/multistream-select/Cargo.toml index 37b5f7753f2..080bd6ee289 100644 --- a/misc/multistream-select/Cargo.toml +++ b/misc/multistream-select/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] bytes = "1" futures = "0.3" -tracing = "0.1.37" +tracing = { workspace = true } pin-project = "1.1.5" smallvec = "1.13.2" unsigned-varint = { workspace = true } diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 6f9f37571a7..74576ad39f5 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -22,7 +22,7 @@ serde = "1.0.197" serde_derive = "1.0.125" serde_json = "1.0" tokio = { version = "1", features = ["rt-multi-thread", "macros"] } -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } zeroize = "1" diff --git a/misc/webrtc-utils/Cargo.toml b/misc/webrtc-utils/Cargo.toml index 7173dedae7b..b28ed74a4b0 100644 --- a/misc/webrtc-utils/Cargo.toml +++ b/misc/webrtc-utils/Cargo.toml @@ -25,7 +25,7 @@ serde = { version = "1.0", features = ["derive"] } sha2 = "0.10.8" thiserror = "1" tinytemplate = "1.2" -tracing = "0.1.37" +tracing = { workspace = true } [dev-dependencies] hex-literal = "0.4" diff --git a/muxers/mplex/Cargo.toml b/muxers/mplex/Cargo.toml index 3ce7dc5c02f..4e612939373 100644 --- a/muxers/mplex/Cargo.toml +++ b/muxers/mplex/Cargo.toml @@ -20,7 +20,7 @@ nohash-hasher = "0.2" parking_lot = "0.12" rand = "0.8" smallvec = "1.13.2" -tracing = "0.1.37" +tracing = { workspace = true } unsigned-varint = { workspace = true, features = ["asynchronous_codec"] } [dev-dependencies] diff --git a/muxers/test-harness/Cargo.toml b/muxers/test-harness/Cargo.toml index bfe1e61b9b6..421292cf0a7 100644 --- a/muxers/test-harness/Cargo.toml +++ b/muxers/test-harness/Cargo.toml @@ -15,7 +15,7 @@ libp2p-core = { workspace = true } futures = "0.3.30" futures-timer = "3.0.3" futures_ringbuf = "0.4.0" -tracing = "0.1.37" +tracing = { workspace = true } [lints] workspace = true diff --git a/muxers/yamux/Cargo.toml b/muxers/yamux/Cargo.toml index 14a5c0fe145..7c36faf022a 100644 --- a/muxers/yamux/Cargo.toml +++ b/muxers/yamux/Cargo.toml @@ -17,7 +17,7 @@ libp2p-core = { workspace = true } thiserror = "1.0" yamux012 = { version = "0.12.1", package = "yamux" } yamux013 = { version = "0.13.1", package = "yamux" } -tracing = "0.1.37" +tracing = { workspace = true } [dev-dependencies] async-std = { version = "1.7.0", features = ["attributes"] } diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index fce64ad0c12..2780016cebd 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -21,7 +21,7 @@ libp2p-request-response = { workspace = true } libp2p-identity = { workspace = true } quick-protobuf = "0.8" rand = "0.8" -tracing = "0.1.37" +tracing = { workspace = true } quick-protobuf-codec = { workspace = true } asynchronous-codec = { workspace = true } diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index c6975337557..414eff4775b 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -22,7 +22,7 @@ libp2p-identity = { workspace = true } quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } thiserror = "1.0" -tracing = "0.1.37" +tracing = { workspace = true } void = "1" lru = "0.12.3" futures-bounded = { workspace = true } diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 98e7cc7fd49..fe1b509735d 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -24,7 +24,7 @@ quick-protobuf-codec = { workspace = true } rand = "0.8" smallvec = "1.13.2" thiserror = "1.0.58" -tracing = "0.1.37" +tracing = { workspace = true } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 8615b99f7e5..22e11180439 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -35,7 +35,7 @@ regex = "1.10.4" serde = { version = "1", optional = true, features = ["derive"] } sha2 = "0.10.8" smallvec = "1.13.2" -tracing = "0.1.37" +tracing = { workspace = true } void = "1.0.2" # Metrics dependencies diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index db42f4b9df2..a794d1e0409 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -23,7 +23,7 @@ quick-protobuf-codec = { workspace = true } quick-protobuf = "0.8" smallvec = "1.13.2" thiserror = "1.0" -tracing = "0.1.37" +tracing = { workspace = true } void = "1.0" either = "1.9.0" diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 5b46642d1ea..fb89337b61e 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -32,7 +32,7 @@ futures-timer = "3.0.3" instant = "0.1.12" serde = { version = "1.0", optional = true, features = ["derive"] } thiserror = "1" -tracing = "0.1.37" +tracing = { workspace = true } [dev-dependencies] async-std = { version = "1.12.0", features = ["attributes"] } diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 3d40e2dfe71..c2dba2cf2f6 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -23,7 +23,7 @@ rand = "0.8.3" smallvec = "1.13.2" socket2 = { version = "0.5.6", features = ["all"] } tokio = { version = "1.37", default-features = false, features = ["net", "time"], optional = true} -tracing = "0.1.37" +tracing = { workspace = true } hickory-proto = { version = "0.24.0", default-features = false, features = ["mdns"] } void = "1.0.2" diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 599c8c21fb2..b73c7d599cb 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -29,7 +29,7 @@ libp2p-yamux = { workspace = true } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" -tracing = "0.1.37" +tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } tokio = { version = "1.37", default-features = false, features = ["macros", "rt", "rt-multi-thread"] } void = "1" diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index da67b894963..5d982c90b7f 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -19,7 +19,7 @@ libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } rand = "0.8" -tracing = "0.1.37" +tracing = { workspace = true } void = "1.0" [dev-dependencies] diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index b3e9fe4d8dd..4183e0facd3 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -26,7 +26,7 @@ quick-protobuf-codec = { workspace = true } rand = "0.8.4" static_assertions = "1" thiserror = "1.0" -tracing = "0.1.37" +tracing = { workspace = true } void = "1" [dev-dependencies] diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index 5c7d69810b3..e2424a9258b 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -25,7 +25,7 @@ quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" thiserror = "1" -tracing = "0.1.37" +tracing = { workspace = true } void = "1" [dev-dependencies] diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index ecfd01be945..c3c43eec286 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -22,7 +22,7 @@ rand = "0.8" serde = { version = "1.0", optional = true} serde_json = { version = "1.0.115", optional = true } smallvec = "1.13.2" -tracing = "0.1.37" +tracing = { workspace = true } void = "1.0.2" futures-timer = "3.0.3" futures-bounded = { workspace = true } diff --git a/protocols/stream/Cargo.toml b/protocols/stream/Cargo.toml index 6a39794c196..f58daff0bb6 100644 --- a/protocols/stream/Cargo.toml +++ b/protocols/stream/Cargo.toml @@ -14,7 +14,7 @@ futures = "0.3.29" libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["peerid"] } libp2p-swarm = { workspace = true } -tracing = "0.1.37" +tracing = { workspace = true } void = "1" rand = "0.8" diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index d1fec8651d5..116941cb75f 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -17,7 +17,7 @@ igd-next = "0.14.3" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } tokio = { version = "1.37", default-features = false, features = ["rt"], optional = true } -tracing = "0.1.37" +tracing = { workspace = true } void = "1.0.2" [features] diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index 8fff18b5d0c..ad7b05264b8 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -21,7 +21,7 @@ libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-yamux = { workspace = true } futures = "0.3.30" rand = "0.8.5" -tracing = "0.1.37" +tracing = { workspace = true } futures-timer = "3.0.3" [lints] diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index fc4094f16ab..3601e03d368 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -25,7 +25,7 @@ multistream-select = { workspace = true } once_cell = "1.19.0" rand = "0.8" smallvec = "1.13.2" -tracing = "0.1.37" +tracing = { workspace = true } void = "1" wasm-bindgen-futures = { version = "0.4.42", optional = true } diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index a6061339197..b06ab6d7d8b 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -19,7 +19,7 @@ libp2p-identity = { workspace = true } parking_lot = "0.12.0" hickory-resolver = { version = "0.24.0", default-features = false, features = ["system-config"] } smallvec = "1.13.2" -tracing = "0.1.37" +tracing = { workspace = true } [dev-dependencies] libp2p-identity = { workspace = true, features = ["rand"] } diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 02bd46550e5..130fce156a9 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -23,7 +23,7 @@ rand = "0.8.3" sha2 = "0.10.8" static_assertions = "1" thiserror = "1.0.58" -tracing = "0.1.37" +tracing = { workspace = true } x25519-dalek = "2" zeroize = "1" diff --git a/transports/plaintext/Cargo.toml b/transports/plaintext/Cargo.toml index e3f1e280851..9a4576ef29f 100644 --- a/transports/plaintext/Cargo.toml +++ b/transports/plaintext/Cargo.toml @@ -17,7 +17,7 @@ futures = "0.3.30" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } quick-protobuf = "0.8" -tracing = "0.1.37" +tracing = { workspace = true } quick-protobuf-codec = { workspace = true } [dev-dependencies] diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index 294d11af14e..e13d9dbd0d4 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] futures = "0.3.30" salsa20 = "0.10" sha3 = "0.10" -tracing = "0.1.37" +tracing = { workspace = true } rand = "0.8" pin-project = "1.1.5" diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 52483cbcccd..f6fad337bb7 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -23,7 +23,7 @@ rand = "0.8.5" rustls = { version = "0.21.9", default-features = false } thiserror = "1.0.58" tokio = { version = "1.37.0", default-features = false, features = ["net", "rt", "time"], optional = true } -tracing = "0.1.37" +tracing = { workspace = true } socket2 = "0.5.6" ring = "0.16.20" diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 9cedec22374..2b6ecf7189b 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -20,7 +20,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true } socket2 = { version = "0.5.6", features = ["all"] } tokio = { version = "1.37.0", default-features = false, features = ["net"], optional = true } -tracing = "0.1.37" +tracing = { workspace = true } [features] tokio = ["dep:tokio", "if-watch/tokio"] diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index b9ae6af7425..b99e869b1df 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -15,7 +15,7 @@ async-std = { version = "1.6.2", optional = true } libp2p-core = { workspace = true } futures = "0.3.30" tokio = { version = "1.37", default-features = false, features = ["net"], optional = true } -tracing = "0.1.37" +tracing = { workspace = true } [dev-dependencies] tempfile = "3.10" diff --git a/transports/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index eb41d1fa3d4..12d825b2ce7 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -22,7 +22,7 @@ libp2p-identity = { workspace = true } libp2p-webrtc-utils = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } thiserror = "1" -tracing = "0.1.37" +tracing = { workspace = true } wasm-bindgen = { version = "0.2.90" } wasm-bindgen-futures = { version = "0.4.42" } web-sys = { version = "0.3.69", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] } diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index 883d5c92a6c..d9d7f8c97d6 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -30,7 +30,7 @@ thiserror = "1" tinytemplate = "1.2" tokio = { version = "1.37", features = ["net"], optional = true } tokio-util = { version = "0.7", features = ["compat"], optional = true } -tracing = "0.1.37" +tracing = { workspace = true } webrtc = { version = "0.9.0", optional = true } [features] diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 59807509c8b..7f3c64a826a 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -15,7 +15,7 @@ bytes = "1.6.0" futures = "0.3.30" js-sys = "0.3.69" libp2p-core = { workspace = true } -tracing = "0.1.37" +tracing = { workspace = true } parking_lot = "0.12.1" send_wrapper = "0.6.0" thiserror = "1.0.58" diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 01a094f2e14..f04c42084c1 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -20,7 +20,7 @@ parking_lot = "0.12.0" pin-project-lite = "0.2.14" rw-stream-sink = { workspace = true } soketto = "0.8.0" -tracing = "0.1.37" +tracing = { workspace = true } url = "2.5" webpki-roots = "0.25" diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index 671f377d1d9..7d844684f0d 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -23,7 +23,7 @@ multiaddr = { workspace = true } multihash = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } thiserror = "1.0.58" -tracing = "0.1.37" +tracing = { workspace = true } wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.42" web-sys = { version = "0.3.69", features = [ From 8027c54c262c6c652df52c7f6ade81f44be34d7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:55:52 +0000 Subject: [PATCH 053/246] deps: bump getrandom from 0.2.12 to 0.2.13 Pull-Request: #5299. --- Cargo.lock | 22 +++++++++++----------- protocols/gossipsub/Cargo.toml | 2 +- swarm/Cargo.toml | 2 +- transports/webrtc-websys/Cargo.toml | 2 +- wasm-tests/webtransport-tests/Cargo.toml | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 579416ac740..b1e21a8408a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1826,9 +1826,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" dependencies = [ "cfg-if", "js-sys", @@ -2611,7 +2611,7 @@ dependencies = [ "either", "futures", "futures-timer", - "getrandom 0.2.12", + "getrandom 0.2.13", "instant", "libp2p-allow-block-list", "libp2p-autonat", @@ -2821,7 +2821,7 @@ dependencies = [ "fnv", "futures", "futures-ticker", - "getrandom 0.2.12", + "getrandom 0.2.13", "hex", "hex_fmt", "instant", @@ -3309,7 +3309,7 @@ dependencies = [ "fnv", "futures", "futures-timer", - "getrandom 0.2.12", + "getrandom 0.2.13", "instant", "libp2p-core", "libp2p-identify", @@ -3484,7 +3484,7 @@ version = "0.3.0-alpha" dependencies = [ "bytes", "futures", - "getrandom 0.2.12", + "getrandom 0.2.13", "hex", "js-sys", "libp2p-core", @@ -4714,7 +4714,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.13", ] [[package]] @@ -4804,7 +4804,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.13", "redox_syscall 0.2.16", "thiserror", ] @@ -5004,7 +5004,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", - "getrandom 0.2.12", + "getrandom 0.2.13", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -6419,7 +6419,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ - "getrandom 0.2.12", + "getrandom 0.2.13", ] [[package]] @@ -6836,7 +6836,7 @@ name = "webtransport-tests" version = "0.1.0" dependencies = [ "futures", - "getrandom 0.2.12", + "getrandom 0.2.13", "libp2p-core", "libp2p-identity", "libp2p-noise", diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 22e11180439..4101a4aa4e9 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -22,7 +22,7 @@ either = "1.9" fnv = "1.0.7" futures = "0.3.30" futures-ticker = "0.0.3" -getrandom = "0.2.12" +getrandom = "0.2.13" hex_fmt = "0.3.0" instant = "0.1.12" libp2p-core = { workspace = true } diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 3601e03d368..90aa57a4d12 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -15,7 +15,7 @@ either = "1.9.0" fnv = "1.0" futures = "0.3.30" futures-timer = "3.0.3" -getrandom = { version = "0.2.12", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature +getrandom = { version = "0.2.13", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature instant = "0.1.12" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } diff --git a/transports/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index 12d825b2ce7..0099851f4d5 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -14,7 +14,7 @@ publish = true [dependencies] bytes = "1" futures = "0.3" -getrandom = { version = "0.2.12", features = ["js"] } +getrandom = { version = "0.2.13", features = ["js"] } hex = "0.4.3" js-sys = { version = "0.3" } libp2p-core = { workspace = true } diff --git a/wasm-tests/webtransport-tests/Cargo.toml b/wasm-tests/webtransport-tests/Cargo.toml index 8b0cb85c3be..11b85910833 100644 --- a/wasm-tests/webtransport-tests/Cargo.toml +++ b/wasm-tests/webtransport-tests/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] futures = "0.3.30" -getrandom = { version = "0.2.12", features = ["js"] } +getrandom = { version = "0.2.13", features = ["js"] } libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-noise = { workspace = true } From 16e52487627e66b15d31b2a24b78e209f12d804d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:10:35 +0000 Subject: [PATCH 054/246] deps: bump syn from 2.0.57 to 2.0.58 Pull-Request: #5300. --- Cargo.lock | 58 ++++++++++++++++++++--------------------- swarm-derive/Cargo.toml | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1e21a8408a..2d3bef6b5be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", "synstructure 0.13.1", ] @@ -247,7 +247,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -469,7 +469,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -486,7 +486,7 @@ checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -988,7 +988,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -1254,7 +1254,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -1385,7 +1385,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -1490,7 +1490,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -1726,7 +1726,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -3341,7 +3341,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -4114,7 +4114,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -4325,7 +4325,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -4522,7 +4522,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -4545,7 +4545,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5103,7 +5103,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.57", + "syn 2.0.58", "walkdir", ] @@ -5364,7 +5364,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5397,7 +5397,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5682,7 +5682,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5732,9 +5732,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.57" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -5773,7 +5773,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5888,7 +5888,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -5990,7 +5990,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -6177,7 +6177,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -6519,7 +6519,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -6553,7 +6553,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6586,7 +6586,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7175,7 +7175,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] [[package]] @@ -7195,5 +7195,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.57", + "syn 2.0.58", ] diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index 153c812e19e..6396dd3f052 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true [dependencies] heck = "0.5" quote = "1.0" -syn = { version = "2.0.57", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.58", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" # Passing arguments to the docsrs builder in order to properly document cfg's. From f1df03e0ccec720882b5e6d501f57c3f862b9cb0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:23:10 +0000 Subject: [PATCH 055/246] deps: bump thirtyfour from 0.32.0-rc.10 to 0.32.0 Pull-Request: #5301. --- Cargo.lock | 144 +++++++++++++++++++++------------------ interop-tests/Cargo.toml | 2 +- 2 files changed, 77 insertions(+), 69 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2d3bef6b5be..ef8fd9df004 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1736,7 +1736,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28" dependencies = [ "futures-io", - "rustls", + "rustls 0.21.9", ] [[package]] @@ -2229,16 +2229,19 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.2" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ "futures-util", - "http 0.2.9", - "hyper 0.14.27", - "rustls", + "http 1.0.0", + "hyper 1.1.0", + "hyper-util", + "rustls 0.22.3", + "rustls-pki-types", "tokio", "tokio-rustls", + "tower-service", ] [[package]] @@ -2451,7 +2454,7 @@ dependencies = [ "mime_guess", "rand 0.8.5", "redis", - "reqwest 0.12.2", + "reqwest", "rust-embed", "serde", "serde_json", @@ -3168,7 +3171,7 @@ dependencies = [ "quinn", "rand 0.8.5", "ring 0.16.20", - "rustls", + "rustls 0.21.9", "socket2 0.5.6", "thiserror", "tokio", @@ -3393,8 +3396,8 @@ dependencies = [ "libp2p-yamux", "rcgen", "ring 0.16.20", - "rustls", - "rustls-webpki", + "rustls 0.21.9", + "rustls-webpki 0.101.7", "thiserror", "tokio", "x509-parser 0.16.0", @@ -3517,7 +3520,7 @@ dependencies = [ "soketto", "tracing", "url", - "webpki-roots", + "webpki-roots 0.25.2", ] [[package]] @@ -4610,7 +4613,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls", + "rustls 0.21.9", "thiserror", "tokio", "tracing", @@ -4626,7 +4629,7 @@ dependencies = [ "rand 0.8.5", "ring 0.16.20", "rustc-hash", - "rustls", + "rustls 0.21.9", "slab", "thiserror", "tinyvec", @@ -4879,47 +4882,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.9", - "http-body 0.4.5", - "hyper 0.14.27", - "hyper-rustls", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration", - "tokio", - "tokio-rustls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", - "winreg", -] - [[package]] name = "reqwest" version = "0.12.2" @@ -4936,6 +4898,7 @@ dependencies = [ "http-body 1.0.0", "http-body-util", "hyper 1.1.0", + "hyper-rustls", "hyper-tls", "hyper-util", "ipnet", @@ -4946,7 +4909,9 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls 0.22.3", "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", @@ -4954,11 +4919,13 @@ dependencies = [ "system-configuration", "tokio", "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.26.1", "winreg", ] @@ -5183,10 +5150,24 @@ checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" dependencies = [ "log", "ring 0.17.5", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +dependencies = [ + "log", + "ring 0.17.5", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + [[package]] name = "rustls-pemfile" version = "1.0.3" @@ -5196,6 +5177,12 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pki-types" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -5206,6 +5193,17 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring 0.17.5", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -5665,18 +5663,18 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" -version = "0.25.0" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.25.3" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ "heck 0.4.1", "proc-macro2", @@ -5835,18 +5833,18 @@ dependencies = [ [[package]] name = "thirtyfour" -version = "0.32.0-rc.10" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc8d557d4ac49c0d0bf13722bf7414506ef50b28ac40894400dcd0b8ed25c4d" +checksum = "0641fa1353dd7b7864a7a7782e495433de18a9096bc91b5a2d5838ac209c2fa8" dependencies = [ "async-trait", - "base64 0.21.7", + "base64 0.22.0", "futures", "http 1.0.0", "indexmap 2.2.1", "parking_lot", "paste", - "reqwest 0.11.27", + "reqwest", "serde", "serde_json", "serde_repr", @@ -6005,11 +6003,12 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls", + "rustls 0.22.3", + "rustls-pki-types", "tokio", ] @@ -6626,6 +6625,15 @@ version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "webrtc" version = "0.9.0" @@ -6647,7 +6655,7 @@ dependencies = [ "ring 0.16.20", "rtcp", "rtp", - "rustls", + "rustls 0.21.9", "sdp", "serde", "serde_json", @@ -6708,7 +6716,7 @@ dependencies = [ "rand_core 0.6.4", "rcgen", "ring 0.16.20", - "rustls", + "rustls 0.21.9", "sec1", "serde", "sha1", diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 9bb08682d6f..4d162c5786a 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -33,7 +33,7 @@ redis = { version = "0.23.3", default-features = false, features = [ ] } rust-embed = "8.3" serde_json = "1" -thirtyfour = "=0.32.0-rc.10" # https://github.com/stevepryde/thirtyfour/issues/169 +thirtyfour = "=0.32.0" # https://github.com/stevepryde/thirtyfour/issues/169 tokio = { version = "1.37.0", features = ["full"] } tower-http = { version = "0.5", features = ["cors", "fs", "trace"] } tracing = { workspace = true } From 9bb2a871939ded657d380cc2b7beb519840f3e8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:33:36 +0000 Subject: [PATCH 056/246] deps: bump reqwest from 0.12.2 to 0.12.3 Pull-Request: #5302. --- Cargo.lock | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef8fd9df004..b3b796c031d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2488,7 +2488,7 @@ dependencies = [ "socket2 0.5.6", "widestring", "windows-sys 0.48.0", - "winreg", + "winreg 0.50.0", ] [[package]] @@ -4884,11 +4884,11 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d66674f2b6fb864665eea7a3c1ac4e3dfacd2fda83cf6f935a612e01b0e3338" +checksum = "3e6cc1e89e689536eb5aeede61520e874df5a4707df811cd5da4aa5fbb2aae19" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "bytes", "encoding_rs", "futures-core", @@ -4926,7 +4926,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots 0.26.1", - "winreg", + "winreg 0.52.0", ] [[package]] @@ -5170,11 +5170,12 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", + "rustls-pki-types", ] [[package]] @@ -7064,6 +7065,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "x25519-dalek" version = "2.0.1" From 042174ebfda46ebba605015ded9314ea3699801a Mon Sep 17 00:00:00 2001 From: DrHuangMHT Date: Fri, 12 Apr 2024 07:29:34 +0800 Subject: [PATCH 057/246] deps: move libp2p-server and metrics example to use axum 0.7 Move from `hyper` to `axum` for `libp2p-server` and metrics example. Running in parallel with #5038. Pull-Request: #5246. --- Cargo.lock | 4 +- examples/metrics/Cargo.toml | 2 +- examples/metrics/src/http_service.rs | 113 +++++++----------------- misc/server/Cargo.toml | 2 +- misc/server/src/http_service.rs | 125 ++++++++------------------- 5 files changed, 72 insertions(+), 174 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b3b796c031d..eeed878cb39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3271,11 +3271,11 @@ dependencies = [ name = "libp2p-server" version = "0.12.7" dependencies = [ + "axum 0.7.5", "base64 0.22.0", "clap", "futures", "futures-timer", - "hyper 0.14.27", "libp2p", "prometheus-client", "serde", @@ -3748,8 +3748,8 @@ dependencies = [ name = "metrics-example" version = "0.1.0" dependencies = [ + "axum 0.7.5", "futures", - "hyper 0.14.27", "libp2p", "opentelemetry", "opentelemetry-otlp", diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index e84b4819897..5059bc4085b 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] futures = "0.3.30" -hyper = { version = "0.14", features = ["server", "tcp", "http1"] } +axum = "0.7" libp2p = { path = "../../libp2p", features = ["tokio", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] } opentelemetry = { version = "0.22.0", features = ["metrics"] } opentelemetry-otlp = { version = "0.15.0", features = ["metrics"] } diff --git a/examples/metrics/src/http_service.rs b/examples/metrics/src/http_service.rs index 8c77d724ea3..4a9c9785bb3 100644 --- a/examples/metrics/src/http_service.rs +++ b/examples/metrics/src/http_service.rs @@ -18,109 +18,60 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use hyper::http::StatusCode; -use hyper::service::Service; -use hyper::{Body, Method, Request, Response, Server}; +use axum::extract::State; +use axum::http::StatusCode; +use axum::response::IntoResponse; +use axum::routing::get; +use axum::Router; use prometheus_client::encoding::text::encode; use prometheus_client::registry::Registry; -use std::future::Future; -use std::pin::Pin; +use std::net::SocketAddr; use std::sync::{Arc, Mutex}; -use std::task::{Context, Poll}; +use tokio::net::TcpListener; const METRICS_CONTENT_TYPE: &str = "application/openmetrics-text;charset=utf-8;version=1.0.0"; pub(crate) async fn metrics_server(registry: Registry) -> Result<(), std::io::Error> { // Serve on localhost. - let addr = ([127, 0, 0, 1], 0).into(); - - let server = Server::bind(&addr).serve(MakeMetricService::new(registry)); - tracing::info!(metrics_server=%format!("http://{}/metrics", server.local_addr())); - if let Err(e) = server.await { - tracing::error!("server error: {}", e); - } + let addr: SocketAddr = ([127, 0, 0, 1], 0).into(); + let service = MetricService::new(registry); + let server = Router::new() + .route("/metrics", get(respond_with_metrics)) + .with_state(service); + let tcp_listener = TcpListener::bind(addr).await?; + let local_addr = tcp_listener.local_addr()?; + tracing::info!(metrics_server=%format!("http://{}/metrics", local_addr)); + axum::serve(tcp_listener, server.into_make_service()).await?; Ok(()) } +#[derive(Clone)] pub(crate) struct MetricService { reg: Arc>, } -type SharedRegistry = Arc>; - -impl MetricService { - fn get_reg(&mut self) -> SharedRegistry { - Arc::clone(&self.reg) - } - fn respond_with_metrics(&mut self) -> Response { - let mut response: Response = Response::default(); - - response.headers_mut().insert( - hyper::header::CONTENT_TYPE, - METRICS_CONTENT_TYPE.try_into().unwrap(), - ); - - let reg = self.get_reg(); - encode(&mut response.body_mut(), ®.lock().unwrap()).unwrap(); - - *response.status_mut() = StatusCode::OK; - - response - } - fn respond_with_404_not_found(&mut self) -> Response { - Response::builder() - .status(StatusCode::NOT_FOUND) - .body("Not found try localhost:[port]/metrics".to_string()) - .unwrap() - } -} - -impl Service> for MetricService { - type Response = Response; - type Error = hyper::Error; - type Future = Pin> + Send>>; - - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } +async fn respond_with_metrics(state: State) -> impl IntoResponse { + let mut sink = String::new(); + let reg = state.get_reg(); + encode(&mut sink, ®.lock().unwrap()).unwrap(); - fn call(&mut self, req: Request) -> Self::Future { - let req_path = req.uri().path(); - let req_method = req.method(); - let resp = if (req_method == Method::GET) && (req_path == "/metrics") { - // Encode and serve metrics from registry. - self.respond_with_metrics() - } else { - self.respond_with_404_not_found() - }; - Box::pin(async { Ok(resp) }) - } + ( + StatusCode::OK, + [(axum::http::header::CONTENT_TYPE, METRICS_CONTENT_TYPE)], + sink, + ) } -pub(crate) struct MakeMetricService { - reg: SharedRegistry, -} +type SharedRegistry = Arc>; -impl MakeMetricService { - pub(crate) fn new(registry: Registry) -> MakeMetricService { - MakeMetricService { +impl MetricService { + fn new(registry: Registry) -> Self { + Self { reg: Arc::new(Mutex::new(registry)), } } -} - -impl Service for MakeMetricService { - type Response = MetricService; - type Error = hyper::Error; - type Future = Pin> + Send>>; - - fn poll_ready(&mut self, _: &mut Context) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, _: T) -> Self::Future { - let reg = self.reg.clone(); - let fut = async move { Ok(MetricService { reg }) }; - Box::pin(fut) + fn get_reg(&self) -> SharedRegistry { + Arc::clone(&self.reg) } } diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 74576ad39f5..14c29b3ebb9 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -15,7 +15,7 @@ base64 = "0.22" clap = { version = "4.5.4", features = ["derive"] } futures = "0.3" futures-timer = "3" -hyper = { version = "0.14", features = ["server", "tcp", "http1"] } +axum = "0.7" libp2p = { workspace = true, features = ["autonat", "dns", "tokio", "noise", "tcp", "yamux", "identify", "kad", "ping", "relay", "metrics", "rsa", "macros", "quic", "websocket"] } prometheus-client = { workspace = true } serde = "1.0.197" diff --git a/misc/server/src/http_service.rs b/misc/server/src/http_service.rs index 7905933fbf5..cee1aa96e28 100644 --- a/misc/server/src/http_service.rs +++ b/misc/server/src/http_service.rs @@ -18,115 +18,62 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use hyper::http::StatusCode; -use hyper::service::Service; -use hyper::{Body, Method, Request, Response, Server}; +use axum::extract::State; +use axum::http::StatusCode; +use axum::response::IntoResponse; +use axum::routing::get; +use axum::Router; use prometheus_client::encoding::text::encode; use prometheus_client::registry::Registry; -use std::future::Future; -use std::pin::Pin; +use std::net::SocketAddr; use std::sync::{Arc, Mutex}; -use std::task::{Context, Poll}; +use tokio::net::TcpListener; const METRICS_CONTENT_TYPE: &str = "application/openmetrics-text;charset=utf-8;version=1.0.0"; pub(crate) async fn metrics_server( registry: Registry, metrics_path: String, -) -> Result<(), hyper::Error> { +) -> Result<(), std::io::Error> { // Serve on localhost. - let addr = ([0, 0, 0, 0], 8888).into(); - - let server = Server::bind(&addr).serve(MakeMetricService::new(registry, metrics_path.clone())); - tracing::info!(metrics_server=%format!("http://{}{}", server.local_addr(), metrics_path)); - server.await?; + let addr: SocketAddr = ([0, 0, 0, 0], 8888).into(); + let service = MetricService::new(registry); + let server = Router::new() + .route(&metrics_path, get(respond_with_metrics)) + .with_state(service); + let tcp_listener = TcpListener::bind(addr).await?; + let local_addr = tcp_listener.local_addr()?; + tracing::info!(metrics_server=%format!("http://{}{}", local_addr, metrics_path)); + axum::serve(tcp_listener, server.into_make_service()).await?; Ok(()) } -pub(crate) struct MetricService { - reg: Arc>, - metrics_path: String, -} -type SharedRegistry = Arc>; +async fn respond_with_metrics(state: State) -> impl IntoResponse { + let mut sink = String::new(); + let reg = state.get_reg(); + encode(&mut sink, ®.lock().unwrap()).unwrap(); -impl MetricService { - fn get_reg(&mut self) -> SharedRegistry { - Arc::clone(&self.reg) - } - fn respond_with_metrics(&mut self) -> Response { - let mut response: Response = Response::default(); - - response.headers_mut().insert( - hyper::header::CONTENT_TYPE, - METRICS_CONTENT_TYPE.try_into().unwrap(), - ); - - let reg = self.get_reg(); - encode(&mut response.body_mut(), ®.lock().unwrap()).unwrap(); - - *response.status_mut() = StatusCode::OK; - - response - } - fn respond_with_404_not_found(&mut self) -> Response { - Response::builder() - .status(StatusCode::NOT_FOUND) - .body(format!( - "Not found try localhost:[port]/{}", - self.metrics_path - )) - .unwrap() - } + ( + StatusCode::OK, + [(axum::http::header::CONTENT_TYPE, METRICS_CONTENT_TYPE)], + sink, + ) } -impl Service> for MetricService { - type Response = Response; - type Error = hyper::Error; - type Future = Pin> + Send>>; - - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - - fn call(&mut self, req: Request) -> Self::Future { - let req_path = req.uri().path(); - let req_method = req.method(); - let resp = if (req_method == Method::GET) && (req_path == self.metrics_path) { - // Encode and serve metrics from registry. - self.respond_with_metrics() - } else { - self.respond_with_404_not_found() - }; - Box::pin(async { Ok(resp) }) - } +#[derive(Clone)] +pub(crate) struct MetricService { + reg: Arc>, } -pub(crate) struct MakeMetricService { - reg: SharedRegistry, - metrics_path: String, -} +type SharedRegistry = Arc>; -impl MakeMetricService { - pub(crate) fn new(registry: Registry, metrics_path: String) -> MakeMetricService { - MakeMetricService { - reg: Arc::new(Mutex::new(registry)), - metrics_path, +impl MetricService { + fn new(reg: Registry) -> Self { + Self { + reg: Arc::new(Mutex::new(reg)), } } -} - -impl Service for MakeMetricService { - type Response = MetricService; - type Error = hyper::Error; - type Future = Pin> + Send>>; - fn poll_ready(&mut self, _: &mut Context) -> Poll> { - Poll::Ready(Ok(())) - } - - fn call(&mut self, _: T) -> Self::Future { - let reg = self.reg.clone(); - let metrics_path = self.metrics_path.clone(); - let fut = async move { Ok(MetricService { reg, metrics_path }) }; - Box::pin(fut) + fn get_reg(&self) -> SharedRegistry { + Arc::clone(&self.reg) } } From bec3037398643733b1ac974e5fbf9b67c3e4752d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 09:03:48 +0000 Subject: [PATCH 058/246] deps: bump quote from 1.0.35 to 1.0.36 Pull-Request: #5307. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eeed878cb39..8e4628a1b11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4651,9 +4651,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] From c1891bc0771618f95e3bab1e1b976a5b7ccc21fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 09:22:57 +0000 Subject: [PATCH 059/246] deps: bump async-trait from 0.1.79 to 0.1.80 Pull-Request: #5308. --- Cargo.lock | 4 ++-- swarm-test/Cargo.toml | 2 +- transports/dns/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e4628a1b11..79f0a1834bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -480,9 +480,9 @@ checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" [[package]] name = "async-trait" -version = "0.1.79" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index ad7b05264b8..0ea404fad7f 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -async-trait = "0.1.79" +async-trait = "0.1.80" libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-plaintext = { workspace = true } diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index b06ab6d7d8b..750317b307d 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-std-resolver = { version = "0.24", optional = true } -async-trait = "0.1.79" +async-trait = "0.1.80" futures = "0.3.30" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } From ec9767acf969ca560af1491ee65cfd9a8929352c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 09:41:57 +0000 Subject: [PATCH 060/246] deps: bump syn from 2.0.58 to 2.0.59 Pull-Request: #5309. --- Cargo.lock | 62 ++++++++++++++++++++--------------------- swarm-derive/Cargo.toml | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79f0a1834bf..00c9a73ecfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", "synstructure 0.13.1", ] @@ -247,7 +247,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -469,7 +469,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -486,7 +486,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -988,7 +988,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1254,7 +1254,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1385,7 +1385,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1490,7 +1490,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1726,7 +1726,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -3344,7 +3344,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -4117,7 +4117,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -4328,7 +4328,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -4498,9 +4498,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" dependencies = [ "unicode-ident", ] @@ -4525,7 +4525,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -4548,7 +4548,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -5070,7 +5070,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.58", + "syn 2.0.59", "walkdir", ] @@ -5363,7 +5363,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -5396,7 +5396,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -5681,7 +5681,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -5731,9 +5731,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ "proc-macro2", "quote", @@ -5772,7 +5772,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -5887,7 +5887,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -5989,7 +5989,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -6177,7 +6177,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -6519,7 +6519,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", "wasm-bindgen-shared", ] @@ -6553,7 +6553,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6586,7 +6586,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -7194,7 +7194,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -7214,5 +7214,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index 6396dd3f052..072efcf0b9b 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true [dependencies] heck = "0.5" quote = "1.0" -syn = { version = "2.0.58", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.59", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" # Passing arguments to the docsrs builder in order to properly document cfg's. From c504eef7678956895548475191b922a4bd22dcb8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 09:54:11 +0000 Subject: [PATCH 061/246] deps: bump proc-macro2 from 1.0.79 to 1.0.80 Pull-Request: #5311. From bee8199c0db79e2b621e3a076ed09ece65337553 Mon Sep 17 00:00:00 2001 From: DrHuangMHT Date: Mon, 15 Apr 2024 18:09:18 +0800 Subject: [PATCH 062/246] deps: promote tokio to workspace dependency Promote `tokio` to workspace dependency. Pull-Request: #5251. --- Cargo.toml | 1 + examples/autonat/Cargo.toml | 2 +- examples/browser-webrtc/Cargo.toml | 2 +- examples/chat/Cargo.toml | 2 +- examples/dcutr/Cargo.toml | 2 +- examples/file-sharing/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- examples/ipfs-private/Cargo.toml | 2 +- examples/metrics/Cargo.toml | 2 +- examples/ping/Cargo.toml | 2 +- examples/rendezvous/Cargo.toml | 2 +- examples/stream/Cargo.toml | 2 +- examples/upnp/Cargo.toml | 2 +- hole-punching-tests/Cargo.toml | 2 +- interop-tests/Cargo.toml | 2 +- libp2p/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- protocols/mdns/Cargo.toml | 4 ++-- protocols/perf/Cargo.toml | 2 +- protocols/rendezvous/Cargo.toml | 2 +- protocols/stream/Cargo.toml | 2 +- protocols/upnp/Cargo.toml | 2 +- swarm/Cargo.toml | 4 ++-- transports/dns/Cargo.toml | 2 +- transports/dns/src/lib.rs | 2 +- transports/pnet/Cargo.toml | 2 +- transports/quic/Cargo.toml | 4 ++-- transports/tcp/Cargo.toml | 4 ++-- transports/tls/Cargo.toml | 2 +- transports/uds/Cargo.toml | 2 +- transports/webrtc/Cargo.toml | 4 ++-- 31 files changed, 36 insertions(+), 35 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index da05125aa2c..796daaae0b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -123,6 +123,7 @@ quick-protobuf-codec = { version = "0.3.1", path = "misc/quick-protobuf-codec" } quickcheck = { package = "quickcheck-ext", path = "misc/quickcheck-ext" } rw-stream-sink = { version = "0.4.0", path = "misc/rw-stream-sink" } unsigned-varint = { version = "0.8.0" } +tokio = { version = "1.37", default-features = false } tracing = "0.1.37" [patch.crates-io] diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index f128347bf04..89cc951c4c8 100644 --- a/examples/autonat/Cargo.toml +++ b/examples/autonat/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -tokio = { version = "1.37", features = ["full"] } +tokio = { workspace = true, features = ["full"] } clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] } diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index f5a70cfd865..fc4adfc1560 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -27,7 +27,7 @@ axum = "0.7.5" libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "tokio"] } libp2p-webrtc = { workspace = true, features = ["tokio"] } rust-embed = { version = "8.3.0", features = ["include-exclude", "interpolate-folder-path"] } -tokio = { version = "1.37", features = ["macros", "net", "rt", "signal"] } +tokio = { workspace = true, features = ["macros", "net", "rt", "signal"] } tokio-util = { version = "0.7", features = ["compat"] } tower = "0.4" tower-http = { version = "0.5.2", features = ["cors"] } diff --git a/examples/chat/Cargo.toml b/examples/chat/Cargo.toml index d6f083962f7..0c7241eae52 100644 --- a/examples/chat/Cargo.toml +++ b/examples/chat/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -tokio = { version = "1.37", features = ["full"] } +tokio = { workspace = true, features = ["full"] } async-trait = "0.1" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic"] } diff --git a/examples/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml index 3d4d3a5c154..497a9dc11ae 100644 --- a/examples/dcutr/Cargo.toml +++ b/examples/dcutr/Cargo.toml @@ -14,7 +14,7 @@ futures = "0.3.30" futures-timer = "3.0" libp2p = { path = "../../libp2p", features = [ "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] } log = "0.4" -tokio = { version = "1.37", features = ["macros", "net", "rt", "signal"] } +tokio = { workspace = true, features = ["macros", "net", "rt", "signal"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index fdc4c7b26fd..f364b9305c9 100644 --- a/examples/file-sharing/Cargo.toml +++ b/examples/file-sharing/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] serde = { version = "1.0", features = ["derive"] } -tokio = { version = "1.37.0", features = ["full"] } +tokio = { workspace = true, features = ["full"] } clap = { version = "4.5.4", features = ["derive"] } futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "tokio", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index d27c68c0e59..2dbaa21365a 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -tokio = { version = "1.37", features = ["rt-multi-thread", "macros"] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } async-trait = "0.1" clap = { version = "4.5.4", features = ["derive"] } env_logger = "0.10" diff --git a/examples/ipfs-private/Cargo.toml b/examples/ipfs-private/Cargo.toml index cf0d2689ced..05798ea82c2 100644 --- a/examples/ipfs-private/Cargo.toml +++ b/examples/ipfs-private/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -tokio = { version = "1.37", features = ["rt-multi-thread", "macros", "io-std"] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros", "io-std"] } async-trait = "0.1" either = "1.9" futures = "0.3.30" diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index 5059bc4085b..f3119b0f0fa 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -16,7 +16,7 @@ opentelemetry = { version = "0.22.0", features = ["metrics"] } opentelemetry-otlp = { version = "0.15.0", features = ["metrics"] } opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio", "metrics"] } prometheus-client = { workspace = true } -tokio = { version = "1", features = ["full"] } +tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } tracing-opentelemetry = "0.23.0" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/ping/Cargo.toml b/examples/ping/Cargo.toml index 6c74f4619fd..d712f482f03 100644 --- a/examples/ping/Cargo.toml +++ b/examples/ping/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] futures = "0.3.30" libp2p = { path = "../../libp2p", features = ["noise", "ping", "tcp", "tokio", "yamux"] } -tokio = { version = "1.37.0", features = ["full"] } +tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/rendezvous/Cargo.toml b/examples/rendezvous/Cargo.toml index aecacbd7fa6..8ce668a98be 100644 --- a/examples/rendezvous/Cargo.toml +++ b/examples/rendezvous/Cargo.toml @@ -13,7 +13,7 @@ async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] } -tokio = { version = "1.37", features = ["rt-multi-thread", "macros", "time"] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros", "time"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/stream/Cargo.toml b/examples/stream/Cargo.toml index 1e33991f27e..37a511d857f 100644 --- a/examples/stream/Cargo.toml +++ b/examples/stream/Cargo.toml @@ -14,7 +14,7 @@ futures = "0.3.29" libp2p = { path = "../../libp2p", features = [ "tokio", "quic"] } libp2p-stream = { path = "../../protocols/stream", version = "0.1.0-alpha" } rand = "0.8" -tokio = { version = "1.37", features = ["full"] } +tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/upnp/Cargo.toml b/examples/upnp/Cargo.toml index db9825c8742..20c1323c7d6 100644 --- a/examples/upnp/Cargo.toml +++ b/examples/upnp/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -tokio = { version = "1", features = ["rt-multi-thread", "macros"] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } futures = "0.3.30" libp2p = { path = "../../libp2p", features = ["tokio", "dns", "macros", "noise", "ping", "tcp", "yamux", "upnp"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 75ed1e31ebe..0a64de1956d 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -12,7 +12,7 @@ futures = "0.3.30" libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] } tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } -tokio = { version = "1.37.0", features = ["full"] } +tokio = { workspace = true, features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.115" either = "1.9.0" diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 4d162c5786a..4749e808a70 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -34,7 +34,7 @@ redis = { version = "0.23.3", default-features = false, features = [ rust-embed = "8.3" serde_json = "1" thirtyfour = "=0.32.0" # https://github.com/stevepryde/thirtyfour/issues/169 -tokio = { version = "1.37.0", features = ["full"] } +tokio = { workspace = true, features = ["full"] } tower-http = { version = "0.5", features = ["cors", "fs", "trace"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index fcec353e3f6..12b895894ab 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -140,7 +140,7 @@ libp2p-websocket = { workspace = true, optional = true } async-std = { version = "1.6.2", features = ["attributes"] } async-trait = "0.1" clap = { version = "4.1.6", features = ["derive"] } -tokio = { version = "1.15", features = [ "io-util", "io-std", "macros", "rt", "rt-multi-thread"] } +tokio = { workspace = true, features = [ "io-util", "io-std", "macros", "rt", "rt-multi-thread"] } libp2p-mplex = { workspace = true } libp2p-noise = { workspace = true } diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 14c29b3ebb9..d744a2f9a08 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -21,7 +21,7 @@ prometheus-client = { workspace = true } serde = "1.0.197" serde_derive = "1.0.125" serde_json = "1.0" -tokio = { version = "1", features = ["rt-multi-thread", "macros"] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } zeroize = "1" diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index c2dba2cf2f6..af8f555156a 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -22,7 +22,7 @@ libp2p-identity = { workspace = true } rand = "0.8.3" smallvec = "1.13.2" socket2 = { version = "0.5.6", features = ["all"] } -tokio = { version = "1.37", default-features = false, features = ["net", "time"], optional = true} +tokio = { workspace = true, default-features = false, features = ["net", "time"], optional = true} tracing = { workspace = true } hickory-proto = { version = "0.24.0", default-features = false, features = ["mdns"] } void = "1.0.2" @@ -37,7 +37,7 @@ libp2p-noise = { workspace = true } libp2p-swarm = { workspace = true, features = ["tokio", "async-std"] } libp2p-tcp = { workspace = true, features = ["tokio", "async-io"] } libp2p-yamux = { workspace = true } -tokio = { version = "1.37", default-features = false, features = ["macros", "rt", "rt-multi-thread", "time"] } +tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread", "time"] } libp2p-swarm-test = { path = "../../swarm-test" } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index b73c7d599cb..655f7e13658 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -31,7 +31,7 @@ serde_json = "1.0" thiserror = "1.0" tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tokio = { version = "1.37", default-features = false, features = ["macros", "rt", "rt-multi-thread"] } +tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread"] } void = "1" [dev-dependencies] diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index e2424a9258b..609ea207bae 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -37,7 +37,7 @@ libp2p-swarm-test = { path = "../../swarm-test" } libp2p-tcp = { workspace = true, features = ["tokio"] } libp2p-yamux = { workspace = true } rand = "0.8" -tokio = { version = "1.37", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] } +tokio = { workspace = true, features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/protocols/stream/Cargo.toml b/protocols/stream/Cargo.toml index f58daff0bb6..964d69027f1 100644 --- a/protocols/stream/Cargo.toml +++ b/protocols/stream/Cargo.toml @@ -20,7 +20,7 @@ rand = "0.8" [dev-dependencies] libp2p-swarm-test = { workspace = true } -tokio = { version = "1", features = ["full"] } +tokio = { workspace = true, features = ["full"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index 116941cb75f..a73f955ae62 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -16,7 +16,7 @@ futures-timer = "3.0.3" igd-next = "0.14.3" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } -tokio = { version = "1.37", default-features = false, features = ["rt"], optional = true } +tokio = { workspace = true, default-features = false, features = ["rt"], optional = true } tracing = { workspace = true } void = "1.0.2" diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 90aa57a4d12..e846e4251d8 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -31,7 +31,7 @@ wasm-bindgen-futures = { version = "0.4.42", optional = true } [target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies] async-std = { version = "1.6.2", optional = true } -tokio = { version = "1.37", features = ["rt"], optional = true } +tokio = { workspace = true, features = ["rt"], optional = true } [features] macros = ["dep:libp2p-swarm-derive"] @@ -55,7 +55,7 @@ quickcheck = { workspace = true } void = "1" once_cell = "1.19.0" trybuild = "1.0.91" -tokio = { version = "1.37.0", features = ["time", "rt", "macros", "rt-multi-thread"] } +tokio = { workspace = true, features = ["time", "rt", "macros", "rt-multi-thread"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [[test]] diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index 750317b307d..d35d87da075 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -23,7 +23,7 @@ tracing = { workspace = true } [dev-dependencies] libp2p-identity = { workspace = true, features = ["rand"] } -tokio-crate = { package = "tokio", version = "1.0", default-features = false, features = ["rt", "time"] } +tokio = { workspace = true, features = ["rt", "time"] } async-std-crate = { package = "async-std", version = "1.6" } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/transports/dns/src/lib.rs b/transports/dns/src/lib.rs index a0fdaf53bdf..505a91f0791 100644 --- a/transports/dns/src/lib.rs +++ b/transports/dns/src/lib.rs @@ -777,7 +777,7 @@ mod tests { // type record lookups may not work with the system DNS resolver. let config = ResolverConfig::quad9(); let opts = ResolverOpts::default(); - let rt = tokio_crate::runtime::Builder::new_current_thread() + let rt = ::tokio::runtime::Builder::new_current_thread() .enable_io() .enable_time() .build() diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index e13d9dbd0d4..bb8b1c03f6f 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -27,7 +27,7 @@ libp2p-tcp = { workspace = true, features = ["tokio"] } libp2p-websocket = { workspace = true } libp2p-yamux = { workspace = true } quickcheck = { workspace = true } -tokio = { version = "1.37.0", features = ["full"] } +tokio = { workspace = true, features = ["full"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index f6fad337bb7..1d283aeef45 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -22,7 +22,7 @@ quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls" rand = "0.8.5" rustls = { version = "0.21.9", default-features = false } thiserror = "1.0.58" -tokio = { version = "1.37.0", default-features = false, features = ["net", "rt", "time"], optional = true } +tokio = { workspace = true, default-features = false, features = ["net", "rt", "time"], optional = true } tracing = { workspace = true } socket2 = "0.5.6" ring = "0.16.20" @@ -46,7 +46,7 @@ libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-yamux = { workspace = true } quickcheck = "1" -tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread", "time"] } +tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [[test]] diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 2b6ecf7189b..b074e8e8b22 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -19,7 +19,7 @@ libc = "0.2.153" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } socket2 = { version = "0.5.6", features = ["all"] } -tokio = { version = "1.37.0", default-features = false, features = ["net"], optional = true } +tokio = { workspace = true, default-features = false, features = ["net"], optional = true } tracing = { workspace = true } [features] @@ -29,7 +29,7 @@ async-io = ["dep:async-io", "if-watch/smol"] [dev-dependencies] async-std = { version = "1.6.5", features = ["attributes"] } libp2p-identity = { workspace = true, features = ["rand"] } -tokio = { version = "1.37.0", default-features = false, features = ["full"] } +tokio = { workspace = true, features = ["full"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 4fed28c64d4..bd0ef91279c 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -33,7 +33,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["ed25519", "rsa", "secp256k1", "ecdsa", "rand"] } libp2p-swarm = { workspace = true, features = ["tokio"] } libp2p-yamux = { workspace = true } -tokio = { version = "1.37.0", features = ["full"] } +tokio = { workspace = true, features = ["full"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index b99e869b1df..84df8dc569e 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] async-std = { version = "1.6.2", optional = true } libp2p-core = { workspace = true } futures = "0.3.30" -tokio = { version = "1.37", default-features = false, features = ["net"], optional = true } +tokio = { workspace = true, default-features = false, features = ["net"], optional = true } tracing = { workspace = true } [dev-dependencies] diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index d9d7f8c97d6..4a7c94ab1ca 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -28,7 +28,7 @@ serde = { version = "1.0", features = ["derive"] } stun = "0.5" thiserror = "1" tinytemplate = "1.2" -tokio = { version = "1.37", features = ["net"], optional = true } +tokio = { workspace = true, features = ["net"], optional = true } tokio-util = { version = "0.7", features = ["compat"], optional = true } tracing = { workspace = true } webrtc = { version = "0.9.0", optional = true } @@ -39,7 +39,7 @@ pem = ["webrtc?/pem"] [dev-dependencies] libp2p-identity = { workspace = true, features = ["rand"] } -tokio = { version = "1.37", features = ["full"] } +tokio = { workspace = true, features = ["full"] } quickcheck = "1.0.3" tracing-subscriber = { version = "0.3", features = ["env-filter"] } From 33ac975d0ffc7db50b410692714024a6691311d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 09:26:47 +0000 Subject: [PATCH 063/246] deps: bump getrandom from 0.2.13 to 0.2.14 Pull-Request: #5310. --- Cargo.lock | 22 +++++++++++----------- protocols/gossipsub/Cargo.toml | 2 +- swarm/Cargo.toml | 2 +- transports/webrtc-websys/Cargo.toml | 2 +- wasm-tests/webtransport-tests/Cargo.toml | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00c9a73ecfc..af75b3f307e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1826,9 +1826,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -2614,7 +2614,7 @@ dependencies = [ "either", "futures", "futures-timer", - "getrandom 0.2.13", + "getrandom 0.2.14", "instant", "libp2p-allow-block-list", "libp2p-autonat", @@ -2824,7 +2824,7 @@ dependencies = [ "fnv", "futures", "futures-ticker", - "getrandom 0.2.13", + "getrandom 0.2.14", "hex", "hex_fmt", "instant", @@ -3312,7 +3312,7 @@ dependencies = [ "fnv", "futures", "futures-timer", - "getrandom 0.2.13", + "getrandom 0.2.14", "instant", "libp2p-core", "libp2p-identify", @@ -3487,7 +3487,7 @@ version = "0.3.0-alpha" dependencies = [ "bytes", "futures", - "getrandom 0.2.13", + "getrandom 0.2.14", "hex", "js-sys", "libp2p-core", @@ -4717,7 +4717,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.13", + "getrandom 0.2.14", ] [[package]] @@ -4807,7 +4807,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.13", + "getrandom 0.2.14", "redox_syscall 0.2.16", "thiserror", ] @@ -4971,7 +4971,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", - "getrandom 0.2.13", + "getrandom 0.2.14", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -6419,7 +6419,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ - "getrandom 0.2.13", + "getrandom 0.2.14", ] [[package]] @@ -6845,7 +6845,7 @@ name = "webtransport-tests" version = "0.1.0" dependencies = [ "futures", - "getrandom 0.2.13", + "getrandom 0.2.14", "libp2p-core", "libp2p-identity", "libp2p-noise", diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 4101a4aa4e9..aec1712be61 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -22,7 +22,7 @@ either = "1.9" fnv = "1.0.7" futures = "0.3.30" futures-ticker = "0.0.3" -getrandom = "0.2.13" +getrandom = "0.2.14" hex_fmt = "0.3.0" instant = "0.1.12" libp2p-core = { workspace = true } diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index e846e4251d8..3b1e0979e81 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -15,7 +15,7 @@ either = "1.9.0" fnv = "1.0" futures = "0.3.30" futures-timer = "3.0.3" -getrandom = { version = "0.2.13", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature +getrandom = { version = "0.2.14", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature instant = "0.1.12" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } diff --git a/transports/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index 0099851f4d5..b5682a7c7da 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -14,7 +14,7 @@ publish = true [dependencies] bytes = "1" futures = "0.3" -getrandom = { version = "0.2.13", features = ["js"] } +getrandom = { version = "0.2.14", features = ["js"] } hex = "0.4.3" js-sys = { version = "0.3" } libp2p-core = { workspace = true } diff --git a/wasm-tests/webtransport-tests/Cargo.toml b/wasm-tests/webtransport-tests/Cargo.toml index 11b85910833..f50a3909bd0 100644 --- a/wasm-tests/webtransport-tests/Cargo.toml +++ b/wasm-tests/webtransport-tests/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] futures = "0.3.30" -getrandom = { version = "0.2.13", features = ["js"] } +getrandom = { version = "0.2.14", features = ["js"] } libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-noise = { workspace = true } From 9a6eccd4b3315848205063a7b2367270d02dc24f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 21:58:06 +0000 Subject: [PATCH 064/246] deps: bump either from 1.9.0 to 1.11.0 Pull-Request: #5320. --- Cargo.lock | 4 ++-- core/Cargo.toml | 2 +- examples/ipfs-private/Cargo.toml | 2 +- hole-punching-tests/Cargo.toml | 2 +- interop-tests/Cargo.toml | 2 +- protocols/dcutr/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- protocols/identify/Cargo.toml | 2 +- protocols/kad/Cargo.toml | 2 +- protocols/ping/Cargo.toml | 2 +- protocols/relay/Cargo.toml | 2 +- swarm/Cargo.toml | 4 ++-- transports/websocket/Cargo.toml | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af75b3f307e..455bd9d99e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1447,9 +1447,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "elliptic-curve" diff --git a/core/Cargo.toml b/core/Cargo.toml index 65b7728b7ba..554d0091866 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -either = "1.9" +either = "1.11" fnv = "1.0" futures = { version = "0.3.30", features = ["executor", "thread-pool"] } futures-timer = "3" diff --git a/examples/ipfs-private/Cargo.toml b/examples/ipfs-private/Cargo.toml index 05798ea82c2..7b017111d26 100644 --- a/examples/ipfs-private/Cargo.toml +++ b/examples/ipfs-private/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] tokio = { workspace = true, features = ["rt-multi-thread", "macros", "io-std"] } async-trait = "0.1" -either = "1.9" +either = "1.11" futures = "0.3.30" libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "dns", "identify", "kad", "macros", "noise", "ping", "pnet", "tcp", "websocket", "yamux"] } tracing = { workspace = true } diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 0a64de1956d..129adca499a 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -15,4 +15,4 @@ redis = { version = "0.23.0", default-features = false, features = ["tokio-comp" tokio = { workspace = true, features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.115" -either = "1.9.0" +either = "1.11.0" diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 4749e808a70..6e6ba028847 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] anyhow = "1" -either = "1.9.0" +either = "1.11.0" futures = "0.3.30" rand = "0.8.5" serde = { version = "1", features = ["derive"] } diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 414eff4775b..10322fb63da 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] asynchronous-codec = { workspace = true } -either = "1.9.0" +either = "1.11.0" futures = "0.3.30" futures-timer = "3.0" instant = "0.1.12" diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index aec1712be61..830866150ac 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -18,7 +18,7 @@ asynchronous-codec = { workspace = true } base64 = "0.22.0" byteorder = "1.5.0" bytes = "1.6" -either = "1.9" +either = "1.11" fnv = "1.0.7" futures = "0.3.30" futures-ticker = "0.0.3" diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index a794d1e0409..16cfef4a05a 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -25,7 +25,7 @@ smallvec = "1.13.2" thiserror = "1.0" tracing = { workspace = true } void = "1.0" -either = "1.9.0" +either = "1.11.0" [dev-dependencies] async-std = { version = "1.6.2", features = ["attributes"] } diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index fb89337b61e..3d2739c6004 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] arrayvec = "0.7.4" bytes = "1" -either = "1.9" +either = "1.11" fnv = "1.0" asynchronous-codec = { workspace = true } futures = "0.3.30" diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index 5d982c90b7f..0a07b403260 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -either = "1.9.0" +either = "1.11.0" futures = "0.3.30" futures-timer = "3.0.3" instant = "0.1.12" diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 4183e0facd3..750f5550dde 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] asynchronous-codec = { workspace = true } bytes = "1" -either = "1.9.0" +either = "1.11.0" futures = "0.3.30" futures-timer = "3" futures-bounded = { workspace = true } diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 3b1e0979e81..10749def335 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -either = "1.9.0" +either = "1.11.0" fnv = "1.0" futures = "0.3.30" futures-timer = "3.0.3" @@ -41,7 +41,7 @@ wasm-bindgen = ["dep:wasm-bindgen-futures", "dep:getrandom"] [dev-dependencies] async-std = { version = "1.6.2", features = ["attributes"] } -either = "1.9.0" +either = "1.11.0" futures = "0.3.30" libp2p-identify = { path = "../protocols/identify" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. libp2p-identity = { workspace = true, features = ["ed25519"] } diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index f04c42084c1..5327d6577b3 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures-rustls = "0.24.0" -either = "1.9.0" +either = "1.11.0" futures = "0.3.30" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } From 31457f61731d93bb3a5b90a9d46319138b420695 Mon Sep 17 00:00:00 2001 From: DrHuangMHT Date: Fri, 19 Apr 2024 15:40:23 +0800 Subject: [PATCH 065/246] feat(kad): derive Copy for kbucket::key::Key Derive `Copy` for `kbucket::key::Key` and `kbucket::key::KeyBytes` because `Key` is almost always used with `PeerId`, which is `Copy`. This will make it easier to iterate over kbuckets. Pull-Request: #5317. --- protocols/kad/CHANGELOG.md | 2 + protocols/kad/src/behaviour.rs | 10 ++--- protocols/kad/src/kbucket.rs | 18 +++----- protocols/kad/src/kbucket/bucket.rs | 41 +++++-------------- protocols/kad/src/kbucket/key.rs | 4 +- protocols/kad/src/query/peers/closest.rs | 11 +++-- .../kad/src/query/peers/closest/disjoint.rs | 10 ++--- protocols/kad/src/record/store/memory.rs | 2 +- 8 files changed, 36 insertions(+), 62 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index b2a06dc691c..bd0c9857cb5 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -15,6 +15,8 @@ See [PR 5122](https://github.com/libp2p/rust-libp2p/pull/5122). - Compute `jobs_query_capacity` accurately. See [PR 5148](https://github.com/libp2p/rust-libp2p/pull/5148). +- Derive `Copy` for `kbucket::key::Key`. + See [PR 5317](https://github.com/libp2p/rust-libp2p/pull/5317). ## 0.45.3 diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 7f47f93bb39..fb77f3c0e0f 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -931,7 +931,7 @@ where /// This parameter is used to call [`Behaviour::bootstrap`] periodically and automatically /// to ensure a healthy routing table. pub fn bootstrap(&mut self) -> Result { - let local_key = self.kbuckets.local_key().clone(); + let local_key = *self.kbuckets.local_key(); let info = QueryInfo::Bootstrap { peer: *local_key.preimage(), remaining: None, @@ -1396,7 +1396,7 @@ where remaining, mut step, } => { - let local_key = self.kbuckets.local_key().clone(); + let local_key = *self.kbuckets.local_key(); let mut remaining = remaining.unwrap_or_else(|| { debug_assert_eq!(&peer, local_key.preimage()); // The lookup for the local key finished. To complete the bootstrap process, @@ -1446,7 +1446,7 @@ where let peers = self.kbuckets.closest_keys(&target); let inner = QueryInner::new(info); self.queries - .continue_iter_closest(query_id, target.clone(), peers, inner); + .continue_iter_closest(query_id, target, peers, inner); } else { step.last = true; self.bootstrap_status.on_finish(); @@ -1642,14 +1642,14 @@ where remaining.take().and_then(|mut r| Some((r.next()?, r))) { let info = QueryInfo::Bootstrap { - peer: target.clone().into_preimage(), + peer: target.into_preimage(), remaining: Some(remaining), step: step.next(), }; let peers = self.kbuckets.closest_keys(&target); let inner = QueryInner::new(info); self.queries - .continue_iter_closest(query_id, target.clone(), peers, inner); + .continue_iter_closest(query_id, target, peers, inner); } else { step.last = true; self.bootstrap_status.on_finish(); diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index 5a110fd7c3f..fbc10f22af8 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -534,7 +534,7 @@ mod tests { fn arbitrary(g: &mut Gen) -> TestTable { let local_key = Key::from(PeerId::random()); let timeout = Duration::from_secs(g.gen_range(1..360)); - let mut table = TestTable::new(local_key.clone().into(), timeout); + let mut table = TestTable::new(local_key.into(), timeout); let mut num_total = g.gen_range(0..100); for (i, b) in &mut table.buckets.iter_mut().enumerate().rev() { let ix = BucketIndex(i); @@ -543,10 +543,7 @@ mod tests { for _ in 0..num { let distance = ix.rand_distance(&mut rand::thread_rng()); let key = local_key.for_distance(distance); - let node = Node { - key: key.clone(), - value: (), - }; + let node = Node { key, value: () }; let status = NodeStatus::arbitrary(g); match b.insert(node, status) { InsertResult::Inserted => {} @@ -643,7 +640,7 @@ mod tests { #[test] fn entry_self() { let local_key = Key::from(PeerId::random()); - let mut table = KBucketsTable::<_, ()>::new(local_key.clone(), Duration::from_secs(5)); + let mut table = KBucketsTable::<_, ()>::new(local_key, Duration::from_secs(5)); assert!(table.entry(&local_key).is_none()) } @@ -671,7 +668,7 @@ mod tests { let mut expected_keys: Vec<_> = table .buckets .iter() - .flat_map(|t| t.iter().map(|(n, _)| n.key.clone())) + .flat_map(|t| t.iter().map(|(n, _)| n.key)) .collect(); for _ in 0..10 { @@ -686,7 +683,7 @@ mod tests { #[test] fn applied_pending() { let local_key = Key::from(PeerId::random()); - let mut table = KBucketsTable::<_, ()>::new(local_key.clone(), Duration::from_millis(1)); + let mut table = KBucketsTable::<_, ()>::new(local_key, Duration::from_millis(1)); let expected_applied; let full_bucket_index; loop { @@ -698,10 +695,7 @@ mod tests { match e.insert((), NodeStatus::Connected) { InsertResult::Pending { disconnected } => { expected_applied = AppliedPending { - inserted: Node { - key: key.clone(), - value: (), - }, + inserted: Node { key, value: () }, evicted: Some(Node { key: disconnected, value: (), diff --git a/protocols/kad/src/kbucket/bucket.rs b/protocols/kad/src/kbucket/bucket.rs index 5e65bc15a37..1bd4389eb3d 100644 --- a/protocols/kad/src/kbucket/bucket.rs +++ b/protocols/kad/src/kbucket/bucket.rs @@ -439,10 +439,7 @@ mod tests { let num_nodes = g.gen_range(1..K_VALUE.get() + 1); for _ in 0..num_nodes { let key = Key::from(PeerId::random()); - let node = Node { - key: key.clone(), - value: (), - }; + let node = Node { key, value: () }; let status = NodeStatus::arbitrary(g); match bucket.insert(node, status) { InsertResult::Inserted => {} @@ -492,10 +489,7 @@ mod tests { // Fill the bucket, thereby populating the expected lists in insertion order. for status in status { let key = Key::from(PeerId::random()); - let node = Node { - key: key.clone(), - value: (), - }; + let node = Node { key, value: () }; let full = bucket.num_entries() == K_VALUE.get(); if let InsertResult::Inserted = bucket.insert(node, status) { let vec = match status { @@ -505,15 +499,12 @@ mod tests { if full { vec.pop_front(); } - vec.push_back((status, key.clone())); + vec.push_back((status, key)); } } // Get all nodes from the bucket, together with their status. - let mut nodes = bucket - .iter() - .map(|(n, s)| (s, n.key.clone())) - .collect::>(); + let mut nodes = bucket.iter().map(|(n, s)| (s, n.key)).collect::>(); // Split the list of nodes at the first connected node. let first_connected_pos = nodes.iter().position(|(s, _)| *s == NodeStatus::Connected); @@ -553,10 +544,7 @@ mod tests { // Add a connected node, which is expected to be pending, scheduled to // replace the first (i.e. least-recently connected) node. let key = Key::from(PeerId::random()); - let node = Node { - key: key.clone(), - value: (), - }; + let node = Node { key, value: () }; match bucket.insert(node.clone(), NodeStatus::Connected) { InsertResult::Pending { disconnected } => { assert_eq!(disconnected, first_disconnected.key) @@ -609,10 +597,7 @@ mod tests { // Add a connected pending node. let key = Key::from(PeerId::random()); - let node = Node { - key: key.clone(), - value: (), - }; + let node = Node { key, value: () }; if let InsertResult::Pending { disconnected } = bucket.insert(node, NodeStatus::Connected) { assert_eq!(&disconnected, &first_disconnected.key); } else { @@ -647,13 +632,10 @@ mod tests { // Capture position and key of the random node to update. let pos = pos.0 % num_nodes; - let key = bucket.nodes[pos].key.clone(); + let key = bucket.nodes[pos].key; // Record the (ordered) list of status of all nodes in the bucket. - let mut expected = bucket - .iter() - .map(|(n, s)| (n.key.clone(), s)) - .collect::>(); + let mut expected = bucket.iter().map(|(n, s)| (n.key, s)).collect::>(); // Update the node in the bucket. bucket.update(&key, status); @@ -665,11 +647,8 @@ mod tests { NodeStatus::Disconnected => bucket.first_connected_pos.unwrap_or(num_nodes) - 1, }; expected.remove(pos); - expected.insert(expected_pos, (key.clone(), status)); - let actual = bucket - .iter() - .map(|(n, s)| (n.key.clone(), s)) - .collect::>(); + expected.insert(expected_pos, (key, status)); + let actual = bucket.iter().map(|(n, s)| (n.key, s)).collect::>(); expected == actual } diff --git a/protocols/kad/src/kbucket/key.rs b/protocols/kad/src/kbucket/key.rs index bc5d6a53750..f35849c6b26 100644 --- a/protocols/kad/src/kbucket/key.rs +++ b/protocols/kad/src/kbucket/key.rs @@ -39,7 +39,7 @@ construct_uint! { /// /// `Key`s have an XOR metric as defined in the Kademlia paper, i.e. the bitwise XOR of /// the hash digests, interpreted as an integer. See [`Key::distance`]. -#[derive(Clone, Debug)] +#[derive(Clone, Copy, Debug)] pub struct Key { preimage: T, bytes: KeyBytes, @@ -145,7 +145,7 @@ impl Hash for Key { } /// The raw bytes of a key in the DHT keyspace. -#[derive(PartialEq, Eq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Copy, Debug)] pub struct KeyBytes(GenericArray); impl KeyBytes { diff --git a/protocols/kad/src/query/peers/closest.rs b/protocols/kad/src/query/peers/closest.rs index 3ee12b98244..a0b5a96708a 100644 --- a/protocols/kad/src/query/peers/closest.rs +++ b/protocols/kad/src/query/peers/closest.rs @@ -556,12 +556,12 @@ mod tests { #[test] fn new_iter() { fn prop(iter: ClosestPeersIter) { - let target = iter.target.clone(); + let target = iter.target; let (keys, states): (Vec<_>, Vec<_>) = iter .closest_peers .values() - .map(|e| (e.key.clone(), &e.state)) + .map(|e| (e.key, &e.state)) .unzip(); let none_contacted = states.iter().all(|s| matches!(s, PeerState::NotContacted)); @@ -595,12 +595,12 @@ mod tests { let mut expected = iter .closest_peers .values() - .map(|e| e.key.clone()) + .map(|e| e.key) .collect::>(); let num_known = expected.len(); let max_parallelism = usize::min(iter.config.parallelism.get(), num_known); - let target = iter.target.clone(); + let target = iter.target; let mut remaining; let mut num_failures = 0; @@ -667,7 +667,7 @@ mod tests { .values() .all(|e| !matches!(e.state, PeerState::NotContacted | PeerState::Waiting { .. })); - let target = iter.target.clone(); + let target = iter.target; let num_results = iter.config.num_results; let result = iter.into_result(); let closest = result.map(Key::from).collect::>(); @@ -744,7 +744,6 @@ mod tests { .next() .unwrap() .key - .clone() .into_preimage(); // Poll the iterator for the first peer to be in progress. diff --git a/protocols/kad/src/query/peers/closest/disjoint.rs b/protocols/kad/src/query/peers/closest/disjoint.rs index e8309a2deda..cafe87b6ef4 100644 --- a/protocols/kad/src/query/peers/closest/disjoint.rs +++ b/protocols/kad/src/query/peers/closest/disjoint.rs @@ -460,7 +460,7 @@ mod tests { peers.into_iter() }); - ResultIter::new(target.clone(), iters) + ResultIter::new(target, iters) } fn shrink(&self) -> Box> { @@ -481,7 +481,7 @@ mod tests { .collect(); Box::new(ResultIterShrinker { - target: self.target.clone(), + target: self.target, peers, iters, }) @@ -511,7 +511,7 @@ mod tests { Some(iter.into_iter()) }); - Some(ResultIter::new(self.target.clone(), iters)) + Some(ResultIter::new(self.target, iters)) } } @@ -867,7 +867,7 @@ mod tests { let closest = drive_to_finish( PeerIterator::Closest(ClosestPeersIter::with_config( cfg.clone(), - target.clone(), + target, known_closest_peers.clone(), )), graph.clone(), @@ -877,7 +877,7 @@ mod tests { let disjoint = drive_to_finish( PeerIterator::Disjoint(ClosestDisjointPeersIter::with_config( cfg, - target.clone(), + target, known_closest_peers.clone(), )), graph, diff --git a/protocols/kad/src/record/store/memory.rs b/protocols/kad/src/record/store/memory.rs index 86c136ebeda..3bd3c56e30c 100644 --- a/protocols/kad/src/record/store/memory.rs +++ b/protocols/kad/src/record/store/memory.rs @@ -157,7 +157,7 @@ impl RecordStore for MemoryStore { providers.as_mut()[i] = record; } else { // It is a new provider record for that key. - let local_key = self.local_key.clone(); + let local_key = self.local_key; let key = kbucket::Key::new(record.key.clone()); let provider = kbucket::Key::from(record.provider); if let Some(i) = providers.iter().position(|p| { From 44bc941c715c51ca2386f9532cd8748da4a126c4 Mon Sep 17 00:00:00 2001 From: Snoppy Date: Mon, 22 Apr 2024 05:31:34 +0800 Subject: [PATCH 066/246] chore: fix typos in doc comments Pull-Request: #5323. --- swarm/src/lib.rs | 2 +- transports/webrtc/src/tokio/sdp.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index dac380855aa..cf2961cef6d 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1147,7 +1147,7 @@ where addrs }; - // If address translation yielded nothing, broacast the original candidate address. + // If address translation yielded nothing, broadcast the original candidate address. if translated_addresses.is_empty() { self.behaviour .on_swarm_event(FromSwarm::NewExternalAddrCandidate( diff --git a/transports/webrtc/src/tokio/sdp.rs b/transports/webrtc/src/tokio/sdp.rs index 8549a864dcc..4be4c19f188 100644 --- a/transports/webrtc/src/tokio/sdp.rs +++ b/transports/webrtc/src/tokio/sdp.rs @@ -98,7 +98,7 @@ pub(crate) fn offer(addr: SocketAddr, client_ufrag: &str) -> RTCSessionDescripti // // a=ice-options:ice2 // -// Indicates that we are complying with RFC8839 (as oppposed to the legacy RFC5245). +// Indicates that we are complying with RFC8839 (as opposed to the legacy RFC5245). // // a=ice-ufrag: // a=ice-pwd: From cde12ee94b632cd6399a2f965287894f68ee0991 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 08:45:46 +0000 Subject: [PATCH 067/246] deps: bump anyhow from 1.0.81 to 1.0.82 Pull-Request: #5306. --- Cargo.lock | 4 ++-- examples/browser-webrtc/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 455bd9d99e4..fbd938d8336 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "arbitrary" diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index fc4adfc1560..70010c5e1b1 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -16,7 +16,7 @@ release = false crate-type = ["cdylib"] [dependencies] -anyhow = "1.0.81" +anyhow = "1.0.82" futures = "0.3.30" rand = "0.8" tracing = { workspace = true } diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index 2dbaa21365a..f18d7b41406 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" clap = { version = "4.5.4", features = ["derive"] } env_logger = "0.10" futures = "0.3.30" -anyhow = "1.0.81" +anyhow = "1.0.82" libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "yamux", "rsa"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index c3c43eec286..aa509eae9e9 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -32,7 +32,7 @@ json = ["dep:serde", "dep:serde_json", "libp2p-swarm/macros"] cbor = ["dep:serde", "dep:cbor4ii", "libp2p-swarm/macros"] [dev-dependencies] -anyhow = "1.0.81" +anyhow = "1.0.82" async-std = { version = "1.6.2", features = ["attributes"] } libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } From d481da7e9bc6df3d91b6324ce484ce77aeb4aa12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:04:29 +0000 Subject: [PATCH 068/246] deps: bump thiserror from 1.0.58 to 1.0.59 Pull-Request: #5331. --- Cargo.lock | 8 ++++---- protocols/floodsub/Cargo.toml | 2 +- transports/noise/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/tls/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/webtransport-websys/Cargo.toml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbd938d8336..22e6345158b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5872,18 +5872,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index fe1b509735d..8e7e0ef3621 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -23,7 +23,7 @@ quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" smallvec = "1.13.2" -thiserror = "1.0.58" +thiserror = "1.0.59" tracing = { workspace = true } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 130fce156a9..9d6229343bd 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -22,7 +22,7 @@ quick-protobuf = "0.8" rand = "0.8.3" sha2 = "0.10.8" static_assertions = "1" -thiserror = "1.0.58" +thiserror = "1.0.59" tracing = { workspace = true } x25519-dalek = "2" zeroize = "1" diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 1d283aeef45..4dd72bee1fe 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -21,7 +21,7 @@ parking_lot = "0.12.0" quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls", "futures-io"] } rand = "0.8.5" rustls = { version = "0.21.9", default-features = false } -thiserror = "1.0.58" +thiserror = "1.0.59" tokio = { workspace = true, default-features = false, features = ["net", "rt", "time"], optional = true } tracing = { workspace = true } socket2 = "0.5.6" diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index bd0ef91279c..d8829f0ae4b 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -15,7 +15,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true } rcgen = "0.11.3" ring = "0.16.20" -thiserror = "1.0.58" +thiserror = "1.0.59" webpki = { version = "0.101.4", package = "rustls-webpki", features = ["std"] } x509-parser = "0.16.0" yasna = "0.5.2" diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 7f3c64a826a..3769806da8c 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -18,7 +18,7 @@ libp2p-core = { workspace = true } tracing = { workspace = true } parking_lot = "0.12.1" send_wrapper = "0.6.0" -thiserror = "1.0.58" +thiserror = "1.0.59" wasm-bindgen = "0.2.90" web-sys = { version = "0.3.69", features = ["BinaryType", "CloseEvent", "MessageEvent", "WebSocket", "Window", "WorkerGlobalScope"] } diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index 7d844684f0d..ed3d4f0b8c4 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -22,7 +22,7 @@ libp2p-noise = { workspace = true } multiaddr = { workspace = true } multihash = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } -thiserror = "1.0.58" +thiserror = "1.0.59" tracing = { workspace = true } wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.42" From 41b55d360af4f9dec630acfacbd3fd33f3bf1874 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:18:05 +0000 Subject: [PATCH 069/246] deps: bump serde_json from 1.0.115 to 1.0.116 Pull-Request: #5332. --- Cargo.lock | 4 ++-- hole-punching-tests/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22e6345158b..779612e4dde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5368,9 +5368,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "indexmap 2.2.1", "itoa", diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 129adca499a..a4a17f3cfd0 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -14,5 +14,5 @@ tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { workspace = true, features = ["full"] } serde = { version = "1.0.197", features = ["derive"] } -serde_json = "1.0.115" +serde_json = "1.0.116" either = "1.11.0" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index cefd28ff6e4..8292414ea5a 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -16,7 +16,7 @@ release = false clap = { version = "4.5.4", features = ["derive"] } zeroize = "1" serde = { version = "1.0.197", features = ["derive"] } -serde_json = "1.0.115" +serde_json = "1.0.116" libp2p-core = { workspace = true } base64 = "0.22.0" libp2p-identity = { workspace = true } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index aa509eae9e9..fd628da2420 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -20,7 +20,7 @@ libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } rand = "0.8" serde = { version = "1.0", optional = true} -serde_json = { version = "1.0.115", optional = true } +serde_json = { version = "1.0.116", optional = true } smallvec = "1.13.2" tracing = { workspace = true } void = "1.0.2" From db7c72654777b63e9377052217dfee57bfc97f2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:30:21 +0000 Subject: [PATCH 070/246] deps: bump proc-macro2 from 1.0.80 to 1.0.81 Pull-Request: #5333. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 779612e4dde..2311f520365 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4498,9 +4498,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] From f525705533f63f85acd83adb118ae3dcfea1be0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:42:57 +0000 Subject: [PATCH 071/246] deps: bump syn from 2.0.59 to 2.0.60 Pull-Request: #5335. --- Cargo.lock | 58 ++++++++++++++++++++--------------------- swarm-derive/Cargo.toml | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2311f520365..18d9a03c556 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", "synstructure 0.13.1", ] @@ -247,7 +247,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -469,7 +469,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -486,7 +486,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -988,7 +988,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1254,7 +1254,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1385,7 +1385,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1490,7 +1490,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1726,7 +1726,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -3344,7 +3344,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -4117,7 +4117,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -4328,7 +4328,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -4525,7 +4525,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -4548,7 +4548,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -5070,7 +5070,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.59", + "syn 2.0.60", "walkdir", ] @@ -5363,7 +5363,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -5396,7 +5396,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -5681,7 +5681,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -5731,9 +5731,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.59" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -5772,7 +5772,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -5887,7 +5887,7 @@ checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -5989,7 +5989,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -6177,7 +6177,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -6519,7 +6519,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -6553,7 +6553,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6586,7 +6586,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -7194,7 +7194,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -7214,5 +7214,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index 072efcf0b9b..7a8a1062d2c 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true [dependencies] heck = "0.5" quote = "1.0" -syn = { version = "2.0.59", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.60", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" # Passing arguments to the docsrs builder in order to properly document cfg's. From d4dd9d0aebf8bb183f0c6a0431db36781d493259 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:54:32 +0000 Subject: [PATCH 072/246] deps: bump rmp-serde from 1.1.2 to 1.2.0 Pull-Request: #5336. --- Cargo.lock | 8 ++++---- identity/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 18d9a03c556..3463c7347c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4989,9 +4989,9 @@ dependencies = [ [[package]] name = "rmp" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" +checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" dependencies = [ "byteorder", "num-traits", @@ -5000,9 +5000,9 @@ dependencies = [ [[package]] name = "rmp-serde" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" +checksum = "938a142ab806f18b88a97b0dea523d39e0fd730a064b035726adcfc58a8a5188" dependencies = [ "byteorder", "rmp", diff --git a/identity/Cargo.toml b/identity/Cargo.toml index 217044d0fcd..fbc7bae3d11 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -44,7 +44,7 @@ rand = ["dep:rand", "ed25519-dalek?/rand_core"] quickcheck = { workspace = true } base64 = "0.22.0" serde_json = "1.0" -rmp-serde = "1.1" +rmp-serde = "1.2" criterion = "0.5" hex-literal = "0.4.1" From 0340c5236eea2e847e7c3011fc5364118748ee46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:06:34 +0000 Subject: [PATCH 073/246] deps: bump reqwest from 0.12.3 to 0.12.4 Pull-Request: #5337. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3463c7347c5..fe1af435e52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4884,9 +4884,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e6cc1e89e689536eb5aeede61520e874df5a4707df811cd5da4aa5fbb2aae19" +checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" dependencies = [ "base64 0.22.0", "bytes", From cf7b678eee7a65d91f736b2231cd2d199a23f3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 25 Apr 2024 12:56:41 +0100 Subject: [PATCH 074/246] fix: update Cargo.lock Pull-Request: #5342. --- Cargo.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe1af435e52..d44fbc0b47a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1453,9 +1453,9 @@ checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "elliptic-curve" -version = "0.13.5" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -1736,7 +1736,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28" dependencies = [ "futures-io", - "rustls 0.21.9", + "rustls 0.21.11", ] [[package]] @@ -2237,7 +2237,7 @@ dependencies = [ "http 1.0.0", "hyper 1.1.0", "hyper-util", - "rustls 0.22.3", + "rustls 0.22.4", "rustls-pki-types", "tokio", "tokio-rustls", @@ -3171,7 +3171,7 @@ dependencies = [ "quinn", "rand 0.8.5", "ring 0.16.20", - "rustls 0.21.9", + "rustls 0.21.11", "socket2 0.5.6", "thiserror", "tokio", @@ -3396,7 +3396,7 @@ dependencies = [ "libp2p-yamux", "rcgen", "ring 0.16.20", - "rustls 0.21.9", + "rustls 0.21.11", "rustls-webpki 0.101.7", "thiserror", "tokio", @@ -4613,7 +4613,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.21.9", + "rustls 0.21.11", "thiserror", "tokio", "tracing", @@ -4629,7 +4629,7 @@ dependencies = [ "rand 0.8.5", "ring 0.16.20", "rustc-hash", - "rustls 0.21.9", + "rustls 0.21.11", "slab", "thiserror", "tinyvec", @@ -4909,7 +4909,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.22.3", + "rustls 0.22.4", "rustls-pemfile", "rustls-pki-types", "serde", @@ -5144,9 +5144,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.9" +version = "0.21.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" +checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" dependencies = [ "log", "ring 0.17.5", @@ -5156,9 +5156,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", "ring 0.17.5", @@ -6008,7 +6008,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.22.3", + "rustls 0.22.4", "rustls-pki-types", "tokio", ] @@ -6656,7 +6656,7 @@ dependencies = [ "ring 0.16.20", "rtcp", "rtp", - "rustls 0.21.9", + "rustls 0.21.11", "sdp", "serde", "serde_json", @@ -6717,7 +6717,7 @@ dependencies = [ "rand_core 0.6.4", "rcgen", "ring 0.16.20", - "rustls 0.21.9", + "rustls 0.21.11", "sec1", "serde", "sha1", From 2dcdda4a72ae814acacdd4ea30851692b6ee9175 Mon Sep 17 00:00:00 2001 From: largemouth <167662830+largemouth@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:23:15 +0800 Subject: [PATCH 075/246] docs: fix typos in some comments fix typos in some comments Pull-Request: #5338. --- core/src/transport/dummy.rs | 2 +- protocols/gossipsub/src/config.rs | 4 ++-- protocols/kad/src/kbucket.rs | 2 +- protocols/kad/src/kbucket/entry.rs | 2 +- protocols/rendezvous/src/server.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/transport/dummy.rs b/core/src/transport/dummy.rs index 951d1039328..0aab94b0396 100644 --- a/core/src/transport/dummy.rs +++ b/core/src/transport/dummy.rs @@ -94,7 +94,7 @@ impl Transport for DummyTransport { } } -/// Implementation of `AsyncRead` and `AsyncWrite`. Not meant to be instanciated. +/// Implementation of `AsyncRead` and `AsyncWrite`. Not meant to be instantiated. pub struct DummyStream(()); impl fmt::Debug for DummyStream { diff --git a/protocols/gossipsub/src/config.rs b/protocols/gossipsub/src/config.rs index 8d7d11802ad..febe2514a30 100644 --- a/protocols/gossipsub/src/config.rs +++ b/protocols/gossipsub/src/config.rs @@ -292,7 +292,7 @@ impl Config { self.mesh_outbound_min } - /// Number of heartbeat ticks that specifcy the interval in which opportunistic grafting is + /// Number of heartbeat ticks that specify the interval in which opportunistic grafting is /// applied. Every `opportunistic_graft_ticks` we will attempt to select some high-scoring mesh /// peers to replace lower-scoring ones, if the median score of our mesh peers falls below a /// threshold (see ). @@ -694,7 +694,7 @@ impl ConfigBuilder { self } - /// Number of heartbeat ticks that specifcy the interval in which opportunistic grafting is + /// Number of heartbeat ticks that specify the interval in which opportunistic grafting is /// applied. Every `opportunistic_graft_ticks` we will attempt to select some high-scoring mesh /// peers to replace lower-scoring ones, if the median score of our mesh peers falls below a /// threshold (see ). diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index fbc10f22af8..459f769fb12 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -344,7 +344,7 @@ enum ClosestBucketsIterState { /// The starting state of the iterator yields the first bucket index and /// then transitions to `ZoomIn`. Start(BucketIndex), - /// The iterator "zooms in" to yield the next bucket cotaining nodes that + /// The iterator "zooms in" to yield the next bucket containing nodes that /// are incrementally closer to the local node but further from the `target`. /// These buckets are identified by a `1` in the corresponding bit position /// of the distance bit string. When bucket `0` is reached, the iterator diff --git a/protocols/kad/src/kbucket/entry.rs b/protocols/kad/src/kbucket/entry.rs index d89853b1761..808db08d858 100644 --- a/protocols/kad/src/kbucket/entry.rs +++ b/protocols/kad/src/kbucket/entry.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//! The `Entry` API for quering and modifying the entries of a `KBucketsTable` +//! The `Entry` API for querying and modifying the entries of a `KBucketsTable` //! representing the nodes participating in the Kademlia DHT. pub(crate) use super::bucket::{AppliedPending, InsertResult, Node, K_VALUE}; diff --git a/protocols/rendezvous/src/server.rs b/protocols/rendezvous/src/server.rs index 0ed1b6523d1..a6e523302d7 100644 --- a/protocols/rendezvous/src/server.rs +++ b/protocols/rendezvous/src/server.rs @@ -442,7 +442,7 @@ impl Registrations { match (discover_namespace.as_ref(), cookie_namespace) { // discover all namespace but cookie is specific to a namespace? => bad (None, Some(_)) => return Err(CookieNamespaceMismatch), - // discover for a namespace but cookie is for a different namesapce? => bad + // discover for a namespace but cookie is for a different namespace? => bad (Some(namespace), Some(cookie_namespace)) if namespace != cookie_namespace => { return Err(CookieNamespaceMismatch) } From bc24ab9cee3803fa116d6672779777620d3f5a7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:59:32 +0000 Subject: [PATCH 076/246] deps: bump serde from 1.0.197 to 1.0.198 Pull-Request: #5334. --- Cargo.lock | 8 ++++---- hole-punching-tests/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d44fbc0b47a..c009be3ab93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5348,18 +5348,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index a4a17f3cfd0..e725d96912e 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -13,6 +13,6 @@ libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { workspace = true, features = ["full"] } -serde = { version = "1.0.197", features = ["derive"] } +serde = { version = "1.0.198", features = ["derive"] } serde_json = "1.0.116" either = "1.11.0" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 8292414ea5a..5b1a2673588 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -15,7 +15,7 @@ release = false [dependencies] clap = { version = "4.5.4", features = ["derive"] } zeroize = "1" -serde = { version = "1.0.197", features = ["derive"] } +serde = { version = "1.0.198", features = ["derive"] } serde_json = "1.0.116" libp2p-core = { workspace = true } base64 = "0.22.0" diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index d744a2f9a08..f6d09103359 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -18,7 +18,7 @@ futures-timer = "3" axum = "0.7" libp2p = { workspace = true, features = ["autonat", "dns", "tokio", "noise", "tcp", "yamux", "identify", "kad", "ping", "relay", "metrics", "rsa", "macros", "quic", "websocket"] } prometheus-client = { workspace = true } -serde = "1.0.197" +serde = "1.0.198" serde_derive = "1.0.125" serde_json = "1.0" tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } From cc432cae2b8d473a8a215338d06aeb3d5e737a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Cie=C4=87ka?= <34537442+CieciaOne@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:20:02 +0200 Subject: [PATCH 077/246] chore: fix typo in ipfs-kad example README.md Pull-Request: #5326. --- examples/ipfs-kad/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ipfs-kad/README.md b/examples/ipfs-kad/README.md index ccefb6b1d9f..a46246a3920 100644 --- a/examples/ipfs-kad/README.md +++ b/examples/ipfs-kad/README.md @@ -11,7 +11,7 @@ By running this example, users can gain a better understanding of how the Kademl The example code demonstrates how to perform Kademlia queries on the IPFS network using the Rust P2P Library. -### Getting closes peers +### Getting closest peers By specifying a peer ID as a parameter, the code will search for the closest peers to the given peer ID. From 66e56fa78aab583efd5f23b05513bc9066393576 Mon Sep 17 00:00:00 2001 From: tesseract <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:07:11 -0700 Subject: [PATCH 078/246] docs: enhance code documentation Pull-Request: #5198. --- libp2p/src/builder/phase/provider.rs | 44 ++++++++++++++++++---------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/libp2p/src/builder/phase/provider.rs b/libp2p/src/builder/phase/provider.rs index 32321442689..2a9154cda74 100644 --- a/libp2p/src/builder/phase/provider.rs +++ b/libp2p/src/builder/phase/provider.rs @@ -1,46 +1,60 @@ #[allow(unused_imports)] use super::*; - use crate::SwarmBuilder; +use std::marker::PhantomData; +/// Represents the phase where a provider is not yet specified. +/// This is a marker type used in the type-state pattern to ensure compile-time checks of the builder's state. +pub enum NoProviderSpecified {} + +// Define enums for each of the possible runtime environments. These are used as markers in the type-state pattern, +// allowing compile-time checks for the appropriate environment configuration. + +#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))] +/// Represents the AsyncStd runtime environment. +pub enum AsyncStd {} + +#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))] +/// Represents the Tokio runtime environment. +pub enum Tokio {} + +#[cfg(feature = "wasm-bindgen")] +/// Represents the WasmBindgen environment for WebAssembly. +pub enum WasmBindgen {} +/// Represents a phase in the SwarmBuilder where a provider has been chosen but not yet specified. pub struct ProviderPhase {} impl SwarmBuilder { + /// Configures the SwarmBuilder to use the AsyncStd runtime. + /// This method is only available when compiling for non-Wasm targets with the `async-std` feature enabled. #[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))] pub fn with_async_std(self) -> SwarmBuilder { SwarmBuilder { keypair: self.keypair, - phantom: std::marker::PhantomData, + phantom: PhantomData, phase: TcpPhase {}, } } + /// Configures the SwarmBuilder to use the Tokio runtime. + /// This method is only available when compiling for non-Wasm targets with the `tokio` feature enabled #[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))] pub fn with_tokio(self) -> SwarmBuilder { SwarmBuilder { keypair: self.keypair, - phantom: std::marker::PhantomData, + phantom: PhantomData, phase: TcpPhase {}, } } + /// Configures the SwarmBuilder for WebAssembly using WasmBindgen. + /// This method is available when the `wasm-bindgen` feature is enabled. #[cfg(feature = "wasm-bindgen")] pub fn with_wasm_bindgen(self) -> SwarmBuilder { SwarmBuilder { keypair: self.keypair, - phantom: std::marker::PhantomData, + phantom: PhantomData, phase: TcpPhase {}, } } } - -pub enum NoProviderSpecified {} - -#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))] -pub enum AsyncStd {} - -#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))] -pub enum Tokio {} - -#[cfg(feature = "wasm-bindgen")] -pub enum WasmBindgen {} From 954c967f7b5c7689b9f5e7d3fea4019abd00c80a Mon Sep 17 00:00:00 2001 From: DrHuangMHT Date: Sat, 27 Apr 2024 21:10:33 +0800 Subject: [PATCH 079/246] deps: promote `futures` to workspace dependency Promote `futures` to workspace dependency for easier management. Pull-Request: #5329. --- Cargo.toml | 1 + core/Cargo.toml | 2 +- examples/autonat/Cargo.toml | 2 +- examples/browser-webrtc/Cargo.toml | 2 +- examples/chat/Cargo.toml | 2 +- examples/dcutr/Cargo.toml | 2 +- examples/distributed-key-value-store/Cargo.toml | 2 +- examples/file-sharing/Cargo.toml | 2 +- examples/identify/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- examples/ipfs-private/Cargo.toml | 2 +- examples/metrics/Cargo.toml | 2 +- examples/ping/Cargo.toml | 2 +- examples/relay-server/Cargo.toml | 2 +- examples/rendezvous/Cargo.toml | 2 +- examples/stream/Cargo.toml | 2 +- examples/upnp/Cargo.toml | 2 +- hole-punching-tests/Cargo.toml | 2 +- interop-tests/Cargo.toml | 2 +- libp2p/Cargo.toml | 2 +- misc/metrics/Cargo.toml | 2 +- misc/multistream-select/Cargo.toml | 2 +- misc/quick-protobuf-codec/Cargo.toml | 2 +- misc/rw-stream-sink/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- misc/webrtc-utils/Cargo.toml | 2 +- muxers/mplex/Cargo.toml | 4 ++-- muxers/test-harness/Cargo.toml | 2 +- muxers/yamux/Cargo.toml | 2 +- protocols/autonat/Cargo.toml | 2 +- protocols/dcutr/Cargo.toml | 2 +- protocols/floodsub/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- protocols/identify/Cargo.toml | 2 +- protocols/kad/Cargo.toml | 2 +- protocols/mdns/Cargo.toml | 2 +- protocols/perf/Cargo.toml | 2 +- protocols/ping/Cargo.toml | 2 +- protocols/relay/Cargo.toml | 2 +- protocols/rendezvous/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- protocols/stream/Cargo.toml | 2 +- protocols/upnp/Cargo.toml | 2 +- swarm-test/Cargo.toml | 2 +- swarm/Cargo.toml | 4 ++-- transports/dns/Cargo.toml | 2 +- transports/noise/Cargo.toml | 2 +- transports/plaintext/Cargo.toml | 2 +- transports/pnet/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/tcp/Cargo.toml | 2 +- transports/tls/Cargo.toml | 2 +- transports/uds/Cargo.toml | 2 +- transports/webrtc-websys/Cargo.toml | 2 +- transports/webrtc/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/websocket/Cargo.toml | 2 +- transports/webtransport-websys/Cargo.toml | 2 +- wasm-tests/webtransport-tests/Cargo.toml | 2 +- 59 files changed, 61 insertions(+), 60 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 796daaae0b9..dd8efeddb12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,6 +125,7 @@ rw-stream-sink = { version = "0.4.0", path = "misc/rw-stream-sink" } unsigned-varint = { version = "0.8.0" } tokio = { version = "1.37", default-features = false } tracing = "0.1.37" +futures = "0.3.30" [patch.crates-io] diff --git a/core/Cargo.toml b/core/Cargo.toml index 554d0091866..92e6e02351a 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] either = "1.11" fnv = "1.0" -futures = { version = "0.3.30", features = ["executor", "thread-pool"] } +futures = { workspace = true, features = ["executor", "thread-pool"] } futures-timer = "3" instant = "0.1.12" libp2p-identity = { workspace = true, features = ["peerid", "ed25519"] } diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index 89cc951c4c8..80ee30db72b 100644 --- a/examples/autonat/Cargo.toml +++ b/examples/autonat/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] tokio = { workspace = true, features = ["full"] } clap = { version = "4.5.4", features = ["derive"] } -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index 70010c5e1b1..ec95b75287f 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib"] [dependencies] anyhow = "1.0.82" -futures = "0.3.30" +futures = { workspace = true } rand = "0.8" tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/chat/Cargo.toml b/examples/chat/Cargo.toml index 0c7241eae52..b276791d39b 100644 --- a/examples/chat/Cargo.toml +++ b/examples/chat/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] tokio = { workspace = true, features = ["full"] } async-trait = "0.1" -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml index 497a9dc11ae..ce027a65ed8 100644 --- a/examples/dcutr/Cargo.toml +++ b/examples/dcutr/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] clap = { version = "4.5.4", features = ["derive"] } -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3.0" libp2p = { path = "../../libp2p", features = [ "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] } log = "0.4" diff --git a/examples/distributed-key-value-store/Cargo.toml b/examples/distributed-key-value-store/Cargo.toml index 809a573cc08..4755b499709 100644 --- a/examples/distributed-key-value-store/Cargo.toml +++ b/examples/distributed-key-value-store/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "async-std", "dns", "kad", "mdns", "noise", "macros", "tcp", "yamux"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index f364b9305c9..b53c8732a33 100644 --- a/examples/file-sharing/Cargo.toml +++ b/examples/file-sharing/Cargo.toml @@ -12,7 +12,7 @@ release = false serde = { version = "1.0", features = ["derive"] } tokio = { workspace = true, features = ["full"] } clap = { version = "4.5.4", features = ["derive"] } -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/identify/Cargo.toml b/examples/identify/Cargo.toml index cf2996e45cd..8ed26ba5fc2 100644 --- a/examples/identify/Cargo.toml +++ b/examples/identify/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio","yamux"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index f18d7b41406..34f92b28979 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -13,7 +13,7 @@ tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } async-trait = "0.1" clap = { version = "4.5.4", features = ["derive"] } env_logger = "0.10" -futures = "0.3.30" +futures = { workspace = true } anyhow = "1.0.82" libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "yamux", "rsa"] } tracing = { workspace = true } diff --git a/examples/ipfs-private/Cargo.toml b/examples/ipfs-private/Cargo.toml index 7b017111d26..8d3a49e85c0 100644 --- a/examples/ipfs-private/Cargo.toml +++ b/examples/ipfs-private/Cargo.toml @@ -12,7 +12,7 @@ release = false tokio = { workspace = true, features = ["rt-multi-thread", "macros", "io-std"] } async-trait = "0.1" either = "1.11" -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "dns", "identify", "kad", "macros", "noise", "ping", "pnet", "tcp", "websocket", "yamux"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index f3119b0f0fa..214b4450de7 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -futures = "0.3.30" +futures = { workspace = true } axum = "0.7" libp2p = { path = "../../libp2p", features = ["tokio", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] } opentelemetry = { version = "0.22.0", features = ["metrics"] } diff --git a/examples/ping/Cargo.toml b/examples/ping/Cargo.toml index d712f482f03..e92b5392c7a 100644 --- a/examples/ping/Cargo.toml +++ b/examples/ping/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = ["noise", "ping", "tcp", "tokio", "yamux"] } tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } diff --git a/examples/relay-server/Cargo.toml b/examples/relay-server/Cargo.toml index 664c52351cb..49b58c9b6bf 100644 --- a/examples/relay-server/Cargo.toml +++ b/examples/relay-server/Cargo.toml @@ -12,7 +12,7 @@ release = false clap = { version = "4.5.4", features = ["derive"] } async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay", "quic"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/rendezvous/Cargo.toml b/examples/rendezvous/Cargo.toml index 8ce668a98be..0a6229e4f07 100644 --- a/examples/rendezvous/Cargo.toml +++ b/examples/rendezvous/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros", "time"] } tracing = { workspace = true } diff --git a/examples/stream/Cargo.toml b/examples/stream/Cargo.toml index 37a511d857f..2c1f5ad1e9d 100644 --- a/examples/stream/Cargo.toml +++ b/examples/stream/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] anyhow = "1" -futures = "0.3.29" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "quic"] } libp2p-stream = { path = "../../protocols/stream", version = "0.1.0-alpha" } rand = "0.8" diff --git a/examples/upnp/Cargo.toml b/examples/upnp/Cargo.toml index 20c1323c7d6..6abe3f8354b 100644 --- a/examples/upnp/Cargo.toml +++ b/examples/upnp/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../../libp2p", features = ["tokio", "dns", "macros", "noise", "ping", "tcp", "yamux", "upnp"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index e725d96912e..6e0c692b5c9 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" [dependencies] anyhow = "1" env_logger = "0.10.2" -futures = "0.3.30" +futures = { workspace = true } libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] } tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 6e6ba028847..cfc85b75755 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] anyhow = "1" either = "1.11.0" -futures = "0.3.30" +futures = { workspace = true } rand = "0.8.5" serde = { version = "1", features = ["derive"] } tracing = { workspace = true } diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index 12b895894ab..01419445b8b 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -92,7 +92,7 @@ upnp = ["dep:libp2p-upnp"] [dependencies] bytes = "1" either = "1.9.0" -futures = "0.3.26" +futures = { workspace = true } futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` feature getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature instant = "0.1.12" # Explicit dependency to be used in `wasm-bindgen` feature diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index b9952e36ba3..4901a3852d7 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -19,7 +19,7 @@ ping = ["libp2p-ping"] relay = ["libp2p-relay"] [dependencies] -futures = "0.3.30" +futures = { workspace = true } instant = "0.1.12" libp2p-core = { workspace = true } libp2p-dcutr = { workspace = true, optional = true } diff --git a/misc/multistream-select/Cargo.toml b/misc/multistream-select/Cargo.toml index 080bd6ee289..3d40f50d967 100644 --- a/misc/multistream-select/Cargo.toml +++ b/misc/multistream-select/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] bytes = "1" -futures = "0.3" +futures = { workspace = true } tracing = { workspace = true } pin-project = "1.1.5" smallvec = "1.13.2" diff --git a/misc/quick-protobuf-codec/Cargo.toml b/misc/quick-protobuf-codec/Cargo.toml index bc07b86b427..a98ffa5308f 100644 --- a/misc/quick-protobuf-codec/Cargo.toml +++ b/misc/quick-protobuf-codec/Cargo.toml @@ -19,7 +19,7 @@ quick-protobuf = "0.8" [dev-dependencies] criterion = "0.5.1" -futures = "0.3.30" +futures = { workspace = true } quickcheck = { workspace = true } [[bench]] diff --git a/misc/rw-stream-sink/Cargo.toml b/misc/rw-stream-sink/Cargo.toml index 8de0555582c..557163c438a 100644 --- a/misc/rw-stream-sink/Cargo.toml +++ b/misc/rw-stream-sink/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["networking"] categories = ["network-programming", "asynchronous"] [dependencies] -futures = "0.3.30" +futures = { workspace = true } pin-project = "1.1.5" static_assertions = "1" diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index f6d09103359..f304d4b6346 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT" [dependencies] base64 = "0.22" clap = { version = "4.5.4", features = ["derive"] } -futures = "0.3" +futures = { workspace = true } futures-timer = "3" axum = "0.7" libp2p = { workspace = true, features = ["autonat", "dns", "tokio", "noise", "tcp", "yamux", "identify", "kad", "ping", "relay", "metrics", "rsa", "macros", "quic", "websocket"] } diff --git a/misc/webrtc-utils/Cargo.toml b/misc/webrtc-utils/Cargo.toml index b28ed74a4b0..f548773b8dd 100644 --- a/misc/webrtc-utils/Cargo.toml +++ b/misc/webrtc-utils/Cargo.toml @@ -13,7 +13,7 @@ publish = true [dependencies] asynchronous-codec = { workspace = true } bytes = "1" -futures = "0.3" +futures = { workspace = true } hex = "0.4" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } diff --git a/muxers/mplex/Cargo.toml b/muxers/mplex/Cargo.toml index 4e612939373..52920479158 100644 --- a/muxers/mplex/Cargo.toml +++ b/muxers/mplex/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] bytes = "1" -futures = "0.3.30" +futures = { workspace = true } asynchronous-codec = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } @@ -26,7 +26,7 @@ unsigned-varint = { workspace = true, features = ["asynchronous_codec"] } [dev-dependencies] async-std = { version = "1.7.0", features = ["attributes"] } criterion = "0.5" -futures = "0.3" +futures = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-muxer-test-harness = { path = "../test-harness" } libp2p-plaintext = { workspace = true } diff --git a/muxers/test-harness/Cargo.toml b/muxers/test-harness/Cargo.toml index 421292cf0a7..f4632437ce6 100644 --- a/muxers/test-harness/Cargo.toml +++ b/muxers/test-harness/Cargo.toml @@ -12,7 +12,7 @@ release = false [dependencies] libp2p-core = { workspace = true } -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3.0.3" futures_ringbuf = "0.4.0" tracing = { workspace = true } diff --git a/muxers/yamux/Cargo.toml b/muxers/yamux/Cargo.toml index 7c36faf022a..ddb9424895b 100644 --- a/muxers/yamux/Cargo.toml +++ b/muxers/yamux/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] either = "1" -futures = "0.3.30" +futures = { workspace = true } libp2p-core = { workspace = true } thiserror = "1.0" yamux012 = { version = "0.12.1", package = "yamux" } diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index 2780016cebd..3dd11be4366 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-trait = "0.1" -futures = "0.3" +futures = { workspace = true } futures-timer = "3.0" instant = "0.1" libp2p-core = { workspace = true } diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 10322fb63da..7be4b01fef5 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] asynchronous-codec = { workspace = true } either = "1.11.0" -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3.0" instant = "0.1.12" libp2p-core = { workspace = true } diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 8e7e0ef3621..e95fa00697e 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -15,7 +15,7 @@ asynchronous-codec = { workspace = true } cuckoofilter = "0.5.0" fnv = "1.0" bytes = "1.6" -futures = "0.3.30" +futures = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 830866150ac..3a5e27f7b5f 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -20,7 +20,7 @@ byteorder = "1.5.0" bytes = "1.6" either = "1.11" fnv = "1.0.7" -futures = "0.3.30" +futures = { workspace = true } futures-ticker = "0.0.3" getrandom = "0.2.14" hex_fmt = "0.3.0" diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 16cfef4a05a..626db2ab944 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] asynchronous-codec = { workspace = true } -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3.0.3" futures-bounded = { workspace = true } libp2p-core = { workspace = true } diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 3d2739c6004..bf4caf28e97 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -16,7 +16,7 @@ bytes = "1" either = "1.11" fnv = "1.0" asynchronous-codec = { workspace = true } -futures = "0.3.30" +futures = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } futures-bounded = { workspace = true } diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index af8f555156a..9db161779dc 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] async-std = { version = "1.12.0", optional = true } async-io = { version = "2.3.2", optional = true } data-encoding = "2.5.0" -futures = "0.3.30" +futures = { workspace = true } if-watch = "3.2.0" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 655f7e13658..9a3d0d57f02 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] anyhow = "1" clap = { version = "4.5.4", features = ["derive"] } -futures = "0.3.30" +futures = { workspace = true } futures-bounded = { workspace = true } futures-timer = "3.0" instant = "0.1.12" diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index 0a07b403260..eb08d21ca92 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] either = "1.11.0" -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3.0.3" instant = "0.1.12" libp2p-core = { workspace = true } diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 750f5550dde..d4ba1b37d86 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] asynchronous-codec = { workspace = true } bytes = "1" either = "1.11.0" -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3" futures-bounded = { workspace = true } instant = "0.1.12" diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index 609ea207bae..2937cbbdd93 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] asynchronous-codec = { workspace = true } async-trait = "0.1" bimap = "0.6.3" -futures = { version = "0.3", default-features = false, features = ["std"] } +futures = { workspace = true, default-features = false, features = ["std"] } futures-timer = "3.0.3" instant = "0.1.12" libp2p-core = { workspace = true } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index fd628da2420..2e10b3e4206 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-trait = "0.1" cbor4ii = { version = "0.3.2", features = ["serde1", "use_std"], optional = true } -futures = "0.3.30" +futures = { workspace = true } instant = "0.1.12" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } diff --git a/protocols/stream/Cargo.toml b/protocols/stream/Cargo.toml index 964d69027f1..b90f9958173 100644 --- a/protocols/stream/Cargo.toml +++ b/protocols/stream/Cargo.toml @@ -10,7 +10,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -futures = "0.3.29" +futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["peerid"] } libp2p-swarm = { workspace = true } diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index a73f955ae62..944b3323842 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -11,7 +11,7 @@ categories = ["network-programming", "asynchronous"] publish = true [dependencies] -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3.0.3" igd-next = "0.14.3" libp2p-core = { workspace = true } diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index 0ea404fad7f..1bd40bdace3 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -19,7 +19,7 @@ libp2p-plaintext = { workspace = true } libp2p-swarm = { workspace = true, features = ["async-std"] } libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-yamux = { workspace = true } -futures = "0.3.30" +futures = { workspace = true } rand = "0.8.5" tracing = { workspace = true } futures-timer = "3.0.3" diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 10749def335..ad224b6168d 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] either = "1.11.0" fnv = "1.0" -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3.0.3" getrandom = { version = "0.2.14", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature instant = "0.1.12" @@ -42,7 +42,7 @@ wasm-bindgen = ["dep:wasm-bindgen-futures", "dep:getrandom"] [dev-dependencies] async-std = { version = "1.6.2", features = ["attributes"] } either = "1.11.0" -futures = "0.3.30" +futures = { workspace = true } libp2p-identify = { path = "../protocols/identify" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. libp2p-identity = { workspace = true, features = ["ed25519"] } libp2p-kad = { path = "../protocols/kad" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index d35d87da075..329268645ab 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-std-resolver = { version = "0.24", optional = true } async-trait = "0.1.80" -futures = "0.3.30" +futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } parking_lot = "0.12.0" diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 9d6229343bd..8e17ba3d6a3 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/libp2p/rust-libp2p" asynchronous-codec = { workspace = true } bytes = "1" curve25519-dalek = "4.1.2" -futures = "0.3.30" +futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["ed25519"] } multiaddr = { workspace = true } diff --git a/transports/plaintext/Cargo.toml b/transports/plaintext/Cargo.toml index 9a4576ef29f..33e7ae1ab5c 100644 --- a/transports/plaintext/Cargo.toml +++ b/transports/plaintext/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] asynchronous-codec = { workspace = true } bytes = "1" -futures = "0.3.30" +futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } quick-protobuf = "0.8" diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index bb8b1c03f6f..76964ce3152 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -futures = "0.3.30" +futures = { workspace = true } salsa20 = "0.10" sha3 = "0.10" tracing = { workspace = true } diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 4dd72bee1fe..26ff0aa6fac 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -11,7 +11,7 @@ license = "MIT" [dependencies] async-std = { version = "1.12.0", optional = true } bytes = "1.6.0" -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3.0.3" if-watch = "3.2.0" libp2p-core = { workspace = true } diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index b074e8e8b22..6a463a72062 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-io = { version = "2.3.2", optional = true } -futures = "0.3.30" +futures = { workspace = true } futures-timer = "3.0" if-watch = "3.2.0" libc = "0.2.153" diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index d8829f0ae4b..1494f110c97 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" exclude = ["src/test_assets"] [dependencies] -futures = { version = "0.3.30", default-features = false } +futures = { workspace = true, default-features = false } futures-rustls = "0.24.0" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index 84df8dc569e..13642a38a48 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-std = { version = "1.6.2", optional = true } libp2p-core = { workspace = true } -futures = "0.3.30" +futures = { workspace = true } tokio = { workspace = true, default-features = false, features = ["net"], optional = true } tracing = { workspace = true } diff --git a/transports/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index b5682a7c7da..e1590404fda 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -13,7 +13,7 @@ publish = true [dependencies] bytes = "1" -futures = "0.3" +futures = { workspace = true } getrandom = { version = "0.2.14", features = ["js"] } hex = "0.4.3" js-sys = { version = "0.3" } diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index 4a7c94ab1ca..a1de95a1993 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-trait = "0.1" bytes = "1" -futures = "0.3" +futures = { workspace = true } futures-timer = "3" hex = "0.4" if-watch = "3.2" diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 3769806da8c..06505c7e1c2 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] bytes = "1.6.0" -futures = "0.3.30" +futures = { workspace = true } js-sys = "0.3.69" libp2p-core = { workspace = true } tracing = { workspace = true } diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 5327d6577b3..89436af1f0c 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures-rustls = "0.24.0" either = "1.11.0" -futures = "0.3.30" +futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } parking_lot = "0.12.0" diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index ed3d4f0b8c4..a1bd3832177 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -14,7 +14,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -futures = "0.3.30" +futures = { workspace = true } js-sys = "0.3.69" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } diff --git a/wasm-tests/webtransport-tests/Cargo.toml b/wasm-tests/webtransport-tests/Cargo.toml index f50a3909bd0..2ea3745ee80 100644 --- a/wasm-tests/webtransport-tests/Cargo.toml +++ b/wasm-tests/webtransport-tests/Cargo.toml @@ -9,7 +9,7 @@ publish = false release = false [dependencies] -futures = "0.3.30" +futures = { workspace = true } getrandom = { version = "0.2.14", features = ["js"] } libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } From 9d86b85ba37587ae67eeb336acf802328fb72e19 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 08:27:05 +0000 Subject: [PATCH 080/246] deps: bump parking_lot from 0.12.1 to 0.12.2 Pull-Request: #5345. --- Cargo.lock | 4 ++-- core/Cargo.toml | 2 +- transports/dns/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/websocket/Cargo.toml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c009be3ab93..ca1df9ca639 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4259,9 +4259,9 @@ checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", diff --git a/core/Cargo.toml b/core/Cargo.toml index 92e6e02351a..f06769ebb41 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -21,7 +21,7 @@ multiaddr = { workspace = true } multihash = { workspace = true } multistream-select = { workspace = true } once_cell = "1.19.0" -parking_lot = "0.12.0" +parking_lot = "0.12.2" pin-project = "1.1.5" quick-protobuf = "0.8" rand = "0.8" diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index 329268645ab..78adccc6069 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -16,7 +16,7 @@ async-trait = "0.1.80" futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -parking_lot = "0.12.0" +parking_lot = "0.12.2" hickory-resolver = { version = "0.24.0", default-features = false, features = ["system-config"] } smallvec = "1.13.2" tracing = { workspace = true } diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 26ff0aa6fac..1bbac27d67f 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -17,7 +17,7 @@ if-watch = "3.2.0" libp2p-core = { workspace = true } libp2p-tls = { workspace = true } libp2p-identity = { workspace = true } -parking_lot = "0.12.0" +parking_lot = "0.12.2" quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls", "futures-io"] } rand = "0.8.5" rustls = { version = "0.21.9", default-features = false } diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 06505c7e1c2..a7713e1fa59 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -16,7 +16,7 @@ futures = { workspace = true } js-sys = "0.3.69" libp2p-core = { workspace = true } tracing = { workspace = true } -parking_lot = "0.12.1" +parking_lot = "0.12.2" send_wrapper = "0.6.0" thiserror = "1.0.59" wasm-bindgen = "0.2.90" diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 89436af1f0c..cc10a0ab727 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -16,7 +16,7 @@ either = "1.11.0" futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -parking_lot = "0.12.0" +parking_lot = "0.12.2" pin-project-lite = "0.2.14" rw-stream-sink = { workspace = true } soketto = "0.8.0" From 6b270f6c6bd0ab783d4050569c6bde3d46426705 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 08:43:09 +0000 Subject: [PATCH 081/246] deps: bump data-encoding from 2.5.0 to 2.6.0 Pull-Request: #5346. --- Cargo.lock | 4 ++-- protocols/mdns/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca1df9ca639..c9ea14807af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1259,9 +1259,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "data-encoding-macro" diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 9db161779dc..061651c07d4 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-std = { version = "1.12.0", optional = true } async-io = { version = "2.3.2", optional = true } -data-encoding = "2.5.0" +data-encoding = "2.6.0" futures = { workspace = true } if-watch = "3.2.0" libp2p-core = { workspace = true } From e5c072c04c1e8ae5899b46eb17bdf9a32c4eaeee Mon Sep 17 00:00:00 2001 From: Darius Clark Date: Tue, 30 Apr 2024 08:32:57 -0400 Subject: [PATCH 082/246] fix(relay): use `web_time` `Instant` and `SystemTime` versions for wasm support. Resolves #5305. Pull-Request: #5328. --- Cargo.lock | 2 +- protocols/relay/CHANGELOG.md | 2 ++ protocols/relay/Cargo.toml | 2 +- protocols/relay/src/behaviour.rs | 2 +- protocols/relay/src/behaviour/handler.rs | 2 +- protocols/relay/src/behaviour/rate_limiter.rs | 2 +- protocols/relay/src/protocol/inbound_hop.rs | 3 ++- protocols/relay/src/protocol/outbound_hop.rs | 3 ++- 8 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9ea14807af..67c1ba524ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3189,7 +3189,6 @@ dependencies = [ "futures", "futures-bounded", "futures-timer", - "instant", "libp2p-core", "libp2p-identity", "libp2p-ping", @@ -3206,6 +3205,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", + "web-time", ] [[package]] diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index b88dd7784f2..83dbf4739ac 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -2,6 +2,8 @@ - Fix support for unlimited relay connection according to spec. See [PR 5244](https://github.com/libp2p/rust-libp2p/pull/5244). +- use `web_time` `Instant` and `SystemTime` versions for wasm support. + See [PR 5328](https://github.com/libp2p/rust-libp2p/pull/5328). ## 0.17.1 diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index d4ba1b37d86..35f404d89b4 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -17,7 +17,6 @@ either = "1.11.0" futures = { workspace = true } futures-timer = "3" futures-bounded = { workspace = true } -instant = "0.1.12" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } @@ -28,6 +27,7 @@ static_assertions = "1" thiserror = "1.0" tracing = { workspace = true } void = "1" +web-time = "1" [dev-dependencies] libp2p-identity = { workspace = true, features = ["rand"] } diff --git a/protocols/relay/src/behaviour.rs b/protocols/relay/src/behaviour.rs index df8443e8359..cf0e76e3662 100644 --- a/protocols/relay/src/behaviour.rs +++ b/protocols/relay/src/behaviour.rs @@ -27,7 +27,6 @@ use crate::multiaddr_ext::MultiaddrExt; use crate::proto; use crate::protocol::{inbound_hop, outbound_stop}; use either::Either; -use instant::Instant; use libp2p_core::multiaddr::Protocol; use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; @@ -41,6 +40,7 @@ use std::num::NonZeroU32; use std::ops::Add; use std::task::{Context, Poll}; use std::time::Duration; +use web_time::Instant; /// Configuration for the relay [`Behaviour`]. /// diff --git a/protocols/relay/src/behaviour/handler.rs b/protocols/relay/src/behaviour/handler.rs index 958c6a9b906..92557287099 100644 --- a/protocols/relay/src/behaviour/handler.rs +++ b/protocols/relay/src/behaviour/handler.rs @@ -28,7 +28,6 @@ use futures::future::{BoxFuture, FutureExt, TryFutureExt}; use futures::io::AsyncWriteExt; use futures::stream::{FuturesUnordered, StreamExt}; use futures_timer::Delay; -use instant::Instant; use libp2p_core::upgrade::ReadyUpgrade; use libp2p_core::{ConnectedPoint, Multiaddr}; use libp2p_identity::PeerId; @@ -43,6 +42,7 @@ use std::collections::{HashMap, VecDeque}; use std::task::{Context, Poll}; use std::time::Duration; use std::{fmt, io}; +use web_time::Instant; const MAX_CONCURRENT_STREAMS_PER_CONNECTION: usize = 10; const STREAM_TIMEOUT: Duration = Duration::from_secs(60); diff --git a/protocols/relay/src/behaviour/rate_limiter.rs b/protocols/relay/src/behaviour/rate_limiter.rs index 73c164c121c..45b701c1b50 100644 --- a/protocols/relay/src/behaviour/rate_limiter.rs +++ b/protocols/relay/src/behaviour/rate_limiter.rs @@ -18,7 +18,6 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use instant::Instant; use libp2p_core::multiaddr::{Multiaddr, Protocol}; use libp2p_identity::PeerId; use std::collections::{HashMap, VecDeque}; @@ -26,6 +25,7 @@ use std::hash::Hash; use std::net::IpAddr; use std::num::NonZeroU32; use std::time::Duration; +use web_time::Instant; /// Allows rate limiting access to some resource based on the [`PeerId`] and /// [`Multiaddr`] of a remote peer. diff --git a/protocols/relay/src/protocol/inbound_hop.rs b/protocols/relay/src/protocol/inbound_hop.rs index 41fe2675dce..57b5d9ad039 100644 --- a/protocols/relay/src/protocol/inbound_hop.rs +++ b/protocols/relay/src/protocol/inbound_hop.rs @@ -18,7 +18,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use std::time::{Duration, SystemTime}; +use std::time::Duration; +use web_time::SystemTime; use asynchronous_codec::{Framed, FramedParts}; use bytes::Bytes; diff --git a/protocols/relay/src/protocol/outbound_hop.rs b/protocols/relay/src/protocol/outbound_hop.rs index 3ae824be167..b349f8848be 100644 --- a/protocols/relay/src/protocol/outbound_hop.rs +++ b/protocols/relay/src/protocol/outbound_hop.rs @@ -19,13 +19,14 @@ // DEALINGS IN THE SOFTWARE. use std::io; -use std::time::{Duration, SystemTime}; +use std::time::Duration; use asynchronous_codec::{Framed, FramedParts}; use bytes::Bytes; use futures::prelude::*; use futures_timer::Delay; use thiserror::Error; +use web_time::SystemTime; use libp2p_core::Multiaddr; use libp2p_identity::PeerId; From a91c48fe5e43f245f4f7da600d425c499c3e3bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Wed, 1 May 2024 20:19:09 +0100 Subject: [PATCH 083/246] chore(swarm-derive): lower unreleased version to 0.32.2 `libp2p-swarm-derive` `0.32.2` wasn't released, last released version was `0.32.1` see [here](https://crates.io/crates/libp2p-swarm-derive). Lower `Cargo.toml` and `CHANGELOG.md` to `0.32.2`. Pull-Request: #5350. --- Cargo.lock | 2 +- Cargo.toml | 2 +- swarm-derive/CHANGELOG.md | 4 +--- swarm-derive/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67c1ba524ad..5f7144269d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3339,7 +3339,7 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.34.3" +version = "0.34.2" dependencies = [ "heck 0.5.0", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index dd8efeddb12..d1f53569389 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,7 +102,7 @@ libp2p-request-response = { version = "0.26.2", path = "protocols/request-respon libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } libp2p-swarm = { version = "0.44.2", path = "swarm" } -libp2p-swarm-derive = { version = "=0.34.3", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. +libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } libp2p-tcp = { version = "0.41.0", path = "transports/tcp" } libp2p-tls = { version = "0.3.0", path = "transports/tls" } diff --git a/swarm-derive/CHANGELOG.md b/swarm-derive/CHANGELOG.md index 55f5e571664..271025aee9f 100644 --- a/swarm-derive/CHANGELOG.md +++ b/swarm-derive/CHANGELOG.md @@ -1,10 +1,8 @@ -## 0.34.3 +## 0.34.2 - Generate code for `libp2p-swarm`'s `FromSwarm::NewExternalAddrOfPeer` enum variant. See [PR 4371](https://github.com/libp2p/rust-libp2p/pull/4371). -## 0.34.2 - - Restore support for generic constraints on behaviours combined with `out_event` generated by `NetworkBehaviour` where no where clause is used. See [PR 5003](https://github.com/libp2p/rust-libp2p/pull/5003). diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index 7a8a1062d2c..babcfb8587c 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm-derive" edition = "2021" rust-version = { workspace = true } description = "Procedural macros of libp2p-swarm" -version = "0.34.3" +version = "0.34.2" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" From 9331d9e9c6e9d8f7ff5f185cb1066ace4ac4ce02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Tue, 7 May 2024 01:00:37 +0100 Subject: [PATCH 084/246] chore: address clippy lints for Rust 1.78 Pull-Request: #5368. --- .github/workflows/ci.yml | 2 +- libp2p/src/bandwidth.rs | 8 ++++---- .../tests/{util.rs => util/mod.rs} | 0 misc/metrics/src/bandwidth.rs | 8 ++++---- misc/multistream-select/src/length_delimited.rs | 1 - misc/quickcheck-ext/src/lib.rs | 2 +- protocols/kad/src/kbucket.rs | 2 +- protocols/mdns/src/behaviour/iface/dns.rs | 2 +- protocols/mdns/src/behaviour/timer.rs | 4 ++-- transports/websocket-websys/src/web_context.rs | 3 +++ 10 files changed, 17 insertions(+), 15 deletions(-) rename misc/memory-connection-limits/tests/{util.rs => util/mod.rs} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9069b2eecf1..69528ec80c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -234,7 +234,7 @@ jobs: fail-fast: false matrix: rust-version: [ - 1.77.0, # current stable + 1.78.0, # current stable beta, ] steps: diff --git a/libp2p/src/bandwidth.rs b/libp2p/src/bandwidth.rs index b84cbb7e27b..8931c5c4166 100644 --- a/libp2p/src/bandwidth.rs +++ b/libp2p/src/bandwidth.rs @@ -154,7 +154,7 @@ impl AsyncRead for InstrumentedStream { let this = self.project(); let num_bytes = ready!(this.inner.poll_read(cx, buf))?; this.sinks.inbound.fetch_add( - u64::try_from(num_bytes).unwrap_or(u64::max_value()), + u64::try_from(num_bytes).unwrap_or(u64::MAX), Ordering::Relaxed, ); Poll::Ready(Ok(num_bytes)) @@ -168,7 +168,7 @@ impl AsyncRead for InstrumentedStream { let this = self.project(); let num_bytes = ready!(this.inner.poll_read_vectored(cx, bufs))?; this.sinks.inbound.fetch_add( - u64::try_from(num_bytes).unwrap_or(u64::max_value()), + u64::try_from(num_bytes).unwrap_or(u64::MAX), Ordering::Relaxed, ); Poll::Ready(Ok(num_bytes)) @@ -184,7 +184,7 @@ impl AsyncWrite for InstrumentedStream { let this = self.project(); let num_bytes = ready!(this.inner.poll_write(cx, buf))?; this.sinks.outbound.fetch_add( - u64::try_from(num_bytes).unwrap_or(u64::max_value()), + u64::try_from(num_bytes).unwrap_or(u64::MAX), Ordering::Relaxed, ); Poll::Ready(Ok(num_bytes)) @@ -198,7 +198,7 @@ impl AsyncWrite for InstrumentedStream { let this = self.project(); let num_bytes = ready!(this.inner.poll_write_vectored(cx, bufs))?; this.sinks.outbound.fetch_add( - u64::try_from(num_bytes).unwrap_or(u64::max_value()), + u64::try_from(num_bytes).unwrap_or(u64::MAX), Ordering::Relaxed, ); Poll::Ready(Ok(num_bytes)) diff --git a/misc/memory-connection-limits/tests/util.rs b/misc/memory-connection-limits/tests/util/mod.rs similarity index 100% rename from misc/memory-connection-limits/tests/util.rs rename to misc/memory-connection-limits/tests/util/mod.rs diff --git a/misc/metrics/src/bandwidth.rs b/misc/metrics/src/bandwidth.rs index 2792e00612c..ac6a4178ce9 100644 --- a/misc/metrics/src/bandwidth.rs +++ b/misc/metrics/src/bandwidth.rs @@ -255,7 +255,7 @@ impl AsyncRead for InstrumentedStream { let num_bytes = ready!(this.inner.poll_read(cx, buf))?; this.metrics .inbound - .inc_by(u64::try_from(num_bytes).unwrap_or(u64::max_value())); + .inc_by(u64::try_from(num_bytes).unwrap_or(u64::MAX)); Poll::Ready(Ok(num_bytes)) } @@ -268,7 +268,7 @@ impl AsyncRead for InstrumentedStream { let num_bytes = ready!(this.inner.poll_read_vectored(cx, bufs))?; this.metrics .inbound - .inc_by(u64::try_from(num_bytes).unwrap_or(u64::max_value())); + .inc_by(u64::try_from(num_bytes).unwrap_or(u64::MAX)); Poll::Ready(Ok(num_bytes)) } } @@ -283,7 +283,7 @@ impl AsyncWrite for InstrumentedStream { let num_bytes = ready!(this.inner.poll_write(cx, buf))?; this.metrics .outbound - .inc_by(u64::try_from(num_bytes).unwrap_or(u64::max_value())); + .inc_by(u64::try_from(num_bytes).unwrap_or(u64::MAX)); Poll::Ready(Ok(num_bytes)) } @@ -296,7 +296,7 @@ impl AsyncWrite for InstrumentedStream { let num_bytes = ready!(this.inner.poll_write_vectored(cx, bufs))?; this.metrics .outbound - .inc_by(u64::try_from(num_bytes).unwrap_or(u64::max_value())); + .inc_by(u64::try_from(num_bytes).unwrap_or(u64::MAX)); Poll::Ready(Ok(num_bytes)) } diff --git a/misc/multistream-select/src/length_delimited.rs b/misc/multistream-select/src/length_delimited.rs index 6515d00c717..3a7988d0548 100644 --- a/misc/multistream-select/src/length_delimited.rs +++ b/misc/multistream-select/src/length_delimited.rs @@ -25,7 +25,6 @@ use std::{ io, pin::Pin, task::{Context, Poll}, - u16, }; const MAX_LEN_BYTES: u16 = 2; diff --git a/misc/quickcheck-ext/src/lib.rs b/misc/quickcheck-ext/src/lib.rs index a3b9ce26e6e..4ada7e73ba1 100644 --- a/misc/quickcheck-ext/src/lib.rs +++ b/misc/quickcheck-ext/src/lib.rs @@ -9,7 +9,7 @@ pub trait GenRange { fn gen_range(&mut self, _range: Range) -> T; fn gen_index(&mut self, ubound: usize) -> usize { - if ubound <= (core::u32::MAX as usize) { + if ubound <= (u32::MAX as usize) { self.gen_range(0..ubound as u32) as usize } else { self.gen_range(0..ubound) diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index 459f769fb12..6eb2e42909a 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -594,7 +594,7 @@ mod tests { assert!(!bucket_ref.contains(&Distance(min.0 - 1))); } - if max != Distance(U256::max_value()) { + if max != Distance(U256::MAX) { // ^ avoid overflow assert!(!bucket_ref.contains(&Distance(max.0 + 1))); } diff --git a/protocols/mdns/src/behaviour/iface/dns.rs b/protocols/mdns/src/behaviour/iface/dns.rs index 41ce9efa714..39dbf08c731 100644 --- a/protocols/mdns/src/behaviour/iface/dns.rs +++ b/protocols/mdns/src/behaviour/iface/dns.rs @@ -247,7 +247,7 @@ fn duration_to_secs(duration: Duration) -> u32 { let secs = duration .as_secs() .saturating_add(u64::from(duration.subsec_nanos() > 0)); - cmp::min(secs, From::from(u32::max_value())) as u32 + cmp::min(secs, From::from(u32::MAX)) as u32 } /// Appends a big-endian u32 to `out`. diff --git a/protocols/mdns/src/behaviour/timer.rs b/protocols/mdns/src/behaviour/timer.rs index 4f6ceec306d..5e284654676 100644 --- a/protocols/mdns/src/behaviour/timer.rs +++ b/protocols/mdns/src/behaviour/timer.rs @@ -98,7 +98,7 @@ pub(crate) mod tokio { // Taken from: https://docs.rs/async-io/1.7.0/src/async_io/lib.rs.html#91 let mut inner = time::interval_at( TokioInstant::from_std(instant), - Duration::new(std::u64::MAX, 1_000_000_000 - 1), + Duration::new(u64::MAX, 1_000_000_000 - 1), ); inner.set_missed_tick_behavior(MissedTickBehavior::Skip); Self { inner } @@ -125,7 +125,7 @@ pub(crate) mod tokio { } fn size_hint(&self) -> (usize, Option) { - (std::usize::MAX, None) + (usize::MAX, None) } } } diff --git a/transports/websocket-websys/src/web_context.rs b/transports/websocket-websys/src/web_context.rs index 2b5d7b46431..40efbb1d9b0 100644 --- a/transports/websocket-websys/src/web_context.rs +++ b/transports/websocket-websys/src/web_context.rs @@ -1,3 +1,6 @@ +// TODO: remove when https://github.com/rust-lang/rust-clippy/issues/12377 fix lands in stable clippy. +#![allow(clippy::empty_docs)] + use wasm_bindgen::prelude::*; use web_sys::window; From 910bf7671afc0ed5acdc314a607964387f161f4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 08:31:05 +0000 Subject: [PATCH 085/246] deps: bump r7kamura/rust-problem-matchers from 1.4.0 to 1.5.0 Pull-Request: #5356. --- .github/workflows/ci.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69528ec80c2..828882b4615 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: with: fetch-depth: 0 - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - uses: dtolnay/rust-toolchain@stable @@ -156,7 +156,7 @@ jobs: with: target: ${{ matrix.target }} - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 with: @@ -181,7 +181,7 @@ jobs: with: toolchain: ${{ env.MSRV }} - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 with: @@ -202,7 +202,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 with: @@ -219,7 +219,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 with: @@ -245,7 +245,7 @@ jobs: toolchain: ${{ matrix.rust-version }} components: clippy - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 with: @@ -261,7 +261,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 with: @@ -280,7 +280,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 with: @@ -330,7 +330,7 @@ jobs: with: components: rustfmt - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - name: Check formatting run: cargo fmt -- --check @@ -342,7 +342,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: r7kamura/rust-problem-matchers@2c2f1016021a7455a6b5b4bbae31145f3b3cd83a #v1.4.0 + - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - name: Ensure `full` feature contains all features run: | From b9353d5770b3bca9589ef97b640936154dda7158 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 11:37:41 +0000 Subject: [PATCH 086/246] deps: bump num-traits from 0.2.18 to 0.2.19 Pull-Request: #5365. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f7144269d1..93c3b611249 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4032,9 +4032,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] From d64173a492b6b3ff86cd43b186d51c7ad61471a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 11:50:56 +0000 Subject: [PATCH 087/246] deps: bump base64 from 0.22.0 to 0.22.1 Pull-Request: #5363. --- Cargo.lock | 20 ++++++++++---------- identity/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 93c3b611249..74f9d02b65c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -678,9 +678,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -2573,7 +2573,7 @@ dependencies = [ name = "keygen" version = "0.1.0" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "clap", "libp2p-core", "libp2p-identity", @@ -2817,7 +2817,7 @@ version = "0.46.1" dependencies = [ "async-std", "asynchronous-codec", - "base64 0.22.0", + "base64 0.22.1", "byteorder", "bytes", "either", @@ -2877,7 +2877,7 @@ name = "libp2p-identity" version = "0.2.8" dependencies = [ "asn1_der", - "base64 0.22.0", + "base64 0.22.1", "bs58", "criterion", "ed25519-dalek", @@ -3272,7 +3272,7 @@ name = "libp2p-server" version = "0.12.7" dependencies = [ "axum 0.7.5", - "base64 0.22.0", + "base64 0.22.1", "clap", "futures", "futures-timer", @@ -4888,7 +4888,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "bytes", "encoding_rs", "futures-core", @@ -5174,7 +5174,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "rustls-pki-types", ] @@ -5596,7 +5596,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "bytes", "futures", "httparse", @@ -5839,7 +5839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0641fa1353dd7b7864a7a7782e495433de18a9096bc91b5a2d5838ac209c2fa8" dependencies = [ "async-trait", - "base64 0.22.0", + "base64 0.22.1", "futures", "http 1.0.0", "indexmap 2.2.1", diff --git a/identity/Cargo.toml b/identity/Cargo.toml index fbc7bae3d11..fac5c8dea48 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -42,7 +42,7 @@ rand = ["dep:rand", "ed25519-dalek?/rand_core"] [dev-dependencies] quickcheck = { workspace = true } -base64 = "0.22.0" +base64 = "0.22.1" serde_json = "1.0" rmp-serde = "1.2" criterion = "0.5" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 5b1a2673588..0c6f0d15e33 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -18,7 +18,7 @@ zeroize = "1" serde = { version = "1.0.198", features = ["derive"] } serde_json = "1.0.116" libp2p-core = { workspace = true } -base64 = "0.22.0" +base64 = "0.22.1" libp2p-identity = { workspace = true } [lints] diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 3a5e27f7b5f..dbe9e6c161c 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -15,7 +15,7 @@ wasm-bindgen = ["getrandom/js", "instant/wasm-bindgen"] [dependencies] asynchronous-codec = { workspace = true } -base64 = "0.22.0" +base64 = "0.22.1" byteorder = "1.5.0" bytes = "1.6" either = "1.11" From adb0d236f3eac6b6a90160acfcc75391137f4415 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 12:02:31 +0000 Subject: [PATCH 088/246] deps: bump trybuild from 1.0.91 to 1.0.93 Pull-Request: #5362. --- Cargo.lock | 5 ++--- swarm/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 74f9d02b65c..565eb6a4bcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6256,12 +6256,11 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "trybuild" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad7eb6319ebadebca3dacf1f85a93bc54b73dd81b9036795f73de7ddfe27d5a" +checksum = "2a0e5d82932dfbf36df38de5df0cfe846d13430b3ae3fdc48b2e91ed692c8df7" dependencies = [ "glob", - "once_cell", "serde", "serde_derive", "serde_json", diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index ad224b6168d..2a928dc0467 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -54,7 +54,7 @@ libp2p-yamux = { path = "../muxers/yamux" } # Using `pat quickcheck = { workspace = true } void = "1" once_cell = "1.19.0" -trybuild = "1.0.91" +trybuild = "1.0.93" tokio = { workspace = true, features = ["time", "rt", "macros", "rt-multi-thread"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } From 0ba0b8a51944983c87ca7feddb3219591f29c2dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 12:14:39 +0000 Subject: [PATCH 089/246] deps: bump tokio-util from 0.7.10 to 0.7.11 Pull-Request: #5361. --- Cargo.lock | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 565eb6a4bcd..0236820a31f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6026,9 +6026,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", @@ -6036,7 +6036,6 @@ dependencies = [ "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] From 6df23046ffad2e97260ed9a56878988ea783ea42 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 12:38:20 +0000 Subject: [PATCH 090/246] deps: bump rmp-serde from 1.2.0 to 1.3.0 Pull-Request: #5360. --- Cargo.lock | 4 ++-- identity/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0236820a31f..143b9d6fcf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5000,9 +5000,9 @@ dependencies = [ [[package]] name = "rmp-serde" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938a142ab806f18b88a97b0dea523d39e0fd730a064b035726adcfc58a8a5188" +checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" dependencies = [ "byteorder", "rmp", diff --git a/identity/Cargo.toml b/identity/Cargo.toml index fac5c8dea48..40af2f9a972 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -44,7 +44,7 @@ rand = ["dep:rand", "ed25519-dalek?/rand_core"] quickcheck = { workspace = true } base64 = "0.22.1" serde_json = "1.0" -rmp-serde = "1.2" +rmp-serde = "1.3" criterion = "0.5" hex-literal = "0.4.1" From fa55c621012c673a8682e4ab9f5b2c6750d930a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 12:50:41 +0000 Subject: [PATCH 091/246] deps: bump serde from 1.0.198 to 1.0.199 Pull-Request: #5344. --- Cargo.lock | 8 ++++---- hole-punching-tests/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 143b9d6fcf0..c78de716a06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5348,18 +5348,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.198" +version = "1.0.199" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.199" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" dependencies = [ "proc-macro2", "quote", diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 6e0c692b5c9..b38c54fb586 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -13,6 +13,6 @@ libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { workspace = true, features = ["full"] } -serde = { version = "1.0.198", features = ["derive"] } +serde = { version = "1.0.199", features = ["derive"] } serde_json = "1.0.116" either = "1.11.0" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 0c6f0d15e33..d7de2725b0c 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -15,7 +15,7 @@ release = false [dependencies] clap = { version = "4.5.4", features = ["derive"] } zeroize = "1" -serde = { version = "1.0.198", features = ["derive"] } +serde = { version = "1.0.199", features = ["derive"] } serde_json = "1.0.116" libp2p-core = { workspace = true } base64 = "0.22.1" diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index f304d4b6346..59b71e5759d 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -18,7 +18,7 @@ futures-timer = "3" axum = "0.7" libp2p = { workspace = true, features = ["autonat", "dns", "tokio", "noise", "tcp", "yamux", "identify", "kad", "ping", "relay", "metrics", "rsa", "macros", "quic", "websocket"] } prometheus-client = { workspace = true } -serde = "1.0.198" +serde = "1.0.199" serde_derive = "1.0.125" serde_json = "1.0" tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } From 625743bd37482d4b590620695ba3d6dcd3009125 Mon Sep 17 00:00:00 2001 From: Kapena Cunmin <168894316+kapenacunmin@users.noreply.github.com> Date: Thu, 9 May 2024 18:47:47 +0800 Subject: [PATCH 092/246] chore: fix typo at pull_request_template.md `mesages` to `messages` Pull-Request: #5370. --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index f724d2fd7de..90e8b2cda53 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,7 +4,7 @@ Please write a summary of your changes and why you made them. This section will appear as the commit message after merging. Please craft it accordingly. -For a quick primer on good commit mesages, check out this blog post: https://cbea.ms/git-commit/ +For a quick primer on good commit messages, check out this blog post: https://cbea.ms/git-commit/ Please include any relevant issues in here, for example: From 0e11c61b2a6e20f6838e9cb906c9bf8cfb53c04b Mon Sep 17 00:00:00 2001 From: "zkElton.eth" <123023258+elton-cs@users.noreply.github.com> Date: Thu, 9 May 2024 07:39:47 -0500 Subject: [PATCH 093/246] chore: add missing "cbor" feature flag on test Found a failing test while looking through the request-response protocol crate. The function `dial_succeeds_after_adding_peers_address()` was just missing the `cbor` feature flag. Added the flag and the test passed. Pull-Request: #5321. --- protocols/request-response/tests/peer_address.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/protocols/request-response/tests/peer_address.rs b/protocols/request-response/tests/peer_address.rs index 2a120931dcd..0ed7ffe5551 100644 --- a/protocols/request-response/tests/peer_address.rs +++ b/protocols/request-response/tests/peer_address.rs @@ -8,6 +8,7 @@ use std::iter; use tracing_subscriber::EnvFilter; #[async_std::test] +#[cfg(feature = "cbor")] async fn dial_succeeds_after_adding_peers_address() { let _ = tracing_subscriber::fmt() .with_env_filter(EnvFilter::from_default_env()) From b88ff17173ffe1b88d8cfe489033ea3a3f1df75e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 08:34:59 +0000 Subject: [PATCH 094/246] deps: bump libc from 0.2.153 to 0.2.154 Pull-Request: #5367. --- Cargo.lock | 4 ++-- transports/tcp/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c78de716a06..415accc9e0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2599,9 +2599,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libp2p" diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 6a463a72062..41d128506dd 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -15,7 +15,7 @@ async-io = { version = "2.3.2", optional = true } futures = { workspace = true } futures-timer = "3.0" if-watch = "3.2.0" -libc = "0.2.153" +libc = "0.2.154" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } socket2 = { version = "0.5.6", features = ["all"] } From b37a788beac8d957b80bb878bb32898c51c6b72c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 08:55:37 +0000 Subject: [PATCH 095/246] deps: bump proc-macro2 from 1.0.81 to 1.0.82 Pull-Request: #5373. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 415accc9e0d..2aa830da03b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4498,9 +4498,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] From 95e0fca97fc1c686705fdfae939bfb06e5be7044 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 09:06:40 +0000 Subject: [PATCH 096/246] deps: bump serde from 1.0.199 to 1.0.201 Pull-Request: #5374. --- Cargo.lock | 8 ++++---- hole-punching-tests/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2aa830da03b..c3530cdcb7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5348,18 +5348,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.199" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index b38c54fb586..5f93c158b98 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -13,6 +13,6 @@ libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { workspace = true, features = ["full"] } -serde = { version = "1.0.199", features = ["derive"] } +serde = { version = "1.0.201", features = ["derive"] } serde_json = "1.0.116" either = "1.11.0" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index d7de2725b0c..93639e309ce 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -15,7 +15,7 @@ release = false [dependencies] clap = { version = "4.5.4", features = ["derive"] } zeroize = "1" -serde = { version = "1.0.199", features = ["derive"] } +serde = { version = "1.0.201", features = ["derive"] } serde_json = "1.0.116" libp2p-core = { workspace = true } base64 = "0.22.1" diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 59b71e5759d..3fb69fdf20f 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -18,7 +18,7 @@ futures-timer = "3" axum = "0.7" libp2p = { workspace = true, features = ["autonat", "dns", "tokio", "noise", "tcp", "yamux", "identify", "kad", "ping", "relay", "metrics", "rsa", "macros", "quic", "websocket"] } prometheus-client = { workspace = true } -serde = "1.0.199" +serde = "1.0.201" serde_derive = "1.0.125" serde_json = "1.0" tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } From c6c09ad7d6262e3056283ea4e2bc8f94d7f2612e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 09:18:14 +0000 Subject: [PATCH 097/246] deps: bump trybuild from 1.0.93 to 1.0.95 Pull-Request: #5375. --- Cargo.lock | 4 ++-- swarm/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3530cdcb7e..b89316ee94e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6255,9 +6255,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "trybuild" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0e5d82932dfbf36df38de5df0cfe846d13430b3ae3fdc48b2e91ed692c8df7" +checksum = "4ddb747392ea12569d501a5bbca08852e4c8cd88b92566074b2243b8846f09e6" dependencies = [ "glob", "serde", diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 2a928dc0467..13fdfa3757e 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -54,7 +54,7 @@ libp2p-yamux = { path = "../muxers/yamux" } # Using `pat quickcheck = { workspace = true } void = "1" once_cell = "1.19.0" -trybuild = "1.0.93" +trybuild = "1.0.95" tokio = { workspace = true, features = ["time", "rt", "macros", "rt-multi-thread"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } From 6e528cac7a4a51a82892d95daac94ddd2795b1cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 09:43:42 +0000 Subject: [PATCH 098/246] deps: bump syn from 2.0.60 to 2.0.63 Pull-Request: #5377. --- Cargo.lock | 58 ++++++++++++++++++++--------------------- swarm-derive/Cargo.toml | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b89316ee94e..febdea9d0f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "synstructure 0.13.1", ] @@ -247,7 +247,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -469,7 +469,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -486,7 +486,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -988,7 +988,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1254,7 +1254,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1385,7 +1385,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1490,7 +1490,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1726,7 +1726,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -3344,7 +3344,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -4117,7 +4117,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -4328,7 +4328,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -4525,7 +4525,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -4548,7 +4548,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5070,7 +5070,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.60", + "syn 2.0.63", "walkdir", ] @@ -5363,7 +5363,7 @@ checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5396,7 +5396,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5681,7 +5681,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5731,9 +5731,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" dependencies = [ "proc-macro2", "quote", @@ -5772,7 +5772,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5887,7 +5887,7 @@ checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -5989,7 +5989,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -6176,7 +6176,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -6517,7 +6517,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "wasm-bindgen-shared", ] @@ -6551,7 +6551,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6584,7 +6584,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -7192,7 +7192,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -7212,5 +7212,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index babcfb8587c..407436766dc 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true [dependencies] heck = "0.5" quote = "1.0" -syn = { version = "2.0.60", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.63", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" # Passing arguments to the docsrs builder in order to properly document cfg's. From 64a4cf4156e6777fd1394fda9771a6c76d49b133 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 09:55:10 +0000 Subject: [PATCH 099/246] deps: bump rust-embed from 8.3.0 to 8.4.0 Pull-Request: #5378. --- Cargo.lock | 12 ++++++------ examples/browser-webrtc/Cargo.toml | 2 +- interop-tests/Cargo.toml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index febdea9d0f5..17fe3d3907f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5051,9 +5051,9 @@ dependencies = [ [[package]] name = "rust-embed" -version = "8.3.0" +version = "8.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb78f46d0066053d16d4ca7b898e9343bc3530f71c61d5ad84cd404ada068745" +checksum = "19549741604902eb99a7ed0ee177a0663ee1eda51a29f71401f166e47e77806a" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -5062,9 +5062,9 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "8.3.0" +version = "8.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91ac2a3c6c0520a3fb3dd89321177c3c692937c4eb21893378219da10c44fc8" +checksum = "cb9f96e283ec64401f30d3df8ee2aaeb2561f34c824381efa24a35f79bf40ee4" dependencies = [ "proc-macro2", "quote", @@ -5076,9 +5076,9 @@ dependencies = [ [[package]] name = "rust-embed-utils" -version = "8.3.0" +version = "8.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f69089032567ffff4eada41c573fc43ff466c7db7c5688b2e7969584345581" +checksum = "38c74a686185620830701348de757fd36bef4aa9680fd23c49fc539ddcc1af32" dependencies = [ "globset", "sha2 0.10.8", diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index ec95b75287f..1744482dddf 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -26,7 +26,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } axum = "0.7.5" libp2p = { path = "../../libp2p", features = [ "ed25519", "macros", "ping", "tokio"] } libp2p-webrtc = { workspace = true, features = ["tokio"] } -rust-embed = { version = "8.3.0", features = ["include-exclude", "interpolate-folder-path"] } +rust-embed = { version = "8.4.0", features = ["include-exclude", "interpolate-folder-path"] } tokio = { workspace = true, features = ["macros", "net", "rt", "signal"] } tokio-util = { version = "0.7", features = ["compat"] } tower = "0.4" diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index cfc85b75755..091ecc86558 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -31,7 +31,7 @@ mime_guess = "2.0" redis = { version = "0.23.3", default-features = false, features = [ "tokio-comp", ] } -rust-embed = "8.3" +rust-embed = "8.4" serde_json = "1" thirtyfour = "=0.32.0" # https://github.com/stevepryde/thirtyfour/issues/169 tokio = { workspace = true, features = ["full"] } From 5f04badcc7eb1d4ed32c470f1a126cdcbd41e5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Mon, 13 May 2024 13:31:32 +0100 Subject: [PATCH 100/246] chore: remove default-features on futures remove default-features on futures subcrate imports to avoid warnings Pull-Request: #5381. --- protocols/rendezvous/Cargo.toml | 2 +- transports/tls/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index 2937cbbdd93..0de7e5fc2d2 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] asynchronous-codec = { workspace = true } async-trait = "0.1" bimap = "0.6.3" -futures = { workspace = true, default-features = false, features = ["std"] } +futures = { workspace = true, features = ["std"] } futures-timer = "3.0.3" instant = "0.1.12" libp2p-core = { workspace = true } diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 1494f110c97..1211dcf2dcf 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" exclude = ["src/test_assets"] [dependencies] -futures = { workspace = true, default-features = false } +futures = { workspace = true } futures-rustls = "0.24.0" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } From 65ffb8e7167f7716e40d593e05119ebb9f66e4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Mon, 13 May 2024 14:15:13 +0100 Subject: [PATCH 101/246] deps: update ring to 0.17.8 deps: update ring to 0.17.8 and move it to a workspace dependency `quic`'s `ring` dependency will be upgraded in its own PR as it also needs `quinn` to be upgraded Pull-Request: #5382. --- Cargo.lock | 23 ++++++++++++----------- Cargo.toml | 1 + identity/Cargo.toml | 4 ++-- transports/tls/Cargo.toml | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17fe3d3907f..7e6477dc99b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2889,7 +2889,7 @@ dependencies = [ "quick-protobuf", "quickcheck-ext", "rand 0.8.5", - "ring 0.17.5", + "ring 0.17.8", "rmp-serde", "sec1", "serde", @@ -3395,7 +3395,7 @@ dependencies = [ "libp2p-swarm", "libp2p-yamux", "rcgen", - "ring 0.16.20", + "ring 0.17.8", "rustls 0.21.11", "rustls-webpki 0.101.7", "thiserror", @@ -4966,16 +4966,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.5" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom 0.2.14", "libc", "spin 0.9.8", "untrusted 0.9.0", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -5149,7 +5150,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" dependencies = [ "log", - "ring 0.17.5", + "ring 0.17.8", "rustls-webpki 0.101.7", "sct", ] @@ -5161,7 +5162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", - "ring 0.17.5", + "ring 0.17.8", "rustls-pki-types", "rustls-webpki 0.102.2", "subtle", @@ -5190,7 +5191,7 @@ version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.17.5", + "ring 0.17.8", "untrusted 0.9.0", ] @@ -5200,7 +5201,7 @@ version = "0.102.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" dependencies = [ - "ring 0.17.5", + "ring 0.17.8", "rustls-pki-types", "untrusted 0.9.0", ] @@ -5564,7 +5565,7 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek", "rand_core 0.6.4", - "ring 0.17.5", + "ring 0.17.8", "rustc_version", "sha2 0.10.8", "subtle", @@ -5695,7 +5696,7 @@ dependencies = [ "lazy_static", "md-5", "rand 0.8.5", - "ring 0.17.5", + "ring 0.17.8", "subtle", "thiserror", "tokio", diff --git a/Cargo.toml b/Cargo.toml index d1f53569389..ec38ffb72fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -126,6 +126,7 @@ unsigned-varint = { version = "0.8.0" } tokio = { version = "1.37", default-features = false } tracing = "0.1.37" futures = "0.3.30" +ring = "0.17.8" [patch.crates-io] diff --git a/identity/Cargo.toml b/identity/Cargo.toml index 40af2f9a972..2e3a75475a1 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -19,7 +19,7 @@ hkdf = { version = "0.12.4", optional = true } libsecp256k1 = { version = "0.7.0", optional = true } tracing = { workspace = true } multihash = { version = "0.19.1", optional = true } -p256 = { version = "0.13", default-features = false, features = [ "ecdsa", "std", "pem"], optional = true } +p256 = { version = "0.13", default-features = false, features = ["ecdsa", "std", "pem"], optional = true } quick-protobuf = "0.8.1" rand = { version = "0.8", optional = true } sec1 = { version = "0.7", default-features = false, optional = true } @@ -30,7 +30,7 @@ void = { version = "1.0", optional = true } zeroize = { version = "1.7", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -ring = { version = "0.17.5", features = [ "alloc", "std"], default-features = false, optional = true } +ring = { workspace = true, features = ["alloc", "std"], optional = true } [features] secp256k1 = ["dep:libsecp256k1", "dep:asn1_der", "dep:sha2", "dep:hkdf", "dep:zeroize"] diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 1211dcf2dcf..7fad6c1f45b 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -14,7 +14,7 @@ futures-rustls = "0.24.0" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } rcgen = "0.11.3" -ring = "0.16.20" +ring = { workspace = true } thiserror = "1.0.59" webpki = { version = "0.101.4", package = "rustls-webpki", features = ["std"] } x509-parser = "0.16.0" From ae0a187e4adf8946e9046c001154b364ca637ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Tue, 14 May 2024 10:39:01 +0100 Subject: [PATCH 102/246] deps(websocket): update futures-rustls to 0.26.0 Pull-Request: #5384. --- Cargo.lock | 29 ++++++++++++++-- transports/websocket/Cargo.toml | 2 +- transports/websocket/src/framed.rs | 2 +- transports/websocket/src/tls.rs | 55 +++++++++++++++++++----------- 4 files changed, 64 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7e6477dc99b..a054df9fb35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1739,6 +1739,17 @@ dependencies = [ "rustls 0.21.11", ] +[[package]] +name = "futures-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" +dependencies = [ + "futures-io", + "rustls 0.23.5", + "rustls-pki-types", +] + [[package]] name = "futures-sink" version = "0.3.30" @@ -3387,7 +3398,7 @@ name = "libp2p-tls" version = "0.3.0" dependencies = [ "futures", - "futures-rustls", + "futures-rustls 0.24.0", "hex", "hex-literal", "libp2p-core", @@ -3508,7 +3519,7 @@ dependencies = [ "async-std", "either", "futures", - "futures-rustls", + "futures-rustls 0.26.0", "libp2p-core", "libp2p-dns", "libp2p-identity", @@ -5169,6 +5180,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls" +version = "0.23.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afabcee0551bd1aa3e18e5adbf2c0544722014b899adb31bd186ec638d3da97e" +dependencies = [ + "once_cell", + "ring 0.17.8", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + [[package]] name = "rustls-pemfile" version = "2.1.2" diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index cc10a0ab727..9156da7c83b 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -futures-rustls = "0.24.0" +futures-rustls = { version = "0.26.0", default-features = false, features = ["ring"] } either = "1.11.0" futures = { workspace = true } libp2p-core = { workspace = true } diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index ab7bfda43db..26634df9830 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -461,7 +461,7 @@ where struct WsAddress { host_port: String, path: String, - dns_name: Option, + dns_name: Option>, use_tls: bool, tcp_addr: Multiaddr, } diff --git a/transports/websocket/src/tls.rs b/transports/websocket/src/tls.rs index 24b0df97db3..77090e21675 100644 --- a/transports/websocket/src/tls.rs +++ b/transports/websocket/src/tls.rs @@ -35,24 +35,32 @@ impl fmt::Debug for Config { } /// Private key, DER-encoded ASN.1 in either PKCS#8 or PKCS#1 format. -#[derive(Clone)] -pub struct PrivateKey(rustls::PrivateKey); +pub struct PrivateKey(rustls::pki_types::PrivateKeyDer<'static>); impl PrivateKey { /// Assert the given bytes are DER-encoded ASN.1 in either PKCS#8 or PKCS#1 format. pub fn new(bytes: Vec) -> Self { - PrivateKey(rustls::PrivateKey(bytes)) + PrivateKey( + rustls::pki_types::PrivateKeyDer::try_from(bytes) + .expect("unknown or invalid key format"), + ) + } +} + +impl Clone for PrivateKey { + fn clone(&self) -> Self { + Self(self.0.clone_key()) } } /// Certificate, DER-encoded X.509 format. #[derive(Debug, Clone)] -pub struct Certificate(rustls::Certificate); +pub struct Certificate(rustls::pki_types::CertificateDer<'static>); impl Certificate { /// Assert the given bytes are in DER-encoded X.509 format. pub fn new(bytes: Vec) -> Self { - Certificate(rustls::Certificate(bytes)) + Certificate(rustls::pki_types::CertificateDer::from(bytes)) } } @@ -69,8 +77,10 @@ impl Config { /// Create a client-only configuration. pub fn client() -> Self { - let client = rustls::ClientConfig::builder() - .with_safe_defaults() + let provider = rustls::crypto::ring::default_provider(); + let client = rustls::ClientConfig::builder_with_provider(provider.into()) + .with_safe_default_protocol_versions() + .unwrap() .with_root_certificates(client_root_store()) .with_no_client_auth(); Config { @@ -91,12 +101,12 @@ impl Config { /// Setup the rustls client configuration. fn client_root_store() -> rustls::RootCertStore { let mut client_root_store = rustls::RootCertStore::empty(); - client_root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| { - rustls::OwnedTrustAnchor::from_subject_spki_name_constraints( - ta.subject, - ta.spki, - ta.name_constraints, - ) + client_root_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| { + rustls::pki_types::TrustAnchor { + subject: ta.subject.into(), + subject_public_key_info: ta.spki.into(), + name_constraints: ta.name_constraints.map(|v| v.into()), + } })); client_root_store } @@ -114,8 +124,10 @@ impl Builder { I: IntoIterator, { let certs = certs.into_iter().map(|c| c.0).collect(); - let server = rustls::ServerConfig::builder() - .with_safe_defaults() + let provider = rustls::crypto::ring::default_provider(); + let server = rustls::ServerConfig::builder_with_provider(provider.into()) + .with_safe_default_protocol_versions() + .unwrap() .with_no_client_auth() .with_single_cert(certs, key.0) .map_err(|e| Error::Tls(Box::new(e)))?; @@ -126,15 +138,17 @@ impl Builder { /// Add an additional trust anchor. pub fn add_trust(&mut self, cert: &Certificate) -> Result<&mut Self, Error> { self.client_root_store - .add(&cert.0) + .add(cert.0.to_owned()) .map_err(|e| Error::Tls(Box::new(e)))?; Ok(self) } /// Finish configuration. pub fn finish(self) -> Config { - let client = rustls::ClientConfig::builder() - .with_safe_defaults() + let provider = rustls::crypto::ring::default_provider(); + let client = rustls::ClientConfig::builder_with_provider(provider.into()) + .with_safe_default_protocol_versions() + .unwrap() .with_root_certificates(self.client_root_store) .with_no_client_auth(); @@ -145,8 +159,9 @@ impl Builder { } } -pub(crate) fn dns_name_ref(name: &str) -> Result { - rustls::ServerName::try_from(name).map_err(|_| Error::InvalidDnsName(name.into())) +pub(crate) fn dns_name_ref(name: &str) -> Result, Error> { + rustls::pki_types::ServerName::try_from(String::from(name)) + .map_err(|_| Error::InvalidDnsName(name.into())) } // Error ////////////////////////////////////////////////////////////////////////////////////////// From 6061172518b4b3ed9fdb609b734ba4f2e31e8226 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 15:46:15 +0000 Subject: [PATCH 103/246] chore(deps): bump golang.org/x/net from 0.21.0 to 0.23.0 Pull-Request: #5325. --- .../webtransport-tests/echo-server/go.mod | 48 +--- .../webtransport-tests/echo-server/go.sum | 227 +++--------------- 2 files changed, 35 insertions(+), 240 deletions(-) diff --git a/wasm-tests/webtransport-tests/echo-server/go.mod b/wasm-tests/webtransport-tests/echo-server/go.mod index 1df54d5dbea..e2e0c6591ba 100644 --- a/wasm-tests/webtransport-tests/echo-server/go.mod +++ b/wasm-tests/webtransport-tests/echo-server/go.mod @@ -5,85 +5,49 @@ go 1.22 require ( github.com/libp2p/go-libp2p v0.33.1 github.com/multiformats/go-multiaddr v0.12.2 + github.com/quic-go/quic-go v0.42.0 ) require ( github.com/benbjohnson/clock v1.3.5 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/containerd/cgroups v1.1.0 // indirect - github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect - github.com/docker/go-units v0.5.0 // indirect - github.com/elastic/gosigar v0.14.2 // indirect github.com/flynn/noise v1.1.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect - github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/gopacket v1.1.19 // indirect github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect - github.com/gorilla/websocket v1.5.1 // indirect - github.com/huin/goupnp v1.3.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-log/v2 v2.5.1 // indirect - github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/klauspost/compress v1.17.6 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect - github.com/koron/go-ssdp v0.0.4 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/libp2p/go-flow-metrics v0.1.0 // indirect - github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect - github.com/libp2p/go-msgio v0.3.0 // indirect - github.com/libp2p/go-nat v0.2.0 // indirect github.com/libp2p/go-netroute v0.2.1 // indirect - github.com/libp2p/go-reuseport v0.4.0 // indirect - github.com/libp2p/go-yamux/v4 v4.0.1 // indirect - github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/miekg/dns v1.1.58 // indirect - github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect - github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect github.com/minio/sha256-simd v1.0.1 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.2.0 // indirect - github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect - github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect github.com/multiformats/go-multibase v0.2.0 // indirect github.com/multiformats/go-multicodec v0.9.0 // indirect github.com/multiformats/go-multihash v0.2.3 // indirect github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/onsi/ginkgo/v2 v2.15.0 // indirect - github.com/opencontainers/runtime-spec v1.2.0 // indirect - github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect - github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/quic-go v0.42.0 // indirect github.com/quic-go/webtransport-go v0.6.0 // indirect - github.com/raulk/go-watchdog v1.3.0 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - go.uber.org/atomic v1.11.0 // indirect - go.uber.org/dig v1.17.1 // indirect - go.uber.org/fx v1.20.1 // indirect go.uber.org/mock v0.4.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.19.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/net v0.23.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect google.golang.org/protobuf v1.33.0 // indirect diff --git a/wasm-tests/webtransport-tests/echo-server/go.sum b/wasm-tests/webtransport-tests/echo-server/go.sum index 7cb38f3e7e2..a9d53233159 100644 --- a/wasm-tests/webtransport-tests/echo-server/go.sum +++ b/wasm-tests/webtransport-tests/echo-server/go.sum @@ -10,49 +10,25 @@ git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGy github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= -github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE= -github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= -github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= -github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d h1:t5Wuyh53qYyg9eqn4BbnlIT+vmhyww0TatL+zT3uWgI= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= -github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= -github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU= github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= -github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= -github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4= -github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= -github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= -github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg= github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= @@ -61,220 +37,123 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= -github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20230405160723-4a4c7d95572b h1:Qcx5LM0fSiks9uCyFZwDBUasd3lxd1RM0GYpL+Li5o4= -github.com/google/pprof v0.0.0-20230405160723-4a4c7d95572b/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 h1:E/LAvt58di64hlYjx7AsNS6C/ysHWYo+2qPCZKTQhRo= github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= -github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= -github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= -github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= -github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.16.4 h1:91KN02FnsOYhuunwU4ssRe8lc2JosWmizWa91B5v1PU= -github.com/klauspost/compress v1.16.4/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= -github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= -github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= -github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= -github.com/libp2p/go-libp2p v0.27.8 h1:IX5x/4yKwyPQeVS2AXHZ3J4YATM9oHBGH1gBc23jBAI= -github.com/libp2p/go-libp2p v0.27.8/go.mod h1:eCFFtd0s5i/EVKR7+5Ki8bM7qwkNW3TPTTSSW9sz8NE= github.com/libp2p/go-libp2p v0.33.1 h1:tvJl9b9M6nSLBtZSXSguq+/lRhRj2oLRkyhBmQNMFLA= github.com/libp2p/go-libp2p v0.33.1/go.mod h1:zOUTMjG4I7TXwMndNyOBn/CNtVBLlvBlnxfi+8xzx+E= -github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= -github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= -github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= -github.com/libp2p/go-nat v0.2.0/go.mod h1:3MJr+GRpRkyT65EpVPBstXLvOlAPzUVlG6Pwg9ohLJk= github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= github.com/libp2p/go-netroute v0.2.1/go.mod h1:hraioZr0fhBjG0ZRXJJ6Zj2IVEVNx6tDTFQfSmcq7mQ= -github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQscQm2s= -github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU= -github.com/libp2p/go-yamux/v4 v4.0.0 h1:+Y80dV2Yx/kv7Y7JKu0LECyVdMXm1VUoko+VQ9rBfZQ= github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ= github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk= -github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= -github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= -github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c/go.mod h1:0SQS9kMwD2VsyFEB++InYyBJroV/FRmBgcydeSUcJms= -github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= -github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU= -github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc= -github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s= -github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= -github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= -github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= -github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= -github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo= -github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= -github.com/multiformats/go-multiaddr v0.9.0 h1:3h4V1LHIk5w4hJHekMKWALPXErDfz/sggzwC/NcqbDQ= -github.com/multiformats/go-multiaddr v0.9.0/go.mod h1:mI67Lb1EeTOYb8GQfL/7wpIZwc46ElrvzhYnoJOmTT0= github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= -github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= -github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= -github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= -github.com/multiformats/go-multiaddr-fmt v0.1.0/go.mod h1:hGtDIW4PU4BqJ50gW2quDuPVjyWNZxToGUh/HwTZYJo= github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= -github.com/multiformats/go-multicodec v0.8.1 h1:ycepHwavHafh3grIbR1jIXnKCsFm0fqsfEOsJ8NtKE8= -github.com/multiformats/go-multicodec v0.8.1/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= -github.com/multiformats/go-multihash v0.0.8/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= -github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108= -github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= -github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo= -github.com/multiformats/go-multistream v0.4.1/go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q= github.com/multiformats/go-multistream v0.5.0 h1:5htLSLl7lvJk3xx3qT/8Zm9J4K8vEOf/QGkvOGQAyiE= github.com/multiformats/go-multistream v0.5.0/go.mod h1:n6tMZiwiP2wUsR8DgfDWw1dydlEqV3l6N3/GBsX6ILA= -github.com/multiformats/go-varint v0.0.1/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= -github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= -github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= -github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= -github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= -github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= -github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= -github.com/quic-go/webtransport-go v0.5.2 h1:GA6Bl6oZY+g/flt00Pnu0XtivSD8vukOu3lYhJjnGEk= -github.com/quic-go/webtransport-go v0.5.2/go.mod h1:OhmmgJIzTTqXK5xvtuX0oBpLV2GkLWNDA+UeTGJXErU= github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY= github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc= -github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= -github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= @@ -296,10 +175,8 @@ github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ= github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -307,36 +184,25 @@ github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= -github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/dig v1.17.1 h1:Tga8Lz8PcYNsWsyHMZ1Vm0OQOUaJNDyvPImgbAu9YSc= -go.uber.org/dig v1.17.1/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= -go.uber.org/fx v1.20.1 h1:zVwVQGS8zYvhh9Xxcu4w1M6ESyeMzebzj2NbSayZ4Mk= -go.uber.org/fx v1.20.1/go.mod h1:iSYNbHf2y55acNCwCXKx7LbWb5WG1Bnue5RDXz1OREg= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= @@ -344,18 +210,12 @@ golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -364,11 +224,7 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -382,15 +238,10 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -401,34 +252,22 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -438,25 +277,20 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= -golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= @@ -474,8 +308,6 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -489,12 +321,11 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= -lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= From 1aa016e1c7e3976748a726eab37af44d1c5b7a6e Mon Sep 17 00:00:00 2001 From: Adam Wierzbicki Date: Tue, 14 May 2024 22:49:37 +0200 Subject: [PATCH 104/246] feat(quic): allow setting the MTU discovery upper bound The default MTU discovery upper bound is too high for some environments and results in permanent warnings. As I'd like to be able to configure this setting, adding a new method for the `Config`. Pull-Request: #5386. --- Cargo.lock | 2 +- Cargo.toml | 2 +- transports/quic/CHANGELOG.md | 4 ++++ transports/quic/Cargo.toml | 2 +- transports/quic/src/config.rs | 12 ++++++++++-- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a054df9fb35..3d49f0c51e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3163,7 +3163,7 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.10.2" +version = "0.10.3" dependencies = [ "async-std", "bytes", diff --git a/Cargo.toml b/Cargo.toml index ec38ffb72fd..f6a4f72df3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,7 +95,7 @@ libp2p-perf = { version = "0.3.0", path = "protocols/perf" } libp2p-ping = { version = "0.44.1", path = "protocols/ping" } libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } -libp2p-quic = { version = "0.10.2", path = "transports/quic" } +libp2p-quic = { version = "0.10.3", path = "transports/quic" } libp2p-relay = { version = "0.17.2", path = "protocols/relay" } libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.26.2", path = "protocols/request-response" } diff --git a/transports/quic/CHANGELOG.md b/transports/quic/CHANGELOG.md index 3c34a1989f9..cd0146afbb2 100644 --- a/transports/quic/CHANGELOG.md +++ b/transports/quic/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.3 +- Allow configuring MTU discovery upper bound. + See [PR 5386](https://github.com/libp2p/rust-libp2p/pull/5386). + ## 0.10.2 - Change `max_idle_timeout`to 10s. diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 1bbac27d67f..5a7e79441db 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-quic" -version = "0.10.2" +version = "0.10.3" authors = ["Parity Technologies "] edition = "2021" rust-version = { workspace = true } diff --git a/transports/quic/src/config.rs b/transports/quic/src/config.rs index 540f13e726b..c5189ce36cd 100644 --- a/transports/quic/src/config.rs +++ b/transports/quic/src/config.rs @@ -40,10 +40,10 @@ pub struct Config { /// concurrently by the remote peer. pub max_concurrent_stream_limit: u32, - /// Max unacknowledged data in bytes that may be send on a single stream. + /// Max unacknowledged data in bytes that may be sent on a single stream. pub max_stream_data: u32, - /// Max unacknowledged data in bytes that may be send in total on all streams + /// Max unacknowledged data in bytes that may be sent in total on all streams /// of a connection. pub max_connection_data: u32, @@ -90,6 +90,14 @@ impl Config { } } + /// Set the upper bound to the max UDP payload size that MTU discovery will search for. + pub fn mtu_upper_bound(mut self, value: u16) -> Self { + self.mtu_discovery_config + .get_or_insert_with(Default::default) + .upper_bound(value); + self + } + /// Disable MTU path discovery (it is enabled by default). pub fn disable_path_mtu_discovery(mut self) -> Self { self.mtu_discovery_config = None; From 1fba3893e90ca442b4dfa01ddd84dd88b1422b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 16 May 2024 16:34:23 +0100 Subject: [PATCH 105/246] chore: fix ci wasm tests by updating chrome download location. Pull-Request: #5394. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 828882b4615..ea2f5a54e1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,7 +108,7 @@ jobs: name: Run all WASM tests runs-on: ubuntu-latest env: - CHROMEDRIVER_VERSION: '114.0.5735.90' + CHROMEDRIVER_VERSION: '125.0.6422.60' steps: - uses: actions/checkout@v4 From 2ad7a25969dab1fea4be4b0198594fec7b738e69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 21:31:10 +0000 Subject: [PATCH 106/246] deps: bump anyhow from 1.0.82 to 1.0.83 Pull-Request: #5379. --- Cargo.lock | 4 ++-- examples/browser-webrtc/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d49f0c51e4..8724c427953 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" [[package]] name = "arbitrary" diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index 1744482dddf..87b4a955ed3 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -16,7 +16,7 @@ release = false crate-type = ["cdylib"] [dependencies] -anyhow = "1.0.82" +anyhow = "1.0.83" futures = { workspace = true } rand = "0.8" tracing = { workspace = true } diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index 34f92b28979..e2b3a2ae83b 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" clap = { version = "4.5.4", features = ["derive"] } env_logger = "0.10" futures = { workspace = true } -anyhow = "1.0.82" +anyhow = "1.0.83" libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "yamux", "rsa"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 2e10b3e4206..2bf6f285f0a 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -32,7 +32,7 @@ json = ["dep:serde", "dep:serde_json", "libp2p-swarm/macros"] cbor = ["dep:serde", "dep:cbor4ii", "libp2p-swarm/macros"] [dev-dependencies] -anyhow = "1.0.82" +anyhow = "1.0.83" async-std = { version = "1.6.2", features = ["attributes"] } libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } From 451bcb60bb472262f96071006b19e5d236b1dd54 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 21:43:17 +0000 Subject: [PATCH 107/246] deps: bump serde_json from 1.0.116 to 1.0.117 Pull-Request: #5380. --- Cargo.lock | 4 ++-- hole-punching-tests/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8724c427953..11eb83796cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5394,9 +5394,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "indexmap 2.2.1", "itoa", diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 5f93c158b98..074a09a4327 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -14,5 +14,5 @@ tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { workspace = true, features = ["full"] } serde = { version = "1.0.201", features = ["derive"] } -serde_json = "1.0.116" +serde_json = "1.0.117" either = "1.11.0" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 93639e309ce..91845657526 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -16,7 +16,7 @@ release = false clap = { version = "4.5.4", features = ["derive"] } zeroize = "1" serde = { version = "1.0.201", features = ["derive"] } -serde_json = "1.0.116" +serde_json = "1.0.117" libp2p-core = { workspace = true } base64 = "0.22.1" libp2p-identity = { workspace = true } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 2bf6f285f0a..f33ee9bb916 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -20,7 +20,7 @@ libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } rand = "0.8" serde = { version = "1.0", optional = true} -serde_json = { version = "1.0.116", optional = true } +serde_json = { version = "1.0.117", optional = true } smallvec = "1.13.2" tracing = { workspace = true } void = "1.0.2" From 35f7f23c1aa35a0a80dec2ce3bef8e35684ac6b8 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Fri, 17 May 2024 17:36:52 +0300 Subject: [PATCH 108/246] fix: Revert "deps: bump libc from 0.2.153 to 0.2.154" libc 0.2.154 is version is not published in crates.io and it breaks the build. The CI of #5390 fails because of this. Pull-Request: #5395. --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- transports/tcp/CHANGELOG.md | 3 +++ transports/tcp/Cargo.toml | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 11eb83796cd..77c102c1fa8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2610,9 +2610,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libp2p" @@ -3377,7 +3377,7 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.41.0" +version = "0.41.1" dependencies = [ "async-io 2.3.2", "async-std", diff --git a/Cargo.toml b/Cargo.toml index f6a4f72df3d..1dec9052c94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,7 +104,7 @@ libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } libp2p-swarm = { version = "0.44.2", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } -libp2p-tcp = { version = "0.41.0", path = "transports/tcp" } +libp2p-tcp = { version = "0.41.1", path = "transports/tcp" } libp2p-tls = { version = "0.3.0", path = "transports/tls" } libp2p-uds = { version = "0.40.0", path = "transports/uds" } libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } diff --git a/transports/tcp/CHANGELOG.md b/transports/tcp/CHANGELOG.md index 2bde64056cb..36ed93a0f5b 100644 --- a/transports/tcp/CHANGELOG.md +++ b/transports/tcp/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.41.1 + + ## 0.41.0 diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 41d128506dd..ea89b523fc2 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-tcp" edition = "2021" rust-version = { workspace = true } description = "TCP/IP transport protocol for libp2p" -version = "0.41.0" +version = "0.41.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -15,7 +15,7 @@ async-io = { version = "2.3.2", optional = true } futures = { workspace = true } futures-timer = "3.0" if-watch = "3.2.0" -libc = "0.2.154" +libc = "0.2.153" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } socket2 = { version = "0.5.6", features = ["all"] } From 80f06d82f3de7edf52c2cf3daa6cc19582806341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Zwoli=C5=84ski?= Date: Fri, 17 May 2024 17:04:43 +0200 Subject: [PATCH 109/246] fix(webtransport-websys): handle exceptions in WebTransport::close Calls to `close` can result in exceptions being thrown eg. when the connection is not yet fully initialized (in `connecting` state). Currently webtransport-websys doesn't catch those resulting in errors like: ``` Uncaught (in promise) WebTransportError { source: "session", streamErrorCode: null, name: "WebTransportError", message: "remote WebTransport close", code: 0, result: 0, filename: "", lineNumber: 0, columnNumber: 0, data: null } ``` Those cannot be caught even by wrapping `.close()` in the `try { ... } catch () {...}` blocks. It's rather poorly documented, indirectly with just an example [here](https://developer.mozilla.org/en-US/docs/Web/API/WebTransport/closed), but the way to catch those is through the promise created by `.closed`. Pull-Request: #5390. --- Cargo.lock | 2 +- Cargo.toml | 2 +- transports/webtransport-websys/CHANGELOG.md | 5 +++++ transports/webtransport-websys/Cargo.toml | 2 +- transports/webtransport-websys/src/connection.rs | 6 ++++++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 77c102c1fa8..daaaf364baa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3555,7 +3555,7 @@ dependencies = [ [[package]] name = "libp2p-webtransport-websys" -version = "0.2.0" +version = "0.2.1" dependencies = [ "futures", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 1dec9052c94..a2c2211c2de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,7 +113,7 @@ libp2p-webrtc-utils = { version = "0.2.0", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.43.0", path = "transports/websocket" } libp2p-websocket-websys = { version = "0.3.2", path = "transports/websocket-websys" } -libp2p-webtransport-websys = { version = "0.2.0", path = "transports/webtransport-websys" } +libp2p-webtransport-websys = { version = "0.2.1", path = "transports/webtransport-websys" } libp2p-yamux = { version = "0.45.1", path = "muxers/yamux" } multiaddr = "0.18.1" multihash = "0.19.1" diff --git a/transports/webtransport-websys/CHANGELOG.md b/transports/webtransport-websys/CHANGELOG.md index b368a943395..91749001010 100644 --- a/transports/webtransport-websys/CHANGELOG.md +++ b/transports/webtransport-websys/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.1 + +* Fix unhandled exceptions thrown when calling `Webtransport::close`. + See [PR 5390](https://github.com/libp2p/rust-libp2p/pull/5390) + ## 0.2.0 diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index a1bd3832177..ac4fcd35d1c 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-webtransport-websys" edition = "2021" rust-version = { workspace = true } description = "WebTransport for libp2p under WASM environment" -version = "0.2.0" +version = "0.2.1" authors = [ "Yiannis Marangos ", "oblique ", diff --git a/transports/webtransport-websys/src/connection.rs b/transports/webtransport-websys/src/connection.rs index 982f9e5a32c..956a66288af 100644 --- a/transports/webtransport-websys/src/connection.rs +++ b/transports/webtransport-websys/src/connection.rs @@ -47,6 +47,12 @@ impl Connection { let opts = endpoint.webtransport_opts(); WebTransport::new_with_options(&url, &opts).map_err(Error::from_js_value)? }; + // Create a promise that will resolve once session is closed. + // It will catch the errors that can eventually happen when + // `.close()` is called. Without it, there is no way of catching + // those from the `.close()` itself, resulting in `Uncaught in promise...` + // logs popping up. + detach_promise(session.closed()); let incoming_streams = session.incoming_bidirectional_streams(); let incoming_streams_reader = From 6c2eacae47fa555c2d9512b9efbccd87799ee8c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Sat, 18 May 2024 01:42:05 +0100 Subject: [PATCH 110/246] deps(tls): upgrade rustls to 0.23 Pull-Request: #5385. --- Cargo.lock | 174 +++++++++++++++++++++--------- Cargo.toml | 3 +- transports/quic/Cargo.toml | 2 +- transports/tls/CHANGELOG.md | 4 + transports/tls/Cargo.toml | 9 +- transports/tls/src/certificate.rs | 30 ++++-- transports/tls/src/lib.rs | 15 +-- transports/tls/src/upgrade.rs | 7 +- transports/tls/src/verifier.rs | 49 +++++---- transports/websocket/Cargo.toml | 2 +- 10 files changed, 198 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index daaaf364baa..945fc2bbc9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2459,7 +2459,7 @@ dependencies = [ "libp2p", "libp2p-mplex", "libp2p-noise", - "libp2p-tls", + "libp2p-tls 0.4.0", "libp2p-webrtc", "libp2p-webrtc-websys", "mime_guess", @@ -2586,7 +2586,7 @@ version = "0.1.0" dependencies = [ "base64 0.22.1", "clap", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "serde", "serde_json", @@ -2630,7 +2630,7 @@ dependencies = [ "libp2p-allow-block-list", "libp2p-autonat", "libp2p-connection-limits", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-dcutr", "libp2p-dns", "libp2p-floodsub", @@ -2652,7 +2652,7 @@ dependencies = [ "libp2p-request-response", "libp2p-swarm", "libp2p-tcp", - "libp2p-tls", + "libp2p-tls 0.4.0", "libp2p-uds", "libp2p-upnp", "libp2p-websocket", @@ -2661,7 +2661,7 @@ dependencies = [ "libp2p-yamux", "multiaddr", "pin-project", - "rw-stream-sink", + "rw-stream-sink 0.4.0", "thiserror", "tokio", "tracing-subscriber", @@ -2672,7 +2672,7 @@ name = "libp2p-allow-block-list" version = "0.3.0" dependencies = [ "async-std", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-swarm", "libp2p-swarm-derive", @@ -2690,7 +2690,7 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-request-response", "libp2p-swarm", @@ -2707,7 +2707,7 @@ name = "libp2p-connection-limits" version = "0.3.1" dependencies = [ "async-std", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identify", "libp2p-identity", "libp2p-ping", @@ -2734,14 +2734,14 @@ dependencies = [ "libp2p-noise", "multiaddr", "multihash", - "multistream-select", + "multistream-select 0.13.0", "once_cell", "parking_lot", "pin-project", "quick-protobuf", "quickcheck-ext", "rand 0.8.5", - "rw-stream-sink", + "rw-stream-sink 0.4.0", "serde", "smallvec", "thiserror", @@ -2750,6 +2750,34 @@ dependencies = [ "void", ] +[[package]] +name = "libp2p-core" +version = "0.41.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8130a8269e65a2554d55131c770bdf4bcd94d2b8d4efb24ca23699be65066c05" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-identity", + "multiaddr", + "multihash", + "multistream-select 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell", + "parking_lot", + "pin-project", + "quick-protobuf", + "rand 0.8.5", + "rw-stream-sink 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec", + "thiserror", + "tracing", + "unsigned-varint 0.8.0", + "void", +] + [[package]] name = "libp2p-dcutr" version = "0.11.0" @@ -2762,7 +2790,7 @@ dependencies = [ "futures-bounded", "futures-timer", "instant", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-dns", "libp2p-identify", "libp2p-identity", @@ -2793,7 +2821,7 @@ dependencies = [ "async-trait", "futures", "hickory-resolver", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "parking_lot", "smallvec", @@ -2811,7 +2839,7 @@ dependencies = [ "cuckoofilter", "fnv", "futures", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-swarm", "quick-protobuf", @@ -2839,7 +2867,7 @@ dependencies = [ "hex", "hex_fmt", "instant", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", "libp2p-swarm", @@ -2869,7 +2897,7 @@ dependencies = [ "futures", "futures-bounded", "futures-timer", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-swarm", "libp2p-swarm-test", @@ -2926,7 +2954,7 @@ dependencies = [ "futures-bounded", "futures-timer", "instant", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identify", "libp2p-identity", "libp2p-noise", @@ -2957,7 +2985,7 @@ dependencies = [ "futures", "hickory-proto", "if-watch", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", "libp2p-swarm", @@ -2978,7 +3006,7 @@ name = "libp2p-memory-connection-limits" version = "0.2.0" dependencies = [ "async-std", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identify", "libp2p-identity", "libp2p-swarm", @@ -2997,7 +3025,7 @@ version = "0.14.1" dependencies = [ "futures", "instant", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-dcutr", "libp2p-gossipsub", "libp2p-identify", @@ -3019,7 +3047,7 @@ dependencies = [ "bytes", "criterion", "futures", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-muxer-test-harness", "libp2p-plaintext", @@ -3041,7 +3069,7 @@ dependencies = [ "futures", "futures-timer", "futures_ringbuf", - "libp2p-core", + "libp2p-core 0.41.2", "tracing", ] @@ -3054,7 +3082,7 @@ dependencies = [ "curve25519-dalek", "futures", "futures_ringbuf", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "multiaddr", "multihash", @@ -3083,14 +3111,14 @@ dependencies = [ "futures-timer", "instant", "libp2p", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-dns", "libp2p-identity", "libp2p-quic", "libp2p-swarm", "libp2p-swarm-test", "libp2p-tcp", - "libp2p-tls", + "libp2p-tls 0.4.0", "libp2p-yamux", "rand 0.8.5", "serde", @@ -3111,7 +3139,7 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-swarm", "libp2p-swarm-test", @@ -3130,7 +3158,7 @@ dependencies = [ "bytes", "futures", "futures_ringbuf", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "quick-protobuf", "quick-protobuf-codec", @@ -3145,7 +3173,7 @@ name = "libp2p-pnet" version = "0.24.0" dependencies = [ "futures", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", "libp2p-swarm", @@ -3170,12 +3198,12 @@ dependencies = [ "futures", "futures-timer", "if-watch", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-muxer-test-harness", "libp2p-noise", "libp2p-tcp", - "libp2p-tls", + "libp2p-tls 0.3.0", "libp2p-yamux", "parking_lot", "quickcheck", @@ -3200,7 +3228,7 @@ dependencies = [ "futures", "futures-bounded", "futures-timer", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-ping", "libp2p-plaintext", @@ -3229,7 +3257,7 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identify", "libp2p-identity", "libp2p-noise", @@ -3262,7 +3290,7 @@ dependencies = [ "futures-timer", "futures_ringbuf", "instant", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", "libp2p-swarm", @@ -3303,7 +3331,7 @@ name = "libp2p-stream" version = "0.1.0-alpha.1" dependencies = [ "futures", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-swarm", "libp2p-swarm-test", @@ -3325,7 +3353,7 @@ dependencies = [ "futures-timer", "getrandom 0.2.14", "instant", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identify", "libp2p-identity", "libp2p-kad", @@ -3335,7 +3363,7 @@ dependencies = [ "libp2p-swarm-test", "libp2p-yamux", "lru", - "multistream-select", + "multistream-select 0.13.0", "once_cell", "quickcheck-ext", "rand 0.8.5", @@ -3365,7 +3393,7 @@ dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-plaintext", "libp2p-swarm", @@ -3385,7 +3413,7 @@ dependencies = [ "futures-timer", "if-watch", "libc", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "socket2 0.5.6", "tokio", @@ -3396,18 +3424,37 @@ dependencies = [ [[package]] name = "libp2p-tls" version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ce7e3c2e7569d685d08ec795157981722ff96e9e9f9eae75df3c29d02b07a5" dependencies = [ "futures", "futures-rustls 0.24.0", + "libp2p-core 0.41.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identity", + "rcgen", + "ring 0.16.20", + "rustls 0.21.11", + "rustls-webpki 0.101.7", + "thiserror", + "x509-parser 0.15.1", + "yasna", +] + +[[package]] +name = "libp2p-tls" +version = "0.4.0" +dependencies = [ + "futures", + "futures-rustls 0.26.0", "hex", "hex-literal", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-swarm", "libp2p-yamux", "rcgen", "ring 0.17.8", - "rustls 0.21.11", + "rustls 0.23.5", "rustls-webpki 0.101.7", "thiserror", "tokio", @@ -3421,7 +3468,7 @@ version = "0.40.0" dependencies = [ "async-std", "futures", - "libp2p-core", + "libp2p-core 0.41.2", "tempfile", "tokio", "tracing", @@ -3434,7 +3481,7 @@ dependencies = [ "futures", "futures-timer", "igd-next", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-swarm", "tokio", "tracing", @@ -3451,7 +3498,7 @@ dependencies = [ "futures-timer", "hex", "if-watch", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", "libp2p-webrtc-utils", @@ -3479,7 +3526,7 @@ dependencies = [ "futures", "hex", "hex-literal", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", "quick-protobuf", @@ -3501,7 +3548,7 @@ dependencies = [ "getrandom 0.2.14", "hex", "js-sys", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-webrtc-utils", "send_wrapper 0.6.0", @@ -3520,14 +3567,14 @@ dependencies = [ "either", "futures", "futures-rustls 0.26.0", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-dns", "libp2p-identity", "libp2p-tcp", "parking_lot", "pin-project-lite", "rcgen", - "rw-stream-sink", + "rw-stream-sink 0.4.0", "soketto", "tracing", "url", @@ -3541,7 +3588,7 @@ dependencies = [ "bytes", "futures", "js-sys", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", "libp2p-yamux", @@ -3559,7 +3606,7 @@ version = "0.2.1" dependencies = [ "futures", "js-sys", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", "multiaddr", @@ -3580,7 +3627,7 @@ dependencies = [ "async-std", "either", "futures", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-muxer-test-harness", "thiserror", "tracing", @@ -3869,13 +3916,27 @@ dependencies = [ "pin-project", "quickcheck-ext", "rand 0.8.5", - "rw-stream-sink", + "rw-stream-sink 0.4.0", "smallvec", "tracing", "tracing-subscriber", "unsigned-varint 0.8.0", ] +[[package]] +name = "multistream-select" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec", + "unsigned-varint 0.7.2", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -5247,6 +5308,17 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "rw-stream-sink" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" +dependencies = [ + "futures", + "pin-project", + "static_assertions", +] + [[package]] name = "ryu" version = "1.0.15" @@ -6870,7 +6942,7 @@ version = "0.1.0" dependencies = [ "futures", "getrandom 0.2.14", - "libp2p-core", + "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", "libp2p-webtransport-websys", diff --git a/Cargo.toml b/Cargo.toml index a2c2211c2de..a0218cd5e75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ rust-version = "1.75.0" [workspace.dependencies] asynchronous-codec = { version = "0.7.0" } futures-bounded = { version = "0.2.3" } +futures-rustls = { version = "0.26.0", default-features = false } libp2p = { version = "0.54.0", path = "libp2p" } libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" } libp2p-autonat = { version = "0.12.0", path = "protocols/autonat" } @@ -104,8 +105,8 @@ libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } libp2p-swarm = { version = "0.44.2", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } +libp2p-tls = { version = "0.4.0", path = "transports/tls" } libp2p-tcp = { version = "0.41.1", path = "transports/tcp" } -libp2p-tls = { version = "0.3.0", path = "transports/tls" } libp2p-uds = { version = "0.40.0", path = "transports/uds" } libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 5a7e79441db..399ddd48e1e 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -15,7 +15,7 @@ futures = { workspace = true } futures-timer = "3.0.3" if-watch = "3.2.0" libp2p-core = { workspace = true } -libp2p-tls = { workspace = true } +libp2p-tls = "0.3.0" libp2p-identity = { workspace = true } parking_lot = "0.12.2" quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls", "futures-io"] } diff --git a/transports/tls/CHANGELOG.md b/transports/tls/CHANGELOG.md index 83f72286559..3c6d0a2a1f5 100644 --- a/transports/tls/CHANGELOG.md +++ b/transports/tls/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.0 + +- Upgrade `rustls` to `0.23`. See [PR 5385](https://github.com/libp2p/rust-libp2p/pull/5385) + ## 0.3.0 - Migrate to `{In,Out}boundConnectionUpgrade` traits. diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 7fad6c1f45b..48693524199 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-tls" -version = "0.3.0" +version = "0.4.0" edition = "2021" rust-version = { workspace = true } description = "TLS configuration based on libp2p TLS specs." @@ -10,7 +10,7 @@ exclude = ["src/test_assets"] [dependencies] futures = { workspace = true } -futures-rustls = "0.24.0" +futures-rustls = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } rcgen = "0.11.3" @@ -22,9 +22,10 @@ yasna = "0.5.2" # Exposed dependencies. Breaking changes to these are breaking changes to us. [dependencies.rustls] -version = "0.21.9" +version = "0.23.4" default-features = false -features = ["dangerous_configuration"] # Must enable this to allow for custom verification code. +features = ["ring", "std"] # Must enable this to allow for custom verification code. + [dev-dependencies] hex = "0.4.3" diff --git a/transports/tls/src/certificate.rs b/transports/tls/src/certificate.rs index 801ba3fe3ce..bbd353e32bd 100644 --- a/transports/tls/src/certificate.rs +++ b/transports/tls/src/certificate.rs @@ -46,14 +46,22 @@ static P2P_SIGNATURE_ALGORITHM: &rcgen::SignatureAlgorithm = &rcgen::PKCS_ECDSA_ /// certificate extension containing the public key of the given keypair. pub fn generate( identity_keypair: &identity::Keypair, -) -> Result<(rustls::Certificate, rustls::PrivateKey), GenError> { +) -> Result< + ( + rustls::pki_types::CertificateDer<'static>, + rustls::pki_types::PrivateKeyDer<'static>, + ), + GenError, +> { // Keypair used to sign the certificate. // SHOULD NOT be related to the host's key. // Endpoints MAY generate a new key and certificate // for every connection attempt, or they MAY reuse the same key // and certificate for multiple connections. let certificate_keypair = rcgen::KeyPair::generate(P2P_SIGNATURE_ALGORITHM)?; - let rustls_key = rustls::PrivateKey(certificate_keypair.serialize_der()); + let rustls_key = rustls::pki_types::PrivateKeyDer::from( + rustls::pki_types::PrivatePkcs8KeyDer::from(certificate_keypair.serialize_der()), + ); let certificate = { let mut params = rcgen::CertificateParams::new(vec![]); @@ -67,7 +75,7 @@ pub fn generate( rcgen::Certificate::from_params(params)? }; - let rustls_certificate = rustls::Certificate(certificate.serialize_der()?); + let rustls_certificate = rustls::pki_types::CertificateDer::from(certificate.serialize_der()?); Ok((rustls_certificate, rustls_key)) } @@ -76,7 +84,9 @@ pub fn generate( /// /// For this to succeed, the certificate must contain the specified extension and the signature must /// match the embedded public key. -pub fn parse(certificate: &rustls::Certificate) -> Result, ParseError> { +pub fn parse<'a>( + certificate: &'a rustls::pki_types::CertificateDer<'a>, +) -> Result, ParseError> { let certificate = parse_unverified(certificate.as_ref())?; certificate.verify()?; @@ -481,7 +491,9 @@ mod tests { #[test] fn rsa_pss_sha384() { - let cert = rustls::Certificate(include_bytes!("./test_assets/rsa_pss_sha384.der").to_vec()); + let cert = rustls::pki_types::CertificateDer::from( + include_bytes!("./test_assets/rsa_pss_sha384.der").to_vec(), + ); let cert = parse(&cert).unwrap(); @@ -502,7 +514,7 @@ mod tests { #[test] fn can_parse_certificate_with_ed25519_keypair() { - let certificate = rustls::Certificate(hex!("308201773082011ea003020102020900f5bd0debaa597f52300a06082a8648ce3d04030230003020170d3735303130313030303030305a180f34303936303130313030303030305a30003059301306072a8648ce3d020106082a8648ce3d030107034200046bf9871220d71dcb3483ecdfcbfcc7c103f8509d0974b3c18ab1f1be1302d643103a08f7a7722c1b247ba3876fe2c59e26526f479d7718a85202ddbe47562358a37f307d307b060a2b0601040183a25a01010101ff046a30680424080112207fda21856709c5ae12fd6e8450623f15f11955d384212b89f56e7e136d2e17280440aaa6bffabe91b6f30c35e3aa4f94b1188fed96b0ffdd393f4c58c1c047854120e674ce64c788406d1c2c4b116581fd7411b309881c3c7f20b46e54c7e6fe7f0f300a06082a8648ce3d040302034700304402207d1a1dbd2bda235ff2ec87daf006f9b04ba076a5a5530180cd9c2e8f6399e09d0220458527178c7e77024601dbb1b256593e9b96d961b96349d1f560114f61a87595").to_vec()); + let certificate = rustls::pki_types::CertificateDer::from(hex!("308201773082011ea003020102020900f5bd0debaa597f52300a06082a8648ce3d04030230003020170d3735303130313030303030305a180f34303936303130313030303030305a30003059301306072a8648ce3d020106082a8648ce3d030107034200046bf9871220d71dcb3483ecdfcbfcc7c103f8509d0974b3c18ab1f1be1302d643103a08f7a7722c1b247ba3876fe2c59e26526f479d7718a85202ddbe47562358a37f307d307b060a2b0601040183a25a01010101ff046a30680424080112207fda21856709c5ae12fd6e8450623f15f11955d384212b89f56e7e136d2e17280440aaa6bffabe91b6f30c35e3aa4f94b1188fed96b0ffdd393f4c58c1c047854120e674ce64c788406d1c2c4b116581fd7411b309881c3c7f20b46e54c7e6fe7f0f300a06082a8648ce3d040302034700304402207d1a1dbd2bda235ff2ec87daf006f9b04ba076a5a5530180cd9c2e8f6399e09d0220458527178c7e77024601dbb1b256593e9b96d961b96349d1f560114f61a87595").to_vec()); let peer_id = parse(&certificate).unwrap().peer_id(); @@ -516,7 +528,7 @@ mod tests { #[test] fn fails_to_parse_bad_certificate_with_ed25519_keypair() { - let certificate = rustls::Certificate(hex!("308201773082011da003020102020830a73c5d896a1109300a06082a8648ce3d04030230003020170d3735303130313030303030305a180f34303936303130313030303030305a30003059301306072a8648ce3d020106082a8648ce3d03010703420004bbe62df9a7c1c46b7f1f21d556deec5382a36df146fb29c7f1240e60d7d5328570e3b71d99602b77a65c9b3655f62837f8d66b59f1763b8c9beba3be07778043a37f307d307b060a2b0601040183a25a01010101ff046a3068042408011220ec8094573afb9728088860864f7bcea2d4fd412fef09a8e2d24d482377c20db60440ecabae8354afa2f0af4b8d2ad871e865cb5a7c0c8d3dbdbf42de577f92461a0ebb0a28703e33581af7d2a4f2270fc37aec6261fcc95f8af08f3f4806581c730a300a06082a8648ce3d040302034800304502202dfb17a6fa0f94ee0e2e6a3b9fb6e986f311dee27392058016464bd130930a61022100ba4b937a11c8d3172b81e7cd04aedb79b978c4379c2b5b24d565dd5d67d3cb3c").to_vec()); + let certificate = rustls::pki_types::CertificateDer::from(hex!("308201773082011da003020102020830a73c5d896a1109300a06082a8648ce3d04030230003020170d3735303130313030303030305a180f34303936303130313030303030305a30003059301306072a8648ce3d020106082a8648ce3d03010703420004bbe62df9a7c1c46b7f1f21d556deec5382a36df146fb29c7f1240e60d7d5328570e3b71d99602b77a65c9b3655f62837f8d66b59f1763b8c9beba3be07778043a37f307d307b060a2b0601040183a25a01010101ff046a3068042408011220ec8094573afb9728088860864f7bcea2d4fd412fef09a8e2d24d482377c20db60440ecabae8354afa2f0af4b8d2ad871e865cb5a7c0c8d3dbdbf42de577f92461a0ebb0a28703e33581af7d2a4f2270fc37aec6261fcc95f8af08f3f4806581c730a300a06082a8648ce3d040302034800304502202dfb17a6fa0f94ee0e2e6a3b9fb6e986f311dee27392058016464bd130930a61022100ba4b937a11c8d3172b81e7cd04aedb79b978c4379c2b5b24d565dd5d67d3cb3c").to_vec()); let error = parse(&certificate).unwrap_err(); @@ -525,7 +537,7 @@ mod tests { #[test] fn can_parse_certificate_with_ecdsa_keypair() { - let certificate = rustls::Certificate(hex!("308201c030820166a003020102020900eaf419a6e3edb4a6300a06082a8648ce3d04030230003020170d3735303130313030303030305a180f34303936303130313030303030305a30003059301306072a8648ce3d020106082a8648ce3d030107034200048dbf1116c7c608d6d5292bd826c3feb53483a89fce434bf64538a359c8e07538ff71f6766239be6a146dcc1a5f3bb934bcd4ae2ae1d4da28ac68b4a20593f06ba381c63081c33081c0060a2b0601040183a25a01010101ff0481ae3081ab045f0803125b3059301306072a8648ce3d020106082a8648ce3d0301070342000484b93fa456a74bd0153919f036db7bc63c802f055bc7023395d0203de718ee0fc7b570b767cdd858aca6c7c4113ff002e78bd2138ac1a3b26dde3519e06979ad04483046022100bc84014cea5a41feabdf4c161096564b9ccf4b62fbef4fe1cd382c84e11101780221009204f086a84cb8ed8a9ddd7868dc90c792ee434adf62c66f99a08a5eba11615b300a06082a8648ce3d0403020348003045022054b437be9a2edf591312d68ff24bf91367ad4143f76cf80b5658f232ade820da022100e23b48de9df9c25d4c83ddddf75d2676f0b9318ee2a6c88a736d85eab94a912f").to_vec()); + let certificate = rustls::pki_types::CertificateDer::from(hex!("308201c030820166a003020102020900eaf419a6e3edb4a6300a06082a8648ce3d04030230003020170d3735303130313030303030305a180f34303936303130313030303030305a30003059301306072a8648ce3d020106082a8648ce3d030107034200048dbf1116c7c608d6d5292bd826c3feb53483a89fce434bf64538a359c8e07538ff71f6766239be6a146dcc1a5f3bb934bcd4ae2ae1d4da28ac68b4a20593f06ba381c63081c33081c0060a2b0601040183a25a01010101ff0481ae3081ab045f0803125b3059301306072a8648ce3d020106082a8648ce3d0301070342000484b93fa456a74bd0153919f036db7bc63c802f055bc7023395d0203de718ee0fc7b570b767cdd858aca6c7c4113ff002e78bd2138ac1a3b26dde3519e06979ad04483046022100bc84014cea5a41feabdf4c161096564b9ccf4b62fbef4fe1cd382c84e11101780221009204f086a84cb8ed8a9ddd7868dc90c792ee434adf62c66f99a08a5eba11615b300a06082a8648ce3d0403020348003045022054b437be9a2edf591312d68ff24bf91367ad4143f76cf80b5658f232ade820da022100e23b48de9df9c25d4c83ddddf75d2676f0b9318ee2a6c88a736d85eab94a912f").to_vec()); let peer_id = parse(&certificate).unwrap().peer_id(); @@ -539,7 +551,7 @@ mod tests { #[test] fn can_parse_certificate_with_secp256k1_keypair() { - let certificate = rustls::Certificate(hex!("3082018230820128a003020102020900f3b305f55622cfdf300a06082a8648ce3d04030230003020170d3735303130313030303030305a180f34303936303130313030303030305a30003059301306072a8648ce3d020106082a8648ce3d0301070342000458f7e9581748ff9bdd933b655cc0e5552a1248f840658cc221dec2186b5a2fe4641b86ab7590a3422cdbb1000cf97662f27e5910d7569f22feed8829c8b52e0fa38188308185308182060a2b0601040183a25a01010101ff0471306f042508021221026b053094d1112bce799dc8026040ae6d4eb574157929f1598172061f753d9b1b04463044022040712707e97794c478d93989aaa28ae1f71c03af524a8a4bd2d98424948a782302207b61b7f074b696a25fb9e0059141a811cccc4cc28042d9301b9b2a4015e87470300a06082a8648ce3d04030203480030450220143ae4d86fdc8675d2480bb6912eca5e39165df7f572d836aa2f2d6acfab13f8022100831d1979a98f0c4a6fb5069ca374de92f1a1205c962a6d90ad3d7554cb7d9df4").to_vec()); + let certificate = rustls::pki_types::CertificateDer::from(hex!("3082018230820128a003020102020900f3b305f55622cfdf300a06082a8648ce3d04030230003020170d3735303130313030303030305a180f34303936303130313030303030305a30003059301306072a8648ce3d020106082a8648ce3d0301070342000458f7e9581748ff9bdd933b655cc0e5552a1248f840658cc221dec2186b5a2fe4641b86ab7590a3422cdbb1000cf97662f27e5910d7569f22feed8829c8b52e0fa38188308185308182060a2b0601040183a25a01010101ff0471306f042508021221026b053094d1112bce799dc8026040ae6d4eb574157929f1598172061f753d9b1b04463044022040712707e97794c478d93989aaa28ae1f71c03af524a8a4bd2d98424948a782302207b61b7f074b696a25fb9e0059141a811cccc4cc28042d9301b9b2a4015e87470300a06082a8648ce3d04030203480030450220143ae4d86fdc8675d2480bb6912eca5e39165df7f572d836aa2f2d6acfab13f8022100831d1979a98f0c4a6fb5069ca374de92f1a1205c962a6d90ad3d7554cb7d9df4").to_vec()); let peer_id = parse(&certificate).unwrap().peer_id(); diff --git a/transports/tls/src/lib.rs b/transports/tls/src/lib.rs index 1edd83e9807..741a4b48077 100644 --- a/transports/tls/src/lib.rs +++ b/transports/tls/src/lib.rs @@ -46,11 +46,13 @@ pub fn make_client_config( ) -> Result { let (certificate, private_key) = certificate::generate(keypair)?; - let mut crypto = rustls::ClientConfig::builder() - .with_cipher_suites(verifier::CIPHERSUITES) - .with_safe_default_kx_groups() + let mut provider = rustls::crypto::ring::default_provider(); + provider.cipher_suites = verifier::CIPHERSUITES.to_vec(); + + let mut crypto = rustls::ClientConfig::builder_with_provider(provider.into()) .with_protocol_versions(verifier::PROTOCOL_VERSIONS) .expect("Cipher suites and kx groups are configured; qed") + .dangerous() .with_custom_certificate_verifier(Arc::new( verifier::Libp2pCertificateVerifier::with_remote_peer_id(remote_peer_id), )) @@ -67,9 +69,10 @@ pub fn make_server_config( ) -> Result { let (certificate, private_key) = certificate::generate(keypair)?; - let mut crypto = rustls::ServerConfig::builder() - .with_cipher_suites(verifier::CIPHERSUITES) - .with_safe_default_kx_groups() + let mut provider = rustls::crypto::ring::default_provider(); + provider.cipher_suites = verifier::CIPHERSUITES.to_vec(); + + let mut crypto = rustls::ServerConfig::builder_with_provider(provider.into()) .with_protocol_versions(verifier::PROTOCOL_VERSIONS) .expect("Cipher suites and kx groups are configured; qed") .with_client_cert_verifier(Arc::new(verifier::Libp2pCertificateVerifier::new())) diff --git a/transports/tls/src/upgrade.rs b/transports/tls/src/upgrade.rs index 84510b6bab0..1c61d265ea6 100644 --- a/transports/tls/src/upgrade.rs +++ b/transports/tls/src/upgrade.rs @@ -28,7 +28,8 @@ use libp2p_core::upgrade::{InboundConnectionUpgrade, OutboundConnectionUpgrade}; use libp2p_core::UpgradeInfo; use libp2p_identity as identity; use libp2p_identity::PeerId; -use rustls::{CommonState, ServerName}; +use rustls::{pki_types::ServerName, CommonState}; + use std::net::{IpAddr, Ipv4Addr}; use std::sync::Arc; @@ -103,7 +104,9 @@ where async move { // Spec: In order to keep this flexibility for future versions, clients that only support the version of the handshake defined in this document MUST NOT send any value in the Server Name Indication. // Setting `ServerName` to unspecified will disable the use of the SNI extension. - let name = ServerName::IpAddress(IpAddr::V4(Ipv4Addr::UNSPECIFIED)); + let name = ServerName::IpAddress(rustls::pki_types::IpAddr::from(IpAddr::V4( + Ipv4Addr::UNSPECIFIED, + ))); let stream = futures_rustls::TlsConnector::from(Arc::new(self.client)) .connect(name, socket) diff --git a/transports/tls/src/verifier.rs b/transports/tls/src/verifier.rs index 01fdb8fdf11..65636cbe708 100644 --- a/transports/tls/src/verifier.rs +++ b/transports/tls/src/verifier.rs @@ -26,12 +26,13 @@ use crate::certificate; use libp2p_identity::PeerId; use rustls::{ - cipher_suite::{ + client::danger::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}, + crypto::ring::cipher_suite::{ TLS13_AES_128_GCM_SHA256, TLS13_AES_256_GCM_SHA384, TLS13_CHACHA20_POLY1305_SHA256, }, - client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}, - server::{ClientCertVerified, ClientCertVerifier}, - Certificate, CertificateError, DigitallySignedStruct, DistinguishedName, SignatureScheme, + pki_types::CertificateDer, + server::danger::{ClientCertVerified, ClientCertVerifier}, + CertificateError, DigitallySignedStruct, DistinguishedName, OtherError, SignatureScheme, SupportedCipherSuite, SupportedProtocolVersion, }; use std::sync::Arc; @@ -56,6 +57,7 @@ pub(crate) static CIPHERSUITES: &[SupportedCipherSuite] = &[ /// Implementation of the `rustls` certificate verification traits for libp2p. /// /// Only TLS 1.3 is supported. TLS 1.2 should be disabled in the configuration of `rustls`. +#[derive(Debug)] pub(crate) struct Libp2pCertificateVerifier { /// The peer ID we intend to connect to remote_peer_id: Option, @@ -103,12 +105,11 @@ impl Libp2pCertificateVerifier { impl ServerCertVerifier for Libp2pCertificateVerifier { fn verify_server_cert( &self, - end_entity: &Certificate, - intermediates: &[Certificate], - _server_name: &rustls::ServerName, - _scts: &mut dyn Iterator, + end_entity: &CertificateDer, + intermediates: &[CertificateDer], + _server_name: &rustls::pki_types::ServerName, _ocsp_response: &[u8], - _now: std::time::SystemTime, + _now: rustls::pki_types::UnixTime, ) -> Result { let peer_id = verify_presented_certs(end_entity, intermediates)?; @@ -130,7 +131,7 @@ impl ServerCertVerifier for Libp2pCertificateVerifier { fn verify_tls12_signature( &self, _message: &[u8], - _cert: &Certificate, + _cert: &CertificateDer, _dss: &DigitallySignedStruct, ) -> Result { unreachable!("`PROTOCOL_VERSIONS` only allows TLS 1.3") @@ -139,7 +140,7 @@ impl ServerCertVerifier for Libp2pCertificateVerifier { fn verify_tls13_signature( &self, message: &[u8], - cert: &Certificate, + cert: &CertificateDer, dss: &DigitallySignedStruct, ) -> Result { verify_tls13_signature(cert, dss.scheme, message, dss.signature()) @@ -162,15 +163,15 @@ impl ClientCertVerifier for Libp2pCertificateVerifier { true } - fn client_auth_root_subjects(&self) -> &[DistinguishedName] { + fn root_hint_subjects(&self) -> &[DistinguishedName] { &[] } fn verify_client_cert( &self, - end_entity: &Certificate, - intermediates: &[Certificate], - _now: std::time::SystemTime, + end_entity: &CertificateDer, + intermediates: &[CertificateDer], + _now: rustls::pki_types::UnixTime, ) -> Result { verify_presented_certs(end_entity, intermediates)?; @@ -180,7 +181,7 @@ impl ClientCertVerifier for Libp2pCertificateVerifier { fn verify_tls12_signature( &self, _message: &[u8], - _cert: &Certificate, + _cert: &CertificateDer, _dss: &DigitallySignedStruct, ) -> Result { unreachable!("`PROTOCOL_VERSIONS` only allows TLS 1.3") @@ -189,7 +190,7 @@ impl ClientCertVerifier for Libp2pCertificateVerifier { fn verify_tls13_signature( &self, message: &[u8], - cert: &Certificate, + cert: &CertificateDer, dss: &DigitallySignedStruct, ) -> Result { verify_tls13_signature(cert, dss.scheme, message, dss.signature()) @@ -207,8 +208,8 @@ impl ClientCertVerifier for Libp2pCertificateVerifier { /// Endpoints MUST abort the connection attempt if more than one certificate is received, /// or if the certificate’s self-signature is not valid. fn verify_presented_certs( - end_entity: &Certificate, - intermediates: &[Certificate], + end_entity: &CertificateDer, + intermediates: &[CertificateDer], ) -> Result { if !intermediates.is_empty() { return Err(rustls::Error::General( @@ -222,7 +223,7 @@ fn verify_presented_certs( } fn verify_tls13_signature( - cert: &Certificate, + cert: &CertificateDer, signature_scheme: SignatureScheme, message: &[u8], signature: &[u8], @@ -237,7 +238,9 @@ impl From for rustls::Error { use webpki::Error::*; match e { BadDer => rustls::Error::InvalidCertificate(CertificateError::BadEncoding), - e => rustls::Error::InvalidCertificate(CertificateError::Other(Arc::new(e))), + e => { + rustls::Error::InvalidCertificate(CertificateError::Other(OtherError(Arc::new(e)))) + } } } } @@ -248,7 +251,9 @@ impl From for rustls::Error { InvalidSignatureForPublicKey => { rustls::Error::InvalidCertificate(CertificateError::BadSignature) } - other => rustls::Error::InvalidCertificate(CertificateError::Other(Arc::new(other))), + other => rustls::Error::InvalidCertificate(CertificateError::Other(OtherError( + Arc::new(other), + ))), } } } diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 9156da7c83b..806086a4369 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -futures-rustls = { version = "0.26.0", default-features = false, features = ["ring"] } +futures-rustls = { workspace = true, features = ["ring"] } either = "1.11.0" futures = { workspace = true } libp2p-core = { workspace = true } From e77a8ff073cdd2ddde14e00bf94028189218d062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Sun, 19 May 2024 16:14:12 +0100 Subject: [PATCH 111/246] chore: remove chrome installation from CI wasm tests Remove chrome installation from CI wasm tests and specifying its version. `chromedriver` automatically installs chrome. Pull-Request: #5397. --- .github/workflows/ci.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea2f5a54e1f..c489d3f5771 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,8 +107,6 @@ jobs: wasm_tests: name: Run all WASM tests runs-on: ubuntu-latest - env: - CHROMEDRIVER_VERSION: '125.0.6422.60' steps: - uses: actions/checkout@v4 @@ -120,15 +118,8 @@ jobs: with: tool: wasm-pack@0.12.0 - - name: Install Google Chrome - run: | - curl -o /tmp/google-chrome-stable_amd64.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROMEDRIVER_VERSION}-1_amd64.deb - sudo dpkg -i /tmp/google-chrome-stable_amd64.deb - - name: Install chromedriver uses: nanasess/setup-chromedriver@v2 - with: - chromedriver-version: ${{ env.CHROMEDRIVER_VERSION }} - name: Run all tests run: ./wasm-tests/run-all.sh From dca5b88119b500f00449416abd293cc384819b2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 15:29:38 +0000 Subject: [PATCH 112/246] deps: bump thiserror from 1.0.59 to 1.0.60 Pull-Request: #5376. --- Cargo.lock | 8 ++++---- protocols/floodsub/Cargo.toml | 2 +- transports/noise/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/tls/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/webtransport-websys/Cargo.toml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 945fc2bbc9f..707fd8f3829 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5970,18 +5970,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index e95fa00697e..3b1f1039875 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -23,7 +23,7 @@ quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" smallvec = "1.13.2" -thiserror = "1.0.59" +thiserror = "1.0.60" tracing = { workspace = true } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 8e17ba3d6a3..51f980b0e49 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -22,7 +22,7 @@ quick-protobuf = "0.8" rand = "0.8.3" sha2 = "0.10.8" static_assertions = "1" -thiserror = "1.0.59" +thiserror = "1.0.60" tracing = { workspace = true } x25519-dalek = "2" zeroize = "1" diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 399ddd48e1e..206c7b9d0e2 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -21,7 +21,7 @@ parking_lot = "0.12.2" quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls", "futures-io"] } rand = "0.8.5" rustls = { version = "0.21.9", default-features = false } -thiserror = "1.0.59" +thiserror = "1.0.60" tokio = { workspace = true, default-features = false, features = ["net", "rt", "time"], optional = true } tracing = { workspace = true } socket2 = "0.5.6" diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 48693524199..344780d9758 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -15,7 +15,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true } rcgen = "0.11.3" ring = { workspace = true } -thiserror = "1.0.59" +thiserror = "1.0.60" webpki = { version = "0.101.4", package = "rustls-webpki", features = ["std"] } x509-parser = "0.16.0" yasna = "0.5.2" diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index a7713e1fa59..518c05519be 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -18,7 +18,7 @@ libp2p-core = { workspace = true } tracing = { workspace = true } parking_lot = "0.12.2" send_wrapper = "0.6.0" -thiserror = "1.0.59" +thiserror = "1.0.60" wasm-bindgen = "0.2.90" web-sys = { version = "0.3.69", features = ["BinaryType", "CloseEvent", "MessageEvent", "WebSocket", "Window", "WorkerGlobalScope"] } diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index ac4fcd35d1c..c2c4fddbcf4 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -22,7 +22,7 @@ libp2p-noise = { workspace = true } multiaddr = { workspace = true } multihash = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } -thiserror = "1.0.59" +thiserror = "1.0.60" tracing = { workspace = true } wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.42" From b1530f3c06631276928c560fec2fa62f41889bb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 16:08:46 +0000 Subject: [PATCH 113/246] deps: bump socket2 from 0.5.6 to 0.5.7 Pull-Request: #5364. --- Cargo.lock | 24 ++++++++++++------------ protocols/mdns/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/tcp/Cargo.toml | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 707fd8f3829..e5cccbe0d48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -447,7 +447,7 @@ dependencies = [ "futures-util", "hickory-resolver", "pin-utils", - "socket2 0.5.6", + "socket2 0.5.7", ] [[package]] @@ -2019,7 +2019,7 @@ dependencies = [ "ipnet", "once_cell", "rand 0.8.5", - "socket2 0.5.6", + "socket2 0.5.7", "thiserror", "tinyvec", "tokio", @@ -2296,7 +2296,7 @@ dependencies = [ "http-body 1.0.0", "hyper 1.1.0", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower", "tower-service", @@ -2496,7 +2496,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.6", + "socket2 0.5.7", "widestring", "windows-sys 0.48.0", "winreg 0.50.0", @@ -2994,7 +2994,7 @@ dependencies = [ "libp2p-yamux", "rand 0.8.5", "smallvec", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tracing", "tracing-subscriber", @@ -3211,7 +3211,7 @@ dependencies = [ "rand 0.8.5", "ring 0.16.20", "rustls 0.21.11", - "socket2 0.5.6", + "socket2 0.5.7", "thiserror", "tokio", "tracing", @@ -3415,7 +3415,7 @@ dependencies = [ "libc", "libp2p-core 0.41.2", "libp2p-identity", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tracing", "tracing-subscriber", @@ -4716,7 +4716,7 @@ checksum = "6df19e284d93757a9fb91d63672f7741b129246a669db09d1c0063071debc0c0" dependencies = [ "bytes", "libc", - "socket2 0.5.6", + "socket2 0.5.7", "tracing", "windows-sys 0.48.0", ] @@ -5680,9 +5680,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -6064,7 +6064,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.6", + "socket2 0.5.7", "tokio-macros", "windows-sys 0.48.0", ] @@ -6857,7 +6857,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62bebbd40e7f8b630a0f1a74783dbfff1edfc0ccaae891c4689891156a8c4d8c" dependencies = [ "log", - "socket2 0.5.6", + "socket2 0.5.7", "thiserror", "tokio", "webrtc-util", diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 061651c07d4..fb96acc7dc0 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -21,7 +21,7 @@ libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } rand = "0.8.3" smallvec = "1.13.2" -socket2 = { version = "0.5.6", features = ["all"] } +socket2 = { version = "0.5.7", features = ["all"] } tokio = { workspace = true, default-features = false, features = ["net", "time"], optional = true} tracing = { workspace = true } hickory-proto = { version = "0.24.0", default-features = false, features = ["mdns"] } diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 206c7b9d0e2..90cbc1d260e 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -24,7 +24,7 @@ rustls = { version = "0.21.9", default-features = false } thiserror = "1.0.60" tokio = { workspace = true, default-features = false, features = ["net", "rt", "time"], optional = true } tracing = { workspace = true } -socket2 = "0.5.6" +socket2 = "0.5.7" ring = "0.16.20" [features] diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index ea89b523fc2..8c59ec67b3b 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -18,7 +18,7 @@ if-watch = "3.2.0" libc = "0.2.153" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -socket2 = { version = "0.5.6", features = ["all"] } +socket2 = { version = "0.5.7", features = ["all"] } tokio = { workspace = true, default-features = false, features = ["net"], optional = true } tracing = { workspace = true } From 6276b0ef8e73d9f278b4a23a8b63720f6f02a9fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 08:52:46 +0000 Subject: [PATCH 114/246] deps: bump thiserror from 1.0.60 to 1.0.61 Pull-Request: #5399. --- Cargo.lock | 8 ++++---- protocols/floodsub/Cargo.toml | 2 +- transports/noise/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/tls/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/webtransport-websys/Cargo.toml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5cccbe0d48..d8311e2db32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5970,18 +5970,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 3b1f1039875..8bcbc4a3557 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -23,7 +23,7 @@ quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" smallvec = "1.13.2" -thiserror = "1.0.60" +thiserror = "1.0.61" tracing = { workspace = true } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 51f980b0e49..36013f077f2 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -22,7 +22,7 @@ quick-protobuf = "0.8" rand = "0.8.3" sha2 = "0.10.8" static_assertions = "1" -thiserror = "1.0.60" +thiserror = "1.0.61" tracing = { workspace = true } x25519-dalek = "2" zeroize = "1" diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 90cbc1d260e..1270d89b61e 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -21,7 +21,7 @@ parking_lot = "0.12.2" quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls", "futures-io"] } rand = "0.8.5" rustls = { version = "0.21.9", default-features = false } -thiserror = "1.0.60" +thiserror = "1.0.61" tokio = { workspace = true, default-features = false, features = ["net", "rt", "time"], optional = true } tracing = { workspace = true } socket2 = "0.5.7" diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 344780d9758..6fa9c426bad 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -15,7 +15,7 @@ libp2p-core = { workspace = true } libp2p-identity = { workspace = true } rcgen = "0.11.3" ring = { workspace = true } -thiserror = "1.0.60" +thiserror = "1.0.61" webpki = { version = "0.101.4", package = "rustls-webpki", features = ["std"] } x509-parser = "0.16.0" yasna = "0.5.2" diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 518c05519be..f2f9a6300d0 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -18,7 +18,7 @@ libp2p-core = { workspace = true } tracing = { workspace = true } parking_lot = "0.12.2" send_wrapper = "0.6.0" -thiserror = "1.0.60" +thiserror = "1.0.61" wasm-bindgen = "0.2.90" web-sys = { version = "0.3.69", features = ["BinaryType", "CloseEvent", "MessageEvent", "WebSocket", "Window", "WorkerGlobalScope"] } diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index c2c4fddbcf4..b039bedb182 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -22,7 +22,7 @@ libp2p-noise = { workspace = true } multiaddr = { workspace = true } multihash = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } -thiserror = "1.0.60" +thiserror = "1.0.61" tracing = { workspace = true } wasm-bindgen = "0.2.90" wasm-bindgen-futures = "0.4.42" From 9254fff5d9e4d74a02de47f4943a7339b0053f2f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 11:11:27 +0000 Subject: [PATCH 115/246] deps: bump trybuild from 1.0.95 to 1.0.96 Pull-Request: #5400. --- Cargo.lock | 4 ++-- swarm/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d8311e2db32..d29007c8038 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6353,9 +6353,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "trybuild" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ddb747392ea12569d501a5bbca08852e4c8cd88b92566074b2243b8846f09e6" +checksum = "33a5f13f11071020bb12de7a16b925d2d58636175c20c11dc5f96cb64bb6c9b3" dependencies = [ "glob", "serde", diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 13fdfa3757e..5c4529b5f10 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -54,7 +54,7 @@ libp2p-yamux = { path = "../muxers/yamux" } # Using `pat quickcheck = { workspace = true } void = "1" once_cell = "1.19.0" -trybuild = "1.0.95" +trybuild = "1.0.96" tokio = { workspace = true, features = ["time", "rt", "macros", "rt-multi-thread"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } From 9f7149d54958c06a72635b375d951d9c5ef643ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 12:06:11 +0000 Subject: [PATCH 116/246] deps: bump syn from 2.0.63 to 2.0.65 Pull-Request: #5401. --- Cargo.lock | 58 ++++++++++++++++++++--------------------- swarm-derive/Cargo.toml | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d29007c8038..df337ad99a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", "synstructure 0.13.1", ] @@ -247,7 +247,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -469,7 +469,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -486,7 +486,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -988,7 +988,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -1254,7 +1254,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -1385,7 +1385,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -1490,7 +1490,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -1726,7 +1726,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -3383,7 +3383,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -4189,7 +4189,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -4400,7 +4400,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -4597,7 +4597,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -4620,7 +4620,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -5143,7 +5143,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.63", + "syn 2.0.65", "walkdir", ] @@ -5461,7 +5461,7 @@ checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -5494,7 +5494,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -5779,7 +5779,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -5829,9 +5829,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.63" +version = "2.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" +checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" dependencies = [ "proc-macro2", "quote", @@ -5870,7 +5870,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -5985,7 +5985,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -6087,7 +6087,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -6274,7 +6274,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -6615,7 +6615,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", "wasm-bindgen-shared", ] @@ -6649,7 +6649,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6682,7 +6682,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -7290,7 +7290,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] [[package]] @@ -7310,5 +7310,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.65", ] diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index 407436766dc..215c5fc0311 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true [dependencies] heck = "0.5" quote = "1.0" -syn = { version = "2.0.63", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.65", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" # Passing arguments to the docsrs builder in order to properly document cfg's. From 6f944595dea6390284c9d6d0e532858e57c37a33 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 12:18:22 +0000 Subject: [PATCH 117/246] deps: bump libc from 0.2.153 to 0.2.155 Pull-Request: #5403. --- Cargo.lock | 4 ++-- transports/tcp/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df337ad99a2..9c6bfb0d999 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2610,9 +2610,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libp2p" diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 8c59ec67b3b..cb19bdede3d 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -15,7 +15,7 @@ async-io = { version = "2.3.2", optional = true } futures = { workspace = true } futures-timer = "3.0" if-watch = "3.2.0" -libc = "0.2.153" +libc = "0.2.155" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } socket2 = { version = "0.5.7", features = ["all"] } From 06c92d7be0e7e6f7bd41ed00baae5bd1365d5a77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 12:30:45 +0000 Subject: [PATCH 118/246] deps: bump proc-macro2 from 1.0.82 to 1.0.83 Pull-Request: #5405. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c6bfb0d999..99eac8b107a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4570,9 +4570,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" dependencies = [ "unicode-ident", ] From 7b28c6614148a2a37b052ffd6bc070e0412cdf57 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 12:42:23 +0000 Subject: [PATCH 119/246] deps: bump either from 1.11.0 to 1.12.0 Pull-Request: #5406. --- Cargo.lock | 4 ++-- core/Cargo.toml | 2 +- examples/ipfs-private/Cargo.toml | 2 +- hole-punching-tests/Cargo.toml | 2 +- interop-tests/Cargo.toml | 2 +- protocols/dcutr/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- protocols/identify/Cargo.toml | 2 +- protocols/kad/Cargo.toml | 2 +- protocols/ping/Cargo.toml | 2 +- protocols/relay/Cargo.toml | 2 +- swarm/Cargo.toml | 4 ++-- transports/websocket/Cargo.toml | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99eac8b107a..667f0371af0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1447,9 +1447,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elliptic-curve" diff --git a/core/Cargo.toml b/core/Cargo.toml index f06769ebb41..4eb9a55e904 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -either = "1.11" +either = "1.12" fnv = "1.0" futures = { workspace = true, features = ["executor", "thread-pool"] } futures-timer = "3" diff --git a/examples/ipfs-private/Cargo.toml b/examples/ipfs-private/Cargo.toml index 8d3a49e85c0..da68256ce59 100644 --- a/examples/ipfs-private/Cargo.toml +++ b/examples/ipfs-private/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] tokio = { workspace = true, features = ["rt-multi-thread", "macros", "io-std"] } async-trait = "0.1" -either = "1.11" +either = "1.12" futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "dns", "identify", "kad", "macros", "noise", "ping", "pnet", "tcp", "websocket", "yamux"] } tracing = { workspace = true } diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 074a09a4327..6f8fb0b377d 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -15,4 +15,4 @@ redis = { version = "0.23.0", default-features = false, features = ["tokio-comp" tokio = { workspace = true, features = ["full"] } serde = { version = "1.0.201", features = ["derive"] } serde_json = "1.0.117" -either = "1.11.0" +either = "1.12.0" diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 091ecc86558..4277429e118 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] anyhow = "1" -either = "1.11.0" +either = "1.12.0" futures = { workspace = true } rand = "0.8.5" serde = { version = "1", features = ["derive"] } diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 7be4b01fef5..e1640a6f459 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] asynchronous-codec = { workspace = true } -either = "1.11.0" +either = "1.12.0" futures = { workspace = true } futures-timer = "3.0" instant = "0.1.12" diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index dbe9e6c161c..b50d65064be 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -18,7 +18,7 @@ asynchronous-codec = { workspace = true } base64 = "0.22.1" byteorder = "1.5.0" bytes = "1.6" -either = "1.11" +either = "1.12" fnv = "1.0.7" futures = { workspace = true } futures-ticker = "0.0.3" diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 626db2ab944..2717aefeced 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -25,7 +25,7 @@ smallvec = "1.13.2" thiserror = "1.0" tracing = { workspace = true } void = "1.0" -either = "1.11.0" +either = "1.12.0" [dev-dependencies] async-std = { version = "1.6.2", features = ["attributes"] } diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index bf4caf28e97..9389518e9d1 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] arrayvec = "0.7.4" bytes = "1" -either = "1.11" +either = "1.12" fnv = "1.0" asynchronous-codec = { workspace = true } futures = { workspace = true } diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index eb08d21ca92..c12d21e7375 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -either = "1.11.0" +either = "1.12.0" futures = { workspace = true } futures-timer = "3.0.3" instant = "0.1.12" diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 35f404d89b4..6c9210d6b3d 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] asynchronous-codec = { workspace = true } bytes = "1" -either = "1.11.0" +either = "1.12.0" futures = { workspace = true } futures-timer = "3" futures-bounded = { workspace = true } diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 5c4529b5f10..6efaa17db80 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -either = "1.11.0" +either = "1.12.0" fnv = "1.0" futures = { workspace = true } futures-timer = "3.0.3" @@ -41,7 +41,7 @@ wasm-bindgen = ["dep:wasm-bindgen-futures", "dep:getrandom"] [dev-dependencies] async-std = { version = "1.6.2", features = ["attributes"] } -either = "1.11.0" +either = "1.12.0" futures = { workspace = true } libp2p-identify = { path = "../protocols/identify" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. libp2p-identity = { workspace = true, features = ["ed25519"] } diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 806086a4369..de748131b81 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures-rustls = { workspace = true, features = ["ring"] } -either = "1.11.0" +either = "1.12.0" futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } From f99301a550629266d6f3b5da0c164aa0e8c7716b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 12:54:20 +0000 Subject: [PATCH 120/246] deps: bump serde from 1.0.201 to 1.0.202 Pull-Request: #5407. --- Cargo.lock | 8 ++++---- hole-punching-tests/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 667f0371af0..d55cbfcdd4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5446,18 +5446,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.201" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 6f8fb0b377d..627813e9d54 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -13,6 +13,6 @@ libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { workspace = true, features = ["full"] } -serde = { version = "1.0.201", features = ["derive"] } +serde = { version = "1.0.202", features = ["derive"] } serde_json = "1.0.117" either = "1.12.0" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 91845657526..cfe5c161cf4 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -15,7 +15,7 @@ release = false [dependencies] clap = { version = "4.5.4", features = ["derive"] } zeroize = "1" -serde = { version = "1.0.201", features = ["derive"] } +serde = { version = "1.0.202", features = ["derive"] } serde_json = "1.0.117" libp2p-core = { workspace = true } base64 = "0.22.1" diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 3fb69fdf20f..0538e7d3b6d 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -18,7 +18,7 @@ futures-timer = "3" axum = "0.7" libp2p = { workspace = true, features = ["autonat", "dns", "tokio", "noise", "tcp", "yamux", "identify", "kad", "ping", "relay", "metrics", "rsa", "macros", "quic", "websocket"] } prometheus-client = { workspace = true } -serde = "1.0.201" +serde = "1.0.202" serde_derive = "1.0.125" serde_json = "1.0" tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } From ad7ad5b3fc5b4bc9a431ece90e9a5ce8c33ca0e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 13:06:10 +0000 Subject: [PATCH 121/246] deps: bump instant from 0.1.12 to 0.1.13 Pull-Request: #5408. --- Cargo.lock | 4 ++-- core/Cargo.toml | 2 +- interop-tests/Cargo.toml | 2 +- misc/metrics/Cargo.toml | 2 +- protocols/dcutr/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- protocols/kad/Cargo.toml | 2 +- protocols/perf/Cargo.toml | 2 +- protocols/ping/Cargo.toml | 2 +- protocols/rendezvous/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- swarm/Cargo.toml | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d55cbfcdd4f..1fb2d56368d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2416,9 +2416,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", "js-sys", diff --git a/core/Cargo.toml b/core/Cargo.toml index 4eb9a55e904..011b9e96c21 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -15,7 +15,7 @@ either = "1.12" fnv = "1.0" futures = { workspace = true, features = ["executor", "thread-pool"] } futures-timer = "3" -instant = "0.1.12" +instant = "0.1.13" libp2p-identity = { workspace = true, features = ["peerid", "ed25519"] } multiaddr = { workspace = true } multihash = { workspace = true } diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 4277429e118..278ac1b75a5 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -46,7 +46,7 @@ libp2p-webrtc-websys = { workspace = true } wasm-bindgen = { version = "0.2" } wasm-bindgen-futures = { version = "0.4" } wasm-logger = { version = "0.2.0" } -instant = "0.1.12" +instant = "0.1.13" reqwest = { version = "0.12", features = ["json"] } console_error_panic_hook = { version = "0.1.7" } futures-timer = "3.0.3" diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index 4901a3852d7..51da56db29f 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -20,7 +20,7 @@ relay = ["libp2p-relay"] [dependencies] futures = { workspace = true } -instant = "0.1.12" +instant = "0.1.13" libp2p-core = { workspace = true } libp2p-dcutr = { workspace = true, optional = true } libp2p-gossipsub = { workspace = true, optional = true } diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index e1640a6f459..97823acbbc0 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -15,7 +15,7 @@ asynchronous-codec = { workspace = true } either = "1.12.0" futures = { workspace = true } futures-timer = "3.0" -instant = "0.1.12" +instant = "0.1.13" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index b50d65064be..39a838dc8bd 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -24,7 +24,7 @@ futures = { workspace = true } futures-ticker = "0.0.3" getrandom = "0.2.14" hex_fmt = "0.3.0" -instant = "0.1.12" +instant = "0.1.13" libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-swarm = { workspace = true } diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 9389518e9d1..e9067609502 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -29,7 +29,7 @@ smallvec = "1.13.2" uint = "0.9" void = "1.0" futures-timer = "3.0.3" -instant = "0.1.12" +instant = "0.1.13" serde = { version = "1.0", optional = true, features = ["derive"] } thiserror = "1" tracing = { workspace = true } diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 9a3d0d57f02..2f1446f197c 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -16,7 +16,7 @@ clap = { version = "4.5.4", features = ["derive"] } futures = { workspace = true } futures-bounded = { workspace = true } futures-timer = "3.0" -instant = "0.1.12" +instant = "0.1.13" libp2p = { workspace = true, features = ["tokio", "tcp", "quic", "tls", "yamux", "dns"] } libp2p-core = { workspace = true } libp2p-dns = { workspace = true, features = ["tokio"] } diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index c12d21e7375..f959e2d5436 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] either = "1.12.0" futures = { workspace = true } futures-timer = "3.0.3" -instant = "0.1.12" +instant = "0.1.13" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index 0de7e5fc2d2..83b1e40af69 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -16,7 +16,7 @@ async-trait = "0.1" bimap = "0.6.3" futures = { workspace = true, features = ["std"] } futures-timer = "3.0.3" -instant = "0.1.12" +instant = "0.1.13" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index f33ee9bb916..f04320ef6b7 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] async-trait = "0.1" cbor4ii = { version = "0.3.2", features = ["serde1", "use_std"], optional = true } futures = { workspace = true } -instant = "0.1.12" +instant = "0.1.13" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 6efaa17db80..15797716603 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -16,7 +16,7 @@ fnv = "1.0" futures = { workspace = true } futures-timer = "3.0.3" getrandom = { version = "0.2.14", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature -instant = "0.1.12" +instant = "0.1.13" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } libp2p-swarm-derive = { workspace = true, optional = true } From 6aaf284de47e37c528bceeb0eeaa7f09e48997ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 13:00:30 +0000 Subject: [PATCH 122/246] deps: bump anyhow from 1.0.83 to 1.0.86 Pull-Request: #5409. --- Cargo.lock | 4 ++-- examples/browser-webrtc/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fb2d56368d..bb5185446d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arbitrary" diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index 87b4a955ed3..731ac289e66 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -16,7 +16,7 @@ release = false crate-type = ["cdylib"] [dependencies] -anyhow = "1.0.83" +anyhow = "1.0.86" futures = { workspace = true } rand = "0.8" tracing = { workspace = true } diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index e2b3a2ae83b..61a1413edf5 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" clap = { version = "4.5.4", features = ["derive"] } env_logger = "0.10" futures = { workspace = true } -anyhow = "1.0.83" +anyhow = "1.0.86" libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "yamux", "rsa"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index f04320ef6b7..1eb8c1ae95f 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -32,7 +32,7 @@ json = ["dep:serde", "dep:serde_json", "libp2p-swarm/macros"] cbor = ["dep:serde", "dep:cbor4ii", "libp2p-swarm/macros"] [dev-dependencies] -anyhow = "1.0.83" +anyhow = "1.0.86" async-std = { version = "1.6.2", features = ["attributes"] } libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } From 94fef37d9b2e66c25a2baab87ce74ac1adeee4fd Mon Sep 17 00:00:00 2001 From: William Blankenship Date: Thu, 23 May 2024 09:08:55 -0600 Subject: [PATCH 123/246] deps(quic): update quinn to 0.11 and libp2p-tls to 0.4.0 This PR updates the following dependencies `quic`: * `quinn@0.10.2` -> `quinn@0.11.0` * `rustls@0.21.9` -> `rustls@0.23.4` Pull-Request: #5316. --- Cargo.lock | 72 +++++++++----------- Cargo.toml | 2 +- transports/quic/CHANGELOG.md | 4 ++ transports/quic/Cargo.toml | 8 +-- transports/quic/src/config.rs | 18 +++-- transports/quic/src/connection/connecting.rs | 3 +- transports/quic/src/connection/stream.rs | 4 +- transports/quic/src/transport.rs | 14 +++- transports/quic/tests/smoke.rs | 2 +- 9 files changed, 71 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb5185446d8..05742c9a961 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1729,16 +1729,6 @@ dependencies = [ "syn 2.0.65", ] -[[package]] -name = "futures-rustls" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28" -dependencies = [ - "futures-io", - "rustls 0.21.11", -] - [[package]] name = "futures-rustls" version = "0.26.0" @@ -3203,14 +3193,14 @@ dependencies = [ "libp2p-muxer-test-harness", "libp2p-noise", "libp2p-tcp", - "libp2p-tls 0.3.0", + "libp2p-tls 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux", "parking_lot", "quickcheck", "quinn", "rand 0.8.5", - "ring 0.16.20", - "rustls 0.21.11", + "ring 0.17.8", + "rustls 0.23.5", "socket2 0.5.7", "thiserror", "tokio", @@ -3423,41 +3413,41 @@ dependencies = [ [[package]] name = "libp2p-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ce7e3c2e7569d685d08ec795157981722ff96e9e9f9eae75df3c29d02b07a5" +version = "0.4.0" dependencies = [ "futures", - "futures-rustls 0.24.0", - "libp2p-core 0.41.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-rustls", + "hex", + "hex-literal", + "libp2p-core 0.41.2", "libp2p-identity", + "libp2p-swarm", + "libp2p-yamux", "rcgen", - "ring 0.16.20", - "rustls 0.21.11", + "ring 0.17.8", + "rustls 0.23.5", "rustls-webpki 0.101.7", "thiserror", - "x509-parser 0.15.1", + "tokio", + "x509-parser 0.16.0", "yasna", ] [[package]] name = "libp2p-tls" version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "251b17aebdd29df7e8f80e4d94b782fae42e934c49086e1a81ba23b60a8314f2" dependencies = [ "futures", - "futures-rustls 0.26.0", - "hex", - "hex-literal", - "libp2p-core 0.41.2", + "futures-rustls", + "libp2p-core 0.41.2 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-identity", - "libp2p-swarm", - "libp2p-yamux", "rcgen", "ring 0.17.8", "rustls 0.23.5", "rustls-webpki 0.101.7", "thiserror", - "tokio", "x509-parser 0.16.0", "yasna", ] @@ -3566,7 +3556,7 @@ dependencies = [ "async-std", "either", "futures", - "futures-rustls 0.26.0", + "futures-rustls", "libp2p-core 0.41.2", "libp2p-dns", "libp2p-identity", @@ -4673,11 +4663,11 @@ dependencies = [ [[package]] name = "quinn" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cc2c5017e4b43d5995dcea317bc46c1e09404c0a9664d2908f7f02dfe943d75" +checksum = "4bb80dc034523335a9fcc34271931dd97e9132d1fb078695db500339eb72e712" dependencies = [ - "async-io 1.13.0", + "async-io 2.3.2", "async-std", "bytes", "futures-io", @@ -4685,7 +4675,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.21.11", + "rustls 0.23.5", "thiserror", "tokio", "tracing", @@ -4693,15 +4683,15 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.10.5" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c78e758510582acc40acb90458401172d41f1016f8c9dde89e49677afb7eec1" +checksum = "a063a47a1aaee4b3b1c2dd44edb7867c10107a2ef171f3543ac40ec5e9092002" dependencies = [ "bytes", "rand 0.8.5", - "ring 0.16.20", + "ring 0.17.8", "rustc-hash", - "rustls 0.21.11", + "rustls 0.23.5", "slab", "thiserror", "tinyvec", @@ -4710,15 +4700,15 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6df19e284d93757a9fb91d63672f7741b129246a669db09d1c0063071debc0c0" +checksum = "cb7ad7bc932e4968523fa7d9c320ee135ff779de720e9350fee8728838551764" dependencies = [ - "bytes", "libc", + "once_cell", "socket2 0.5.7", "tracing", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a0218cd5e75..805661b26d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,8 +105,8 @@ libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } libp2p-swarm = { version = "0.44.2", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } -libp2p-tls = { version = "0.4.0", path = "transports/tls" } libp2p-tcp = { version = "0.41.1", path = "transports/tcp" } +libp2p-tls = { version = "0.4.0", path = "transports/tls" } libp2p-uds = { version = "0.40.0", path = "transports/uds" } libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } diff --git a/transports/quic/CHANGELOG.md b/transports/quic/CHANGELOG.md index cd0146afbb2..3ec52ec0ddb 100644 --- a/transports/quic/CHANGELOG.md +++ b/transports/quic/CHANGELOG.md @@ -1,4 +1,8 @@ ## 0.10.3 + +- Update `quinn` to 0.11 and `libp2p-tls` to 0.4.0. + See [PR 5316](https://github.com/libp2p/rust-libp2p/pull/5316) + - Allow configuring MTU discovery upper bound. See [PR 5386](https://github.com/libp2p/rust-libp2p/pull/5386). diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 1270d89b61e..4a935de585b 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -15,17 +15,17 @@ futures = { workspace = true } futures-timer = "3.0.3" if-watch = "3.2.0" libp2p-core = { workspace = true } -libp2p-tls = "0.3.0" +libp2p-tls = "0.4.0" libp2p-identity = { workspace = true } parking_lot = "0.12.2" -quinn = { version = "0.10.2", default-features = false, features = ["tls-rustls", "futures-io"] } +quinn = { version = "0.11.0", default-features = false, features = ["rustls", "futures-io"] } rand = "0.8.5" -rustls = { version = "0.21.9", default-features = false } +rustls = { version = "0.23.5", default-features = false } thiserror = "1.0.61" tokio = { workspace = true, default-features = false, features = ["net", "rt", "time"], optional = true } tracing = { workspace = true } socket2 = "0.5.7" -ring = "0.16.20" +ring = { workspace = true } [features] tokio = ["dep:tokio", "if-watch/tokio", "quinn/runtime-tokio"] diff --git a/transports/quic/src/config.rs b/transports/quic/src/config.rs index c5189ce36cd..2456ed3e36f 100644 --- a/transports/quic/src/config.rs +++ b/transports/quic/src/config.rs @@ -18,7 +18,10 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use quinn::{MtuDiscoveryConfig, VarInt}; +use quinn::{ + crypto::rustls::{QuicClientConfig, QuicServerConfig}, + MtuDiscoveryConfig, VarInt, +}; use std::{sync::Arc, time::Duration}; /// Config for the transport. @@ -58,9 +61,9 @@ pub struct Config { pub support_draft_29: bool, /// TLS client config for the inner [`quinn::ClientConfig`]. - client_tls_config: Arc, + client_tls_config: Arc, /// TLS server config for the inner [`quinn::ServerConfig`]. - server_tls_config: Arc, + server_tls_config: Arc, /// Libp2p identity of the node. keypair: libp2p_identity::Keypair, @@ -71,8 +74,13 @@ pub struct Config { impl Config { /// Creates a new configuration object with default values. pub fn new(keypair: &libp2p_identity::Keypair) -> Self { - let client_tls_config = Arc::new(libp2p_tls::make_client_config(keypair, None).unwrap()); - let server_tls_config = Arc::new(libp2p_tls::make_server_config(keypair).unwrap()); + let client_tls_config = Arc::new( + QuicClientConfig::try_from(libp2p_tls::make_client_config(keypair, None).unwrap()) + .unwrap(), + ); + let server_tls_config = Arc::new( + QuicServerConfig::try_from(libp2p_tls::make_server_config(keypair).unwrap()).unwrap(), + ); Self { client_tls_config, server_tls_config, diff --git a/transports/quic/src/connection/connecting.rs b/transports/quic/src/connection/connecting.rs index 141f0b5542e..f6e397b4d1e 100644 --- a/transports/quic/src/connection/connecting.rs +++ b/transports/quic/src/connection/connecting.rs @@ -28,6 +28,7 @@ use futures::{ }; use futures_timer::Delay; use libp2p_identity::PeerId; +use quinn::rustls::pki_types::CertificateDer; use std::{ pin::Pin, task::{Context, Poll}, @@ -55,7 +56,7 @@ impl Connecting { let identity = connection .peer_identity() .expect("connection got identity because it passed TLS handshake; qed"); - let certificates: Box> = + let certificates: Box> = identity.downcast().expect("we rely on rustls feature; qed"); let end_entity = certificates .first() diff --git a/transports/quic/src/connection/stream.rs b/transports/quic/src/connection/stream.rs index b0c505bf856..ed3a71ea496 100644 --- a/transports/quic/src/connection/stream.rs +++ b/transports/quic/src/connection/stream.rs @@ -67,7 +67,9 @@ impl AsyncWrite for Stream { cx: &mut Context, buf: &[u8], ) -> Poll> { - Pin::new(&mut self.send).poll_write(cx, buf) + Pin::new(&mut self.send) + .poll_write(cx, buf) + .map_err(Into::into) } fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { diff --git a/transports/quic/src/transport.rs b/transports/quic/src/transport.rs index c33931fc798..9bd4c035cec 100644 --- a/transports/quic/src/transport.rs +++ b/transports/quic/src/transport.rs @@ -425,7 +425,7 @@ struct Listener { socket: UdpSocket, /// A future to poll new incoming connections. - accept: BoxFuture<'static, Option>, + accept: BoxFuture<'static, Option>, /// Timeout for connection establishment on inbound connections. handshake_timeout: Duration, @@ -583,10 +583,20 @@ impl Stream for Listener

{ } match self.accept.poll_unpin(cx) { - Poll::Ready(Some(connecting)) => { + Poll::Ready(Some(incoming)) => { let endpoint = self.endpoint.clone(); self.accept = async move { endpoint.accept().await }.boxed(); + let connecting = match incoming.accept() { + Ok(connecting) => connecting, + Err(error) => { + return Poll::Ready(Some(TransportEvent::ListenerError { + listener_id: self.listener_id, + error: Error::Connection(crate::ConnectionError(error)), + })) + } + }; + let local_addr = socketaddr_to_multiaddr(&self.socket_addr(), self.version); let remote_addr = connecting.remote_address(); let send_back_addr = socketaddr_to_multiaddr(&remote_addr, self.version); diff --git a/transports/quic/tests/smoke.rs b/transports/quic/tests/smoke.rs index 36fb72a5ee7..74423076780 100644 --- a/transports/quic/tests/smoke.rs +++ b/transports/quic/tests/smoke.rs @@ -408,7 +408,7 @@ async fn write_after_peer_dropped_stream() { .try_init(); let (stream_a, mut stream_b) = build_streams::().await; drop(stream_a); - futures_timer::Delay::new(Duration::from_millis(1)).await; + futures_timer::Delay::new(Duration::from_millis(10)).await; let data = vec![0; 10]; stream_b.write_all(&data).await.expect("Write failed."); From b83d3ce762caa70d473de5b4b03349b089fa513e Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Sun, 26 May 2024 19:45:50 +0300 Subject: [PATCH 124/246] chore(webtransport-websys): Change logs to debug level When you enable Kademlia in a large network that uses multiple type of transports, then this log creates a very noisy console and makes meaningful logs hard to see. We can also remove the log entirely if you prefer. Check: https://github.com/libp2p/rust-libp2p/pull/4015#discussion_r1229951440, https://github.com/libp2p/rust-libp2p/issues/4072, https://github.com/libp2p/rust-libp2p/pull/4133 Pull-Request: #5396. --- Cargo.lock | 2 +- Cargo.toml | 2 +- transports/webtransport-websys/CHANGELOG.md | 7 +++++-- transports/webtransport-websys/Cargo.toml | 2 +- transports/webtransport-websys/src/transport.rs | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05742c9a961..87a27d282fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3592,7 +3592,7 @@ dependencies = [ [[package]] name = "libp2p-webtransport-websys" -version = "0.2.1" +version = "0.3.0" dependencies = [ "futures", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 805661b26d7..aa82f5fa12d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,7 +114,7 @@ libp2p-webrtc-utils = { version = "0.2.0", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.43.0", path = "transports/websocket" } libp2p-websocket-websys = { version = "0.3.2", path = "transports/websocket-websys" } -libp2p-webtransport-websys = { version = "0.2.1", path = "transports/webtransport-websys" } +libp2p-webtransport-websys = { version = "0.3.0", path = "transports/webtransport-websys" } libp2p-yamux = { version = "0.45.1", path = "muxers/yamux" } multiaddr = "0.18.1" multihash = "0.19.1" diff --git a/transports/webtransport-websys/CHANGELOG.md b/transports/webtransport-websys/CHANGELOG.md index 91749001010..0409819a63f 100644 --- a/transports/webtransport-websys/CHANGELOG.md +++ b/transports/webtransport-websys/CHANGELOG.md @@ -1,7 +1,10 @@ -## 0.2.1 +## 0.3.0 * Fix unhandled exceptions thrown when calling `Webtransport::close`. - See [PR 5390](https://github.com/libp2p/rust-libp2p/pull/5390) + See [PR 5390](https://github.com/libp2p/rust-libp2p/pull/5390). +* Change logs to debug level. + See [PR 5396](https://github.com/libp2p/rust-libp2p/pull/5396). + ## 0.2.0 diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index b039bedb182..3defdce5203 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-webtransport-websys" edition = "2021" rust-version = { workspace = true } description = "WebTransport for libp2p under WASM environment" -version = "0.2.1" +version = "0.3.0" authors = [ "Yiannis Marangos ", "oblique ", diff --git a/transports/webtransport-websys/src/transport.rs b/transports/webtransport-websys/src/transport.rs index cb556ffef99..3f14f3e476b 100644 --- a/transports/webtransport-websys/src/transport.rs +++ b/transports/webtransport-websys/src/transport.rs @@ -65,7 +65,7 @@ impl libp2p_core::Transport for Transport { fn dial(&mut self, addr: Multiaddr) -> Result> { let endpoint = Endpoint::from_multiaddr(&addr).map_err(|e| match e { e @ Error::InvalidMultiaddr(_) => { - tracing::warn!("{}", e); + tracing::debug!("{}", e); TransportError::MultiaddrNotSupported(addr) } e => TransportError::Other(e), From bf3e2682ee41d0428b8b04977e0e799fcb870e2d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 08:52:41 +0000 Subject: [PATCH 125/246] deps: bump getrandom from 0.2.14 to 0.2.15 Pull-Request: #5420. --- Cargo.lock | 22 +++++++++++----------- protocols/gossipsub/Cargo.toml | 2 +- swarm/Cargo.toml | 2 +- transports/webrtc-websys/Cargo.toml | 2 +- wasm-tests/webtransport-tests/Cargo.toml | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87a27d282fe..8cf90dcb6e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1827,9 +1827,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -2615,7 +2615,7 @@ dependencies = [ "either", "futures", "futures-timer", - "getrandom 0.2.14", + "getrandom 0.2.15", "instant", "libp2p-allow-block-list", "libp2p-autonat", @@ -2853,7 +2853,7 @@ dependencies = [ "fnv", "futures", "futures-ticker", - "getrandom 0.2.14", + "getrandom 0.2.15", "hex", "hex_fmt", "instant", @@ -3341,7 +3341,7 @@ dependencies = [ "fnv", "futures", "futures-timer", - "getrandom 0.2.14", + "getrandom 0.2.15", "instant", "libp2p-core 0.41.2", "libp2p-identify", @@ -3535,7 +3535,7 @@ version = "0.3.0-alpha" dependencies = [ "bytes", "futures", - "getrandom 0.2.14", + "getrandom 0.2.15", "hex", "js-sys", "libp2p-core 0.41.2", @@ -4779,7 +4779,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", ] [[package]] @@ -4869,7 +4869,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", "redox_syscall 0.2.16", "thiserror", ] @@ -5034,7 +5034,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.14", + "getrandom 0.2.15", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -6505,7 +6505,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", ] [[package]] @@ -6931,7 +6931,7 @@ name = "webtransport-tests" version = "0.1.0" dependencies = [ "futures", - "getrandom 0.2.14", + "getrandom 0.2.15", "libp2p-core 0.41.2", "libp2p-identity", "libp2p-noise", diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 39a838dc8bd..9439c0b2e8a 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -22,7 +22,7 @@ either = "1.12" fnv = "1.0.7" futures = { workspace = true } futures-ticker = "0.0.3" -getrandom = "0.2.14" +getrandom = "0.2.15" hex_fmt = "0.3.0" instant = "0.1.13" libp2p-core = { workspace = true } diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 15797716603..b841246aef5 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -15,7 +15,7 @@ either = "1.12.0" fnv = "1.0" futures = { workspace = true } futures-timer = "3.0.3" -getrandom = { version = "0.2.14", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature +getrandom = { version = "0.2.15", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature instant = "0.1.13" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } diff --git a/transports/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index e1590404fda..4a8b8dfcdf0 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -14,7 +14,7 @@ publish = true [dependencies] bytes = "1" futures = { workspace = true } -getrandom = { version = "0.2.14", features = ["js"] } +getrandom = { version = "0.2.15", features = ["js"] } hex = "0.4.3" js-sys = { version = "0.3" } libp2p-core = { workspace = true } diff --git a/wasm-tests/webtransport-tests/Cargo.toml b/wasm-tests/webtransport-tests/Cargo.toml index 2ea3745ee80..cf51a510a3f 100644 --- a/wasm-tests/webtransport-tests/Cargo.toml +++ b/wasm-tests/webtransport-tests/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] futures = { workspace = true } -getrandom = { version = "0.2.14", features = ["js"] } +getrandom = { version = "0.2.15", features = ["js"] } libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-noise = { workspace = true } From 5b419a873708f9a7d6e9609641b7e15faa11b865 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 09:11:20 +0000 Subject: [PATCH 126/246] deps: bump syn from 2.0.65 to 2.0.66 Pull-Request: #5421. --- Cargo.lock | 58 ++++++++++++++++++++--------------------- swarm-derive/Cargo.toml | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8cf90dcb6e5..5bc842af42f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ checksum = "7378575ff571966e99a744addeff0bff98b8ada0dedf1956d59e634db95eaac1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", "synstructure 0.13.1", ] @@ -247,7 +247,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -469,7 +469,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -486,7 +486,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -988,7 +988,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1254,7 +1254,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1385,7 +1385,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1490,7 +1490,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -1726,7 +1726,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -3373,7 +3373,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -4179,7 +4179,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -4390,7 +4390,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -4587,7 +4587,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -4610,7 +4610,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5133,7 +5133,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.65", + "syn 2.0.66", "walkdir", ] @@ -5451,7 +5451,7 @@ checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5484,7 +5484,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5769,7 +5769,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5819,9 +5819,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.65" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -5860,7 +5860,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -5975,7 +5975,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -6077,7 +6077,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -6264,7 +6264,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -6605,7 +6605,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", "wasm-bindgen-shared", ] @@ -6639,7 +6639,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6672,7 +6672,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -7280,7 +7280,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] [[package]] @@ -7300,5 +7300,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.66", ] diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index 215c5fc0311..d4b596a12cf 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -16,7 +16,7 @@ proc-macro = true [dependencies] heck = "0.5" quote = "1.0" -syn = { version = "2.0.65", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } +syn = { version = "2.0.66", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] } proc-macro2 = "1.0" # Passing arguments to the docsrs builder in order to properly document cfg's. From b57c85cab0a77cc2b1b9195793530b5cc7d16425 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 09:47:51 +0000 Subject: [PATCH 127/246] deps: bump quinn from 0.11.0 to 0.11.1 Pull-Request: #5426. --- Cargo.lock | 8 ++++---- transports/quic/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5bc842af42f..e78e8227836 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4663,9 +4663,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb80dc034523335a9fcc34271931dd97e9132d1fb078695db500339eb72e712" +checksum = "904e3d3ba178131798c6d9375db2b13b34337d489b089fc5ba0825a2ff1bee73" dependencies = [ "async-io 2.3.2", "async-std", @@ -4683,9 +4683,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a063a47a1aaee4b3b1c2dd44edb7867c10107a2ef171f3543ac40ec5e9092002" +checksum = "e974563a4b1c2206bbc61191ca4da9c22e4308b4c455e8906751cc7828393f08" dependencies = [ "bytes", "rand 0.8.5", diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 4a935de585b..bc8f8ffe67a 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -18,7 +18,7 @@ libp2p-core = { workspace = true } libp2p-tls = "0.4.0" libp2p-identity = { workspace = true } parking_lot = "0.12.2" -quinn = { version = "0.11.0", default-features = false, features = ["rustls", "futures-io"] } +quinn = { version = "0.11.1", default-features = false, features = ["rustls", "futures-io"] } rand = "0.8.5" rustls = { version = "0.23.5", default-features = false } thiserror = "1.0.61" From a8888a7978f08ec9b8762207bf166193bf312b94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 10:01:09 +0000 Subject: [PATCH 128/246] deps: bump proc-macro2 from 1.0.83 to 1.0.84 Pull-Request: #5427. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e78e8227836..d2d04cf19aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4560,9 +4560,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.83" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" dependencies = [ "unicode-ident", ] From 75288cac5e3a4c52736d56da9071177f872f3a0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 14:40:36 +0000 Subject: [PATCH 129/246] deps: bump rustls from 0.23.5 to 0.23.8 Pull-Request: #5423. --- Cargo.lock | 28 ++++++++++++++-------------- transports/quic/Cargo.toml | 2 +- transports/tls/Cargo.toml | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2d04cf19aa..9e6fc36f8d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1736,7 +1736,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls 0.23.5", + "rustls 0.23.8", "rustls-pki-types", ] @@ -3200,7 +3200,7 @@ dependencies = [ "quinn", "rand 0.8.5", "ring 0.17.8", - "rustls 0.23.5", + "rustls 0.23.8", "socket2 0.5.7", "thiserror", "tokio", @@ -3425,7 +3425,7 @@ dependencies = [ "libp2p-yamux", "rcgen", "ring 0.17.8", - "rustls 0.23.5", + "rustls 0.23.8", "rustls-webpki 0.101.7", "thiserror", "tokio", @@ -3445,7 +3445,7 @@ dependencies = [ "libp2p-identity", "rcgen", "ring 0.17.8", - "rustls 0.23.5", + "rustls 0.23.8", "rustls-webpki 0.101.7", "thiserror", "x509-parser 0.16.0", @@ -4675,7 +4675,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.5", + "rustls 0.23.8", "thiserror", "tokio", "tracing", @@ -4691,7 +4691,7 @@ dependencies = [ "rand 0.8.5", "ring 0.17.8", "rustc-hash", - "rustls 0.23.5", + "rustls 0.23.8", "slab", "thiserror", "tinyvec", @@ -5226,21 +5226,21 @@ dependencies = [ "log", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.2", + "rustls-webpki 0.102.4", "subtle", "zeroize", ] [[package]] name = "rustls" -version = "0.23.5" +version = "0.23.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afabcee0551bd1aa3e18e5adbf2c0544722014b899adb31bd186ec638d3da97e" +checksum = "79adb16721f56eb2d843e67676896a61ce7a0fa622dc18d3e372477a029d2740" dependencies = [ "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.2", + "rustls-webpki 0.102.4", "subtle", "zeroize", ] @@ -5257,9 +5257,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.4.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" @@ -5273,9 +5273,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.2" +version = "0.102.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" dependencies = [ "ring 0.17.8", "rustls-pki-types", diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index bc8f8ffe67a..40af89b65c8 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -20,7 +20,7 @@ libp2p-identity = { workspace = true } parking_lot = "0.12.2" quinn = { version = "0.11.1", default-features = false, features = ["rustls", "futures-io"] } rand = "0.8.5" -rustls = { version = "0.23.5", default-features = false } +rustls = { version = "0.23.8", default-features = false } thiserror = "1.0.61" tokio = { workspace = true, default-features = false, features = ["net", "rt", "time"], optional = true } tracing = { workspace = true } diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 6fa9c426bad..cca7faf829f 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -22,7 +22,7 @@ yasna = "0.5.2" # Exposed dependencies. Breaking changes to these are breaking changes to us. [dependencies.rustls] -version = "0.23.4" +version = "0.23.8" default-features = false features = ["ring", "std"] # Must enable this to allow for custom verification code. From 38f8f21451be8bce45f14a05a048b53fd4481111 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Fri, 31 May 2024 01:28:38 +0300 Subject: [PATCH 130/246] fix(interop-tests): Update chrome container Pull-Request: #5431. --- interop-tests/Dockerfile.chromium | 2 +- interop-tests/src/bin/wasm_ping.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/interop-tests/Dockerfile.chromium b/interop-tests/Dockerfile.chromium index 04af84fdc46..a6b0fc89e82 100644 --- a/interop-tests/Dockerfile.chromium +++ b/interop-tests/Dockerfile.chromium @@ -20,7 +20,7 @@ COPY . . RUN wasm-pack build --target web interop-tests RUN RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --package interop-tests --target x86_64-unknown-linux-gnu --bin wasm_ping -FROM selenium/standalone-chrome:115.0 +FROM selenium/standalone-chrome:125.0 COPY --from=builder /app/target/x86_64-unknown-linux-gnu/release/wasm_ping /usr/local/bin/testplan ENV RUST_BACKTRACE=1 ENTRYPOINT ["testplan"] diff --git a/interop-tests/src/bin/wasm_ping.rs b/interop-tests/src/bin/wasm_ping.rs index e1bb2ea49fb..706fad21039 100644 --- a/interop-tests/src/bin/wasm_ping.rs +++ b/interop-tests/src/bin/wasm_ping.rs @@ -130,6 +130,8 @@ async fn open_in_browser() -> Result<(Child, WebDriver)> { // run a webdriver client let mut caps = DesiredCapabilities::chrome(); caps.set_headless()?; + caps.set_disable_dev_shm_usage()?; + caps.set_no_sandbox()?; let driver = WebDriver::new("http://localhost:45782", caps).await?; // go to the wasm test service driver.goto(format!("http://{BIND_ADDR}")).await?; From 8c291fe891dd50610e5dc01353f0e2fd194b086f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jun 2024 10:46:23 +0000 Subject: [PATCH 131/246] deps: bump tj-actions/glob from 21 to 22 Pull-Request: #5358. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c489d3f5771..87987489450 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -370,7 +370,7 @@ jobs: - run: cargo install --version 0.10.0 pb-rs --locked - name: Glob match - uses: tj-actions/glob@v21 + uses: tj-actions/glob@v22 id: glob with: files: | From 796705cdadee5f996b13f8fe15a4366019fcc12f Mon Sep 17 00:00:00 2001 From: NinaLua <168073229+NinaLua@users.noreply.github.com> Date: Sun, 2 Jun 2024 00:05:08 +0800 Subject: [PATCH 132/246] chore: fix some typos in comment fix some typos in comment Pull-Request: #5348. --- protocols/gossipsub/src/behaviour/tests.rs | 2 +- transports/websocket/src/framed.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index 3cf61f9bb41..6cad719b5ab 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -4546,7 +4546,7 @@ fn test_limit_number_of_message_ids_inside_ihave() { //emit gossip gs.emit_gossip(); - // both peers should have gotten 100 random ihave messages, to asser the randomness, we + // both peers should have gotten 100 random ihave messages, to assert the randomness, we // assert that both have not gotten the same set of messages, but have an intersection // (which is the case with very high probability, the probabiltity of failure is < 10^-58). diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index 26634df9830..f6f99d18580 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -511,7 +511,7 @@ fn parse_ws_dial_addr(addr: Multiaddr) -> Result> { Some(Protocol::Ws(path)) => break (false, path.into_owned()), Some(Protocol::Wss(path)) => { if dns_name.is_none() { - tracing::debug!(addrress=%addr, "Missing DNS name in WSS address"); + tracing::debug!(address=%addr, "Missing DNS name in WSS address"); return Err(Error::InvalidMultiaddr(addr)); } break (true, path.into_owned()); From 914e9c811aaca5924640328c884123ed039bd18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Sat, 1 Jun 2024 19:25:18 +0300 Subject: [PATCH 133/246] deps: deduplicate dependencies Helps to reduce number of dependencies by removing duplicated ones. Pull-Request: #5318. --- Cargo.lock | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e6fc36f8d7..820c602f822 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,15 +64,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - [[package]] name = "aho-corasick" version = "1.0.2" @@ -1862,11 +1853,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "1391ab1f92ffcc08911957149833e682aa3fe252b9f45f966d2ef972274c97df" dependencies = [ - "aho-corasick 0.7.20", + "aho-corasick", "bstr", "fnv", "log", @@ -4880,7 +4871,7 @@ version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", "regex-automata 0.4.4", "regex-syntax 0.8.2", @@ -4901,7 +4892,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", "regex-syntax 0.8.2", ] From d8a3e45bd48596948583ce734ac55c4acfea1944 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jun 2024 18:08:05 +0000 Subject: [PATCH 134/246] deps: bump parking_lot from 0.12.2 to 0.12.3 Pull-Request: #5425. --- Cargo.lock | 4 ++-- core/Cargo.toml | 2 +- transports/dns/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/websocket-websys/Cargo.toml | 2 +- transports/websocket/Cargo.toml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 820c602f822..62437579082 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4312,9 +4312,9 @@ checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", diff --git a/core/Cargo.toml b/core/Cargo.toml index 011b9e96c21..5b3fbe32d0b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -21,7 +21,7 @@ multiaddr = { workspace = true } multihash = { workspace = true } multistream-select = { workspace = true } once_cell = "1.19.0" -parking_lot = "0.12.2" +parking_lot = "0.12.3" pin-project = "1.1.5" quick-protobuf = "0.8" rand = "0.8" diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index 78adccc6069..f7014994587 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -16,7 +16,7 @@ async-trait = "0.1.80" futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -parking_lot = "0.12.2" +parking_lot = "0.12.3" hickory-resolver = { version = "0.24.0", default-features = false, features = ["system-config"] } smallvec = "1.13.2" tracing = { workspace = true } diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 40af89b65c8..20533629404 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -17,7 +17,7 @@ if-watch = "3.2.0" libp2p-core = { workspace = true } libp2p-tls = "0.4.0" libp2p-identity = { workspace = true } -parking_lot = "0.12.2" +parking_lot = "0.12.3" quinn = { version = "0.11.1", default-features = false, features = ["rustls", "futures-io"] } rand = "0.8.5" rustls = { version = "0.23.8", default-features = false } diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index f2f9a6300d0..48bf8d9818a 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -16,7 +16,7 @@ futures = { workspace = true } js-sys = "0.3.69" libp2p-core = { workspace = true } tracing = { workspace = true } -parking_lot = "0.12.2" +parking_lot = "0.12.3" send_wrapper = "0.6.0" thiserror = "1.0.61" wasm-bindgen = "0.2.90" diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index de748131b81..7b83d8284bd 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -16,7 +16,7 @@ either = "1.12.0" futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -parking_lot = "0.12.2" +parking_lot = "0.12.3" pin-project-lite = "0.2.14" rw-stream-sink = { workspace = true } soketto = "0.8.0" From fe4f55e4921f64e71dd6a5e673613d8baea20399 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:11:04 +0000 Subject: [PATCH 135/246] deps: bump proc-macro2 from 1.0.84 to 1.0.85 Pull-Request: #5434. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62437579082..a9ea5787a7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4551,9 +4551,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] From 83facf344c173fa6afee10665689e518c955c489 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:25:28 +0000 Subject: [PATCH 136/246] deps: bump serde from 1.0.202 to 1.0.203 Pull-Request: #5422. --- Cargo.lock | 8 ++++---- hole-punching-tests/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9ea5787a7a..0fd87a2c2c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5427,18 +5427,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 627813e9d54..22edd8e95ca 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -13,6 +13,6 @@ libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros tracing = { workspace = true } redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } tokio = { workspace = true, features = ["full"] } -serde = { version = "1.0.202", features = ["derive"] } +serde = { version = "1.0.203", features = ["derive"] } serde_json = "1.0.117" either = "1.12.0" diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index cfe5c161cf4..22b546aff10 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -15,7 +15,7 @@ release = false [dependencies] clap = { version = "4.5.4", features = ["derive"] } zeroize = "1" -serde = { version = "1.0.202", features = ["derive"] } +serde = { version = "1.0.203", features = ["derive"] } serde_json = "1.0.117" libp2p-core = { workspace = true } base64 = "0.22.1" diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 0538e7d3b6d..072b99bf788 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -18,7 +18,7 @@ futures-timer = "3" axum = "0.7" libp2p = { workspace = true, features = ["autonat", "dns", "tokio", "noise", "tcp", "yamux", "identify", "kad", "ping", "relay", "metrics", "rsa", "macros", "quic", "websocket"] } prometheus-client = { workspace = true } -serde = "1.0.202" +serde = "1.0.203" serde_derive = "1.0.125" serde_json = "1.0" tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } From 8607888c617c711fd9b2e9b5ed22a4f6bc03361b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:39:57 +0000 Subject: [PATCH 137/246] deps: bump async-io from 2.3.2 to 2.3.3 Pull-Request: #5436. --- Cargo.lock | 12 ++++++------ protocols/mdns/Cargo.toml | 2 +- transports/tcp/Cargo.toml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fd87a2c2c3..0e7faca0b3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -331,9 +331,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcccb0f599cfa2f8ace422d3555572f47424da5648a4382a9dd0310ff8210884" +checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" dependencies = [ "async-lock 3.1.0", "cfg-if", @@ -2332,7 +2332,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e" dependencies = [ - "async-io 2.3.2", + "async-io 2.3.3", "core-foundation", "fnv", "futures", @@ -2960,7 +2960,7 @@ dependencies = [ name = "libp2p-mdns" version = "0.45.1" dependencies = [ - "async-io 2.3.2", + "async-io 2.3.3", "async-std", "data-encoding", "futures", @@ -3388,7 +3388,7 @@ dependencies = [ name = "libp2p-tcp" version = "0.41.1" dependencies = [ - "async-io 2.3.2", + "async-io 2.3.3", "async-std", "futures", "futures-timer", @@ -4658,7 +4658,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904e3d3ba178131798c6d9375db2b13b34337d489b089fc5ba0825a2ff1bee73" dependencies = [ - "async-io 2.3.2", + "async-io 2.3.3", "async-std", "bytes", "futures-io", diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index fb96acc7dc0..c939a828d61 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] async-std = { version = "1.12.0", optional = true } -async-io = { version = "2.3.2", optional = true } +async-io = { version = "2.3.3", optional = true } data-encoding = "2.6.0" futures = { workspace = true } if-watch = "3.2.0" diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index cb19bdede3d..648a88d6fed 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -async-io = { version = "2.3.2", optional = true } +async-io = { version = "2.3.3", optional = true } futures = { workspace = true } futures-timer = "3.0" if-watch = "3.2.0" From 1987d96d4b203ffc56e136281f5d2bc51bbf130e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:54:15 +0000 Subject: [PATCH 138/246] deps: bump tokio from 1.37.0 to 1.38.0 Pull-Request: #5437. --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e7faca0b3c..1984b4fdf67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6033,9 +6033,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -6062,9 +6062,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index aa82f5fa12d..8ef9a500820 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,7 +124,7 @@ quick-protobuf-codec = { version = "0.3.1", path = "misc/quick-protobuf-codec" } quickcheck = { package = "quickcheck-ext", path = "misc/quickcheck-ext" } rw-stream-sink = { version = "0.4.0", path = "misc/rw-stream-sink" } unsigned-varint = { version = "0.8.0" } -tokio = { version = "1.37", default-features = false } +tokio = { version = "1.38", default-features = false } tracing = "0.1.37" futures = "0.3.30" ring = "0.17.8" From 3185fb991e2163fcde185d63f97bd85ab2d57234 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 10:49:35 +0000 Subject: [PATCH 139/246] deps: bump zeroize from 1.7.0 to 1.8.1 Pull-Request: #5424. --- Cargo.lock | 4 ++-- identity/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1984b4fdf67..980d9553830 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7276,9 +7276,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] diff --git a/identity/Cargo.toml b/identity/Cargo.toml index 2e3a75475a1..e7d464a520a 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -27,7 +27,7 @@ serde = { version = "1", optional = true, features = ["derive"] } sha2 = { version = "0.10.8", optional = true } thiserror = { version = "1.0", optional = true } void = { version = "1.0", optional = true } -zeroize = { version = "1.7", optional = true } +zeroize = { version = "1.8", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] ring = { workspace = true, features = ["alloc", "std"], optional = true } From 2c5a979a96b3c077a296646b7668bba4a84de5ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:27:02 +0000 Subject: [PATCH 140/246] deps: bump the opentelemetry group across 1 directory with 4 updates Pull-Request: #5435. --- Cargo.lock | 36 +++++++++++------------------------- examples/metrics/Cargo.toml | 8 ++++---- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 980d9553830..df310ead72e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4193,9 +4193,9 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900d57987be3f2aeb70d385fff9b27fb74c5723cc9a52d904d4f9c807a0667bf" +checksum = "1b69a91d4893e713e06f724597ad630f1fa76057a5e1026c0ca67054a9032a76" dependencies = [ "futures-core", "futures-sink", @@ -4203,21 +4203,19 @@ dependencies = [ "once_cell", "pin-project-lite", "thiserror", - "urlencoding", ] [[package]] name = "opentelemetry-otlp" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a016b8d9495c639af2145ac22387dcb88e44118e45320d9238fbf4e7889abcb" +checksum = "a94c69209c05319cdf7460c6d4c055ed102be242a0a6245835d7bc42c6ec7f54" dependencies = [ "async-trait", "futures-core", "http 0.2.9", "opentelemetry", "opentelemetry-proto", - "opentelemetry-semantic-conventions", "opentelemetry_sdk", "prost", "thiserror", @@ -4227,9 +4225,9 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8fddc9b68f5b80dae9d6f510b88e02396f006ad48cac349411fbecc80caae4" +checksum = "984806e6cf27f2b49282e2a05e288f30594f3dbc74eb7a6e99422bc48ed78162" dependencies = [ "opentelemetry", "opentelemetry_sdk", @@ -4237,24 +4235,18 @@ dependencies = [ "tonic", ] -[[package]] -name = "opentelemetry-semantic-conventions" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9ab5bd6c42fb9349dcf28af2ba9a0667f697f9bdcca045d39f2cec5543e2910" - [[package]] name = "opentelemetry_sdk" -version = "0.22.1" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e90c7113be649e31e9a0f8b5ee24ed7a16923b322c3c5ab6367469c049d6b7e" +checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd" dependencies = [ "async-trait", - "crossbeam-channel", "futures-channel", "futures-executor", "futures-util", "glob", + "lazy_static", "once_cell", "opentelemetry", "ordered-float", @@ -6281,9 +6273,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9be14ba1bbe4ab79e9229f7f89fab8d120b865859f10527f31c033e599d2284" +checksum = "f68803492bf28ab40aeccaecc7021096bd256baf7ca77c3d425d89b35a7be4e4" dependencies = [ "js-sys", "once_cell", @@ -6478,12 +6470,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "urlencoding" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" - [[package]] name = "utf8parse" version = "0.2.1" diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index 214b4450de7..f75e6c0a564 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -12,13 +12,13 @@ release = false futures = { workspace = true } axum = "0.7" libp2p = { path = "../../libp2p", features = ["tokio", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] } -opentelemetry = { version = "0.22.0", features = ["metrics"] } -opentelemetry-otlp = { version = "0.15.0", features = ["metrics"] } -opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio", "metrics"] } +opentelemetry = { version = "0.23.0", features = ["metrics"] } +opentelemetry-otlp = { version = "0.16.0", features = ["metrics"] } +opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio", "metrics"] } prometheus-client = { workspace = true } tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } -tracing-opentelemetry = "0.23.0" +tracing-opentelemetry = "0.24.0" tracing-subscriber = { version = "0.3", features = ["env-filter"] } [lints] From 68301b8db54816a616900d088342010fd0493a29 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Tue, 4 Jun 2024 13:02:16 +0300 Subject: [PATCH 141/246] fix(request-response): Report dial IO errors to the user This fixes a potential infinite retrying when dialing bad peers. The error is now reported to the user and they should handle it as they see fit for their case. Pull-Request: #5429. --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/request-response/CHANGELOG.md | 5 +++++ protocols/request-response/Cargo.toml | 2 +- protocols/request-response/src/handler.rs | 9 ++++----- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df310ead72e..f526b1983bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3260,7 +3260,7 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.26.2" +version = "0.26.3" dependencies = [ "anyhow", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 8ef9a500820..18b09e388c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,7 +99,7 @@ libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } libp2p-quic = { version = "0.10.3", path = "transports/quic" } libp2p-relay = { version = "0.17.2", path = "protocols/relay" } libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" } -libp2p-request-response = { version = "0.26.2", path = "protocols/request-response" } +libp2p-request-response = { version = "0.26.3", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } libp2p-swarm = { version = "0.44.2", path = "swarm" } diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index 92417508786..4d2a29ac92c 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.26.3 + +- Report dial IO errors to the user. + See [PR 5429](https://github.com/libp2p/rust-libp2p/pull/5429). + ## 0.26.2 - Deprecate `Behaviour::add_address` in favor of `Swarm::add_peer_address`. diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 1eb8c1ae95f..d621e477bfb 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-request-response" edition = "2021" rust-version = { workspace = true } description = "Generic Request/Response Protocols" -version = "0.26.2" +version = "0.26.3" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/request-response/src/handler.rs b/protocols/request-response/src/handler.rs index 2d45e0d7dc3..96b6217b12a 100644 --- a/protocols/request-response/src/handler.rs +++ b/protocols/request-response/src/handler.rs @@ -236,11 +236,10 @@ where } StreamUpgradeError::Apply(e) => void::unreachable(e), StreamUpgradeError::Io(e) => { - tracing::debug!( - "outbound stream for request {} failed: {e}, retrying", - message.request_id - ); - self.requested_outbound.push_back(message); + self.pending_events.push_back(Event::OutboundStreamFailed { + request_id: message.request_id, + error: e, + }); } } } From af42122f61d0d7be9e4b0ccdadbde0cc1e0f5c9c Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Tue, 4 Jun 2024 17:18:55 +0300 Subject: [PATCH 142/246] fix(request-response): Report failure when streams are at capacity Fixes potential hanging issue if use relies on response or failures to make progress Pull-Request: #5417. --- protocols/request-response/CHANGELOG.md | 3 + protocols/request-response/src/handler.rs | 8 ++- .../request-response/tests/error_reporting.rs | 67 ++++++++++++++++++- 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index 4d2a29ac92c..e9d92b08857 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,5 +1,8 @@ ## 0.26.3 +- Report failure when streams are at capacity. + See [PR 5417](https://github.com/libp2p/rust-libp2p/pull/5417). + - Report dial IO errors to the user. See [PR 5429](https://github.com/libp2p/rust-libp2p/pull/5429). diff --git a/protocols/request-response/src/handler.rs b/protocols/request-response/src/handler.rs index 96b6217b12a..f0467593f85 100644 --- a/protocols/request-response/src/handler.rs +++ b/protocols/request-response/src/handler.rs @@ -159,6 +159,9 @@ where } }; + // Inbound connections are reported to the upper layer from within the above task, + // so by failing to schedule it, it means the upper layer will never know about the + // inbound request. Because of that we do not report any inbound failure. if self .worker_streams .try_push(RequestId::Inbound(request_id), recv.boxed()) @@ -204,7 +207,10 @@ where .try_push(RequestId::Outbound(request_id), send.boxed()) .is_err() { - tracing::warn!("Dropping outbound stream because we are at capacity") + self.pending_events.push_back(Event::OutboundStreamFailed { + request_id: message.request_id, + error: io::Error::new(io::ErrorKind::Other, "max sub-streams reached"), + }); } } diff --git a/protocols/request-response/tests/error_reporting.rs b/protocols/request-response/tests/error_reporting.rs index 2dc82b2e0c5..e78bba926e2 100644 --- a/protocols/request-response/tests/error_reporting.rs +++ b/protocols/request-response/tests/error_reporting.rs @@ -161,6 +161,58 @@ async fn report_outbound_timeout_on_read_response() { futures::future::select(server_task, client_task).await; } +#[async_std::test] +async fn report_outbound_failure_on_max_streams() { + let _ = tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .try_init(); + + // `swarm2` will be able to handle only 1 stream per time. + let swarm2_config = request_response::Config::default() + .with_request_timeout(Duration::from_millis(100)) + .with_max_concurrent_streams(1); + + let (peer1_id, mut swarm1) = new_swarm(); + let (peer2_id, mut swarm2) = new_swarm_with_config(swarm2_config); + + swarm1.listen().with_memory_addr_external().await; + swarm2.connect(&mut swarm1).await; + + let swarm1_task = async move { + let _req_id = swarm1 + .behaviour_mut() + .send_request(&peer2_id, Action::FailOnMaxStreams); + + // Keep the connection alive, otherwise swarm2 may receive `ConnectionClosed` instead. + wait_no_events(&mut swarm1).await; + }; + + // Expects OutboundFailure::Io failure. + let swarm2_task = async move { + let (peer, _inbound_req_id, action, _resp_channel) = + wait_request(&mut swarm2).await.unwrap(); + assert_eq!(peer, peer1_id); + assert_eq!(action, Action::FailOnMaxStreams); + + // A task for sending back a response is already scheduled so max concurrent + // streams is reached and no new tasks can be sheduled. + // + // We produce the failure by creating new request before we response. + let outbound_req_id = swarm2 + .behaviour_mut() + .send_request(&peer1_id, Action::FailOnMaxStreams); + + let (peer, req_id_done, error) = wait_outbound_failure(&mut swarm2).await.unwrap(); + assert_eq!(peer, peer1_id); + assert_eq!(req_id_done, outbound_req_id); + assert!(matches!(error, OutboundFailure::Io(_))); + }; + + let swarm1_task = pin!(swarm1_task); + let swarm2_task = pin!(swarm2_task); + futures::future::select(swarm1_task, swarm2_task).await; +} + #[async_std::test] async fn report_inbound_failure_on_read_request() { let _ = tracing_subscriber::fmt() @@ -332,6 +384,7 @@ enum Action { FailOnWriteRequest, FailOnWriteResponse, TimeoutOnWriteResponse, + FailOnMaxStreams, } impl From for u8 { @@ -343,6 +396,7 @@ impl From for u8 { Action::FailOnWriteRequest => 3, Action::FailOnWriteResponse => 4, Action::TimeoutOnWriteResponse => 5, + Action::FailOnMaxStreams => 6, } } } @@ -358,6 +412,7 @@ impl TryFrom for Action { 3 => Ok(Action::FailOnWriteRequest), 4 => Ok(Action::FailOnWriteResponse), 5 => Ok(Action::TimeoutOnWriteResponse), + 6 => Ok(Action::FailOnMaxStreams), _ => Err(io::Error::new(io::ErrorKind::Other, "invalid action")), } } @@ -468,11 +523,10 @@ impl Codec for TestCodec { } } -fn new_swarm_with_timeout( - timeout: Duration, +fn new_swarm_with_config( + cfg: request_response::Config, ) -> (PeerId, Swarm>) { let protocols = iter::once((StreamProtocol::new("/test/1"), ProtocolSupport::Full)); - let cfg = request_response::Config::default().with_request_timeout(timeout); let swarm = Swarm::new_ephemeral(|_| request_response::Behaviour::::new(protocols, cfg)); @@ -481,6 +535,13 @@ fn new_swarm_with_timeout( (peed_id, swarm) } +fn new_swarm_with_timeout( + timeout: Duration, +) -> (PeerId, Swarm>) { + let cfg = request_response::Config::default().with_request_timeout(timeout); + new_swarm_with_config(cfg) +} + fn new_swarm() -> (PeerId, Swarm>) { new_swarm_with_timeout(Duration::from_millis(100)) } From 9dcc172fd30384407616d1ccb8648c528dd8bede Mon Sep 17 00:00:00 2001 From: DrHuangMHT Date: Tue, 4 Jun 2024 23:07:43 +0800 Subject: [PATCH 143/246] deps: promote tracing-subscriber to workspace level Promote `tracing-subscriber` to workspace-level dependency. Related issue: #5230 Pull-Request: #5441. --- Cargo.toml | 1 + examples/autonat/Cargo.toml | 2 +- examples/browser-webrtc/Cargo.toml | 2 +- examples/chat/Cargo.toml | 2 +- examples/dcutr/Cargo.toml | 2 +- examples/distributed-key-value-store/Cargo.toml | 2 +- examples/file-sharing/Cargo.toml | 2 +- examples/identify/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- examples/ipfs-private/Cargo.toml | 2 +- examples/metrics/Cargo.toml | 2 +- examples/ping/Cargo.toml | 2 +- examples/relay-server/Cargo.toml | 2 +- examples/rendezvous/Cargo.toml | 2 +- examples/stream/Cargo.toml | 2 +- examples/upnp/Cargo.toml | 2 +- interop-tests/Cargo.toml | 4 ++-- libp2p/Cargo.toml | 2 +- misc/multistream-select/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- muxers/mplex/Cargo.toml | 2 +- protocols/autonat/Cargo.toml | 2 +- protocols/dcutr/Cargo.toml | 2 +- protocols/gossipsub/Cargo.toml | 2 +- protocols/identify/Cargo.toml | 2 +- protocols/kad/Cargo.toml | 2 +- protocols/mdns/Cargo.toml | 2 +- protocols/perf/Cargo.toml | 2 +- protocols/ping/Cargo.toml | 2 +- protocols/relay/Cargo.toml | 2 +- protocols/rendezvous/Cargo.toml | 2 +- protocols/request-response/Cargo.toml | 2 +- protocols/stream/Cargo.toml | 2 +- swarm/Cargo.toml | 2 +- transports/dns/Cargo.toml | 2 +- transports/noise/Cargo.toml | 2 +- transports/plaintext/Cargo.toml | 2 +- transports/quic/Cargo.toml | 2 +- transports/tcp/Cargo.toml | 2 +- transports/webrtc/Cargo.toml | 2 +- 40 files changed, 41 insertions(+), 40 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 18b09e388c8..eca9c381b5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -126,6 +126,7 @@ rw-stream-sink = { version = "0.4.0", path = "misc/rw-stream-sink" } unsigned-varint = { version = "0.8.0" } tokio = { version = "1.38", default-features = false } tracing = "0.1.37" +tracing-subscriber = "0.3" futures = "0.3.30" ring = "0.17.8" diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index 80ee30db72b..ce703ca742e 100644 --- a/examples/autonat/Cargo.toml +++ b/examples/autonat/Cargo.toml @@ -14,7 +14,7 @@ clap = { version = "4.5.4", features = ["derive"] } futures = { workspace = true } libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/browser-webrtc/Cargo.toml b/examples/browser-webrtc/Cargo.toml index 731ac289e66..c3630d805fb 100644 --- a/examples/browser-webrtc/Cargo.toml +++ b/examples/browser-webrtc/Cargo.toml @@ -20,7 +20,7 @@ anyhow = "1.0.86" futures = { workspace = true } rand = "0.8" tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] axum = "0.7.5" diff --git a/examples/chat/Cargo.toml b/examples/chat/Cargo.toml index b276791d39b..a1d32956825 100644 --- a/examples/chat/Cargo.toml +++ b/examples/chat/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml index ce027a65ed8..97fabbbd006 100644 --- a/examples/dcutr/Cargo.toml +++ b/examples/dcutr/Cargo.toml @@ -16,7 +16,7 @@ libp2p = { path = "../../libp2p", features = [ "dns", "dcutr", "identify", "macr log = "0.4" tokio = { workspace = true, features = ["macros", "net", "rt", "signal"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/distributed-key-value-store/Cargo.toml b/examples/distributed-key-value-store/Cargo.toml index 4755b499709..9c2e2bce5c9 100644 --- a/examples/distributed-key-value-store/Cargo.toml +++ b/examples/distributed-key-value-store/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "async-std", "dns", "kad", "mdns", "noise", "macros", "tcp", "yamux"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index b53c8732a33..b13c30885cb 100644 --- a/examples/file-sharing/Cargo.toml +++ b/examples/file-sharing/Cargo.toml @@ -15,7 +15,7 @@ clap = { version = "4.5.4", features = ["derive"] } futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } void = "1.0.2" [lints] diff --git a/examples/identify/Cargo.toml b/examples/identify/Cargo.toml index 8ed26ba5fc2..cbe569b9d07 100644 --- a/examples/identify/Cargo.toml +++ b/examples/identify/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1" futures = { workspace = true } libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio","yamux"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index 61a1413edf5..f492fac7fb3 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -17,7 +17,7 @@ futures = { workspace = true } anyhow = "1.0.86" libp2p = { path = "../../libp2p", features = [ "tokio", "dns", "kad", "noise", "tcp", "yamux", "rsa"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/ipfs-private/Cargo.toml b/examples/ipfs-private/Cargo.toml index da68256ce59..0813dba56e0 100644 --- a/examples/ipfs-private/Cargo.toml +++ b/examples/ipfs-private/Cargo.toml @@ -15,7 +15,7 @@ either = "1.12" futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "gossipsub", "dns", "identify", "kad", "macros", "noise", "ping", "pnet", "tcp", "websocket", "yamux"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index f75e6c0a564..2b82668f52a 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -19,7 +19,7 @@ prometheus-client = { workspace = true } tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } tracing-opentelemetry = "0.24.0" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/ping/Cargo.toml b/examples/ping/Cargo.toml index e92b5392c7a..633f043de56 100644 --- a/examples/ping/Cargo.toml +++ b/examples/ping/Cargo.toml @@ -13,7 +13,7 @@ futures = { workspace = true } libp2p = { path = "../../libp2p", features = ["noise", "ping", "tcp", "tokio", "yamux"] } tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/relay-server/Cargo.toml b/examples/relay-server/Cargo.toml index 49b58c9b6bf..e792ca48dd5 100644 --- a/examples/relay-server/Cargo.toml +++ b/examples/relay-server/Cargo.toml @@ -15,7 +15,7 @@ async-trait = "0.1" futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay", "quic"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/rendezvous/Cargo.toml b/examples/rendezvous/Cargo.toml index 0a6229e4f07..5a0672dcec8 100644 --- a/examples/rendezvous/Cargo.toml +++ b/examples/rendezvous/Cargo.toml @@ -15,7 +15,7 @@ futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros", "time"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/stream/Cargo.toml b/examples/stream/Cargo.toml index 2c1f5ad1e9d..de46d204c77 100644 --- a/examples/stream/Cargo.toml +++ b/examples/stream/Cargo.toml @@ -16,7 +16,7 @@ libp2p-stream = { path = "../../protocols/stream", version = "0.1.0-alpha" } rand = "0.8" tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/examples/upnp/Cargo.toml b/examples/upnp/Cargo.toml index 6abe3f8354b..ae292e0a48d 100644 --- a/examples/upnp/Cargo.toml +++ b/examples/upnp/Cargo.toml @@ -12,7 +12,7 @@ release = false tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } futures = { workspace = true } libp2p = { path = "../../libp2p", features = ["tokio", "dns", "macros", "noise", "ping", "tcp", "yamux", "upnp"] } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 278ac1b75a5..3a9fea3c0df 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -18,7 +18,7 @@ futures = { workspace = true } rand = "0.8.5" serde = { version = "1", features = ["derive"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] axum = "0.7" @@ -37,7 +37,7 @@ thirtyfour = "=0.32.0" # https://github.com/stevepryde/thirtyfour/issues/169 tokio = { workspace = true, features = ["full"] } tower-http = { version = "0.5", features = ["cors", "fs", "trace"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [target.'cfg(target_arch = "wasm32")'.dependencies] libp2p = { path = "../libp2p", features = [ "ping", "macros", "webtransport-websys", "wasm-bindgen", "identify", "websocket-websys", "yamux", "noise"] } diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index 01419445b8b..4304f4e557a 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -145,7 +145,7 @@ tokio = { workspace = true, features = [ "io-util", "io-std", "macros", "rt", "r libp2p-mplex = { workspace = true } libp2p-noise = { workspace = true } libp2p-tcp = { workspace = true, features = ["tokio"] } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/misc/multistream-select/Cargo.toml b/misc/multistream-select/Cargo.toml index 3d40f50d967..77d8de54332 100644 --- a/misc/multistream-select/Cargo.toml +++ b/misc/multistream-select/Cargo.toml @@ -24,7 +24,7 @@ futures_ringbuf = "0.4.0" quickcheck = { workspace = true } rand = "0.8" rw-stream-sink = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 072b99bf788..2c146c0c6e3 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -23,7 +23,7 @@ serde_derive = "1.0.125" serde_json = "1.0" tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } zeroize = "1" [lints] diff --git a/muxers/mplex/Cargo.toml b/muxers/mplex/Cargo.toml index 52920479158..fb55e03b614 100644 --- a/muxers/mplex/Cargo.toml +++ b/muxers/mplex/Cargo.toml @@ -32,7 +32,7 @@ libp2p-muxer-test-harness = { path = "../test-harness" } libp2p-plaintext = { workspace = true } libp2p-tcp = { workspace = true, features = ["async-io"] } quickcheck = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [[bench]] name = "split_send_size" diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index 3dd11be4366..ba7a21b4da7 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -28,7 +28,7 @@ asynchronous-codec = { workspace = true } [dev-dependencies] async-std = { version = "1.10", features = ["attributes"] } libp2p-swarm-test = { path = "../../swarm-test" } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 97823acbbc0..819c7a6e56b 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -41,7 +41,7 @@ libp2p-swarm-test = { path = "../../swarm-test" } libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-yamux = { workspace = true } rand = "0.8" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 9439c0b2e8a..aa11a8a8309 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -49,7 +49,7 @@ libp2p-yamux = { workspace = true } libp2p-noise = { workspace = true } libp2p-swarm-test = { path = "../../swarm-test" } quickcheck = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 2717aefeced..e75a2c4c4bc 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -31,7 +31,7 @@ either = "1.12.0" async-std = { version = "1.6.2", features = ["attributes"] } libp2p-swarm-test = { path = "../../swarm-test" } libp2p-swarm = { workspace = true, features = ["macros"] } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index e9067609502..7d3e3caa047 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -43,7 +43,7 @@ libp2p-swarm = { path = "../../swarm", features = ["macros"] } libp2p-swarm-test = { path = "../../swarm-test" } libp2p-yamux = { workspace = true } quickcheck = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [features] serde = ["dep:serde", "bytes/serde"] diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index c939a828d61..0d58c9467c4 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -39,7 +39,7 @@ libp2p-tcp = { workspace = true, features = ["tokio", "async-io"] } libp2p-yamux = { workspace = true } tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread", "time"] } libp2p-swarm-test = { path = "../../swarm-test" } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [[test]] name = "use-async-std" diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 2f1446f197c..6ed6baa0714 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -30,7 +30,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" tracing = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread"] } void = "1" diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index f959e2d5436..c436478668c 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -27,7 +27,7 @@ async-std = "1.6.2" libp2p-swarm = { workspace = true, features = ["macros"] } libp2p-swarm-test = { path = "../../swarm-test" } quickcheck = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 6c9210d6b3d..aa185a42af0 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -37,7 +37,7 @@ libp2p-swarm = { workspace = true, features = ["macros", "async-std"] } libp2p-swarm-test = { workspace = true } libp2p-yamux = { workspace = true } quickcheck = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index 83b1e40af69..2d344e5e250 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -38,7 +38,7 @@ libp2p-tcp = { workspace = true, features = ["tokio"] } libp2p-yamux = { workspace = true } rand = "0.8" tokio = { workspace = true, features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index d621e477bfb..794a3e74956 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -41,7 +41,7 @@ rand = "0.8" libp2p-swarm-test = { path = "../../swarm-test" } futures_ringbuf = "0.4.0" serde = { version = "1.0", features = ["derive"] } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/protocols/stream/Cargo.toml b/protocols/stream/Cargo.toml index b90f9958173..a8d88399c0b 100644 --- a/protocols/stream/Cargo.toml +++ b/protocols/stream/Cargo.toml @@ -21,7 +21,7 @@ rand = "0.8" [dev-dependencies] libp2p-swarm-test = { workspace = true } tokio = { workspace = true, features = ["full"] } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] workspace = true diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index b841246aef5..17a66abba0a 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -56,7 +56,7 @@ void = "1" once_cell = "1.19.0" trybuild = "1.0.96" tokio = { workspace = true, features = ["time", "rt", "macros", "rt-multi-thread"] } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [[test]] name = "swarm_derive" diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index f7014994587..105fe0a62d0 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -25,7 +25,7 @@ tracing = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } tokio = { workspace = true, features = ["rt", "time"] } async-std-crate = { package = "async-std", version = "1.6" } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [features] async-std = ["async-std-resolver"] diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 36013f077f2..7333d4cddda 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -36,7 +36,7 @@ snow = { version = "0.9.5", features = ["default-resolver"], default-features = [dev-dependencies] futures_ringbuf = "0.4.0" quickcheck = { workspace = true } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } libp2p-identity = { workspace = true, features = ["rand"] } # Passing arguments to the docsrs builder in order to properly document cfg's. diff --git a/transports/plaintext/Cargo.toml b/transports/plaintext/Cargo.toml index 33e7ae1ab5c..db6fe75b505 100644 --- a/transports/plaintext/Cargo.toml +++ b/transports/plaintext/Cargo.toml @@ -25,7 +25,7 @@ libp2p-identity = { workspace = true, features = ["ed25519", "rand"] } quickcheck = { workspace = true } rand = "0.8" futures_ringbuf = "0.4.0" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 20533629404..42296d0c0a7 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -47,7 +47,7 @@ libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-yamux = { workspace = true } quickcheck = "1" tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time"] } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [[test]] name = "stream_compliance" diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 648a88d6fed..7f0cf5ca943 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -30,7 +30,7 @@ async-io = ["dep:async-io", "if-watch/smol"] async-std = { version = "1.6.5", features = ["attributes"] } libp2p-identity = { workspace = true, features = ["rand"] } tokio = { workspace = true, features = ["full"] } -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index a1de95a1993..0450616261e 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -41,7 +41,7 @@ pem = ["webrtc?/pem"] libp2p-identity = { workspace = true, features = ["rand"] } tokio = { workspace = true, features = ["full"] } quickcheck = "1.0.3" -tracing-subscriber = { version = "0.3", features = ["env-filter"] } +tracing-subscriber = { workspace = true, features = ["env-filter"] } [[test]] From 3da7d918d0d3c443f20d1813772af1ac152b68c7 Mon Sep 17 00:00:00 2001 From: Doug A Date: Wed, 5 Jun 2024 13:09:46 -0300 Subject: [PATCH 144/246] fix(webrtc-utils): read buffer only if empty message This PR adds a return of `Poll::Ready(Ok(0))` when the `message` vector is empty or not present. This missing return was causing the stream not to finish, then to be dropped, causing the request response protocol to fail over WebRTC. Now that empty or non existent message vectors get returned as `Ok(0)` the stream can be read and request response works now over WebRTC. Pull-Request: #5439. --- Cargo.lock | 2 +- Cargo.toml | 2 +- misc/webrtc-utils/CHANGELOG.md | 5 +++++ misc/webrtc-utils/Cargo.toml | 2 +- misc/webrtc-utils/src/stream.rs | 10 ++++++++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f526b1983bd..a3e98555eca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3500,7 +3500,7 @@ dependencies = [ [[package]] name = "libp2p-webrtc-utils" -version = "0.2.0" +version = "0.2.1" dependencies = [ "asynchronous-codec", "bytes", diff --git a/Cargo.toml b/Cargo.toml index eca9c381b5d..8c8c0a70fd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,7 +110,7 @@ libp2p-tls = { version = "0.4.0", path = "transports/tls" } libp2p-uds = { version = "0.40.0", path = "transports/uds" } libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } -libp2p-webrtc-utils = { version = "0.2.0", path = "misc/webrtc-utils" } +libp2p-webrtc-utils = { version = "0.2.1", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.43.0", path = "transports/websocket" } libp2p-websocket-websys = { version = "0.3.2", path = "transports/websocket-websys" } diff --git a/misc/webrtc-utils/CHANGELOG.md b/misc/webrtc-utils/CHANGELOG.md index 6949113a377..b69bf74bfc8 100644 --- a/misc/webrtc-utils/CHANGELOG.md +++ b/misc/webrtc-utils/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.1 + +- Fix end of stream handling when buffer is empty or not present. + See [PR 5439](https://github.com/libp2p/rust-libp2p/pull/5439). + ## 0.2.0 - Update to latest version of `libp2p-noise`. diff --git a/misc/webrtc-utils/Cargo.toml b/misc/webrtc-utils/Cargo.toml index f548773b8dd..d870e43781e 100644 --- a/misc/webrtc-utils/Cargo.toml +++ b/misc/webrtc-utils/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT" name = "libp2p-webrtc-utils" repository = "https://github.com/libp2p/rust-libp2p" rust-version = { workspace = true } -version = "0.2.0" +version = "0.2.1" publish = true [dependencies] diff --git a/misc/webrtc-utils/src/stream.rs b/misc/webrtc-utils/src/stream.rs index 0e1496eb640..17f746a92a1 100644 --- a/misc/webrtc-utils/src/stream.rs +++ b/misc/webrtc-utils/src/stream.rs @@ -146,8 +146,14 @@ where } debug_assert!(read_buffer.is_empty()); - if let Some(message) = message { - *read_buffer = message.into(); + match message { + Some(msg) if !msg.is_empty() => { + *read_buffer = msg.into(); + } + _ => { + tracing::debug!("poll_read buffer is empty, received None"); + return Poll::Ready(Ok(0)); + } } } None => { From 01f7b4006ef42ed35547b44b96c69fa3a27e7583 Mon Sep 17 00:00:00 2001 From: EB Date: Thu, 6 Jun 2024 08:37:29 +0900 Subject: [PATCH 145/246] fix: add example metrics's `tracing::info` Adding a Minimal `println!()` Syntax for Metrics Example Pull-Request: #5440. --- examples/metrics/src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/metrics/src/main.rs b/examples/metrics/src/main.rs index 6b7ad9cedfb..99a9ca66aaf 100644 --- a/examples/metrics/src/main.rs +++ b/examples/metrics/src/main.rs @@ -66,6 +66,13 @@ async fn main() -> Result<(), Box> { loop { match swarm.select_next_some().await { + SwarmEvent::NewListenAddr { address, .. } => { + tracing::info!( + "Local node is listening on\n {}/p2p/{}", + address, + swarm.local_peer_id() + ); + } SwarmEvent::Behaviour(BehaviourEvent::Ping(ping_event)) => { tracing::info!(?ping_event); metrics.record(&ping_event); From 8f42576e1a58a716eae1040a988f99d5b44ce710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 6 Jun 2024 12:12:40 +0100 Subject: [PATCH 146/246] chore: move rcgen to workspace dependency Pull-Request: #5446. --- Cargo.toml | 1 + transports/tls/Cargo.toml | 2 +- transports/webrtc/Cargo.toml | 2 +- transports/websocket/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8c8c0a70fd8..6c6dc114983 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -129,6 +129,7 @@ tracing = "0.1.37" tracing-subscriber = "0.3" futures = "0.3.30" ring = "0.17.8" +rcgen = "0.11.3" [patch.crates-io] diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index cca7faf829f..9bcff3bc88b 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -13,7 +13,7 @@ futures = { workspace = true } futures-rustls = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } -rcgen = "0.11.3" +rcgen = { workspace = true } ring = { workspace = true } thiserror = "1.0.61" webpki = { version = "0.101.4", package = "rustls-webpki", features = ["std"] } diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index 0450616261e..909f78479d9 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -23,7 +23,7 @@ libp2p-identity = { workspace = true } libp2p-webrtc-utils = { workspace = true } multihash = { workspace = true } rand = "0.8" -rcgen = "0.11.3" +rcgen = { workspace = true } serde = { version = "1.0", features = ["derive"] } stun = "0.5" thiserror = "1" diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 7b83d8284bd..bcffe49a561 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -29,7 +29,7 @@ libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-dns = { workspace = true, features = ["async-std"] } libp2p-identity = { workspace = true, features = ["rand"] } async-std = { version = "1.6.5", features = ["attributes"] } -rcgen = "0.11.3" +rcgen = { workspace = true } # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling From b1d94c236e23234637a4379a6058a91a5bc1c42d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 7 Jun 2024 22:43:52 +0100 Subject: [PATCH 147/246] chore: update deny.toml Pull-Request: #5454. --- deny.toml | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/deny.toml b/deny.toml index dedcb7a3a95..5be86107edf 100644 --- a/deny.toml +++ b/deny.toml @@ -2,20 +2,14 @@ # More documentation for the advisories section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html [advisories] +# Version of the advisory config. See https://github.com/EmbarkStudios/cargo-deny/pull/611 +version = 2 # The path where the advisory database is cloned/fetched into db-path = "~/cargo/advisory-db" # The url of the advisory database to use -db-urls = [ "https://github.com/rustsec/advisory-db" ] -# The lint level for security vulnerabilities -vulnerability = "deny" -# The lint level for unmaintained crates -unmaintained = "warn" +db-urls = ["https://github.com/rustsec/advisory-db"] # The lint level for crates that have been yanked from their source registry yanked = "warn" -# The lint level for crates with security notices. Note that as of -# 2019-12-17 there are no security notice advisories in -# https://github.com/rustsec/advisory-db -notice = "warn" # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. ignore = [ @@ -35,35 +29,21 @@ ignore = [ # More documentation for the licenses section can be found here: # https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html [licenses] -# The lint level for crates which do not have a detectable license -unlicensed = "deny" +# Version of the license config. See https://github.com/EmbarkStudios/cargo-deny/pull/611 +version = 2 # List of explicitly allowed licenses # See https://spdx.org/licenses/ for list of possible licenses -# [possible values: any SPDX 3.7 short identifier (+ optional exception)]. +# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. allow = [ + "Apache-2.0 WITH LLVM-exception", "Apache-2.0", "BSD-2-Clause", + "BSD-3-Clause", + "ISC", "MIT", + "MPL-2.0", "Unlicense", ] -# List of explicitly disallowed licenses -# See https://spdx.org/licenses/ for list of possible licenses -# [possible values: any SPDX 3.7 short identifier (+ optional exception)]. -deny = [] -# Lint level for licenses considered copyleft -copyleft = "allow" -# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses -# * both - The license will be approved if it is both OSI-approved *AND* FSF -# * either - The license will be approved if it is either OSI-approved *OR* FSF -# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF -# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved -# * neither - This predicate is ignored and the default lint level is used -allow-osi-fsf-free = "both" -# Lint level used when no other predicates are matched -# 1. License isn't in the allow or deny lists -# 2. License isn't copyleft -# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither" -default = "deny" # The confidence threshold for detecting a license from license text. # The higher the value, the more closely the license text must be to the # canonical license text of a valid SPDX license file. @@ -76,7 +56,7 @@ exceptions = [ # https://www.openssl.org/blog/blog/2017/03/22/license/ # ring crate is ISC & MIT { allow = ["ISC", "MIT", "OpenSSL"], name = "ring" }, - # libp2p is not re-distributing unicode tables data by itself + # libp2p is not re-distributing unicode tables data by itself { allow = ["MIT", "Apache-2.0", "Unicode-DFS-2016"], name = "unicode-ident" }, ] From 88635ea51574821c38db0ed0881227c42a05a1e4 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Sat, 8 Jun 2024 03:39:03 +0300 Subject: [PATCH 148/246] chore: Use `libp2p-tls` from workspace Pull-Request: #5452. --- Cargo.lock | 172 +++++++++++-------------------------- transports/quic/Cargo.toml | 2 +- 2 files changed, 51 insertions(+), 123 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3e98555eca..13b29b0dc0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2440,7 +2440,7 @@ dependencies = [ "libp2p", "libp2p-mplex", "libp2p-noise", - "libp2p-tls 0.4.0", + "libp2p-tls", "libp2p-webrtc", "libp2p-webrtc-websys", "mime_guess", @@ -2567,7 +2567,7 @@ version = "0.1.0" dependencies = [ "base64 0.22.1", "clap", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "serde", "serde_json", @@ -2611,7 +2611,7 @@ dependencies = [ "libp2p-allow-block-list", "libp2p-autonat", "libp2p-connection-limits", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-dcutr", "libp2p-dns", "libp2p-floodsub", @@ -2633,7 +2633,7 @@ dependencies = [ "libp2p-request-response", "libp2p-swarm", "libp2p-tcp", - "libp2p-tls 0.4.0", + "libp2p-tls", "libp2p-uds", "libp2p-upnp", "libp2p-websocket", @@ -2642,7 +2642,7 @@ dependencies = [ "libp2p-yamux", "multiaddr", "pin-project", - "rw-stream-sink 0.4.0", + "rw-stream-sink", "thiserror", "tokio", "tracing-subscriber", @@ -2653,7 +2653,7 @@ name = "libp2p-allow-block-list" version = "0.3.0" dependencies = [ "async-std", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-swarm", "libp2p-swarm-derive", @@ -2671,7 +2671,7 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-request-response", "libp2p-swarm", @@ -2688,7 +2688,7 @@ name = "libp2p-connection-limits" version = "0.3.1" dependencies = [ "async-std", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identify", "libp2p-identity", "libp2p-ping", @@ -2715,14 +2715,14 @@ dependencies = [ "libp2p-noise", "multiaddr", "multihash", - "multistream-select 0.13.0", + "multistream-select", "once_cell", "parking_lot", "pin-project", "quick-protobuf", "quickcheck-ext", "rand 0.8.5", - "rw-stream-sink 0.4.0", + "rw-stream-sink", "serde", "smallvec", "thiserror", @@ -2731,34 +2731,6 @@ dependencies = [ "void", ] -[[package]] -name = "libp2p-core" -version = "0.41.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8130a8269e65a2554d55131c770bdf4bcd94d2b8d4efb24ca23699be65066c05" -dependencies = [ - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-identity", - "multiaddr", - "multihash", - "multistream-select 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "once_cell", - "parking_lot", - "pin-project", - "quick-protobuf", - "rand 0.8.5", - "rw-stream-sink 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec", - "thiserror", - "tracing", - "unsigned-varint 0.8.0", - "void", -] - [[package]] name = "libp2p-dcutr" version = "0.11.0" @@ -2771,7 +2743,7 @@ dependencies = [ "futures-bounded", "futures-timer", "instant", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-dns", "libp2p-identify", "libp2p-identity", @@ -2802,7 +2774,7 @@ dependencies = [ "async-trait", "futures", "hickory-resolver", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "parking_lot", "smallvec", @@ -2820,7 +2792,7 @@ dependencies = [ "cuckoofilter", "fnv", "futures", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-swarm", "quick-protobuf", @@ -2848,7 +2820,7 @@ dependencies = [ "hex", "hex_fmt", "instant", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-noise", "libp2p-swarm", @@ -2878,7 +2850,7 @@ dependencies = [ "futures", "futures-bounded", "futures-timer", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-swarm", "libp2p-swarm-test", @@ -2935,7 +2907,7 @@ dependencies = [ "futures-bounded", "futures-timer", "instant", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identify", "libp2p-identity", "libp2p-noise", @@ -2966,7 +2938,7 @@ dependencies = [ "futures", "hickory-proto", "if-watch", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-noise", "libp2p-swarm", @@ -2987,7 +2959,7 @@ name = "libp2p-memory-connection-limits" version = "0.2.0" dependencies = [ "async-std", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identify", "libp2p-identity", "libp2p-swarm", @@ -3006,7 +2978,7 @@ version = "0.14.1" dependencies = [ "futures", "instant", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-dcutr", "libp2p-gossipsub", "libp2p-identify", @@ -3028,7 +3000,7 @@ dependencies = [ "bytes", "criterion", "futures", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-muxer-test-harness", "libp2p-plaintext", @@ -3050,7 +3022,7 @@ dependencies = [ "futures", "futures-timer", "futures_ringbuf", - "libp2p-core 0.41.2", + "libp2p-core", "tracing", ] @@ -3063,7 +3035,7 @@ dependencies = [ "curve25519-dalek", "futures", "futures_ringbuf", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "multiaddr", "multihash", @@ -3092,14 +3064,14 @@ dependencies = [ "futures-timer", "instant", "libp2p", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-dns", "libp2p-identity", "libp2p-quic", "libp2p-swarm", "libp2p-swarm-test", "libp2p-tcp", - "libp2p-tls 0.4.0", + "libp2p-tls", "libp2p-yamux", "rand 0.8.5", "serde", @@ -3120,7 +3092,7 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-swarm", "libp2p-swarm-test", @@ -3139,7 +3111,7 @@ dependencies = [ "bytes", "futures", "futures_ringbuf", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "quick-protobuf", "quick-protobuf-codec", @@ -3154,7 +3126,7 @@ name = "libp2p-pnet" version = "0.24.0" dependencies = [ "futures", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-noise", "libp2p-swarm", @@ -3179,12 +3151,12 @@ dependencies = [ "futures", "futures-timer", "if-watch", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-muxer-test-harness", "libp2p-noise", "libp2p-tcp", - "libp2p-tls 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-tls", "libp2p-yamux", "parking_lot", "quickcheck", @@ -3209,7 +3181,7 @@ dependencies = [ "futures", "futures-bounded", "futures-timer", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-ping", "libp2p-plaintext", @@ -3238,7 +3210,7 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identify", "libp2p-identity", "libp2p-noise", @@ -3271,7 +3243,7 @@ dependencies = [ "futures-timer", "futures_ringbuf", "instant", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-noise", "libp2p-swarm", @@ -3312,7 +3284,7 @@ name = "libp2p-stream" version = "0.1.0-alpha.1" dependencies = [ "futures", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-swarm", "libp2p-swarm-test", @@ -3334,7 +3306,7 @@ dependencies = [ "futures-timer", "getrandom 0.2.15", "instant", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identify", "libp2p-identity", "libp2p-kad", @@ -3344,7 +3316,7 @@ dependencies = [ "libp2p-swarm-test", "libp2p-yamux", "lru", - "multistream-select 0.13.0", + "multistream-select", "once_cell", "quickcheck-ext", "rand 0.8.5", @@ -3374,7 +3346,7 @@ dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-plaintext", "libp2p-swarm", @@ -3394,7 +3366,7 @@ dependencies = [ "futures-timer", "if-watch", "libc", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "socket2 0.5.7", "tokio", @@ -3410,7 +3382,7 @@ dependencies = [ "futures-rustls", "hex", "hex-literal", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-swarm", "libp2p-yamux", @@ -3424,32 +3396,13 @@ dependencies = [ "yasna", ] -[[package]] -name = "libp2p-tls" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "251b17aebdd29df7e8f80e4d94b782fae42e934c49086e1a81ba23b60a8314f2" -dependencies = [ - "futures", - "futures-rustls", - "libp2p-core 0.41.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identity", - "rcgen", - "ring 0.17.8", - "rustls 0.23.8", - "rustls-webpki 0.101.7", - "thiserror", - "x509-parser 0.16.0", - "yasna", -] - [[package]] name = "libp2p-uds" version = "0.40.0" dependencies = [ "async-std", "futures", - "libp2p-core 0.41.2", + "libp2p-core", "tempfile", "tokio", "tracing", @@ -3462,7 +3415,7 @@ dependencies = [ "futures", "futures-timer", "igd-next", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-swarm", "tokio", "tracing", @@ -3479,7 +3432,7 @@ dependencies = [ "futures-timer", "hex", "if-watch", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-noise", "libp2p-webrtc-utils", @@ -3507,7 +3460,7 @@ dependencies = [ "futures", "hex", "hex-literal", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-noise", "quick-protobuf", @@ -3529,7 +3482,7 @@ dependencies = [ "getrandom 0.2.15", "hex", "js-sys", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-webrtc-utils", "send_wrapper 0.6.0", @@ -3548,14 +3501,14 @@ dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-dns", "libp2p-identity", "libp2p-tcp", "parking_lot", "pin-project-lite", "rcgen", - "rw-stream-sink 0.4.0", + "rw-stream-sink", "soketto", "tracing", "url", @@ -3569,7 +3522,7 @@ dependencies = [ "bytes", "futures", "js-sys", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-noise", "libp2p-yamux", @@ -3587,7 +3540,7 @@ version = "0.3.0" dependencies = [ "futures", "js-sys", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-noise", "multiaddr", @@ -3608,7 +3561,7 @@ dependencies = [ "async-std", "either", "futures", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-muxer-test-harness", "thiserror", "tracing", @@ -3897,27 +3850,13 @@ dependencies = [ "pin-project", "quickcheck-ext", "rand 0.8.5", - "rw-stream-sink 0.4.0", + "rw-stream-sink", "smallvec", "tracing", "tracing-subscriber", "unsigned-varint 0.8.0", ] -[[package]] -name = "multistream-select" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" -dependencies = [ - "bytes", - "futures", - "log", - "pin-project", - "smallvec", - "unsigned-varint 0.7.2", -] - [[package]] name = "native-tls" version = "0.2.11" @@ -5281,17 +5220,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "rw-stream-sink" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" -dependencies = [ - "futures", - "pin-project", - "static_assertions", -] - [[package]] name = "ryu" version = "1.0.15" @@ -6909,7 +6837,7 @@ version = "0.1.0" dependencies = [ "futures", "getrandom 0.2.15", - "libp2p-core 0.41.2", + "libp2p-core", "libp2p-identity", "libp2p-noise", "libp2p-webtransport-websys", diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 42296d0c0a7..11eee04e199 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -15,7 +15,7 @@ futures = { workspace = true } futures-timer = "3.0.3" if-watch = "3.2.0" libp2p-core = { workspace = true } -libp2p-tls = "0.4.0" +libp2p-tls = { workspace = true } libp2p-identity = { workspace = true } parking_lot = "0.12.3" quinn = { version = "0.11.1", default-features = false, features = ["rustls", "futures-io"] } From f54423a221104cb1967f6a88e8d04fb10b15416b Mon Sep 17 00:00:00 2001 From: Darius Clark Date: Fri, 7 Jun 2024 21:36:24 -0400 Subject: [PATCH 149/246] deps: use `web-time` instead of `instant` See https://github.com/sebcrozet/instant/issues/52 Pull-Request: #5347. --- Cargo.lock | 52 +++++++++----------- Cargo.toml | 17 ++++--- core/CHANGELOG.md | 4 ++ core/Cargo.toml | 6 +-- core/src/peer_record.rs | 2 +- interop-tests/Cargo.toml | 4 +- interop-tests/src/arch.rs | 2 +- libp2p/CHANGELOG.md | 3 ++ libp2p/Cargo.toml | 3 +- misc/metrics/CHANGELOG.md | 4 ++ misc/metrics/Cargo.toml | 4 +- misc/metrics/src/swarm.rs | 2 +- muxers/yamux/Cargo.toml | 2 +- protocols/autonat/CHANGELOG.md | 4 ++ protocols/autonat/Cargo.toml | 4 +- protocols/autonat/src/behaviour.rs | 2 +- protocols/autonat/src/behaviour/as_client.rs | 2 +- protocols/autonat/src/behaviour/as_server.rs | 2 +- protocols/dcutr/CHANGELOG.md | 4 ++ protocols/dcutr/Cargo.toml | 6 +-- protocols/dcutr/src/protocol/outbound.rs | 2 +- protocols/gossipsub/CHANGELOG.md | 4 ++ protocols/gossipsub/Cargo.toml | 8 +-- protocols/gossipsub/src/backoff.rs | 2 +- protocols/gossipsub/src/behaviour.rs | 3 +- protocols/gossipsub/src/gossip_promises.rs | 2 +- protocols/gossipsub/src/handler.rs | 2 +- protocols/gossipsub/src/peer_score.rs | 2 +- protocols/gossipsub/src/time_cache.rs | 2 +- protocols/kad/CHANGELOG.md | 2 + protocols/kad/Cargo.toml | 4 +- protocols/kad/src/behaviour.rs | 2 +- protocols/kad/src/bootstrap.rs | 2 +- protocols/kad/src/jobs.rs | 2 +- protocols/kad/src/kbucket.rs | 3 +- protocols/kad/src/protocol.rs | 2 +- protocols/kad/src/query.rs | 2 +- protocols/kad/src/query/peers/closest.rs | 2 +- protocols/kad/src/record.rs | 2 +- protocols/perf/CHANGELOG.md | 4 ++ protocols/perf/Cargo.toml | 4 +- protocols/perf/src/bin/perf.rs | 2 +- protocols/perf/src/lib.rs | 2 +- protocols/perf/src/protocol.rs | 2 +- protocols/ping/CHANGELOG.md | 3 ++ protocols/ping/Cargo.toml | 4 +- protocols/ping/src/protocol.rs | 2 +- protocols/relay/CHANGELOG.md | 4 ++ protocols/relay/Cargo.toml | 4 +- protocols/rendezvous/CHANGELOG.md | 4 ++ protocols/rendezvous/Cargo.toml | 4 +- protocols/rendezvous/src/server.rs | 2 +- protocols/request-response/CHANGELOG.md | 2 + protocols/request-response/Cargo.toml | 2 +- swarm/CHANGELOG.md | 2 + swarm/Cargo.toml | 8 +-- swarm/src/connection.rs | 2 +- swarm/src/connection/pool.rs | 2 +- 58 files changed, 139 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13b29b0dc0b..8ad67903c93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2402,9 +2402,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", ] [[package]] @@ -2436,7 +2433,6 @@ dependencies = [ "either", "futures", "futures-timer", - "instant", "libp2p", "libp2p-mplex", "libp2p-noise", @@ -2458,6 +2454,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "wasm-logger", + "web-time", ] [[package]] @@ -2607,7 +2604,6 @@ dependencies = [ "futures", "futures-timer", "getrandom 0.2.15", - "instant", "libp2p-allow-block-list", "libp2p-autonat", "libp2p-connection-limits", @@ -2663,14 +2659,13 @@ dependencies = [ [[package]] name = "libp2p-autonat" -version = "0.12.0" +version = "0.12.1" dependencies = [ "async-std", "async-trait", "asynchronous-codec", "futures", "futures-timer", - "instant", "libp2p-core", "libp2p-identity", "libp2p-request-response", @@ -2681,6 +2676,7 @@ dependencies = [ "rand 0.8.5", "tracing", "tracing-subscriber", + "web-time", ] [[package]] @@ -2702,14 +2698,13 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.41.2" +version = "0.41.3" dependencies = [ "async-std", "either", "fnv", "futures", "futures-timer", - "instant", "libp2p-identity", "libp2p-mplex", "libp2p-noise", @@ -2729,11 +2724,12 @@ dependencies = [ "tracing", "unsigned-varint 0.8.0", "void", + "web-time", ] [[package]] name = "libp2p-dcutr" -version = "0.11.0" +version = "0.11.1" dependencies = [ "async-std", "asynchronous-codec", @@ -2742,7 +2738,6 @@ dependencies = [ "futures", "futures-bounded", "futures-timer", - "instant", "libp2p-core", "libp2p-dns", "libp2p-identify", @@ -2763,6 +2758,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", + "web-time", ] [[package]] @@ -2805,7 +2801,7 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" -version = "0.46.1" +version = "0.46.2" dependencies = [ "async-std", "asynchronous-codec", @@ -2819,7 +2815,6 @@ dependencies = [ "getrandom 0.2.15", "hex", "hex_fmt", - "instant", "libp2p-core", "libp2p-identity", "libp2p-noise", @@ -2838,6 +2833,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", + "web-time", ] [[package]] @@ -2906,7 +2902,6 @@ dependencies = [ "futures", "futures-bounded", "futures-timer", - "instant", "libp2p-core", "libp2p-identify", "libp2p-identity", @@ -2926,6 +2921,7 @@ dependencies = [ "tracing-subscriber", "uint", "void", + "web-time", ] [[package]] @@ -2974,10 +2970,9 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.14.1" +version = "0.14.2" dependencies = [ "futures", - "instant", "libp2p-core", "libp2p-dcutr", "libp2p-gossipsub", @@ -2989,6 +2984,7 @@ dependencies = [ "libp2p-swarm", "pin-project", "prometheus-client", + "web-time", ] [[package]] @@ -3055,14 +3051,13 @@ dependencies = [ [[package]] name = "libp2p-perf" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "clap", "futures", "futures-bounded", "futures-timer", - "instant", "libp2p", "libp2p-core", "libp2p-dns", @@ -3081,6 +3076,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", + "web-time", ] [[package]] @@ -3091,7 +3087,6 @@ dependencies = [ "either", "futures", "futures-timer", - "instant", "libp2p-core", "libp2p-identity", "libp2p-swarm", @@ -3101,6 +3096,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", + "web-time", ] [[package]] @@ -3173,7 +3169,7 @@ dependencies = [ [[package]] name = "libp2p-relay" -version = "0.17.2" +version = "0.17.3" dependencies = [ "asynchronous-codec", "bytes", @@ -3202,14 +3198,13 @@ dependencies = [ [[package]] name = "libp2p-rendezvous" -version = "0.14.0" +version = "0.14.1" dependencies = [ "async-trait", "asynchronous-codec", "bimap", "futures", "futures-timer", - "instant", "libp2p-core", "libp2p-identify", "libp2p-identity", @@ -3228,6 +3223,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", + "web-time", ] [[package]] @@ -3242,7 +3238,6 @@ dependencies = [ "futures-bounded", "futures-timer", "futures_ringbuf", - "instant", "libp2p-core", "libp2p-identity", "libp2p-noise", @@ -3257,6 +3252,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", + "web-time", ] [[package]] @@ -3305,7 +3301,6 @@ dependencies = [ "futures", "futures-timer", "getrandom 0.2.15", - "instant", "libp2p-core", "libp2p-identify", "libp2p-identity", @@ -3327,6 +3322,7 @@ dependencies = [ "trybuild", "void", "wasm-bindgen-futures", + "web-time", ] [[package]] @@ -3566,7 +3562,7 @@ dependencies = [ "thiserror", "tracing", "yamux 0.12.1", - "yamux 0.13.1", + "yamux 0.13.3", ] [[package]] @@ -7145,18 +7141,18 @@ dependencies = [ [[package]] name = "yamux" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1d0148b89300047e72994bee99ecdabd15a9166a7b70c8b8c37c314dcc9002" +checksum = "a31b5e376a8b012bee9c423acdbb835fc34d45001cfa3106236a624e4b738028" dependencies = [ "futures", - "instant", "log", "nohash-hasher", "parking_lot", "pin-project", "rand 0.8.5", "static_assertions", + "web-time", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6c6dc114983..995951a01d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,29 +76,29 @@ futures-bounded = { version = "0.2.3" } futures-rustls = { version = "0.26.0", default-features = false } libp2p = { version = "0.54.0", path = "libp2p" } libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" } -libp2p-autonat = { version = "0.12.0", path = "protocols/autonat" } +libp2p-autonat = { version = "0.12.1", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.3.1", path = "misc/connection-limits" } -libp2p-core = { version = "0.41.2", path = "core" } -libp2p-dcutr = { version = "0.11.0", path = "protocols/dcutr" } +libp2p-core = { version = "0.41.3", path = "core" } +libp2p-dcutr = { version = "0.11.1", path = "protocols/dcutr" } libp2p-dns = { version = "0.41.1", path = "transports/dns" } libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" } -libp2p-gossipsub = { version = "0.46.1", path = "protocols/gossipsub" } +libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" } libp2p-identify = { version = "0.44.2", path = "protocols/identify" } libp2p-identity = { version = "0.2.8" } libp2p-kad = { version = "0.46.0", path = "protocols/kad" } libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" } -libp2p-metrics = { version = "0.14.1", path = "misc/metrics" } +libp2p-metrics = { version = "0.14.2", path = "misc/metrics" } libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" } libp2p-muxer-test-harness = { path = "muxers/test-harness" } libp2p-noise = { version = "0.44.0", path = "transports/noise" } -libp2p-perf = { version = "0.3.0", path = "protocols/perf" } +libp2p-perf = { version = "0.3.1", path = "protocols/perf" } libp2p-ping = { version = "0.44.1", path = "protocols/ping" } libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } libp2p-quic = { version = "0.10.3", path = "transports/quic" } -libp2p-relay = { version = "0.17.2", path = "protocols/relay" } -libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" } +libp2p-relay = { version = "0.17.3", path = "protocols/relay" } +libp2p-rendezvous = { version = "0.14.1", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.26.3", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } @@ -128,6 +128,7 @@ tokio = { version = "1.38", default-features = false } tracing = "0.1.37" tracing-subscriber = "0.3" futures = "0.3.30" +web-time = "1.1.0" ring = "0.17.8" rcgen = "0.11.3" diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 73f377a8aa5..633b627d41d 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.41.3 +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.41.2 - Implement `std::fmt::Display` on `ListenerId`. diff --git a/core/Cargo.toml b/core/Cargo.toml index 5b3fbe32d0b..6831eb54c94 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-core" edition = "2021" rust-version = { workspace = true } description = "Core traits and structs of libp2p" -version = "0.41.2" +version = "0.41.3" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -11,11 +11,11 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -either = "1.12" +either = "1.11" fnv = "1.0" futures = { workspace = true, features = ["executor", "thread-pool"] } futures-timer = "3" -instant = "0.1.13" +web-time = { workspace = true } libp2p-identity = { workspace = true, features = ["peerid", "ed25519"] } multiaddr = { workspace = true } multihash = { workspace = true } diff --git a/core/src/peer_record.rs b/core/src/peer_record.rs index d5fc86c391e..ac488338cc6 100644 --- a/core/src/peer_record.rs +++ b/core/src/peer_record.rs @@ -1,10 +1,10 @@ use crate::signed_envelope::SignedEnvelope; use crate::{proto, signed_envelope, DecodeError, Multiaddr}; -use instant::SystemTime; use libp2p_identity::Keypair; use libp2p_identity::PeerId; use libp2p_identity::SigningError; use quick_protobuf::{BytesReader, Writer}; +use web_time::SystemTime; const PAYLOAD_TYPE: &str = "/libp2p/routing-state-record"; const DOMAIN_SEP: &str = "libp2p-routing-state"; diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 3a9fea3c0df..5dbdafa34b1 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] anyhow = "1" -either = "1.12.0" +either = "1.11.0" futures = { workspace = true } rand = "0.8.5" serde = { version = "1", features = ["derive"] } @@ -46,7 +46,7 @@ libp2p-webrtc-websys = { workspace = true } wasm-bindgen = { version = "0.2" } wasm-bindgen-futures = { version = "0.4" } wasm-logger = { version = "0.2.0" } -instant = "0.1.13" +web-time = { workspace = true } reqwest = { version = "0.12", features = ["json"] } console_error_panic_hook = { version = "0.1.7" } futures-timer = "3.0.3" diff --git a/interop-tests/src/arch.rs b/interop-tests/src/arch.rs index 52000f90a86..06d630d68d5 100644 --- a/interop-tests/src/arch.rs +++ b/interop-tests/src/arch.rs @@ -199,7 +199,7 @@ pub(crate) mod wasm { use crate::{BlpopRequest, Muxer, SecProtocol, Transport}; - pub(crate) type Instant = instant::Instant; + pub(crate) type Instant = web_time::Instant; pub(crate) fn init_logger() { console_error_panic_hook::set_once(); diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index 7acd4ab602d..8b1a332769f 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -6,6 +6,9 @@ - Raise MSRV to 1.73. See [PR 5266](https://github.com/libp2p/rust-libp2p/pull/5266). +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.53.2 - Allow `SwarmBuilder::with_bandwidth_metrics` after `SwarmBuilder::with_websocket`. diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index 4304f4e557a..59a075b777e 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -82,7 +82,7 @@ tcp = ["dep:libp2p-tcp"] tls = ["dep:libp2p-tls"] tokio = [ "libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-upnp?/tokio"] uds = ["dep:libp2p-uds"] -wasm-bindgen = [ "futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen",] +wasm-bindgen = [ "futures-timer/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"] websocket-websys = ["dep:libp2p-websocket-websys"] websocket = ["dep:libp2p-websocket"] webtransport-websys = ["dep:libp2p-webtransport-websys"] @@ -95,7 +95,6 @@ either = "1.9.0" futures = { workspace = true } futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` feature getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature -instant = "0.1.12" # Explicit dependency to be used in `wasm-bindgen` feature # TODO feature flag? rw-stream-sink = { workspace = true } diff --git a/misc/metrics/CHANGELOG.md b/misc/metrics/CHANGELOG.md index 67c304680db..c36d7f95ebc 100644 --- a/misc/metrics/CHANGELOG.md +++ b/misc/metrics/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.14.2 +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.14.1 - Add `BandwidthTransport`, wrapping an existing `Transport`, exposing Prometheus bandwidth metrics. diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index 51da56db29f..5fb927bee84 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-metrics" edition = "2021" rust-version = { workspace = true } description = "Metrics for libp2p" -version = "0.14.1" +version = "0.14.2" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -20,7 +20,7 @@ relay = ["libp2p-relay"] [dependencies] futures = { workspace = true } -instant = "0.1.13" +web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-dcutr = { workspace = true, optional = true } libp2p-gossipsub = { workspace = true, optional = true } diff --git a/misc/metrics/src/swarm.rs b/misc/metrics/src/swarm.rs index ad83401f316..51c0a0af253 100644 --- a/misc/metrics/src/swarm.rs +++ b/misc/metrics/src/swarm.rs @@ -22,13 +22,13 @@ use std::collections::HashMap; use std::sync::{Arc, Mutex}; use crate::protocol_stack; -use instant::Instant; use libp2p_swarm::{ConnectionId, DialError, SwarmEvent}; use prometheus_client::encoding::{EncodeLabelSet, EncodeLabelValue}; use prometheus_client::metrics::counter::Counter; use prometheus_client::metrics::family::Family; use prometheus_client::metrics::histogram::{exponential_buckets, Histogram}; use prometheus_client::registry::{Registry, Unit}; +use web_time::Instant; pub(crate) struct Metrics { connections_incoming: Family, diff --git a/muxers/yamux/Cargo.toml b/muxers/yamux/Cargo.toml index ddb9424895b..4d6d655e330 100644 --- a/muxers/yamux/Cargo.toml +++ b/muxers/yamux/Cargo.toml @@ -16,7 +16,7 @@ futures = { workspace = true } libp2p-core = { workspace = true } thiserror = "1.0" yamux012 = { version = "0.12.1", package = "yamux" } -yamux013 = { version = "0.13.1", package = "yamux" } +yamux013 = { version = "0.13.3", package = "yamux" } tracing = { workspace = true } [dev-dependencies] diff --git a/protocols/autonat/CHANGELOG.md b/protocols/autonat/CHANGELOG.md index 1259dd01fd4..6a25dc173dd 100644 --- a/protocols/autonat/CHANGELOG.md +++ b/protocols/autonat/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.12.1 +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.12.0 - Remove `Clone`, `PartialEq` and `Eq` implementations on `Event` and its sub-structs. diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index ba7a21b4da7..970dd27bc53 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -4,7 +4,7 @@ edition = "2021" rust-version = { workspace = true } description = "NAT and firewall detection for libp2p" authors = ["David Craven ", "Elena Frank "] -version = "0.12.0" +version = "0.12.1" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] async-trait = "0.1" futures = { workspace = true } futures-timer = "3.0" -instant = "0.1" +web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-request-response = { workspace = true } diff --git a/protocols/autonat/src/behaviour.rs b/protocols/autonat/src/behaviour.rs index a770e61e88a..a47852e5206 100644 --- a/protocols/autonat/src/behaviour.rs +++ b/protocols/autonat/src/behaviour.rs @@ -28,7 +28,6 @@ pub use as_client::{OutboundProbeError, OutboundProbeEvent}; use as_server::AsServer; pub use as_server::{InboundProbeError, InboundProbeEvent}; use futures_timer::Delay; -use instant::Instant; use libp2p_core::{multiaddr::Protocol, ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_request_response::{ @@ -45,6 +44,7 @@ use std::{ task::{Context, Poll}, time::Duration, }; +use web_time::Instant; /// Config for the [`Behaviour`]. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/protocols/autonat/src/behaviour/as_client.rs b/protocols/autonat/src/behaviour/as_client.rs index 668f3b93719..8960163ccb3 100644 --- a/protocols/autonat/src/behaviour/as_client.rs +++ b/protocols/autonat/src/behaviour/as_client.rs @@ -26,7 +26,6 @@ use super::{ }; use futures::FutureExt; use futures_timer::Delay; -use instant::Instant; use libp2p_core::Multiaddr; use libp2p_identity::PeerId; use libp2p_request_response::{self as request_response, OutboundFailure, OutboundRequestId}; @@ -37,6 +36,7 @@ use std::{ task::{Context, Poll}, time::Duration, }; +use web_time::Instant; /// Outbound probe failed or was aborted. #[derive(Debug)] diff --git a/protocols/autonat/src/behaviour/as_server.rs b/protocols/autonat/src/behaviour/as_server.rs index 878fd713dda..af6be799e21 100644 --- a/protocols/autonat/src/behaviour/as_server.rs +++ b/protocols/autonat/src/behaviour/as_server.rs @@ -22,7 +22,6 @@ use super::{ Action, AutoNatCodec, Config, DialRequest, DialResponse, Event, HandleInnerEvent, ProbeId, ResponseError, }; -use instant::Instant; use libp2p_core::{multiaddr::Protocol, Multiaddr}; use libp2p_identity::PeerId; use libp2p_request_response::{ @@ -36,6 +35,7 @@ use std::{ collections::{HashMap, HashSet, VecDeque}, num::NonZeroU8, }; +use web_time::Instant; /// Inbound probe failed. #[derive(Debug)] diff --git a/protocols/dcutr/CHANGELOG.md b/protocols/dcutr/CHANGELOG.md index d3857373658..4865a0540bb 100644 --- a/protocols/dcutr/CHANGELOG.md +++ b/protocols/dcutr/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.1 +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.11.0 - Add `ConnectionId` to `Event::DirectConnectionUpgradeSucceeded` and `Event::DirectConnectionUpgradeFailed`. diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 819c7a6e56b..daf4846a2ae 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-dcutr" edition = "2021" rust-version = { workspace = true } description = "Direct connection upgrade through relay" -version = "0.11.0" +version = "0.11.1" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -12,10 +12,10 @@ categories = ["network-programming", "asynchronous"] [dependencies] asynchronous-codec = { workspace = true } -either = "1.12.0" +either = "1.11.0" futures = { workspace = true } futures-timer = "3.0" -instant = "0.1.13" +web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/protocols/dcutr/src/protocol/outbound.rs b/protocols/dcutr/src/protocol/outbound.rs index dc46442fae5..8639ff4f053 100644 --- a/protocols/dcutr/src/protocol/outbound.rs +++ b/protocols/dcutr/src/protocol/outbound.rs @@ -23,11 +23,11 @@ use crate::PROTOCOL_NAME; use asynchronous_codec::Framed; use futures::prelude::*; use futures_timer::Delay; -use instant::Instant; use libp2p_core::{multiaddr::Protocol, Multiaddr}; use libp2p_swarm::Stream; use std::io; use thiserror::Error; +use web_time::Instant; pub(crate) async fn handshake( stream: Stream, diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index 5ff4cfa27d6..970db3f1ec3 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.46.2 +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.46.1 - Deprecate `Rpc` in preparation for removing it from the public API because it is an internal type. diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index aa11a8a8309..35bc3eef9bd 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-gossipsub" edition = "2021" rust-version = { workspace = true } description = "Gossipsub protocol for libp2p" -version = "0.46.1" +version = "0.46.2" authors = ["Age Manning "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -11,20 +11,20 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [features] -wasm-bindgen = ["getrandom/js", "instant/wasm-bindgen"] +wasm-bindgen = ["getrandom/js"] [dependencies] asynchronous-codec = { workspace = true } base64 = "0.22.1" byteorder = "1.5.0" bytes = "1.6" -either = "1.12" +either = "1.11" fnv = "1.0.7" futures = { workspace = true } futures-ticker = "0.0.3" getrandom = "0.2.15" hex_fmt = "0.3.0" -instant = "0.1.13" +web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-swarm = { workspace = true } diff --git a/protocols/gossipsub/src/backoff.rs b/protocols/gossipsub/src/backoff.rs index b4a40b91a74..b24da318582 100644 --- a/protocols/gossipsub/src/backoff.rs +++ b/protocols/gossipsub/src/backoff.rs @@ -20,13 +20,13 @@ //! Data structure for efficiently storing known back-off's when pruning peers. use crate::topic::TopicHash; -use instant::Instant; use libp2p_identity::PeerId; use std::collections::{ hash_map::{Entry, HashMap}, HashSet, }; use std::time::Duration; +use web_time::Instant; #[derive(Copy, Clone)] struct HeartbeatIndex(usize); diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index 6da2aceaa08..b508959317b 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -34,7 +34,6 @@ use futures_ticker::Ticker; use prometheus_client::registry::Registry; use rand::{seq::SliceRandom, thread_rng}; -use instant::Instant; use libp2p_core::{multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, Endpoint, Multiaddr}; use libp2p_identity::Keypair; use libp2p_identity::PeerId; @@ -44,6 +43,7 @@ use libp2p_swarm::{ ConnectionDenied, ConnectionId, NetworkBehaviour, NotifyHandler, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }; +use web_time::{Instant, SystemTime}; use crate::backoff::BackoffStorage; use crate::config::{Config, ValidationMode}; @@ -64,7 +64,6 @@ use crate::types::{ use crate::types::{PeerConnections, PeerKind, RpcOut}; use crate::{rpc_proto::proto, TopicScoreParams}; use crate::{PublishError, SubscriptionError, ValidationError}; -use instant::SystemTime; use quick_protobuf::{MessageWrite, Writer}; use std::{cmp::Ordering::Equal, fmt::Debug}; diff --git a/protocols/gossipsub/src/gossip_promises.rs b/protocols/gossipsub/src/gossip_promises.rs index 9538622c0dc..bdf58b74fc2 100644 --- a/protocols/gossipsub/src/gossip_promises.rs +++ b/protocols/gossipsub/src/gossip_promises.rs @@ -21,9 +21,9 @@ use crate::peer_score::RejectReason; use crate::MessageId; use crate::ValidationError; -use instant::Instant; use libp2p_identity::PeerId; use std::collections::HashMap; +use web_time::Instant; /// Tracks recently sent `IWANT` messages and checks if peers respond to them. #[derive(Default)] diff --git a/protocols/gossipsub/src/handler.rs b/protocols/gossipsub/src/handler.rs index e91f81776e7..88def13a521 100644 --- a/protocols/gossipsub/src/handler.rs +++ b/protocols/gossipsub/src/handler.rs @@ -26,7 +26,6 @@ use asynchronous_codec::Framed; use futures::future::Either; use futures::prelude::*; use futures::StreamExt; -use instant::Instant; use libp2p_core::upgrade::DeniedUpgrade; use libp2p_swarm::handler::{ ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, DialUpgradeError, @@ -38,6 +37,7 @@ use std::{ pin::Pin, task::{Context, Poll}, }; +use web_time::Instant; /// The event emitted by the Handler. This informs the behaviour of various events created /// by the handler. diff --git a/protocols/gossipsub/src/peer_score.rs b/protocols/gossipsub/src/peer_score.rs index 386cc85bd3c..ac24fc91970 100644 --- a/protocols/gossipsub/src/peer_score.rs +++ b/protocols/gossipsub/src/peer_score.rs @@ -24,11 +24,11 @@ use crate::metrics::{Metrics, Penalty}; use crate::time_cache::TimeCache; use crate::{MessageId, TopicHash}; -use instant::Instant; use libp2p_identity::PeerId; use std::collections::{hash_map, HashMap, HashSet}; use std::net::IpAddr; use std::time::Duration; +use web_time::Instant; mod params; use crate::ValidationError; diff --git a/protocols/gossipsub/src/time_cache.rs b/protocols/gossipsub/src/time_cache.rs index 89fd4afee09..a3e5c01ac4c 100644 --- a/protocols/gossipsub/src/time_cache.rs +++ b/protocols/gossipsub/src/time_cache.rs @@ -21,13 +21,13 @@ //! This implements a time-based LRU cache for checking gossipsub message duplicates. use fnv::FnvHashMap; -use instant::Instant; use std::collections::hash_map::{ self, Entry::{Occupied, Vacant}, }; use std::collections::VecDeque; use std::time::Duration; +use web_time::Instant; struct ExpiringElement { /// The element that expires diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index bd0c9857cb5..57ac92d2f6f 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -17,6 +17,8 @@ See [PR 5148](https://github.com/libp2p/rust-libp2p/pull/5148). - Derive `Copy` for `kbucket::key::Key`. See [PR 5317](https://github.com/libp2p/rust-libp2p/pull/5317). +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). ## 0.45.3 diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 7d3e3caa047..494d812c6ec 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] arrayvec = "0.7.4" bytes = "1" -either = "1.12" +either = "1.11" fnv = "1.0" asynchronous-codec = { workspace = true } futures = { workspace = true } @@ -29,7 +29,7 @@ smallvec = "1.13.2" uint = "0.9" void = "1.0" futures-timer = "3.0.3" -instant = "0.1.13" +web-time = { workspace = true } serde = { version = "1.0", optional = true, features = ["derive"] } thiserror = "1" tracing = { workspace = true } diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index fb77f3c0e0f..302433a8d70 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -36,7 +36,6 @@ use crate::record::{ use crate::K_VALUE; use crate::{jobs::*, protocol}; use fnv::{FnvHashMap, FnvHashSet}; -use instant::Instant; use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::{ @@ -57,6 +56,7 @@ use std::time::Duration; use std::vec; use thiserror::Error; use tracing::Level; +use web_time::Instant; pub use crate::query::QueryStats; diff --git a/protocols/kad/src/bootstrap.rs b/protocols/kad/src/bootstrap.rs index 58fa662d414..bcb9d0cccf3 100644 --- a/protocols/kad/src/bootstrap.rs +++ b/protocols/kad/src/bootstrap.rs @@ -171,7 +171,7 @@ impl futures::Future for ThrottleTimer { #[cfg(test)] mod tests { use super::*; - use instant::Instant; + use web_time::Instant; const MS_5: Duration = Duration::from_millis(5); const MS_100: Duration = Duration::from_millis(100); diff --git a/protocols/kad/src/jobs.rs b/protocols/kad/src/jobs.rs index f1631ed6ad1..537f652b7a4 100644 --- a/protocols/kad/src/jobs.rs +++ b/protocols/kad/src/jobs.rs @@ -64,13 +64,13 @@ use crate::record::{self, store::RecordStore, ProviderRecord, Record}; use futures::prelude::*; use futures_timer::Delay; -use instant::Instant; use libp2p_identity::PeerId; use std::collections::HashSet; use std::pin::Pin; use std::task::{Context, Poll}; use std::time::Duration; use std::vec; +use web_time::Instant; /// The maximum number of queries towards which background jobs /// are allowed to start new queries on an invocation of diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index 6eb2e42909a..7ed10f7f853 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -78,7 +78,8 @@ pub use entry::*; use arrayvec::ArrayVec; use bucket::KBucket; use std::collections::VecDeque; -use std::time::{Duration, Instant}; +use std::time::Duration; +use web_time::Instant; /// Maximum number of k-buckets. const NUM_BUCKETS: usize = 256; diff --git a/protocols/kad/src/protocol.rs b/protocols/kad/src/protocol.rs index 9803af00579..9d2ef56f5d8 100644 --- a/protocols/kad/src/protocol.rs +++ b/protocols/kad/src/protocol.rs @@ -31,7 +31,6 @@ use crate::record::{self, Record}; use asynchronous_codec::{Decoder, Encoder, Framed}; use bytes::BytesMut; use futures::prelude::*; -use instant::Instant; use libp2p_core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use libp2p_core::Multiaddr; use libp2p_identity::PeerId; @@ -40,6 +39,7 @@ use std::marker::PhantomData; use std::time::Duration; use std::{io, iter}; use tracing::debug; +use web_time::Instant; /// The protocol name used for negotiating with multistream-select. pub(crate) const DEFAULT_PROTO_NAME: StreamProtocol = StreamProtocol::new("/ipfs/kad/1.0.0"); diff --git a/protocols/kad/src/query.rs b/protocols/kad/src/query.rs index bb240d5864a..cf102040a7a 100644 --- a/protocols/kad/src/query.rs +++ b/protocols/kad/src/query.rs @@ -30,9 +30,9 @@ use crate::kbucket::{Key, KeyBytes}; use crate::{ALPHA_VALUE, K_VALUE}; use either::Either; use fnv::FnvHashMap; -use instant::Instant; use libp2p_identity::PeerId; use std::{num::NonZeroUsize, time::Duration}; +use web_time::Instant; /// A `QueryPool` provides an aggregate state machine for driving `Query`s to completion. /// diff --git a/protocols/kad/src/query/peers/closest.rs b/protocols/kad/src/query/peers/closest.rs index a0b5a96708a..2505ee2e9b2 100644 --- a/protocols/kad/src/query/peers/closest.rs +++ b/protocols/kad/src/query/peers/closest.rs @@ -22,9 +22,9 @@ use super::*; use crate::kbucket::{Distance, Key, KeyBytes}; use crate::{ALPHA_VALUE, K_VALUE}; -use instant::Instant; use std::collections::btree_map::{BTreeMap, Entry}; use std::{num::NonZeroUsize, time::Duration}; +use web_time::Instant; pub(crate) mod disjoint; /// A peer iterator for a dynamically changing list of peers, sorted by increasing diff --git a/protocols/kad/src/record.rs b/protocols/kad/src/record.rs index 4eb8e861c6f..cb7c4b866fc 100644 --- a/protocols/kad/src/record.rs +++ b/protocols/kad/src/record.rs @@ -23,13 +23,13 @@ pub mod store; use bytes::Bytes; -use instant::Instant; use libp2p_core::{multihash::Multihash, Multiaddr}; use libp2p_identity::PeerId; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use std::borrow::Borrow; use std::hash::{Hash, Hasher}; +use web_time::Instant; /// The (opaque) key of a record. #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] diff --git a/protocols/perf/CHANGELOG.md b/protocols/perf/CHANGELOG.md index 4e448d7f44a..d83e8b48472 100644 --- a/protocols/perf/CHANGELOG.md +++ b/protocols/perf/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.1 +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.3.0 - Continuously measure on single connection (iperf-style). diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 6ed6baa0714..0d379f77353 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-perf" edition = "2021" rust-version = { workspace = true } description = "libp2p perf protocol implementation" -version = "0.3.0" +version = "0.3.1" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -16,7 +16,7 @@ clap = { version = "4.5.4", features = ["derive"] } futures = { workspace = true } futures-bounded = { workspace = true } futures-timer = "3.0" -instant = "0.1.13" +web-time = { workspace = true } libp2p = { workspace = true, features = ["tokio", "tcp", "quic", "tls", "yamux", "dns"] } libp2p-core = { workspace = true } libp2p-dns = { workspace = true, features = ["tokio"] } diff --git a/protocols/perf/src/bin/perf.rs b/protocols/perf/src/bin/perf.rs index 9ac8f0a6cde..9a4cfb8bcac 100644 --- a/protocols/perf/src/bin/perf.rs +++ b/protocols/perf/src/bin/perf.rs @@ -23,7 +23,6 @@ use std::{net::SocketAddr, str::FromStr}; use anyhow::{bail, Result}; use clap::Parser; use futures::StreamExt; -use instant::{Duration, Instant}; use libp2p::core::{multiaddr::Protocol, upgrade, Multiaddr}; use libp2p::identity::PeerId; use libp2p::swarm::{NetworkBehaviour, Swarm, SwarmEvent}; @@ -32,6 +31,7 @@ use libp2p_perf::{client, server}; use libp2p_perf::{Final, Intermediate, Run, RunParams, RunUpdate}; use serde::{Deserialize, Serialize}; use tracing_subscriber::EnvFilter; +use web_time::{Duration, Instant}; #[derive(Debug, Parser)] #[clap(name = "libp2p perf client")] diff --git a/protocols/perf/src/lib.rs b/protocols/perf/src/lib.rs index f9db96aa9d9..be950ac87a2 100644 --- a/protocols/perf/src/lib.rs +++ b/protocols/perf/src/lib.rs @@ -26,8 +26,8 @@ use std::fmt::Display; -use instant::Duration; use libp2p_swarm::StreamProtocol; +use web_time::Duration; pub mod client; mod protocol; diff --git a/protocols/perf/src/protocol.rs b/protocols/perf/src/protocol.rs index d2d65b42303..f995bbe2d3b 100644 --- a/protocols/perf/src/protocol.rs +++ b/protocols/perf/src/protocol.rs @@ -19,8 +19,8 @@ // DEALINGS IN THE SOFTWARE. use futures_timer::Delay; -use instant::Instant; use std::time::Duration; +use web_time::Instant; use futures::{ future::{select, Either}, diff --git a/protocols/ping/CHANGELOG.md b/protocols/ping/CHANGELOG.md index 17338a4ba9a..65d45a69f23 100644 --- a/protocols/ping/CHANGELOG.md +++ b/protocols/ping/CHANGELOG.md @@ -4,6 +4,9 @@ `ping::Event` can now be shared between threads. See [PR 5250] +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + [PR 5250]: https://github.com/libp2p/rust-libp2p/pull/5250 ## 0.44.0 diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index c436478668c..99597fd5fe8 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -11,10 +11,10 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -either = "1.12.0" +either = "1.11.0" futures = { workspace = true } futures-timer = "3.0.3" -instant = "0.1.13" +web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/protocols/ping/src/protocol.rs b/protocols/ping/src/protocol.rs index fe84cb4ea59..9b4d7da98db 100644 --- a/protocols/ping/src/protocol.rs +++ b/protocols/ping/src/protocol.rs @@ -19,10 +19,10 @@ // DEALINGS IN THE SOFTWARE. use futures::prelude::*; -use instant::Instant; use libp2p_swarm::StreamProtocol; use rand::{distributions, prelude::*}; use std::{io, time::Duration}; +use web_time::Instant; pub const PROTOCOL_NAME: StreamProtocol = StreamProtocol::new("/ipfs/ping/1.0.0"); diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index 83dbf4739ac..125f51e4961 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.17.3 +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.17.2 - Fix support for unlimited relay connection according to spec. diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index aa185a42af0..4981c94d9c8 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-relay" edition = "2021" rust-version = { workspace = true } description = "Communications relaying for libp2p" -version = "0.17.2" +version = "0.17.3" authors = ["Parity Technologies ", "Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -17,6 +17,7 @@ either = "1.12.0" futures = { workspace = true } futures-timer = "3" futures-bounded = { workspace = true } +web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } @@ -27,7 +28,6 @@ static_assertions = "1" thiserror = "1.0" tracing = { workspace = true } void = "1" -web-time = "1" [dev-dependencies] libp2p-identity = { workspace = true, features = ["rand"] } diff --git a/protocols/rendezvous/CHANGELOG.md b/protocols/rendezvous/CHANGELOG.md index e60699da734..4aa18985f1e 100644 --- a/protocols/rendezvous/CHANGELOG.md +++ b/protocols/rendezvous/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.14.1 +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.14.0 diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index 2d344e5e250..6879a4093ce 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-rendezvous" edition = "2021" rust-version = { workspace = true } description = "Rendezvous protocol for libp2p" -version = "0.14.0" +version = "0.14.1" authors = ["The COMIT guys "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -16,7 +16,7 @@ async-trait = "0.1" bimap = "0.6.3" futures = { workspace = true, features = ["std"] } futures-timer = "3.0.3" -instant = "0.1.13" +web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/protocols/rendezvous/src/server.rs b/protocols/rendezvous/src/server.rs index a6e523302d7..bee91f28e88 100644 --- a/protocols/rendezvous/src/server.rs +++ b/protocols/rendezvous/src/server.rs @@ -527,7 +527,7 @@ pub struct CookieNamespaceMismatch; #[cfg(test)] mod tests { - use instant::SystemTime; + use web_time::SystemTime; use libp2p_core::PeerRecord; use libp2p_identity as identity; diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index e9d92b08857..a181adc8c52 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -10,6 +10,8 @@ - Deprecate `Behaviour::add_address` in favor of `Swarm::add_peer_address`. See [PR 4371](https://github.com/libp2p/rust-libp2p/pull/4371). +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). ## 0.26.1 diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 794a3e74956..900efd70d8b 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -14,7 +14,7 @@ categories = ["network-programming", "asynchronous"] async-trait = "0.1" cbor4ii = { version = "0.3.2", features = ["serde1", "use_std"], optional = true } futures = { workspace = true } -instant = "0.1.13" +web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 75e18a6a5af..b669bb0091a 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -5,6 +5,8 @@ The address is broadcast to all behaviours via `FromSwarm::NewExternalAddrOfPeer`. Protocols that want to collect these addresses can use the new `PeerAddresses` utility. See [PR 4371](https://github.com/libp2p/rust-libp2p/pull/4371). +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). ## 0.44.1 diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 17a66abba0a..714e8a8f349 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -11,12 +11,12 @@ keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] [dependencies] -either = "1.12.0" +either = "1.11.0" fnv = "1.0" futures = { workspace = true } futures-timer = "3.0.3" getrandom = { version = "0.2.15", features = ["js"], optional = true } # Explicit dependency to be used in `wasm-bindgen` feature -instant = "0.1.13" +web-time = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } libp2p-swarm-derive = { workspace = true, optional = true } @@ -41,7 +41,7 @@ wasm-bindgen = ["dep:wasm-bindgen-futures", "dep:getrandom"] [dev-dependencies] async-std = { version = "1.6.2", features = ["attributes"] } -either = "1.12.0" +either = "1.11.0" futures = { workspace = true } libp2p-identify = { path = "../protocols/identify" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. libp2p-identity = { workspace = true, features = ["ed25519"] } @@ -54,7 +54,7 @@ libp2p-yamux = { path = "../muxers/yamux" } # Using `pat quickcheck = { workspace = true } void = "1" once_cell = "1.19.0" -trybuild = "1.0.96" +trybuild = "1.0.95" tokio = { workspace = true, features = ["time", "rt", "macros", "rt-multi-thread"] } tracing-subscriber = { workspace = true, features = ["env-filter"] } diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index c701f1773e6..69f95bca1d3 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -44,7 +44,6 @@ use futures::stream::FuturesUnordered; use futures::StreamExt; use futures::{stream, FutureExt}; use futures_timer::Delay; -use instant::Instant; use libp2p_core::connection::ConnectedPoint; use libp2p_core::multiaddr::Multiaddr; use libp2p_core::muxing::{StreamMuxerBox, StreamMuxerEvent, StreamMuxerExt, SubstreamBox}; @@ -59,6 +58,7 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::task::Waker; use std::time::Duration; use std::{fmt, io, mem, pin::Pin, task::Context, task::Poll}; +use web_time::Instant; static NEXT_CONNECTION_ID: AtomicUsize = AtomicUsize::new(1); diff --git a/swarm/src/connection/pool.rs b/swarm/src/connection/pool.rs index f876c39f12c..236f76e2fcc 100644 --- a/swarm/src/connection/pool.rs +++ b/swarm/src/connection/pool.rs @@ -37,7 +37,6 @@ use futures::{ ready, stream::FuturesUnordered, }; -use instant::{Duration, Instant}; use libp2p_core::connection::Endpoint; use libp2p_core::muxing::{StreamMuxerBox, StreamMuxerExt}; use std::task::Waker; @@ -51,6 +50,7 @@ use std::{ }; use tracing::Instrument; use void::Void; +use web_time::{Duration, Instant}; mod concurrent_dial; mod task; From 3b61e57d0e72d371ccdfc134bd71cb3aa20addee Mon Sep 17 00:00:00 2001 From: EB Date: Sat, 8 Jun 2024 19:35:18 +0900 Subject: [PATCH 150/246] chore: remove one `std::` chore: remove one `std::` Pull-Request: #5450. --- core/src/transport.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/transport.rs b/core/src/transport.rs index db8c083bd0a..2246f3db747 100644 --- a/core/src/transport.rs +++ b/core/src/transport.rs @@ -256,7 +256,7 @@ impl ListenerId { } } -impl std::fmt::Display for ListenerId { +impl fmt::Display for ListenerId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.0) } From 927428fb0cbd27e3da8871df09af0650156719b2 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Sun, 9 Jun 2024 03:36:51 +0300 Subject: [PATCH 151/246] chore: Fixes versions and changelogs Pull-Request: #5455. --- Cargo.lock | 10 +++++----- Cargo.toml | 10 +++++----- libp2p/CHANGELOG.md | 2 +- muxers/yamux/CHANGELOG.md | 4 ++++ muxers/yamux/Cargo.toml | 2 +- protocols/kad/CHANGELOG.md | 2 +- protocols/ping/CHANGELOG.md | 9 ++++++--- protocols/ping/Cargo.toml | 2 +- protocols/request-response/CHANGELOG.md | 7 +++++-- protocols/request-response/Cargo.toml | 2 +- swarm/CHANGELOG.md | 7 +++++-- swarm/Cargo.toml | 2 +- transports/websocket/CHANGELOG.md | 2 ++ transports/websocket/Cargo.toml | 2 +- 14 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ad67903c93..7366606fe15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3081,7 +3081,7 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.44.1" +version = "0.44.2" dependencies = [ "async-std", "either", @@ -3228,7 +3228,7 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.26.3" +version = "0.26.4" dependencies = [ "anyhow", "async-std", @@ -3293,7 +3293,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.44.2" +version = "0.44.3" dependencies = [ "async-std", "either", @@ -3491,7 +3491,7 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.43.0" +version = "0.43.1" dependencies = [ "async-std", "either", @@ -3552,7 +3552,7 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.45.1" +version = "0.45.2" dependencies = [ "async-std", "either", diff --git a/Cargo.toml b/Cargo.toml index 995951a01d6..00628ca23b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -93,16 +93,16 @@ libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" } libp2p-muxer-test-harness = { path = "muxers/test-harness" } libp2p-noise = { version = "0.44.0", path = "transports/noise" } libp2p-perf = { version = "0.3.1", path = "protocols/perf" } -libp2p-ping = { version = "0.44.1", path = "protocols/ping" } +libp2p-ping = { version = "0.44.2", path = "protocols/ping" } libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } libp2p-quic = { version = "0.10.3", path = "transports/quic" } libp2p-relay = { version = "0.17.3", path = "protocols/relay" } libp2p-rendezvous = { version = "0.14.1", path = "protocols/rendezvous" } -libp2p-request-response = { version = "0.26.3", path = "protocols/request-response" } +libp2p-request-response = { version = "0.26.4", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } -libp2p-swarm = { version = "0.44.2", path = "swarm" } +libp2p-swarm = { version = "0.44.3", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } libp2p-tcp = { version = "0.41.1", path = "transports/tcp" } @@ -112,10 +112,10 @@ libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.2.1", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } -libp2p-websocket = { version = "0.43.0", path = "transports/websocket" } +libp2p-websocket = { version = "0.43.1", path = "transports/websocket" } libp2p-websocket-websys = { version = "0.3.2", path = "transports/websocket-websys" } libp2p-webtransport-websys = { version = "0.3.0", path = "transports/webtransport-websys" } -libp2p-yamux = { version = "0.45.1", path = "muxers/yamux" } +libp2p-yamux = { version = "0.45.2", path = "muxers/yamux" } multiaddr = "0.18.1" multihash = "0.19.1" multistream-select = { version = "0.13.0", path = "misc/multistream-select" } diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index 8b1a332769f..ed3ecbe2f20 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.54.0 -- unreleased +## 0.54.0 - Update individual crates. - Update to [`libp2p-kad` `v0.46.0`](protocols/kad/CHANGELOG.md#0460). diff --git a/muxers/yamux/CHANGELOG.md b/muxers/yamux/CHANGELOG.md index de608b195f8..295ee251f65 100644 --- a/muxers/yamux/CHANGELOG.md +++ b/muxers/yamux/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.45.2 + +- Update `yamux` to version `v0.13.3`.` + ## 0.45.1 - Deprecate `WindowUpdateMode::on_receive`. diff --git a/muxers/yamux/Cargo.toml b/muxers/yamux/Cargo.toml index 4d6d655e330..f56cd485b9b 100644 --- a/muxers/yamux/Cargo.toml +++ b/muxers/yamux/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-yamux" edition = "2021" rust-version = { workspace = true } description = "Yamux multiplexing protocol for libp2p" -version = "0.45.1" +version = "0.45.2" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 57ac92d2f6f..1d124fb37a2 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.46.0 -- unreleased +## 0.46.0 - Changed `FIND_NODE` response: now includes a list of closest peers when querying the recipient peer ID. Previously, this request yielded an empty response. See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270) diff --git a/protocols/ping/CHANGELOG.md b/protocols/ping/CHANGELOG.md index 65d45a69f23..507bf7532ba 100644 --- a/protocols/ping/CHANGELOG.md +++ b/protocols/ping/CHANGELOG.md @@ -1,11 +1,14 @@ -## 0.44.1 - unreleased +## 0.44.2 + +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + +## 0.44.1 - Impose `Sync` on `ping::Failure::Other`. `ping::Event` can now be shared between threads. See [PR 5250] -- Use `web-time` instead of `instant`. - See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). [PR 5250]: https://github.com/libp2p/rust-libp2p/pull/5250 diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index 99597fd5fe8..79c0a43aa69 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-ping" edition = "2021" rust-version = { workspace = true } description = "Ping protocol for libp2p" -version = "0.44.1" +version = "0.44.2" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index a181adc8c52..beee817f024 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.26.4 + +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.26.3 - Report failure when streams are at capacity. @@ -10,8 +15,6 @@ - Deprecate `Behaviour::add_address` in favor of `Swarm::add_peer_address`. See [PR 4371](https://github.com/libp2p/rust-libp2p/pull/4371). -- Use `web-time` instead of `instant`. - See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). ## 0.26.1 diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 900efd70d8b..4bc2378ae54 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-request-response" edition = "2021" rust-version = { workspace = true } description = "Generic Request/Response Protocols" -version = "0.26.3" +version = "0.26.4" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index b669bb0091a..8cded416628 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.44.3 + +- Use `web-time` instead of `instant`. + See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + ## 0.44.2 - Allow `NetworkBehaviour`s to share addresses of peers. @@ -5,8 +10,6 @@ The address is broadcast to all behaviours via `FromSwarm::NewExternalAddrOfPeer`. Protocols that want to collect these addresses can use the new `PeerAddresses` utility. See [PR 4371](https://github.com/libp2p/rust-libp2p/pull/4371). -- Use `web-time` instead of `instant`. - See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). ## 0.44.1 diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 714e8a8f349..338cbf91641 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition = "2021" rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.44.2" +version = "0.44.3" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/websocket/CHANGELOG.md b/transports/websocket/CHANGELOG.md index 192b1fa094e..d206cbac6a1 100644 --- a/transports/websocket/CHANGELOG.md +++ b/transports/websocket/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.43.1 + ## 0.43.0 diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index bcffe49a561..b022d95ca47 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-websocket" edition = "2021" rust-version = { workspace = true } description = "WebSocket transport for libp2p" -version = "0.43.0" +version = "0.43.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" From 78fac65b3dc15d62a165945dacfb6fc5265cfcba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 08:50:28 +0000 Subject: [PATCH 152/246] deps: bump clap from 4.5.4 to 4.5.6 Pull-Request: #5458. --- Cargo.lock | 12 ++++++------ examples/autonat/Cargo.toml | 2 +- examples/dcutr/Cargo.toml | 2 +- examples/file-sharing/Cargo.toml | 2 +- examples/ipfs-kad/Cargo.toml | 2 +- examples/relay-server/Cargo.toml | 2 +- misc/keygen/Cargo.toml | 2 +- misc/server/Cargo.toml | 2 +- protocols/dcutr/Cargo.toml | 2 +- protocols/perf/Cargo.toml | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7366606fe15..40d46b5c754 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -950,9 +950,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7" dependencies = [ "clap_builder", "clap_derive", @@ -960,9 +960,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df" dependencies = [ "anstream", "anstyle", @@ -972,9 +972,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck 0.5.0", "proc-macro2", diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index ce703ca742e..9bdf0be393d 100644 --- a/examples/autonat/Cargo.toml +++ b/examples/autonat/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] tokio = { workspace = true, features = ["full"] } -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.6", features = ["derive"] } futures = { workspace = true } libp2p = { path = "../../libp2p", features = ["tokio", "tcp", "noise", "yamux", "autonat", "identify", "macros"] } tracing = { workspace = true } diff --git a/examples/dcutr/Cargo.toml b/examples/dcutr/Cargo.toml index 97fabbbd006..c1b4bbc6e7e 100644 --- a/examples/dcutr/Cargo.toml +++ b/examples/dcutr/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.6", features = ["derive"] } futures = { workspace = true } futures-timer = "3.0" libp2p = { path = "../../libp2p", features = [ "dns", "dcutr", "identify", "macros", "noise", "ping", "quic", "relay", "rendezvous", "tcp", "tokio", "yamux"] } diff --git a/examples/file-sharing/Cargo.toml b/examples/file-sharing/Cargo.toml index b13c30885cb..7cbb96cc7ed 100644 --- a/examples/file-sharing/Cargo.toml +++ b/examples/file-sharing/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] serde = { version = "1.0", features = ["derive"] } tokio = { workspace = true, features = ["full"] } -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.6", features = ["derive"] } futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "cbor", "dns", "kad", "noise", "macros", "request-response", "tcp", "websocket", "yamux"] } tracing = { workspace = true } diff --git a/examples/ipfs-kad/Cargo.toml b/examples/ipfs-kad/Cargo.toml index f492fac7fb3..115c604269f 100644 --- a/examples/ipfs-kad/Cargo.toml +++ b/examples/ipfs-kad/Cargo.toml @@ -11,7 +11,7 @@ release = false [dependencies] tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } async-trait = "0.1" -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.6", features = ["derive"] } env_logger = "0.10" futures = { workspace = true } anyhow = "1.0.86" diff --git a/examples/relay-server/Cargo.toml b/examples/relay-server/Cargo.toml index e792ca48dd5..12d3e2467ce 100644 --- a/examples/relay-server/Cargo.toml +++ b/examples/relay-server/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" release = false [dependencies] -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.6", features = ["derive"] } async-std = { version = "1.12", features = ["attributes"] } async-trait = "0.1" futures = { workspace = true } diff --git a/misc/keygen/Cargo.toml b/misc/keygen/Cargo.toml index 22b546aff10..003993a512c 100644 --- a/misc/keygen/Cargo.toml +++ b/misc/keygen/Cargo.toml @@ -13,7 +13,7 @@ publish = false release = false [dependencies] -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.6", features = ["derive"] } zeroize = "1" serde = { version = "1.0.203", features = ["derive"] } serde_json = "1.0.117" diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 2c146c0c6e3..798ecfa07a9 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT" [dependencies] base64 = "0.22" -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.6", features = ["derive"] } futures = { workspace = true } futures-timer = "3" axum = "0.7" diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index daf4846a2ae..24a5560f5b5 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -29,7 +29,7 @@ futures-bounded = { workspace = true } [dev-dependencies] async-std = { version = "1.12.0", features = ["attributes"] } -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.6", features = ["derive"] } libp2p-dns = { workspace = true, features = ["async-std"] } libp2p-identify = { workspace = true } libp2p-noise = { workspace = true } diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 0d379f77353..4f154ab1b08 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] anyhow = "1" -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.6", features = ["derive"] } futures = { workspace = true } futures-bounded = { workspace = true } futures-timer = "3.0" From cc1f777009c389506056909c04bd56e12a13c532 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 09:03:49 +0000 Subject: [PATCH 153/246] deps: bump regex from 1.10.4 to 1.10.5 Pull-Request: #5459. --- Cargo.lock | 4 ++-- protocols/gossipsub/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40d46b5c754..717d872ed30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4794,9 +4794,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 35bc3eef9bd..f556443477f 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -31,7 +31,7 @@ libp2p-swarm = { workspace = true } quick-protobuf = "0.8" quick-protobuf-codec = { workspace = true } rand = "0.8" -regex = "1.10.4" +regex = "1.10.5" serde = { version = "1", optional = true, features = ["derive"] } sha2 = "0.10.8" smallvec = "1.13.2" From 75483e8dbe9beceacebe4ab19467400ea490d0b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 09:17:25 +0000 Subject: [PATCH 154/246] deps: bump rustls from 0.23.8 to 0.23.9 Pull-Request: #5460. --- Cargo.lock | 14 +++++++------- transports/quic/Cargo.toml | 2 +- transports/tls/Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 717d872ed30..774e02e2506 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1727,7 +1727,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls 0.23.8", + "rustls 0.23.9", "rustls-pki-types", ] @@ -3159,7 +3159,7 @@ dependencies = [ "quinn", "rand 0.8.5", "ring 0.17.8", - "rustls 0.23.8", + "rustls 0.23.9", "socket2 0.5.7", "thiserror", "tokio", @@ -3384,7 +3384,7 @@ dependencies = [ "libp2p-yamux", "rcgen", "ring 0.17.8", - "rustls 0.23.8", + "rustls 0.23.9", "rustls-webpki 0.101.7", "thiserror", "tokio", @@ -4593,7 +4593,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.8", + "rustls 0.23.9", "thiserror", "tokio", "tracing", @@ -4609,7 +4609,7 @@ dependencies = [ "rand 0.8.5", "ring 0.17.8", "rustc-hash", - "rustls 0.23.8", + "rustls 0.23.9", "slab", "thiserror", "tinyvec", @@ -5151,9 +5151,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.8" +version = "0.23.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79adb16721f56eb2d843e67676896a61ce7a0fa622dc18d3e372477a029d2740" +checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b" dependencies = [ "once_cell", "ring 0.17.8", diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 11eee04e199..3f99abf52e7 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -20,7 +20,7 @@ libp2p-identity = { workspace = true } parking_lot = "0.12.3" quinn = { version = "0.11.1", default-features = false, features = ["rustls", "futures-io"] } rand = "0.8.5" -rustls = { version = "0.23.8", default-features = false } +rustls = { version = "0.23.9", default-features = false } thiserror = "1.0.61" tokio = { workspace = true, default-features = false, features = ["net", "rt", "time"], optional = true } tracing = { workspace = true } diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 9bcff3bc88b..a4817f20336 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -22,7 +22,7 @@ yasna = "0.5.2" # Exposed dependencies. Breaking changes to these are breaking changes to us. [dependencies.rustls] -version = "0.23.8" +version = "0.23.9" default-features = false features = ["ring", "std"] # Must enable this to allow for custom verification code. From 60e32c9d3b4bee42ac698791e917e1587eaa1388 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Tue, 11 Jun 2024 01:17:16 +0300 Subject: [PATCH 155/246] fix(ping): Fix panic in WASM caused by retrying on dial upgrade errors This PR workarounds async-rs/futures-timer#74 issue. Fixes #5442 Pull-Request: #5447. --- protocols/ping/CHANGELOG.md | 3 +++ protocols/ping/src/handler.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/protocols/ping/CHANGELOG.md b/protocols/ping/CHANGELOG.md index 507bf7532ba..7c7d7f3a54f 100644 --- a/protocols/ping/CHANGELOG.md +++ b/protocols/ping/CHANGELOG.md @@ -3,6 +3,9 @@ - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). +- Fix panic in WASM caused by retrying on dial upgrade errors. + See [PR 5447](https://github.com/libp2p/rust-libp2p/pull/5447). + ## 0.44.1 - Impose `Sync` on `ping::Failure::Other`. diff --git a/protocols/ping/src/handler.rs b/protocols/ping/src/handler.rs index b9bd25c52ea..2816cdc4048 100644 --- a/protocols/ping/src/handler.rs +++ b/protocols/ping/src/handler.rs @@ -184,6 +184,18 @@ impl Handler { ) { self.outbound = None; // Request a new substream on the next `poll`. + // Timer is already polled and expired before substream request is initiated + // and will be polled again later on in our `poll` because we reset `self.outbound`. + // + // `futures-timer` allows an expired timer to be polled again and returns + // immediately `Poll::Ready`. However in its WASM implementation there is + // a bug that causes the expired timer to panic. + // This is a workaround until a proper fix is merged and released. + // See libp2p/rust-libp2p#5447 for more info. + // + // TODO: remove when async-rs/futures-timer#74 gets merged. + self.interval.reset(Duration::new(0, 0)); + let error = match error { StreamUpgradeError::NegotiationFailed => { debug_assert_eq!(self.state, State::Active); From 65658f5c81c601f8ed558bc688c9bce6365011cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 09:56:11 +0000 Subject: [PATCH 156/246] deps: bump quinn from 0.11.1 to 0.11.2 Pull-Request: #5462. --- Cargo.lock | 4 ++-- transports/quic/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 774e02e2506..300c64f48ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4581,9 +4581,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904e3d3ba178131798c6d9375db2b13b34337d489b089fc5ba0825a2ff1bee73" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" dependencies = [ "async-io 2.3.3", "async-std", diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 3f99abf52e7..c7e031b1cfd 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -18,7 +18,7 @@ libp2p-core = { workspace = true } libp2p-tls = { workspace = true } libp2p-identity = { workspace = true } parking_lot = "0.12.3" -quinn = { version = "0.11.1", default-features = false, features = ["rustls", "futures-io"] } +quinn = { version = "0.11.2", default-features = false, features = ["rustls", "futures-io"] } rand = "0.8.5" rustls = { version = "0.23.9", default-features = false } thiserror = "1.0.61" From 28dd3b21571e3de374ea373deb731f2f7abc7a74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:25:03 +0000 Subject: [PATCH 157/246] deps: bump futures-bounded from 0.2.3 to 0.2.4 Pull-Request: #5461. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 300c64f48ef..7b1f9685b24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1642,9 +1642,9 @@ dependencies = [ [[package]] name = "futures-bounded" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e2774cc104e198ef3d3e1ff4ab40f86fa3245d6cb6a3a46174f21463cee173" +checksum = "91f328e7fb845fc832912fb6a34f40cf6d1888c92f974d1893a54e97b5ff542e" dependencies = [ "futures-timer", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index 00628ca23b8..0dd5b9075cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,7 +72,7 @@ rust-version = "1.75.0" [workspace.dependencies] asynchronous-codec = { version = "0.7.0" } -futures-bounded = { version = "0.2.3" } +futures-bounded = { version = "0.2.4" } futures-rustls = { version = "0.26.0", default-features = false } libp2p = { version = "0.54.0", path = "libp2p" } libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" } From c44ed01a2636dd433c1a2563bb79b63472a5c66e Mon Sep 17 00:00:00 2001 From: todaymoon Date: Wed, 12 Jun 2024 19:37:45 +0900 Subject: [PATCH 158/246] chore: fix some comments fix some comments Pull-Request: #5456. --- protocols/identify/Cargo.toml | 2 +- protocols/request-response/tests/error_reporting.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index e75a2c4c4bc..86425d580e9 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-identify" edition = "2021" rust-version = { workspace = true } -description = "Nodes identifcation protocol for libp2p" +description = "Nodes identification protocol for libp2p" version = "0.44.2" authors = ["Parity Technologies "] license = "MIT" diff --git a/protocols/request-response/tests/error_reporting.rs b/protocols/request-response/tests/error_reporting.rs index e78bba926e2..19f323e169f 100644 --- a/protocols/request-response/tests/error_reporting.rs +++ b/protocols/request-response/tests/error_reporting.rs @@ -195,7 +195,7 @@ async fn report_outbound_failure_on_max_streams() { assert_eq!(action, Action::FailOnMaxStreams); // A task for sending back a response is already scheduled so max concurrent - // streams is reached and no new tasks can be sheduled. + // streams is reached and no new tasks can be scheduled. // // We produce the failure by creating new request before we response. let outbound_req_id = swarm2 From 9708b6377233fbb11ebd1e518b8b63c6f67cbb58 Mon Sep 17 00:00:00 2001 From: Rikard Hjort <8545447+hjorthjort@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:56:46 +0200 Subject: [PATCH 159/246] chore(tutorials): fix typo Fixes typo: "dailing" -> "dialing" Pull-Request: #5428. --- libp2p/src/tutorials/hole_punching.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libp2p/src/tutorials/hole_punching.rs b/libp2p/src/tutorials/hole_punching.rs index f9f42432ba4..0963c0ca59e 100644 --- a/libp2p/src/tutorials/hole_punching.rs +++ b/libp2p/src/tutorials/hole_punching.rs @@ -69,7 +69,7 @@ //! Now let's make sure that the server is public, in other words let's make sure one can reach it //! through the Internet. First, either manually replace `$RELAY_SERVER_IP` in the following //! commands or `export RELAY_SERVER_IP=ipaddr` with the appropriate relay server `ipaddr` in -//! the dailing client and listening client. +//! the dialing client and listening client. //! //! Now, from the dialing client: //! From fc9b1ad51655b79561e3c552859554e99e2b0040 Mon Sep 17 00:00:00 2001 From: taikoon Date: Wed, 12 Jun 2024 20:03:41 +0800 Subject: [PATCH 160/246] chore(transports): remove duplicate word Pull-Request: #5449. --- transports/webrtc-websys/src/stream/poll_data_channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transports/webrtc-websys/src/stream/poll_data_channel.rs b/transports/webrtc-websys/src/stream/poll_data_channel.rs index f323d542eaf..dfd861de9df 100644 --- a/transports/webrtc-websys/src/stream/poll_data_channel.rs +++ b/transports/webrtc-websys/src/stream/poll_data_channel.rs @@ -13,7 +13,7 @@ use libp2p_webrtc_utils::MAX_MSG_LEN; use wasm_bindgen::prelude::*; use web_sys::{Event, MessageEvent, RtcDataChannel, RtcDataChannelEvent, RtcDataChannelState}; -/// [`PollDataChannel`] is a wrapper around around [`RtcDataChannel`] which implements [`AsyncRead`] and [`AsyncWrite`]. +/// [`PollDataChannel`] is a wrapper around [`RtcDataChannel`] which implements [`AsyncRead`] and [`AsyncWrite`]. #[derive(Debug, Clone)] pub(crate) struct PollDataChannel { /// The [`RtcDataChannel`] being wrapped. From 5089299ff96fd8ee68d8ee45b9889a0ca40c9453 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:26:33 -0400 Subject: [PATCH 161/246] fix: require rand feature when generating ecdsa key Using `libp2p-identity` as a crate did not work if `default-features` is `false` and `ecdsa` is included. The following command also fails: ``` cargo check --no-default-features --features "ecdsa,ed25519,peerid,secp256k1" ``` Now, this command works Pull-Request: #5212. --- Cargo.lock | 2 +- Cargo.toml | 2 +- identity/CHANGELOG.md | 5 +++++ identity/Cargo.toml | 2 +- identity/src/ecdsa.rs | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b1f9685b24..9e7e03bc7ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2862,7 +2862,7 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.2.8" +version = "0.2.9" dependencies = [ "asn1_der", "base64 0.22.1", diff --git a/Cargo.toml b/Cargo.toml index 0dd5b9075cb..29c0664735f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,7 @@ libp2p-dns = { version = "0.41.1", path = "transports/dns" } libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" } libp2p-identify = { version = "0.44.2", path = "protocols/identify" } -libp2p-identity = { version = "0.2.8" } +libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.46.0", path = "protocols/kad" } libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" } diff --git a/identity/CHANGELOG.md b/identity/CHANGELOG.md index 004943ce195..9670a843130 100644 --- a/identity/CHANGELOG.md +++ b/identity/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.9 + +- Add `rand` feature gate to ecdsa methods requiring a random number generator. + See [PR 5212](https://github.com/libp2p/rust-libp2p/pull/5212). + ## 0.2.8 - Bump `ring` to `0.17.5. diff --git a/identity/Cargo.toml b/identity/Cargo.toml index e7d464a520a..ea49a1adbb4 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-identity" -version = "0.2.8" +version = "0.2.9" edition = "2021" description = "Data structures and algorithms for identifying peers in libp2p." rust-version = "1.73.0" # MUST NOT inherit from workspace because we don't want to publish breaking changes to `libp2p-identity`. diff --git a/identity/src/ecdsa.rs b/identity/src/ecdsa.rs index 2f1a286d46d..65cbe885b86 100644 --- a/identity/src/ecdsa.rs +++ b/identity/src/ecdsa.rs @@ -94,6 +94,7 @@ pub struct SecretKey(SigningKey); impl SecretKey { /// Generate a new random ECDSA secret key. + #[cfg(feature = "rand")] pub fn generate() -> SecretKey { SecretKey(SigningKey::random(&mut rand::thread_rng())) } From 7fa6684444dc68318ce6d7e0f71cc2ff52a73768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Wed, 12 Jun 2024 19:11:34 +0100 Subject: [PATCH 162/246] chore: address clippy beta lints Pull-Request: #5467. --- Cargo.lock | 37 ++++++++++++++++--- Cargo.toml | 2 +- core/src/upgrade.rs | 6 +-- examples/chat/README.md | 2 +- .../distributed-key-value-store/README.md | 10 ++--- examples/file-sharing/README.md | 20 +++++----- examples/ipfs-private/README.md | 6 +-- examples/relay-server/README.md | 2 +- libp2p/src/builder.rs | 4 +- misc/multistream-select/src/protocol.rs | 12 ++---- protocols/gossipsub/src/behaviour.rs | 2 + protocols/gossipsub/src/lib.rs | 16 ++++---- protocols/gossipsub/src/protocol.rs | 14 ------- protocols/identify/src/lib.rs | 6 +-- protocols/kad/src/behaviour.rs | 10 ++--- protocols/kad/src/lib.rs | 18 ++++----- swarm/src/handler.rs | 1 + transports/dns/src/lib.rs | 14 +++---- transports/noise/src/io/framed.rs | 10 ++--- transports/webrtc/src/tokio/certificate.rs | 1 + 20 files changed, 99 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e7e03bc7ec..7fab00010fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1327,6 +1327,15 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "digest" version = "0.9.0" @@ -4008,6 +4017,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.45" @@ -4437,6 +4452,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -5897,11 +5918,14 @@ dependencies = [ [[package]] name = "time" -version = "0.3.23" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ + "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -5909,16 +5933,17 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.10" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] diff --git a/Cargo.toml b/Cargo.toml index 29c0664735f..822c1692960 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,7 +144,7 @@ libp2p-identity = { path = "identity" } [workspace.lints] rust.unreachable_pub = "warn" clippy.used_underscore_binding = "warn" -clippy.pedantic = "allow" +clippy.pedantic = { level = "allow", priority = -1 } clippy.type_complexity = "allow" clippy.unnecessary_wraps = "warn" clippy.manual_let_else = "warn" diff --git a/core/src/upgrade.rs b/core/src/upgrade.rs index 69561fbebd8..7a1fd3724d0 100644 --- a/core/src/upgrade.rs +++ b/core/src/upgrade.rs @@ -52,9 +52,9 @@ //! can be used by the user to control the behaviour of the protocol. //! //! > **Note**: You can use the `apply_inbound` or `apply_outbound` methods to try upgrade a -//! connection or substream. However if you use the recommended `Swarm` or -//! `ConnectionHandler` APIs, the upgrade is automatically handled for you and you don't -//! need to use these methods. +//! > connection or substream. However if you use the recommended `Swarm` or +//! > `ConnectionHandler` APIs, the upgrade is automatically handled for you and you don't +//! > need to use these methods. //! mod apply; diff --git a/examples/chat/README.md b/examples/chat/README.md index 96bad137b07..2dbf585100b 100644 --- a/examples/chat/README.md +++ b/examples/chat/README.md @@ -11,7 +11,7 @@ It showcases how peers can connect, discover each other using mDNS, and engage i ``` 2. Mutual mDNS discovery may take a few seconds. When each peer does discover the other -it will print a message like: + it will print a message like: ```sh mDNS discovered a new peer: {peerId} ``` diff --git a/examples/distributed-key-value-store/README.md b/examples/distributed-key-value-store/README.md index 6065609cfdf..4a44e0c5427 100644 --- a/examples/distributed-key-value-store/README.md +++ b/examples/distributed-key-value-store/README.md @@ -9,10 +9,10 @@ This example showcases a basic distributed key-value store implemented using **l 1. Open two terminal windows, type `cargo run` and press Enter. 2. In terminal one, type `PUT my-key my-value` and press Enter. -This command will store the value `my-value` with the key `my-key` in the distributed key-value store. + This command will store the value `my-value` with the key `my-key` in the distributed key-value store. 3. In terminal two, type `GET my-key` and press Enter. -This command will retrieve the value associated with the key `my-key` from the key-value store. + This command will retrieve the value associated with the key `my-key` from the key-value store. 4. To exit, press `Ctrl-c` in each terminal window to gracefully close the instances. @@ -22,13 +22,13 @@ This command will retrieve the value associated with the key `my-key` from the k You can also use provider records instead of key-value records in the distributed store. 1. Open two terminal windows and start two instances of the key-value store. -If your local network supports mDNS, the instances will automatically connect. + If your local network supports mDNS, the instances will automatically connect. 2. In terminal one, type `PUT_PROVIDER my-key` and press Enter. -This command will register the peer as a provider for the key `my-key` in the distributed key-value store. + This command will register the peer as a provider for the key `my-key` in the distributed key-value store. 3. In terminal two, type `GET_PROVIDERS my-key` and press Enter. -This command will retrieve the list of providers for the key `my-key` from the key-value store. + This command will retrieve the list of providers for the key `my-key` from the key-value store. 4. To exit, press `Ctrl-c` in each terminal window to gracefully close the instances. diff --git a/examples/file-sharing/README.md b/examples/file-sharing/README.md index 2a2b3ec5317..5424026bb12 100644 --- a/examples/file-sharing/README.md +++ b/examples/file-sharing/README.md @@ -12,28 +12,28 @@ Retrievers can locate and retrieve files by their names from any node in the net Let's understand the flow of the file sharing process: - **File Providers**: Nodes A and B serve as file providers. -Each node offers a specific file: file FA for node A and file FB for node B. -To make their files available, they advertise themselves as providers on the DHT using `libp2p-kad`. -This enables other nodes in the network to discover and retrieve their files. + Each node offers a specific file: file FA for node A and file FB for node B. + To make their files available, they advertise themselves as providers on the DHT using `libp2p-kad`. + This enables other nodes in the network to discover and retrieve their files. - **File Retrievers**: Node C acts as a file retriever. -It wants to retrieve either file FA or FB. -Using `libp2p-kad`, it can locate the providers for these files on the DHT without being directly connected to them. -Node C connects to the corresponding provider node and requests the file content using `libp2p-request-response`. + It wants to retrieve either file FA or FB. + Using `libp2p-kad`, it can locate the providers for these files on the DHT without being directly connected to them. + Node C connects to the corresponding provider node and requests the file content using `libp2p-request-response`. - **DHT and Network Connectivity**: The DHT (Distributed Hash Table) plays a crucial role in the file sharing process. -It allows nodes to store and discover information about file providers. -Nodes in the network are interconnected via the DHT, enabling efficient file discovery and retrieval. + It allows nodes to store and discover information about file providers. + Nodes in the network are interconnected via the DHT, enabling efficient file discovery and retrieval. ## Architectural Properties The File Sharing application has the following architectural properties: - **Clean and Clonable Interface**: The application provides a clean and clonable async/await interface, allowing users to interact with the network layer seamlessly. -The `Client` module encapsulates the necessary functionality for network communication. + The `Client` module encapsulates the necessary functionality for network communication. - **Efficient Network Handling**: The application operates with a single task that drives the network layer. -This design choice ensures efficient network communication without the need for locks or complex synchronization mechanisms. + This design choice ensures efficient network communication without the need for locks or complex synchronization mechanisms. ## Usage diff --git a/examples/ipfs-private/README.md b/examples/ipfs-private/README.md index bc3b12a7ac8..ae7fc42c9c4 100644 --- a/examples/ipfs-private/README.md +++ b/examples/ipfs-private/README.md @@ -24,11 +24,11 @@ To run the example, follow these steps: 2. Once the example is running, you can interact with the IPFS node using the following commands: - **Pubsub (Gossipsub):** You can use the gossipsub protocol to send and receive messages on the "chat" topic. - To send a message, type it in the console and press Enter. - The message will be broadcasted to other connected nodes using gossipsub. + To send a message, type it in the console and press Enter. + The message will be broadcasted to other connected nodes using gossipsub. - **Ping:** You can ping other connected nodes to test network connectivity. - The example will display the round-trip time (RTT) for successful pings or indicate if a timeout occurs. + The example will display the round-trip time (RTT) for successful pings or indicate if a timeout occurs. ## Conclusion diff --git a/examples/relay-server/README.md b/examples/relay-server/README.md index ae2ab3fdfd8..cd8f0340a5a 100644 --- a/examples/relay-server/README.md +++ b/examples/relay-server/README.md @@ -16,7 +16,7 @@ To run the example, follow these steps: Replace `` with a seed value used to generate a deterministic peer ID for the relay node. 2. The relay node will start listening for incoming connections. -It will print the listening address once it is ready. + It will print the listening address once it is ready. 3. Connect other **libp2p** nodes to the relay node by specifying the relay's listening address as one of the bootstrap nodes in their configuration. diff --git a/libp2p/src/builder.rs b/libp2p/src/builder.rs index c96c20d470a..de003314cca 100644 --- a/libp2p/src/builder.rs +++ b/libp2p/src/builder.rs @@ -575,7 +575,7 @@ mod tests { #[test] #[cfg(all(feature = "tokio", feature = "quic"))] - fn quic_bandwidth_metrics() -> Result<(), Box> { + fn quic_bandwidth_metrics() { let _ = SwarmBuilder::with_new_identity() .with_tokio() .with_quic() @@ -583,8 +583,6 @@ mod tests { .with_behaviour(|_| libp2p_swarm::dummy::Behaviour) .unwrap() .build(); - - Ok(()) } #[test] diff --git a/misc/multistream-select/src/protocol.rs b/misc/multistream-select/src/protocol.rs index 2189c50e697..92b6acedaeb 100644 --- a/misc/multistream-select/src/protocol.rs +++ b/misc/multistream-select/src/protocol.rs @@ -136,24 +136,21 @@ pub(crate) enum Message { impl Message { /// Encodes a `Message` into its byte representation. - fn encode(&self, dest: &mut BytesMut) -> Result<(), ProtocolError> { + fn encode(&self, dest: &mut BytesMut) { match self { Message::Header(HeaderLine::V1) => { dest.reserve(MSG_MULTISTREAM_1_0.len()); dest.put(MSG_MULTISTREAM_1_0); - Ok(()) } Message::Protocol(p) => { let len = p.as_ref().len() + 1; // + 1 for \n dest.reserve(len); dest.put(p.0.as_ref()); dest.put_u8(b'\n'); - Ok(()) } Message::ListProtocols => { dest.reserve(MSG_LS.len()); dest.put(MSG_LS); - Ok(()) } Message::Protocols(ps) => { let mut buf = uvi::encode::usize_buffer(); @@ -166,12 +163,10 @@ impl Message { encoded.push(b'\n'); dest.reserve(encoded.len()); dest.put(encoded.as_ref()); - Ok(()) } Message::NotAvailable => { dest.reserve(MSG_PROTOCOL_NA.len()); dest.put(MSG_PROTOCOL_NA); - Ok(()) } } } @@ -288,7 +283,7 @@ where fn start_send(self: Pin<&mut Self>, item: Message) -> Result<(), Self::Error> { let mut buf = BytesMut::new(); - item.encode(&mut buf)?; + item.encode(&mut buf); self.project() .inner .start_send(buf.freeze()) @@ -499,8 +494,7 @@ mod tests { fn encode_decode_message() { fn prop(msg: Message) { let mut buf = BytesMut::new(); - msg.encode(&mut buf) - .unwrap_or_else(|_| panic!("Encoding message failed: {msg:?}")); + msg.encode(&mut buf); match Message::decode(buf.freeze()) { Ok(m) => assert_eq!(m, msg), Err(e) => panic!("Decoding failed: {e:?}"), diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index b508959317b..7980f362acf 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -549,6 +549,7 @@ where /// Unsubscribes from a topic. /// /// Returns [`Ok(true)`] if we were subscribed to this topic. + #[allow(clippy::unnecessary_wraps)] pub fn unsubscribe(&mut self, topic: &Topic) -> Result { tracing::debug!(%topic, "Unsubscribing from topic"); let topic_hash = topic.hash(); @@ -2551,6 +2552,7 @@ where /// Helper function which forwards a message to mesh\[topic\] peers. /// /// Returns true if at least one peer was messaged. + #[allow(clippy::unnecessary_wraps)] fn forward_msg( &mut self, msg_id: &MessageId, diff --git a/protocols/gossipsub/src/lib.rs b/protocols/gossipsub/src/lib.rs index 15db5eba21d..3db2fa7ce51 100644 --- a/protocols/gossipsub/src/lib.rs +++ b/protocols/gossipsub/src/lib.rs @@ -43,16 +43,16 @@ //! implementations, due to undefined elements in the current specification. //! //! - **Topics** - In gossipsub, topics configurable by the `hash_topics` configuration parameter. -//! Topics are of type [`TopicHash`]. The current go implementation uses raw utf-8 strings, and this -//! is default configuration in rust-libp2p. Topics can be hashed (SHA256 hashed then base64 -//! encoded) by setting the `hash_topics` configuration parameter to true. +//! Topics are of type [`TopicHash`]. The current go implementation uses raw utf-8 strings, and this +//! is default configuration in rust-libp2p. Topics can be hashed (SHA256 hashed then base64 +//! encoded) by setting the `hash_topics` configuration parameter to true. //! //! - **Sequence Numbers** - A message on the gossipsub network is identified by the source -//! [`PeerId`](libp2p_identity::PeerId) and a nonce (sequence number) of the message. The sequence numbers in -//! this implementation are sent as raw bytes across the wire. They are 64-bit big-endian unsigned -//! integers. When messages are signed, they are monotonically increasing integers starting from a -//! random value and wrapping around u64::MAX. When messages are unsigned, they are chosen at random. -//! NOTE: These numbers are sequential in the current go implementation. +//! [`PeerId`](libp2p_identity::PeerId) and a nonce (sequence number) of the message. The sequence numbers in +//! this implementation are sent as raw bytes across the wire. They are 64-bit big-endian unsigned +//! integers. When messages are signed, they are monotonically increasing integers starting from a +//! random value and wrapping around u64::MAX. When messages are unsigned, they are chosen at random. +//! NOTE: These numbers are sequential in the current go implementation. //! //! # Peer Discovery //! diff --git a/protocols/gossipsub/src/protocol.rs b/protocols/gossipsub/src/protocol.rs index 01a38562c02..c13caae58b6 100644 --- a/protocols/gossipsub/src/protocol.rs +++ b/protocols/gossipsub/src/protocol.rs @@ -541,20 +541,6 @@ mod tests { struct TestKeypair(Keypair); impl Arbitrary for TestKeypair { - #[cfg(feature = "rsa")] - fn arbitrary(g: &mut Gen) -> Self { - let keypair = if bool::arbitrary(g) { - // Small enough to be inlined. - Keypair::generate_ed25519() - } else { - // Too large to be inlined. - let mut rsa_key = hex::decode("308204bd020100300d06092a864886f70d0101010500048204a7308204a30201000282010100ef930f41a71288b643c1cbecbf5f72ab53992249e2b00835bf07390b6745419f3848cbcc5b030faa127bc88cdcda1c1d6f3ff699f0524c15ab9d2c9d8015f5d4bd09881069aad4e9f91b8b0d2964d215cdbbae83ddd31a7622a8228acee07079f6e501aea95508fa26c6122816ef7b00ac526d422bd12aed347c37fff6c1c307f3ba57bb28a7f28609e0bdcc839da4eedca39f5d2fa855ba4b0f9c763e9764937db929a1839054642175312a3de2d3405c9d27bdf6505ef471ce85c5e015eee85bf7874b3d512f715de58d0794fd8afe021c197fbd385bb88a930342fac8da31c27166e2edab00fa55dc1c3814448ba38363077f4e8fe2bdea1c081f85f1aa6f02030100010282010028ff427a1aac1a470e7b4879601a6656193d3857ea79f33db74df61e14730e92bf9ffd78200efb0c40937c3356cbe049cd32e5f15be5c96d5febcaa9bd3484d7fded76a25062d282a3856a1b3b7d2c525cdd8434beae147628e21adf241dd64198d5819f310d033743915ba40ea0b6acdbd0533022ad6daa1ff42de51885f9e8bab2306c6ef1181902d1cd7709006eba1ab0587842b724e0519f295c24f6d848907f772ae9a0953fc931f4af16a07df450fb8bfa94572562437056613647818c238a6ff3f606cffa0533e4b8755da33418dfbc64a85110b1a036623c947400a536bb8df65e5ebe46f2dfd0cfc86e7aeeddd7574c253e8fbf755562b3669525d902818100f9fff30c6677b78dd31ec7a634361438457e80be7a7faf390903067ea8355faa78a1204a82b6e99cb7d9058d23c1ecf6cfe4a900137a00cecc0113fd68c5931602980267ea9a95d182d48ba0a6b4d5dd32fdac685cb2e5d8b42509b2eb59c9579ea6a67ccc7547427e2bd1fb1f23b0ccb4dd6ba7d206c8dd93253d70a451701302818100f5530dfef678d73ce6a401ae47043af10a2e3f224c71ae933035ecd68ccbc4df52d72bc6ca2b17e8faf3e548b483a2506c0369ab80df3b137b54d53fac98f95547c2bc245b416e650ce617e0d29db36066f1335a9ba02ad3e0edf9dc3d58fd835835042663edebce81803972696c789012847cb1f854ab2ac0a1bd3867ac7fb502818029c53010d456105f2bf52a9a8482bca2224a5eac74bf3cc1a4d5d291fafcdffd15a6a6448cce8efdd661f6617ca5fc37c8c885cc3374e109ac6049bcbf72b37eabf44602a2da2d4a1237fd145c863e6d75059976de762d9d258c42b0984e2a2befa01c95217c3ee9c736ff209c355466ff99375194eff943bc402ea1d172a1ed02818027175bf493bbbfb8719c12b47d967bf9eac061c90a5b5711172e9095c38bb8cc493c063abffe4bea110b0a2f22ac9311b3947ba31b7ef6bfecf8209eebd6d86c316a2366bbafda7279b2b47d5bb24b6202254f249205dcad347b574433f6593733b806f84316276c1990a016ce1bbdbe5f650325acc7791aefe515ecc60063bd02818100b6a2077f4adcf15a17092d9c4a346d6022ac48f3861b73cf714f84c440a07419a7ce75a73b9cbff4597c53c128bf81e87b272d70428a272d99f90cd9b9ea1033298e108f919c6477400145a102df3fb5601ffc4588203cf710002517bfa24e6ad32f4d09c6b1a995fa28a3104131bedd9072f3b4fb4a5c2056232643d310453f").unwrap(); - Keypair::rsa_from_pkcs8(&mut rsa_key).unwrap() - }; - TestKeypair(keypair) - } - - #[cfg(not(feature = "rsa"))] fn arbitrary(_g: &mut Gen) -> Self { // Small enough to be inlined. TestKeypair(Keypair::generate_ed25519()) diff --git a/protocols/identify/src/lib.rs b/protocols/identify/src/lib.rs index 34928d5d7df..7d28e5b5cc7 100644 --- a/protocols/identify/src/lib.rs +++ b/protocols/identify/src/lib.rs @@ -29,9 +29,9 @@ //! # Important Discrepancies //! //! - **Using Identify with other protocols** Unlike some other libp2p implementations, -//! rust-libp2p does not treat Identify as a core protocol. This means that other protocols cannot -//! rely upon the existence of Identify, and need to be manually hooked up to Identify in order to -//! make use of its capabilities. +//! rust-libp2p does not treat Identify as a core protocol. This means that other protocols cannot +//! rely upon the existence of Identify, and need to be manually hooked up to Identify in order to +//! make use of its capabilities. //! //! # Usage //! diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 302433a8d70..5d8a8bb0fd8 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -925,11 +925,11 @@ where /// > See [`Behaviour::add_address`]. /// /// > **Note**: Bootstrap does not require to be called manually. It is periodically - /// invoked at regular intervals based on the configured `periodic_bootstrap_interval` (see - /// [`Config::set_periodic_bootstrap_interval`] for details) and it is also automatically invoked - /// when a new peer is inserted in the routing table. - /// This parameter is used to call [`Behaviour::bootstrap`] periodically and automatically - /// to ensure a healthy routing table. + /// > invoked at regular intervals based on the configured `periodic_bootstrap_interval` (see + /// > [`Config::set_periodic_bootstrap_interval`] for details) and it is also automatically invoked + /// > when a new peer is inserted in the routing table. + /// > This parameter is used to call [`Behaviour::bootstrap`] periodically and automatically + /// > to ensure a healthy routing table. pub fn bootstrap(&mut self) -> Result { let local_key = *self.kbuckets.local_key(); let info = QueryInfo::Bootstrap { diff --git a/protocols/kad/src/lib.rs b/protocols/kad/src/lib.rs index bc01b9fd3ce..bb7c2ace663 100644 --- a/protocols/kad/src/lib.rs +++ b/protocols/kad/src/lib.rs @@ -23,15 +23,15 @@ //! # Important Discrepancies //! //! - **Peer Discovery with Identify** In other libp2p implementations, the -//! [Identify](https://github.com/libp2p/specs/tree/master/identify) protocol might be seen as a core protocol. Rust-libp2p -//! tries to stay as generic as possible, and does not make this assumption. -//! This means that the Identify protocol must be manually hooked up to Kademlia through calls -//! to [`Behaviour::add_address`]. -//! If you choose not to use the Identify protocol, and do not provide an alternative peer -//! discovery mechanism, a Kademlia node will not discover nodes beyond the network's -//! [boot nodes](https://docs.libp2p.io/concepts/glossary/#boot-node). Without the Identify protocol, -//! existing nodes in the kademlia network cannot obtain the listen addresses -//! of nodes querying them, and thus will not be able to add them to their routing table. +//! [Identify](https://github.com/libp2p/specs/tree/master/identify) protocol might be seen as a core protocol. Rust-libp2p +//! tries to stay as generic as possible, and does not make this assumption. +//! This means that the Identify protocol must be manually hooked up to Kademlia through calls +//! to [`Behaviour::add_address`]. +//! If you choose not to use the Identify protocol, and do not provide an alternative peer +//! discovery mechanism, a Kademlia node will not discover nodes beyond the network's +//! [boot nodes](https://docs.libp2p.io/concepts/glossary/#boot-node). Without the Identify protocol, +//! existing nodes in the kademlia network cannot obtain the listen addresses +//! of nodes querying them, and thus will not be able to add them to their routing table. #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] diff --git a/swarm/src/handler.rs b/swarm/src/handler.rs index 31d2c91e391..20980aff8bd 100644 --- a/swarm/src/handler.rs +++ b/swarm/src/handler.rs @@ -137,6 +137,7 @@ pub trait ConnectionHandler: Send + 'static { /// /// - Protocols like [circuit-relay v2](https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md) need to keep a connection alive beyond these circumstances and can thus override this method. /// - Protocols like [ping](https://github.com/libp2p/specs/blob/master/ping/ping.md) **don't** want to keep a connection alive despite an active streams. + /// /// In that case, protocol authors can use [`Stream::ignore_for_keep_alive`](crate::Stream::ignore_for_keep_alive) to opt-out a particular stream from the keep-alive algorithm. fn connection_keep_alive(&self) -> bool { false diff --git a/transports/dns/src/lib.rs b/transports/dns/src/lib.rs index 505a91f0791..63bd9bbad26 100644 --- a/transports/dns/src/lib.rs +++ b/transports/dns/src/lib.rs @@ -48,6 +48,7 @@ //! any system APIs (like libc's `gethostbyname`). Again this is //! problematic on platforms like Android, where there's a lot of //! complexity hidden behind the system APIs. +//! //! If the implementation requires different characteristics, one should //! consider providing their own implementation of [`Transport`] or use //! platform specific APIs to extract the host's DNS configuration (if possible) @@ -231,14 +232,14 @@ where } fn dial(&mut self, addr: Multiaddr) -> Result> { - self.do_dial(addr, Endpoint::Dialer) + Ok(self.do_dial(addr, Endpoint::Dialer)) } fn dial_as_listener( &mut self, addr: Multiaddr, ) -> Result> { - self.do_dial(addr, Endpoint::Listener) + Ok(self.do_dial(addr, Endpoint::Listener)) } fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { @@ -269,16 +270,13 @@ where &mut self, addr: Multiaddr, role_override: Endpoint, - ) -> Result< - ::Dial, - TransportError<::Error>, - > { + ) -> ::Dial { let resolver = self.resolver.clone(); let inner = self.inner.clone(); // Asynchronously resolve all DNS names in the address before proceeding // with dialing on the underlying transport. - Ok(async move { + async move { let mut last_err = None; let mut dns_lookups = 0; let mut dial_attempts = 0; @@ -404,7 +402,7 @@ where })) } .boxed() - .right_future()) + .right_future() } } diff --git a/transports/noise/src/io/framed.rs b/transports/noise/src/io/framed.rs index 9ed6045cf38..17254efb0a9 100644 --- a/transports/noise/src/io/framed.rs +++ b/transports/noise/src/io/framed.rs @@ -197,7 +197,7 @@ fn decrypt( ciphertext: &mut BytesMut, decrypt_fn: impl FnOnce(&[u8], &mut [u8]) -> Result, ) -> io::Result> { - let Some(ciphertext) = decode_length_prefixed(ciphertext)? else { + let Some(ciphertext) = decode_length_prefixed(ciphertext) else { return Ok(None); }; @@ -223,9 +223,9 @@ fn encode_length_prefixed(src: &[u8], dst: &mut BytesMut) { dst.extend_from_slice(src); } -fn decode_length_prefixed(src: &mut BytesMut) -> Result, io::Error> { +fn decode_length_prefixed(src: &mut BytesMut) -> Option { if src.len() < size_of::() { - return Ok(None); + return None; } let mut len_bytes = [0u8; U16_LENGTH]; @@ -235,8 +235,8 @@ fn decode_length_prefixed(src: &mut BytesMut) -> Result, io::Error if src.len() - U16_LENGTH >= len { // Skip the length header we already read. src.advance(U16_LENGTH); - Ok(Some(src.split_to(len).freeze())) + Some(src.split_to(len).freeze()) } else { - Ok(None) + None } } diff --git a/transports/webrtc/src/tokio/certificate.rs b/transports/webrtc/src/tokio/certificate.rs index 7c7c65f0447..81197af4132 100644 --- a/transports/webrtc/src/tokio/certificate.rs +++ b/transports/webrtc/src/tokio/certificate.rs @@ -32,6 +32,7 @@ impl Certificate { /// Generate new certificate. /// /// `_rng` argument is ignored for now. See . + #[allow(clippy::unnecessary_wraps)] pub fn generate(_rng: &mut R) -> Result where R: CryptoRng + Rng, From af5f0d33138437c53da9639964265d901b78bf65 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:35:07 +0000 Subject: [PATCH 163/246] deps: bump taiki-e/cache-cargo-install-action from 1 to 2 Pull-Request: #5343. --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87987489450..a19cdce6558 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: cargo metadata --format-version=1 --no-deps | \ jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .dependencies | all(.name != "libp2p")' - - uses: taiki-e/cache-cargo-install-action@924d49e0af41f449f0ad549559bc608ee4653562 # v1 + - uses: taiki-e/cache-cargo-install-action@5b024fe3a0a2c7f2aaff0e47871acf0d14b07207 # v1 with: tool: tomlq @@ -114,7 +114,7 @@ jobs: with: target: wasm32-unknown-unknown - - uses: taiki-e/cache-cargo-install-action@v1 + - uses: taiki-e/cache-cargo-install-action@v2 with: tool: wasm-pack@0.12.0 @@ -286,7 +286,7 @@ jobs: cargo check --manifest-path "$toml"; done - - uses: taiki-e/cache-cargo-install-action@v1 + - uses: taiki-e/cache-cargo-install-action@v2 with: tool: wasm-pack@0.12.0 From fb6bd36ca1f89a34ce98f4948f76734c52768c46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 23:33:02 +0000 Subject: [PATCH 164/246] deps: bump stun from 0.5.1 to 0.6.0 Pull-Request: #5366. --- Cargo.lock | 78 ++++++++++++++++++++++++++++-------- transports/webrtc/Cargo.toml | 2 +- 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7fab00010fb..195fc1d37fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2429,7 +2429,7 @@ dependencies = [ "tokio", "waitgroup", "webrtc-srtp", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -3446,7 +3446,7 @@ dependencies = [ "rand 0.8.5", "rcgen", "serde", - "stun", + "stun 0.6.0", "thiserror", "tinytemplate", "tokio", @@ -4452,6 +4452,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" + [[package]] name = "powerfmt" version = "0.2.0" @@ -5019,7 +5025,7 @@ checksum = "3677908cadfbecb4cc1da9a56a32524fae4ebdfa7c2ea93886e1b1e846488cb9" dependencies = [ "bytes", "thiserror", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -5048,7 +5054,7 @@ dependencies = [ "rand 0.8.5", "serde", "thiserror", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -5716,7 +5722,26 @@ dependencies = [ "thiserror", "tokio", "url", - "webrtc-util", + "webrtc-util 0.8.1", +] + +[[package]] +name = "stun" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28fad383a1cc63ae141e84e48eaef44a1063e9d9e55bcb8f51a99b886486e01b" +dependencies = [ + "base64 0.21.7", + "crc", + "lazy_static", + "md-5", + "rand 0.8.5", + "ring 0.17.8", + "subtle", + "thiserror", + "tokio", + "url", + "webrtc-util 0.9.0", ] [[package]] @@ -6300,10 +6325,10 @@ dependencies = [ "md-5", "rand 0.8.5", "ring 0.16.20", - "stun", + "stun 0.5.1", "thiserror", "tokio", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -6674,7 +6699,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "smol_str", - "stun", + "stun 0.5.1", "thiserror", "time", "tokio", @@ -6688,7 +6713,7 @@ dependencies = [ "webrtc-media", "webrtc-sctp", "webrtc-srtp", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -6702,7 +6727,7 @@ dependencies = [ "thiserror", "tokio", "webrtc-sctp", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -6737,7 +6762,7 @@ dependencies = [ "subtle", "thiserror", "tokio", - "webrtc-util", + "webrtc-util 0.8.1", "x25519-dalek", "x509-parser 0.15.1", ] @@ -6755,7 +6780,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "stun", + "stun 0.5.1", "thiserror", "tokio", "turn", @@ -6763,7 +6788,7 @@ dependencies = [ "uuid", "waitgroup", "webrtc-mdns", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -6776,7 +6801,7 @@ dependencies = [ "socket2 0.5.7", "thiserror", "tokio", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -6806,7 +6831,7 @@ dependencies = [ "rand 0.8.5", "thiserror", "tokio", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -6829,7 +6854,7 @@ dependencies = [ "subtle", "thiserror", "tokio", - "webrtc-util", + "webrtc-util 0.8.1", ] [[package]] @@ -6852,6 +6877,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "webrtc-util" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc8d9bc631768958ed97b8d68b5d301e63054ae90b09083d43e2fefb939fd77e" +dependencies = [ + "async-trait", + "bitflags 1.3.2", + "bytes", + "ipnet", + "lazy_static", + "libc", + "log", + "nix 0.26.4", + "portable-atomic", + "rand 0.8.5", + "thiserror", + "tokio", + "winapi", +] + [[package]] name = "webtransport-tests" version = "0.1.0" diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index 909f78479d9..4fb4a2f8a45 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -25,7 +25,7 @@ multihash = { workspace = true } rand = "0.8" rcgen = { workspace = true } serde = { version = "1.0", features = ["derive"] } -stun = "0.5" +stun = "0.6" thiserror = "1" tinytemplate = "1.2" tokio = { workspace = true, features = ["net"], optional = true } From b3aa10d1a93b01b6c2e8c3a7b423ddeb78093a4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 23:45:16 +0000 Subject: [PATCH 165/246] deps: bump redis from 0.23.3 to 0.24.0 Pull-Request: #4999. --- Cargo.lock | 4 ++-- hole-punching-tests/Cargo.toml | 2 +- hole-punching-tests/src/main.rs | 2 +- interop-tests/Cargo.toml | 2 +- interop-tests/src/arch.rs | 2 +- interop-tests/src/bin/wasm_ping.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 195fc1d37fd..5ac52d0059d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4773,9 +4773,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.23.3" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f49cdc0bb3f412bf8e7d1bd90fe1d9eb10bc5c399ba90973c14662a27b3f8ba" +checksum = "c580d9cbbe1d1b479e8d67cf9daf6a62c957e6846048408b80b43ac3f6af84cd" dependencies = [ "async-trait", "bytes", diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 22edd8e95ca..79728f9535c 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -11,7 +11,7 @@ env_logger = "0.10.2" futures = { workspace = true } libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] } tracing = { workspace = true } -redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] } +redis = { version = "0.24.0", default-features = false, features = ["tokio-comp"] } tokio = { workspace = true, features = ["full"] } serde = { version = "1.0.203", features = ["derive"] } serde_json = "1.0.117" diff --git a/hole-punching-tests/src/main.rs b/hole-punching-tests/src/main.rs index 4f81cd65480..f09fbb1e6a0 100644 --- a/hole-punching-tests/src/main.rs +++ b/hole-punching-tests/src/main.rs @@ -308,7 +308,7 @@ impl RedisClient { let value = self .inner - .blpop::<_, HashMap>(key, 0) + .blpop::<_, HashMap>(key, 0.0) .await? .remove(key) .with_context(|| format!("Failed to get value for {key} from redis"))? diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 5dbdafa34b1..0eb32bb4975 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -28,7 +28,7 @@ libp2p-noise = { workspace = true } libp2p-tls = { workspace = true } libp2p-webrtc = { workspace = true, features = ["tokio"] } mime_guess = "2.0" -redis = { version = "0.23.3", default-features = false, features = [ +redis = { version = "0.24.0", default-features = false, features = [ "tokio-comp", ] } rust-embed = "8.4" diff --git a/interop-tests/src/arch.rs b/interop-tests/src/arch.rs index 06d630d68d5..fb229434981 100644 --- a/interop-tests/src/arch.rs +++ b/interop-tests/src/arch.rs @@ -174,7 +174,7 @@ pub(crate) mod native { pub(crate) async fn blpop(&self, key: &str, timeout: u64) -> Result> { let mut conn = self.0.get_async_connection().await?; - Ok(conn.blpop(key, timeout as usize).await?) + Ok(conn.blpop(key, timeout as f64).await?) } pub(crate) async fn rpush(&self, key: &str, value: String) -> Result<()> { diff --git a/interop-tests/src/bin/wasm_ping.rs b/interop-tests/src/bin/wasm_ping.rs index 706fad21039..0d697a0e2a3 100644 --- a/interop-tests/src/bin/wasm_ping.rs +++ b/interop-tests/src/bin/wasm_ping.rs @@ -151,7 +151,7 @@ async fn redis_blpop( StatusCode::INTERNAL_SERVER_ERROR })?; let res = conn - .blpop(&request.key, request.timeout as usize) + .blpop(&request.key, request.timeout as f64) .await .map_err(|e| { tracing::warn!( From 362c3d334901ff81efc11b120272c1df2d657766 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 00:15:12 +0000 Subject: [PATCH 166/246] deps: bump sysinfo from 0.29.11 to 0.30.5 Pull-Request: #5061. --- Cargo.lock | 49 +++++++++++-------- misc/memory-connection-limits/Cargo.toml | 2 +- misc/memory-connection-limits/src/lib.rs | 9 ++-- .../tests/max_percentage.rs | 6 ++- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ac52d0059d..d875724764a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1118,16 +1118,6 @@ dependencies = [ "itertools", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -2352,7 +2342,7 @@ dependencies = [ "smol", "system-configuration", "tokio", - "windows", + "windows 0.51.1", ] [[package]] @@ -4738,9 +4728,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -4748,14 +4738,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -5818,9 +5806,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.29.11" +version = "0.30.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd727fc423c2060f6c92d9534cef765c65a6ed3f428a03d7def74a8c4348e666" +checksum = "1fb4f3438c8f6389c864e61221cbc97e9bca98b4daf39a5beb7bea660f528bb2" dependencies = [ "cfg-if", "core-foundation-sys", @@ -5828,7 +5816,7 @@ dependencies = [ "ntapi", "once_cell", "rayon", - "winapi", + "windows 0.52.0", ] [[package]] @@ -6959,10 +6947,20 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows-core", + "windows-core 0.51.1", "windows-targets 0.48.5", ] +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core 0.52.0", + "windows-targets 0.52.0", +] + [[package]] name = "windows-core" version = "0.51.1" @@ -6972,6 +6970,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/misc/memory-connection-limits/Cargo.toml b/misc/memory-connection-limits/Cargo.toml index 5f8d9b91613..9f7406599e7 100644 --- a/misc/memory-connection-limits/Cargo.toml +++ b/misc/memory-connection-limits/Cargo.toml @@ -14,7 +14,7 @@ memory-stats = { version = "1", features = ["always_use_statm"] } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true, features = ["peerid"] } -sysinfo = "0.29" +sysinfo = "0.30" tracing = { workspace = true } void = "1" diff --git a/misc/memory-connection-limits/src/lib.rs b/misc/memory-connection-limits/src/lib.rs index ac911654979..08c45154221 100644 --- a/misc/memory-connection-limits/src/lib.rs +++ b/misc/memory-connection-limits/src/lib.rs @@ -31,6 +31,7 @@ use std::{ task::{Context, Poll}, time::{Duration, Instant}, }; +use sysinfo::MemoryRefreshKind; /// A [`NetworkBehaviour`] that enforces a set of memory usage based limits. /// @@ -90,10 +91,12 @@ impl Behaviour { /// /// New inbound and outbound connections will be denied when the threshold is reached. pub fn with_max_percentage(percentage: f64) -> Self { - use sysinfo::{RefreshKind, SystemExt}; + use sysinfo::{RefreshKind, System}; - let system_memory_bytes = - sysinfo::System::new_with_specifics(RefreshKind::new().with_memory()).total_memory(); + let system_memory_bytes = System::new_with_specifics( + RefreshKind::new().with_memory(MemoryRefreshKind::new().with_ram()), + ) + .total_memory(); Self::with_max_bytes((system_memory_bytes as f64 * percentage).round() as usize) } diff --git a/misc/memory-connection-limits/tests/max_percentage.rs b/misc/memory-connection-limits/tests/max_percentage.rs index daee20703ee..bfb1b504af5 100644 --- a/misc/memory-connection-limits/tests/max_percentage.rs +++ b/misc/memory-connection-limits/tests/max_percentage.rs @@ -24,7 +24,7 @@ use libp2p_core::Multiaddr; use libp2p_identity::PeerId; use libp2p_memory_connection_limits::*; use std::time::Duration; -use sysinfo::{RefreshKind, SystemExt}; +use sysinfo::{MemoryRefreshKind, RefreshKind}; use util::*; use libp2p_swarm::{ @@ -36,7 +36,9 @@ use libp2p_swarm_test::SwarmExt; #[test] fn max_percentage() { const CONNECTION_LIMIT: usize = 20; - let system_info = sysinfo::System::new_with_specifics(RefreshKind::new().with_memory()); + let system_info = sysinfo::System::new_with_specifics( + RefreshKind::new().with_memory(MemoryRefreshKind::new().with_ram()), + ); let mut network = Swarm::new_ephemeral(|_| TestBehaviour { connection_limits: Behaviour::with_max_percentage(0.1), From 87b939402cfc893572918d65ffa88736620bd209 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 00:39:10 +0000 Subject: [PATCH 167/246] deps: bump the hickory-dns group with 3 updates Pull-Request: #5330. --- Cargo.lock | 12 ++++++------ protocols/mdns/Cargo.toml | 2 +- transports/dns/Cargo.toml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d875724764a..d680af5ea42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -428,9 +428,9 @@ dependencies = [ [[package]] name = "async-std-resolver" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0ed2b6671c13d2c28756c5a64e04759c1e0b5d3d7ac031f521c3561e21fbcb" +checksum = "bc3b454643291f9a4a3bbdb35fa62efa4ba7be5ea13fe243e3be4352182ff4b8" dependencies = [ "async-std", "async-trait", @@ -1984,9 +1984,9 @@ checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" [[package]] name = "hickory-proto" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "091a6fbccf4860009355e3efc52ff4acf37a63489aad7435372d44ceeb6fbbcf" +checksum = "07698b8420e2f0d6447a436ba999ec85d8fbf2a398bbd737b82cac4a2e96e512" dependencies = [ "async-trait", "cfg-if", @@ -2009,9 +2009,9 @@ dependencies = [ [[package]] name = "hickory-resolver" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35b8f021164e6a984c9030023544c57789c51760065cd510572fedcfb04164e8" +checksum = "28757f23aa75c98f254cf0405e6d8c25b831b32921b050a66692427679b1f243" dependencies = [ "cfg-if", "futures-util", diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 0d58c9467c4..56741463d6b 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -24,7 +24,7 @@ smallvec = "1.13.2" socket2 = { version = "0.5.7", features = ["all"] } tokio = { workspace = true, default-features = false, features = ["net", "time"], optional = true} tracing = { workspace = true } -hickory-proto = { version = "0.24.0", default-features = false, features = ["mdns"] } +hickory-proto = { version = "0.24.1", default-features = false, features = ["mdns"] } void = "1.0.2" [features] diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index 105fe0a62d0..1e50ad444b8 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -17,7 +17,7 @@ futures = { workspace = true } libp2p-core = { workspace = true } libp2p-identity = { workspace = true } parking_lot = "0.12.3" -hickory-resolver = { version = "0.24.0", default-features = false, features = ["system-config"] } +hickory-resolver = { version = "0.24.1", default-features = false, features = ["system-config"] } smallvec = "1.13.2" tracing = { workspace = true } From 43524e7bf04c27ace76d128fa48407a61eb690d2 Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Thu, 13 Jun 2024 04:37:03 -0600 Subject: [PATCH 168/246] feat(swarm): add `peer_id` to `ListenFailure` It's possible in certain failure modes to know the peer_id of a failed incoming connection. For example when an inbound connection has been negotiated/upgraded but then rejected locally for a connection limit or similar reason. In these cases it makes sense to communicate the peer_id to behaviours in case they have created any internal state about the peer. Related https://github.com/libp2p/rust-libp2p/pull/4777 Pull-Request: #4818. --- Cargo.lock | 2 +- Cargo.toml | 2 +- swarm/CHANGELOG.md | 5 ++++- swarm/Cargo.toml | 2 +- swarm/src/behaviour.rs | 9 ++++++++- swarm/src/lib.rs | 3 +++ 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d680af5ea42..367d37b0ec2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3292,7 +3292,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.44.3" +version = "0.45.0" dependencies = [ "async-std", "either", diff --git a/Cargo.toml b/Cargo.toml index 822c1692960..bf57480bbbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,7 +102,7 @@ libp2p-rendezvous = { version = "0.14.1", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.26.4", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } -libp2p-swarm = { version = "0.44.3", path = "swarm" } +libp2p-swarm = { version = "0.45.0", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } libp2p-tcp = { version = "0.41.1", path = "transports/tcp" } diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 8cded416628..1b53ee9b937 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,4 +1,7 @@ -## 0.44.3 +## 0.45.0 + +- Add peer_id to `FromSwarm::ListenFailure`. + See [PR 4818](https://github.com/libp2p/rust-libp2p/pull/4818). - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 338cbf91641..60cf58cb495 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition = "2021" rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.44.3" +version = "0.45.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index 5070871a4c1..fc9045dfc3f 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -148,6 +148,9 @@ pub trait NetworkBehaviour: 'static { /// At this point, we have verified their [`PeerId`] and we know, which particular [`Multiaddr`] succeeded in the dial. /// In order to actually use this connection, this function must return a [`ConnectionHandler`]. /// Returning an error will immediately close the connection. + /// + /// Note when any composed behaviour returns an error the connection will be closed and a + /// [`FromSwarm::ListenFailure`] event will be emitted. fn handle_established_inbound_connection( &mut self, _connection_id: ConnectionId, @@ -184,6 +187,9 @@ pub trait NetworkBehaviour: 'static { /// At this point, we have verified their [`PeerId`] and we know, which particular [`Multiaddr`] succeeded in the dial. /// In order to actually use this connection, this function must return a [`ConnectionHandler`]. /// Returning an error will immediately close the connection. + /// + /// Note when any composed behaviour returns an error the connection will be closed and a + /// [`FromSwarm::DialFailure`] event will be emitted. fn handle_established_outbound_connection( &mut self, _connection_id: ConnectionId, @@ -269,7 +275,7 @@ pub enum ToSwarm { /// The emphasis on a **new** candidate is important. /// Protocols MUST take care to only emit a candidate once per "source". /// For example, the observed address of a TCP connection does not change throughout its lifetime. - /// Thus, only one candidate should be emitted per connection. + /// Thus, only one candidate should be emitted per connection. /// /// This makes the report frequency of an address a meaningful data-point for consumers of this event. /// This address will be shared with all [`NetworkBehaviour`]s via [`FromSwarm::NewExternalAddrCandidate`]. @@ -508,6 +514,7 @@ pub struct ListenFailure<'a> { pub send_back_addr: &'a Multiaddr, pub error: &'a ListenError, pub connection_id: ConnectionId, + pub peer_id: Option, } /// [`FromSwarm`] variant that informs the behaviour that a new listener was created. diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index cf2961cef6d..ec5b7a109cc 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -754,6 +754,7 @@ where send_back_addr: &send_back_addr, error: &listen_error, connection_id: id, + peer_id: Some(peer_id), }, )); @@ -867,6 +868,7 @@ where send_back_addr: &send_back_addr, error: &error, connection_id: id, + peer_id: None, })); self.pending_swarm_events .push_back(SwarmEvent::IncomingConnectionError { @@ -970,6 +972,7 @@ where send_back_addr: &send_back_addr, error: &listen_error, connection_id, + peer_id: None, })); self.pending_swarm_events From a35e269645f9d5f618b2817adff4c82f255804ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 13 Jun 2024 13:51:59 +0100 Subject: [PATCH 169/246] feat(tcp): make TCP_NODELAY the default Superseeds #4916. Fixes: #4890. Pull-Request: #5469. --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 2 +- transports/tcp/CHANGELOG.md | 4 +++- transports/tcp/Cargo.toml | 2 +- transports/tcp/src/lib.rs | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 367d37b0ec2..efa620c9f41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -428,9 +428,9 @@ dependencies = [ [[package]] name = "async-std-resolver" -version = "0.24.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc3b454643291f9a4a3bbdb35fa62efa4ba7be5ea13fe243e3be4352182ff4b8" +checksum = "3c0ed2b6671c13d2c28756c5a64e04759c1e0b5d3d7ac031f521c3561e21fbcb" dependencies = [ "async-std", "async-trait", @@ -3353,7 +3353,7 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.41.1" +version = "0.42.0" dependencies = [ "async-io 2.3.3", "async-std", @@ -4728,9 +4728,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -4738,9 +4738,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -5806,9 +5806,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.30.5" +version = "0.30.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb4f3438c8f6389c864e61221cbc97e9bca98b4daf39a5beb7bea660f528bb2" +checksum = "732ffa00f53e6b2af46208fba5718d9662a421049204e156328b66791ffa15ae" dependencies = [ "cfg-if", "core-foundation-sys", diff --git a/Cargo.toml b/Cargo.toml index bf57480bbbe..3f7d8ab7c0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,7 +105,7 @@ libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } libp2p-swarm = { version = "0.45.0", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } -libp2p-tcp = { version = "0.41.1", path = "transports/tcp" } +libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } libp2p-tls = { version = "0.4.0", path = "transports/tls" } libp2p-uds = { version = "0.40.0", path = "transports/uds" } libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } diff --git a/transports/tcp/CHANGELOG.md b/transports/tcp/CHANGELOG.md index 36ed93a0f5b..f0204f1ba85 100644 --- a/transports/tcp/CHANGELOG.md +++ b/transports/tcp/CHANGELOG.md @@ -1,5 +1,7 @@ -## 0.41.1 +## 0.42.0 +- Disable Nagle's algorithm (i.e. `TCP_NODELAY`) by default. + See [PR 4916](https://github.com/libp2p/rust-libp2p/pull/4916) ## 0.41.0 diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 7f0cf5ca943..b17d7f3b58e 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-tcp" edition = "2021" rust-version = { workspace = true } description = "TCP/IP transport protocol for libp2p" -version = "0.41.1" +version = "0.42.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/tcp/src/lib.rs b/transports/tcp/src/lib.rs index c8f0410d9e5..3d881a6421c 100644 --- a/transports/tcp/src/lib.rs +++ b/transports/tcp/src/lib.rs @@ -161,7 +161,7 @@ impl Config { pub fn new() -> Self { Self { ttl: None, - nodelay: None, + nodelay: Some(false), // Disable Nagle's algorithm by default backlog: 1024, enable_port_reuse: false, } From a8a49570ba296b0c01088424893cb3143856c1d6 Mon Sep 17 00:00:00 2001 From: Hannes <55623006+umgefahren@users.noreply.github.com> Date: Mon, 17 Jun 2024 20:39:20 +0900 Subject: [PATCH 170/246] chore: Update cargo semver I updated the semver version so it makes the CI run again Pull-Request: #5470. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a19cdce6558..3e6d8c7fdaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -308,7 +308,7 @@ jobs: RUSTFLAGS: '' steps: - uses: actions/checkout@v4 - - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.27.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin + - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.31.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin shell: bash - uses: obi1kenobi/cargo-semver-checks-action@c7306483f698c511eaf7416d1bf2e1958c90140f # v2 From 0b1733d4db065e0236a28f8628d9b401b9645001 Mon Sep 17 00:00:00 2001 From: Darius Clark Date: Tue, 18 Jun 2024 09:43:24 -0400 Subject: [PATCH 171/246] refactor: remove redundant async signature Resolves #4832 Pull-Request: #5468. --- libp2p/CHANGELOG.md | 3 +++ libp2p/src/builder/phase/dns.rs | 3 +-- libp2p/src/builder/phase/other_transport.rs | 4 ++-- libp2p/src/builder/phase/quic.rs | 3 +-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index ed3ecbe2f20..23efbc21fd9 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -9,6 +9,9 @@ - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). +- Remove redundant async signature from builder methods. + See [PR 5468](https://github.com/libp2p/rust-libp2p/pull/5468). + ## 0.53.2 - Allow `SwarmBuilder::with_bandwidth_metrics` after `SwarmBuilder::with_websocket`. diff --git a/libp2p/src/builder/phase/dns.rs b/libp2p/src/builder/phase/dns.rs index 135f6c57b19..638064d58bb 100644 --- a/libp2p/src/builder/phase/dns.rs +++ b/libp2p/src/builder/phase/dns.rs @@ -8,8 +8,7 @@ pub struct DnsPhase { #[cfg(all(not(target_arch = "wasm32"), feature = "async-std", feature = "dns"))] impl SwarmBuilder> { - // TODO: Remove `async` - pub async fn with_dns( + pub fn with_dns( self, ) -> Result< SwarmBuilder< diff --git a/libp2p/src/builder/phase/other_transport.rs b/libp2p/src/builder/phase/other_transport.rs index b0d56cd92d2..e04621b2e3f 100644 --- a/libp2p/src/builder/phase/other_transport.rs +++ b/libp2p/src/builder/phase/other_transport.rs @@ -73,7 +73,7 @@ impl impl SwarmBuilder> { - pub async fn with_dns( + pub fn with_dns( self, ) -> Result< SwarmBuilder< @@ -82,7 +82,7 @@ impl >, std::io::Error, > { - self.without_any_other_transports().with_dns().await + self.without_any_other_transports().with_dns() } } #[cfg(all(not(target_arch = "wasm32"), feature = "tokio", feature = "dns"))] diff --git a/libp2p/src/builder/phase/quic.rs b/libp2p/src/builder/phase/quic.rs index 885b16e2e03..e030e9493bb 100644 --- a/libp2p/src/builder/phase/quic.rs +++ b/libp2p/src/builder/phase/quic.rs @@ -150,7 +150,7 @@ impl SwarmBuilder SwarmBuilder> { - pub async fn with_dns( + pub fn with_dns( self, ) -> Result< SwarmBuilder< @@ -162,7 +162,6 @@ impl SwarmBuilder Date: Tue, 18 Jun 2024 19:59:44 +0200 Subject: [PATCH 172/246] fix(kad): correctly handle `NoKnownPeers` error when bootstrap After testing `master`, we encountered a bug due to #4838 when doing automatic or periodic bootstrap if the node has no known peers. Since it failed immediately, I though there was no need to call the `bootstrap_status.on_started` method. But not doing so never resets the periodic timer inside `bootstrap_status` resulting in getting stuck to try to bootstrap every time `poll` is called on `kad::Behaviour`. Pull-Request: #5349. --- protocols/kad/CHANGELOG.md | 2 ++ protocols/kad/src/behaviour.rs | 1 + protocols/kad/src/bootstrap.rs | 18 +++++++++++------- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 1d124fb37a2..5cd537cae9e 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -19,6 +19,8 @@ See [PR 5317](https://github.com/libp2p/rust-libp2p/pull/5317). - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). +- Correctly handle the `NoKnownPeers` error on automatic bootstrap. + See [PR 5349](https://github.com/libp2p/rust-libp2p/pull/5349). ## 0.45.3 diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 5d8a8bb0fd8..c9690d2c873 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -939,6 +939,7 @@ where }; let peers = self.kbuckets.closest_keys(&local_key).collect::>(); if peers.is_empty() { + self.bootstrap_status.reset_timers(); Err(NoKnownPeers()) } else { self.bootstrap_status.on_started(); diff --git a/protocols/kad/src/bootstrap.rs b/protocols/kad/src/bootstrap.rs index bcb9d0cccf3..fd9e3d41be6 100644 --- a/protocols/kad/src/bootstrap.rs +++ b/protocols/kad/src/bootstrap.rs @@ -61,19 +61,23 @@ impl Status { } } + pub(crate) fn reset_timers(&mut self) { + // Canceling the `throttle_timer` if any and resetting the `delay` if any. + self.throttle_timer = None; + + if let Some((interval, delay)) = self.interval_and_delay.as_mut() { + delay.reset(*interval); + } + } + pub(crate) fn on_started(&mut self) { // No periodic or automatic bootstrap will be triggered as long as // `self.current_bootstrap_requests > 0` but the user could still manually // trigger a bootstrap. self.current_bootstrap_requests += 1; - // Canceling the `throttle_timer` if any since a bootstrap request is being triggered right now. - self.throttle_timer = None; - - // Resetting the `delay` if any since a bootstrap request is being triggered right now. - if let Some((interval, delay)) = self.interval_and_delay.as_mut() { - delay.reset(*interval); - } + // Resetting the Status timers since a bootstrap request is being triggered right now. + self.reset_timers(); } pub(crate) fn on_finish(&mut self) { From 605f20846280679e26e72e34efabfb3603aed678 Mon Sep 17 00:00:00 2001 From: stormshield-frb <144998884+stormshield-frb@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:41:19 +0200 Subject: [PATCH 173/246] feat(identify): add connection_id in event Fixes: #4980. Pull-Request: #4981. --- Cargo.lock | 2 +- Cargo.toml | 2 +- libp2p/CHANGELOG.md | 1 + misc/server/CHANGELOG.md | 2 ++ misc/server/src/main.rs | 1 + protocols/identify/CHANGELOG.md | 5 ++++ protocols/identify/Cargo.toml | 2 +- protocols/identify/src/behaviour.rs | 46 +++++++++++++++++++++++------ 8 files changed, 49 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efa620c9f41..67d0c3fb59b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2837,7 +2837,7 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.44.2" +version = "0.45.0" dependencies = [ "async-std", "asynchronous-codec", diff --git a/Cargo.toml b/Cargo.toml index 3f7d8ab7c0d..76bb4f18b3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,7 @@ libp2p-dcutr = { version = "0.11.1", path = "protocols/dcutr" } libp2p-dns = { version = "0.41.1", path = "transports/dns" } libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" } -libp2p-identify = { version = "0.44.2", path = "protocols/identify" } +libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.46.0", path = "protocols/kad" } libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" } diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index 23efbc21fd9..977d9f91924 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -2,6 +2,7 @@ - Update individual crates. - Update to [`libp2p-kad` `v0.46.0`](protocols/kad/CHANGELOG.md#0460). + - Update to [`libp2p-identify` `v0.45.0`](protocols/identify/CHANGELOG.md#0450). - Raise MSRV to 1.73. See [PR 5266](https://github.com/libp2p/rust-libp2p/pull/5266). diff --git a/misc/server/CHANGELOG.md b/misc/server/CHANGELOG.md index 254ab1d92be..5369163460c 100644 --- a/misc/server/CHANGELOG.md +++ b/misc/server/CHANGELOG.md @@ -4,6 +4,8 @@ - Use periodic and automatic bootstrap of Kademlia. See [PR 4838](https://github.com/libp2p/rust-libp2p/pull/4838). +- Update to [`libp2p-identify` `v0.45.0`](protocols/identify/CHANGELOG.md#0450). + See [PR 4981](https://github.com/libp2p/rust-libp2p/pull/4981). ## 0.12.6 diff --git a/misc/server/src/main.rs b/misc/server/src/main.rs index 6dfa035f3b1..eb28b9ad5c2 100644 --- a/misc/server/src/main.rs +++ b/misc/server/src/main.rs @@ -138,6 +138,7 @@ async fn main() -> Result<(), Box> { protocols, .. }, + .. } = e { if protocols.iter().any(|p| *p == kad::PROTOCOL_NAME) { diff --git a/protocols/identify/CHANGELOG.md b/protocols/identify/CHANGELOG.md index 83984448d07..b8ab3f8df50 100644 --- a/protocols/identify/CHANGELOG.md +++ b/protocols/identify/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.45.0 + +- Add `ConnectionId` in `Event`. + See [PR 4981](https://github.com/libp2p/rust-libp2p/pull/4981). + ## 0.44.2 - Emit `ToSwarm::NewExternalAddrOfPeer` for all external addresses of remote peers. diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 86425d580e9..320c8465650 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-identify" edition = "2021" rust-version = { workspace = true } description = "Nodes identification protocol for libp2p" -version = "0.44.2" +version = "0.45.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/identify/src/behaviour.rs b/protocols/identify/src/behaviour.rs index 43bddb52fe7..92a0dc46103 100644 --- a/protocols/identify/src/behaviour.rs +++ b/protocols/identify/src/behaviour.rs @@ -258,7 +258,7 @@ impl NetworkBehaviour for Behaviour { fn on_connection_handler_event( &mut self, peer_id: PeerId, - id: ConnectionId, + connection_id: ConnectionId, event: THandlerOutEvent, ) { match event { @@ -270,6 +270,7 @@ impl NetworkBehaviour for Behaviour { let observed = info.observed_addr.clone(); self.events .push_back(ToSwarm::GenerateEvent(Event::Received { + connection_id, peer_id, info: info.clone(), })); @@ -285,7 +286,7 @@ impl NetworkBehaviour for Behaviour { } } - match self.our_observed_addresses.entry(id) { + match self.our_observed_addresses.entry(connection_id) { Entry::Vacant(not_yet_observed) => { not_yet_observed.insert(observed.clone()); self.events @@ -298,7 +299,7 @@ impl NetworkBehaviour for Behaviour { tracing::info!( old_address=%already_observed.get(), new_address=%observed, - "Our observed address on connection {id} changed", + "Our observed address on connection {connection_id} changed", ); *already_observed.get_mut() = observed.clone(); @@ -308,16 +309,24 @@ impl NetworkBehaviour for Behaviour { } } handler::Event::Identification => { - self.events - .push_back(ToSwarm::GenerateEvent(Event::Sent { peer_id })); + self.events.push_back(ToSwarm::GenerateEvent(Event::Sent { + connection_id, + peer_id, + })); } handler::Event::IdentificationPushed(info) => { - self.events - .push_back(ToSwarm::GenerateEvent(Event::Pushed { peer_id, info })); + self.events.push_back(ToSwarm::GenerateEvent(Event::Pushed { + connection_id, + peer_id, + info, + })); } handler::Event::IdentificationError(error) => { - self.events - .push_back(ToSwarm::GenerateEvent(Event::Error { peer_id, error })); + self.events.push_back(ToSwarm::GenerateEvent(Event::Error { + connection_id, + peer_id, + error, + })); } } } @@ -415,6 +424,8 @@ impl NetworkBehaviour for Behaviour { pub enum Event { /// Identification information has been received from a peer. Received { + /// Identifier of the connection. + connection_id: ConnectionId, /// The peer that has been identified. peer_id: PeerId, /// The information provided by the peer. @@ -423,12 +434,16 @@ pub enum Event { /// Identification information of the local node has been sent to a peer in /// response to an identification request. Sent { + /// Identifier of the connection. + connection_id: ConnectionId, /// The peer that the information has been sent to. peer_id: PeerId, }, /// Identification information of the local node has been actively pushed to /// a peer. Pushed { + /// Identifier of the connection. + connection_id: ConnectionId, /// The peer that the information has been sent to. peer_id: PeerId, /// The full Info struct we pushed to the remote peer. Clients must @@ -437,6 +452,8 @@ pub enum Event { }, /// Error while attempting to identify the remote. Error { + /// Identifier of the connection. + connection_id: ConnectionId, /// The peer with whom the error originated. peer_id: PeerId, /// The error that occurred. @@ -444,6 +461,17 @@ pub enum Event { }, } +impl Event { + pub fn connection_id(&self) -> ConnectionId { + match self { + Event::Received { connection_id, .. } + | Event::Sent { connection_id, .. } + | Event::Pushed { connection_id, .. } + | Event::Error { connection_id, .. } => *connection_id, + } + } +} + /// If there is a given peer_id in the multiaddr, make sure it is the same as /// the given peer_id. If there is no peer_id for the peer in the mutiaddr, this returns true. fn multiaddr_matches_peer_id(addr: &Multiaddr, peer_id: &PeerId) -> bool { From e28de77f32b2c550c6b627e2d1006290bb74657d Mon Sep 17 00:00:00 2001 From: Adam Wierzbicki Date: Fri, 21 Jun 2024 13:03:41 +0200 Subject: [PATCH 174/246] feat(kad): Return multiaddrs alognside peer IDs Pull-Request: #5475. --- Cargo.lock | 4 +-- Cargo.toml | 4 +-- core/CHANGELOG.md | 4 +++ core/Cargo.toml | 2 +- core/src/lib.rs | 8 ++++++ protocols/kad/CHANGELOG.md | 4 +++ protocols/kad/Cargo.toml | 2 +- protocols/kad/src/behaviour.rs | 41 ++++++++++++++++++++++------- protocols/kad/src/behaviour/test.rs | 8 +++--- 9 files changed, 58 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67d0c3fb59b..c71837e0e94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2697,7 +2697,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.41.3" +version = "0.41.4" dependencies = [ "async-std", "either", @@ -2890,7 +2890,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.46.0" +version = "0.47.0" dependencies = [ "arrayvec", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 76bb4f18b3d..88f09be43b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,14 +78,14 @@ libp2p = { version = "0.54.0", path = "libp2p" } libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" } libp2p-autonat = { version = "0.12.1", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.3.1", path = "misc/connection-limits" } -libp2p-core = { version = "0.41.3", path = "core" } +libp2p-core = { version = "0.41.4", path = "core" } libp2p-dcutr = { version = "0.11.1", path = "protocols/dcutr" } libp2p-dns = { version = "0.41.1", path = "transports/dns" } libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" } libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } -libp2p-kad = { version = "0.46.0", path = "protocols/kad" } +libp2p-kad = { version = "0.47.0", path = "protocols/kad" } libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.14.2", path = "misc/metrics" } diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 633b627d41d..0c3b81cd3e5 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.41.4 +- Add `PeerInfo` struct. + See [PR 5475](https://github.com/libp2p/rust-libp2p/pull/5475) + ## 0.41.3 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/core/Cargo.toml b/core/Cargo.toml index 6831eb54c94..048988c75b0 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-core" edition = "2021" rust-version = { workspace = true } description = "Core traits and structs of libp2p" -version = "0.41.3" +version = "0.41.4" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/core/src/lib.rs b/core/src/lib.rs index abb83481d6c..73a4382c315 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -56,6 +56,7 @@ pub mod transport; pub mod upgrade; pub use connection::{ConnectedPoint, Endpoint}; +pub use libp2p_identity::PeerId; pub use multiaddr::Multiaddr; pub use multihash; pub use muxing::StreamMuxer; @@ -68,3 +69,10 @@ pub use upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; #[derive(Debug, thiserror::Error)] #[error(transparent)] pub struct DecodeError(quick_protobuf::Error); + +/// Peer Info combines a Peer ID with a set of multiaddrs that the peer is listening on. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct PeerInfo { + pub peer_id: PeerId, + pub addrs: Vec, +} diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 5cd537cae9e..d26a58715b3 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.47.0 +- Included multiaddresses of found peers alongside peer IDs in `GetClosestPeers` query results. + See [PR 5475](https://github.com/libp2p/rust-libp2p/pull/5475) + ## 0.46.0 - Changed `FIND_NODE` response: now includes a list of closest peers when querying the recipient peer ID. Previously, this request yielded an empty response. diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 494d812c6ec..04d78a9947d 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-kad" edition = "2021" rust-version = { workspace = true } description = "Kademlia protocol for libp2p" -version = "0.46.0" +version = "0.47.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index c9690d2c873..ce81c2e8dca 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -36,7 +36,7 @@ use crate::record::{ use crate::K_VALUE; use crate::{jobs::*, protocol}; use fnv::{FnvHashMap, FnvHashSet}; -use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; +use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr, PeerInfo}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::{ AddressChange, ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm, @@ -1390,7 +1390,7 @@ where fn query_finished(&mut self, q: Query) -> Option { let query_id = q.id(); tracing::trace!(query=?query_id, "Query finished"); - let result = q.into_result(); + let mut result = q.into_result(); match result.inner.info { QueryInfo::Bootstrap { peer, @@ -1466,14 +1466,23 @@ where QueryInfo::GetClosestPeers { key, mut step } => { step.last = true; + let peers = result + .peers + .map(|peer_id| { + let addrs = result + .inner + .addresses + .remove(&peer_id) + .unwrap_or_default() + .to_vec(); + PeerInfo { peer_id, addrs } + }) + .collect(); Some(Event::OutboundQueryProgressed { id: query_id, stats: result.stats, - result: QueryResult::GetClosestPeers(Ok(GetClosestPeersOk { - key, - peers: result.peers.collect(), - })), + result: QueryResult::GetClosestPeers(Ok(GetClosestPeersOk { key, peers })), step, }) } @@ -1629,7 +1638,7 @@ where fn query_timeout(&mut self, query: Query) -> Option { let query_id = query.id(); tracing::trace!(query=?query_id, "Query timed out"); - let result = query.into_result(); + let mut result = query.into_result(); match result.inner.info { QueryInfo::Bootstrap { peer, @@ -1684,13 +1693,25 @@ where QueryInfo::GetClosestPeers { key, mut step } => { step.last = true; + let peers = result + .peers + .map(|peer_id| { + let addrs = result + .inner + .addresses + .remove(&peer_id) + .unwrap_or_default() + .to_vec(); + PeerInfo { peer_id, addrs } + }) + .collect(); Some(Event::OutboundQueryProgressed { id: query_id, stats: result.stats, result: QueryResult::GetClosestPeers(Err(GetClosestPeersError::Timeout { key, - peers: result.peers.collect(), + peers, })), step, }) @@ -2978,14 +2999,14 @@ pub type GetClosestPeersResult = Result #[derive(Debug, Clone)] pub struct GetClosestPeersOk { pub key: Vec, - pub peers: Vec, + pub peers: Vec, } /// The error result of [`Behaviour::get_closest_peers`]. #[derive(Debug, Clone, Error)] pub enum GetClosestPeersError { #[error("the request timed out")] - Timeout { key: Vec, peers: Vec }, + Timeout { key: Vec, peers: Vec }, } impl GetClosestPeersError { diff --git a/protocols/kad/src/behaviour/test.rs b/protocols/kad/src/behaviour/test.rs index 7005f39e5e6..a3ff43ded6e 100644 --- a/protocols/kad/src/behaviour/test.rs +++ b/protocols/kad/src/behaviour/test.rs @@ -294,9 +294,11 @@ fn query_iter() { assert_eq!(&ok.key[..], search_target.to_bytes().as_slice()); assert_eq!(swarm_ids[i], expected_swarm_id); assert_eq!(swarm.behaviour_mut().queries.size(), 0); - assert!(expected_peer_ids.iter().all(|p| ok.peers.contains(p))); + let peer_ids = + ok.peers.into_iter().map(|p| p.peer_id).collect::>(); + assert!(expected_peer_ids.iter().all(|p| peer_ids.contains(p))); let key = kbucket::Key::new(ok.key); - assert_eq!(expected_distances, distances(&key, ok.peers)); + assert_eq!(expected_distances, distances(&key, peer_ids)); return Poll::Ready(()); } // Ignore any other event. @@ -408,7 +410,7 @@ fn unresponsive_not_returned_indirect() { }))) => { assert_eq!(&ok.key[..], search_target.to_bytes().as_slice()); assert_eq!(ok.peers.len(), 1); - assert_eq!(ok.peers[0], first_peer_id); + assert_eq!(ok.peers[0].peer_id, first_peer_id); return Poll::Ready(()); } // Ignore any other event. From 3759e190d1e2e83f87d4be191ea7d6f747d31b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Tue, 25 Jun 2024 12:56:17 +0100 Subject: [PATCH 175/246] fix: update Cargo.lock To address [RUSTSEC-2024-0344](https://rustsec.org/advisories/RUSTSEC-2024-0344) Pull-Request: #5477. --- Cargo.lock | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c71837e0e94..2bf774b1fd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1212,16 +1212,15 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.1.2" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "platforms", "rustc_version", "subtle", "zeroize", @@ -4355,12 +4354,6 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" -[[package]] -name = "platforms" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" - [[package]] name = "plotters" version = "0.3.5" From d1025d258727ef76bc888af5cafa49aab9a1e935 Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Tue, 25 Jun 2024 17:00:22 +0200 Subject: [PATCH 176/246] fix(kad): changelog Correct `kad` changelog after https://github.com/libp2p/rust-libp2p/pull/5475 `kad` `0.46.0` isn't released yet, hence changelog entry from https://github.com/libp2p/rust-libp2p/pull/5475 will be published with `0.46.0`. Pull-Request: #5478. --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/kad/CHANGELOG.md | 6 ++---- protocols/kad/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2bf774b1fd9..3521b7e4535 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2889,7 +2889,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.47.0" +version = "0.46.0" dependencies = [ "arrayvec", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 88f09be43b1..ca85cb1ae5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,7 +85,7 @@ libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" } libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } -libp2p-kad = { version = "0.47.0", path = "protocols/kad" } +libp2p-kad = { version = "0.46.0", path = "protocols/kad" } libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.14.2", path = "misc/metrics" } diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index d26a58715b3..b31797b196d 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,9 +1,7 @@ -## 0.47.0 -- Included multiaddresses of found peers alongside peer IDs in `GetClosestPeers` query results. - See [PR 5475](https://github.com/libp2p/rust-libp2p/pull/5475) - ## 0.46.0 +- Included multiaddresses of found peers alongside peer IDs in `GetClosestPeers` query results. + See [PR 5475](https://github.com/libp2p/rust-libp2p/pull/5475) - Changed `FIND_NODE` response: now includes a list of closest peers when querying the recipient peer ID. Previously, this request yielded an empty response. See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270) - Update to DHT republish interval and expiration time defaults to 22h and 48h respectively, rationale in [libp2p/specs#451](https://github.com/libp2p/specs/pull/451) diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 04d78a9947d..494d812c6ec 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-kad" edition = "2021" rust-version = { workspace = true } description = "Kademlia protocol for libp2p" -version = "0.47.0" +version = "0.46.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" From df59f4f590b5d171e07cd7435f17bc7c1087ee5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:16:51 +0000 Subject: [PATCH 177/246] deps: bump docker/build-push-action from 5 to 6 Pull-Request: #5473. --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b9cd82897c2..21863d0ed39 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -30,7 +30,7 @@ jobs: images: ghcr.io/${{ github.repository }}-server - name: Build and push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . file: ./misc/server/Dockerfile From 63313f44f02e266488bd473a2c97691dbfe30236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 27 Jun 2024 09:05:49 +0100 Subject: [PATCH 178/246] chore(kad): remove unrequired generics Remove the unrequired generics in `kad` and refactor the code for less duplication. Please review by commit order as it will be easier to understand each commit's rational and logic Pull-Request: #5476. --- Cargo.lock | 2 +- Cargo.toml | 2 +- core/CHANGELOG.md | 6 +- core/Cargo.toml | 6 +- core/src/lib.rs | 7 - protocols/kad/src/behaviour.rs | 209 ++++++++++------------------ protocols/kad/src/behaviour/test.rs | 4 +- protocols/kad/src/lib.rs | 6 +- protocols/kad/src/query.rs | 142 +++++++++++-------- 9 files changed, 170 insertions(+), 214 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3521b7e4535..9b25b574a46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2696,7 +2696,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.41.4" +version = "0.41.3" dependencies = [ "async-std", "either", diff --git a/Cargo.toml b/Cargo.toml index ca85cb1ae5d..76bb4f18b3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,7 +78,7 @@ libp2p = { version = "0.54.0", path = "libp2p" } libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" } libp2p-autonat = { version = "0.12.1", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.3.1", path = "misc/connection-limits" } -libp2p-core = { version = "0.41.4", path = "core" } +libp2p-core = { version = "0.41.3", path = "core" } libp2p-dcutr = { version = "0.11.1", path = "protocols/dcutr" } libp2p-dns = { version = "0.41.1", path = "transports/dns" } libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" } diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 0c3b81cd3e5..b7f3c3c4640 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -1,8 +1,4 @@ -## 0.41.4 -- Add `PeerInfo` struct. - See [PR 5475](https://github.com/libp2p/rust-libp2p/pull/5475) - -## 0.41.3 +## 0.41.3 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/core/Cargo.toml b/core/Cargo.toml index 048988c75b0..76021c15186 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-core" edition = "2021" rust-version = { workspace = true } description = "Core traits and structs of libp2p" -version = "0.41.4" +version = "0.41.3" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -35,8 +35,8 @@ void = "1" [dev-dependencies] async-std = { version = "1.6.2", features = ["attributes"] } -libp2p-mplex = { path = "../muxers/mplex" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. -libp2p-noise = { path = "../transports/noise" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. +libp2p-mplex = { path = "../muxers/mplex" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. +libp2p-noise = { path = "../transports/noise" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. multihash = { workspace = true, features = ["arb"] } quickcheck = { workspace = true } libp2p-identity = { workspace = true, features = ["ed25519", "rand"] } diff --git a/core/src/lib.rs b/core/src/lib.rs index 73a4382c315..3ba153e1927 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -69,10 +69,3 @@ pub use upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; #[derive(Debug, thiserror::Error)] #[error(transparent)] pub struct DecodeError(quick_protobuf::Error); - -/// Peer Info combines a Peer ID with a set of multiaddrs that the peer is listening on. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct PeerInfo { - pub peer_id: PeerId, - pub addrs: Vec, -} diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index ce81c2e8dca..09f4e93fe4e 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -33,10 +33,9 @@ use crate::record::{ store::{self, RecordStore}, ProviderRecord, Record, }; -use crate::K_VALUE; use crate::{jobs::*, protocol}; -use fnv::{FnvHashMap, FnvHashSet}; -use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr, PeerInfo}; +use fnv::FnvHashSet; +use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::{ AddressChange, ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm, @@ -47,7 +46,6 @@ use libp2p_swarm::{ ListenAddresses, NetworkBehaviour, NotifyHandler, StreamProtocol, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }; -use smallvec::SmallVec; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; use std::fmt; use std::num::NonZeroUsize; @@ -76,7 +74,7 @@ pub struct Behaviour { record_filtering: StoreInserts, /// The currently active (i.e. in-progress) queries. - queries: QueryPool, + queries: QueryPool, /// The currently connected peers. /// @@ -270,7 +268,7 @@ impl Config { /// Sets the replication factor to use. /// /// The replication factor determines to how many closest peers - /// a record is replicated. The default is [`K_VALUE`]. + /// a record is replicated. The default is [`crate::K_VALUE`]. pub fn set_replication_factor(&mut self, replication_factor: NonZeroUsize) -> &mut Self { self.query_config.replication_factor = replication_factor; self @@ -429,7 +427,7 @@ impl Config { /// Sets the time to wait before calling [`Behaviour::bootstrap`] after a new peer is inserted in the routing table. /// This prevent cascading bootstrap requests when multiple peers are inserted into the routing table "at the same time". /// This also allows to wait a little bit for other potential peers to be inserted into the routing table before - /// triggering a bootstrap, giving more context to the future bootstrap request. + /// triggering a bootstrap, giving more context to the future bootstrap request. /// /// * Default to `500` ms. /// * Set to `Some(Duration::ZERO)` to never wait before triggering a bootstrap request when a new peer @@ -725,8 +723,7 @@ where step: ProgressStep::first(), }; let peer_keys: Vec> = self.kbuckets.closest_keys(&target).collect(); - let inner = QueryInner::new(info); - self.queries.add_iter_closest(target, peer_keys, inner) + self.queries.add_iter_closest(target, peer_keys, info) } /// Returns closest peers to the given key; takes peers from local routing table only. @@ -775,8 +772,7 @@ where } }; let peers = self.kbuckets.closest_keys(&target); - let inner = QueryInner::new(info); - let id = self.queries.add_iter_closest(target.clone(), peers, inner); + let id = self.queries.add_iter_closest(target.clone(), peers, info); // No queries were actually done for the results yet. let stats = QueryStats::empty(); @@ -832,8 +828,7 @@ where quorum, phase: PutRecordPhase::GetClosestPeers, }; - let inner = QueryInner::new(info); - Ok(self.queries.add_iter_closest(target.clone(), peers, inner)) + Ok(self.queries.add_iter_closest(target.clone(), peers, info)) } /// Stores a record at specific peers, without storing it locally. @@ -878,8 +873,7 @@ where get_closest_peers_stats: QueryStats::empty(), }, }; - let inner = QueryInner::new(info); - self.queries.add_fixed(peers, inner) + self.queries.add_fixed(peers, info) } /// Removes the record with the given key from _local_ storage, @@ -943,8 +937,7 @@ where Err(NoKnownPeers()) } else { self.bootstrap_status.on_started(); - let inner = QueryInner::new(info); - Ok(self.queries.add_iter_closest(local_key, peers, inner)) + Ok(self.queries.add_iter_closest(local_key, peers, info)) } } @@ -989,8 +982,7 @@ where key, phase: AddProviderPhase::GetClosestPeers, }; - let inner = QueryInner::new(info); - let id = self.queries.add_iter_closest(target.clone(), peers, inner); + let id = self.queries.add_iter_closest(target.clone(), peers, info); Ok(id) } @@ -1030,8 +1022,7 @@ where let target = kbucket::Key::new(key.clone()); let peers = self.kbuckets.closest_keys(&target); - let inner = QueryInner::new(info); - let id = self.queries.add_iter_closest(target.clone(), peers, inner); + let id = self.queries.add_iter_closest(target.clone(), peers, info); // No queries were actually done for the results yet. let stats = QueryStats::empty(); @@ -1165,7 +1156,7 @@ where "Peer reported by source in query" ); let addrs = peer.multiaddrs.iter().cloned().collect(); - query.inner.addresses.insert(peer.node_id, addrs); + query.peers.addresses.insert(peer.node_id, addrs); } query.on_success(source, others_iter.cloned().map(|kp| kp.node_id)) } @@ -1254,8 +1245,7 @@ where }; let target = kbucket::Key::new(key); let peers = self.kbuckets.closest_keys(&target); - let inner = QueryInner::new(info); - self.queries.add_iter_closest(target.clone(), peers, inner); + self.queries.add_iter_closest(target.clone(), peers, info); } /// Starts an iterative `PUT_VALUE` query for the given record. @@ -1269,8 +1259,7 @@ where context, phase: PutRecordPhase::GetClosestPeers, }; - let inner = QueryInner::new(info); - self.queries.add_iter_closest(target.clone(), peers, inner); + self.queries.add_iter_closest(target.clone(), peers, info); } /// Updates the routing table with a new connection status and address of a peer. @@ -1387,11 +1376,10 @@ where } /// Handles a finished (i.e. successful) query. - fn query_finished(&mut self, q: Query) -> Option { + fn query_finished(&mut self, q: Query) -> Option { let query_id = q.id(); tracing::trace!(query=?query_id, "Query finished"); - let mut result = q.into_result(); - match result.inner.info { + match q.info { QueryInfo::Bootstrap { peer, remaining, @@ -1445,9 +1433,8 @@ where step: step.next(), }; let peers = self.kbuckets.closest_keys(&target); - let inner = QueryInner::new(info); self.queries - .continue_iter_closest(query_id, target, peers, inner); + .continue_iter_closest(query_id, target, peers, info); } else { step.last = true; self.bootstrap_status.on_finish(); @@ -1455,7 +1442,7 @@ where Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: q.stats, result: QueryResult::Bootstrap(Ok(BootstrapOk { peer, num_remaining, @@ -1466,23 +1453,14 @@ where QueryInfo::GetClosestPeers { key, mut step } => { step.last = true; - let peers = result - .peers - .map(|peer_id| { - let addrs = result - .inner - .addresses - .remove(&peer_id) - .unwrap_or_default() - .to_vec(); - PeerInfo { peer_id, addrs } - }) - .collect(); Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, - result: QueryResult::GetClosestPeers(Ok(GetClosestPeersOk { key, peers })), + stats: q.stats, + result: QueryResult::GetClosestPeers(Ok(GetClosestPeersOk { + key, + peers: q.peers.into_peerinfos_iter().collect(), + })), step, }) } @@ -1492,10 +1470,10 @@ where Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: q.stats, result: QueryResult::GetProviders(Ok( GetProvidersOk::FinishedWithNoAdditionalRecord { - closest_peers: result.peers.collect(), + closest_peers: q.peers.into_peerids_iter().collect(), }, )), step, @@ -1509,16 +1487,17 @@ where } => { let provider_id = self.local_peer_id; let external_addresses = self.external_addresses.iter().cloned().collect(); - let inner = QueryInner::new(QueryInfo::AddProvider { + let info = QueryInfo::AddProvider { context, key, phase: AddProviderPhase::AddProvider { provider_id, external_addresses, - get_closest_peers_stats: result.stats, + get_closest_peers_stats: q.stats, }, - }); - self.queries.continue_fixed(query_id, result.peers, inner); + }; + self.queries + .continue_fixed(query_id, q.peers.into_peerids_iter(), info); None } @@ -1533,13 +1512,13 @@ where } => match context { AddProviderContext::Publish => Some(Event::OutboundQueryProgressed { id: query_id, - stats: get_closest_peers_stats.merge(result.stats), + stats: get_closest_peers_stats.merge(q.stats), result: QueryResult::StartProviding(Ok(AddProviderOk { key })), step: ProgressStep::first_and_last(), }), AddProviderContext::Republish => Some(Event::OutboundQueryProgressed { id: query_id, - stats: get_closest_peers_stats.merge(result.stats), + stats: get_closest_peers_stats.merge(q.stats), result: QueryResult::RepublishProvider(Ok(AddProviderOk { key })), step: ProgressStep::first_and_last(), }), @@ -1558,12 +1537,12 @@ where } else { Err(GetRecordError::NotFound { key, - closest_peers: result.peers.collect(), + closest_peers: q.peers.into_peerids_iter().collect(), }) }; Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: q.stats, result: QueryResult::GetRecord(results), step, }) @@ -1581,11 +1560,11 @@ where quorum, phase: PutRecordPhase::PutRecord { success: vec![], - get_closest_peers_stats: result.stats, + get_closest_peers_stats: q.stats, }, }; - let inner = QueryInner::new(info); - self.queries.continue_fixed(query_id, result.peers, inner); + self.queries + .continue_fixed(query_id, q.peers.into_peerids_iter(), info); None } @@ -1614,14 +1593,14 @@ where PutRecordContext::Publish | PutRecordContext::Custom => { Some(Event::OutboundQueryProgressed { id: query_id, - stats: get_closest_peers_stats.merge(result.stats), + stats: get_closest_peers_stats.merge(q.stats), result: QueryResult::PutRecord(mk_result(record.key)), step: ProgressStep::first_and_last(), }) } PutRecordContext::Republish => Some(Event::OutboundQueryProgressed { id: query_id, - stats: get_closest_peers_stats.merge(result.stats), + stats: get_closest_peers_stats.merge(q.stats), result: QueryResult::RepublishRecord(mk_result(record.key)), step: ProgressStep::first_and_last(), }), @@ -1635,11 +1614,10 @@ where } /// Handles a query that timed out. - fn query_timeout(&mut self, query: Query) -> Option { + fn query_timeout(&mut self, query: Query) -> Option { let query_id = query.id(); tracing::trace!(query=?query_id, "Query timed out"); - let mut result = query.into_result(); - match result.inner.info { + match query.info { QueryInfo::Bootstrap { peer, mut remaining, @@ -1657,9 +1635,8 @@ where step: step.next(), }; let peers = self.kbuckets.closest_keys(&target); - let inner = QueryInner::new(info); self.queries - .continue_iter_closest(query_id, target, peers, inner); + .continue_iter_closest(query_id, target, peers, info); } else { step.last = true; self.bootstrap_status.on_finish(); @@ -1667,7 +1644,7 @@ where Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: query.stats, result: QueryResult::Bootstrap(Err(BootstrapError::Timeout { peer, num_remaining, @@ -1679,13 +1656,13 @@ where QueryInfo::AddProvider { context, key, .. } => Some(match context { AddProviderContext::Publish => Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: query.stats, result: QueryResult::StartProviding(Err(AddProviderError::Timeout { key })), step: ProgressStep::first_and_last(), }, AddProviderContext::Republish => Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: query.stats, result: QueryResult::RepublishProvider(Err(AddProviderError::Timeout { key })), step: ProgressStep::first_and_last(), }, @@ -1693,25 +1670,12 @@ where QueryInfo::GetClosestPeers { key, mut step } => { step.last = true; - let peers = result - .peers - .map(|peer_id| { - let addrs = result - .inner - .addresses - .remove(&peer_id) - .unwrap_or_default() - .to_vec(); - PeerInfo { peer_id, addrs } - }) - .collect(); - Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: query.stats, result: QueryResult::GetClosestPeers(Err(GetClosestPeersError::Timeout { key, - peers, + peers: query.peers.into_peerinfos_iter().collect(), })), step, }) @@ -1735,14 +1699,14 @@ where PutRecordContext::Publish | PutRecordContext::Custom => { Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: query.stats, result: QueryResult::PutRecord(err), step: ProgressStep::first_and_last(), }) } PutRecordContext::Republish => Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: query.stats, result: QueryResult::RepublishRecord(err), step: ProgressStep::first_and_last(), }), @@ -1767,7 +1731,7 @@ where Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: query.stats, result: QueryResult::GetRecord(Err(GetRecordError::Timeout { key })), step, }) @@ -1778,10 +1742,10 @@ where Some(Event::OutboundQueryProgressed { id: query_id, - stats: result.stats, + stats: query.stats, result: QueryResult::GetProviders(Err(GetProvidersError::Timeout { key, - closest_peers: result.peers.collect(), + closest_peers: query.peers.into_peerids_iter().collect(), })), step, }) @@ -1979,7 +1943,7 @@ where } for query in self.queries.iter_mut() { - if let Some(addrs) = query.inner.addresses.get_mut(&peer_id) { + if let Some(addrs) = query.peers.addresses.get_mut(&peer_id) { addrs.retain(|a| a != address); } } @@ -2051,10 +2015,10 @@ where // // Given two connected nodes: local node A and remote node B. Say node B // is not in node A's routing table. Additionally node B is part of the - // `QueryInner::addresses` list of an ongoing query on node A. Say Node + // `Query::addresses` list of an ongoing query on node A. Say Node // B triggers an address change and then disconnects. Later on the // earlier mentioned query on node A would like to connect to node B. - // Without replacing the address in the `QueryInner::addresses` set node + // Without replacing the address in the `Query::addresses` set node // A would attempt to dial the old and not the new address. // // While upholding correctness, iterating through all discovered @@ -2062,7 +2026,7 @@ where // large performance impact. If so, the code below might be worth // revisiting. for query in self.queries.iter_mut() { - if let Some(addrs) = query.inner.addresses.get_mut(&peer) { + if let Some(addrs) = query.peers.addresses.get_mut(&peer) { for addr in addrs.iter_mut() { if addr == old { *addr = new.clone(); @@ -2137,11 +2101,10 @@ where // Queue events for sending pending RPCs to the connected peer. // There can be only one pending RPC for a particular peer and query per definition. for (_peer_id, event) in self.queries.iter_mut().filter_map(|q| { - q.inner - .pending_rpcs + q.pending_rpcs .iter() .position(|(p, _)| p == &peer) - .map(|p| q.inner.pending_rpcs.remove(p)) + .map(|p| q.pending_rpcs.remove(p)) }) { handler.on_behaviour_event(event) } @@ -2232,7 +2195,7 @@ where // We add to that a temporary list of addresses from the ongoing queries. for query in self.queries.iter() { - if let Some(addrs) = query.inner.addresses.get(&peer_id) { + if let Some(addrs) = query.peers.addresses.get(&peer_id) { peer_addrs.extend(addrs.iter().cloned()) } } @@ -2333,7 +2296,7 @@ where ref mut providers_found, ref mut step, .. - } = query.inner.info + } = query.info { *providers_found += provider_peers.len(); let providers = provider_peers.iter().map(|p| p.node_id).collect(); @@ -2425,7 +2388,7 @@ where ref mut step, ref mut found_a_record, cache_candidates, - } = &mut query.inner.info + } = &mut query.info { if let Some(record) = record { *found_a_record = true; @@ -2479,7 +2442,7 @@ where phase: PutRecordPhase::PutRecord { success, .. }, quorum, .. - } = &mut query.inner.info + } = &mut query.info { success.push(source); @@ -2591,7 +2554,7 @@ where } } QueryPoolState::Waiting(Some((query, peer_id))) => { - let event = query.inner.info.to_request(query.id()); + let event = query.info.to_request(query.id()); // TODO: AddProvider requests yield no response, so the query completes // as soon as all requests have been sent. However, the handler should // better emit an event when the request has been sent (and report @@ -2600,7 +2563,7 @@ where if let QueryInfo::AddProvider { phase: AddProviderPhase::AddProvider { .. }, .. - } = &query.inner.info + } = &query.info { query.on_success(&peer_id, vec![]) } @@ -2612,7 +2575,7 @@ where handler: NotifyHandler::Any, }); } else if &peer_id != self.kbuckets.local_key().preimage() { - query.inner.pending_rpcs.push((peer_id, event)); + query.pending_rpcs.push((peer_id, event)); self.queued_events.push_back(ToSwarm::Dial { opts: DialOpts::peer_id(peer_id).build(), }); @@ -2655,6 +2618,13 @@ where } } +/// Peer Info combines a Peer ID with a set of multiaddrs that the peer is listening on. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct PeerInfo { + pub peer_id: PeerId, + pub addrs: Vec, +} + /// A quorum w.r.t. the configured replication factor specifies the minimum /// number of distinct nodes that must be successfully contacted in order /// for a query to succeed. @@ -3114,31 +3084,6 @@ impl From, Addresses>> for KadPeer { } } -////////////////////////////////////////////////////////////////////////////// -// Internal query state - -struct QueryInner { - /// The query-specific state. - info: QueryInfo, - /// Addresses of peers discovered during a query. - addresses: FnvHashMap>, - /// A map of pending requests to peers. - /// - /// A request is pending if the targeted peer is not currently connected - /// and these requests are sent as soon as a connection to the peer is established. - pending_rpcs: SmallVec<[(PeerId, HandlerIn); K_VALUE.get()]>, -} - -impl QueryInner { - fn new(info: QueryInfo) -> Self { - QueryInner { - info, - addresses: Default::default(), - pending_rpcs: SmallVec::default(), - } - } -} - /// The context of a [`QueryInfo::AddProvider`] query. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum AddProviderContext { @@ -3324,7 +3269,7 @@ pub enum PutRecordPhase { /// A mutable reference to a running query. pub struct QueryMut<'a> { - query: &'a mut Query, + query: &'a mut Query, } impl<'a> QueryMut<'a> { @@ -3334,7 +3279,7 @@ impl<'a> QueryMut<'a> { /// Gets information about the type and state of the query. pub fn info(&self) -> &QueryInfo { - &self.query.inner.info + &self.query.info } /// Gets execution statistics about the query. @@ -3354,7 +3299,7 @@ impl<'a> QueryMut<'a> { /// An immutable reference to a running query. pub struct QueryRef<'a> { - query: &'a Query, + query: &'a Query, } impl<'a> QueryRef<'a> { @@ -3364,7 +3309,7 @@ impl<'a> QueryRef<'a> { /// Gets information about the type and state of the query. pub fn info(&self) -> &QueryInfo { - &self.query.inner.info + &self.query.info } /// Gets execution statistics about the query. diff --git a/protocols/kad/src/behaviour/test.rs b/protocols/kad/src/behaviour/test.rs index a3ff43ded6e..b82ec966f89 100644 --- a/protocols/kad/src/behaviour/test.rs +++ b/protocols/kad/src/behaviour/test.rs @@ -23,7 +23,7 @@ use super::*; use crate::record::{store::MemoryStore, Key}; -use crate::{PROTOCOL_NAME, SHA_256_MH}; +use crate::{K_VALUE, PROTOCOL_NAME, SHA_256_MH}; use futures::{executor::block_on, future::poll_fn, prelude::*}; use futures_timer::Delay; use libp2p_core::{ @@ -1187,7 +1187,7 @@ fn disjoint_query_does_not_finish_before_all_paths_did() { .behaviour() .queries .iter() - .for_each(|q| match &q.inner.info { + .for_each(|q| match &q.info { QueryInfo::GetRecord { step, .. } => { assert_eq!(usize::from(step.count), 2); } diff --git a/protocols/kad/src/lib.rs b/protocols/kad/src/lib.rs index bb7c2ace663..681d135f79b 100644 --- a/protocols/kad/src/lib.rs +++ b/protocols/kad/src/lib.rs @@ -59,9 +59,9 @@ pub use behaviour::{ AddProviderContext, AddProviderError, AddProviderOk, AddProviderPhase, AddProviderResult, BootstrapError, BootstrapOk, BootstrapResult, GetClosestPeersError, GetClosestPeersOk, GetClosestPeersResult, GetProvidersError, GetProvidersOk, GetProvidersResult, GetRecordError, - GetRecordOk, GetRecordResult, InboundRequest, Mode, NoKnownPeers, PeerRecord, PutRecordContext, - PutRecordError, PutRecordOk, PutRecordPhase, PutRecordResult, QueryInfo, QueryMut, QueryRef, - QueryResult, QueryStats, RoutingUpdate, + GetRecordOk, GetRecordResult, InboundRequest, Mode, NoKnownPeers, PeerInfo, PeerRecord, + PutRecordContext, PutRecordError, PutRecordOk, PutRecordPhase, PutRecordResult, QueryInfo, + QueryMut, QueryRef, QueryResult, QueryStats, RoutingUpdate, }; pub use behaviour::{ Behaviour, BucketInserts, Caching, Config, Event, ProgressStep, Quorum, StoreInserts, diff --git a/protocols/kad/src/query.rs b/protocols/kad/src/query.rs index cf102040a7a..c598bac012e 100644 --- a/protocols/kad/src/query.rs +++ b/protocols/kad/src/query.rs @@ -20,14 +20,18 @@ mod peers; +use libp2p_core::Multiaddr; use peers::closest::{ disjoint::ClosestDisjointPeersIter, ClosestPeersIter, ClosestPeersIterConfig, }; use peers::fixed::FixedPeersIter; use peers::PeersIterState; +use smallvec::SmallVec; +use crate::behaviour::PeerInfo; +use crate::handler::HandlerIn; use crate::kbucket::{Key, KeyBytes}; -use crate::{ALPHA_VALUE, K_VALUE}; +use crate::{QueryInfo, ALPHA_VALUE, K_VALUE}; use either::Either; use fnv::FnvHashMap; use libp2p_identity::PeerId; @@ -39,26 +43,26 @@ use web_time::Instant; /// Internally, a `Query` is in turn driven by an underlying `QueryPeerIter` /// that determines the peer selection strategy, i.e. the order in which the /// peers involved in the query should be contacted. -pub(crate) struct QueryPool { +pub(crate) struct QueryPool { next_id: usize, config: QueryConfig, - queries: FnvHashMap>, + queries: FnvHashMap, } /// The observable states emitted by [`QueryPool::poll`]. -pub(crate) enum QueryPoolState<'a, TInner> { +pub(crate) enum QueryPoolState<'a> { /// The pool is idle, i.e. there are no queries to process. Idle, /// At least one query is waiting for results. `Some(request)` indicates /// that a new request is now being waited on. - Waiting(Option<(&'a mut Query, PeerId)>), + Waiting(Option<(&'a mut Query, PeerId)>), /// A query has finished. - Finished(Query), + Finished(Query), /// A query has timed out. - Timeout(Query), + Timeout(Query), } -impl QueryPool { +impl QueryPool { /// Creates a new `QueryPool` with the given configuration. pub(crate) fn new(config: QueryConfig) -> Self { QueryPool { @@ -74,7 +78,7 @@ impl QueryPool { } /// Returns an iterator over the queries in the pool. - pub(crate) fn iter(&self) -> impl Iterator> { + pub(crate) fn iter(&self) -> impl Iterator { self.queries.values() } @@ -84,42 +88,42 @@ impl QueryPool { } /// Returns an iterator that allows modifying each query in the pool. - pub(crate) fn iter_mut(&mut self) -> impl Iterator> { + pub(crate) fn iter_mut(&mut self) -> impl Iterator { self.queries.values_mut() } /// Adds a query to the pool that contacts a fixed set of peers. - pub(crate) fn add_fixed(&mut self, peers: I, inner: TInner) -> QueryId + pub(crate) fn add_fixed(&mut self, peers: I, info: QueryInfo) -> QueryId where I: IntoIterator, { let id = self.next_query_id(); - self.continue_fixed(id, peers, inner); + self.continue_fixed(id, peers, info); id } /// Continues an earlier query with a fixed set of peers, reusing /// the given query ID, which must be from a query that finished /// earlier. - pub(crate) fn continue_fixed(&mut self, id: QueryId, peers: I, inner: TInner) + pub(crate) fn continue_fixed(&mut self, id: QueryId, peers: I, info: QueryInfo) where I: IntoIterator, { assert!(!self.queries.contains_key(&id)); let parallelism = self.config.replication_factor; let peer_iter = QueryPeerIter::Fixed(FixedPeersIter::new(peers, parallelism)); - let query = Query::new(id, peer_iter, inner); + let query = Query::new(id, peer_iter, info); self.queries.insert(id, query); } /// Adds a query to the pool that iterates towards the closest peers to the target. - pub(crate) fn add_iter_closest(&mut self, target: T, peers: I, inner: TInner) -> QueryId + pub(crate) fn add_iter_closest(&mut self, target: T, peers: I, info: QueryInfo) -> QueryId where T: Into + Clone, I: IntoIterator>, { let id = self.next_query_id(); - self.continue_iter_closest(id, target, peers, inner); + self.continue_iter_closest(id, target, peers, info); id } @@ -129,7 +133,7 @@ impl QueryPool { id: QueryId, target: T, peers: I, - inner: TInner, + info: QueryInfo, ) where T: Into + Clone, I: IntoIterator>, @@ -148,7 +152,7 @@ impl QueryPool { QueryPeerIter::Closest(ClosestPeersIter::with_config(cfg, target, peers)) }; - let query = Query::new(id, peer_iter, inner); + let query = Query::new(id, peer_iter, info); self.queries.insert(id, query); } @@ -159,17 +163,17 @@ impl QueryPool { } /// Returns a reference to a query with the given ID, if it is in the pool. - pub(crate) fn get(&self, id: &QueryId) -> Option<&Query> { + pub(crate) fn get(&self, id: &QueryId) -> Option<&Query> { self.queries.get(id) } /// Returns a mutablereference to a query with the given ID, if it is in the pool. - pub(crate) fn get_mut(&mut self, id: &QueryId) -> Option<&mut Query> { + pub(crate) fn get_mut(&mut self, id: &QueryId) -> Option<&mut Query> { self.queries.get_mut(id) } /// Polls the pool to advance the queries. - pub(crate) fn poll(&mut self, now: Instant) -> QueryPoolState<'_, TInner> { + pub(crate) fn poll(&mut self, now: Instant) -> QueryPoolState<'_> { let mut finished = None; let mut timeout = None; let mut waiting = None; @@ -264,15 +268,53 @@ impl Default for QueryConfig { } /// A query in a `QueryPool`. -pub(crate) struct Query { +pub(crate) struct Query { /// The unique ID of the query. id: QueryId, /// The peer iterator that drives the query state. - peer_iter: QueryPeerIter, + pub(crate) peers: QueryPeers, /// Execution statistics of the query. - stats: QueryStats, - /// The opaque inner query state. - pub(crate) inner: TInner, + pub(crate) stats: QueryStats, + /// The query-specific state. + pub(crate) info: QueryInfo, + /// A map of pending requests to peers. + /// + /// A request is pending if the targeted peer is not currently connected + /// and these requests are sent as soon as a connection to the peer is established. + pub(crate) pending_rpcs: SmallVec<[(PeerId, HandlerIn); K_VALUE.get()]>, +} + +/// The peer iterator that drives the query state, +pub(crate) struct QueryPeers { + /// Addresses of peers discovered during a query. + pub(crate) addresses: FnvHashMap>, + /// The peer iterator that drives the query state. + peer_iter: QueryPeerIter, +} + +impl QueryPeers { + /// Consumes the peers iterator, producing a final `Iterator` over the discovered `PeerId`s. + pub(crate) fn into_peerids_iter(self) -> impl Iterator { + match self.peer_iter { + QueryPeerIter::Closest(iter) => Either::Left(Either::Left(iter.into_result())), + QueryPeerIter::ClosestDisjoint(iter) => Either::Left(Either::Right(iter.into_result())), + QueryPeerIter::Fixed(iter) => Either::Right(iter.into_result()), + } + } + + /// Consumes the peers iterator, producing a final `Iterator` over the discovered `PeerId`s + /// with their matching `Multiaddr`s. + pub(crate) fn into_peerinfos_iter(mut self) -> impl Iterator { + match self.peer_iter { + QueryPeerIter::Closest(iter) => Either::Left(Either::Left(iter.into_result())), + QueryPeerIter::ClosestDisjoint(iter) => Either::Left(Either::Right(iter.into_result())), + QueryPeerIter::Fixed(iter) => Either::Right(iter.into_result()), + } + .map(move |peer_id| { + let addrs = self.addresses.remove(&peer_id).unwrap_or_default().to_vec(); + PeerInfo { peer_id, addrs } + }) + } } /// The peer selection strategies that can be used by queries. @@ -282,13 +324,17 @@ enum QueryPeerIter { Fixed(FixedPeersIter), } -impl Query { +impl Query { /// Creates a new query without starting it. - fn new(id: QueryId, peer_iter: QueryPeerIter, inner: TInner) -> Self { + fn new(id: QueryId, peer_iter: QueryPeerIter, info: QueryInfo) -> Self { Query { id, - inner, - peer_iter, + info, + peers: QueryPeers { + addresses: Default::default(), + peer_iter, + }, + pending_rpcs: SmallVec::default(), stats: QueryStats::empty(), } } @@ -305,7 +351,7 @@ impl Query { /// Informs the query that the attempt to contact `peer` failed. pub(crate) fn on_failure(&mut self, peer: &PeerId) { - let updated = match &mut self.peer_iter { + let updated = match &mut self.peers.peer_iter { QueryPeerIter::Closest(iter) => iter.on_failure(peer), QueryPeerIter::ClosestDisjoint(iter) => iter.on_failure(peer), QueryPeerIter::Fixed(iter) => iter.on_failure(peer), @@ -322,7 +368,7 @@ impl Query { where I: IntoIterator, { - let updated = match &mut self.peer_iter { + let updated = match &mut self.peers.peer_iter { QueryPeerIter::Closest(iter) => iter.on_success(peer, new_peers), QueryPeerIter::ClosestDisjoint(iter) => iter.on_success(peer, new_peers), QueryPeerIter::Fixed(iter) => iter.on_success(peer), @@ -334,7 +380,7 @@ impl Query { /// Advances the state of the underlying peer iterator. fn next(&mut self, now: Instant) -> PeersIterState<'_> { - let state = match &mut self.peer_iter { + let state = match &mut self.peers.peer_iter { QueryPeerIter::Closest(iter) => iter.next(now), QueryPeerIter::ClosestDisjoint(iter) => iter.next(now), QueryPeerIter::Fixed(iter) => iter.next(), @@ -368,7 +414,7 @@ impl Query { where I: IntoIterator, { - match &mut self.peer_iter { + match &mut self.peers.peer_iter { QueryPeerIter::Closest(iter) => { iter.finish(); true @@ -386,7 +432,7 @@ impl Query { /// A finished query immediately stops yielding new peers to contact and will be /// reported by [`QueryPool::poll`] via [`QueryPoolState::Finished`]. pub(crate) fn finish(&mut self) { - match &mut self.peer_iter { + match &mut self.peers.peer_iter { QueryPeerIter::Closest(iter) => iter.finish(), QueryPeerIter::ClosestDisjoint(iter) => iter.finish(), QueryPeerIter::Fixed(iter) => iter.finish(), @@ -398,36 +444,12 @@ impl Query { /// A finished query is eventually reported by `QueryPool::next()` and /// removed from the pool. pub(crate) fn is_finished(&self) -> bool { - match &self.peer_iter { + match &self.peers.peer_iter { QueryPeerIter::Closest(iter) => iter.is_finished(), QueryPeerIter::ClosestDisjoint(iter) => iter.is_finished(), QueryPeerIter::Fixed(iter) => iter.is_finished(), } } - - /// Consumes the query, producing the final `QueryResult`. - pub(crate) fn into_result(self) -> QueryResult> { - let peers = match self.peer_iter { - QueryPeerIter::Closest(iter) => Either::Left(Either::Left(iter.into_result())), - QueryPeerIter::ClosestDisjoint(iter) => Either::Left(Either::Right(iter.into_result())), - QueryPeerIter::Fixed(iter) => Either::Right(iter.into_result()), - }; - QueryResult { - peers, - inner: self.inner, - stats: self.stats, - } - } -} - -/// The result of a `Query`. -pub(crate) struct QueryResult { - /// The opaque inner query state. - pub(crate) inner: TInner, - /// The successfully contacted peers. - pub(crate) peers: TPeers, - /// The collected query statistics. - pub(crate) stats: QueryStats, } /// Execution statistics of a query. From 23eb4f8e30bd5ca6cc55ed3ac6fdefe2131c9830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 4 Jul 2024 11:49:23 +0100 Subject: [PATCH 179/246] deps(ci): update cache-cargo-install-action and fix ci, by using `tomlq` new binary name, `tq` Pull-Request: #5481. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e6d8c7fdaf..8f1fe263a2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: cargo metadata --format-version=1 --no-deps | \ jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .dependencies | all(.name != "libp2p")' - - uses: taiki-e/cache-cargo-install-action@5b024fe3a0a2c7f2aaff0e47871acf0d14b07207 # v1 + - uses: taiki-e/cache-cargo-install-action@v2 with: tool: tomlq @@ -70,7 +70,7 @@ jobs: - name: Enforce version in `workspace.dependencies` matches latest version if: env.CRATE != 'libp2p' run: | - SPECIFIED_VERSION=$(tomlq "workspace.dependencies.$CRATE.version" --file ./Cargo.toml) + SPECIFIED_VERSION=$(tq "workspace.dependencies.$CRATE.version" --file ./Cargo.toml) echo "Package version: $CRATE_VERSION"; echo "Specified version: $SPECIFIED_VERSION"; From 36c2f94affce4edff303f8dcfa882737451da13c Mon Sep 17 00:00:00 2001 From: stormshield-frb <144998884+stormshield-frb@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:17:28 +0200 Subject: [PATCH 180/246] feat(kad): improve automatic bootstrap As discussed in the last maintainer call, some improvements are probably necessary for the automatic bootstrap feature (introduced by https://github.com/libp2p/rust-libp2p/pull/4838). Indeed, like @drHuangMHT mentioned in https://github.com/libp2p/rust-libp2p/issues/5341 and like @guillaumemichel has agreed, triggering a bootstrap every time an update happens inside the routing table consumes a lot more resources. The idea behind the automatic bootstrap feature it that, when a peer is starting, if a routing table update happens we probably don't want to wait for the periodic bootstrap to trigger and we want to trigger it right now. However, like @guillaumemichel said, this is something we want to do at startup or when a network connectivity problem happens, we don't want to do that all the time. This PR is a proposal to trigger automatically a bootstrap on routing table update but only when we have less that `K_VALUE` peers in it (meaning that we are starting up or something went wrong and the fact that a new peer is inserted is probably a sign that the network connectivity issue is resolved). I have also added a new triggering condition like mentioned in the maintainer call. When discovering a new listen address and if we have no connected peers, we trigger a bootstrap. This condition is based on our own experience at Stormshield : some peers were starting before the network interfaces were up, doing so, the automatic and periodic bootstrap failed, but when the network interfaces were finally up, we were waiting X minutes for the periodic bootstrap to actually trigger a bootstrap and join the p2p network. Pull-Request: #5474. --- protocols/kad/CHANGELOG.md | 4 ++++ protocols/kad/src/behaviour.rs | 28 +++++++++++++++++++++++++--- protocols/kad/src/bootstrap.rs | 17 +++++++++-------- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index b31797b196d..f88484bafa1 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -23,6 +23,10 @@ See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). - Correctly handle the `NoKnownPeers` error on automatic bootstrap. See [PR 5349](https://github.com/libp2p/rust-libp2p/pull/5349). +- Improve automatic bootstrap triggering conditions: + trigger when the routing table is updated and we have less that `K_VALUE` peers in it, + trigger when a new listen address is discovered and we have no connected peers. + See [PR 5474](https://github.com/libp2p/rust-libp2p/pull/5474). ## 0.45.3 diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 09f4e93fe4e..069eec1a5b4 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -23,7 +23,6 @@ mod test; use crate::addresses::Addresses; -use crate::bootstrap; use crate::handler::{Handler, HandlerEvent, HandlerIn, RequestId}; use crate::kbucket::{self, Distance, KBucketsTable, NodeStatus}; use crate::protocol::{ConnectionType, KadPeer, ProtocolConfig}; @@ -33,6 +32,7 @@ use crate::record::{ store::{self, RecordStore}, ProviderRecord, Record, }; +use crate::{bootstrap, K_VALUE}; use crate::{jobs::*, protocol}; use fnv::FnvHashSet; use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; @@ -604,7 +604,8 @@ where }; match entry.insert(addresses.clone(), status) { kbucket::InsertResult::Inserted => { - self.bootstrap_status.on_new_peer_in_routing_table(); + self.bootstrap_on_low_peers(); + self.queued_events.push_back(ToSwarm::GenerateEvent( Event::RoutingUpdated { peer: *peer, @@ -1324,7 +1325,8 @@ where let addresses = Addresses::new(a); match entry.insert(addresses.clone(), new_status) { kbucket::InsertResult::Inserted => { - self.bootstrap_status.on_new_peer_in_routing_table(); + self.bootstrap_on_low_peers(); + let event = Event::RoutingUpdated { peer, is_new_peer: true, @@ -1375,6 +1377,20 @@ where } } + /// A new peer has been inserted in the routing table but we check if the routing + /// table is currently small (less that `K_VALUE` peers are present) and only + /// trigger a bootstrap in that case + fn bootstrap_on_low_peers(&mut self) { + if self + .kbuckets() + .map(|kbucket| kbucket.num_entries()) + .sum::() + < K_VALUE.get() + { + self.bootstrap_status.trigger(); + } + } + /// Handles a finished (i.e. successful) query. fn query_finished(&mut self, q: Query) -> Option { let query_id = q.id(); @@ -2613,6 +2629,12 @@ where } FromSwarm::DialFailure(dial_failure) => self.on_dial_failure(dial_failure), FromSwarm::AddressChange(address_change) => self.on_address_change(address_change), + FromSwarm::NewListenAddr(_) if self.connected_peers.is_empty() => { + // A new listen addr was just discovered and we have no connected peers, + // it can mean that our network interfaces were not up but they are now + // so it might be a good idea to trigger a bootstrap. + self.bootstrap_status.trigger(); + } _ => {} } } diff --git a/protocols/kad/src/bootstrap.rs b/protocols/kad/src/bootstrap.rs index fd9e3d41be6..40acdfd88ee 100644 --- a/protocols/kad/src/bootstrap.rs +++ b/protocols/kad/src/bootstrap.rs @@ -44,7 +44,8 @@ impl Status { } } - pub(crate) fn on_new_peer_in_routing_table(&mut self) { + /// Trigger a bootstrap now or after the configured `automatic_throttle` if configured. + pub(crate) fn trigger(&mut self) { // Registering `self.throttle_timer` means scheduling a bootstrap. // A bootstrap will be triggered when `self.throttle_timer` finishes. // A `throttle_timer` is useful to not trigger a batch of bootstraps when a @@ -201,7 +202,7 @@ mod tests { "bootstrap to not be triggered immediately because periodic bootstrap is in ~1s" ); - status.on_new_peer_in_routing_table(); // Connected to a new peer though! + status.trigger(); // Connected to a new peer though! assert!( status.next().now_or_never().is_some(), "bootstrap to be triggered immediately because we connected to a new peer" @@ -226,7 +227,7 @@ mod tests { "bootstrap to not be triggered immediately because periodic bootstrap is in ~1s" ); - status.on_new_peer_in_routing_table(); // Connected to a new peer though! + status.trigger(); // Connected to a new peer though! assert!( status.next().now_or_never().is_none(), "bootstrap to not be triggered immediately because throttle is 5ms" @@ -247,7 +248,7 @@ mod tests { // User manually triggered a bootstrap do_bootstrap(&mut status); - status.on_new_peer_in_routing_table(); // Connected to a new peer though! + status.trigger(); // Connected to a new peer though! assert!( status.next().now_or_never().is_some(), @@ -260,7 +261,7 @@ mod tests { ) { let mut status = Status::new(Some(MS_100), Some(MS_5)); - status.on_new_peer_in_routing_table(); + status.trigger(); let start = Instant::now(); await_and_do_bootstrap(&mut status).await; @@ -280,7 +281,7 @@ mod tests { ) { let mut status = Status::new(None, Some(Duration::ZERO)); - status.on_new_peer_in_routing_table(); + status.trigger(); status.next().await; } @@ -304,10 +305,10 @@ mod tests { ) { let mut status = Status::new(None, Some(MS_100)); - status.on_new_peer_in_routing_table(); + status.trigger(); for _ in 0..10 { Delay::new(MS_100 / 2).await; - status.on_new_peer_in_routing_table(); // should reset throttle_timer + status.trigger(); // should reset throttle_timer } assert!( status.next().now_or_never().is_none(), From 693d7b7df75ce02095c3e5d6acb2315882445f52 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Thu, 4 Jul 2024 18:02:49 +0300 Subject: [PATCH 181/246] feat(swarm): Show task `spawn` paths in tokio-console This PR adds `#[track_caller]` on all `spawn` wrappers. Pull-Request: #5465. --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/mdns/CHANGELOG.md | 5 +++++ protocols/mdns/Cargo.toml | 2 +- protocols/mdns/src/behaviour.rs | 1 + swarm/CHANGELOG.md | 2 ++ swarm/src/connection/pool.rs | 1 + swarm/src/executor.rs | 1 + 8 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b25b574a46..5d45d51ac4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2924,7 +2924,7 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.45.1" +version = "0.45.2" dependencies = [ "async-io 2.3.3", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 76bb4f18b3d..ab660cc90e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" } libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.46.0", path = "protocols/kad" } -libp2p-mdns = { version = "0.45.1", path = "protocols/mdns" } +libp2p-mdns = { version = "0.45.2", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.14.2", path = "misc/metrics" } libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" } diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index cfd02232b07..18fe0e76e6f 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.45.2 + +- Add `#[track_caller]` on all `spawn` wrappers. + See [PR 5465](https://github.com/libp2p/rust-libp2p/pull/5465). + ## 0.45.1 - Ensure `Multiaddr` handled and returned by `Behaviour` are `/p2p` terminated. diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 56741463d6b..724c8818621 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-mdns" edition = "2021" rust-version = { workspace = true } -version = "0.45.1" +version = "0.45.2" description = "Implementation of the libp2p mDNS discovery method" authors = ["Parity Technologies "] license = "MIT" diff --git a/protocols/mdns/src/behaviour.rs b/protocols/mdns/src/behaviour.rs index 4e3533f26ab..d4a0a707a01 100644 --- a/protocols/mdns/src/behaviour.rs +++ b/protocols/mdns/src/behaviour.rs @@ -55,6 +55,7 @@ pub trait Provider: 'static { /// Create a new instance of the `IfWatcher` type. fn new_watcher() -> Result; + #[track_caller] fn spawn(task: impl Future + Send + 'static) -> Self::TaskHandle; } diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 1b53ee9b937..1139c40021f 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -5,6 +5,8 @@ - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). +- Add `#[track_caller]` on all `spawn` wrappers. + See [PR 5465](https://github.com/libp2p/rust-libp2p/pull/5465). ## 0.44.2 diff --git a/swarm/src/connection/pool.rs b/swarm/src/connection/pool.rs index 236f76e2fcc..48ba92f1020 100644 --- a/swarm/src/connection/pool.rs +++ b/swarm/src/connection/pool.rs @@ -70,6 +70,7 @@ impl ExecSwitch { } } + #[track_caller] fn spawn(&mut self, task: impl Future + Send + 'static) { let task = task.boxed(); diff --git a/swarm/src/executor.rs b/swarm/src/executor.rs index e949bf3cbde..a2abbbde6ef 100644 --- a/swarm/src/executor.rs +++ b/swarm/src/executor.rs @@ -11,6 +11,7 @@ use std::{future::Future, pin::Pin}; /// > about running `Future`s on a separate task. pub trait Executor { /// Run the given future in the background until it ends. + #[track_caller] fn exec(&self, future: Pin + Send>>); } From 02fc0278f675ba33d0e749b7dbe0d0b5d289d88e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20D=C3=B3ka?= <60517552+jakubDoka@users.noreply.github.com> Date: Sat, 6 Jul 2024 01:30:18 +0200 Subject: [PATCH 182/246] fix(swarm): eliminating protocol cloning when nothing is happening MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code keeps the API while eliminating repetitive protocol cloning when protocols did not change, If protocol changes occur, only then the protocols are cloned to a reused buffer from which they are borrowed for iteration. Following are benchmark results: |behaviour count|iterations|protocols|timings|change*| |-|-|-|-|-| |1|1000|10|27.798 µs 28.134 µs 28.493 µs|-15.771% -14.523% -13.269%| |1|1000|100|55.171 µs 55.578 µs 56.009 µs|-51.831% -50.162% -48.437%| |1|1000|1000|289.24 µs 290.99 µs 293.00 µs|-61.748% -60.895% -60.054%| |5|1000|2|34.000 µs 34.216 µs 34.457 µs|-18.538% -16.231% -14.011%| |5|1000|20|70.962 µs 71.428 µs 72.005 µs|-40.501% -38.944% -37.309%| |5|1000|200|426.17 µs 433.27 µs 442.60 µs|-44.824% -42.663% -40.262%| |10|1000|1|42.993 µs 44.382 µs 45.655 µs|-18.839% -16.292% -13.584%| |10|1000|10|94.022 µs 96.787 µs 99.321 µs|-25.469% -23.572% -21.562%| |10|1000|100|543.13 µs 554.91 µs 569.06 µs|-43.781% -42.189% -40.568%| |20|500|1|63.150 µs 64.846 µs 66.860 µs|-9.5693% -6.1722% -2.6400%| |20|500|10|212.21 µs 217.48 µs 222.64 µs|-16.525% -14.234% -11.925%| |20|500|100|1.6651 ms 1.7083 ms 1.7490 ms|-27.704% -25.683% -23.618%| change*: 3da7d918d0d3c443f20d1813772af1ac152b68c7 is the baseline Pull-Request: #5026. --- Cargo.lock | 5 +- Cargo.toml | 2 +- swarm/CHANGELOG.md | 7 + swarm/Cargo.toml | 7 +- swarm/benches/connection_handler.rs | 359 ++++++++++++++++++++ swarm/src/connection.rs | 70 ++-- swarm/src/connection/supported_protocols.rs | 20 +- swarm/src/handler.rs | 320 +++++++++++++---- swarm/src/lib.rs | 8 + 9 files changed, 707 insertions(+), 91 deletions(-) create mode 100644 swarm/benches/connection_handler.rs diff --git a/Cargo.lock b/Cargo.lock index 5d45d51ac4b..5ee39cb1786 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1093,6 +1093,7 @@ dependencies = [ "ciborium", "clap", "criterion-plot", + "futures", "is-terminal", "itertools", "num-traits", @@ -1105,6 +1106,7 @@ dependencies = [ "serde_derive", "serde_json", "tinytemplate", + "tokio", "walkdir", ] @@ -3291,9 +3293,10 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.45.0" +version = "0.45.1" dependencies = [ "async-std", + "criterion", "either", "fnv", "futures", diff --git a/Cargo.toml b/Cargo.toml index ab660cc90e9..1444b469c31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,7 +102,7 @@ libp2p-rendezvous = { version = "0.14.1", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.26.4", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } -libp2p-swarm = { version = "0.45.0", path = "swarm" } +libp2p-swarm = { version = "0.45.1", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 1139c40021f..8cf8852dd76 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,3 +1,10 @@ + +## 0.45.1 + +- Optimize internal connection `fn poll`. New implementation now scales much better with number of listen protocols active. + No changes to public API introduced. + See [PR 5026](https://github.com/libp2p/rust-libp2p/pull/5026) + ## 0.45.0 - Add peer_id to `FromSwarm::ListenFailure`. diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 60cf58cb495..6ce99aa33c5 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition = "2021" rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.45.0" +version = "0.45.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -52,6 +52,7 @@ libp2p-swarm-derive = { path = "../swarm-derive" } # Using `pat libp2p-swarm-test = { path = "../swarm-test" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. libp2p-yamux = { path = "../muxers/yamux" } # Using `path` here because this is a cyclic dev-dependency which otherwise breaks releasing. quickcheck = { workspace = true } +criterion = { version = "0.5", features = ["async_tokio"] } void = "1" once_cell = "1.19.0" trybuild = "1.0.95" @@ -69,5 +70,9 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] rustc-args = ["--cfg", "docsrs"] +[[bench]] +name = "connection_handler" +harness = false + [lints] workspace = true diff --git a/swarm/benches/connection_handler.rs b/swarm/benches/connection_handler.rs new file mode 100644 index 00000000000..b9986d9649f --- /dev/null +++ b/swarm/benches/connection_handler.rs @@ -0,0 +1,359 @@ +use async_std::stream::StreamExt; +use criterion::{criterion_group, criterion_main, Criterion}; +use libp2p_core::{ + transport::MemoryTransport, InboundUpgrade, Multiaddr, OutboundUpgrade, Transport, UpgradeInfo, +}; +use libp2p_identity::PeerId; +use libp2p_swarm::{ConnectionHandler, NetworkBehaviour, StreamProtocol}; +use std::{convert::Infallible, sync::atomic::AtomicUsize}; +use web_time::Duration; + +macro_rules! gen_behaviour { + ($($name:ident {$($field:ident),*};)*) => {$( + #[derive(libp2p_swarm::NetworkBehaviour, Default)] + #[behaviour(prelude = "libp2p_swarm::derive_prelude")] + struct $name { + $($field: SpinningBehaviour,)* + } + + impl BigBehaviour for $name { + fn behaviours(&mut self) -> &mut [SpinningBehaviour] { + unsafe { + std::slice::from_raw_parts_mut( + self as *mut Self as *mut SpinningBehaviour, + std::mem::size_of::() / std::mem::size_of::(), + ) + } + } + } + )*}; +} + +macro_rules! benchmarks { + ($( + $group:ident::[$( + $beh:ident::bench() + .name($name:ident) + .poll_count($count:expr) + .protocols_per_behaviour($protocols:expr), + )+]; + )*) => { + + $( + $( + fn $name(c: &mut Criterion) { + <$beh>::run_bench(c, $protocols, $count, true); + } + )+ + + criterion_group!($group, $($name),*); + )* + + criterion_main!($($group),*); + }; +} + +// fans go brrr +gen_behaviour! { + SpinningBehaviour5 { a, b, c, d, e }; + SpinningBehaviour10 { a, b, c, d, e, f, g, h, i, j }; + SpinningBehaviour20 { a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u }; +} + +benchmarks! { + singles::[ + SpinningBehaviour::bench().name(b).poll_count(1000).protocols_per_behaviour(10), + SpinningBehaviour::bench().name(c).poll_count(1000).protocols_per_behaviour(100), + SpinningBehaviour::bench().name(d).poll_count(1000).protocols_per_behaviour(1000), + ]; + big_5::[ + SpinningBehaviour5::bench().name(e).poll_count(1000).protocols_per_behaviour(2), + SpinningBehaviour5::bench().name(f).poll_count(1000).protocols_per_behaviour(20), + SpinningBehaviour5::bench().name(g).poll_count(1000).protocols_per_behaviour(200), + ]; + top_10::[ + SpinningBehaviour10::bench().name(h).poll_count(1000).protocols_per_behaviour(1), + SpinningBehaviour10::bench().name(i).poll_count(1000).protocols_per_behaviour(10), + SpinningBehaviour10::bench().name(j).poll_count(1000).protocols_per_behaviour(100), + ]; + lucky_20::[ + SpinningBehaviour20::bench().name(k).poll_count(500).protocols_per_behaviour(1), + SpinningBehaviour20::bench().name(l).poll_count(500).protocols_per_behaviour(10), + SpinningBehaviour20::bench().name(m).poll_count(500).protocols_per_behaviour(100), + ]; +} +//fn main() {} + +trait BigBehaviour: Sized { + fn behaviours(&mut self) -> &mut [SpinningBehaviour]; + + fn for_each_beh(&mut self, f: impl FnMut(&mut SpinningBehaviour)) { + self.behaviours().iter_mut().for_each(f); + } + + fn any_beh(&mut self, f: impl FnMut(&mut SpinningBehaviour) -> bool) -> bool { + self.behaviours().iter_mut().any(f) + } + + fn run_bench( + c: &mut Criterion, + protocols_per_behaviour: usize, + spam_count: usize, + static_protocols: bool, + ) where + Self: Default + NetworkBehaviour, + { + let name = format!( + "{}::bench().poll_count({}).protocols_per_behaviour({})", + std::any::type_name::(), + spam_count, + protocols_per_behaviour + ); + + let init = || { + let mut swarm_a = new_swarm(Self::default()); + let mut swarm_b = new_swarm(Self::default()); + + let behaviour_count = swarm_a.behaviours().len(); + let protocol_count = behaviour_count * protocols_per_behaviour; + let protocols = (0..protocol_count) + .map(|i| { + if static_protocols { + StreamProtocol::new(format!("/protocol/{i}").leak()) + } else { + StreamProtocol::try_from_owned(format!("/protocol/{i}")).unwrap() + } + }) + .collect::>() + .leak(); + + let mut protocol_chunks = protocols.chunks(protocols_per_behaviour); + swarm_a.for_each_beh(|b| b.protocols = protocol_chunks.next().unwrap()); + let mut protocol_chunks = protocols.chunks(protocols_per_behaviour); + swarm_b.for_each_beh(|b| b.protocols = protocol_chunks.next().unwrap()); + + swarm_a.for_each_beh(|b| b.iter_count = spam_count); + swarm_b.for_each_beh(|b| b.iter_count = 0); + + swarm_a.for_each_beh(|b| b.other_peer = Some(*swarm_b.local_peer_id())); + swarm_b.for_each_beh(|b| b.other_peer = Some(*swarm_a.local_peer_id())); + + static OFFSET: AtomicUsize = AtomicUsize::new(8000); + let offset = OFFSET.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + + swarm_a + .listen_on(format!("/memory/{offset}").parse().unwrap()) + .unwrap(); + swarm_b + .dial(format!("/memory/{offset}").parse::().unwrap()) + .unwrap(); + + (swarm_a, swarm_b) + }; + + c.bench_function(&name, |b| { + b.to_async(tokio::runtime::Builder::new_multi_thread().build().unwrap()) + .iter_batched( + init, + |(mut swarm_a, mut swarm_b)| async move { + while swarm_a.any_beh(|b| !b.finished) || swarm_b.any_beh(|b| !b.finished) { + futures::future::select(swarm_b.next(), swarm_a.next()).await; + } + }, + criterion::BatchSize::LargeInput, + ); + }); + } +} + +impl BigBehaviour for libp2p_swarm::Swarm { + fn behaviours(&mut self) -> &mut [SpinningBehaviour] { + self.behaviour_mut().behaviours() + } +} + +fn new_swarm(beh: T) -> libp2p_swarm::Swarm { + let keypair = libp2p_identity::Keypair::generate_ed25519(); + libp2p_swarm::Swarm::new( + MemoryTransport::default() + .upgrade(multistream_select::Version::V1) + .authenticate(libp2p_plaintext::Config::new(&keypair)) + .multiplex(libp2p_yamux::Config::default()) + .boxed(), + beh, + keypair.public().to_peer_id(), + libp2p_swarm::Config::without_executor().with_idle_connection_timeout(Duration::MAX), + ) +} + +/// Whole purpose of the behaviour is to rapidly call `poll` on the handler +/// configured amount of times and then emit event when finished. +#[derive(Default)] +struct SpinningBehaviour { + iter_count: usize, + protocols: &'static [StreamProtocol], + finished: bool, + emitted: bool, + other_peer: Option, +} + +#[derive(Debug)] +struct FinishedSpinning; + +impl NetworkBehaviour for SpinningBehaviour { + type ConnectionHandler = SpinningHandler; + type ToSwarm = FinishedSpinning; + + fn handle_established_inbound_connection( + &mut self, + _connection_id: libp2p_swarm::ConnectionId, + _peer: libp2p_identity::PeerId, + _local_addr: &libp2p_core::Multiaddr, + _remote_addr: &libp2p_core::Multiaddr, + ) -> Result, libp2p_swarm::ConnectionDenied> { + Ok(SpinningHandler { + iter_count: 0, + protocols: self.protocols, + }) + } + + fn handle_established_outbound_connection( + &mut self, + _connection_id: libp2p_swarm::ConnectionId, + _peer: libp2p_identity::PeerId, + _addr: &libp2p_core::Multiaddr, + _role_override: libp2p_core::Endpoint, + ) -> Result, libp2p_swarm::ConnectionDenied> { + Ok(SpinningHandler { + iter_count: self.iter_count, + protocols: self.protocols, + }) + } + + fn on_swarm_event(&mut self, _: libp2p_swarm::FromSwarm) {} + + fn on_connection_handler_event( + &mut self, + _peer_id: libp2p_identity::PeerId, + _connection_id: libp2p_swarm::ConnectionId, + _event: libp2p_swarm::THandlerOutEvent, + ) { + self.finished = true; + } + + fn poll( + &mut self, + _: &mut std::task::Context<'_>, + ) -> std::task::Poll>> + { + if self.finished && !self.emitted { + self.emitted = true; + std::task::Poll::Ready(libp2p_swarm::ToSwarm::GenerateEvent(FinishedSpinning)) + } else { + std::task::Poll::Pending + } + } +} + +impl BigBehaviour for SpinningBehaviour { + fn behaviours(&mut self) -> &mut [SpinningBehaviour] { + std::slice::from_mut(self) + } +} + +struct SpinningHandler { + iter_count: usize, + protocols: &'static [StreamProtocol], +} + +impl ConnectionHandler for SpinningHandler { + type FromBehaviour = Infallible; + + type ToBehaviour = FinishedSpinning; + + type InboundProtocol = Upgrade; + + type OutboundProtocol = Upgrade; + + type InboundOpenInfo = (); + + type OutboundOpenInfo = (); + + fn listen_protocol( + &self, + ) -> libp2p_swarm::SubstreamProtocol { + libp2p_swarm::SubstreamProtocol::new(Upgrade(self.protocols), ()) + } + + fn poll( + &mut self, + cx: &mut std::task::Context<'_>, + ) -> std::task::Poll< + libp2p_swarm::ConnectionHandlerEvent< + Self::OutboundProtocol, + Self::OutboundOpenInfo, + Self::ToBehaviour, + >, + > { + if self.iter_count == usize::MAX { + return std::task::Poll::Pending; + } + + if self.iter_count != 0 { + self.iter_count -= 1; + cx.waker().wake_by_ref(); + return std::task::Poll::Pending; + } + + self.iter_count = usize::MAX; + std::task::Poll::Ready(libp2p_swarm::ConnectionHandlerEvent::NotifyBehaviour( + FinishedSpinning, + )) + } + + fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + match event {} + } + + fn on_connection_event( + &mut self, + _event: libp2p_swarm::handler::ConnectionEvent< + Self::InboundProtocol, + Self::OutboundProtocol, + Self::InboundOpenInfo, + Self::OutboundOpenInfo, + >, + ) { + } +} + +pub struct Upgrade(&'static [StreamProtocol]); + +impl UpgradeInfo for Upgrade { + type Info = &'static StreamProtocol; + type InfoIter = std::slice::Iter<'static, StreamProtocol>; + + fn protocol_info(&self) -> Self::InfoIter { + self.0.iter() + } +} + +impl OutboundUpgrade for Upgrade { + type Output = libp2p_swarm::Stream; + type Error = Infallible; + type Future = futures::future::Ready>; + + fn upgrade_outbound(self, s: libp2p_swarm::Stream, _: Self::Info) -> Self::Future { + futures::future::ready(Ok(s)) + } +} + +impl InboundUpgrade for Upgrade { + type Output = libp2p_swarm::Stream; + type Error = Infallible; + type Future = futures::future::Ready>; + + fn upgrade_inbound(self, s: libp2p_swarm::Stream, _: Self::Info) -> Self::Future { + futures::future::ready(Ok(s)) + } +} diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index 69f95bca1d3..9c5e39830ed 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -31,8 +31,7 @@ pub use supported_protocols::SupportedProtocols; use crate::handler::{ AddressChange, ConnectionEvent, ConnectionHandler, DialUpgradeError, FullyNegotiatedInbound, - FullyNegotiatedOutbound, ListenUpgradeError, ProtocolSupport, ProtocolsAdded, ProtocolsChange, - UpgradeInfoSend, + FullyNegotiatedOutbound, ListenUpgradeError, ProtocolSupport, ProtocolsChange, UpgradeInfoSend, }; use crate::stream::ActiveStreamCounter; use crate::upgrade::{InboundUpgradeSend, OutboundUpgradeSend}; @@ -51,7 +50,7 @@ use libp2p_core::upgrade; use libp2p_core::upgrade::{NegotiationError, ProtocolError}; use libp2p_core::Endpoint; use libp2p_identity::PeerId; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; use std::fmt::{Display, Formatter}; use std::future::Future; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -153,8 +152,11 @@ where SubstreamRequested, >, - local_supported_protocols: HashSet, + local_supported_protocols: + HashMap::Info>, bool>, remote_supported_protocols: HashSet, + protocol_buffer: Vec, + idle_timeout: Duration, stream_counter: ActiveStreamCounter, } @@ -187,11 +189,17 @@ where idle_timeout: Duration, ) -> Self { let initial_protocols = gather_supported_protocols(&handler); + let mut buffer = Vec::new(); + if !initial_protocols.is_empty() { handler.on_connection_event(ConnectionEvent::LocalProtocolsChange( - ProtocolsChange::Added(ProtocolsAdded::from_set(&initial_protocols)), + ProtocolsChange::from_initial_protocols( + initial_protocols.keys().map(|e| &e.0), + &mut buffer, + ), )); } + Connection { muxing: muxer, handler, @@ -203,6 +211,7 @@ where requested_substreams: Default::default(), local_supported_protocols: initial_protocols, remote_supported_protocols: Default::default(), + protocol_buffer: buffer, idle_timeout, stream_counter: ActiveStreamCounter::default(), } @@ -250,6 +259,7 @@ where substream_upgrade_protocol_override, local_supported_protocols: supported_protocols, remote_supported_protocols, + protocol_buffer, idle_timeout, stream_counter, .. @@ -287,25 +297,24 @@ where ProtocolSupport::Added(protocols), )) => { if let Some(added) = - ProtocolsChange::add(remote_supported_protocols, &protocols) + ProtocolsChange::add(remote_supported_protocols, protocols, protocol_buffer) { handler.on_connection_event(ConnectionEvent::RemoteProtocolsChange(added)); - remote_supported_protocols.extend(protocols); + remote_supported_protocols.extend(protocol_buffer.drain(..)); } - continue; } Poll::Ready(ConnectionHandlerEvent::ReportRemoteProtocols( ProtocolSupport::Removed(protocols), )) => { - if let Some(removed) = - ProtocolsChange::remove(remote_supported_protocols, &protocols) - { + if let Some(removed) = ProtocolsChange::remove( + remote_supported_protocols, + protocols, + protocol_buffer, + ) { handler .on_connection_event(ConnectionEvent::RemoteProtocolsChange(removed)); - remote_supported_protocols.retain(|p| !protocols.contains(p)); } - continue; } } @@ -431,16 +440,16 @@ where } } - let new_protocols = gather_supported_protocols(handler); - let changes = ProtocolsChange::from_full_sets(supported_protocols, &new_protocols); + let changes = ProtocolsChange::from_full_sets( + supported_protocols, + handler.listen_protocol().upgrade().protocol_info(), + protocol_buffer, + ); if !changes.is_empty() { for change in changes { handler.on_connection_event(ConnectionEvent::LocalProtocolsChange(change)); } - - *supported_protocols = new_protocols; - continue; // Go back to the top, handler can potentially make progress again. } @@ -454,12 +463,14 @@ where } } -fn gather_supported_protocols(handler: &impl ConnectionHandler) -> HashSet { +fn gather_supported_protocols( + handler: &C, +) -> HashMap::Info>, bool> { handler .listen_protocol() .upgrade() .protocol_info() - .filter_map(|i| StreamProtocol::try_from_owned(i.as_ref().to_owned()).ok()) + .map(|info| (AsStrHashEq(info), true)) .collect() } @@ -734,6 +745,25 @@ enum Shutdown { Later(Delay), } +// Structure used to avoid allocations when storing the protocols in the `HashMap. +// Instead of allocating a new `String` for the key, +// we use `T::as_ref()` in `Hash`, `Eq` and `PartialEq` requirements. +pub(crate) struct AsStrHashEq(pub(crate) T); + +impl> Eq for AsStrHashEq {} + +impl> PartialEq for AsStrHashEq { + fn eq(&self, other: &Self) -> bool { + self.0.as_ref() == other.0.as_ref() + } +} + +impl> std::hash::Hash for AsStrHashEq { + fn hash(&self, state: &mut H) { + self.0.as_ref().hash(state) + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/swarm/src/connection/supported_protocols.rs b/swarm/src/connection/supported_protocols.rs index 0575046bb44..124ec93d669 100644 --- a/swarm/src/connection/supported_protocols.rs +++ b/swarm/src/connection/supported_protocols.rs @@ -40,7 +40,6 @@ impl SupportedProtocols { mod tests { use super::*; use crate::handler::{ProtocolsAdded, ProtocolsRemoved}; - use once_cell::sync::Lazy; #[test] fn protocols_change_added_returns_correct_changed_value() { @@ -70,19 +69,24 @@ mod tests { } fn add_foo() -> ProtocolsChange<'static> { - ProtocolsChange::Added(ProtocolsAdded::from_set(&FOO_PROTOCOLS)) + ProtocolsChange::Added(ProtocolsAdded { + protocols: FOO_PROTOCOLS.iter(), + }) } fn add_foo_bar() -> ProtocolsChange<'static> { - ProtocolsChange::Added(ProtocolsAdded::from_set(&FOO_BAR_PROTOCOLS)) + ProtocolsChange::Added(ProtocolsAdded { + protocols: FOO_BAR_PROTOCOLS.iter(), + }) } fn remove_foo() -> ProtocolsChange<'static> { - ProtocolsChange::Removed(ProtocolsRemoved::from_set(&FOO_PROTOCOLS)) + ProtocolsChange::Removed(ProtocolsRemoved { + protocols: FOO_PROTOCOLS.iter(), + }) } - static FOO_PROTOCOLS: Lazy> = - Lazy::new(|| HashSet::from([StreamProtocol::new("/foo")])); - static FOO_BAR_PROTOCOLS: Lazy> = - Lazy::new(|| HashSet::from([StreamProtocol::new("/foo"), StreamProtocol::new("/bar")])); + static FOO_PROTOCOLS: &[StreamProtocol] = &[StreamProtocol::new("/foo")]; + static FOO_BAR_PROTOCOLS: &[StreamProtocol] = + &[StreamProtocol::new("/foo"), StreamProtocol::new("/bar")]; } diff --git a/swarm/src/handler.rs b/swarm/src/handler.rs index 20980aff8bd..610b95b8cf1 100644 --- a/swarm/src/handler.rs +++ b/swarm/src/handler.rs @@ -46,22 +46,19 @@ mod one_shot; mod pending; mod select; +use crate::connection::AsStrHashEq; pub use crate::upgrade::{InboundUpgradeSend, OutboundUpgradeSend, SendWrapper, UpgradeInfoSend}; pub use map_in::MapInEvent; pub use map_out::MapOutEvent; pub use one_shot::{OneShotHandler, OneShotHandlerConfig}; pub use pending::PendingConnectionHandler; pub use select::ConnectionHandlerSelect; +use smallvec::SmallVec; use crate::StreamProtocol; -use ::either::Either; +use core::slice; use libp2p_core::Multiaddr; -use once_cell::sync::Lazy; -use smallvec::SmallVec; -use std::collections::hash_map::RandomState; -use std::collections::hash_set::{Difference, Intersection}; -use std::collections::HashSet; -use std::iter::Peekable; +use std::collections::{HashMap, HashSet}; use std::{error, fmt, io, task::Context, task::Poll, time::Duration}; /// A handler for a set of protocols used on a connection with a remote. @@ -335,64 +332,124 @@ pub enum ProtocolsChange<'a> { } impl<'a> ProtocolsChange<'a> { + /// Compute the protocol change for the initial set of protocols. + pub(crate) fn from_initial_protocols<'b, T: AsRef + 'b>( + new_protocols: impl IntoIterator, + buffer: &'a mut Vec, + ) -> Self { + buffer.clear(); + buffer.extend( + new_protocols + .into_iter() + .filter_map(|i| StreamProtocol::try_from_owned(i.as_ref().to_owned()).ok()), + ); + + ProtocolsChange::Added(ProtocolsAdded { + protocols: buffer.iter(), + }) + } + /// Compute the [`ProtocolsChange`] that results from adding `to_add` to `existing_protocols`. /// /// Returns `None` if the change is a no-op, i.e. `to_add` is a subset of `existing_protocols`. pub(crate) fn add( - existing_protocols: &'a HashSet, - to_add: &'a HashSet, + existing_protocols: &HashSet, + to_add: HashSet, + buffer: &'a mut Vec, ) -> Option { - let mut actually_added_protocols = to_add.difference(existing_protocols).peekable(); - - actually_added_protocols.peek()?; + buffer.clear(); + buffer.extend( + to_add + .into_iter() + .filter(|i| !existing_protocols.contains(i)), + ); + + if buffer.is_empty() { + return None; + } - Some(ProtocolsChange::Added(ProtocolsAdded { - protocols: actually_added_protocols, + Some(Self::Added(ProtocolsAdded { + protocols: buffer.iter(), })) } - /// Compute the [`ProtocolsChange`] that results from removing `to_remove` from `existing_protocols`. + /// Compute the [`ProtocolsChange`] that results from removing `to_remove` from `existing_protocols`. Removes the protocols from `existing_protocols`. /// /// Returns `None` if the change is a no-op, i.e. none of the protocols in `to_remove` are in `existing_protocols`. pub(crate) fn remove( - existing_protocols: &'a HashSet, - to_remove: &'a HashSet, + existing_protocols: &mut HashSet, + to_remove: HashSet, + buffer: &'a mut Vec, ) -> Option { - let mut actually_removed_protocols = existing_protocols.intersection(to_remove).peekable(); - - actually_removed_protocols.peek()?; + buffer.clear(); + buffer.extend( + to_remove + .into_iter() + .filter_map(|i| existing_protocols.take(&i)), + ); + + if buffer.is_empty() { + return None; + } - Some(ProtocolsChange::Removed(ProtocolsRemoved { - protocols: Either::Right(actually_removed_protocols), + Some(Self::Removed(ProtocolsRemoved { + protocols: buffer.iter(), })) } /// Compute the [`ProtocolsChange`]s required to go from `existing_protocols` to `new_protocols`. - pub(crate) fn from_full_sets( - existing_protocols: &'a HashSet, - new_protocols: &'a HashSet, + pub(crate) fn from_full_sets>( + existing_protocols: &mut HashMap, bool>, + new_protocols: impl IntoIterator, + buffer: &'a mut Vec, ) -> SmallVec<[Self; 2]> { - if existing_protocols == new_protocols { + buffer.clear(); + + // Initially, set the boolean for all protocols to `false`, meaning "not visited". + for v in existing_protocols.values_mut() { + *v = false; + } + + let mut new_protocol_count = 0; // We can only iterate `new_protocols` once, so keep track of its length separately. + for new_protocol in new_protocols { + existing_protocols + .entry(AsStrHashEq(new_protocol)) + .and_modify(|v| *v = true) // Mark protocol as visited (i.e. we still support it) + .or_insert_with_key(|k| { + // Encountered a previously unsupported protocol, remember it in `buffer`. + buffer.extend(StreamProtocol::try_from_owned(k.0.as_ref().to_owned()).ok()); + true + }); + new_protocol_count += 1; + } + + if new_protocol_count == existing_protocols.len() && buffer.is_empty() { return SmallVec::new(); } - let mut changes = SmallVec::new(); + let num_new_protocols = buffer.len(); + // Drain all protocols that we haven't visited. + // For existing protocols that are not in `new_protocols`, the boolean will be false, meaning we need to remove it. + existing_protocols.retain(|p, &mut is_supported| { + if !is_supported { + buffer.extend(StreamProtocol::try_from_owned(p.0.as_ref().to_owned()).ok()); + } - let mut added_protocols = new_protocols.difference(existing_protocols).peekable(); - let mut removed_protocols = existing_protocols.difference(new_protocols).peekable(); + is_supported + }); - if added_protocols.peek().is_some() { + let (added, removed) = buffer.split_at(num_new_protocols); + let mut changes = SmallVec::new(); + if !added.is_empty() { changes.push(ProtocolsChange::Added(ProtocolsAdded { - protocols: added_protocols, + protocols: added.iter(), })); } - - if removed_protocols.peek().is_some() { + if !removed.is_empty() { changes.push(ProtocolsChange::Removed(ProtocolsRemoved { - protocols: Either::Left(removed_protocols), + protocols: removed.iter(), })); } - changes } } @@ -400,33 +457,13 @@ impl<'a> ProtocolsChange<'a> { /// An [`Iterator`] over all protocols that have been added. #[derive(Debug, Clone)] pub struct ProtocolsAdded<'a> { - protocols: Peekable>, -} - -impl<'a> ProtocolsAdded<'a> { - pub(crate) fn from_set(protocols: &'a HashSet) -> Self { - ProtocolsAdded { - protocols: protocols.difference(&EMPTY_HASHSET).peekable(), - } - } + pub(crate) protocols: slice::Iter<'a, StreamProtocol>, } /// An [`Iterator`] over all protocols that have been removed. #[derive(Debug, Clone)] pub struct ProtocolsRemoved<'a> { - protocols: Either< - Peekable>, - Peekable>, - >, -} - -impl<'a> ProtocolsRemoved<'a> { - #[cfg(test)] - pub(crate) fn from_set(protocols: &'a HashSet) -> Self { - ProtocolsRemoved { - protocols: Either::Left(protocols.difference(&EMPTY_HASHSET).peekable()), - } - } + pub(crate) protocols: slice::Iter<'a, StreamProtocol>, } impl<'a> Iterator for ProtocolsAdded<'a> { @@ -691,6 +728,169 @@ where } } -/// A statically declared, empty [`HashSet`] allows us to work around borrow-checker rules for -/// [`ProtocolsAdded::from_set`]. The lifetimes don't work unless we have a [`HashSet`] with a `'static' lifetime. -static EMPTY_HASHSET: Lazy> = Lazy::new(HashSet::new); +#[cfg(test)] +mod test { + use super::*; + + fn protocol_set_of(s: &'static str) -> HashSet { + s.split_whitespace() + .map(|p| StreamProtocol::try_from_owned(format!("/{p}")).unwrap()) + .collect() + } + + fn test_remove( + existing: &mut HashSet, + to_remove: HashSet, + ) -> HashSet { + ProtocolsChange::remove(existing, to_remove, &mut Vec::new()) + .into_iter() + .flat_map(|c| match c { + ProtocolsChange::Added(_) => panic!("unexpected added"), + ProtocolsChange::Removed(r) => r.cloned(), + }) + .collect::>() + } + + #[test] + fn test_protocol_remove_subset() { + let mut existing = protocol_set_of("a b c"); + let to_remove = protocol_set_of("a b"); + + let change = test_remove(&mut existing, to_remove); + + assert_eq!(existing, protocol_set_of("c")); + assert_eq!(change, protocol_set_of("a b")); + } + + #[test] + fn test_protocol_remove_all() { + let mut existing = protocol_set_of("a b c"); + let to_remove = protocol_set_of("a b c"); + + let change = test_remove(&mut existing, to_remove); + + assert_eq!(existing, protocol_set_of("")); + assert_eq!(change, protocol_set_of("a b c")); + } + + #[test] + fn test_protocol_remove_superset() { + let mut existing = protocol_set_of("a b c"); + let to_remove = protocol_set_of("a b c d"); + + let change = test_remove(&mut existing, to_remove); + + assert_eq!(existing, protocol_set_of("")); + assert_eq!(change, protocol_set_of("a b c")); + } + + #[test] + fn test_protocol_remove_none() { + let mut existing = protocol_set_of("a b c"); + let to_remove = protocol_set_of("d"); + + let change = test_remove(&mut existing, to_remove); + + assert_eq!(existing, protocol_set_of("a b c")); + assert_eq!(change, protocol_set_of("")); + } + + #[test] + fn test_protocol_remove_none_from_empty() { + let mut existing = protocol_set_of(""); + let to_remove = protocol_set_of("d"); + + let change = test_remove(&mut existing, to_remove); + + assert_eq!(existing, protocol_set_of("")); + assert_eq!(change, protocol_set_of("")); + } + + fn test_from_full_sets( + existing: HashSet, + new: HashSet, + ) -> [HashSet; 2] { + let mut buffer = Vec::new(); + let mut existing = existing + .iter() + .map(|p| (AsStrHashEq(p.as_ref()), true)) + .collect::>(); + + let changes = ProtocolsChange::from_full_sets( + &mut existing, + new.iter().map(AsRef::as_ref), + &mut buffer, + ); + + let mut added_changes = HashSet::new(); + let mut removed_changes = HashSet::new(); + + for change in changes { + match change { + ProtocolsChange::Added(a) => { + added_changes.extend(a.cloned()); + } + ProtocolsChange::Removed(r) => { + removed_changes.extend(r.cloned()); + } + } + } + + [removed_changes, added_changes] + } + + #[test] + fn test_from_full_stes_subset() { + let existing = protocol_set_of("a b c"); + let new = protocol_set_of("a b"); + + let [removed_changes, added_changes] = test_from_full_sets(existing, new); + + assert_eq!(added_changes, protocol_set_of("")); + assert_eq!(removed_changes, protocol_set_of("c")); + } + + #[test] + fn test_from_full_sets_superset() { + let existing = protocol_set_of("a b"); + let new = protocol_set_of("a b c"); + + let [removed_changes, added_changes] = test_from_full_sets(existing, new); + + assert_eq!(added_changes, protocol_set_of("c")); + assert_eq!(removed_changes, protocol_set_of("")); + } + + #[test] + fn test_from_full_sets_intersection() { + let existing = protocol_set_of("a b c"); + let new = protocol_set_of("b c d"); + + let [removed_changes, added_changes] = test_from_full_sets(existing, new); + + assert_eq!(added_changes, protocol_set_of("d")); + assert_eq!(removed_changes, protocol_set_of("a")); + } + + #[test] + fn test_from_full_sets_disjoint() { + let existing = protocol_set_of("a b c"); + let new = protocol_set_of("d e f"); + + let [removed_changes, added_changes] = test_from_full_sets(existing, new); + + assert_eq!(added_changes, protocol_set_of("d e f")); + assert_eq!(removed_changes, protocol_set_of("a b c")); + } + + #[test] + fn test_from_full_sets_empty() { + let existing = protocol_set_of(""); + let new = protocol_set_of(""); + + let [removed_changes, added_changes] = test_from_full_sets(existing, new); + + assert_eq!(added_changes, protocol_set_of("")); + assert_eq!(removed_changes, protocol_set_of("")); + } +} diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index ec5b7a109cc..fb02cdce392 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1416,6 +1416,14 @@ impl Config { } } + #[doc(hidden)] + /// Used on connection benchmarks. + pub fn without_executor() -> Self { + Self { + pool_config: PoolConfig::new(None), + } + } + /// Sets executor to the `wasm` executor. /// Background tasks will be executed by the browser on the next micro-tick. /// From 4e4b5949288de9f4ab0fe0e48507c5a5e534a813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Sat, 6 Jul 2024 01:53:56 +0100 Subject: [PATCH 183/246] chore(swarm): reword CHANGELOG.md `libp2p-swarm` `0.45.0` hasn't been released. Pull-Request: #5483. --- Cargo.lock | 2 +- Cargo.toml | 2 +- swarm/CHANGELOG.md | 6 +----- swarm/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ee39cb1786..6c64ea3fea7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3293,7 +3293,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.45.1" +version = "0.45.0" dependencies = [ "async-std", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 1444b469c31..ab660cc90e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,7 +102,7 @@ libp2p-rendezvous = { version = "0.14.1", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.26.4", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } -libp2p-swarm = { version = "0.45.1", path = "swarm" } +libp2p-swarm = { version = "0.45.0", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 8cf8852dd76..bdb0b1cd5d0 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,15 +1,11 @@ -## 0.45.1 +## 0.45.0 - Optimize internal connection `fn poll`. New implementation now scales much better with number of listen protocols active. No changes to public API introduced. See [PR 5026](https://github.com/libp2p/rust-libp2p/pull/5026) - -## 0.45.0 - - Add peer_id to `FromSwarm::ListenFailure`. See [PR 4818](https://github.com/libp2p/rust-libp2p/pull/4818). - - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). - Add `#[track_caller]` on all `spawn` wrappers. diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 6ce99aa33c5..1e2842998a3 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition = "2021" rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.45.1" +version = "0.45.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" From 02fa7c8bb329d0a10411280bc01b039c52a2944d Mon Sep 17 00:00:00 2001 From: Darius Clark Date: Tue, 9 Jul 2024 13:41:21 -0400 Subject: [PATCH 184/246] feat: Add `ConnectionError` to `FromSwarm::ConnectionClosed` Resolves #5484. Pull-Request: #5485. --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- protocols/gossipsub/CHANGELOG.md | 4 ++++ protocols/gossipsub/Cargo.toml | 2 +- protocols/gossipsub/src/behaviour/tests.rs | 1 + protocols/perf/CHANGELOG.md | 4 ++++ protocols/perf/Cargo.toml | 2 +- protocols/perf/src/client/behaviour.rs | 1 + swarm/CHANGELOG.md | 2 ++ swarm/src/behaviour.rs | 5 +++-- swarm/src/lib.rs | 1 + swarm/src/test.rs | 2 ++ 12 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c64ea3fea7..ec114491e48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2801,7 +2801,7 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" -version = "0.46.2" +version = "0.47.0" dependencies = [ "async-std", "asynchronous-codec", @@ -3051,7 +3051,7 @@ dependencies = [ [[package]] name = "libp2p-perf" -version = "0.3.1" +version = "0.4.0" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index ab660cc90e9..7fa6856c26b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,7 +82,7 @@ libp2p-core = { version = "0.41.3", path = "core" } libp2p-dcutr = { version = "0.11.1", path = "protocols/dcutr" } libp2p-dns = { version = "0.41.1", path = "transports/dns" } libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" } -libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" } +libp2p-gossipsub = { version = "0.47.0", path = "protocols/gossipsub" } libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.46.0", path = "protocols/kad" } @@ -92,7 +92,7 @@ libp2p-metrics = { version = "0.14.2", path = "misc/metrics" } libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" } libp2p-muxer-test-harness = { path = "muxers/test-harness" } libp2p-noise = { version = "0.44.0", path = "transports/noise" } -libp2p-perf = { version = "0.3.1", path = "protocols/perf" } +libp2p-perf = { version = "0.4.0", path = "protocols/perf" } libp2p-ping = { version = "0.44.2", path = "protocols/ping" } libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index 970db3f1ec3..7c43b98f0a7 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.47.0 +- Add ConnectionError to FromSwarm::ConnectionClosed. + See [PR 5485](https://github.com/libp2p/rust-libp2p/pull/5485). + ## 0.46.2 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index f556443477f..f989e997bfb 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-gossipsub" edition = "2021" rust-version = { workspace = true } description = "Gossipsub protocol for libp2p" -version = "0.46.2" +version = "0.47.0" authors = ["Age Manning "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index 6cad719b5ab..fe861a674dd 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -268,6 +268,7 @@ where connection_id, endpoint: &fake_endpoint, remaining_established: active_connections, + cause: None, })); } } diff --git a/protocols/perf/CHANGELOG.md b/protocols/perf/CHANGELOG.md index d83e8b48472..b347f21e9e0 100644 --- a/protocols/perf/CHANGELOG.md +++ b/protocols/perf/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.0 +- Add ConnectionError to FromSwarm::ConnectionClosed. + See [PR 5485](https://github.com/libp2p/rust-libp2p/pull/5485). + ## 0.3.1 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 4f154ab1b08..abe58088caa 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-perf" edition = "2021" rust-version = { workspace = true } description = "libp2p perf protocol implementation" -version = "0.3.1" +version = "0.4.0" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/perf/src/client/behaviour.rs b/protocols/perf/src/client/behaviour.rs index 880bcdd9c83..5e430f8f0c1 100644 --- a/protocols/perf/src/client/behaviour.rs +++ b/protocols/perf/src/client/behaviour.rs @@ -116,6 +116,7 @@ impl NetworkBehaviour for Behaviour { connection_id: _, endpoint: _, remaining_established, + .. }) => { if remaining_established == 0 { assert!(self.connected.remove(&peer_id)); diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index bdb0b1cd5d0..f4901947b8b 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -10,6 +10,8 @@ See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). - Add `#[track_caller]` on all `spawn` wrappers. See [PR 5465](https://github.com/libp2p/rust-libp2p/pull/5465). +- Add ConnectionError to FromSwarm::ConnectionClosed. + See [PR 5485](https://github.com/libp2p/rust-libp2p/pull/5485). ## 0.44.2 diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index fc9045dfc3f..8a8418739c8 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -32,8 +32,8 @@ use crate::connection::ConnectionId; use crate::dial_opts::DialOpts; use crate::listen_opts::ListenOpts; use crate::{ - ConnectionDenied, ConnectionHandler, DialError, ListenError, THandler, THandlerInEvent, - THandlerOutEvent, + ConnectionDenied, ConnectionError, ConnectionHandler, DialError, ListenError, THandler, + THandlerInEvent, THandlerOutEvent, }; use libp2p_core::{transport::ListenerId, ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; @@ -481,6 +481,7 @@ pub struct ConnectionClosed<'a> { pub peer_id: PeerId, pub connection_id: ConnectionId, pub endpoint: &'a ConnectedPoint, + pub cause: Option<&'a ConnectionError>, pub remaining_established: usize, } diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index fb02cdce392..31eb2aa28f5 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -909,6 +909,7 @@ where peer_id, connection_id: id, endpoint: &endpoint, + cause: error.as_ref(), remaining_established: num_established as usize, })); self.pending_swarm_events diff --git a/swarm/src/test.rs b/swarm/src/test.rs index 547277550bb..d49b504392a 100644 --- a/swarm/src/test.rs +++ b/swarm/src/test.rs @@ -301,6 +301,7 @@ where connection_id, endpoint, remaining_established, + cause, }: ConnectionClosed, ) { let mut other_closed_connections = self @@ -350,6 +351,7 @@ where connection_id, endpoint, remaining_established, + cause, })); } } From c19c1409824a68586c3779729329040a554f12db Mon Sep 17 00:00:00 2001 From: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Date: Wed, 10 Jul 2024 02:44:38 +0300 Subject: [PATCH 185/246] fix(webocket): Avoid panic when polling quicksink after errors Pull-Request: #5482. --- Cargo.lock | 3 +- Cargo.toml | 2 +- transports/websocket/CHANGELOG.md | 6 +++ transports/websocket/Cargo.toml | 3 +- transports/websocket/src/framed.rs | 2 +- transports/websocket/src/quicksink.rs | 72 ++++++++++++++++++--------- 6 files changed, 61 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec114491e48..6a9dc56e987 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3492,7 +3492,7 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.43.1" +version = "0.43.2" dependencies = [ "async-std", "either", @@ -3507,6 +3507,7 @@ dependencies = [ "rcgen", "rw-stream-sink", "soketto", + "thiserror", "tracing", "url", "webpki-roots 0.25.2", diff --git a/Cargo.toml b/Cargo.toml index 7fa6856c26b..84767573b9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,7 +112,7 @@ libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.2.1", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } -libp2p-websocket = { version = "0.43.1", path = "transports/websocket" } +libp2p-websocket = { version = "0.43.2", path = "transports/websocket" } libp2p-websocket-websys = { version = "0.3.2", path = "transports/websocket-websys" } libp2p-webtransport-websys = { version = "0.3.0", path = "transports/webtransport-websys" } libp2p-yamux = { version = "0.45.2", path = "muxers/yamux" } diff --git a/transports/websocket/CHANGELOG.md b/transports/websocket/CHANGELOG.md index d206cbac6a1..419ff41c6fc 100644 --- a/transports/websocket/CHANGELOG.md +++ b/transports/websocket/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.43.2 + +- fix: Avoid websocket panic on polling after errors. See [PR 5482]. + +[PR 5482]: https://github.com/libp2p/rust-libp2p/pull/5482 + ## 0.43.1 ## 0.43.0 diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index b022d95ca47..f1b0a413115 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-websocket" edition = "2021" rust-version = { workspace = true } description = "WebSocket transport for libp2p" -version = "0.43.1" +version = "0.43.2" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -21,6 +21,7 @@ pin-project-lite = "0.2.14" rw-stream-sink = { workspace = true } soketto = "0.8.0" tracing = { workspace = true } +thiserror = "1.0.61" url = "2.5" webpki-roots = "0.25" diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index f6f99d18580..69a01fdbd46 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -571,7 +571,7 @@ fn location_to_multiaddr(location: &str) -> Result> { /// The websocket connection. pub struct Connection { receiver: BoxStream<'static, Result>, - sender: Pin + Send>>, + sender: Pin> + Send>>, _marker: std::marker::PhantomData, } diff --git a/transports/websocket/src/quicksink.rs b/transports/websocket/src/quicksink.rs index cb2c98b078f..4f620536ea1 100644 --- a/transports/websocket/src/quicksink.rs +++ b/transports/websocket/src/quicksink.rs @@ -30,14 +30,6 @@ // Ok::<_, io::Error>(stdout) // }); // ``` -// -// # Panics -// -// - If any of the [`Sink`] methods produce an error, the sink transitions -// to a failure state and none of its methods must be called afterwards or -// else a panic will occur. -// - If [`Sink::poll_close`] has been called, no other sink method must be -// called afterwards or else a panic will be caused. use futures::{ready, sink::Sink}; use pin_project_lite::pin_project; @@ -102,6 +94,15 @@ enum State { Failed, } +/// Errors the `Sink` may return. +#[derive(Debug, thiserror::Error)] +pub(crate) enum Error { + #[error("Error while sending over the sink, {0}")] + Send(E), + #[error("The Sink has closed")] + Closed, +} + pin_project! { /// `SinkImpl` implements the `Sink` trait. #[derive(Debug)] @@ -119,7 +120,7 @@ where F: FnMut(S, Action) -> T, T: Future>, { - type Error = E; + type Error = Error; fn poll_ready(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let mut this = self.project(); @@ -135,7 +136,7 @@ where Err(e) => { this.future.set(None); *this.state = State::Failed; - Poll::Ready(Err(e)) + Poll::Ready(Err(Error::Send(e))) } } } @@ -143,20 +144,19 @@ where Ok(_) => { this.future.set(None); *this.state = State::Closed; - panic!("SinkImpl::poll_ready called on a closing sink.") + Poll::Ready(Err(Error::Closed)) } Err(e) => { this.future.set(None); *this.state = State::Failed; - Poll::Ready(Err(e)) + Poll::Ready(Err(Error::Send(e))) } }, State::Empty => { assert!(this.param.is_some()); Poll::Ready(Ok(())) } - State::Closed => panic!("SinkImpl::poll_ready called on a closed sink."), - State::Failed => panic!("SinkImpl::poll_ready called after error."), + State::Closed | State::Failed => Poll::Ready(Err(Error::Closed)), } } @@ -193,7 +193,7 @@ where Err(e) => { this.future.set(None); *this.state = State::Failed; - return Poll::Ready(Err(e)); + return Poll::Ready(Err(Error::Send(e))); } }, State::Flushing => { @@ -207,7 +207,7 @@ where Err(e) => { this.future.set(None); *this.state = State::Failed; - return Poll::Ready(Err(e)); + return Poll::Ready(Err(Error::Send(e))); } } } @@ -221,11 +221,10 @@ where Err(e) => { this.future.set(None); *this.state = State::Failed; - return Poll::Ready(Err(e)); + return Poll::Ready(Err(Error::Send(e))); } }, - State::Closed => return Poll::Ready(Ok(())), - State::Failed => panic!("SinkImpl::poll_flush called after error."), + State::Closed | State::Failed => return Poll::Ready(Err(Error::Closed)), } } } @@ -253,7 +252,7 @@ where Err(e) => { this.future.set(None); *this.state = State::Failed; - return Poll::Ready(Err(e)); + return Poll::Ready(Err(Error::Send(e))); } }, State::Flushing => { @@ -266,7 +265,7 @@ where Err(e) => { this.future.set(None); *this.state = State::Failed; - return Poll::Ready(Err(e)); + return Poll::Ready(Err(Error::Send(e))); } } } @@ -280,11 +279,11 @@ where Err(e) => { this.future.set(None); *this.state = State::Failed; - return Poll::Ready(Err(e)); + return Poll::Ready(Err(Error::Send(e))); } }, State::Closed => return Poll::Ready(Ok(())), - State::Failed => panic!("SinkImpl::poll_closed called after error."), + State::Failed => return Poll::Ready(Err(Error::Closed)), } } } @@ -347,4 +346,31 @@ mod tests { assert_eq!(&expected[..], &actual[..]) }); } + + #[test] + fn error_does_not_panic() { + task::block_on(async { + let sink = make_sink(io::stdout(), |mut _stdout, _action| async move { + Err(io::Error::new(io::ErrorKind::Other, "oh no")) + }); + + futures::pin_mut!(sink); + + let result = sink.send("hello").await; + match result { + Err(crate::quicksink::Error::Send(e)) => { + assert_eq!(e.kind(), io::ErrorKind::Other); + assert_eq!(e.to_string(), "oh no") + } + _ => panic!("unexpected result: {:?}", result), + }; + + // Call send again, expect not to panic. + let result = sink.send("hello").await; + match result { + Err(crate::quicksink::Error::Closed) => {} + _ => panic!("unexpected result: {:?}", result), + }; + }) + } } From 8e28edf69a5f25d1d919962a70fa32203b48f8dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 08:16:42 +0000 Subject: [PATCH 186/246] deps: bump obi1kenobi/cargo-semver-checks-action from 2.4 to 2.5 Pull-Request: #5499. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f1fe263a2d..c8ff0521ce5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -310,7 +310,7 @@ jobs: - uses: actions/checkout@v4 - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.31.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin shell: bash - - uses: obi1kenobi/cargo-semver-checks-action@c7306483f698c511eaf7416d1bf2e1958c90140f # v2 + - uses: obi1kenobi/cargo-semver-checks-action@ca26a44cfb670b2078c8f757d06e696a7c3820cf # v2 rustfmt: runs-on: ubuntu-latest From e2e98ad5e8f8ab2c0ae037b69a3a7149a116bf02 Mon Sep 17 00:00:00 2001 From: EdwardJES <107906898+EdwardJES@users.noreply.github.com> Date: Wed, 17 Jul 2024 07:15:59 +1000 Subject: [PATCH 187/246] fix: rendezvous identify example This pr closes https://github.com/libp2p/rust-libp2p/issues/5388 by explicitly adding the local observed address, noting this is out of protocol behaviour in non-example cases Pull-Request: #5496. --- examples/rendezvous/src/bin/rzv-identify.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/rendezvous/src/bin/rzv-identify.rs b/examples/rendezvous/src/bin/rzv-identify.rs index 1d545592829..ff637aa6f49 100644 --- a/examples/rendezvous/src/bin/rzv-identify.rs +++ b/examples/rendezvous/src/bin/rzv-identify.rs @@ -76,8 +76,12 @@ async fn main() { } // once `/identify` did its job, we know our external address and can register SwarmEvent::Behaviour(MyBehaviourEvent::Identify(identify::Event::Received { + info, .. })) => { + // Register our external address. Needs to be done explicitly + // for this case, as it's a local address. + swarm.add_external_address(info.observed_addr); if let Err(error) = swarm.behaviour_mut().rendezvous.register( rendezvous::Namespace::from_static("rendezvous"), rendezvous_point, From 1617abb3bfcf3e8663568e90a8fc4009aef04ba9 Mon Sep 17 00:00:00 2001 From: Arpan Kapoor Date: Thu, 18 Jul 2024 20:30:33 +0530 Subject: [PATCH 188/246] fix(tls): fix rustls panic due to critical libp2p extension Resolves #5487. Pull-Request: #5498. --- Cargo.lock | 24 +++++++++--------- Cargo.toml | 2 +- transports/tls/CHANGELOG.md | 5 ++++ transports/tls/Cargo.toml | 2 +- transports/tls/src/certificate.rs | 41 +++++++++++++++++++++++++++++++ transports/tls/src/lib.rs | 17 ++++++++++--- 6 files changed, 73 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a9dc56e987..80a186f0026 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1727,7 +1727,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls 0.23.9", + "rustls 0.23.11", "rustls-pki-types", ] @@ -3159,7 +3159,7 @@ dependencies = [ "quinn", "rand 0.8.5", "ring 0.17.8", - "rustls 0.23.9", + "rustls 0.23.11", "socket2 0.5.7", "thiserror", "tokio", @@ -3373,7 +3373,7 @@ dependencies = [ [[package]] name = "libp2p-tls" -version = "0.4.0" +version = "0.4.1" dependencies = [ "futures", "futures-rustls", @@ -3385,7 +3385,7 @@ dependencies = [ "libp2p-yamux", "rcgen", "ring 0.17.8", - "rustls 0.23.9", + "rustls 0.23.11", "rustls-webpki 0.101.7", "thiserror", "tokio", @@ -4607,7 +4607,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.9", + "rustls 0.23.11", "thiserror", "tokio", "tracing", @@ -4623,7 +4623,7 @@ dependencies = [ "rand 0.8.5", "ring 0.17.8", "rustc-hash", - "rustls 0.23.9", + "rustls 0.23.11", "slab", "thiserror", "tinyvec", @@ -5156,21 +5156,21 @@ dependencies = [ "log", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.5", "subtle", "zeroize", ] [[package]] name = "rustls" -version = "0.23.9" +version = "0.23.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b" +checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki 0.102.5", "subtle", "zeroize", ] @@ -5203,9 +5203,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" dependencies = [ "ring 0.17.8", "rustls-pki-types", diff --git a/Cargo.toml b/Cargo.toml index 84767573b9e..55fc43d5b5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,7 +106,7 @@ libp2p-swarm = { version = "0.45.0", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } -libp2p-tls = { version = "0.4.0", path = "transports/tls" } +libp2p-tls = { version = "0.4.1", path = "transports/tls" } libp2p-uds = { version = "0.40.0", path = "transports/uds" } libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } diff --git a/transports/tls/CHANGELOG.md b/transports/tls/CHANGELOG.md index 3c6d0a2a1f5..0343c690834 100644 --- a/transports/tls/CHANGELOG.md +++ b/transports/tls/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.1 + +- Fix a panic caused by `rustls` parsing the libp2p TLS extension. + See [PR 5498](https://github.com/libp2p/rust-libp2p/pull/5498). + ## 0.4.0 - Upgrade `rustls` to `0.23`. See [PR 5385](https://github.com/libp2p/rust-libp2p/pull/5385) diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index a4817f20336..c4b30951e66 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-tls" -version = "0.4.0" +version = "0.4.1" edition = "2021" rust-version = { workspace = true } description = "TLS configuration based on libp2p TLS specs." diff --git a/transports/tls/src/certificate.rs b/transports/tls/src/certificate.rs index bbd353e32bd..65b373bcf9b 100644 --- a/transports/tls/src/certificate.rs +++ b/transports/tls/src/certificate.rs @@ -26,6 +26,8 @@ use libp2p_identity as identity; use libp2p_identity::PeerId; use x509_parser::{prelude::*, signature_algorithm::SignatureAlgorithm}; +use std::sync::Arc; + /// The libp2p Public Key Extension is a X.509 extension /// with the Object Identifier 1.3.6.1.4.1.53594.1.1, /// allocated by IANA to the libp2p project at Protocol Labs. @@ -42,6 +44,45 @@ const P2P_SIGNING_PREFIX: [u8; 21] = *b"libp2p-tls-handshake:"; // Similarly, hash functions with an output length less than 256 bits MUST NOT be used. static P2P_SIGNATURE_ALGORITHM: &rcgen::SignatureAlgorithm = &rcgen::PKCS_ECDSA_P256_SHA256; +#[derive(Debug)] +pub(crate) struct AlwaysResolvesCert(Arc); + +impl AlwaysResolvesCert { + pub(crate) fn new( + cert: rustls::pki_types::CertificateDer<'static>, + key: &rustls::pki_types::PrivateKeyDer<'_>, + ) -> Result { + let certified_key = rustls::sign::CertifiedKey::new( + vec![cert], + rustls::crypto::ring::sign::any_ecdsa_type(key)?, + ); + Ok(Self(Arc::new(certified_key))) + } +} + +impl rustls::client::ResolvesClientCert for AlwaysResolvesCert { + fn resolve( + &self, + _root_hint_subjects: &[&[u8]], + _sigschemes: &[rustls::SignatureScheme], + ) -> Option> { + Some(Arc::clone(&self.0)) + } + + fn has_certs(&self) -> bool { + true + } +} + +impl rustls::server::ResolvesServerCert for AlwaysResolvesCert { + fn resolve( + &self, + _client_hello: rustls::server::ClientHello<'_>, + ) -> Option> { + Some(Arc::clone(&self.0)) + } +} + /// Generates a self-signed TLS certificate that includes a libp2p-specific /// certificate extension containing the public key of the given keypair. pub fn generate( diff --git a/transports/tls/src/lib.rs b/transports/tls/src/lib.rs index 741a4b48077..3aa66db12b3 100644 --- a/transports/tls/src/lib.rs +++ b/transports/tls/src/lib.rs @@ -29,6 +29,7 @@ pub mod certificate; mod upgrade; mod verifier; +use certificate::AlwaysResolvesCert; use libp2p_identity::Keypair; use libp2p_identity::PeerId; use std::sync::Arc; @@ -49,6 +50,11 @@ pub fn make_client_config( let mut provider = rustls::crypto::ring::default_provider(); provider.cipher_suites = verifier::CIPHERSUITES.to_vec(); + let cert_resolver = Arc::new( + AlwaysResolvesCert::new(certificate, &private_key) + .expect("Client cert key DER is valid; qed"), + ); + let mut crypto = rustls::ClientConfig::builder_with_provider(provider.into()) .with_protocol_versions(verifier::PROTOCOL_VERSIONS) .expect("Cipher suites and kx groups are configured; qed") @@ -56,8 +62,7 @@ pub fn make_client_config( .with_custom_certificate_verifier(Arc::new( verifier::Libp2pCertificateVerifier::with_remote_peer_id(remote_peer_id), )) - .with_client_auth_cert(vec![certificate], private_key) - .expect("Client cert key DER is valid; qed"); + .with_client_cert_resolver(cert_resolver); crypto.alpn_protocols = vec![P2P_ALPN.to_vec()]; Ok(crypto) @@ -72,12 +77,16 @@ pub fn make_server_config( let mut provider = rustls::crypto::ring::default_provider(); provider.cipher_suites = verifier::CIPHERSUITES.to_vec(); + let cert_resolver = Arc::new( + AlwaysResolvesCert::new(certificate, &private_key) + .expect("Server cert key DER is valid; qed"), + ); + let mut crypto = rustls::ServerConfig::builder_with_provider(provider.into()) .with_protocol_versions(verifier::PROTOCOL_VERSIONS) .expect("Cipher suites and kx groups are configured; qed") .with_client_cert_verifier(Arc::new(verifier::Libp2pCertificateVerifier::new())) - .with_single_cert(vec![certificate], private_key) - .expect("Server cert key DER is valid; qed"); + .with_cert_resolver(cert_resolver); crypto.alpn_protocols = vec![P2P_ALPN.to_vec()]; Ok(crypto) From a749a41b95441a3dc87c61c472e7a9f00ca997fc Mon Sep 17 00:00:00 2001 From: Probot <94048855+Prabhat1308@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:09:11 +0530 Subject: [PATCH 189/246] fix(relay): Add resource limits to `CircuitReq` to be set Fixes #5466 Adds resource limits to `CircuitReq` to be set . Pull-Request: #5493. --- protocols/relay/CHANGELOG.md | 2 ++ protocols/relay/src/protocol/inbound_hop.rs | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index 125f51e4961..f49e57af0f7 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,6 +1,8 @@ ## 0.17.3 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). +- Add resource limits to `CircuitReq` to be set + See [PR 5493](https://github.com/libp2p/rust-libp2p/pull/5493) ## 0.17.2 diff --git a/protocols/relay/src/protocol/inbound_hop.rs b/protocols/relay/src/protocol/inbound_hop.rs index 57b5d9ad039..401c6258176 100644 --- a/protocols/relay/src/protocol/inbound_hop.rs +++ b/protocols/relay/src/protocol/inbound_hop.rs @@ -115,6 +115,8 @@ impl ReservationReq { pub struct CircuitReq { dst: PeerId, substream: Framed>, + max_circuit_duration: Duration, + max_circuit_bytes: u64, } impl CircuitReq { @@ -127,7 +129,15 @@ impl CircuitReq { type_pb: proto::HopMessageType::STATUS, peer: None, reservation: None, - limit: None, + limit: Some(proto::Limit { + duration: Some( + self.max_circuit_duration + .as_secs() + .try_into() + .expect("`max_circuit_duration` not to exceed `u32::MAX`."), + ), + data: Some(self.max_circuit_bytes), + }), status: Some(proto::Status::OK), }; @@ -204,7 +214,12 @@ pub(crate) async fn handle_inbound_request( let dst = peer_id_res.map_err(|_| Error::ParsePeerId)?; - Either::Right(CircuitReq { dst, substream }) + Either::Right(CircuitReq { + dst, + substream, + max_circuit_duration, + max_circuit_bytes, + }) } Type::STATUS => return Err(Error::UnexpectedTypeStatus), }; From 879d5941b326126b95e2c77c73b64cc9d50ff852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Wed, 24 Jul 2024 12:03:40 +0100 Subject: [PATCH 190/246] fix: update Cargo.lock To address [RUSTSEC-2024-0357](https://rustsec.org/advisories/RUSTSEC-2024-0357.html) Pull-Request: #5511. --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80a186f0026..3fda6b57aa8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4092,9 +4092,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.60" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -4124,9 +4124,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.96" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3812c071ba60da8b5677cc12bcb1d42989a65553772897a7e0355545a819838f" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", From 4a16b6181d36cd703066a227deff57c6ebe91f7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:28:52 +0000 Subject: [PATCH 191/246] deps: bump obi1kenobi/cargo-semver-checks-action from 2.5 to 2.6 Pull-Request: #5512. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8ff0521ce5..54ddcf47028 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -310,7 +310,7 @@ jobs: - uses: actions/checkout@v4 - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.31.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin shell: bash - - uses: obi1kenobi/cargo-semver-checks-action@ca26a44cfb670b2078c8f757d06e696a7c3820cf # v2 + - uses: obi1kenobi/cargo-semver-checks-action@7272cc2caa468d3e009a2b0a9cc366839348237b # v2 rustfmt: runs-on: ubuntu-latest From 055b179a2354ea174dbb8beb38804719d655667c Mon Sep 17 00:00:00 2001 From: dewmal Date: Mon, 29 Jul 2024 19:35:19 +0530 Subject: [PATCH 192/246] docs(README): Add Ceylon to the notable users section. I have added Project Ceylon: A Multi-Agent System (MAS) Development Framework to the notable users list. Pull-Request: #5513. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4d72626e413..77323a1d659 100644 --- a/README.md +++ b/README.md @@ -102,3 +102,4 @@ Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). - [Substrate](https://github.com/paritytech/substrate) - Framework for blockchain innovation, used by [Polkadot](https://www.parity.io/technologies/polkadot/). - [Taple](https://github.com/opencanarias/taple-core) - Sustainable DLT for asset and process traceability by [OpenCanarias](https://www.opencanarias.com/en/). +- [Ceylon](https://github.com/ceylonai/ceylon) - A Multi-Agent System (MAS) Development Framwork. From 41e2d5dc4ad37af4b3256dc7c089188d1589e6e5 Mon Sep 17 00:00:00 2001 From: stormshield-frb <144998884+stormshield-frb@users.noreply.github.com> Date: Mon, 29 Jul 2024 21:43:39 +0200 Subject: [PATCH 193/246] fix(relay): wake the relay Listener on close When closing a relayed `Listener` manually, the `TransportEvent::ListenerClosed` generated by the `relay::priv_client::Transport` is never forwarded back up to the `Swarm`, causing the `Swarm` to never remove the corresponding listener and never emitting the `SwarmEvent::ListenerClosed` event. This happens because, when stopping a relayed listener manually, the call to the [`close()` function](https://github.com/libp2p/rust-libp2p/blob/master/protocols/relay/src/priv_client/transport.rs#L324), is done outside the `poll` function, which mean nothing is triggering a wake up call to wake up the polling. Unfortunately, even if the [`listeners` (`SelectAll`) is always polled](https://github.com/libp2p/rust-libp2p/blob/master/protocols/relay/src/priv_client/transport.rs#L241) after a call to the `close` method, since `SelectAll` uses a `FuturesUnordered` internally, the poll does nothing. Indeed, the `FuturesUnordered` states that: ```rust /// This structure is optimized to manage a large number of futures. /// Futures managed by [`FuturesUnordered`] will only be polled when they /// generate wake-up notifications. This reduces the required amount of work /// needed to poll large numbers of futures. ``` Since means that when closing a relayed listener manually (calling `swarm.remove_listener`), it is never removed. This PR fixes that by triggering a `waker` when calling the `close` function. Pull-Request: #5491. --- protocols/relay/CHANGELOG.md | 3 +++ protocols/relay/src/priv_client/transport.rs | 26 +++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index f49e57af0f7..97638d1ae6a 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,9 +1,12 @@ ## 0.17.3 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). +- Fix manual closure of relayed listener. + See [PR 5491](https://github.com/libp2p/rust-libp2p/pull/5491) - Add resource limits to `CircuitReq` to be set See [PR 5493](https://github.com/libp2p/rust-libp2p/pull/5493) + ## 0.17.2 - Fix support for unlimited relay connection according to spec. diff --git a/protocols/relay/src/priv_client/transport.rs b/protocols/relay/src/priv_client/transport.rs index 7147f0b5e55..b4374aa4672 100644 --- a/protocols/relay/src/priv_client/transport.rs +++ b/protocols/relay/src/priv_client/transport.rs @@ -27,7 +27,6 @@ use crate::RequestId; use futures::channel::mpsc; use futures::channel::oneshot; use futures::future::{ready, BoxFuture, FutureExt, Ready}; -use futures::ready; use futures::sink::SinkExt; use futures::stream::SelectAll; use futures::stream::{Stream, StreamExt}; @@ -36,7 +35,7 @@ use libp2p_core::transport::{ListenerId, TransportError, TransportEvent}; use libp2p_identity::PeerId; use std::collections::VecDeque; use std::pin::Pin; -use std::task::{Context, Poll}; +use std::task::{Context, Poll, Waker}; use thiserror::Error; /// A [`Transport`] enabling client relay capabilities. @@ -151,6 +150,7 @@ impl libp2p_core::Transport for Transport { queued_events: Default::default(), from_behaviour, is_closed: false, + waker: None, }; self.listeners.push(listener); Ok(()) @@ -313,6 +313,7 @@ pub(crate) struct Listener { /// The listener can be closed either manually with [`Transport::remove_listener`](libp2p_core::Transport) or if /// the sender side of the `from_behaviour` channel is dropped. is_closed: bool, + waker: Option, } impl Listener { @@ -328,6 +329,10 @@ impl Listener { reason, }); self.is_closed = true; + + if let Some(waker) = self.waker.take() { + waker.wake(); + } } } @@ -337,18 +342,27 @@ impl Stream for Listener { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { loop { if let Some(event) = self.queued_events.pop_front() { + self.waker = None; return Poll::Ready(Some(event)); } if self.is_closed { // Terminate the stream if the listener closed and all remaining events have been reported. + self.waker = None; return Poll::Ready(None); } - let Some(msg) = ready!(self.from_behaviour.poll_next_unpin(cx)) else { - // Sender of `from_behaviour` has been dropped, signaling listener to close. - self.close(Ok(())); - continue; + let msg = match self.from_behaviour.poll_next_unpin(cx) { + Poll::Ready(Some(msg)) => msg, + Poll::Ready(None) => { + // Sender of `from_behaviour` has been dropped, signaling listener to close. + self.close(Ok(())); + continue; + } + Poll::Pending => { + self.waker = Some(cx.waker().clone()); + return Poll::Pending; + } }; match msg { From 06b5847a89bfea8b95c443e088eba08a66a04418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Tue, 30 Jul 2024 17:03:00 +0100 Subject: [PATCH 194/246] chore: address clippy beta lints Pull-Request: #5515. --- hole-punching-tests/src/main.rs | 4 +--- interop-tests/src/arch.rs | 3 +-- protocols/ping/src/protocol.rs | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/hole-punching-tests/src/main.rs b/hole-punching-tests/src/main.rs index f09fbb1e6a0..bbecc948e08 100644 --- a/hole-punching-tests/src/main.rs +++ b/hole-punching-tests/src/main.rs @@ -294,9 +294,7 @@ impl RedisClient { tracing::debug!("Pushing {key}={value} to redis"); - self.inner.rpush(key, value).await?; - - Ok(()) + self.inner.rpush(key, value).await.map_err(Into::into) } async fn pop(&mut self, key: &str) -> Result diff --git a/interop-tests/src/arch.rs b/interop-tests/src/arch.rs index fb229434981..a7755b95977 100644 --- a/interop-tests/src/arch.rs +++ b/interop-tests/src/arch.rs @@ -179,8 +179,7 @@ pub(crate) mod native { pub(crate) async fn rpush(&self, key: &str, value: String) -> Result<()> { let mut conn = self.0.get_async_connection().await?; - conn.rpush(key, value).await?; - Ok(()) + conn.rpush(key, value).await.map_err(Into::into) } } } diff --git a/protocols/ping/src/protocol.rs b/protocols/ping/src/protocol.rs index 9b4d7da98db..8fc18505d35 100644 --- a/protocols/ping/src/protocol.rs +++ b/protocols/ping/src/protocol.rs @@ -44,8 +44,7 @@ pub const PROTOCOL_NAME: StreamProtocol = StreamProtocol::new("/ipfs/ping/1.0.0" /// > Nagle's algorithm, delayed acks and similar configuration options /// > which can affect latencies especially on otherwise low-volume /// > connections. -#[derive(Default, Debug, Copy, Clone)] -pub(crate) struct Ping; + const PING_SIZE: usize = 32; /// Sends a ping and waits for the pong. From 5b4c43cc4361bfdd1a0f7d06ce4d700796717d2f Mon Sep 17 00:00:00 2001 From: Hannes <55623006+umgefahren@users.noreply.github.com> Date: Fri, 2 Aug 2024 00:21:21 +0200 Subject: [PATCH 195/246] chore: Update cargo semver binary I updated the semver binary to the new version, this should make the CI run again. Pull-Request: #5520. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54ddcf47028..648945820fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -308,9 +308,9 @@ jobs: RUSTFLAGS: '' steps: - uses: actions/checkout@v4 - - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.31.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin + - run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.33.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin shell: bash - - uses: obi1kenobi/cargo-semver-checks-action@7272cc2caa468d3e009a2b0a9cc366839348237b # v2 + - uses: obi1kenobi/cargo-semver-checks-action@7272cc2caa468d3e009a2b0a9cc366839348237b # v2.6 rustfmt: runs-on: ubuntu-latest From 5c11f4a9e42f7675c58c1604ed7039a7740e582d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 2 Aug 2024 12:05:54 +0100 Subject: [PATCH 196/246] docs(swarm): doc DialError::Denied Pull-Request: #5510. --- swarm/src/lib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 31eb2aa28f5..03e30240771 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1538,9 +1538,7 @@ impl Config { #[derive(Debug)] pub enum DialError { /// The peer identity obtained on the connection matches the local peer. - LocalPeerId { - endpoint: ConnectedPoint, - }, + LocalPeerId { endpoint: ConnectedPoint }, /// No addresses have been provided by [`NetworkBehaviour::handle_pending_outbound_connection`] and [`DialOpts`]. NoAddresses, /// The provided [`dial_opts::PeerCondition`] evaluated to false and thus @@ -1553,9 +1551,10 @@ pub enum DialError { obtained: PeerId, endpoint: ConnectedPoint, }, - Denied { - cause: ConnectionDenied, - }, + /// One of the [`NetworkBehaviour`]s rejected the outbound connection + /// via [`NetworkBehaviour::handle_pending_outbound_connection`] or + /// [`NetworkBehaviour::handle_established_outbound_connection`]. + Denied { cause: ConnectionDenied }, /// An error occurred while negotiating the transport protocol(s) on a connection. Transport(Vec<(Multiaddr, TransportError)>), } From d733dfe10dc576ce8e408846103e98241d341df7 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Fri, 2 Aug 2024 16:29:14 +0300 Subject: [PATCH 197/246] fix(websocket-websys): Unsubscribe from websocket events on drop Avoid use-after-free handler invocation from JS side. Fixes #5490 Pull-Request: #5521. --- Cargo.lock | 2 +- Cargo.toml | 2 +- transports/websocket-websys/CHANGELOG.md | 5 +++++ transports/websocket-websys/Cargo.toml | 2 +- transports/websocket-websys/src/lib.rs | 6 ++++++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3fda6b57aa8..b4d877e49d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "libp2p-websocket-websys" -version = "0.3.2" +version = "0.3.3" dependencies = [ "bytes", "futures", diff --git a/Cargo.toml b/Cargo.toml index 55fc43d5b5a..52226f6c6e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,7 +113,7 @@ libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.2.1", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.43.2", path = "transports/websocket" } -libp2p-websocket-websys = { version = "0.3.2", path = "transports/websocket-websys" } +libp2p-websocket-websys = { version = "0.3.3", path = "transports/websocket-websys" } libp2p-webtransport-websys = { version = "0.3.0", path = "transports/webtransport-websys" } libp2p-yamux = { version = "0.45.2", path = "muxers/yamux" } multiaddr = "0.18.1" diff --git a/transports/websocket-websys/CHANGELOG.md b/transports/websocket-websys/CHANGELOG.md index f92b76ebeaa..c16ad6cc406 100644 --- a/transports/websocket-websys/CHANGELOG.md +++ b/transports/websocket-websys/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.3.3 + +- Fix use-after-free handler invocation from JS side. + See [PR 5521](https://github.com/libp2p/rust-libp2p/pull/5521). + ## 0.3.2 - Change close code in drop implementation to `1000` given that in browsers only diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 48bf8d9818a..a2127986ddc 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-websocket-websys" edition = "2021" rust-version = "1.60.0" description = "WebSocket for libp2p under WASM environment" -version = "0.3.2" +version = "0.3.3" authors = ["Vince Vasta "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/websocket-websys/src/lib.rs b/transports/websocket-websys/src/lib.rs index ca56d5727a5..c96d1d6aa3a 100644 --- a/transports/websocket-websys/src/lib.rs +++ b/transports/websocket-websys/src/lib.rs @@ -434,6 +434,12 @@ impl AsyncWrite for Connection { impl Drop for Connection { fn drop(&mut self) { + // Unset event listeners, as otherwise they will be called by JS after the handlers have already been dropped. + self.inner.socket.set_onclose(None); + self.inner.socket.set_onerror(None); + self.inner.socket.set_onopen(None); + self.inner.socket.set_onmessage(None); + // In browsers, userland code is not allowed to use any other status code than 1000: https://websockets.spec.whatwg.org/#dom-websocket-close const REGULAR_CLOSE: u16 = 1000; // See https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1. From 53eb339a01245a8d017ae0f11f88ba9496cfc31b Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 2 Aug 2024 15:01:13 +0100 Subject: [PATCH 198/246] docs: remove myself as a maintainer This reflects the current state of things. Pull-Request: #5514. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 77323a1d659..f43cf044ef3 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,6 @@ Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). (In alphabetical order.) - João Oliveira ([@jxs](https://github.com/jxs)) -- Thomas Eizinger ([@thomaseizinger](https://github.com/thomaseizinger)) ## Notable users From 079b2d6b99262f4f0ca42994571614787a5c98f7 Mon Sep 17 00:00:00 2001 From: Hannes <55623006+umgefahren@users.noreply.github.com> Date: Sat, 3 Aug 2024 16:05:59 +0200 Subject: [PATCH 199/246] refactor(*): Transport redesign Resolves: #4226. Resolves: #3953. Resolves: #3889. Pull-Request: #4568. --- Cargo.lock | 38 +- Cargo.toml | 39 +- core/CHANGELOG.md | 11 + core/Cargo.toml | 2 +- core/src/connection.rs | 13 +- core/src/either.rs | 36 +- core/src/lib.rs | 3 - core/src/transport.rs | 54 +-- core/src/transport/and_then.rs | 35 +- core/src/transport/boxed.rs | 42 +- core/src/transport/choice.rs | 55 +-- core/src/transport/dummy.rs | 13 +- core/src/transport/global_only.rs | 40 +- core/src/transport/map.rs | 27 +- core/src/transport/map_err.rs | 22 +- core/src/transport/memory.rs | 65 ++- core/src/transport/optional.rs | 23 +- core/src/transport/timeout.rs | 21 +- core/src/transport/upgrade.rs | 46 +- core/src/upgrade/ready.rs | 2 +- core/tests/transport_upgrade.rs | 15 +- examples/autonat/Cargo.toml | 2 +- examples/dcutr/src/main.rs | 2 +- examples/stream/Cargo.toml | 2 +- hole-punching-tests/src/main.rs | 2 +- libp2p/CHANGELOG.md | 11 + misc/allow-block-list/src/lib.rs | 2 + misc/connection-limits/src/lib.rs | 4 +- misc/memory-connection-limits/src/lib.rs | 3 +- .../tests/util/mod.rs | 3 +- misc/metrics/src/bandwidth.rs | 21 +- misc/server/src/main.rs | 2 +- muxers/mplex/benches/split_send_size.rs | 13 +- protocols/autonat/CHANGELOG.md | 8 + protocols/autonat/Cargo.toml | 2 +- protocols/autonat/src/behaviour.rs | 13 +- protocols/autonat/src/behaviour/as_server.rs | 1 + protocols/autonat/tests/test_server.rs | 2 + protocols/dcutr/CHANGELOG.md | 4 + protocols/dcutr/Cargo.toml | 2 +- protocols/dcutr/src/behaviour.rs | 3 + protocols/floodsub/CHANGELOG.md | 4 + protocols/floodsub/Cargo.toml | 2 +- protocols/floodsub/src/layer.rs | 2 + protocols/gossipsub/CHANGELOG.md | 4 +- protocols/gossipsub/src/behaviour.rs | 5 +- protocols/gossipsub/src/behaviour/tests.rs | 6 + protocols/identify/CHANGELOG.md | 5 + protocols/identify/src/behaviour.rs | 127 ++++- protocols/identify/tests/smoke.rs | 8 +- protocols/kad/CHANGELOG.md | 1 + protocols/kad/src/behaviour.rs | 4 +- protocols/kad/src/behaviour/test.rs | 3 + protocols/mdns/CHANGELOG.md | 3 + protocols/mdns/Cargo.toml | 2 +- protocols/mdns/src/behaviour.rs | 2 + protocols/mdns/src/behaviour/iface/query.rs | 9 +- protocols/perf/CHANGELOG.md | 2 + protocols/perf/src/client/behaviour.rs | 3 +- protocols/perf/src/server/behaviour.rs | 2 + protocols/ping/CHANGELOG.md | 5 +- protocols/ping/Cargo.toml | 2 +- protocols/ping/src/lib.rs | 2 + protocols/ping/src/protocol.rs | 11 +- protocols/relay/CHANGELOG.md | 4 + protocols/relay/Cargo.toml | 2 +- protocols/relay/src/behaviour.rs | 3 + protocols/relay/src/priv_client.rs | 2 + protocols/relay/src/priv_client/transport.rs | 41 +- protocols/rendezvous/CHANGELOG.md | 4 + protocols/rendezvous/Cargo.toml | 2 +- protocols/rendezvous/src/client.rs | 11 +- protocols/rendezvous/src/server.rs | 11 +- protocols/request-response/CHANGELOG.md | 4 + protocols/request-response/Cargo.toml | 2 +- protocols/request-response/src/lib.rs | 3 +- protocols/stream/CHANGELOG.md | 4 + protocols/stream/Cargo.toml | 2 +- protocols/stream/src/behaviour.rs | 3 +- protocols/upnp/CHANGELOG.md | 4 + protocols/upnp/Cargo.toml | 2 +- protocols/upnp/src/behaviour.rs | 7 +- swarm-derive/src/lib.rs | 4 +- swarm/CHANGELOG.md | 8 + swarm/benches/connection_handler.rs | 1 + swarm/src/behaviour.rs | 6 +- swarm/src/behaviour/either.rs | 4 + swarm/src/behaviour/toggle.rs | 3 + swarm/src/connection.rs | 11 +- swarm/src/connection/pool.rs | 16 +- swarm/src/dial_opts.rs | 79 ++-- swarm/src/dummy.rs | 2 + swarm/src/lib.rs | 76 ++- swarm/src/test.rs | 12 +- {core => swarm}/src/translation.rs | 7 +- swarm/tests/connection_close.rs | 2 + swarm/tests/listener.rs | 7 +- swarm/tests/swarm_derive.rs | 4 +- transports/dns/CHANGELOG.md | 5 + transports/dns/Cargo.toml | 2 +- transports/dns/src/lib.rs | 67 ++- transports/quic/CHANGELOG.md | 5 + transports/quic/Cargo.toml | 2 +- transports/quic/src/transport.rs | 251 +++++----- transports/quic/tests/smoke.rs | 87 ++-- transports/quic/tests/stream_compliance.rs | 14 +- transports/tcp/CHANGELOG.md | 9 + transports/tcp/src/lib.rs | 447 ++++++------------ transports/uds/CHANGELOG.md | 5 + transports/uds/Cargo.toml | 2 +- transports/uds/src/lib.rs | 35 +- transports/webrtc-websys/CHANGELOG.md | 5 + transports/webrtc-websys/Cargo.toml | 2 +- transports/webrtc-websys/src/transport.rs | 22 +- transports/webrtc/CHANGELOG.md | 5 + transports/webrtc/Cargo.toml | 2 +- transports/webrtc/src/tokio/transport.rs | 31 +- transports/webrtc/tests/smoke.rs | 16 +- transports/websocket-websys/CHANGELOG.md | 4 + transports/websocket-websys/Cargo.toml | 2 +- transports/websocket-websys/src/lib.rs | 22 +- transports/websocket/CHANGELOG.md | 4 + transports/websocket/Cargo.toml | 2 +- transports/websocket/src/framed.rs | 38 +- transports/websocket/src/lib.rs | 29 +- transports/webtransport-websys/CHANGELOG.md | 5 + transports/webtransport-websys/Cargo.toml | 2 +- .../webtransport-websys/src/transport.rs | 25 +- wasm-tests/webtransport-tests/src/lib.rs | 51 +- 129 files changed, 1294 insertions(+), 1175 deletions(-) rename {core => swarm}/src/translation.rs (95%) diff --git a/Cargo.lock b/Cargo.lock index b4d877e49d6..cf0cde790c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2659,7 +2659,7 @@ dependencies = [ [[package]] name = "libp2p-autonat" -version = "0.12.1" +version = "0.13.0" dependencies = [ "async-std", "async-trait", @@ -2698,7 +2698,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.41.3" +version = "0.42.0" dependencies = [ "async-std", "either", @@ -2729,7 +2729,7 @@ dependencies = [ [[package]] name = "libp2p-dcutr" -version = "0.11.1" +version = "0.12.0" dependencies = [ "async-std", "asynchronous-codec", @@ -2763,7 +2763,7 @@ dependencies = [ [[package]] name = "libp2p-dns" -version = "0.41.1" +version = "0.42.0" dependencies = [ "async-std", "async-std-resolver", @@ -2781,7 +2781,7 @@ dependencies = [ [[package]] name = "libp2p-floodsub" -version = "0.44.0" +version = "0.45.0" dependencies = [ "asynchronous-codec", "bytes", @@ -2926,7 +2926,7 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.45.2" +version = "0.46.0" dependencies = [ "async-io 2.3.3", "async-std", @@ -3081,7 +3081,7 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.44.2" +version = "0.45.0" dependencies = [ "async-std", "either", @@ -3140,7 +3140,7 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.10.3" +version = "0.11.0" dependencies = [ "async-std", "bytes", @@ -3169,7 +3169,7 @@ dependencies = [ [[package]] name = "libp2p-relay" -version = "0.17.3" +version = "0.18.0" dependencies = [ "asynchronous-codec", "bytes", @@ -3198,7 +3198,7 @@ dependencies = [ [[package]] name = "libp2p-rendezvous" -version = "0.14.1" +version = "0.15.0" dependencies = [ "async-trait", "asynchronous-codec", @@ -3228,7 +3228,7 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.26.4" +version = "0.27.0" dependencies = [ "anyhow", "async-std", @@ -3277,7 +3277,7 @@ dependencies = [ [[package]] name = "libp2p-stream" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" dependencies = [ "futures", "libp2p-core", @@ -3395,7 +3395,7 @@ dependencies = [ [[package]] name = "libp2p-uds" -version = "0.40.0" +version = "0.41.0" dependencies = [ "async-std", "futures", @@ -3407,7 +3407,7 @@ dependencies = [ [[package]] name = "libp2p-upnp" -version = "0.2.2" +version = "0.3.0" dependencies = [ "futures", "futures-timer", @@ -3421,7 +3421,7 @@ dependencies = [ [[package]] name = "libp2p-webrtc" -version = "0.7.1-alpha" +version = "0.8.0-alpha" dependencies = [ "async-trait", "bytes", @@ -3472,7 +3472,7 @@ dependencies = [ [[package]] name = "libp2p-webrtc-websys" -version = "0.3.0-alpha" +version = "0.4.0-alpha" dependencies = [ "bytes", "futures", @@ -3492,7 +3492,7 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.43.2" +version = "0.44.0" dependencies = [ "async-std", "either", @@ -3515,7 +3515,7 @@ dependencies = [ [[package]] name = "libp2p-websocket-websys" -version = "0.3.3" +version = "0.4.0" dependencies = [ "bytes", "futures", @@ -3534,7 +3534,7 @@ dependencies = [ [[package]] name = "libp2p-webtransport-websys" -version = "0.3.0" +version = "0.4.0" dependencies = [ "futures", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 52226f6c6e3..7eb1517d24c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,45 +76,44 @@ futures-bounded = { version = "0.2.4" } futures-rustls = { version = "0.26.0", default-features = false } libp2p = { version = "0.54.0", path = "libp2p" } libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" } -libp2p-autonat = { version = "0.12.1", path = "protocols/autonat" } +libp2p-autonat = { version = "0.13.0", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.3.1", path = "misc/connection-limits" } -libp2p-core = { version = "0.41.3", path = "core" } -libp2p-dcutr = { version = "0.11.1", path = "protocols/dcutr" } -libp2p-dns = { version = "0.41.1", path = "transports/dns" } -libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" } +libp2p-core = { version = "0.42.0", path = "core" } +libp2p-dcutr = { version = "0.12.0", path = "protocols/dcutr" } +libp2p-dns = { version = "0.42.0", path = "transports/dns" } +libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.47.0", path = "protocols/gossipsub" } libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.46.0", path = "protocols/kad" } -libp2p-mdns = { version = "0.45.2", path = "protocols/mdns" } +libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.14.2", path = "misc/metrics" } libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" } -libp2p-muxer-test-harness = { path = "muxers/test-harness" } libp2p-noise = { version = "0.44.0", path = "transports/noise" } libp2p-perf = { version = "0.4.0", path = "protocols/perf" } -libp2p-ping = { version = "0.44.2", path = "protocols/ping" } +libp2p-ping = { version = "0.45.0", path = "protocols/ping" } libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } -libp2p-quic = { version = "0.10.3", path = "transports/quic" } -libp2p-relay = { version = "0.17.3", path = "protocols/relay" } -libp2p-rendezvous = { version = "0.14.1", path = "protocols/rendezvous" } -libp2p-request-response = { version = "0.26.4", path = "protocols/request-response" } +libp2p-quic = { version = "0.11.0", path = "transports/quic" } +libp2p-relay = { version = "0.18.0", path = "protocols/relay" } +libp2p-rendezvous = { version = "0.15.0", path = "protocols/rendezvous" } +libp2p-request-response = { version = "0.27.0", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } -libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" } +libp2p-stream = { version = "0.2.0-alpha", path = "protocols/stream" } libp2p-swarm = { version = "0.45.0", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } libp2p-tls = { version = "0.4.1", path = "transports/tls" } -libp2p-uds = { version = "0.40.0", path = "transports/uds" } -libp2p-upnp = { version = "0.2.2", path = "protocols/upnp" } -libp2p-webrtc = { version = "0.7.1-alpha", path = "transports/webrtc" } +libp2p-uds = { version = "0.41.0", path = "transports/uds" } +libp2p-upnp = { version = "0.3.0", path = "protocols/upnp" } +libp2p-webrtc = { version = "0.8.0-alpha", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.2.1", path = "misc/webrtc-utils" } -libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } -libp2p-websocket = { version = "0.43.2", path = "transports/websocket" } -libp2p-websocket-websys = { version = "0.3.3", path = "transports/websocket-websys" } -libp2p-webtransport-websys = { version = "0.3.0", path = "transports/webtransport-websys" } +libp2p-webrtc-websys = { version = "0.4.0-alpha", path = "transports/webrtc-websys" } +libp2p-websocket = { version = "0.44.0", path = "transports/websocket" } +libp2p-websocket-websys = { version = "0.4.0", path = "transports/websocket-websys" } +libp2p-webtransport-websys = { version = "0.4.0", path = "transports/webtransport-websys" } libp2p-yamux = { version = "0.45.2", path = "muxers/yamux" } multiaddr = "0.18.1" multihash = "0.19.1" diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index b7f3c3c4640..5ed4b4e181d 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -1,3 +1,14 @@ +## 0.42.0 + +- Update `Transport::dial` function signature with a `DialOpts` param and remove `Transport::dial_as_listener`: + - `DialOpts` struct contains `PortUse` and `Endpoint`, + - `PortUse` allows controling port allocation of new connections (defaults to `PortUse::Reuse`) - + - Add `port_use` field to `ConnectedPoint` + - Set `endpoint` field in `DialOpts` to `Endpoint::Listener` to dial as a listener +- Remove `Transport::address_translation` and relocate functionality to `libp2p_swarm` + +See [PR 4568]. + ## 0.41.3 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/core/Cargo.toml b/core/Cargo.toml index 76021c15186..3f9bd540f23 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-core" edition = "2021" rust-version = { workspace = true } description = "Core traits and structs of libp2p" -version = "0.41.3" +version = "0.42.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/core/src/connection.rs b/core/src/connection.rs index ff613c5cce0..bb6639842c9 100644 --- a/core/src/connection.rs +++ b/core/src/connection.rs @@ -18,7 +18,10 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use crate::multiaddr::{Multiaddr, Protocol}; +use crate::{ + multiaddr::{Multiaddr, Protocol}, + transport::PortUse, +}; /// The endpoint roles associated with a peer-to-peer communication channel. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -80,6 +83,13 @@ pub enum ConnectedPoint { /// connection as a dialer and one peer dial the other and upgrade the /// connection _as a listener_ overriding its role. role_override: Endpoint, + /// Whether the port for the outgoing connection was reused from a listener + /// or a new port was allocated. This is useful for address translation. + /// + /// The port use is implemented on a best-effort basis. It is not guaranteed + /// that [`PortUse::Reuse`] actually reused a port. A good example is the case + /// where there is no listener available to reuse a port from. + port_use: PortUse, }, /// We received the node. Listener { @@ -133,6 +143,7 @@ impl ConnectedPoint { ConnectedPoint::Dialer { address, role_override: _, + port_use: _, } => address, ConnectedPoint::Listener { local_addr, .. } => local_addr, } diff --git a/core/src/either.rs b/core/src/either.rs index 3f79b2b37a9..2593174290c 100644 --- a/core/src/either.rs +++ b/core/src/either.rs @@ -19,6 +19,7 @@ // DEALINGS IN THE SOFTWARE. use crate::muxing::StreamMuxerEvent; +use crate::transport::DialOpts; use crate::{ muxing::StreamMuxer, transport::{ListenerId, Transport, TransportError, TransportEvent}, @@ -172,48 +173,23 @@ where } } - fn dial(&mut self, addr: Multiaddr) -> Result> { - use TransportError::*; - match self { - Either::Left(a) => match a.dial(addr) { - Ok(connec) => Ok(EitherFuture::First(connec)), - Err(MultiaddrNotSupported(addr)) => Err(MultiaddrNotSupported(addr)), - Err(Other(err)) => Err(Other(Either::Left(err))), - }, - Either::Right(b) => match b.dial(addr) { - Ok(connec) => Ok(EitherFuture::Second(connec)), - Err(MultiaddrNotSupported(addr)) => Err(MultiaddrNotSupported(addr)), - Err(Other(err)) => Err(Other(Either::Right(err))), - }, - } - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, - ) -> Result> - where - Self: Sized, - { + opts: DialOpts, + ) -> Result> { use TransportError::*; match self { - Either::Left(a) => match a.dial_as_listener(addr) { + Either::Left(a) => match a.dial(addr, opts) { Ok(connec) => Ok(EitherFuture::First(connec)), Err(MultiaddrNotSupported(addr)) => Err(MultiaddrNotSupported(addr)), Err(Other(err)) => Err(Other(Either::Left(err))), }, - Either::Right(b) => match b.dial_as_listener(addr) { + Either::Right(b) => match b.dial(addr, opts) { Ok(connec) => Ok(EitherFuture::Second(connec)), Err(MultiaddrNotSupported(addr)) => Err(MultiaddrNotSupported(addr)), Err(Other(err)) => Err(Other(Either::Right(err))), }, } } - - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - match self { - Either::Left(a) => a.address_translation(server, observed), - Either::Right(b) => b.address_translation(server, observed), - } - } } diff --git a/core/src/lib.rs b/core/src/lib.rs index 3ba153e1927..a42f56773df 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -45,8 +45,6 @@ mod proto { pub use multiaddr; pub type Negotiated = multistream_select::Negotiated; -mod translation; - pub mod connection; pub mod either; pub mod muxing; @@ -62,7 +60,6 @@ pub use multihash; pub use muxing::StreamMuxer; pub use peer_record::PeerRecord; pub use signed_envelope::SignedEnvelope; -pub use translation::address_translation; pub use transport::Transport; pub use upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; diff --git a/core/src/transport.rs b/core/src/transport.rs index 2246f3db747..28ce2dbf650 100644 --- a/core/src/transport.rs +++ b/core/src/transport.rs @@ -48,7 +48,7 @@ pub mod upgrade; mod boxed; mod optional; -use crate::ConnectedPoint; +use crate::{ConnectedPoint, Endpoint}; pub use self::boxed::Boxed; pub use self::choice::OrTransport; @@ -58,6 +58,30 @@ pub use self::upgrade::Upgrade; static NEXT_LISTENER_ID: AtomicUsize = AtomicUsize::new(1); +/// The port use policy for a new connection. +#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, Hash)] +pub enum PortUse { + /// Always allocate a new port for the dial. + New, + /// Best effor reusing of an existing port. + /// + /// If there is no listener present that can be used to dial, a new port is allocated. + #[default] + Reuse, +} + +/// Options to customize the behaviour during dialing. +#[derive(Debug, Copy, Clone)] +pub struct DialOpts { + /// The endpoint establishing a new connection. + /// + /// When attempting a hole-punch, both parties simultaneously "dial" each other but one party has to be the "listener" on the final connection. + /// This option specifies the role of this node in the final connection. + pub role: Endpoint, + /// The port use policy for a new connection. + pub port_use: PortUse, +} + /// A transport provides connection-oriented communication between two peers /// through ordered streams of data (i.e. connections). /// @@ -129,16 +153,10 @@ pub trait Transport { /// /// If [`TransportError::MultiaddrNotSupported`] is returned, it may be desirable to /// try an alternative [`Transport`], if available. - fn dial(&mut self, addr: Multiaddr) -> Result>; - - /// As [`Transport::dial`] but has the local node act as a listener on the outgoing connection. - /// - /// This option is needed for NAT and firewall hole punching. - /// - /// See [`ConnectedPoint::Dialer`] for related option. - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + opts: DialOpts, ) -> Result>; /// Poll for [`TransportEvent`]s. @@ -157,24 +175,6 @@ pub trait Transport { cx: &mut Context<'_>, ) -> Poll>; - /// Performs a transport-specific mapping of an address `observed` by a remote onto a - /// local `listen` address to yield an address for the local node that may be reachable - /// for other peers. - /// - /// This is relevant for transports where Network Address Translation (NAT) can occur - /// so that e.g. the peer is observed at a different IP than the IP of the local - /// listening address. See also [`address_translation`][crate::address_translation]. - /// - /// Within [`libp2p::Swarm`]() this is - /// used when extending the listening addresses of the local peer with external addresses - /// observed by remote peers. - /// On transports where this is not relevant (i.e. no NATs are present) `None` should be - /// returned for the sake of de-duplication. - /// - /// Note: if the listen or observed address is not a valid address of this transport, - /// `None` should be returned as well. - fn address_translation(&self, listen: &Multiaddr, observed: &Multiaddr) -> Option; - /// Boxes the transport, including custom transport errors. fn boxed(self) -> boxed::Boxed where diff --git a/core/src/transport/and_then.rs b/core/src/transport/and_then.rs index 6e0c7e32067..e85703f77fb 100644 --- a/core/src/transport/and_then.rs +++ b/core/src/transport/and_then.rs @@ -19,8 +19,8 @@ // DEALINGS IN THE SOFTWARE. use crate::{ - connection::{ConnectedPoint, Endpoint}, - transport::{ListenerId, Transport, TransportError, TransportEvent}, + connection::ConnectedPoint, + transport::{DialOpts, ListenerId, Transport, TransportError, TransportEvent}, }; use either::Either; use futures::prelude::*; @@ -68,32 +68,14 @@ where self.transport.remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - let dialed_fut = self - .transport - .dial(addr.clone()) - .map_err(|err| err.map(Either::Left))?; - let future = AndThenFuture { - inner: Either::Left(Box::pin(dialed_fut)), - args: Some(( - self.fun.clone(), - ConnectedPoint::Dialer { - address: addr, - role_override: Endpoint::Dialer, - }, - )), - _marker: PhantomPinned, - }; - Ok(future) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + opts: DialOpts, ) -> Result> { let dialed_fut = self .transport - .dial_as_listener(addr.clone()) + .dial(addr.clone(), opts) .map_err(|err| err.map(Either::Left))?; let future = AndThenFuture { inner: Either::Left(Box::pin(dialed_fut)), @@ -101,7 +83,8 @@ where self.fun.clone(), ConnectedPoint::Dialer { address: addr, - role_override: Endpoint::Listener, + role_override: opts.role, + port_use: opts.port_use, }, )), _marker: PhantomPinned, @@ -109,10 +92,6 @@ where Ok(future) } - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.transport.address_translation(server, observed) - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/core/src/transport/boxed.rs b/core/src/transport/boxed.rs index 1cede676c8e..596ab262221 100644 --- a/core/src/transport/boxed.rs +++ b/core/src/transport/boxed.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use crate::transport::{ListenerId, Transport, TransportError, TransportEvent}; +use crate::transport::{DialOpts, ListenerId, Transport, TransportError, TransportEvent}; use futures::{prelude::*, stream::FusedStream}; use multiaddr::Multiaddr; use std::{ @@ -58,9 +58,11 @@ trait Abstract { addr: Multiaddr, ) -> Result<(), TransportError>; fn remove_listener(&mut self, id: ListenerId) -> bool; - fn dial(&mut self, addr: Multiaddr) -> Result, TransportError>; - fn dial_as_listener(&mut self, addr: Multiaddr) -> Result, TransportError>; - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option; + fn dial( + &mut self, + addr: Multiaddr, + opts: DialOpts, + ) -> Result, TransportError>; fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -86,24 +88,17 @@ where Transport::remove_listener(self, id) } - fn dial(&mut self, addr: Multiaddr) -> Result, TransportError> { - let fut = Transport::dial(self, addr) - .map(|r| r.map_err(box_err)) - .map_err(|e| e.map(box_err))?; - Ok(Box::pin(fut) as Dial<_>) - } - - fn dial_as_listener(&mut self, addr: Multiaddr) -> Result, TransportError> { - let fut = Transport::dial_as_listener(self, addr) + fn dial( + &mut self, + addr: Multiaddr, + opts: DialOpts, + ) -> Result, TransportError> { + let fut = Transport::dial(self, addr, opts) .map(|r| r.map_err(box_err)) .map_err(|e| e.map(box_err))?; Ok(Box::pin(fut) as Dial<_>) } - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - Transport::address_translation(self, server, observed) - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -143,19 +138,12 @@ impl Transport for Boxed { self.inner.remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - self.inner.dial(addr) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + opts: DialOpts, ) -> Result> { - self.inner.dial_as_listener(addr) - } - - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.inner.address_translation(server, observed) + self.inner.dial(addr, opts) } fn poll( diff --git a/core/src/transport/choice.rs b/core/src/transport/choice.rs index aa3acfc3231..4339f6bba71 100644 --- a/core/src/transport/choice.rs +++ b/core/src/transport/choice.rs @@ -19,7 +19,7 @@ // DEALINGS IN THE SOFTWARE. use crate::either::EitherFuture; -use crate::transport::{ListenerId, Transport, TransportError, TransportEvent}; +use crate::transport::{DialOpts, ListenerId, Transport, TransportError, TransportEvent}; use either::Either; use futures::future; use multiaddr::Multiaddr; @@ -92,19 +92,23 @@ where self.0.remove_listener(id) || self.1.remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + opts: DialOpts, + ) -> Result> { tracing::trace!( address=%addr, - "Attempting to dial address using {}", + "Attempting to dial using {}", std::any::type_name::() ); - let addr = match self.0.dial(addr) { + let addr = match self.0.dial(addr, opts) { Ok(connec) => return Ok(EitherFuture::First(connec)), Err(TransportError::MultiaddrNotSupported(addr)) => { tracing::debug!( address=%addr, - "Failed to dial address using {}", - std::any::type_name::() + "Failed to dial using {}", + std::any::type_name::(), ); addr } @@ -115,16 +119,16 @@ where tracing::trace!( address=%addr, - "Attempting to dial address using {}", + "Attempting to dial {}", std::any::type_name::() ); - let addr = match self.1.dial(addr) { + let addr = match self.1.dial(addr, opts) { Ok(connec) => return Ok(EitherFuture::Second(connec)), Err(TransportError::MultiaddrNotSupported(addr)) => { tracing::debug!( address=%addr, - "Failed to dial address using {}", - std::any::type_name::() + "Failed to dial using {}", + std::any::type_name::(), ); addr } @@ -136,37 +140,6 @@ where Err(TransportError::MultiaddrNotSupported(addr)) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - let addr = match self.0.dial_as_listener(addr) { - Ok(connec) => return Ok(EitherFuture::First(connec)), - Err(TransportError::MultiaddrNotSupported(addr)) => addr, - Err(TransportError::Other(err)) => { - return Err(TransportError::Other(Either::Left(err))) - } - }; - - let addr = match self.1.dial_as_listener(addr) { - Ok(connec) => return Ok(EitherFuture::Second(connec)), - Err(TransportError::MultiaddrNotSupported(addr)) => addr, - Err(TransportError::Other(err)) => { - return Err(TransportError::Other(Either::Right(err))) - } - }; - - Err(TransportError::MultiaddrNotSupported(addr)) - } - - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - if let Some(addr) = self.0.address_translation(server, observed) { - Some(addr) - } else { - self.1.address_translation(server, observed) - } - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/core/src/transport/dummy.rs b/core/src/transport/dummy.rs index 0aab94b0396..72558d34a79 100644 --- a/core/src/transport/dummy.rs +++ b/core/src/transport/dummy.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use crate::transport::{ListenerId, Transport, TransportError, TransportEvent}; +use crate::transport::{DialOpts, ListenerId, Transport, TransportError, TransportEvent}; use crate::Multiaddr; use futures::{prelude::*, task::Context, task::Poll}; use std::{fmt, io, marker::PhantomData, pin::Pin}; @@ -71,21 +71,14 @@ impl Transport for DummyTransport { false } - fn dial(&mut self, addr: Multiaddr) -> Result> { - Err(TransportError::MultiaddrNotSupported(addr)) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + _opts: DialOpts, ) -> Result> { Err(TransportError::MultiaddrNotSupported(addr)) } - fn address_translation(&self, _server: &Multiaddr, _observed: &Multiaddr) -> Option { - None - } - fn poll( self: Pin<&mut Self>, _: &mut Context<'_>, diff --git a/core/src/transport/global_only.rs b/core/src/transport/global_only.rs index 0671b0e9984..83774f37004 100644 --- a/core/src/transport/global_only.rs +++ b/core/src/transport/global_only.rs @@ -20,7 +20,7 @@ use crate::{ multiaddr::{Multiaddr, Protocol}, - transport::{ListenerId, TransportError, TransportEvent}, + transport::{DialOpts, ListenerId, TransportError, TransportEvent}, }; use std::{ pin::Pin, @@ -287,47 +287,25 @@ impl crate::Transport for Transport { self.inner.remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - match addr.iter().next() { - Some(Protocol::Ip4(a)) => { - if !ipv4_global::is_global(a) { - tracing::debug!(ip=%a, "Not dialing non global IP address"); - return Err(TransportError::MultiaddrNotSupported(addr)); - } - self.inner.dial(addr) - } - Some(Protocol::Ip6(a)) => { - if !ipv6_global::is_global(a) { - tracing::debug!(ip=%a, "Not dialing non global IP address"); - return Err(TransportError::MultiaddrNotSupported(addr)); - } - self.inner.dial(addr) - } - _ => { - tracing::debug!(address=%addr, "Not dialing unsupported Multiaddress"); - Err(TransportError::MultiaddrNotSupported(addr)) - } - } - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + opts: DialOpts, ) -> Result> { match addr.iter().next() { Some(Protocol::Ip4(a)) => { if !ipv4_global::is_global(a) { - tracing::debug!(ip=?a, "Not dialing non global IP address"); + tracing::debug!(ip=%a, "Not dialing non global IP address"); return Err(TransportError::MultiaddrNotSupported(addr)); } - self.inner.dial_as_listener(addr) + self.inner.dial(addr, opts) } Some(Protocol::Ip6(a)) => { if !ipv6_global::is_global(a) { - tracing::debug!(ip=?a, "Not dialing non global IP address"); + tracing::debug!(ip=%a, "Not dialing non global IP address"); return Err(TransportError::MultiaddrNotSupported(addr)); } - self.inner.dial_as_listener(addr) + self.inner.dial(addr, opts) } _ => { tracing::debug!(address=%addr, "Not dialing unsupported Multiaddress"); @@ -336,10 +314,6 @@ impl crate::Transport for Transport { } } - fn address_translation(&self, listen: &Multiaddr, observed: &Multiaddr) -> Option { - self.inner.address_translation(listen, observed) - } - fn poll( mut self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/core/src/transport/map.rs b/core/src/transport/map.rs index 553f3e6338d..9aab84ba8b1 100644 --- a/core/src/transport/map.rs +++ b/core/src/transport/map.rs @@ -18,8 +18,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +use crate::transport::DialOpts; use crate::{ - connection::{ConnectedPoint, Endpoint}, + connection::ConnectedPoint, transport::{Transport, TransportError, TransportEvent}, }; use futures::prelude::*; @@ -73,26 +74,16 @@ where self.transport.remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - let future = self.transport.dial(addr.clone())?; - let p = ConnectedPoint::Dialer { - address: addr, - role_override: Endpoint::Dialer, - }; - Ok(MapFuture { - inner: future, - args: Some((self.fun.clone(), p)), - }) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + opts: DialOpts, ) -> Result> { - let future = self.transport.dial_as_listener(addr.clone())?; + let future = self.transport.dial(addr.clone(), opts)?; let p = ConnectedPoint::Dialer { address: addr, - role_override: Endpoint::Listener, + role_override: opts.role, + port_use: opts.port_use, }; Ok(MapFuture { inner: future, @@ -100,10 +91,6 @@ where }) } - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.transport.address_translation(server, observed) - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/core/src/transport/map_err.rs b/core/src/transport/map_err.rs index 56e1ebf2929..5d44af9af2e 100644 --- a/core/src/transport/map_err.rs +++ b/core/src/transport/map_err.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use crate::transport::{ListenerId, Transport, TransportError, TransportEvent}; +use crate::transport::{DialOpts, ListenerId, Transport, TransportError, TransportEvent}; use futures::prelude::*; use multiaddr::Multiaddr; use std::{error, pin::Pin, task::Context, task::Poll}; @@ -65,23 +65,13 @@ where self.transport.remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - let map = self.map.clone(); - match self.transport.dial(addr) { - Ok(future) => Ok(MapErrDial { - inner: future, - map: Some(map), - }), - Err(err) => Err(err.map(map)), - } - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + opts: DialOpts, ) -> Result> { let map = self.map.clone(); - match self.transport.dial_as_listener(addr) { + match self.transport.dial(addr, opts) { Ok(future) => Ok(MapErrDial { inner: future, map: Some(map), @@ -90,10 +80,6 @@ where } } - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.transport.address_translation(server, observed) - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/core/src/transport/memory.rs b/core/src/transport/memory.rs index 6e4b9322ee5..85680265e8b 100644 --- a/core/src/transport/memory.rs +++ b/core/src/transport/memory.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use crate::transport::{ListenerId, Transport, TransportError, TransportEvent}; +use crate::transport::{DialOpts, ListenerId, Transport, TransportError, TransportEvent}; use fnv::FnvHashMap; use futures::{channel::mpsc, future::Ready, prelude::*, task::Context, task::Poll}; use multiaddr::{Multiaddr, Protocol}; @@ -208,7 +208,11 @@ impl Transport for MemoryTransport { } } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + _opts: DialOpts, + ) -> Result> { let port = if let Ok(port) = parse_memory_addr(&addr) { if let Some(port) = NonZeroU64::new(port) { port @@ -222,17 +226,6 @@ impl Transport for MemoryTransport { DialFuture::new(port).ok_or(TransportError::Other(MemoryTransportError::Unreachable)) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - self.dial(addr) - } - - fn address_translation(&self, _server: &Multiaddr, _observed: &Multiaddr) -> Option { - None - } - fn poll( mut self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -405,6 +398,8 @@ impl Drop for Chan { #[cfg(test)] mod tests { + use crate::{transport::PortUse, Endpoint}; + use super::*; #[test] @@ -489,7 +484,13 @@ mod tests { fn port_not_in_use() { let mut transport = MemoryTransport::default(); assert!(transport - .dial("/memory/810172461024613".parse().unwrap()) + .dial( + "/memory/810172461024613".parse().unwrap(), + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::New + } + ) .is_err()); transport .listen_on( @@ -498,7 +499,13 @@ mod tests { ) .unwrap(); assert!(transport - .dial("/memory/810172461024613".parse().unwrap()) + .dial( + "/memory/810172461024613".parse().unwrap(), + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::New + } + ) .is_ok()); } @@ -565,7 +572,17 @@ mod tests { let mut t2 = MemoryTransport::default(); let dialer = async move { - let mut socket = t2.dial(cloned_t1_addr).unwrap().await.unwrap(); + let mut socket = t2 + .dial( + cloned_t1_addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::New, + }, + ) + .unwrap() + .await + .unwrap(); socket.write_all(&msg).await.unwrap(); }; @@ -601,7 +618,13 @@ mod tests { let dialer = async move { MemoryTransport::default() - .dial(listener_addr_cloned) + .dial( + listener_addr_cloned, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::New, + }, + ) .unwrap() .await .unwrap(); @@ -652,7 +675,13 @@ mod tests { let dialer = async move { let chan = MemoryTransport::default() - .dial(listener_addr_cloned) + .dial( + listener_addr_cloned, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::New, + }, + ) .unwrap() .await .unwrap(); diff --git a/core/src/transport/optional.rs b/core/src/transport/optional.rs index 839f55a4000..f18bfa441b0 100644 --- a/core/src/transport/optional.rs +++ b/core/src/transport/optional.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use crate::transport::{ListenerId, Transport, TransportError, TransportEvent}; +use crate::transport::{DialOpts, ListenerId, Transport, TransportError, TransportEvent}; use multiaddr::Multiaddr; use std::{pin::Pin, task::Context, task::Poll}; @@ -80,33 +80,18 @@ where } } - fn dial(&mut self, addr: Multiaddr) -> Result> { - if let Some(inner) = self.0.as_mut() { - inner.dial(addr) - } else { - Err(TransportError::MultiaddrNotSupported(addr)) - } - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + opts: DialOpts, ) -> Result> { if let Some(inner) = self.0.as_mut() { - inner.dial_as_listener(addr) + inner.dial(addr, opts) } else { Err(TransportError::MultiaddrNotSupported(addr)) } } - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - if let Some(inner) = &self.0 { - inner.address_translation(server, observed) - } else { - None - } - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/core/src/transport/timeout.rs b/core/src/transport/timeout.rs index 0e8ab3f5201..830ed099629 100644 --- a/core/src/transport/timeout.rs +++ b/core/src/transport/timeout.rs @@ -24,6 +24,7 @@ //! underlying `Transport`. // TODO: add example +use crate::transport::DialOpts; use crate::{ transport::{ListenerId, TransportError, TransportEvent}, Multiaddr, Transport, @@ -99,24 +100,14 @@ where self.inner.remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - let dial = self - .inner - .dial(addr) - .map_err(|err| err.map(TransportTimeoutError::Other))?; - Ok(Timeout { - inner: dial, - timer: Delay::new(self.outgoing_timeout), - }) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + opts: DialOpts, ) -> Result> { let dial = self .inner - .dial_as_listener(addr) + .dial(addr, opts) .map_err(|err| err.map(TransportTimeoutError::Other))?; Ok(Timeout { inner: dial, @@ -124,10 +115,6 @@ where }) } - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.inner.address_translation(server, observed) - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/core/src/transport/upgrade.rs b/core/src/transport/upgrade.rs index 9626312b5fb..66b9e7509af 100644 --- a/core/src/transport/upgrade.rs +++ b/core/src/transport/upgrade.rs @@ -22,6 +22,7 @@ pub use crate::upgrade::Version; +use crate::transport::DialOpts; use crate::{ connection::ConnectedPoint, muxing::{StreamMuxer, StreamMuxerBox}, @@ -335,21 +336,18 @@ where type ListenerUpgrade = T::ListenerUpgrade; type Dial = T::Dial; - fn dial(&mut self, addr: Multiaddr) -> Result> { - self.0.dial(addr) + fn dial( + &mut self, + addr: Multiaddr, + opts: DialOpts, + ) -> Result> { + self.0.dial(addr, opts) } fn remove_listener(&mut self, id: ListenerId) -> bool { self.0.remove_listener(id) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - self.0.dial_as_listener(addr) - } - fn listen_on( &mut self, id: ListenerId, @@ -358,10 +356,6 @@ where self.0.listen_on(id, addr) } - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.0.address_translation(server, observed) - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -404,10 +398,14 @@ where type ListenerUpgrade = ListenerUpgradeFuture; type Dial = DialUpgradeFuture; - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + opts: DialOpts, + ) -> Result> { let future = self .inner - .dial(addr) + .dial(addr, opts) .map_err(|err| err.map(TransportUpgradeError::Transport))?; Ok(DialUpgradeFuture { future: Box::pin(future), @@ -419,20 +417,6 @@ where self.inner.remove_listener(id) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - let future = self - .inner - .dial_as_listener(addr) - .map_err(|err| err.map(TransportUpgradeError::Transport))?; - Ok(DialUpgradeFuture { - future: Box::pin(future), - upgrade: future::Either::Left(Some(self.upgrade.clone())), - }) - } - fn listen_on( &mut self, id: ListenerId, @@ -443,10 +427,6 @@ where .map_err(|err| err.map(TransportUpgradeError::Transport)) } - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.inner.address_translation(server, observed) - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/core/src/upgrade/ready.rs b/core/src/upgrade/ready.rs index 323f1f73f32..7e235902651 100644 --- a/core/src/upgrade/ready.rs +++ b/core/src/upgrade/ready.rs @@ -31,7 +31,7 @@ pub struct ReadyUpgrade

{ } impl

ReadyUpgrade

{ - pub fn new(protocol_name: P) -> Self { + pub const fn new(protocol_name: P) -> Self { Self { protocol_name } } } diff --git a/core/tests/transport_upgrade.rs b/core/tests/transport_upgrade.rs index a8872051618..d8bec6f2b59 100644 --- a/core/tests/transport_upgrade.rs +++ b/core/tests/transport_upgrade.rs @@ -19,10 +19,11 @@ // DEALINGS IN THE SOFTWARE. use futures::prelude::*; -use libp2p_core::transport::{ListenerId, MemoryTransport, Transport}; +use libp2p_core::transport::{DialOpts, ListenerId, MemoryTransport, PortUse, Transport}; use libp2p_core::upgrade::{ self, InboundConnectionUpgrade, OutboundConnectionUpgrade, UpgradeInfo, }; +use libp2p_core::Endpoint; use libp2p_identity as identity; use libp2p_mplex::MplexConfig; use libp2p_noise as noise; @@ -121,7 +122,17 @@ fn upgrade_pipeline() { }; let client = async move { - let (peer, _mplex) = dialer_transport.dial(listen_addr2).unwrap().await.unwrap(); + let (peer, _mplex) = dialer_transport + .dial( + listen_addr2, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::New, + }, + ) + .unwrap() + .await + .unwrap(); assert_eq!(peer, listener_id); }; diff --git a/examples/autonat/Cargo.toml b/examples/autonat/Cargo.toml index 9bdf0be393d..010b76623e0 100644 --- a/examples/autonat/Cargo.toml +++ b/examples/autonat/Cargo.toml @@ -3,7 +3,7 @@ name = "autonat-example" version = "0.1.0" edition = "2021" publish = false -license = "MIT" +license = "MIT or Apache-2.0" [package.metadata.release] release = false diff --git a/examples/dcutr/src/main.rs b/examples/dcutr/src/main.rs index 51df670f8a7..630d4b2b1f3 100644 --- a/examples/dcutr/src/main.rs +++ b/examples/dcutr/src/main.rs @@ -89,7 +89,7 @@ async fn main() -> Result<(), Box> { libp2p::SwarmBuilder::with_existing_identity(generate_ed25519(opts.secret_key_seed)) .with_tokio() .with_tcp( - tcp::Config::default().port_reuse(true).nodelay(true), + tcp::Config::default().nodelay(true), noise::Config::new, yamux::Config::default, )? diff --git a/examples/stream/Cargo.toml b/examples/stream/Cargo.toml index de46d204c77..ba31d4d9e13 100644 --- a/examples/stream/Cargo.toml +++ b/examples/stream/Cargo.toml @@ -12,7 +12,7 @@ release = false anyhow = "1" futures = { workspace = true } libp2p = { path = "../../libp2p", features = [ "tokio", "quic"] } -libp2p-stream = { path = "../../protocols/stream", version = "0.1.0-alpha" } +libp2p-stream = { path = "../../protocols/stream", version = "0.2.0-alpha" } rand = "0.8" tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } diff --git a/hole-punching-tests/src/main.rs b/hole-punching-tests/src/main.rs index bbecc948e08..02229e16262 100644 --- a/hole-punching-tests/src/main.rs +++ b/hole-punching-tests/src/main.rs @@ -64,7 +64,7 @@ async fn main() -> Result<()> { let mut swarm = libp2p::SwarmBuilder::with_new_identity() .with_tokio() .with_tcp( - tcp::Config::new().port_reuse(true).nodelay(true), + tcp::Config::new().nodelay(true), noise::Config::new, yamux::Config::default, )? diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index 977d9f91924..7e1b95c6e75 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -7,12 +7,23 @@ - Raise MSRV to 1.73. See [PR 5266](https://github.com/libp2p/rust-libp2p/pull/5266). +- Implement refactored `Transport`. + See [PR 4568]. + +- Move `address_translation` from `libp2p-core` to `libp2p-swarm` and `libp2p-identify`. To now get + address translation behaviour, i.e. discovery of extern address (candidates) based on connecting + to other peers, one needs to use `libp2p-identify` now. This pertains to you if your nodes can be + behind NATs and they aren't aware of their true external address. + See [PR 4568]. + - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). - Remove redundant async signature from builder methods. See [PR 5468](https://github.com/libp2p/rust-libp2p/pull/5468). +[PR 4568]: https://github.com/libp2p/rust-libp2p/pull/4568 + ## 0.53.2 - Allow `SwarmBuilder::with_bandwidth_metrics` after `SwarmBuilder::with_websocket`. diff --git a/misc/allow-block-list/src/lib.rs b/misc/allow-block-list/src/lib.rs index c1d31433db1..c877ab09c9b 100644 --- a/misc/allow-block-list/src/lib.rs +++ b/misc/allow-block-list/src/lib.rs @@ -61,6 +61,7 @@ //! # } //! ``` +use libp2p_core::transport::PortUse; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ @@ -225,6 +226,7 @@ where peer: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { self.state.enforce(&peer)?; diff --git a/misc/connection-limits/src/lib.rs b/misc/connection-limits/src/lib.rs index dbe68a8ad11..b02e52f25a1 100644 --- a/misc/connection-limits/src/lib.rs +++ b/misc/connection-limits/src/lib.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; +use libp2p_core::{transport::PortUse, ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ behaviour::{ConnectionEstablished, DialFailure, ListenFailure}, @@ -278,6 +278,7 @@ impl NetworkBehaviour for Behaviour { peer: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { self.pending_outbound_connections.remove(&connection_id); @@ -569,6 +570,7 @@ mod tests { _peer: PeerId, _addr: &Multiaddr, _role_override: Endpoint, + _port_use: PortUse, ) -> Result, ConnectionDenied> { Err(ConnectionDenied::new(std::io::Error::new( std::io::ErrorKind::Other, diff --git a/misc/memory-connection-limits/src/lib.rs b/misc/memory-connection-limits/src/lib.rs index 08c45154221..7b5803a61aa 100644 --- a/misc/memory-connection-limits/src/lib.rs +++ b/misc/memory-connection-limits/src/lib.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use libp2p_core::{Endpoint, Multiaddr}; +use libp2p_core::{transport::PortUse, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ dummy, ConnectionDenied, ConnectionId, FromSwarm, NetworkBehaviour, THandler, THandlerInEvent, @@ -177,6 +177,7 @@ impl NetworkBehaviour for Behaviour { _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(dummy::ConnectionHandler) } diff --git a/misc/memory-connection-limits/tests/util/mod.rs b/misc/memory-connection-limits/tests/util/mod.rs index f40ce319929..d18aa78fd22 100644 --- a/misc/memory-connection-limits/tests/util/mod.rs +++ b/misc/memory-connection-limits/tests/util/mod.rs @@ -20,7 +20,7 @@ use std::task::{Context, Poll}; -use libp2p_core::{Endpoint, Multiaddr}; +use libp2p_core::{transport::PortUse, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ dummy, ConnectionDenied, ConnectionId, FromSwarm, NetworkBehaviour, THandler, THandlerInEvent, @@ -102,6 +102,7 @@ impl NetworkBehaviour _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { self.handle_established(); Ok(dummy::ConnectionHandler) diff --git a/misc/metrics/src/bandwidth.rs b/misc/metrics/src/bandwidth.rs index ac6a4178ce9..8a0f54e5b65 100644 --- a/misc/metrics/src/bandwidth.rs +++ b/misc/metrics/src/bandwidth.rs @@ -7,7 +7,7 @@ use futures::{ }; use libp2p_core::{ muxing::{StreamMuxer, StreamMuxerEvent}, - transport::{ListenerId, TransportError, TransportEvent}, + transport::{DialOpts, ListenerId, TransportError, TransportEvent}, Multiaddr, }; use libp2p_identity::PeerId; @@ -84,33 +84,20 @@ where self.transport.remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - let metrics = ConnectionMetrics::from_family_and_addr(&self.metrics, &addr); - Ok(self - .transport - .dial(addr.clone())? - .map_ok(Box::new(|(peer_id, stream_muxer)| { - (peer_id, Muxer::new(stream_muxer, metrics)) - }))) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + dial_opts: DialOpts, ) -> Result> { let metrics = ConnectionMetrics::from_family_and_addr(&self.metrics, &addr); Ok(self .transport - .dial_as_listener(addr.clone())? + .dial(addr.clone(), dial_opts)? .map_ok(Box::new(|(peer_id, stream_muxer)| { (peer_id, Muxer::new(stream_muxer, metrics)) }))) } - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.transport.address_translation(server, observed) - } - fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/misc/server/src/main.rs b/misc/server/src/main.rs index eb28b9ad5c2..820921beaed 100644 --- a/misc/server/src/main.rs +++ b/misc/server/src/main.rs @@ -71,7 +71,7 @@ async fn main() -> Result<(), Box> { let mut swarm = libp2p::SwarmBuilder::with_existing_identity(local_keypair) .with_tokio() .with_tcp( - tcp::Config::default().port_reuse(true).nodelay(true), + tcp::Config::default().nodelay(true), noise::Config::new, yamux::Config::default, )? diff --git a/muxers/mplex/benches/split_send_size.rs b/muxers/mplex/benches/split_send_size.rs index 0125d49dcef..44eafa884ac 100644 --- a/muxers/mplex/benches/split_send_size.rs +++ b/muxers/mplex/benches/split_send_size.rs @@ -28,6 +28,7 @@ use futures::prelude::*; use futures::{channel::oneshot, future::join}; use libp2p_core::muxing::StreamMuxerExt; use libp2p_core::transport::ListenerId; +use libp2p_core::Endpoint; use libp2p_core::{multiaddr::multiaddr, muxing, transport, upgrade, Multiaddr, Transport}; use libp2p_identity as identity; use libp2p_identity::PeerId; @@ -146,7 +147,17 @@ fn run( // Spawn and block on the sender, i.e. until all data is sent. let sender = async move { let addr = addr_receiver.await.unwrap(); - let (_peer, mut conn) = sender_trans.dial(addr).unwrap().await.unwrap(); + let (_peer, mut conn) = sender_trans + .dial( + addr, + transport::DialOpts { + role: Endpoint::Dialer, + port_use: transport::PortUse::Reuse, + }, + ) + .unwrap() + .await + .unwrap(); // Just calling `poll_outbound` without `poll` is fine here because mplex makes progress through all `poll_` functions. It is hacky though. let mut stream = poll_fn(|cx| conn.poll_outbound_unpin(cx)).await.unwrap(); let mut off = 0; diff --git a/protocols/autonat/CHANGELOG.md b/protocols/autonat/CHANGELOG.md index 6a25dc173dd..2a799221f7c 100644 --- a/protocols/autonat/CHANGELOG.md +++ b/protocols/autonat/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.13.0 + +- Due to the refactor of `Transport` it's no longer required to create a seperate transport for +AutoNAT where port reuse is disabled. This information is now passed by the behaviour. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568). + + + ## 0.12.1 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index 970dd27bc53..f047cb7d5ba 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -4,7 +4,7 @@ edition = "2021" rust-version = { workspace = true } description = "NAT and firewall detection for libp2p" authors = ["David Craven ", "Elena Frank "] -version = "0.12.1" +version = "0.13.0" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] diff --git a/protocols/autonat/src/behaviour.rs b/protocols/autonat/src/behaviour.rs index a47852e5206..64bebfb6233 100644 --- a/protocols/autonat/src/behaviour.rs +++ b/protocols/autonat/src/behaviour.rs @@ -28,6 +28,7 @@ pub use as_client::{OutboundProbeError, OutboundProbeEvent}; use as_server::AsServer; pub use as_server::{InboundProbeError, InboundProbeEvent}; use futures_timer::Delay; +use libp2p_core::transport::PortUse; use libp2p_core::{multiaddr::Protocol, ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_request_response::{ @@ -338,6 +339,7 @@ impl Behaviour { ConnectedPoint::Dialer { address, role_override: Endpoint::Dialer, + .. } => { if let Some(event) = self.as_server().on_outbound_connection(&peer, address) { self.pending_actions @@ -347,6 +349,7 @@ impl Behaviour { ConnectedPoint::Dialer { address: _, role_override: Endpoint::Listener, + .. } => { // Outgoing connection was dialed as a listener. In other words outgoing connection // was dialed as part of a hole punch. `libp2p-autonat` never attempts to hole @@ -512,9 +515,15 @@ impl NetworkBehaviour for Behaviour { peer: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { - self.inner - .handle_established_outbound_connection(connection_id, peer, addr, role_override) + self.inner.handle_established_outbound_connection( + connection_id, + peer, + addr, + role_override, + port_use, + ) } fn on_swarm_event(&mut self, event: FromSwarm) { diff --git a/protocols/autonat/src/behaviour/as_server.rs b/protocols/autonat/src/behaviour/as_server.rs index af6be799e21..8f1d6642de5 100644 --- a/protocols/autonat/src/behaviour/as_server.rs +++ b/protocols/autonat/src/behaviour/as_server.rs @@ -135,6 +135,7 @@ impl<'a> HandleInnerEvent for AsServer<'a> { NonZeroU8::new(1).expect("1 > 0"), ) .addresses(addrs) + .allocate_new_port() .build(), }, ]) diff --git a/protocols/autonat/tests/test_server.rs b/protocols/autonat/tests/test_server.rs index b0610ef59a4..fd97b1a9132 100644 --- a/protocols/autonat/tests/test_server.rs +++ b/protocols/autonat/tests/test_server.rs @@ -92,6 +92,7 @@ async fn test_dial_back() { ConnectedPoint::Dialer { address, role_override: Endpoint::Dialer, + .. }, num_established, concurrent_dial_errors, @@ -300,6 +301,7 @@ async fn test_dial_multiple_addr() { ConnectedPoint::Dialer { address, role_override: Endpoint::Dialer, + .. }, concurrent_dial_errors, .. diff --git a/protocols/dcutr/CHANGELOG.md b/protocols/dcutr/CHANGELOG.md index 4865a0540bb..0ddc4aa1148 100644 --- a/protocols/dcutr/CHANGELOG.md +++ b/protocols/dcutr/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.12.0 + + + ## 0.11.1 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index 24a5560f5b5..cd46840caf3 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-dcutr" edition = "2021" rust-version = { workspace = true } description = "Direct connection upgrade through relay" -version = "0.11.1" +version = "0.12.0" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/dcutr/src/behaviour.rs b/protocols/dcutr/src/behaviour.rs index 4409b5f6a64..574c96205fa 100644 --- a/protocols/dcutr/src/behaviour.rs +++ b/protocols/dcutr/src/behaviour.rs @@ -24,6 +24,7 @@ use crate::{handler, protocol}; use either::Either; use libp2p_core::connection::ConnectedPoint; use libp2p_core::multiaddr::Protocol; +use libp2p_core::transport::PortUse; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::{ConnectionClosed, DialFailure, FromSwarm}; @@ -206,12 +207,14 @@ impl NetworkBehaviour for Behaviour { peer: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { if is_relayed(addr) { return Ok(Either::Left(handler::relayed::Handler::new( ConnectedPoint::Dialer { address: addr.clone(), role_override, + port_use, }, self.observed_addresses(), ))); // TODO: We could make two `handler::relayed::Handler` here, one inbound one outbound. diff --git a/protocols/floodsub/CHANGELOG.md b/protocols/floodsub/CHANGELOG.md index 8e3cb70ddf1..4192e0ea58d 100644 --- a/protocols/floodsub/CHANGELOG.md +++ b/protocols/floodsub/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.45.0 + + + ## 0.44.0 - Change publish to require `data: impl Into` to internally avoid any costly cloning / allocation. diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 8bcbc4a3557..9f0557c6d01 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-floodsub" edition = "2021" rust-version = { workspace = true } description = "Floodsub protocol for libp2p" -version = "0.44.0" +version = "0.45.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/floodsub/src/layer.rs b/protocols/floodsub/src/layer.rs index 35711408a8d..1a70d2213b2 100644 --- a/protocols/floodsub/src/layer.rs +++ b/protocols/floodsub/src/layer.rs @@ -27,6 +27,7 @@ use crate::FloodsubConfig; use bytes::Bytes; use cuckoofilter::{CuckooError, CuckooFilter}; use fnv::FnvHashSet; +use libp2p_core::transport::PortUse; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::{ConnectionClosed, ConnectionEstablished, FromSwarm}; @@ -346,6 +347,7 @@ impl NetworkBehaviour for Floodsub { _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(Default::default()) } diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index 7c43b98f0a7..8e115052d31 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -1,4 +1,6 @@ ## 0.47.0 + + - Add ConnectionError to FromSwarm::ConnectionClosed. See [PR 5485](https://github.com/libp2p/rust-libp2p/pull/5485). @@ -9,7 +11,7 @@ ## 0.46.1 - Deprecate `Rpc` in preparation for removing it from the public API because it is an internal type. - See [PR 4833](https://github.com/libp2p/rust-libp2p/pull/4833). + See [PR 4833](https://github.com/libp2p/rust-libp2p/pull/4833). ## 0.46.0 diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index 7980f362acf..0d1af1ada0c 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -34,7 +34,9 @@ use futures_ticker::Ticker; use prometheus_client::registry::Registry; use rand::{seq::SliceRandom, thread_rng}; -use libp2p_core::{multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, Endpoint, Multiaddr}; +use libp2p_core::{ + multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, transport::PortUse, Endpoint, Multiaddr, +}; use libp2p_identity::Keypair; use libp2p_identity::PeerId; use libp2p_swarm::{ @@ -3012,6 +3014,7 @@ where _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(Handler::new(self.config.protocol_config())) } diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index fe861a674dd..c44152ed2f9 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -206,6 +206,7 @@ where ConnectedPoint::Dialer { address, role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, } } else { ConnectedPoint::Listener { @@ -256,6 +257,7 @@ where let fake_endpoint = ConnectedPoint::Dialer { address: Multiaddr::empty(), role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }; // this is not relevant // peer_connections.connections should never be empty. @@ -562,6 +564,7 @@ fn test_join() { endpoint: &ConnectedPoint::Dialer { address: "/ip4/127.0.0.1".parse::().unwrap(), role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, failed_addresses: &[], other_established: 0, @@ -4052,6 +4055,7 @@ fn test_scoring_p6() { endpoint: &ConnectedPoint::Dialer { address: addr.clone(), role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, failed_addresses: &[], other_established: 0, @@ -4073,6 +4077,7 @@ fn test_scoring_p6() { endpoint: &ConnectedPoint::Dialer { address: addr2.clone(), role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, failed_addresses: &[], other_established: 1, @@ -4103,6 +4108,7 @@ fn test_scoring_p6() { endpoint: &ConnectedPoint::Dialer { address: addr, role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, failed_addresses: &[], other_established: 2, diff --git a/protocols/identify/CHANGELOG.md b/protocols/identify/CHANGELOG.md index b8ab3f8df50..275f7114b28 100644 --- a/protocols/identify/CHANGELOG.md +++ b/protocols/identify/CHANGELOG.md @@ -1,5 +1,10 @@ ## 0.45.0 +- Address translation is moved here from `libp2p-core`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) + + + - Add `ConnectionId` in `Event`. See [PR 4981](https://github.com/libp2p/rust-libp2p/pull/4981). diff --git a/protocols/identify/src/behaviour.rs b/protocols/identify/src/behaviour.rs index 92a0dc46103..6590ccd6588 100644 --- a/protocols/identify/src/behaviour.rs +++ b/protocols/identify/src/behaviour.rs @@ -20,6 +20,8 @@ use crate::handler::{self, Handler, InEvent}; use crate::protocol::{Info, UpgradeError}; +use libp2p_core::multiaddr::Protocol; +use libp2p_core::transport::PortUse; use libp2p_core::{multiaddr, ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_identity::PublicKey; @@ -27,6 +29,7 @@ use libp2p_swarm::behaviour::{ConnectionClosed, ConnectionEstablished, DialFailu use libp2p_swarm::{ ConnectionDenied, DialError, ExternalAddresses, ListenAddresses, NetworkBehaviour, NotifyHandler, PeerAddresses, StreamUpgradeError, THandlerInEvent, ToSwarm, + _address_translation, }; use libp2p_swarm::{ConnectionId, THandler, THandlerOutEvent}; @@ -39,6 +42,50 @@ use std::{ time::Duration, }; +/// Whether an [`Multiaddr`] is a valid for the QUIC transport. +fn is_quic_addr(addr: &Multiaddr, v1: bool) -> bool { + use Protocol::*; + let mut iter = addr.iter(); + let Some(first) = iter.next() else { + return false; + }; + let Some(second) = iter.next() else { + return false; + }; + let Some(third) = iter.next() else { + return false; + }; + let fourth = iter.next(); + let fifth = iter.next(); + + matches!(first, Ip4(_) | Ip6(_) | Dns(_) | Dns4(_) | Dns6(_)) + && matches!(second, Udp(_)) + && if v1 { + matches!(third, QuicV1) + } else { + matches!(third, Quic) + } + && matches!(fourth, Some(P2p(_)) | None) + && fifth.is_none() +} + +fn is_tcp_addr(addr: &Multiaddr) -> bool { + use Protocol::*; + + let mut iter = addr.iter(); + + let first = match iter.next() { + None => return false, + Some(p) => p, + }; + let second = match iter.next() { + None => return false, + Some(p) => p, + }; + + matches!(first, Ip4(_) | Ip6(_) | Dns(_) | Dns4(_) | Dns6(_)) && matches!(second, Tcp(_)) +} + /// Network behaviour that automatically identifies nodes periodically, returns information /// about them, and answers identify queries from other nodes. /// @@ -52,6 +99,9 @@ pub struct Behaviour { /// The address a remote observed for us. our_observed_addresses: HashMap, + /// The outbound connections established without port reuse (require translation) + outbound_connections_with_ephemeral_port: HashSet, + /// Pending events to be emitted when polled. events: VecDeque>, /// The addresses of all peers that we have discovered. @@ -153,6 +203,7 @@ impl Behaviour { config, connected: HashMap::new(), our_observed_addresses: Default::default(), + outbound_connections_with_ephemeral_port: Default::default(), events: VecDeque::new(), discovered_peers, listen_addresses: Default::default(), @@ -213,6 +264,58 @@ impl Behaviour { .cloned() .collect() } + + fn emit_new_external_addr_candidate_event( + &mut self, + connection_id: ConnectionId, + observed: &Multiaddr, + ) { + if self + .outbound_connections_with_ephemeral_port + .contains(&connection_id) + { + // Apply address translation to the candidate address. + // For TCP without port-reuse, the observed address contains an ephemeral port which needs to be replaced by the port of a listen address. + let translated_addresses = { + let mut addrs: Vec<_> = self + .listen_addresses + .iter() + .filter_map(|server| { + if (is_tcp_addr(server) && is_tcp_addr(observed)) + || (is_quic_addr(server, true) && is_quic_addr(observed, true)) + || (is_quic_addr(server, false) && is_quic_addr(observed, false)) + { + _address_translation(server, observed) + } else { + None + } + }) + .collect(); + + // remove duplicates + addrs.sort_unstable(); + addrs.dedup(); + addrs + }; + + // If address translation yielded nothing, broadcast the original candidate address. + if translated_addresses.is_empty() { + self.events + .push_back(ToSwarm::NewExternalAddrCandidate(observed.clone())); + } else { + for addr in translated_addresses { + self.events + .push_back(ToSwarm::NewExternalAddrCandidate(addr)); + } + } + return; + } + + // outgoing connection dialed with port reuse + // incomming connection + self.events + .push_back(ToSwarm::NewExternalAddrCandidate(observed.clone())); + } } impl NetworkBehaviour for Behaviour { @@ -239,11 +342,25 @@ impl NetworkBehaviour for Behaviour { fn handle_established_outbound_connection( &mut self, - _: ConnectionId, + connection_id: ConnectionId, peer: PeerId, addr: &Multiaddr, _: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { + // Contrary to inbound events, outbound events are full-p2p qualified + // so we remove /p2p/ in order to be homogeneous + // this will avoid Autonatv2 to probe twice the same address (fully-p2p-qualified + not fully-p2p-qualified) + let mut addr = addr.clone(); + if matches!(addr.iter().last(), Some(multiaddr::Protocol::P2p(_))) { + addr.pop(); + } + + if port_use == PortUse::New { + self.outbound_connections_with_ephemeral_port + .insert(connection_id); + } + Ok(Handler::new( self.config.interval, peer, @@ -289,8 +406,7 @@ impl NetworkBehaviour for Behaviour { match self.our_observed_addresses.entry(connection_id) { Entry::Vacant(not_yet_observed) => { not_yet_observed.insert(observed.clone()); - self.events - .push_back(ToSwarm::NewExternalAddrCandidate(observed)); + self.emit_new_external_addr_candidate_event(connection_id, &observed); } Entry::Occupied(already_observed) if already_observed.get() == &observed => { // No-op, we already observed this address. @@ -303,8 +419,7 @@ impl NetworkBehaviour for Behaviour { ); *already_observed.get_mut() = observed.clone(); - self.events - .push_back(ToSwarm::NewExternalAddrCandidate(observed)); + self.emit_new_external_addr_candidate_event(connection_id, &observed); } } } @@ -403,6 +518,8 @@ impl NetworkBehaviour for Behaviour { } self.our_observed_addresses.remove(&connection_id); + self.outbound_connections_with_ephemeral_port + .remove(&connection_id); } FromSwarm::DialFailure(DialFailure { peer_id, error, .. }) => { if let (Some(peer_id), Some(cache), DialError::Transport(errors)) = diff --git a/protocols/identify/tests/smoke.rs b/protocols/identify/tests/smoke.rs index dd92d10979a..49ae9f0726f 100644 --- a/protocols/identify/tests/smoke.rs +++ b/protocols/identify/tests/smoke.rs @@ -1,5 +1,4 @@ use futures::StreamExt; -use libp2p_core::multiaddr::Protocol; use libp2p_identify as identify; use libp2p_swarm::{Swarm, SwarmEvent}; use libp2p_swarm_test::SwarmExt; @@ -59,12 +58,7 @@ async fn periodic_identify() { assert_eq!(s1_info.protocol_version, "c"); assert_eq!(s1_info.agent_version, "d"); assert!(!s1_info.protocols.is_empty()); - assert_eq!( - s1_info.observed_addr, - swarm1_memory_listen - .clone() - .with(Protocol::P2p(swarm1_peer_id)) - ); + assert_eq!(s1_info.observed_addr, swarm1_memory_listen); assert!(s1_info.listen_addrs.contains(&swarm2_tcp_listen_addr)); assert!(s1_info.listen_addrs.contains(&swarm2_memory_listen)); diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index f88484bafa1..a5b404ae6bd 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -21,6 +21,7 @@ See [PR 5317](https://github.com/libp2p/rust-libp2p/pull/5317). - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). + - Correctly handle the `NoKnownPeers` error on automatic bootstrap. See [PR 5349](https://github.com/libp2p/rust-libp2p/pull/5349). - Improve automatic bootstrap triggering conditions: diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 069eec1a5b4..8d6f86d7e0f 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -35,7 +35,7 @@ use crate::record::{ use crate::{bootstrap, K_VALUE}; use crate::{jobs::*, protocol}; use fnv::FnvHashSet; -use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; +use libp2p_core::{transport::PortUse, ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::{ AddressChange, ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm, @@ -2168,10 +2168,12 @@ where peer: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { let connected_point = ConnectedPoint::Dialer { address: addr.clone(), role_override, + port_use, }; let mut handler = Handler::new( diff --git a/protocols/kad/src/behaviour/test.rs b/protocols/kad/src/behaviour/test.rs index b82ec966f89..c4859f2f138 100644 --- a/protocols/kad/src/behaviour/test.rs +++ b/protocols/kad/src/behaviour/test.rs @@ -1310,6 +1310,7 @@ fn network_behaviour_on_address_change() { let endpoint = ConnectedPoint::Dialer { address: old_address.clone(), role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }; // Mimick a connection being established. @@ -1360,10 +1361,12 @@ fn network_behaviour_on_address_change() { old: &ConnectedPoint::Dialer { address: old_address, role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, new: &ConnectedPoint::Dialer { address: new_address.clone(), role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, }, })); diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index 18fe0e76e6f..67b1d669f60 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.46.0 + + ## 0.45.2 - Add `#[track_caller]` on all `spawn` wrappers. diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 724c8818621..0c8229465d6 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-mdns" edition = "2021" rust-version = { workspace = true } -version = "0.45.2" +version = "0.46.0" description = "Implementation of the libp2p mDNS discovery method" authors = ["Parity Technologies "] license = "MIT" diff --git a/protocols/mdns/src/behaviour.rs b/protocols/mdns/src/behaviour.rs index d4a0a707a01..6355fbf4943 100644 --- a/protocols/mdns/src/behaviour.rs +++ b/protocols/mdns/src/behaviour.rs @@ -28,6 +28,7 @@ use crate::Config; use futures::channel::mpsc; use futures::{Stream, StreamExt}; use if_watch::IfEvent; +use libp2p_core::transport::PortUse; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::FromSwarm; @@ -263,6 +264,7 @@ where _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(dummy::ConnectionHandler) } diff --git a/protocols/mdns/src/behaviour/iface/query.rs b/protocols/mdns/src/behaviour/iface/query.rs index eeb699fca6b..70b84816d0f 100644 --- a/protocols/mdns/src/behaviour/iface/query.rs +++ b/protocols/mdns/src/behaviour/iface/query.rs @@ -24,10 +24,9 @@ use hickory_proto::{ op::Message, rr::{Name, RData}, }; -use libp2p_core::{ - address_translation, - multiaddr::{Multiaddr, Protocol}, -}; +use libp2p_core::multiaddr::{Multiaddr, Protocol}; +use libp2p_swarm::_address_translation; + use libp2p_identity::PeerId; use std::time::Instant; use std::{fmt, net::SocketAddr, str, time::Duration}; @@ -179,7 +178,7 @@ impl MdnsResponse { let new_expiration = now + peer.ttl(); peer.addresses().iter().filter_map(move |address| { - let new_addr = address_translation(address, &observed)?; + let new_addr = _address_translation(address, &observed)?; let new_addr = new_addr.with_p2p(*peer.id()).ok()?; Some((*peer.id(), new_addr, new_expiration)) diff --git a/protocols/perf/CHANGELOG.md b/protocols/perf/CHANGELOG.md index b347f21e9e0..abeca9fad25 100644 --- a/protocols/perf/CHANGELOG.md +++ b/protocols/perf/CHANGELOG.md @@ -1,4 +1,6 @@ ## 0.4.0 + + - Add ConnectionError to FromSwarm::ConnectionClosed. See [PR 5485](https://github.com/libp2p/rust-libp2p/pull/5485). diff --git a/protocols/perf/src/client/behaviour.rs b/protocols/perf/src/client/behaviour.rs index 5e430f8f0c1..1b181557acc 100644 --- a/protocols/perf/src/client/behaviour.rs +++ b/protocols/perf/src/client/behaviour.rs @@ -25,7 +25,7 @@ use std::{ task::{Context, Poll}, }; -use libp2p_core::Multiaddr; +use libp2p_core::{transport::PortUse, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ derive_prelude::ConnectionEstablished, ConnectionClosed, ConnectionId, FromSwarm, @@ -92,6 +92,7 @@ impl NetworkBehaviour for Behaviour { _peer: PeerId, _addr: &Multiaddr, _role_override: libp2p_core::Endpoint, + _port_use: PortUse, ) -> Result, libp2p_swarm::ConnectionDenied> { Ok(Handler::default()) } diff --git a/protocols/perf/src/server/behaviour.rs b/protocols/perf/src/server/behaviour.rs index da24d763606..5408029e85d 100644 --- a/protocols/perf/src/server/behaviour.rs +++ b/protocols/perf/src/server/behaviour.rs @@ -25,6 +25,7 @@ use std::{ task::{Context, Poll}, }; +use libp2p_core::transport::PortUse; use libp2p_identity::PeerId; use libp2p_swarm::{ ConnectionId, FromSwarm, NetworkBehaviour, THandlerInEvent, THandlerOutEvent, ToSwarm, @@ -71,6 +72,7 @@ impl NetworkBehaviour for Behaviour { _peer: PeerId, _addr: &libp2p_core::Multiaddr, _role_override: libp2p_core::Endpoint, + _port_use: PortUse, ) -> Result, libp2p_swarm::ConnectionDenied> { Ok(Handler::default()) } diff --git a/protocols/ping/CHANGELOG.md b/protocols/ping/CHANGELOG.md index 7c7d7f3a54f..c0a124333e9 100644 --- a/protocols/ping/CHANGELOG.md +++ b/protocols/ping/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.45.0 + + + ## 0.44.2 - Use `web-time` instead of `instant`. @@ -12,7 +16,6 @@ `ping::Event` can now be shared between threads. See [PR 5250] - [PR 5250]: https://github.com/libp2p/rust-libp2p/pull/5250 ## 0.44.0 diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index 79c0a43aa69..2c347adb2c4 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-ping" edition = "2021" rust-version = { workspace = true } description = "Ping protocol for libp2p" -version = "0.44.2" +version = "0.45.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/ping/src/lib.rs b/protocols/ping/src/lib.rs index 5eaa6d4952a..82f240cab6b 100644 --- a/protocols/ping/src/lib.rs +++ b/protocols/ping/src/lib.rs @@ -51,6 +51,7 @@ mod handler; mod protocol; use handler::Handler; +use libp2p_core::transport::PortUse; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ @@ -124,6 +125,7 @@ impl NetworkBehaviour for Behaviour { _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(Handler::new(self.config.clone())) } diff --git a/protocols/ping/src/protocol.rs b/protocols/ping/src/protocol.rs index 8fc18505d35..566e5e258e2 100644 --- a/protocols/ping/src/protocol.rs +++ b/protocols/ping/src/protocol.rs @@ -86,7 +86,8 @@ mod tests { use futures::StreamExt; use libp2p_core::{ multiaddr::multiaddr, - transport::{memory::MemoryTransport, ListenerId, Transport}, + transport::{memory::MemoryTransport, DialOpts, ListenerId, PortUse, Transport}, + Endpoint, }; #[test] @@ -110,7 +111,13 @@ mod tests { async_std::task::block_on(async move { let c = MemoryTransport::new() - .dial(listener_addr) + .dial( + listener_addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) .unwrap() .await .unwrap(); diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index 97638d1ae6a..fc71ccedad5 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.18.0 + + + ## 0.17.3 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 4981c94d9c8..1a0e7836158 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-relay" edition = "2021" rust-version = { workspace = true } description = "Communications relaying for libp2p" -version = "0.17.3" +version = "0.18.0" authors = ["Parity Technologies ", "Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/relay/src/behaviour.rs b/protocols/relay/src/behaviour.rs index cf0e76e3662..463febf9f2f 100644 --- a/protocols/relay/src/behaviour.rs +++ b/protocols/relay/src/behaviour.rs @@ -28,6 +28,7 @@ use crate::proto; use crate::protocol::{inbound_hop, outbound_stop}; use either::Either; use libp2p_core::multiaddr::Protocol; +use libp2p_core::transport::PortUse; use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::{ConnectionClosed, FromSwarm}; @@ -328,6 +329,7 @@ impl NetworkBehaviour for Behaviour { _: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { if addr.is_relayed() { // Deny all substreams on relayed connection. @@ -343,6 +345,7 @@ impl NetworkBehaviour for Behaviour { ConnectedPoint::Dialer { address: addr.clone(), role_override, + port_use, }, ))) } diff --git a/protocols/relay/src/priv_client.rs b/protocols/relay/src/priv_client.rs index e414852ef81..f8d1d9c9eb2 100644 --- a/protocols/relay/src/priv_client.rs +++ b/protocols/relay/src/priv_client.rs @@ -34,6 +34,7 @@ use futures::io::{AsyncRead, AsyncWrite}; use futures::ready; use futures::stream::StreamExt; use libp2p_core::multiaddr::Protocol; +use libp2p_core::transport::PortUse; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::{ConnectionClosed, ConnectionEstablished, FromSwarm}; @@ -178,6 +179,7 @@ impl NetworkBehaviour for Behaviour { peer: PeerId, addr: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { if addr.is_relayed() { return Ok(Either::Right(dummy::ConnectionHandler)); diff --git a/protocols/relay/src/priv_client/transport.rs b/protocols/relay/src/priv_client/transport.rs index b4374aa4672..ec1e8ca5fb8 100644 --- a/protocols/relay/src/priv_client/transport.rs +++ b/protocols/relay/src/priv_client/transport.rs @@ -31,7 +31,7 @@ use futures::sink::SinkExt; use futures::stream::SelectAll; use futures::stream::{Stream, StreamExt}; use libp2p_core::multiaddr::{Multiaddr, Protocol}; -use libp2p_core::transport::{ListenerId, TransportError, TransportEvent}; +use libp2p_core::transport::{DialOpts, ListenerId, TransportError, TransportEvent}; use libp2p_identity::PeerId; use std::collections::VecDeque; use std::pin::Pin; @@ -49,7 +49,7 @@ use thiserror::Error; /// 1. Establish relayed connections by dialing `/p2p-circuit` addresses. /// /// ``` -/// # use libp2p_core::{Multiaddr, multiaddr::{Protocol}, Transport}; +/// # use libp2p_core::{Multiaddr, multiaddr::{Protocol}, Transport, transport::{DialOpts, PortUse}, connection::Endpoint}; /// # use libp2p_core::transport::memory::MemoryTransport; /// # use libp2p_core::transport::choice::OrTransport; /// # use libp2p_relay as relay; @@ -66,7 +66,10 @@ use thiserror::Error; /// .with(Protocol::P2p(relay_id.into())) // Relay peer id. /// .with(Protocol::P2pCircuit) // Signal to connect via relay and not directly. /// .with(Protocol::P2p(destination_id.into())); // Destination peer id. -/// transport.dial(dst_addr_via_relay).unwrap(); +/// transport.dial(dst_addr_via_relay, DialOpts { +/// port_use: PortUse::Reuse, +/// role: Endpoint::Dialer, +/// }).unwrap(); /// ``` /// /// 3. Listen for incoming relayed connections via specific relay. @@ -165,7 +168,19 @@ impl libp2p_core::Transport for Transport { } } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + dial_opts: DialOpts, + ) -> Result> { + if dial_opts.role.is_listener() { + // [`Endpoint::Listener`] is used for NAT and firewall + // traversal. One would coordinate such traversal via a previously + // established relayed connection, but never using a relayed connection + // itself. + return Err(TransportError::MultiaddrNotSupported(addr)); + } + let RelayedMultiaddr { relay_peer_id, relay_addr, @@ -198,24 +213,6 @@ impl libp2p_core::Transport for Transport { .boxed()) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> - where - Self: Sized, - { - // [`Transport::dial_as_listener`] is used for NAT and firewall - // traversal. One would coordinate such traversal via a previously - // established relayed connection, but never using a relayed connection - // itself. - Err(TransportError::MultiaddrNotSupported(addr)) - } - - fn address_translation(&self, _server: &Multiaddr, _observed: &Multiaddr) -> Option { - None - } - fn poll( mut self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/protocols/rendezvous/CHANGELOG.md b/protocols/rendezvous/CHANGELOG.md index 4aa18985f1e..1ed9e5bc3b0 100644 --- a/protocols/rendezvous/CHANGELOG.md +++ b/protocols/rendezvous/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.15.0 + + + ## 0.14.1 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index 6879a4093ce..32b233813e3 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-rendezvous" edition = "2021" rust-version = { workspace = true } description = "Rendezvous protocol for libp2p" -version = "0.14.1" +version = "0.15.0" authors = ["The COMIT guys "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/rendezvous/src/client.rs b/protocols/rendezvous/src/client.rs index 92d7884758b..a794252ff0b 100644 --- a/protocols/rendezvous/src/client.rs +++ b/protocols/rendezvous/src/client.rs @@ -24,6 +24,7 @@ use futures::future::BoxFuture; use futures::future::FutureExt; use futures::stream::FuturesUnordered; use futures::stream::StreamExt; +use libp2p_core::transport::PortUse; use libp2p_core::{Endpoint, Multiaddr, PeerRecord}; use libp2p_identity::{Keypair, PeerId, SigningError}; use libp2p_request_response::{OutboundRequestId, ProtocolSupport}; @@ -208,9 +209,15 @@ impl NetworkBehaviour for Behaviour { peer: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { - self.inner - .handle_established_outbound_connection(connection_id, peer, addr, role_override) + self.inner.handle_established_outbound_connection( + connection_id, + peer, + addr, + role_override, + port_use, + ) } fn on_connection_handler_event( diff --git a/protocols/rendezvous/src/server.rs b/protocols/rendezvous/src/server.rs index bee91f28e88..45a525d9573 100644 --- a/protocols/rendezvous/src/server.rs +++ b/protocols/rendezvous/src/server.rs @@ -24,6 +24,7 @@ use bimap::BiMap; use futures::future::BoxFuture; use futures::stream::FuturesUnordered; use futures::{FutureExt, StreamExt}; +use libp2p_core::transport::PortUse; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_request_response::ProtocolSupport; @@ -139,9 +140,15 @@ impl NetworkBehaviour for Behaviour { peer: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { - self.inner - .handle_established_outbound_connection(connection_id, peer, addr, role_override) + self.inner.handle_established_outbound_connection( + connection_id, + peer, + addr, + role_override, + port_use, + ) } fn on_connection_handler_event( diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index beee817f024..db0d9126516 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.27.0 + + + ## 0.26.4 - Use `web-time` instead of `instant`. diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 4bc2378ae54..af70fd9a83e 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-request-response" edition = "2021" rust-version = { workspace = true } description = "Generic Request/Response Protocols" -version = "0.26.4" +version = "0.27.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/request-response/src/lib.rs b/protocols/request-response/src/lib.rs index 4362b3255ad..e627f5668ff 100644 --- a/protocols/request-response/src/lib.rs +++ b/protocols/request-response/src/lib.rs @@ -79,7 +79,7 @@ pub use handler::ProtocolSupport; use crate::handler::OutboundMessage; use futures::channel::oneshot; use handler::Handler; -use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; +use libp2p_core::{transport::PortUse, ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ behaviour::{AddressChange, ConnectionClosed, DialFailure, FromSwarm}, @@ -772,6 +772,7 @@ where peer: PeerId, remote_address: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { let mut handler = Handler::new( self.inbound_protocols.clone(), diff --git a/protocols/stream/CHANGELOG.md b/protocols/stream/CHANGELOG.md index 1e3b85da0b9..2532970d3c6 100644 --- a/protocols/stream/CHANGELOG.md +++ b/protocols/stream/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.0-alpha + + + ## 0.1.0-alpha.1 - Implement Error for `OpenStreamError`. See [PR 5169](https://github.com/libp2p/rust-libp2p/pull/5169). diff --git a/protocols/stream/Cargo.toml b/protocols/stream/Cargo.toml index a8d88399c0b..9aa9559a2d6 100644 --- a/protocols/stream/Cargo.toml +++ b/protocols/stream/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-stream" -version = "0.1.0-alpha.1" +version = "0.2.0-alpha" edition = "2021" rust-version.workspace = true description = "Generic stream protocols for libp2p" diff --git a/protocols/stream/src/behaviour.rs b/protocols/stream/src/behaviour.rs index e02aca884b7..07549ccef54 100644 --- a/protocols/stream/src/behaviour.rs +++ b/protocols/stream/src/behaviour.rs @@ -5,7 +5,7 @@ use std::{ }; use futures::{channel::mpsc, StreamExt}; -use libp2p_core::{Endpoint, Multiaddr}; +use libp2p_core::{transport::PortUse, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ self as swarm, dial_opts::DialOpts, ConnectionDenied, ConnectionId, FromSwarm, @@ -82,6 +82,7 @@ impl NetworkBehaviour for Behaviour { peer: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(Handler::new( peer, diff --git a/protocols/upnp/CHANGELOG.md b/protocols/upnp/CHANGELOG.md index 9472c7153c6..21e90f9534b 100644 --- a/protocols/upnp/CHANGELOG.md +++ b/protocols/upnp/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0 + + + ## 0.2.2 - Fix a panic caused when `upnp::Gateway` is dropped and its events queue receiver is no longer available. diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index 944b3323842..50ed9db0f6f 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-upnp" edition = "2021" rust-version = "1.60.0" description = "UPnP support for libp2p transports" -version = "0.2.2" +version = "0.3.0" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] diff --git a/protocols/upnp/src/behaviour.rs b/protocols/upnp/src/behaviour.rs index a94ef9526dd..29a7fbf84a4 100644 --- a/protocols/upnp/src/behaviour.rs +++ b/protocols/upnp/src/behaviour.rs @@ -36,7 +36,11 @@ use crate::tokio::{is_addr_global, Gateway}; use futures::{channel::oneshot, Future, StreamExt}; use futures_timer::Delay; use igd_next::PortMappingProtocol; -use libp2p_core::{multiaddr, transport::ListenerId, Endpoint, Multiaddr}; +use libp2p_core::{ + multiaddr, + transport::{ListenerId, PortUse}, + Endpoint, Multiaddr, +}; use libp2p_swarm::{ derive_prelude::PeerId, dummy, ConnectionDenied, ConnectionId, ExpiredListenAddr, FromSwarm, NetworkBehaviour, NewListenAddr, ToSwarm, @@ -248,6 +252,7 @@ impl NetworkBehaviour for Behaviour { _peer: PeerId, _addr: &Multiaddr, _role_override: Endpoint, + _port_use: PortUse, ) -> Result, libp2p_swarm::ConnectionDenied> { Ok(dummy::ConnectionHandler) } diff --git a/swarm-derive/src/lib.rs b/swarm-derive/src/lib.rs index 2e7daf7acc4..258c0b976c8 100644 --- a/swarm-derive/src/lib.rs +++ b/swarm-derive/src/lib.rs @@ -76,6 +76,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> syn::Result syn::Result syn::Result Result<#t_handler, #connection_denied> { Ok(#handle_established_outbound_connection) } diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index f4901947b8b..9aeaa5a1ccc 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,6 +1,14 @@ ## 0.45.0 +- Implement refactored `Transport`. + See [PR 4568] +- Move `address_translation` into swarm and into `libp2p-identify`. + See [PR 4568] + +[PR 4568]: https://github.com/libp2p/rust-libp2p/pull/4568 + +## 0.44.3 - Optimize internal connection `fn poll`. New implementation now scales much better with number of listen protocols active. No changes to public API introduced. See [PR 5026](https://github.com/libp2p/rust-libp2p/pull/5026) diff --git a/swarm/benches/connection_handler.rs b/swarm/benches/connection_handler.rs index b9986d9649f..09340421f83 100644 --- a/swarm/benches/connection_handler.rs +++ b/swarm/benches/connection_handler.rs @@ -223,6 +223,7 @@ impl NetworkBehaviour for SpinningBehaviour { _peer: libp2p_identity::PeerId, _addr: &libp2p_core::Multiaddr, _role_override: libp2p_core::Endpoint, + _port_use: libp2p_core::transport::PortUse, ) -> Result, libp2p_swarm::ConnectionDenied> { Ok(SpinningHandler { iter_count: self.iter_count, diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index 8a8418739c8..35aed12fba5 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -35,7 +35,10 @@ use crate::{ ConnectionDenied, ConnectionError, ConnectionHandler, DialError, ListenError, THandler, THandlerInEvent, THandlerOutEvent, }; -use libp2p_core::{transport::ListenerId, ConnectedPoint, Endpoint, Multiaddr}; +use libp2p_core::{ + transport::{ListenerId, PortUse}, + ConnectedPoint, Endpoint, Multiaddr, +}; use libp2p_identity::PeerId; use std::{task::Context, task::Poll}; @@ -196,6 +199,7 @@ pub trait NetworkBehaviour: 'static { peer: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied>; /// Informs the behaviour about an event from the [`Swarm`](crate::Swarm). diff --git a/swarm/src/behaviour/either.rs b/swarm/src/behaviour/either.rs index 25da83fa11f..7a51303e74d 100644 --- a/swarm/src/behaviour/either.rs +++ b/swarm/src/behaviour/either.rs @@ -22,6 +22,7 @@ use crate::behaviour::{self, NetworkBehaviour, ToSwarm}; use crate::connection::ConnectionId; use crate::{ConnectionDenied, THandler, THandlerInEvent, THandlerOutEvent}; use either::Either; +use libp2p_core::transport::PortUse; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use std::{task::Context, task::Poll}; @@ -103,6 +104,7 @@ where peer: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { let handler = match self { Either::Left(inner) => Either::Left(inner.handle_established_outbound_connection( @@ -110,12 +112,14 @@ where peer, addr, role_override, + port_use, )?), Either::Right(inner) => Either::Right(inner.handle_established_outbound_connection( connection_id, peer, addr, role_override, + port_use, )?), }; diff --git a/swarm/src/behaviour/toggle.rs b/swarm/src/behaviour/toggle.rs index e81c5343701..398c919ae86 100644 --- a/swarm/src/behaviour/toggle.rs +++ b/swarm/src/behaviour/toggle.rs @@ -30,6 +30,7 @@ use crate::{ }; use either::Either; use futures::future; +use libp2p_core::transport::PortUse; use libp2p_core::{upgrade::DeniedUpgrade, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use std::{task::Context, task::Poll}; @@ -139,6 +140,7 @@ where peer: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { let inner = match self.inner.as_mut() { None => return Ok(ToggleConnectionHandler { inner: None }), @@ -150,6 +152,7 @@ where peer, addr, role_override, + port_use, )?; Ok(ToggleConnectionHandler { diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index 9c5e39830ed..603a5b0d7c4 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -27,6 +27,7 @@ pub use error::ConnectionError; pub(crate) use error::{ PendingConnectionError, PendingInboundConnectionError, PendingOutboundConnectionError, }; +use libp2p_core::transport::PortUse; pub use supported_protocols::SupportedProtocols; use crate::handler::{ @@ -1352,6 +1353,7 @@ enum PendingPoint { Dialer { /// Same as [`ConnectedPoint::Dialer`] `role_override`. role_override: Endpoint, + port_use: PortUse, }, /// The socket comes from a listener. Listener { @@ -1365,7 +1367,14 @@ enum PendingPoint { impl From for PendingPoint { fn from(endpoint: ConnectedPoint) -> Self { match endpoint { - ConnectedPoint::Dialer { role_override, .. } => PendingPoint::Dialer { role_override }, + ConnectedPoint::Dialer { + role_override, + port_use, + .. + } => PendingPoint::Dialer { + role_override, + port_use, + }, ConnectedPoint::Listener { local_addr, send_back_addr, diff --git a/swarm/src/connection/pool.rs b/swarm/src/connection/pool.rs index 48ba92f1020..07f6968dec9 100644 --- a/swarm/src/connection/pool.rs +++ b/swarm/src/connection/pool.rs @@ -39,6 +39,7 @@ use futures::{ }; use libp2p_core::connection::Endpoint; use libp2p_core::muxing::{StreamMuxerBox, StreamMuxerExt}; +use libp2p_core::transport::PortUse; use std::task::Waker; use std::{ collections::HashMap, @@ -424,6 +425,7 @@ where >, peer: Option, role_override: Endpoint, + port_use: PortUse, dial_concurrency_factor_override: Option, connection_id: ConnectionId, ) { @@ -444,7 +446,10 @@ where .instrument(span), ); - let endpoint = PendingPoint::Dialer { role_override }; + let endpoint = PendingPoint::Dialer { + role_override, + port_use, + }; self.counters.inc_pending(&endpoint); self.pending.insert( @@ -650,10 +655,17 @@ where self.counters.dec_pending(&endpoint); let (endpoint, concurrent_dial_errors) = match (endpoint, outgoing) { - (PendingPoint::Dialer { role_override }, Some((address, errors))) => ( + ( + PendingPoint::Dialer { + role_override, + port_use, + }, + Some((address, errors)), + ) => ( ConnectedPoint::Dialer { address, role_override, + port_use, }, Some(errors), ), diff --git a/swarm/src/dial_opts.rs b/swarm/src/dial_opts.rs index 4442d913847..4f5b621327c 100644 --- a/swarm/src/dial_opts.rs +++ b/swarm/src/dial_opts.rs @@ -22,10 +22,38 @@ use crate::ConnectionId; use libp2p_core::connection::Endpoint; use libp2p_core::multiaddr::Protocol; +use libp2p_core::transport::PortUse; use libp2p_core::Multiaddr; use libp2p_identity::PeerId; use std::num::NonZeroU8; +macro_rules! fn_override_role { + () => { + /// Override role of local node on connection. I.e. execute the dial _as a + /// listener_. + /// + /// See + /// [`ConnectedPoint::Dialer`](libp2p_core::connection::ConnectedPoint::Dialer) + /// for details. + pub fn override_role(mut self) -> Self { + self.role_override = Endpoint::Listener; + self + } + }; +} + +macro_rules! fn_allocate_new_port { + () => { + /// Enforce the allocation of a new port. + /// Default behaviour is best effort reuse of existing ports. If there is no existing + /// fitting listener, a new port is allocated. + pub fn allocate_new_port(mut self) -> Self { + self.port_use = PortUse::New; + self + } + }; +} + /// Options to configure a dial to a known or unknown peer. /// /// Used in [`Swarm::dial`](crate::Swarm::dial) and @@ -45,6 +73,7 @@ pub struct DialOpts { role_override: Endpoint, dial_concurrency_factor_override: Option, connection_id: ConnectionId, + port_use: PortUse, } impl DialOpts { @@ -65,6 +94,7 @@ impl DialOpts { condition: Default::default(), role_override: Endpoint::Dialer, dial_concurrency_factor_override: Default::default(), + port_use: PortUse::Reuse, } } @@ -124,6 +154,10 @@ impl DialOpts { pub(crate) fn role_override(&self) -> Endpoint { self.role_override } + + pub(crate) fn port_use(&self) -> PortUse { + self.port_use + } } impl From for DialOpts { @@ -144,6 +178,7 @@ pub struct WithPeerId { condition: PeerCondition, role_override: Endpoint, dial_concurrency_factor_override: Option, + port_use: PortUse, } impl WithPeerId { @@ -169,19 +204,12 @@ impl WithPeerId { extend_addresses_through_behaviour: false, role_override: self.role_override, dial_concurrency_factor_override: self.dial_concurrency_factor_override, + port_use: self.port_use, } } - /// Override role of local node on connection. I.e. execute the dial _as a - /// listener_. - /// - /// See - /// [`ConnectedPoint::Dialer`](libp2p_core::connection::ConnectedPoint::Dialer) - /// for details. - pub fn override_role(mut self) -> Self { - self.role_override = Endpoint::Listener; - self - } + fn_override_role!(); + fn_allocate_new_port!(); /// Build the final [`DialOpts`]. pub fn build(self) -> DialOpts { @@ -193,6 +221,7 @@ impl WithPeerId { role_override: self.role_override, dial_concurrency_factor_override: self.dial_concurrency_factor_override, connection_id: ConnectionId::next(), + port_use: self.port_use, } } } @@ -205,6 +234,7 @@ pub struct WithPeerIdWithAddresses { extend_addresses_through_behaviour: bool, role_override: Endpoint, dial_concurrency_factor_override: Option, + port_use: PortUse, } impl WithPeerIdWithAddresses { @@ -221,16 +251,8 @@ impl WithPeerIdWithAddresses { self } - /// Override role of local node on connection. I.e. execute the dial _as a - /// listener_. - /// - /// See - /// [`ConnectedPoint::Dialer`](libp2p_core::connection::ConnectedPoint::Dialer) - /// for details. - pub fn override_role(mut self) -> Self { - self.role_override = Endpoint::Listener; - self - } + fn_override_role!(); + fn_allocate_new_port!(); /// Override /// Number of addresses concurrently dialed for a single outbound connection attempt. @@ -249,6 +271,7 @@ impl WithPeerIdWithAddresses { role_override: self.role_override, dial_concurrency_factor_override: self.dial_concurrency_factor_override, connection_id: ConnectionId::next(), + port_use: self.port_use, } } } @@ -262,6 +285,7 @@ impl WithoutPeerId { WithoutPeerIdWithAddress { address, role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, } } } @@ -270,19 +294,13 @@ impl WithoutPeerId { pub struct WithoutPeerIdWithAddress { address: Multiaddr, role_override: Endpoint, + port_use: PortUse, } impl WithoutPeerIdWithAddress { - /// Override role of local node on connection. I.e. execute the dial _as a - /// listener_. - /// - /// See - /// [`ConnectedPoint::Dialer`](libp2p_core::connection::ConnectedPoint::Dialer) - /// for details. - pub fn override_role(mut self) -> Self { - self.role_override = Endpoint::Listener; - self - } + fn_override_role!(); + fn_allocate_new_port!(); + /// Build the final [`DialOpts`]. pub fn build(self) -> DialOpts { DialOpts { @@ -293,6 +311,7 @@ impl WithoutPeerIdWithAddress { role_override: self.role_override, dial_concurrency_factor_override: None, connection_id: ConnectionId::next(), + port_use: self.port_use, } } } diff --git a/swarm/src/dummy.rs b/swarm/src/dummy.rs index 86df676443b..6e1b4d56eb9 100644 --- a/swarm/src/dummy.rs +++ b/swarm/src/dummy.rs @@ -7,6 +7,7 @@ use crate::{ ConnectionDenied, ConnectionHandlerEvent, StreamUpgradeError, SubstreamProtocol, THandler, THandlerInEvent, THandlerOutEvent, }; +use libp2p_core::transport::PortUse; use libp2p_core::upgrade::DeniedUpgrade; use libp2p_core::Endpoint; use libp2p_core::Multiaddr; @@ -37,6 +38,7 @@ impl NetworkBehaviour for Behaviour { _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(ConnectionHandler) } diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 03e30240771..81b1ca1a68d 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -68,6 +68,7 @@ pub mod dial_opts; pub mod dummy; pub mod handler; mod listen_opts; +mod translation; /// Bundles all symbols required for the [`libp2p_swarm_derive::NetworkBehaviour`] macro. #[doc(hidden)] @@ -99,7 +100,7 @@ pub mod derive_prelude { pub use crate::ToSwarm; pub use either::Either; pub use futures::prelude as futures; - pub use libp2p_core::transport::ListenerId; + pub use libp2p_core::transport::{ListenerId, PortUse}; pub use libp2p_core::ConnectedPoint; pub use libp2p_core::Endpoint; pub use libp2p_core::Multiaddr; @@ -134,13 +135,15 @@ use connection::{ }; use dial_opts::{DialOpts, PeerCondition}; use futures::{prelude::*, stream::FusedStream}; + use libp2p_core::{ connection::ConnectedPoint, muxing::StreamMuxerBox, transport::{self, ListenerId, TransportError, TransportEvent}, - Endpoint, Multiaddr, Transport, + Multiaddr, Transport, }; use libp2p_identity::PeerId; + use smallvec::SmallVec; use std::collections::{HashMap, HashSet, VecDeque}; use std::num::{NonZeroU32, NonZeroU8, NonZeroUsize}; @@ -151,6 +154,8 @@ use std::{ task::{Context, Poll}, }; use tracing::Instrument; +#[doc(hidden)] +pub use translation::_address_translation; /// Event generated by the [`NetworkBehaviour`] that the swarm will report back. type TBehaviourOutEvent = ::ToSwarm; @@ -528,18 +533,15 @@ where .into_iter() .map(|a| match peer_id.map_or(Ok(a.clone()), |p| a.with_p2p(p)) { Ok(address) => { - let (dial, span) = match dial_opts.role_override() { - Endpoint::Dialer => ( - self.transport.dial(address.clone()), - tracing::debug_span!(parent: tracing::Span::none(), "Transport::dial", %address), - ), - Endpoint::Listener => ( - self.transport.dial_as_listener(address.clone()), - tracing::debug_span!(parent: tracing::Span::none(), "Transport::dial_as_listener", %address), - ), - }; + let dial = self.transport.dial( + address.clone(), + transport::DialOpts { + role: dial_opts.role_override(), + port_use: dial_opts.port_use(), + }, + ); + let span = tracing::debug_span!(parent: tracing::Span::none(), "Transport::dial", %address); span.follows_from(tracing::Span::current()); - match dial { Ok(fut) => fut .map(|r| (address, r.map_err(TransportError::Other))) @@ -560,6 +562,7 @@ where dials, peer_id, dial_opts.role_override(), + dial_opts.port_use(), dial_opts.dial_concurrency_override(), connection_id, ); @@ -706,12 +709,14 @@ where ConnectedPoint::Dialer { address, role_override, + port_use, } => { match self.behaviour.handle_established_outbound_connection( id, peer_id, &address, role_override, + port_use, ) { Ok(handler) => handler, Err(cause) => { @@ -1135,40 +1140,12 @@ where self.pending_handler_event = Some((peer_id, handler, event)); } ToSwarm::NewExternalAddrCandidate(addr) => { - // Apply address translation to the candidate address. - // For TCP without port-reuse, the observed address contains an ephemeral port which needs to be replaced by the port of a listen address. - let translated_addresses = { - let mut addrs: Vec<_> = self - .listened_addrs - .values() - .flatten() - .filter_map(|server| self.transport.address_translation(server, &addr)) - .collect(); - - // remove duplicates - addrs.sort_unstable(); - addrs.dedup(); - addrs - }; - - // If address translation yielded nothing, broadcast the original candidate address. - if translated_addresses.is_empty() { - self.behaviour - .on_swarm_event(FromSwarm::NewExternalAddrCandidate( - NewExternalAddrCandidate { addr: &addr }, - )); - self.pending_swarm_events - .push_back(SwarmEvent::NewExternalAddrCandidate { address: addr }); - } else { - for addr in translated_addresses { - self.behaviour - .on_swarm_event(FromSwarm::NewExternalAddrCandidate( - NewExternalAddrCandidate { addr: &addr }, - )); - self.pending_swarm_events - .push_back(SwarmEvent::NewExternalAddrCandidate { address: addr }); - } - } + self.behaviour + .on_swarm_event(FromSwarm::NewExternalAddrCandidate( + NewExternalAddrCandidate { addr: &addr }, + )); + self.pending_swarm_events + .push_back(SwarmEvent::NewExternalAddrCandidate { address: addr }); } ToSwarm::ExternalAddrConfirmed(addr) => { self.add_external_address(addr.clone()); @@ -1784,7 +1761,9 @@ mod tests { use crate::test::{CallTraceBehaviour, MockBehaviour}; use libp2p_core::multiaddr::multiaddr; use libp2p_core::transport::memory::MemoryTransportError; - use libp2p_core::{multiaddr, upgrade}; + use libp2p_core::transport::{PortUse, TransportEvent}; + use libp2p_core::Endpoint; + use libp2p_core::{multiaddr, transport, upgrade}; use libp2p_identity as identity; use libp2p_plaintext as plaintext; use libp2p_yamux as yamux; @@ -2179,6 +2158,7 @@ mod tests { ConnectedPoint::Dialer { address: other_addr, role_override: Endpoint::Dialer, + port_use: PortUse::Reuse, } ); } diff --git a/swarm/src/test.rs b/swarm/src/test.rs index d49b504392a..a6cb7c4d4eb 100644 --- a/swarm/src/test.rs +++ b/swarm/src/test.rs @@ -26,6 +26,7 @@ use crate::{ ConnectionDenied, ConnectionHandler, ConnectionId, NetworkBehaviour, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }; +use libp2p_core::transport::PortUse; use libp2p_core::{multiaddr::Multiaddr, transport::ListenerId, ConnectedPoint, Endpoint}; use libp2p_identity::PeerId; use std::collections::HashMap; @@ -91,6 +92,7 @@ where _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result { Ok(self.handler_proto.clone()) } @@ -427,6 +429,7 @@ where peer: PeerId, addr: &Multiaddr, role_override: Endpoint, + port_use: PortUse, ) -> Result, ConnectionDenied> { self.handle_established_outbound_connection.push(( peer, @@ -434,8 +437,13 @@ where role_override, connection_id, )); - self.inner - .handle_established_outbound_connection(connection_id, peer, addr, role_override) + self.inner.handle_established_outbound_connection( + connection_id, + peer, + addr, + role_override, + port_use, + ) } fn on_swarm_event(&mut self, event: FromSwarm) { diff --git a/core/src/translation.rs b/swarm/src/translation.rs similarity index 95% rename from core/src/translation.rs rename to swarm/src/translation.rs index efddae31052..baa80c907b5 100644 --- a/core/src/translation.rs +++ b/swarm/src/translation.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use multiaddr::{Multiaddr, Protocol}; +use libp2p_core::{multiaddr::Protocol, Multiaddr}; /// Perform IP address translation. /// @@ -35,7 +35,8 @@ use multiaddr::{Multiaddr, Protocol}; /// address and vice versa. /// /// If the first [`Protocol`]s are not IP addresses, `None` is returned instead. -pub fn address_translation(original: &Multiaddr, observed: &Multiaddr) -> Option { +#[doc(hidden)] +pub fn _address_translation(original: &Multiaddr, observed: &Multiaddr) -> Option { original.replace(0, move |proto| match proto { Protocol::Ip4(_) | Protocol::Ip6(_) @@ -106,7 +107,7 @@ mod tests { for test in tests.iter() { assert_eq!( - address_translation(&test.original, &test.observed), + _address_translation(&test.original, &test.observed), Some(test.expected.clone()) ); } diff --git a/swarm/tests/connection_close.rs b/swarm/tests/connection_close.rs index 4efe8d17e49..4d530f47684 100644 --- a/swarm/tests/connection_close.rs +++ b/swarm/tests/connection_close.rs @@ -1,3 +1,4 @@ +use libp2p_core::transport::PortUse; use libp2p_core::upgrade::DeniedUpgrade; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; @@ -66,6 +67,7 @@ impl NetworkBehaviour for Behaviour { _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(HandlerWithState { precious_state: self.state, diff --git a/swarm/tests/listener.rs b/swarm/tests/listener.rs index 8d22acc90e2..160b1f5b064 100644 --- a/swarm/tests/listener.rs +++ b/swarm/tests/listener.rs @@ -3,7 +3,11 @@ use std::{ task::{Context, Poll}, }; -use libp2p_core::{multiaddr::Protocol, transport::ListenerId, Endpoint, Multiaddr}; +use libp2p_core::{ + multiaddr::Protocol, + transport::{ListenerId, PortUse}, + Endpoint, Multiaddr, +}; use libp2p_identity::PeerId; use libp2p_swarm::{ derive_prelude::NewListener, dummy, ConnectionDenied, ConnectionId, FromSwarm, ListenOpts, @@ -93,6 +97,7 @@ impl NetworkBehaviour for Behaviour { _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(dummy::ConnectionHandler) } diff --git a/swarm/tests/swarm_derive.rs b/swarm/tests/swarm_derive.rs index 12f0d0a5ba8..919ed0cab7f 100644 --- a/swarm/tests/swarm_derive.rs +++ b/swarm/tests/swarm_derive.rs @@ -19,7 +19,7 @@ // DEALINGS IN THE SOFTWARE. use futures::StreamExt; -use libp2p_core::{Endpoint, Multiaddr}; +use libp2p_core::{transport::PortUse, Endpoint, Multiaddr}; use libp2p_identify as identify; use libp2p_ping as ping; use libp2p_swarm::{ @@ -404,6 +404,7 @@ fn with_generics_constrained() { _: libp2p_identity::PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(dummy::ConnectionHandler) } @@ -565,6 +566,7 @@ fn custom_out_event_no_type_parameters() { _: PeerId, _: &Multiaddr, _: Endpoint, + _: PortUse, ) -> Result, ConnectionDenied> { Ok(dummy::ConnectionHandler) } diff --git a/transports/dns/CHANGELOG.md b/transports/dns/CHANGELOG.md index 91cfbc00883..e4f951f157f 100644 --- a/transports/dns/CHANGELOG.md +++ b/transports/dns/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.42.0 + +- Implement refactored `Transport`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) + ## 0.41.1 - Add hidden API that removes unnecessary async for `async-std`. diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index 1e50ad444b8..b728509364a 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-dns" edition = "2021" rust-version = { workspace = true } description = "DNS transport implementation for libp2p" -version = "0.41.1" +version = "0.42.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/dns/src/lib.rs b/transports/dns/src/lib.rs index 63bd9bbad26..7d92cc8ecfc 100644 --- a/transports/dns/src/lib.rs +++ b/transports/dns/src/lib.rs @@ -149,9 +149,8 @@ pub mod tokio { use async_trait::async_trait; use futures::{future::BoxFuture, prelude::*}; use libp2p_core::{ - connection::Endpoint, multiaddr::{Multiaddr, Protocol}, - transport::{ListenerId, TransportError, TransportEvent}, + transport::{DialOpts, ListenerId, TransportError, TransportEvent}, }; use parking_lot::Mutex; use smallvec::SmallVec; @@ -231,19 +230,12 @@ where self.inner.lock().remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - Ok(self.do_dial(addr, Endpoint::Dialer)) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + dial_opts: DialOpts, ) -> Result> { - Ok(self.do_dial(addr, Endpoint::Listener)) - } - - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.inner.lock().address_translation(server, observed) + Ok(self.do_dial(addr, dial_opts)) } fn poll( @@ -269,7 +261,7 @@ where fn do_dial( &mut self, addr: Multiaddr, - role_override: Endpoint, + dial_opts: DialOpts, ) -> ::Dial { let resolver = self.resolver.clone(); let inner = self.inner.clone(); @@ -355,10 +347,7 @@ where tracing::debug!(address=%addr, "Dialing address"); let transport = inner.clone(); - let dial = match role_override { - Endpoint::Dialer => transport.lock().dial(addr), - Endpoint::Listener => transport.lock().dial_as_listener(addr), - }; + let dial = transport.lock().dial(addr, dial_opts); let result = match dial { Ok(out) => { // We only count attempts that the inner transport @@ -625,7 +614,12 @@ where #[cfg(all(test, any(feature = "tokio", feature = "async-std")))] mod tests { use super::*; - use libp2p_core::Transport; + use futures::future::BoxFuture; + use libp2p_core::{ + multiaddr::{Multiaddr, Protocol}, + transport::{PortUse, TransportError, TransportEvent}, + Endpoint, Transport, + }; use libp2p_identity::PeerId; #[test] @@ -655,7 +649,11 @@ mod tests { false } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + _: DialOpts, + ) -> Result> { // Check that all DNS components have been resolved, i.e. replaced. assert!(!addr.iter().any(|p| matches!( p, @@ -664,17 +662,6 @@ mod tests { Ok(Box::pin(future::ready(Ok(())))) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - self.dial(addr) - } - - fn address_translation(&self, _: &Multiaddr, _: &Multiaddr) -> Option { - None - } - fn poll( self: Pin<&mut Self>, _: &mut Context<'_>, @@ -690,30 +677,34 @@ mod tests { T::Dial: Send, R: Clone + Send + Sync + Resolver + 'static, { + let dial_opts = DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }; // Success due to existing A record for example.com. let _ = transport - .dial("/dns4/example.com/tcp/20000".parse().unwrap()) + .dial("/dns4/example.com/tcp/20000".parse().unwrap(), dial_opts) .unwrap() .await .unwrap(); // Success due to existing AAAA record for example.com. let _ = transport - .dial("/dns6/example.com/tcp/20000".parse().unwrap()) + .dial("/dns6/example.com/tcp/20000".parse().unwrap(), dial_opts) .unwrap() .await .unwrap(); // Success due to pass-through, i.e. nothing to resolve. let _ = transport - .dial("/ip4/1.2.3.4/tcp/20000".parse().unwrap()) + .dial("/ip4/1.2.3.4/tcp/20000".parse().unwrap(), dial_opts) .unwrap() .await .unwrap(); // Success due to the DNS TXT records at _dnsaddr.bootstrap.libp2p.io. let _ = transport - .dial("/dnsaddr/bootstrap.libp2p.io".parse().unwrap()) + .dial("/dnsaddr/bootstrap.libp2p.io".parse().unwrap(), dial_opts) .unwrap() .await .unwrap(); @@ -722,7 +713,7 @@ mod tests { // an entry with suffix `/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN`, // i.e. a bootnode with such a peer ID. let _ = transport - .dial("/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN".parse().unwrap()) + .dial("/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN".parse().unwrap(), dial_opts) .unwrap() .await .unwrap(); @@ -734,6 +725,7 @@ mod tests { format!("/dnsaddr/bootstrap.libp2p.io/p2p/{}", PeerId::random()) .parse() .unwrap(), + dial_opts, ) .unwrap() .await @@ -745,7 +737,10 @@ mod tests { // Failure due to no records. match transport - .dial("/dns4/example.invalid/tcp/20000".parse().unwrap()) + .dial( + "/dns4/example.invalid/tcp/20000".parse().unwrap(), + dial_opts, + ) .unwrap() .await { diff --git a/transports/quic/CHANGELOG.md b/transports/quic/CHANGELOG.md index 3ec52ec0ddb..2593af605df 100644 --- a/transports/quic/CHANGELOG.md +++ b/transports/quic/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.11.0 + +- Implement refactored `Transport`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) + ## 0.10.3 - Update `quinn` to 0.11 and `libp2p-tls` to 0.4.0. diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index c7e031b1cfd..d2d8c6fc2b0 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-quic" -version = "0.10.3" +version = "0.11.0" authors = ["Parity Technologies "] edition = "2021" rust-version = { workspace = true } diff --git a/transports/quic/src/transport.rs b/transports/quic/src/transport.rs index 9bd4c035cec..057d0f978d7 100644 --- a/transports/quic/src/transport.rs +++ b/transports/quic/src/transport.rs @@ -31,6 +31,8 @@ use futures::{prelude::*, stream::SelectAll}; use if_watch::IfEvent; +use libp2p_core::transport::{DialOpts, PortUse}; +use libp2p_core::Endpoint; use libp2p_core::{ multiaddr::{Multiaddr, Protocol}, transport::{ListenerId, TransportError, TransportEvent}, @@ -195,6 +197,21 @@ impl GenTransport

{ Ok(socket.into()) } + + fn bound_socket(&mut self, socket_addr: SocketAddr) -> Result { + let socket_family = socket_addr.ip().into(); + if let Some(waker) = self.waker.take() { + waker.wake(); + } + let listen_socket_addr = match socket_family { + SocketFamily::Ipv4 => SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0), + SocketFamily::Ipv6 => SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), 0), + }; + let socket = UdpSocket::bind(listen_socket_addr)?; + let endpoint_config = self.quinn_config.endpoint_config.clone(); + let endpoint = Self::new_endpoint(endpoint_config, None, socket)?; + Ok(endpoint) + } } impl Transport for GenTransport

{ @@ -247,119 +264,110 @@ impl Transport for GenTransport

{ } } - fn address_translation(&self, listen: &Multiaddr, observed: &Multiaddr) -> Option { - if !is_quic_addr(listen, self.support_draft_29) - || !is_quic_addr(observed, self.support_draft_29) - { - return None; - } - Some(observed.clone()) - } - - fn dial(&mut self, addr: Multiaddr) -> Result> { - let (socket_addr, version, _peer_id) = self.remote_multiaddr_to_socketaddr(addr, true)?; - - let endpoint = match self.eligible_listener(&socket_addr) { - None => { - // No listener. Get or create an explicit dialer. - let socket_family = socket_addr.ip().into(); - let dialer = match self.dialer.entry(socket_family) { - Entry::Occupied(occupied) => occupied.get().clone(), - Entry::Vacant(vacant) => { - if let Some(waker) = self.waker.take() { - waker.wake(); - } - let listen_socket_addr = match socket_family { - SocketFamily::Ipv4 => SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0), - SocketFamily::Ipv6 => SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), 0), - }; - let socket = - UdpSocket::bind(listen_socket_addr).map_err(Self::Error::from)?; - let endpoint_config = self.quinn_config.endpoint_config.clone(); - let endpoint = Self::new_endpoint(endpoint_config, None, socket)?; - - vacant.insert(endpoint.clone()); - endpoint - } - }; - dialer - } - Some(listener) => listener.endpoint.clone(), - }; - let handshake_timeout = self.handshake_timeout; - let mut client_config = self.quinn_config.client_config.clone(); - if version == ProtocolVersion::Draft29 { - client_config.version(0xff00_001d); - } - Ok(Box::pin(async move { - // This `"l"` seems necessary because an empty string is an invalid domain - // name. While we don't use domain names, the underlying rustls library - // is based upon the assumption that we do. - let connecting = endpoint - .connect_with(client_config, socket_addr, "l") - .map_err(ConnectError)?; - Connecting::new(connecting, handshake_timeout).await - })) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + dial_opts: DialOpts, ) -> Result> { - let (socket_addr, _version, peer_id) = + let (socket_addr, version, peer_id) = self.remote_multiaddr_to_socketaddr(addr.clone(), true)?; - let peer_id = peer_id.ok_or(TransportError::MultiaddrNotSupported(addr.clone()))?; - - let socket = self - .eligible_listener(&socket_addr) - .ok_or(TransportError::Other( - Error::NoActiveListenerForDialAsListener, - ))? - .try_clone_socket() - .map_err(Self::Error::from)?; - - tracing::debug!("Preparing for hole-punch from {addr}"); - - let hole_puncher = hole_puncher::

(socket, socket_addr, self.handshake_timeout); - - let (sender, receiver) = oneshot::channel(); - - match self.hole_punch_attempts.entry(socket_addr) { - Entry::Occupied(mut sender_entry) => { - // Stale senders, i.e. from failed hole punches are not removed. - // Thus, we can just overwrite a stale sender. - if !sender_entry.get().is_canceled() { - return Err(TransportError::Other(Error::HolePunchInProgress( - socket_addr, - ))); + + match (dial_opts.role, dial_opts.port_use) { + (Endpoint::Dialer, _) | (Endpoint::Listener, PortUse::Reuse) => { + let endpoint = if let Some(listener) = dial_opts + .port_use + .eq(&PortUse::Reuse) + .then(|| self.eligible_listener(&socket_addr)) + .flatten() + { + listener.endpoint.clone() + } else { + let socket_family = socket_addr.ip().into(); + let dialer = if dial_opts.port_use == PortUse::Reuse { + if let Some(occupied) = self.dialer.get(&socket_family) { + occupied.clone() + } else { + let endpoint = self.bound_socket(socket_addr)?; + self.dialer.insert(socket_family, endpoint.clone()); + endpoint + } + } else { + self.bound_socket(socket_addr)? + }; + dialer + }; + let handshake_timeout = self.handshake_timeout; + let mut client_config = self.quinn_config.client_config.clone(); + if version == ProtocolVersion::Draft29 { + client_config.version(0xff00_001d); } - sender_entry.insert(sender); - } - Entry::Vacant(entry) => { - entry.insert(sender); + Ok(Box::pin(async move { + // This `"l"` seems necessary because an empty string is an invalid domain + // name. While we don't use domain names, the underlying rustls library + // is based upon the assumption that we do. + let connecting = endpoint + .connect_with(client_config, socket_addr, "l") + .map_err(ConnectError)?; + Connecting::new(connecting, handshake_timeout).await + })) } - }; + (Endpoint::Listener, _) => { + let peer_id = peer_id.ok_or(TransportError::MultiaddrNotSupported(addr.clone()))?; + + let socket = self + .eligible_listener(&socket_addr) + .ok_or(TransportError::Other( + Error::NoActiveListenerForDialAsListener, + ))? + .try_clone_socket() + .map_err(Self::Error::from)?; + + tracing::debug!("Preparing for hole-punch from {addr}"); + + let hole_puncher = hole_puncher::

(socket, socket_addr, self.handshake_timeout); + + let (sender, receiver) = oneshot::channel(); + + match self.hole_punch_attempts.entry(socket_addr) { + Entry::Occupied(mut sender_entry) => { + // Stale senders, i.e. from failed hole punches are not removed. + // Thus, we can just overwrite a stale sender. + if !sender_entry.get().is_canceled() { + return Err(TransportError::Other(Error::HolePunchInProgress( + socket_addr, + ))); + } + sender_entry.insert(sender); + } + Entry::Vacant(entry) => { + entry.insert(sender); + } + }; - Ok(Box::pin(async move { - futures::pin_mut!(hole_puncher); - match futures::future::select(receiver, hole_puncher).await { - Either::Left((message, _)) => { - let (inbound_peer_id, connection) = message - .expect("hole punch connection sender is never dropped before receiver") - .await?; - if inbound_peer_id != peer_id { - tracing::warn!( - peer=%peer_id, - inbound_peer=%inbound_peer_id, - socket_address=%socket_addr, - "expected inbound connection from socket_address to resolve to peer but got inbound peer" - ); + Ok(Box::pin(async move { + futures::pin_mut!(hole_puncher); + match futures::future::select(receiver, hole_puncher).await { + Either::Left((message, _)) => { + let (inbound_peer_id, connection) = message + .expect( + "hole punch connection sender is never dropped before receiver", + ) + .await?; + if inbound_peer_id != peer_id { + tracing::warn!( + peer=%peer_id, + inbound_peer=%inbound_peer_id, + socket_address=%socket_addr, + "expected inbound connection from socket_address to resolve to peer but got inbound peer" + ); + } + Ok((inbound_peer_id, connection)) + } + Either::Right((hole_punch_err, _)) => Err(hole_punch_err), } - Ok((inbound_peer_id, connection)) - } - Either::Right((hole_punch_err, _)) => Err(hole_punch_err), + })) } - })) + } } fn poll( @@ -722,33 +730,6 @@ fn multiaddr_to_socketaddr( } } -/// Whether an [`Multiaddr`] is a valid for the QUIC transport. -fn is_quic_addr(addr: &Multiaddr, support_draft_29: bool) -> bool { - use Protocol::*; - let mut iter = addr.iter(); - let Some(first) = iter.next() else { - return false; - }; - let Some(second) = iter.next() else { - return false; - }; - let Some(third) = iter.next() else { - return false; - }; - let fourth = iter.next(); - let fifth = iter.next(); - - matches!(first, Ip4(_) | Ip6(_) | Dns(_) | Dns4(_) | Dns6(_)) - && matches!(second, Udp(_)) - && if support_draft_29 { - matches!(third, QuicV1 | Quic) - } else { - matches!(third, QuicV1) - } - && matches!(fourth, Some(P2p(_)) | None) - && fifth.is_none() -} - /// Turns an IP address and port into the corresponding QUIC multiaddr. fn socketaddr_to_multiaddr(socket_addr: &SocketAddr, version: ProtocolVersion) -> Multiaddr { let quic_proto = match version { @@ -921,7 +902,13 @@ mod tests { let mut transport = crate::tokio::Transport::new(config); let _dial = transport - .dial("/ip4/123.45.67.8/udp/1234/quic-v1".parse().unwrap()) + .dial( + "/ip4/123.45.67.8/udp/1234/quic-v1".parse().unwrap(), + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) .unwrap(); assert!(transport.dialer.contains_key(&SocketFamily::Ipv4)); diff --git a/transports/quic/tests/smoke.rs b/transports/quic/tests/smoke.rs index 74423076780..6a760f9997c 100644 --- a/transports/quic/tests/smoke.rs +++ b/transports/quic/tests/smoke.rs @@ -7,8 +7,9 @@ use futures::stream::StreamExt; use futures::{future, AsyncReadExt, AsyncWriteExt, FutureExt, SinkExt}; use futures_timer::Delay; use libp2p_core::muxing::{StreamMuxerBox, StreamMuxerExt, SubstreamBox}; -use libp2p_core::transport::{Boxed, OrTransport, TransportEvent}; +use libp2p_core::transport::{Boxed, DialOpts, OrTransport, PortUse, TransportEvent}; use libp2p_core::transport::{ListenerId, TransportError}; +use libp2p_core::Endpoint; use libp2p_core::{multiaddr::Protocol, upgrade, Multiaddr, Transport}; use libp2p_identity::PeerId; use libp2p_noise as noise; @@ -90,6 +91,8 @@ async fn ipv4_dial_ipv6() { #[cfg(feature = "async-std")] #[async_std::test] async fn wrapped_with_delay() { + use libp2p_core::transport::DialOpts; + let _ = tracing_subscriber::fmt() .with_env_filter(EnvFilter::from_default_env()) .try_init(); @@ -114,18 +117,14 @@ async fn wrapped_with_delay() { self.0.lock().unwrap().remove_listener(id) } - fn address_translation( - &self, - listen: &Multiaddr, - observed: &Multiaddr, - ) -> Option { - self.0.lock().unwrap().address_translation(listen, observed) - } - /// Delayed dial, i.e. calling [`Transport::dial`] on the inner [`Transport`] not within the /// synchronous [`Transport::dial`] method, but within the [`Future`] returned by the outer /// [`Transport::dial`]. - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + dial_opts: DialOpts, + ) -> Result> { let t = self.0.clone(); Ok(async move { // Simulate DNS lookup. Giving the `Transport::poll` the chance to return @@ -133,24 +132,21 @@ async fn wrapped_with_delay() { // on the inner transport below. Delay::new(Duration::from_millis(100)).await; - let dial = t.lock().unwrap().dial(addr).map_err(|e| match e { - TransportError::MultiaddrNotSupported(_) => { - panic!() - } - TransportError::Other(e) => e, - })?; + let dial = t + .lock() + .unwrap() + .dial(addr, dial_opts) + .map_err(|e| match e { + TransportError::MultiaddrNotSupported(_) => { + panic!() + } + TransportError::Other(e) => e, + })?; dial.await } .boxed()) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - self.0.lock().unwrap().dial_as_listener(addr) - } - fn poll( self: Pin<&mut Self>, cx: &mut std::task::Context<'_>, @@ -183,7 +179,15 @@ async fn wrapped_with_delay() { // Note that the dial is spawned on a different task than the transport allowing the transport // task to poll the transport once and then suspend, waiting for the wakeup from the dial. let dial = async_std::task::spawn({ - let dial = b_transport.dial(a_addr).unwrap(); + let dial = b_transport + .dial( + a_addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap(); async { dial.await.unwrap().0 } }); async_std::task::spawn(async move { b_transport.next().await }); @@ -315,7 +319,13 @@ async fn draft_29_support() { let (_, mut c_transport) = create_transport::(|cfg| cfg.support_draft_29 = false); assert!(matches!( - c_transport.dial(a_quic_addr), + c_transport.dial( + a_quic_addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::New + } + ), Err(TransportError::MultiaddrNotSupported(_)) )); @@ -331,7 +341,15 @@ async fn draft_29_support() { )); let d_quic_v1_addr = start_listening(&mut d_transport, "/ip4/127.0.0.1/udp/0/quic-v1").await; let d_quic_addr_mapped = swap_protocol!(d_quic_v1_addr, QuicV1 => Quic); - let dial = b_transport.dial(d_quic_addr_mapped).unwrap(); + let dial = b_transport + .dial( + d_quic_addr_mapped, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap(); let drive_transports = poll_fn::<(), _>(|cx| { let _ = b_transport.poll_next_unpin(cx); let _ = d_transport.poll_next_unpin(cx); @@ -408,7 +426,7 @@ async fn write_after_peer_dropped_stream() { .try_init(); let (stream_a, mut stream_b) = build_streams::().await; drop(stream_a); - futures_timer::Delay::new(Duration::from_millis(10)).await; + futures_timer::Delay::new(Duration::from_millis(100)).await; let data = vec![0; 10]; stream_b.write_all(&data).await.expect("Write failed."); @@ -765,7 +783,20 @@ async fn dial( transport: &mut Boxed<(PeerId, StreamMuxerBox)>, addr: Multiaddr, ) -> io::Result<(PeerId, StreamMuxerBox)> { - match future::select(transport.dial(addr).unwrap(), transport.next()).await { + match future::select( + transport + .dial( + addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap(), + transport.next(), + ) + .await + { Either::Left((conn, _)) => conn, Either::Right((event, _)) => { panic!("Unexpected event: {event:?}") diff --git a/transports/quic/tests/stream_compliance.rs b/transports/quic/tests/stream_compliance.rs index 0eff0584588..b0536473215 100644 --- a/transports/quic/tests/stream_compliance.rs +++ b/transports/quic/tests/stream_compliance.rs @@ -1,7 +1,7 @@ use futures::channel::oneshot; use futures::StreamExt; -use libp2p_core::transport::ListenerId; -use libp2p_core::Transport; +use libp2p_core::transport::{DialOpts, ListenerId, PortUse}; +use libp2p_core::{Endpoint, Transport}; use libp2p_quic as quic; use std::time::Duration; @@ -47,7 +47,15 @@ async fn connected_peers() -> (quic::Connection, quic::Connection) { listener.next().await; } }); - let dial_fut = dialer.dial(listen_address).unwrap(); + let dial_fut = dialer + .dial( + listen_address, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap(); async_std::task::spawn(async move { let connection = dial_fut.await.unwrap().1; diff --git a/transports/tcp/CHANGELOG.md b/transports/tcp/CHANGELOG.md index f0204f1ba85..107d0d13ece 100644 --- a/transports/tcp/CHANGELOG.md +++ b/transports/tcp/CHANGELOG.md @@ -1,5 +1,14 @@ ## 0.42.0 +- Implement refactored `Transport`. + See [PR 4568] +- Deprecate `port_reuse` setting, as this is now decided by the behaviour, not the transport. + See [PR 4568] + +[PR 4568]: https://github.com/libp2p/rust-libp2p/pull/4568 + +## 0.41.1 + - Disable Nagle's algorithm (i.e. `TCP_NODELAY`) by default. See [PR 4916](https://github.com/libp2p/rust-libp2p/pull/4916) diff --git a/transports/tcp/src/lib.rs b/transports/tcp/src/lib.rs index 3d881a6421c..386caa78b0f 100644 --- a/transports/tcp/src/lib.rs +++ b/transports/tcp/src/lib.rs @@ -40,9 +40,8 @@ use futures::{future::Ready, prelude::*, stream::SelectAll}; use futures_timer::Delay; use if_watch::IfEvent; use libp2p_core::{ - address_translation, multiaddr::{Multiaddr, Protocol}, - transport::{ListenerId, TransportError, TransportEvent}, + transport::{DialOpts, ListenerId, PortUse, TransportError, TransportEvent}, }; use provider::{Incoming, Provider}; use socket2::{Domain, Socket, Type}; @@ -65,27 +64,16 @@ pub struct Config { nodelay: Option, /// Size of the listen backlog for listen sockets. backlog: u32, - /// Whether port reuse should be enabled. - enable_port_reuse: bool, } type Port = u16; /// The configuration for port reuse of listening sockets. -#[derive(Debug, Clone)] -enum PortReuse { - /// Port reuse is disabled, i.e. ephemeral local ports are - /// used for outgoing TCP connections. - Disabled, - /// Port reuse when dialing is enabled, i.e. the local - /// address and port that a new socket for an outgoing - /// connection is bound to are chosen from an existing - /// listening socket, if available. - Enabled { - /// The addresses and ports of the listening sockets - /// registered as eligible for port reuse when dialing. - listen_addrs: Arc>>, - }, +#[derive(Debug, Clone, Default)] +struct PortReuse { + /// The addresses and ports of the listening sockets + /// registered as eligible for port reuse when dialing + listen_addrs: Arc>>, } impl PortReuse { @@ -93,26 +81,22 @@ impl PortReuse { /// /// Has no effect if port reuse is disabled. fn register(&mut self, ip: IpAddr, port: Port) { - if let PortReuse::Enabled { listen_addrs } = self { - tracing::trace!(%ip, %port, "Registering for port reuse"); - listen_addrs - .write() - .expect("`register()` and `unregister()` never panic while holding the lock") - .insert((ip, port)); - } + tracing::trace!(%ip, %port, "Registering for port reuse"); + self.listen_addrs + .write() + .expect("`register()` and `unregister()` never panic while holding the lock") + .insert((ip, port)); } /// Unregisters a socket address for port reuse. /// /// Has no effect if port reuse is disabled. fn unregister(&mut self, ip: IpAddr, port: Port) { - if let PortReuse::Enabled { listen_addrs } = self { - tracing::trace!(%ip, %port, "Unregistering for port reuse"); - listen_addrs - .write() - .expect("`register()` and `unregister()` never panic while holding the lock") - .remove(&(ip, port)); - } + tracing::trace!(%ip, %port, "Unregistering for port reuse"); + self.listen_addrs + .write() + .expect("`register()` and `unregister()` never panic while holding the lock") + .remove(&(ip, port)); } /// Selects a listening socket address suitable for use @@ -125,20 +109,17 @@ impl PortReuse { /// Returns `None` if port reuse is disabled or no suitable /// listening socket address is found. fn local_dial_addr(&self, remote_ip: &IpAddr) -> Option { - if let PortReuse::Enabled { listen_addrs } = self { - for (ip, port) in listen_addrs - .read() - .expect("`local_dial_addr` never panic while holding the lock") - .iter() - { - if ip.is_ipv4() == remote_ip.is_ipv4() - && ip.is_loopback() == remote_ip.is_loopback() - { - if remote_ip.is_ipv4() { - return Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), *port)); - } else { - return Some(SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), *port)); - } + for (ip, port) in self + .listen_addrs + .read() + .expect("`local_dial_addr` never panic while holding the lock") + .iter() + { + if ip.is_ipv4() == remote_ip.is_ipv4() && ip.is_loopback() == remote_ip.is_loopback() { + if remote_ip.is_ipv4() { + return Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), *port)); + } else { + return Some(SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), *port)); } } } @@ -163,7 +144,6 @@ impl Config { ttl: None, nodelay: Some(false), // Disable Nagle's algorithm by default backlog: 1024, - enable_port_reuse: false, } } @@ -189,101 +169,55 @@ impl Config { /// reuse of listening ports for outgoing connections to /// enhance NAT traversal capabilities. /// - /// Please refer to e.g. [RFC 4787](https://tools.ietf.org/html/rfc4787) - /// section 4 and 5 for some of the NAT terminology used here. - /// - /// There are two main use-cases for port reuse among local - /// sockets: - /// - /// 1. Creating multiple listening sockets for the same address - /// and port to allow accepting connections on multiple threads - /// without having to synchronise access to a single listen socket. - /// - /// 2. Creating outgoing connections whose local socket is bound to - /// the same address and port as a listening socket. In the rare - /// case of simple NATs with both endpoint-independent mapping and - /// endpoint-independent filtering, this can on its own already - /// permit NAT traversal by other nodes sharing the observed - /// external address of the local node. For the common case of - /// NATs with address-dependent or address and port-dependent - /// filtering, port reuse for outgoing connections can facilitate - /// further TCP hole punching techniques for NATs that perform - /// endpoint-independent mapping. Port reuse cannot facilitate - /// NAT traversal in the presence of "symmetric" NATs that employ - /// both address/port-dependent mapping and filtering, unless - /// there is some means of port prediction. - /// - /// Both use-cases are enabled when port reuse is enabled, with port reuse - /// for outgoing connections (`2.` above) always being implied. - /// - /// > **Note**: Due to the identification of a TCP socket by a 4-tuple - /// > of source IP address, source port, destination IP address and - /// > destination port, with port reuse enabled there can be only - /// > a single outgoing connection to a particular address and port - /// > of a peer per local listening socket address. - /// - /// [`Transport`] keeps track of the listen socket addresses as they - /// are reported by polling it. It is possible to listen on multiple - /// addresses, enabling port reuse for each, knowing exactly which listen - /// address is reused when dialing with a specific [`Transport`], as in the - /// following example: - /// - /// ```no_run - /// # use futures::StreamExt; - /// # use libp2p_core::transport::{ListenerId, TransportEvent}; - /// # use libp2p_core::{Multiaddr, Transport}; - /// # use std::pin::Pin; - /// # #[cfg(not(feature = "async-io"))] - /// # fn main() {} - /// # - /// #[cfg(feature = "async-io")] - /// #[async_std::main] - /// async fn main() -> std::io::Result<()> { - /// - /// let listen_addr1: Multiaddr = "/ip4/127.0.0.1/tcp/9001".parse().unwrap(); - /// let listen_addr2: Multiaddr = "/ip4/127.0.0.1/tcp/9002".parse().unwrap(); - /// - /// let mut tcp1 = libp2p_tcp::async_io::Transport::new(libp2p_tcp::Config::new().port_reuse(true)).boxed(); - /// tcp1.listen_on(ListenerId::next(), listen_addr1.clone()).expect("listener"); - /// match tcp1.select_next_some().await { - /// TransportEvent::NewAddress { listen_addr, .. } => { - /// println!("Listening on {:?}", listen_addr); - /// let mut stream = tcp1.dial(listen_addr2.clone()).unwrap().await?; - /// // `stream` has `listen_addr1` as its local socket address. - /// } - /// _ => {} - /// } + /// # Deprecation Notice /// - /// let mut tcp2 = libp2p_tcp::async_io::Transport::new(libp2p_tcp::Config::new().port_reuse(true)).boxed(); - /// tcp2.listen_on(ListenerId::next(), listen_addr2).expect("listener"); - /// match tcp2.select_next_some().await { - /// TransportEvent::NewAddress { listen_addr, .. } => { - /// println!("Listening on {:?}", listen_addr); - /// let mut socket = tcp2.dial(listen_addr1).unwrap().await?; - /// // `stream` has `listen_addr2` as its local socket address. - /// } - /// _ => {} - /// } - /// Ok(()) - /// } - /// ``` + /// The new implementation works on a per-connaction basis, defined by the behaviour. This + /// removes the necessaity to configure the transport for port reuse, instead the behaviour + /// requiring this behaviour can decide wether to use port reuse or not. /// - /// If a wildcard listen socket address is used to listen on any interface, - /// there can be multiple such addresses registered for port reuse. In this - /// case, one is chosen whose IP protocol version and loopback status is the - /// same as that of the remote address. Consequently, for maximum control of - /// the local listening addresses and ports that are used for outgoing - /// connections, a new [`Transport`] should be created for each listening - /// socket, avoiding the use of wildcard addresses which bind a socket to - /// all network interfaces. + /// The API to configure port reuse is part of [`Transport`] and the option can be found in + /// [`libp2p_core::transport::DialOpts`]. /// - /// When this option is enabled on a unix system, the socket - /// option `SO_REUSEPORT` is set, if available, to permit - /// reuse of listening ports for multiple sockets. - pub fn port_reuse(mut self, port_reuse: bool) -> Self { - self.enable_port_reuse = port_reuse; + /// If [`PortUse::Reuse`] is enabled, the transport will try to reuse the local port of the + /// listener. If that's not possible, i.e. there is no listener or the transport doesn't allow + /// a direct control over ports, a new port (or the default behaviour) is used. If port reuse + /// is enabled for a connection, this option will be treated on a best-effor basis. + #[deprecated( + since = "0.42.0", + note = "This option does nothing now, since the port reuse policy is now decided on a per-connection basis by the behaviour. The function will be removed in a future release." + )] + pub fn port_reuse(self, _port_reuse: bool) -> Self { self } + + fn create_socket(&self, socket_addr: SocketAddr, port_use: PortUse) -> io::Result { + let socket = Socket::new( + Domain::for_address(socket_addr), + Type::STREAM, + Some(socket2::Protocol::TCP), + )?; + if socket_addr.is_ipv6() { + socket.set_only_v6(true)?; + } + if let Some(ttl) = self.ttl { + socket.set_ttl(ttl)?; + } + if let Some(nodelay) = self.nodelay { + socket.set_nodelay(nodelay)?; + } + socket.set_reuse_address(true)?; + #[cfg(all(unix, not(any(target_os = "solaris", target_os = "illumos"))))] + if port_use == PortUse::Reuse { + socket.set_reuse_port(true)?; + } + + #[cfg(not(all(unix, not(any(target_os = "solaris", target_os = "illumos")))))] + let _ = port_use; // silence the unused warning on non-unix platforms (i.e. Windows) + + socket.set_nonblocking(true)?; + + Ok(socket) + } } impl Default for Config { @@ -328,49 +262,18 @@ where /// - [`tokio::Transport::new`] /// - [`async_io::Transport::new`] pub fn new(config: Config) -> Self { - let port_reuse = if config.enable_port_reuse { - PortReuse::Enabled { - listen_addrs: Arc::new(RwLock::new(HashSet::new())), - } - } else { - PortReuse::Disabled - }; Transport { config, - port_reuse, ..Default::default() } } - fn create_socket(&self, socket_addr: SocketAddr) -> io::Result { - let socket = Socket::new( - Domain::for_address(socket_addr), - Type::STREAM, - Some(socket2::Protocol::TCP), - )?; - if socket_addr.is_ipv6() { - socket.set_only_v6(true)?; - } - if let Some(ttl) = self.config.ttl { - socket.set_ttl(ttl)?; - } - if let Some(nodelay) = self.config.nodelay { - socket.set_nodelay(nodelay)?; - } - socket.set_reuse_address(true)?; - #[cfg(unix)] - if let PortReuse::Enabled { .. } = &self.port_reuse { - socket.set_reuse_port(true)?; - } - Ok(socket) - } - fn do_listen( &mut self, id: ListenerId, socket_addr: SocketAddr, ) -> io::Result> { - let socket = self.create_socket(socket_addr)?; + let socket = self.config.create_socket(socket_addr, PortUse::Reuse)?; socket.bind(&socket_addr.into())?; socket.listen(self.config.backlog as _)?; socket.set_nonblocking(true)?; @@ -404,17 +307,9 @@ where /// /// This transport will have port-reuse disabled. fn default() -> Self { - let config = Config::default(); - let port_reuse = if config.enable_port_reuse { - PortReuse::Enabled { - listen_addrs: Arc::new(RwLock::new(HashSet::new())), - } - } else { - PortReuse::Disabled - }; Transport { - port_reuse, - config, + port_reuse: PortReuse::default(), + config: Config::default(), listeners: SelectAll::new(), pending_events: VecDeque::new(), } @@ -456,7 +351,11 @@ where } } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + opts: DialOpts, + ) -> Result> { let socket_addr = if let Ok(socket_addr) = multiaddr_to_socketaddr(addr.clone()) { if socket_addr.port() == 0 || socket_addr.ip().is_unspecified() { return Err(TransportError::MultiaddrNotSupported(addr)); @@ -468,26 +367,45 @@ where tracing::debug!(address=%socket_addr, "dialing address"); let socket = self - .create_socket(socket_addr) + .config + .create_socket(socket_addr, opts.port_use) .map_err(TransportError::Other)?; - if let Some(addr) = self.port_reuse.local_dial_addr(&socket_addr.ip()) { - tracing::trace!(address=%addr, "Binding dial socket to listen socket address"); - socket.bind(&addr.into()).map_err(TransportError::Other)?; - } + let bind_addr = match self.port_reuse.local_dial_addr(&socket_addr.ip()) { + Some(socket_addr) if opts.port_use == PortUse::Reuse => { + tracing::trace!(address=%addr, "Binding dial socket to listen socket address"); + Some(socket_addr) + } + _ => None, + }; - socket - .set_nonblocking(true) - .map_err(TransportError::Other)?; + let local_config = self.config.clone(); Ok(async move { + if let Some(bind_addr) = bind_addr { + socket.bind(&bind_addr.into())?; + } + // [`Transport::dial`] should do no work unless the returned [`Future`] is polled. Thus // do the `connect` call within the [`Future`]. - match socket.connect(&socket_addr.into()) { - Ok(()) => {} - Err(err) if err.raw_os_error() == Some(libc::EINPROGRESS) => {} - Err(err) if err.kind() == io::ErrorKind::WouldBlock => {} - Err(err) => return Err(err), + let socket = match (socket.connect(&socket_addr.into()), bind_addr) { + (Ok(()), _) => socket, + (Err(err), _) if err.raw_os_error() == Some(libc::EINPROGRESS) => socket, + (Err(err), _) if err.kind() == io::ErrorKind::WouldBlock => socket, + (Err(err), Some(bind_addr)) if err.kind() == io::ErrorKind::AddrNotAvailable => { + // The socket was bound to a local address that is no longer available. + // Retry without binding. + tracing::debug!(connect_addr = %socket_addr, ?bind_addr, "Failed to connect using existing socket because we already have a connection, re-dialing with new port"); + std::mem::drop(socket); + let socket = local_config.create_socket(socket_addr, PortUse::New)?; + match socket.connect(&socket_addr.into()) { + Ok(()) => socket, + Err(err) if err.raw_os_error() == Some(libc::EINPROGRESS) => socket, + Err(err) if err.kind() == io::ErrorKind::WouldBlock => socket, + Err(err) => return Err(err), + } + } + (Err(err), _) => return Err(err), }; let stream = T::new_stream(socket.into()).await?; @@ -496,40 +414,6 @@ where .boxed()) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - self.dial(addr) - } - - /// When port reuse is disabled and hence ephemeral local ports are - /// used for outgoing connections, the returned address is the - /// `observed` address with the port replaced by the port of the - /// `listen` address. - /// - /// If port reuse is enabled, `Some(observed)` is returned, as there - /// is a chance that the `observed` address _and_ port are reachable - /// for other peers if there is a NAT in the way that does endpoint- - /// independent filtering. Furthermore, even if that is not the case - /// and TCP hole punching techniques must be used for NAT traversal, - /// the `observed` address is still the one that a remote should connect - /// to for the purpose of the hole punching procedure, as it represents - /// the mapped IP and port of the NAT device in front of the local - /// node. - /// - /// `None` is returned if one of the given addresses is not a TCP/IP - /// address. - fn address_translation(&self, listen: &Multiaddr, observed: &Multiaddr) -> Option { - if !is_tcp_addr(listen) || !is_tcp_addr(observed) { - return None; - } - match &self.port_reuse { - PortReuse::Disabled => address_translation(listen, observed), - PortReuse::Enabled { .. } => Some(observed.clone()), - } - } - /// Poll all listeners. #[tracing::instrument(level = "trace", name = "Transport::poll", skip(self, cx))] fn poll( @@ -819,23 +703,6 @@ fn ip_to_multiaddr(ip: IpAddr, port: u16) -> Multiaddr { Multiaddr::empty().with(ip.into()).with(Protocol::Tcp(port)) } -fn is_tcp_addr(addr: &Multiaddr) -> bool { - use Protocol::*; - - let mut iter = addr.iter(); - - let first = match iter.next() { - None => return false, - Some(p) => p, - }; - let second = match iter.next() { - None => return false, - Some(p) => p, - }; - - matches!(first, Ip4(_) | Ip6(_) | Dns(_) | Dns4(_) | Dns6(_)) && matches!(second, Tcp(_)) -} - #[cfg(test)] mod tests { use super::*; @@ -843,8 +710,8 @@ mod tests { channel::{mpsc, oneshot}, future::poll_fn, }; + use libp2p_core::Endpoint; use libp2p_core::Transport as _; - use libp2p_identity::PeerId; #[test] fn multiaddr_to_tcp_conversion() { @@ -927,7 +794,17 @@ mod tests { let mut tcp = Transport::::default(); // Obtain a future socket through dialing - let mut socket = tcp.dial(addr.clone()).unwrap().await.unwrap(); + let mut socket = tcp + .dial( + addr.clone(), + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap() + .await + .unwrap(); socket.write_all(&[0x1, 0x2, 0x3]).await.unwrap(); let mut buf = [0u8; 3]; @@ -1003,7 +880,16 @@ mod tests { async fn dialer(mut ready_rx: mpsc::Receiver) { let dest_addr = ready_rx.next().await.unwrap(); let mut tcp = Transport::::default(); - tcp.dial(dest_addr).unwrap().await.unwrap(); + tcp.dial( + dest_addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::New, + }, + ) + .unwrap() + .await + .unwrap(); } fn test(addr: Multiaddr) { @@ -1083,7 +969,7 @@ mod tests { port_reuse_tx: oneshot::Sender>, ) { let dest_addr = ready_rx.next().await.unwrap(); - let mut tcp = Transport::::new(Config::new().port_reuse(true)); + let mut tcp = Transport::::new(Config::new()); tcp.listen_on(ListenerId::next(), addr).unwrap(); match poll_fn(|cx| Pin::new(&mut tcp).poll(cx)).await { TransportEvent::NewAddress { .. } => { @@ -1102,7 +988,17 @@ mod tests { .ok(); // Obtain a future socket through dialing - let mut socket = tcp.dial(dest_addr).unwrap().await.unwrap(); + let mut socket = tcp + .dial( + dest_addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap() + .await + .unwrap(); socket.write_all(&[0x1, 0x2, 0x3]).await.unwrap(); // socket.flush().await; let mut buf = [0u8; 3]; @@ -1153,7 +1049,7 @@ mod tests { .try_init(); async fn listen_twice(addr: Multiaddr) { - let mut tcp = Transport::::new(Config::new().port_reuse(true)); + let mut tcp = Transport::::new(Config::new()); tcp.listen_on(ListenerId::next(), addr).unwrap(); match poll_fn(|cx| Pin::new(&mut tcp).poll(cx)).await { TransportEvent::NewAddress { @@ -1262,55 +1158,6 @@ mod tests { test("/ip4/127.0.0.1/tcp/12345/tcp/12345".parse().unwrap()); } - #[cfg(feature = "async-io")] - #[test] - fn test_address_translation_async_io() { - test_address_translation::() - } - - #[cfg(feature = "tokio")] - #[test] - fn test_address_translation_tokio() { - test_address_translation::() - } - - fn test_address_translation() - where - T: Default + libp2p_core::Transport, - { - let transport = T::default(); - - let port = 42; - let tcp_listen_addr = Multiaddr::empty() - .with(Protocol::Ip4(Ipv4Addr::new(127, 0, 0, 1))) - .with(Protocol::Tcp(port)); - let observed_ip = Ipv4Addr::new(123, 45, 67, 8); - let tcp_observed_addr = Multiaddr::empty() - .with(Protocol::Ip4(observed_ip)) - .with(Protocol::Tcp(1)) - .with(Protocol::P2p(PeerId::random())); - - let translated = transport - .address_translation(&tcp_listen_addr, &tcp_observed_addr) - .unwrap(); - let mut iter = translated.iter(); - assert_eq!(iter.next(), Some(Protocol::Ip4(observed_ip))); - assert_eq!(iter.next(), Some(Protocol::Tcp(port))); - assert_eq!(iter.next(), None); - - let quic_addr = Multiaddr::empty() - .with(Protocol::Ip4(Ipv4Addr::new(87, 65, 43, 21))) - .with(Protocol::Udp(1)) - .with(Protocol::QuicV1); - - assert!(transport - .address_translation(&tcp_listen_addr, &quic_addr) - .is_none()); - assert!(transport - .address_translation(&quic_addr, &tcp_observed_addr) - .is_none()); - } - #[test] fn test_remove_listener() { let _ = tracing_subscriber::fmt() @@ -1373,7 +1220,7 @@ mod tests { .build() .unwrap(); rt.block_on(async { - test::(); + test::(); }); } } diff --git a/transports/uds/CHANGELOG.md b/transports/uds/CHANGELOG.md index aad61d21547..aa068fe3877 100644 --- a/transports/uds/CHANGELOG.md +++ b/transports/uds/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.41.0 + +- Implement refactored `Transport`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) + ## 0.40.0 diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index 13642a38a48..df5159f3c02 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-uds" edition = "2021" rust-version = { workspace = true } description = "Unix domain sockets transport for libp2p" -version = "0.40.0" +version = "0.41.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/uds/src/lib.rs b/transports/uds/src/lib.rs index 4b1c7a1670d..5c57e255b4d 100644 --- a/transports/uds/src/lib.rs +++ b/transports/uds/src/lib.rs @@ -46,7 +46,7 @@ use futures::{ use libp2p_core::transport::ListenerId; use libp2p_core::{ multiaddr::{Multiaddr, Protocol}, - transport::{TransportError, TransportEvent}, + transport::{DialOpts, TransportError, TransportEvent}, Transport, }; use std::collections::VecDeque; @@ -159,7 +159,7 @@ macro_rules! codegen { } } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial(&mut self, addr: Multiaddr, _dial_opts: DialOpts) -> Result> { // TODO: Should we dial at all? if let Ok(path) = multiaddr_to_path(&addr) { tracing::debug!(address=%addr, "Dialing address"); @@ -169,21 +169,6 @@ macro_rules! codegen { } } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - self.dial(addr) - } - - fn address_translation( - &self, - _server: &Multiaddr, - _observed: &Multiaddr, - ) -> Option { - None - } - fn poll( mut self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -260,8 +245,8 @@ mod tests { use futures::{channel::oneshot, prelude::*}; use libp2p_core::{ multiaddr::{Multiaddr, Protocol}, - transport::ListenerId, - Transport, + transport::{DialOpts, ListenerId, PortUse}, + Endpoint, Transport, }; use std::{borrow::Cow, path::Path}; @@ -318,7 +303,17 @@ mod tests { async_std::task::block_on(async move { let mut uds = UdsConfig::new(); let addr = rx.await.unwrap(); - let mut socket = uds.dial(addr).unwrap().await.unwrap(); + let mut socket = uds + .dial( + addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap() + .await + .unwrap(); let _ = socket.write(&[1, 2, 3]).await.unwrap(); }); } diff --git a/transports/webrtc-websys/CHANGELOG.md b/transports/webrtc-websys/CHANGELOG.md index 634120c53c3..475b13727e6 100644 --- a/transports/webrtc-websys/CHANGELOG.md +++ b/transports/webrtc-websys/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.0-alpha + +- Implement refactored `Transport`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) + ## 0.3.0-alpha - Bump version in order to publish a new version dependent on latest `libp2p-core`. diff --git a/transports/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index 4a8b8dfcdf0..c874b33bfc7 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" name = "libp2p-webrtc-websys" repository = "https://github.com/libp2p/rust-libp2p" rust-version = { workspace = true } -version = "0.3.0-alpha" +version = "0.4.0-alpha" publish = true [dependencies] diff --git a/transports/webrtc-websys/src/transport.rs b/transports/webrtc-websys/src/transport.rs index ecf137eab8a..836acb0b9f6 100644 --- a/transports/webrtc-websys/src/transport.rs +++ b/transports/webrtc-websys/src/transport.rs @@ -4,6 +4,7 @@ use super::Error; use futures::future::FutureExt; use libp2p_core::multiaddr::Multiaddr; use libp2p_core::muxing::StreamMuxerBox; +use libp2p_core::transport::DialOpts; use libp2p_core::transport::{Boxed, ListenerId, Transport as _, TransportError, TransportEvent}; use libp2p_identity::{Keypair, PeerId}; use std::future::Future; @@ -62,7 +63,15 @@ impl libp2p_core::Transport for Transport { false } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + dial_opts: DialOpts, + ) -> Result> { + if dial_opts.role.is_listener() { + return Err(TransportError::MultiaddrNotSupported(addr)); + } + if maybe_local_firefox() { return Err(TransportError::Other( "Firefox does not support WebRTC over localhost or 127.0.0.1" @@ -89,23 +98,12 @@ impl libp2p_core::Transport for Transport { .boxed()) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - Err(TransportError::MultiaddrNotSupported(addr)) - } - fn poll( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll> { Poll::Pending } - - fn address_translation(&self, _listen: &Multiaddr, _observed: &Multiaddr) -> Option { - None - } } /// Checks if local Firefox. diff --git a/transports/webrtc/CHANGELOG.md b/transports/webrtc/CHANGELOG.md index 930526d58d5..90d4ce83df3 100644 --- a/transports/webrtc/CHANGELOG.md +++ b/transports/webrtc/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.8.0-alpha + +- Implement refactored `Transport`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) + ## 0.7.1-alpha - Bump `libp2p-webrtc-utils` dependency to `0.2.0`. diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index 4fb4a2f8a45..a205810e7c4 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-webrtc" -version = "0.7.1-alpha" +version = "0.8.0-alpha" authors = ["Parity Technologies "] description = "WebRTC transport for libp2p" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/webrtc/src/tokio/transport.rs b/transports/webrtc/src/tokio/transport.rs index 2e73ac9c459..62049c8f59b 100644 --- a/transports/webrtc/src/tokio/transport.rs +++ b/transports/webrtc/src/tokio/transport.rs @@ -22,7 +22,7 @@ use futures::{future::BoxFuture, prelude::*, stream::SelectAll}; use if_watch::{tokio::IfWatcher, IfEvent}; use libp2p_core::{ multiaddr::{Multiaddr, Protocol}, - transport::{ListenerId, TransportError, TransportEvent}, + transport::{DialOpts, ListenerId, TransportError, TransportEvent}, }; use libp2p_identity as identity; use libp2p_identity::PeerId; @@ -118,7 +118,19 @@ impl libp2p_core::Transport for Transport { } } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + dial_opts: DialOpts, + ) -> Result> { + if dial_opts.role.is_listener() { + // TODO: As the listener of a WebRTC hole punch, we need to send a random UDP packet to the + // `addr`. See DCUtR specification below. + // + // https://github.com/libp2p/specs/blob/master/relay/DCUtR.md#the-protocol + tracing::warn!("WebRTC hole punch is not yet supported"); + } + let (sock_addr, server_fingerprint) = libp2p_webrtc_utils::parse_webrtc_dial_addr(&addr) .ok_or_else(|| TransportError::MultiaddrNotSupported(addr.clone()))?; if sock_addr.port() == 0 || sock_addr.ip().is_unspecified() { @@ -150,21 +162,6 @@ impl libp2p_core::Transport for Transport { } .boxed()) } - - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - // TODO: As the listener of a WebRTC hole punch, we need to send a random UDP packet to the - // `addr`. See DCUtR specification below. - // - // https://github.com/libp2p/specs/blob/master/relay/DCUtR.md#the-protocol - self.dial(addr) - } - - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - libp2p_core::address_translation(server, observed) - } } /// A stream of incoming connections on one or more interfaces. diff --git a/transports/webrtc/tests/smoke.rs b/transports/webrtc/tests/smoke.rs index 76e168edfd6..d606d66c41f 100644 --- a/transports/webrtc/tests/smoke.rs +++ b/transports/webrtc/tests/smoke.rs @@ -23,8 +23,8 @@ use futures::future::{BoxFuture, Either}; use futures::stream::StreamExt; use futures::{future, ready, AsyncReadExt, AsyncWriteExt, FutureExt, SinkExt}; use libp2p_core::muxing::{StreamMuxerBox, StreamMuxerExt}; -use libp2p_core::transport::{Boxed, ListenerId, TransportEvent}; -use libp2p_core::{Multiaddr, Transport}; +use libp2p_core::transport::{Boxed, DialOpts, ListenerId, PortUse, TransportEvent}; +use libp2p_core::{Endpoint, Multiaddr, Transport}; use libp2p_identity::PeerId; use libp2p_webrtc as webrtc; use rand::{thread_rng, RngCore}; @@ -322,7 +322,17 @@ struct Dial<'a> { impl<'a> Dial<'a> { fn new(dialer: &'a mut Boxed<(PeerId, StreamMuxerBox)>, addr: Multiaddr) -> Self { Self { - dial_task: dialer.dial(addr).unwrap().map(|r| r.unwrap()).boxed(), + dial_task: dialer + .dial( + addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap() + .map(|r| r.unwrap()) + .boxed(), dialer, } } diff --git a/transports/websocket-websys/CHANGELOG.md b/transports/websocket-websys/CHANGELOG.md index c16ad6cc406..70d866e6141 100644 --- a/transports/websocket-websys/CHANGELOG.md +++ b/transports/websocket-websys/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.0 + +- Implement refactored `Transport`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) ## 0.3.3 - Fix use-after-free handler invocation from JS side. diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index a2127986ddc..0b3148a8b92 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-websocket-websys" edition = "2021" rust-version = "1.60.0" description = "WebSocket for libp2p under WASM environment" -version = "0.3.3" +version = "0.4.0" authors = ["Vince Vasta "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/websocket-websys/src/lib.rs b/transports/websocket-websys/src/lib.rs index c96d1d6aa3a..d2589715bbb 100644 --- a/transports/websocket-websys/src/lib.rs +++ b/transports/websocket-websys/src/lib.rs @@ -26,6 +26,7 @@ use bytes::BytesMut; use futures::task::AtomicWaker; use futures::{future::Ready, io, prelude::*}; use js_sys::Array; +use libp2p_core::transport::DialOpts; use libp2p_core::{ multiaddr::{Multiaddr, Protocol}, transport::{ListenerId, TransportError, TransportEvent}, @@ -86,7 +87,15 @@ impl libp2p_core::Transport for Transport { false } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + dial_opts: DialOpts, + ) -> Result> { + if dial_opts.role.is_listener() { + return Err(TransportError::MultiaddrNotSupported(addr)); + } + let url = extract_websocket_url(&addr) .ok_or_else(|| TransportError::MultiaddrNotSupported(addr))?; @@ -101,23 +110,12 @@ impl libp2p_core::Transport for Transport { .boxed()) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - Err(TransportError::MultiaddrNotSupported(addr)) - } - fn poll( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> std::task::Poll> { Poll::Pending } - - fn address_translation(&self, _listen: &Multiaddr, _observed: &Multiaddr) -> Option { - None - } } // Try to convert Multiaddr to a Websocket url. diff --git a/transports/websocket/CHANGELOG.md b/transports/websocket/CHANGELOG.md index 419ff41c6fc..50b1c42d3e1 100644 --- a/transports/websocket/CHANGELOG.md +++ b/transports/websocket/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.44.0 + +- Implement refactored `Transport`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) ## 0.43.2 - fix: Avoid websocket panic on polling after errors. See [PR 5482]. diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index f1b0a413115..271631b4021 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-websocket" edition = "2021" rust-version = { workspace = true } description = "WebSocket transport for libp2p" -version = "0.43.2" +version = "0.44.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index 69a01fdbd46..fc6a3f0e90e 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -23,9 +23,8 @@ use either::Either; use futures::{future::BoxFuture, prelude::*, ready, stream::BoxStream}; use futures_rustls::{client, rustls, server}; use libp2p_core::{ - connection::Endpoint, multiaddr::{Multiaddr, Protocol}, - transport::{ListenerId, TransportError, TransportEvent}, + transport::{DialOpts, ListenerId, TransportError, TransportEvent}, Transport, }; use parking_lot::Mutex; @@ -149,19 +148,12 @@ where self.transport.lock().remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - self.do_dial(addr, Endpoint::Dialer) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + dial_opts: DialOpts, ) -> Result> { - self.do_dial(addr, Endpoint::Listener) - } - - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.transport.lock().address_translation(server, observed) + self.do_dial(addr, dial_opts) } fn poll( @@ -263,7 +255,7 @@ where fn do_dial( &mut self, addr: Multiaddr, - role_override: Endpoint, + dial_opts: DialOpts, ) -> Result<::Dial, TransportError<::Error>> { let mut addr = match parse_ws_dial_addr(addr) { Ok(addr) => addr, @@ -282,8 +274,7 @@ where let future = async move { loop { - match Self::dial_once(transport.clone(), addr, tls_config.clone(), role_override) - .await + match Self::dial_once(transport.clone(), addr, tls_config.clone(), dial_opts).await { Ok(Either::Left(redirect)) => { if remaining_redirects == 0 { @@ -307,18 +298,17 @@ where transport: Arc>, addr: WsAddress, tls_config: tls::Config, - role_override: Endpoint, + dial_opts: DialOpts, ) -> Result>, Error> { tracing::trace!(address=?addr, "Dialing websocket address"); - let dial = match role_override { - Endpoint::Dialer => transport.lock().dial(addr.tcp_addr), - Endpoint::Listener => transport.lock().dial_as_listener(addr.tcp_addr), - } - .map_err(|e| match e { - TransportError::MultiaddrNotSupported(a) => Error::InvalidMultiaddr(a), - TransportError::Other(e) => Error::Transport(e), - })?; + let dial = transport + .lock() + .dial(addr.tcp_addr, dial_opts) + .map_err(|e| match e { + TransportError::MultiaddrNotSupported(a) => Error::InvalidMultiaddr(a), + TransportError::Other(e) => Error::Transport(e), + })?; let stream = dial.map_err(Error::Transport).await?; tracing::trace!(port=%addr.host_port, "TCP connection established"); diff --git a/transports/websocket/src/lib.rs b/transports/websocket/src/lib.rs index e0b3d09ca25..40d6db44471 100644 --- a/transports/websocket/src/lib.rs +++ b/transports/websocket/src/lib.rs @@ -33,7 +33,7 @@ use futures::{future::BoxFuture, prelude::*, ready}; use libp2p_core::{ connection::ConnectedPoint, multiaddr::Multiaddr, - transport::{map::MapFuture, ListenerId, TransportError, TransportEvent}, + transport::{map::MapFuture, DialOpts, ListenerId, TransportError, TransportEvent}, Transport, }; use rw_stream_sink::RwStreamSink; @@ -202,19 +202,12 @@ where self.transport.remove_listener(id) } - fn dial(&mut self, addr: Multiaddr) -> Result> { - self.transport.dial(addr) - } - - fn dial_as_listener( + fn dial( &mut self, addr: Multiaddr, + opts: DialOpts, ) -> Result> { - self.transport.dial_as_listener(addr) - } - - fn address_translation(&self, server: &Multiaddr, observed: &Multiaddr) -> Option { - self.transport.address_translation(server, observed) + self.transport.dial(addr, opts) } fn poll( @@ -292,7 +285,11 @@ where mod tests { use super::WsConfig; use futures::prelude::*; - use libp2p_core::{multiaddr::Protocol, transport::ListenerId, Multiaddr, Transport}; + use libp2p_core::{ + multiaddr::Protocol, + transport::{DialOpts, ListenerId, PortUse}, + Endpoint, Multiaddr, Transport, + }; use libp2p_identity::PeerId; use libp2p_tcp as tcp; @@ -339,7 +336,13 @@ mod tests { let outbound = new_ws_config() .boxed() - .dial(addr.with(Protocol::P2p(PeerId::random()))) + .dial( + addr.with(Protocol::P2p(PeerId::random())), + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::New, + }, + ) .unwrap(); let (a, b) = futures::join!(inbound, outbound); diff --git a/transports/webtransport-websys/CHANGELOG.md b/transports/webtransport-websys/CHANGELOG.md index 0409819a63f..2aab226ab12 100644 --- a/transports/webtransport-websys/CHANGELOG.md +++ b/transports/webtransport-websys/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.0 + +- Implement refactored `Transport`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) + ## 0.3.0 * Fix unhandled exceptions thrown when calling `Webtransport::close`. diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index 3defdce5203..68ba7091794 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-webtransport-websys" edition = "2021" rust-version = { workspace = true } description = "WebTransport for libp2p under WASM environment" -version = "0.3.0" +version = "0.4.0" authors = [ "Yiannis Marangos ", "oblique ", diff --git a/transports/webtransport-websys/src/transport.rs b/transports/webtransport-websys/src/transport.rs index 3f14f3e476b..6a9a9dad954 100644 --- a/transports/webtransport-websys/src/transport.rs +++ b/transports/webtransport-websys/src/transport.rs @@ -1,6 +1,8 @@ use futures::future::FutureExt; use libp2p_core::muxing::StreamMuxerBox; -use libp2p_core::transport::{Boxed, ListenerId, Transport as _, TransportError, TransportEvent}; +use libp2p_core::transport::{ + Boxed, DialOpts, ListenerId, Transport as _, TransportError, TransportEvent, +}; use libp2p_identity::{Keypair, PeerId}; use multiaddr::Multiaddr; use std::future::Future; @@ -62,7 +64,15 @@ impl libp2p_core::Transport for Transport { false } - fn dial(&mut self, addr: Multiaddr) -> Result> { + fn dial( + &mut self, + addr: Multiaddr, + dial_opts: DialOpts, + ) -> Result> { + if dial_opts.role.is_listener() { + return Err(TransportError::MultiaddrNotSupported(addr)); + } + let endpoint = Endpoint::from_multiaddr(&addr).map_err(|e| match e { e @ Error::InvalidMultiaddr(_) => { tracing::debug!("{}", e); @@ -83,21 +93,10 @@ impl libp2p_core::Transport for Transport { .boxed()) } - fn dial_as_listener( - &mut self, - addr: Multiaddr, - ) -> Result> { - Err(TransportError::MultiaddrNotSupported(addr)) - } - fn poll( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll> { Poll::Pending } - - fn address_translation(&self, _listen: &Multiaddr, _observed: &Multiaddr) -> Option { - None - } } diff --git a/wasm-tests/webtransport-tests/src/lib.rs b/wasm-tests/webtransport-tests/src/lib.rs index 1f420cd6671..938cdf0b3e1 100644 --- a/wasm-tests/webtransport-tests/src/lib.rs +++ b/wasm-tests/webtransport-tests/src/lib.rs @@ -1,7 +1,8 @@ use futures::channel::oneshot; use futures::{AsyncReadExt, AsyncWriteExt}; use getrandom::getrandom; -use libp2p_core::{StreamMuxer, Transport as _}; +use libp2p_core::transport::{DialOpts, PortUse}; +use libp2p_core::{Endpoint, StreamMuxer, Transport as _}; use libp2p_identity::{Keypair, PeerId}; use libp2p_noise as noise; use libp2p_webtransport_websys::{Config, Connection, Error, Stream, Transport}; @@ -263,7 +264,17 @@ async fn connect_without_peer_id() { addr.pop(); let mut transport = Transport::new(Config::new(&keypair)); - transport.dial(addr).unwrap().await.unwrap(); + transport + .dial( + addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap() + .await + .unwrap(); } #[wasm_bindgen_test] @@ -278,7 +289,17 @@ async fn error_on_unknown_peer_id() { addr.push(Protocol::P2p(PeerId::random())); let mut transport = Transport::new(Config::new(&keypair)); - let e = transport.dial(addr.clone()).unwrap().await.unwrap_err(); + let e = transport + .dial( + addr.clone(), + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap() + .await + .unwrap_err(); assert!(matches!(e, Error::UnknownRemotePeerId)); } @@ -297,7 +318,17 @@ async fn error_on_unknown_certhash() { addr.push(peer_id); let mut transport = Transport::new(Config::new(&keypair)); - let e = transport.dial(addr.clone()).unwrap().await.unwrap_err(); + let e = transport + .dial( + addr.clone(), + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap() + .await + .unwrap_err(); assert!(matches!( e, Error::Noise(noise::Error::UnknownWebTransportCerthashes(..)) @@ -310,7 +341,17 @@ async fn new_connection_to_echo_server() -> Connection { let mut transport = Transport::new(Config::new(&keypair)); - let (_peer_id, conn) = transport.dial(addr).unwrap().await.unwrap(); + let (_peer_id, conn) = transport + .dial( + addr, + DialOpts { + role: Endpoint::Dialer, + port_use: PortUse::Reuse, + }, + ) + .unwrap() + .await + .unwrap(); conn } From 4de8b839855d2452a09c7a8936c8575e79ebd12a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 10:12:12 +0000 Subject: [PATCH 200/246] deps: bump EmbarkStudios/cargo-deny-action from 1 to 2 Pull-Request: #5530. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 648945820fa..d0465540d47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -398,6 +398,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v1 + - uses: EmbarkStudios/cargo-deny-action@v2 with: command: check advisories bans licenses sources From 732ade698303a8346c44d8638143ca502458b670 Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Mon, 5 Aug 2024 17:47:39 +0200 Subject: [PATCH 201/246] chore: remove RUSTFLAG from docs workflow `"--cfg docsrs"` shouldn't be part of `RUSTFLAGS` but only of `RUSTDOCFLAGS`. This should fix failing docs Actions. Pull-Request: #5517. --- .github/workflows/docs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b2a761fd8c1..e2bac78c006 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,7 +17,6 @@ jobs: run: cargo +nightly doc --no-deps --workspace -F full env: RUSTDOCFLAGS: "--cfg docsrs" - RUSTFLAGS: "--cfg docsrs" - name: Add index file run: | mkdir host-docs From 823acd6f6991b1b6b0f6d09959d89599d6abc730 Mon Sep 17 00:00:00 2001 From: Hannes <55623006+umgefahren@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:14:49 +0200 Subject: [PATCH 202/246] docs: As implied by #5517 make sure everything still builds on docs.rs As @guillaumemichel already found out, passing the `docsrs` cfg to rustc now breaks the documentation build. Although I couldn't exactly reproduce the docs.rs build env (everyone is welcome to try; it's explained [here](https://github.com/rust-lang/docs.rs/blob/master/README.md#build-subcommand)) it's safe to assume that the same problem will occur when we push to docs.rs. Passing the docsrs flag is also no longer required since it's now automatically passed to rustdoc when building on docs.rs. Explanation: https://docs.rs/about/builds#detecting-docsrs Pull-Request: #5535. --- core/Cargo.toml | 2 -- identity/Cargo.toml | 2 -- libp2p/Cargo.toml | 2 -- misc/metrics/Cargo.toml | 2 -- misc/multistream-select/Cargo.toml | 2 -- misc/quick-protobuf-codec/Cargo.toml | 2 -- misc/rw-stream-sink/Cargo.toml | 2 -- muxers/mplex/Cargo.toml | 2 -- muxers/yamux/Cargo.toml | 2 -- protocols/autonat/Cargo.toml | 2 -- protocols/dcutr/Cargo.toml | 2 -- protocols/floodsub/Cargo.toml | 2 -- protocols/gossipsub/Cargo.toml | 2 -- protocols/identify/Cargo.toml | 2 -- protocols/kad/Cargo.toml | 2 -- protocols/mdns/Cargo.toml | 2 -- protocols/perf/Cargo.toml | 2 -- protocols/ping/Cargo.toml | 2 -- protocols/relay/Cargo.toml | 2 -- protocols/rendezvous/Cargo.toml | 2 -- protocols/request-response/Cargo.toml | 2 -- protocols/upnp/Cargo.toml | 2 -- swarm-derive/Cargo.toml | 2 -- swarm/Cargo.toml | 2 -- transports/dns/Cargo.toml | 2 -- transports/noise/Cargo.toml | 2 -- transports/plaintext/Cargo.toml | 2 -- transports/pnet/Cargo.toml | 2 -- transports/quic/Cargo.toml | 2 -- transports/tcp/Cargo.toml | 2 -- transports/tls/Cargo.toml | 2 -- transports/uds/Cargo.toml | 2 -- transports/webrtc/Cargo.toml | 2 -- transports/websocket-websys/Cargo.toml | 2 -- transports/websocket/Cargo.toml | 2 -- transports/webtransport-websys/Cargo.toml | 2 -- 36 files changed, 72 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 3f9bd540f23..8a083276e7f 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -48,8 +48,6 @@ serde = ["multihash/serde-codec", "dep:serde", "libp2p-identity/serde"] # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/identity/Cargo.toml b/identity/Cargo.toml index ea49a1adbb4..cb0b8cb000e 100644 --- a/identity/Cargo.toml +++ b/identity/Cargo.toml @@ -56,8 +56,6 @@ harness = false # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index 59a075b777e..68a76e52b58 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -150,8 +150,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index 5fb927bee84..b75ea5ed0de 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -40,8 +40,6 @@ libp2p-identity = { workspace = true, features = ["rand"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/misc/multistream-select/Cargo.toml b/misc/multistream-select/Cargo.toml index 77d8de54332..1bbe3642477 100644 --- a/misc/multistream-select/Cargo.toml +++ b/misc/multistream-select/Cargo.toml @@ -30,8 +30,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/misc/quick-protobuf-codec/Cargo.toml b/misc/quick-protobuf-codec/Cargo.toml index a98ffa5308f..985479059a2 100644 --- a/misc/quick-protobuf-codec/Cargo.toml +++ b/misc/quick-protobuf-codec/Cargo.toml @@ -30,8 +30,6 @@ harness = false # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/misc/rw-stream-sink/Cargo.toml b/misc/rw-stream-sink/Cargo.toml index 557163c438a..20fa2fa23fa 100644 --- a/misc/rw-stream-sink/Cargo.toml +++ b/misc/rw-stream-sink/Cargo.toml @@ -22,8 +22,6 @@ async-std = "1.0" # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/muxers/mplex/Cargo.toml b/muxers/mplex/Cargo.toml index fb55e03b614..4fdb4dabedd 100644 --- a/muxers/mplex/Cargo.toml +++ b/muxers/mplex/Cargo.toml @@ -42,8 +42,6 @@ harness = false # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/muxers/yamux/Cargo.toml b/muxers/yamux/Cargo.toml index f56cd485b9b..289f84fe1dd 100644 --- a/muxers/yamux/Cargo.toml +++ b/muxers/yamux/Cargo.toml @@ -27,8 +27,6 @@ libp2p-muxer-test-harness = { path = "../test-harness" } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index f047cb7d5ba..7e31a7f3895 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -34,8 +34,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/dcutr/Cargo.toml b/protocols/dcutr/Cargo.toml index cd46840caf3..6b1d04f82f5 100644 --- a/protocols/dcutr/Cargo.toml +++ b/protocols/dcutr/Cargo.toml @@ -47,8 +47,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 9f0557c6d01..18d77e99e9c 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -30,8 +30,6 @@ tracing = { workspace = true } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index f989e997bfb..4cb590bed0c 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -55,8 +55,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 320c8465650..cdc5ce587de 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -37,8 +37,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 494d812c6ec..72b29d00ef7 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -52,8 +52,6 @@ serde = ["dep:serde", "bytes/serde"] # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 0c8229465d6..19ae5ce9f36 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -54,8 +54,6 @@ required-features = ["tokio"] # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index abe58088caa..398bdce65ec 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -42,8 +42,6 @@ libp2p-swarm-test = { path = "../../swarm-test" } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/ping/Cargo.toml b/protocols/ping/Cargo.toml index 2c347adb2c4..66775d3ba8d 100644 --- a/protocols/ping/Cargo.toml +++ b/protocols/ping/Cargo.toml @@ -33,8 +33,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 1a0e7836158..084fec07efd 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -44,8 +44,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/rendezvous/Cargo.toml b/protocols/rendezvous/Cargo.toml index 32b233813e3..78a6a1a0a4c 100644 --- a/protocols/rendezvous/Cargo.toml +++ b/protocols/rendezvous/Cargo.toml @@ -44,8 +44,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index af70fd9a83e..c6b2eda348b 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -47,8 +47,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index 50ed9db0f6f..e9c7414236d 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -30,5 +30,3 @@ workspace = true # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index d4b596a12cf..b31ea188962 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -23,8 +23,6 @@ proc-macro2 = "1.0" # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 1e2842998a3..375f51490a8 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -67,8 +67,6 @@ required-features = ["macros"] # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [[bench]] name = "connection_handler" diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index b728509364a..707b67fc935 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -35,8 +35,6 @@ tokio = ["hickory-resolver/tokio-runtime"] # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 7333d4cddda..76cf9475cc4 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -43,8 +43,6 @@ libp2p-identity = { workspace = true, features = ["rand"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/transports/plaintext/Cargo.toml b/transports/plaintext/Cargo.toml index db6fe75b505..4f07c5fee6e 100644 --- a/transports/plaintext/Cargo.toml +++ b/transports/plaintext/Cargo.toml @@ -31,8 +31,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index 76964ce3152..e7b3bfc30ac 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -33,8 +33,6 @@ tokio = { workspace = true, features = ["full"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index d2d8c6fc2b0..1f540c9542a 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -35,8 +35,6 @@ async-std = ["dep:async-std", "if-watch/smol", "quinn/runtime-async-std"] # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [dev-dependencies] async-std = { version = "1.12.0", features = ["attributes"] } diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index b17d7f3b58e..03e7fac491c 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -37,8 +37,6 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index c4b30951e66..41b4c215dd9 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -40,8 +40,6 @@ tokio = { workspace = true, features = ["full"] } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index df5159f3c02..f70ac388fa8 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -24,8 +24,6 @@ tempfile = "3.10" # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/transports/webrtc/Cargo.toml b/transports/webrtc/Cargo.toml index a205810e7c4..fc2748d93c3 100644 --- a/transports/webrtc/Cargo.toml +++ b/transports/webrtc/Cargo.toml @@ -55,5 +55,3 @@ workspace = true # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] diff --git a/transports/websocket-websys/Cargo.toml b/transports/websocket-websys/Cargo.toml index 0b3148a8b92..32483f28c57 100644 --- a/transports/websocket-websys/Cargo.toml +++ b/transports/websocket-websys/Cargo.toml @@ -26,8 +26,6 @@ web-sys = { version = "0.3.69", features = ["BinaryType", "CloseEvent", "Message # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [dev-dependencies] libp2p-yamux = { workspace = true } diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 271631b4021..e08346da5ca 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -36,8 +36,6 @@ rcgen = { workspace = true } # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index 68ba7091794..370158190b1 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -44,8 +44,6 @@ multibase = "0.9.1" # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] -rustc-args = ["--cfg", "docsrs"] [lints] workspace = true From 98da34a7dc216b5e022ff5400356c73a23dfac96 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Wed, 7 Aug 2024 12:19:54 +0300 Subject: [PATCH 203/246] feat(websocket): Allow wss connections on IP addresses Pull-Request: #5525. --- transports/websocket/CHANGELOG.md | 3 + transports/websocket/src/framed.rs | 141 +++++++++++++++++++++++++---- 2 files changed, 124 insertions(+), 20 deletions(-) diff --git a/transports/websocket/CHANGELOG.md b/transports/websocket/CHANGELOG.md index 50b1c42d3e1..df51e2c807d 100644 --- a/transports/websocket/CHANGELOG.md +++ b/transports/websocket/CHANGELOG.md @@ -2,6 +2,9 @@ - Implement refactored `Transport`. See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) +- Allow wss connections on IP addresses. + See [PR 5525](https://github.com/libp2p/rust-libp2p/pull/5525). + ## 0.43.2 - fix: Avoid websocket panic on polling after errors. See [PR 5482]. diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index fc6a3f0e90e..074271e672f 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -21,7 +21,8 @@ use crate::{error::Error, quicksink, tls}; use either::Either; use futures::{future::BoxFuture, prelude::*, ready, stream::BoxStream}; -use futures_rustls::{client, rustls, server}; +use futures_rustls::rustls::pki_types::ServerName; +use futures_rustls::{client, server}; use libp2p_core::{ multiaddr::{Multiaddr, Protocol}, transport::{DialOpts, ListenerId, TransportError, TransportEvent}, @@ -32,6 +33,7 @@ use soketto::{ connection::{self, CloseReason}, handshake, }; +use std::net::IpAddr; use std::{collections::HashMap, ops::DerefMut, sync::Arc}; use std::{fmt, io, mem, pin::Pin, task::Context, task::Poll}; use url::Url; @@ -315,15 +317,12 @@ where let stream = if addr.use_tls { // begin TLS session - let dns_name = addr - .dns_name - .expect("for use_tls we have checked that dns_name is some"); - tracing::trace!(?dns_name, "Starting TLS handshake"); + tracing::trace!(?addr.server_name, "Starting TLS handshake"); let stream = tls_config .client - .connect(dns_name.clone(), stream) + .connect(addr.server_name.clone(), stream) .map_err(|e| { - tracing::debug!(?dns_name, "TLS handshake failed: {}", e); + tracing::debug!(?addr.server_name, "TLS handshake failed: {}", e); Error::Tls(tls::Error::from(e)) }) .await?; @@ -451,7 +450,7 @@ where struct WsAddress { host_port: String, path: String, - dns_name: Option>, + server_name: ServerName<'static>, use_tls: bool, tcp_addr: Multiaddr, } @@ -468,19 +467,21 @@ fn parse_ws_dial_addr(addr: Multiaddr) -> Result> { let mut protocols = addr.iter(); let mut ip = protocols.next(); let mut tcp = protocols.next(); - let (host_port, dns_name) = loop { + let (host_port, server_name) = loop { match (ip, tcp) { (Some(Protocol::Ip4(ip)), Some(Protocol::Tcp(port))) => { - break (format!("{ip}:{port}"), None) + let server_name = ServerName::IpAddress(IpAddr::V4(ip).into()); + break (format!("{ip}:{port}"), server_name); } (Some(Protocol::Ip6(ip)), Some(Protocol::Tcp(port))) => { - break (format!("{ip}:{port}"), None) + let server_name = ServerName::IpAddress(IpAddr::V6(ip).into()); + break (format!("[{ip}]:{port}"), server_name); } (Some(Protocol::Dns(h)), Some(Protocol::Tcp(port))) | (Some(Protocol::Dns4(h)), Some(Protocol::Tcp(port))) | (Some(Protocol::Dns6(h)), Some(Protocol::Tcp(port))) | (Some(Protocol::Dnsaddr(h)), Some(Protocol::Tcp(port))) => { - break (format!("{}:{}", &h, port), Some(tls::dns_name_ref(&h)?)) + break (format!("{h}:{port}"), tls::dns_name_ref(&h)?) } (Some(_), Some(p)) => { ip = Some(p); @@ -499,13 +500,7 @@ fn parse_ws_dial_addr(addr: Multiaddr) -> Result> { match protocols.pop() { p @ Some(Protocol::P2p(_)) => p2p = p, Some(Protocol::Ws(path)) => break (false, path.into_owned()), - Some(Protocol::Wss(path)) => { - if dns_name.is_none() { - tracing::debug!(address=%addr, "Missing DNS name in WSS address"); - return Err(Error::InvalidMultiaddr(addr)); - } - break (true, path.into_owned()); - } + Some(Protocol::Wss(path)) => break (true, path.into_owned()), _ => return Err(Error::InvalidMultiaddr(addr)), } }; @@ -519,7 +514,7 @@ fn parse_ws_dial_addr(addr: Multiaddr) -> Result> { Ok(WsAddress { host_port, - dns_name, + server_name, path, use_tls, tcp_addr, @@ -757,3 +752,109 @@ where .map_err(|e| io::Error::new(io::ErrorKind::Other, e)) } } + +#[cfg(test)] +mod tests { + use super::*; + use libp2p_identity::PeerId; + use std::io; + + #[test] + fn dial_addr() { + let peer_id = PeerId::random(); + + // Check `/wss` + let addr = "/dns4/example.com/tcp/2222/wss" + .parse::() + .unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "example.com:2222"); + assert_eq!(info.path, "/"); + assert!(info.use_tls); + assert_eq!(info.server_name, "example.com".try_into().unwrap()); + assert_eq!(info.tcp_addr, "/dns4/example.com/tcp/2222".parse().unwrap()); + + // Check `/wss` with `/p2p` + let addr = format!("/dns4/example.com/tcp/2222/wss/p2p/{peer_id}") + .parse() + .unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "example.com:2222"); + assert_eq!(info.path, "/"); + assert!(info.use_tls); + assert_eq!(info.server_name, "example.com".try_into().unwrap()); + assert_eq!( + info.tcp_addr, + format!("/dns4/example.com/tcp/2222/p2p/{peer_id}") + .parse() + .unwrap() + ); + + // Check `/wss` with `/ip4` + let addr = "/ip4/127.0.0.1/tcp/2222/wss".parse::().unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "127.0.0.1:2222"); + assert_eq!(info.path, "/"); + assert!(info.use_tls); + assert_eq!(info.server_name, "127.0.0.1".try_into().unwrap()); + assert_eq!(info.tcp_addr, "/ip4/127.0.0.1/tcp/2222".parse().unwrap()); + + // Check `/wss` with `/ip6` + let addr = "/ip6/::1/tcp/2222/wss".parse::().unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "[::1]:2222"); + assert_eq!(info.path, "/"); + assert!(info.use_tls); + assert_eq!(info.server_name, "::1".try_into().unwrap()); + assert_eq!(info.tcp_addr, "/ip6/::1/tcp/2222".parse().unwrap()); + + // Check `/ws` + let addr = "/dns4/example.com/tcp/2222/ws" + .parse::() + .unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "example.com:2222"); + assert_eq!(info.path, "/"); + assert!(!info.use_tls); + assert_eq!(info.server_name, "example.com".try_into().unwrap()); + assert_eq!(info.tcp_addr, "/dns4/example.com/tcp/2222".parse().unwrap()); + + // Check `/ws` with `/p2p` + let addr = format!("/dns4/example.com/tcp/2222/ws/p2p/{peer_id}") + .parse() + .unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "example.com:2222"); + assert_eq!(info.path, "/"); + assert!(!info.use_tls); + assert_eq!(info.server_name, "example.com".try_into().unwrap()); + assert_eq!( + info.tcp_addr, + format!("/dns4/example.com/tcp/2222/p2p/{peer_id}") + .parse() + .unwrap() + ); + + // Check `/ws` with `/ip4` + let addr = "/ip4/127.0.0.1/tcp/2222/ws".parse::().unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "127.0.0.1:2222"); + assert_eq!(info.path, "/"); + assert!(!info.use_tls); + assert_eq!(info.server_name, "127.0.0.1".try_into().unwrap()); + assert_eq!(info.tcp_addr, "/ip4/127.0.0.1/tcp/2222".parse().unwrap()); + + // Check `/ws` with `/ip6` + let addr = "/ip6/::1/tcp/2222/ws".parse::().unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "[::1]:2222"); + assert_eq!(info.path, "/"); + assert!(!info.use_tls); + assert_eq!(info.server_name, "::1".try_into().unwrap()); + assert_eq!(info.tcp_addr, "/ip6/::1/tcp/2222".parse().unwrap()); + + // Check non-ws address + let addr = "/ip4/127.0.0.1/tcp/2222".parse::().unwrap(); + parse_ws_dial_addr::(addr).unwrap_err(); + } +} From 417968e07cfb79163a541ee2e5871a9bb6fe9534 Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Thu, 8 Aug 2024 14:16:43 +0200 Subject: [PATCH 204/246] feat(kad): configurable bucket size Making bucket size configurable. Currently `K_VALUE` is used by default, and the only way to change the bucket size is to edit the const. Resolves https://github.com/libp2p/rust-libp2p/issues/5389 Pull-Request: #5414. --- protocols/kad/CHANGELOG.md | 8 ++- protocols/kad/src/behaviour.rs | 26 +++++++-- protocols/kad/src/kbucket.rs | 91 +++++++++++++++++++++-------- protocols/kad/src/kbucket/bucket.rs | 78 ++++++++++++++++++------- 4 files changed, 151 insertions(+), 52 deletions(-) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index a5b404ae6bd..cbb5a4decf2 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -3,9 +3,9 @@ - Included multiaddresses of found peers alongside peer IDs in `GetClosestPeers` query results. See [PR 5475](https://github.com/libp2p/rust-libp2p/pull/5475) - Changed `FIND_NODE` response: now includes a list of closest peers when querying the recipient peer ID. Previously, this request yielded an empty response. - See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270) -- Update to DHT republish interval and expiration time defaults to 22h and 48h respectively, rationale in [libp2p/specs#451](https://github.com/libp2p/specs/pull/451) - See [PR 3230](https://github.com/libp2p/rust-libp2p/pull/3230) + See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270). +- Update to DHT republish interval and expiration time defaults to 22h and 48h respectively, rationale in [libp2p/specs#451](https://github.com/libp2p/specs/pull/451). + See [PR 3230](https://github.com/libp2p/rust-libp2p/pull/3230). - Use default dial conditions more consistently. See [PR 4957](https://github.com/libp2p/rust-libp2p/pull/4957) - QueryClose progress whenever closer in range, instead of having to be the closest. @@ -19,6 +19,8 @@ See [PR 5148](https://github.com/libp2p/rust-libp2p/pull/5148). - Derive `Copy` for `kbucket::key::Key`. See [PR 5317](https://github.com/libp2p/rust-libp2p/pull/5317). +⁻ `KBucket` size can now be modified without changing the `K_VALUE`. + See [PR 5414](https://github.com/libp2p/rust-libp2p/pull/5414). - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 8d6f86d7e0f..fc3d8a1adaa 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -24,7 +24,7 @@ mod test; use crate::addresses::Addresses; use crate::handler::{Handler, HandlerEvent, HandlerIn, RequestId}; -use crate::kbucket::{self, Distance, KBucketsTable, NodeStatus}; +use crate::kbucket::{self, Distance, KBucketConfig, KBucketsTable, NodeStatus}; use crate::protocol::{ConnectionType, KadPeer, ProtocolConfig}; use crate::query::{Query, QueryConfig, QueryId, QueryPool, QueryPoolState}; use crate::record::{ @@ -172,7 +172,7 @@ pub enum StoreInserts { /// The configuration is consumed by [`Behaviour::new`]. #[derive(Debug, Clone)] pub struct Config { - kbucket_pending_timeout: Duration, + kbucket_config: KBucketConfig, query_config: QueryConfig, protocol_config: ProtocolConfig, record_ttl: Option, @@ -215,7 +215,7 @@ impl Config { /// Builds a new `Config` with the given protocol name. pub fn new(protocol_name: StreamProtocol) -> Self { Config { - kbucket_pending_timeout: Duration::from_secs(60), + kbucket_config: KBucketConfig::default(), query_config: QueryConfig::default(), protocol_config: ProtocolConfig::new(protocol_name), record_ttl: Some(Duration::from_secs(48 * 60 * 60)), @@ -424,6 +424,24 @@ impl Config { self } + /// Sets the configuration for the k-buckets. + /// + /// * Default to K_VALUE. + pub fn set_kbucket_size(&mut self, size: NonZeroUsize) -> &mut Self { + self.kbucket_config.set_bucket_size(size); + self + } + + /// Sets the timeout duration after creation of a pending entry after which + /// it becomes eligible for insertion into a full bucket, replacing the + /// least-recently (dis)connected node. + /// + /// * Default to `60` s. + pub fn set_kbucket_pending_timeout(&mut self, timeout: Duration) -> &mut Self { + self.kbucket_config.set_pending_timeout(timeout); + self + } + /// Sets the time to wait before calling [`Behaviour::bootstrap`] after a new peer is inserted in the routing table. /// This prevent cascading bootstrap requests when multiple peers are inserted into the routing table "at the same time". /// This also allows to wait a little bit for other potential peers to be inserted into the routing table before @@ -481,7 +499,7 @@ where Behaviour { store, caching: config.caching, - kbuckets: KBucketsTable::new(local_key, config.kbucket_pending_timeout), + kbuckets: KBucketsTable::new(local_key, config.kbucket_config), kbucket_inserts: config.kbucket_inserts, protocol_config: config.protocol_config, record_filtering: config.record_filtering, diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index 7ed10f7f853..28d7df03917 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -75,15 +75,49 @@ mod key; pub use bucket::NodeStatus; pub use entry::*; -use arrayvec::ArrayVec; use bucket::KBucket; use std::collections::VecDeque; +use std::num::NonZeroUsize; use std::time::Duration; use web_time::Instant; /// Maximum number of k-buckets. const NUM_BUCKETS: usize = 256; +/// The configuration for `KBucketsTable`. +#[derive(Debug, Clone, Copy)] +pub(crate) struct KBucketConfig { + /// Maximal number of nodes that a bucket can contain. + bucket_size: usize, + /// 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. + pending_timeout: Duration, +} + +impl Default for KBucketConfig { + fn default() -> Self { + KBucketConfig { + bucket_size: K_VALUE.get(), + pending_timeout: Duration::from_secs(60), + } + } +} + +impl KBucketConfig { + /// Modifies the maximal number of nodes that a bucket can contain. + pub(crate) fn set_bucket_size(&mut self, bucket_size: NonZeroUsize) { + self.bucket_size = bucket_size.get(); + } + + /// Modifies 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(crate) fn set_pending_timeout(&mut self, pending_timeout: Duration) { + self.pending_timeout = pending_timeout; + } +} + /// A `KBucketsTable` represents a Kademlia routing table. #[derive(Debug, Clone)] pub(crate) struct KBucketsTable { @@ -91,6 +125,8 @@ pub(crate) struct KBucketsTable { local_key: TKey, /// The buckets comprising the routing table. buckets: Vec>, + /// The maximal number of nodes that a bucket can contain. + bucket_size: usize, /// The list of evicted entries that have been replaced with pending /// entries since the last call to [`KBucketsTable::take_applied_pending`]. applied_pending: VecDeque>, @@ -151,17 +187,12 @@ where TVal: Clone, { /// Creates a new, empty Kademlia routing table with entries partitioned - /// into buckets as per the Kademlia protocol. - /// - /// 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(crate) fn new(local_key: TKey, pending_timeout: Duration) -> Self { + /// into buckets as per the Kademlia protocol using the provided config. + pub(crate) fn new(local_key: TKey, config: KBucketConfig) -> Self { KBucketsTable { local_key, - buckets: (0..NUM_BUCKETS) - .map(|_| KBucket::new(pending_timeout)) - .collect(), + buckets: (0..NUM_BUCKETS).map(|_| KBucket::new(config)).collect(), + bucket_size: config.bucket_size, applied_pending: VecDeque::new(), } } @@ -247,13 +278,16 @@ where T: AsRef, { let distance = self.local_key.as_ref().distance(target); + let bucket_size = self.bucket_size; ClosestIter { target, iter: None, table: self, buckets_iter: ClosestBucketsIter::new(distance), - fmap: |b: &KBucket| -> ArrayVec<_, { K_VALUE.get() }> { - b.iter().map(|(n, _)| n.key.clone()).collect() + fmap: move |b: &KBucket| -> Vec<_> { + let mut vec = Vec::with_capacity(bucket_size); + vec.extend(b.iter().map(|(n, _)| n.key.clone())); + vec }, } } @@ -269,13 +303,15 @@ where TVal: Clone, { let distance = self.local_key.as_ref().distance(target); + let bucket_size = self.bucket_size; ClosestIter { target, iter: None, table: self, buckets_iter: ClosestBucketsIter::new(distance), - fmap: |b: &KBucket<_, TVal>| -> ArrayVec<_, { K_VALUE.get() }> { + fmap: move |b: &KBucket<_, TVal>| -> Vec<_> { b.iter() + .take(bucket_size) .map(|(n, status)| EntryView { node: n.clone(), status, @@ -324,7 +360,7 @@ struct ClosestIter<'a, TTarget, TKey, TVal, TMap, TOut> { /// distance of the local key to the target. buckets_iter: ClosestBucketsIter, /// The iterator over the entries in the currently traversed bucket. - iter: Option>, + iter: Option>, /// The projection function / mapping applied on each bucket as /// it is encountered, producing the next `iter`ator. fmap: TMap, @@ -429,7 +465,7 @@ where TTarget: AsRef, TKey: Clone + AsRef, TVal: Clone, - TMap: Fn(&KBucket) -> ArrayVec, + TMap: Fn(&KBucket) -> Vec, TOut: AsRef, { type Item = TOut; @@ -535,11 +571,14 @@ mod tests { fn arbitrary(g: &mut Gen) -> TestTable { let local_key = Key::from(PeerId::random()); let timeout = Duration::from_secs(g.gen_range(1..360)); - let mut table = TestTable::new(local_key.into(), timeout); + let mut config = KBucketConfig::default(); + config.set_pending_timeout(timeout); + let bucket_size = config.bucket_size; + let mut table = TestTable::new(local_key.into(), config); let mut num_total = g.gen_range(0..100); for (i, b) in &mut table.buckets.iter_mut().enumerate().rev() { let ix = BucketIndex(i); - let num = g.gen_range(0..usize::min(K_VALUE.get(), num_total) + 1); + let num = g.gen_range(0..usize::min(bucket_size, num_total) + 1); num_total -= num; for _ in 0..num { let distance = ix.rand_distance(&mut rand::thread_rng()); @@ -560,7 +599,9 @@ mod tests { fn buckets_are_non_overlapping_and_exhaustive() { let local_key = Key::from(PeerId::random()); let timeout = Duration::from_secs(0); - let mut table = KBucketsTable::::new(local_key.into(), timeout); + let mut config = KBucketConfig::default(); + config.set_pending_timeout(timeout); + let mut table = KBucketsTable::::new(local_key.into(), config); let mut prev_max = U256::from(0); @@ -577,7 +618,9 @@ mod tests { fn bucket_contains_range() { fn prop(ix: u8) { let index = BucketIndex(ix as usize); - let mut bucket = KBucket::, ()>::new(Duration::from_secs(0)); + let mut config = KBucketConfig::default(); + config.set_pending_timeout(Duration::from_secs(0)); + let mut bucket = KBucket::, ()>::new(config); let bucket_ref = KBucketRef { index, bucket: &mut bucket, @@ -623,7 +666,7 @@ mod tests { let local_key = Key::from(PeerId::random()); let other_id = Key::from(PeerId::random()); - let mut table = KBucketsTable::<_, ()>::new(local_key, Duration::from_secs(5)); + let mut table = KBucketsTable::<_, ()>::new(local_key, KBucketConfig::default()); if let Some(Entry::Absent(entry)) = table.entry(&other_id) { match entry.insert((), NodeStatus::Connected) { InsertResult::Inserted => (), @@ -641,7 +684,7 @@ mod tests { #[test] fn entry_self() { let local_key = Key::from(PeerId::random()); - let mut table = KBucketsTable::<_, ()>::new(local_key, Duration::from_secs(5)); + let mut table = KBucketsTable::<_, ()>::new(local_key, KBucketConfig::default()); assert!(table.entry(&local_key).is_none()) } @@ -649,7 +692,7 @@ mod tests { #[test] fn closest() { let local_key = Key::from(PeerId::random()); - let mut table = KBucketsTable::<_, ()>::new(local_key, Duration::from_secs(5)); + let mut table = KBucketsTable::<_, ()>::new(local_key, KBucketConfig::default()); let mut count = 0; loop { if count == 100 { @@ -684,7 +727,9 @@ mod tests { #[test] fn applied_pending() { let local_key = Key::from(PeerId::random()); - let mut table = KBucketsTable::<_, ()>::new(local_key, Duration::from_millis(1)); + let mut config = KBucketConfig::default(); + config.set_pending_timeout(Duration::from_millis(1)); + let mut table = KBucketsTable::<_, ()>::new(local_key, config); let expected_applied; let full_bucket_index; loop { diff --git a/protocols/kad/src/kbucket/bucket.rs b/protocols/kad/src/kbucket/bucket.rs index 1bd4389eb3d..1426017aa7a 100644 --- a/protocols/kad/src/kbucket/bucket.rs +++ b/protocols/kad/src/kbucket/bucket.rs @@ -88,15 +88,17 @@ pub struct Node { } /// The position of a node in a `KBucket`, i.e. a non-negative integer -/// in the range `[0, K_VALUE)`. +/// in the range `[0, bucket_size)`. #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub(crate) struct Position(usize); -/// A `KBucket` is a list of up to `K_VALUE` keys and associated values, +/// A `KBucket` is a list of up to `capacity` keys and associated values, /// ordered from least-recently connected to most-recently connected. #[derive(Debug, Clone)] pub(crate) struct KBucket { /// The nodes contained in the bucket. - nodes: ArrayVec, { K_VALUE.get() }>, + nodes: Vec>, + /// The maximal number of nodes that a bucket can contain. + capacity: usize, /// The position (index) in `nodes` that marks the first connected node. /// @@ -104,7 +106,7 @@ pub(crate) struct KBucket { /// most-recently connected, all entries above this index are also considered /// connected, i.e. the range `[0, first_connected_pos)` marks the sub-list of entries /// that are considered disconnected and the range - /// `[first_connected_pos, K_VALUE)` marks sub-list of entries that are + /// `[first_connected_pos, capacity)` marks sub-list of entries that are /// considered connected. /// /// `None` indicates that there are no connected entries in the bucket, i.e. @@ -156,18 +158,31 @@ pub(crate) struct AppliedPending { pub(crate) evicted: Option>, } +impl Default for KBucket { + fn default() -> Self { + KBucket { + nodes: Vec::with_capacity(K_VALUE.get()), + capacity: K_VALUE.get(), + first_connected_pos: None, + pending: None, + pending_timeout: Duration::from_secs(60), + } + } +} + impl KBucket where TKey: Clone + AsRef, TVal: Clone, { - /// Creates a new `KBucket` with the given timeout for pending entries. - pub(crate) fn new(pending_timeout: Duration) -> Self { + /// Creates a new `KBucket` with the given configuration. + pub(crate) fn new(config: KBucketConfig) -> Self { KBucket { - nodes: ArrayVec::new(), + nodes: Vec::with_capacity(config.bucket_size), + capacity: config.bucket_size, first_connected_pos: None, pending: None, - pending_timeout, + pending_timeout: config.pending_timeout, } } @@ -205,7 +220,7 @@ where pub(crate) fn apply_pending(&mut self) -> Option> { if let Some(pending) = self.pending.take() { if pending.replace <= Instant::now() { - if self.nodes.is_full() { + if self.nodes.len() >= self.capacity { if self.status(Position(0)) == NodeStatus::Connected { // The bucket is full with connected nodes. Drop the pending node. return None; @@ -316,7 +331,7 @@ where ) -> InsertResult { match status { NodeStatus::Connected => { - if self.nodes.is_full() { + if self.nodes.len() >= self.capacity { if self.first_connected_pos == Some(0) || self.pending.is_some() { return InsertResult::Full; } else { @@ -336,7 +351,7 @@ where InsertResult::Inserted } NodeStatus::Disconnected => { - if self.nodes.is_full() { + if self.nodes.len() >= self.capacity { return InsertResult::Full; } if let Some(ref mut p) = self.first_connected_pos { @@ -435,8 +450,10 @@ mod tests { impl Arbitrary for KBucket, ()> { fn arbitrary(g: &mut Gen) -> KBucket, ()> { let timeout = Duration::from_secs(g.gen_range(1..g.size()) as u64); - let mut bucket = KBucket::, ()>::new(timeout); - let num_nodes = g.gen_range(1..K_VALUE.get() + 1); + let mut config = KBucketConfig::default(); + config.set_pending_timeout(timeout); + let mut bucket = KBucket::, ()>::new(config); + let num_nodes = g.gen_range(1..bucket.capacity + 1); for _ in 0..num_nodes { let key = Key::from(PeerId::random()); let node = Node { key, value: () }; @@ -469,7 +486,7 @@ mod tests { // Fill a bucket with random nodes with the given status. fn fill_bucket(bucket: &mut KBucket, ()>, status: NodeStatus) { let num_entries_start = bucket.num_entries(); - for i in 0..K_VALUE.get() - num_entries_start { + for i in 0..bucket.capacity - num_entries_start { let key = Key::from(PeerId::random()); let node = Node { key, value: () }; assert_eq!(InsertResult::Inserted, bucket.insert(node, status)); @@ -480,7 +497,7 @@ mod tests { #[test] fn ordering() { fn prop(status: Vec) -> bool { - let mut bucket = KBucket::, ()>::new(Duration::from_secs(1)); + let mut bucket = KBucket::, ()>::default(); // The expected lists of connected and disconnected nodes. let mut connected = VecDeque::new(); @@ -490,7 +507,7 @@ mod tests { for status in status { let key = Key::from(PeerId::random()); let node = Node { key, value: () }; - let full = bucket.num_entries() == K_VALUE.get(); + let full = bucket.num_entries() == bucket.capacity; if let InsertResult::Inserted = bucket.insert(node, status) { let vec = match status { NodeStatus::Connected => &mut connected, @@ -522,7 +539,7 @@ mod tests { #[test] fn full_bucket() { - let mut bucket = KBucket::, ()>::new(Duration::from_secs(1)); + let mut bucket = KBucket::, ()>::default(); // Fill the bucket with disconnected nodes. fill_bucket(&mut bucket, NodeStatus::Disconnected); @@ -536,7 +553,7 @@ mod tests { } // One-by-one fill the bucket with connected nodes, replacing the disconnected ones. - for i in 0..K_VALUE.get() { + for i in 0..bucket.capacity { let (first, first_status) = bucket.iter().next().unwrap(); let first_disconnected = first.clone(); assert_eq!(first_status, NodeStatus::Disconnected); @@ -573,11 +590,11 @@ mod tests { ); assert_eq!(Some((&node, NodeStatus::Connected)), bucket.iter().last()); assert!(bucket.pending().is_none()); - assert_eq!(Some(K_VALUE.get() - (i + 1)), bucket.first_connected_pos); + assert_eq!(Some(bucket.capacity - (i + 1)), bucket.first_connected_pos); } assert!(bucket.pending().is_none()); - assert_eq!(K_VALUE.get(), bucket.num_entries()); + assert_eq!(bucket.capacity, bucket.num_entries()); // Trying to insert another connected node fails. let key = Key::from(PeerId::random()); @@ -590,7 +607,7 @@ mod tests { #[test] fn full_bucket_discard_pending() { - let mut bucket = KBucket::, ()>::new(Duration::from_secs(1)); + let mut bucket = KBucket::, ()>::default(); fill_bucket(&mut bucket, NodeStatus::Disconnected); let (first, _) = bucket.iter().next().unwrap(); let first_disconnected = first.clone(); @@ -622,7 +639,7 @@ mod tests { bucket.first_connected_pos ); assert_eq!(1, bucket.num_connected()); - assert_eq!(K_VALUE.get() - 1, bucket.num_disconnected()); + assert_eq!(bucket.capacity - 1, bucket.num_disconnected()); } #[test] @@ -654,4 +671,21 @@ mod tests { quickcheck(prop as fn(_, _, _) -> _); } + + #[test] + fn test_custom_bucket_size() { + let bucket_sizes: [NonZeroUsize; 4] = [ + NonZeroUsize::new(2).unwrap(), + NonZeroUsize::new(20).unwrap(), + NonZeroUsize::new(200).unwrap(), + NonZeroUsize::new(2000).unwrap(), + ]; + for &size in &bucket_sizes { + let mut config = KBucketConfig::default(); + config.set_bucket_size(size); + let mut bucket = KBucket::, ()>::new(config); + fill_bucket(&mut bucket, NodeStatus::Disconnected); + assert_eq!(size.get(), bucket.num_entries()); + } + } } From ddda3be64468af360419daf92f824375247f40e3 Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Thu, 8 Aug 2024 15:05:11 +0200 Subject: [PATCH 205/246] chore: add Gui as a maintainer Pull-Request: #5538. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f43cf044ef3..eeab866768d 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). (In alphabetical order.) +- Guillaume Michel ([@guillaumemichel](https://github.com/guillaumemichel)) - João Oliveira ([@jxs](https://github.com/jxs)) ## Notable users From 848e2e9e103af75f7b1d868839e971d2cc5dc706 Mon Sep 17 00:00:00 2001 From: Hannes <55623006+umgefahren@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:35:29 +0200 Subject: [PATCH 206/246] feat(autonat): Implement AutoNATv2 Closes: #4524 This is the implementation of the evolved AutoNAT protocol, named AutonatV2 as defined in the [spec](https://github.com/libp2p/specs/blob/03718ef0f2dea4a756a85ba716ee33f97e4a6d6c/autonat/autonat-v2.md). The stabilization PR for the spec can be found under libp2p/specs#538. The work on the Rust implementation can be found in the PR to my fork: umgefahren/rust-libp2p#1. The implementation has been smoke-tested with the Go implementation (PR: libp2p/go-libp2p#2469). The new protocol addresses shortcomings of the original AutoNAT protocol: - Since the server now always dials back over a newly allocated port, this made #4568 necessary; the client can be sure of the reachability state for other peers, even if the connection to the server was made through a hole punch. - The server can now test addresses different from the observed address (i.e., the connection to the server was made through a `p2p-circuit`). To mitigate against DDoS attacks, the client has to send more data to the server than the dial-back costs. Pull-Request: #5526. --- Cargo.lock | 227 ++++++- Cargo.toml | 1 + examples/autonatv2/Cargo.toml | 38 ++ examples/autonatv2/Dockerfile | 20 + examples/autonatv2/docker-compose.yml | 16 + .../autonatv2/src/bin/autonatv2_client.rs | 111 ++++ .../autonatv2/src/bin/autonatv2_server.rs | 87 +++ protocols/autonat/CHANGELOG.md | 7 + protocols/autonat/Cargo.toml | 31 +- protocols/autonat/src/lib.rs | 45 +- protocols/autonat/src/v1.rs | 45 ++ protocols/autonat/src/{ => v1}/behaviour.rs | 4 +- .../src/{ => v1}/behaviour/as_client.rs | 0 .../src/{ => v1}/behaviour/as_server.rs | 1 - .../autonat/src/{ => v1}/generated/mod.rs | 0 .../src/{ => v1}/generated/structs.proto | 0 .../autonat/src/{ => v1}/generated/structs.rs | 0 protocols/autonat/src/{ => v1}/protocol.rs | 0 protocols/autonat/src/v2.rs | 37 ++ protocols/autonat/src/v2/client.rs | 5 + protocols/autonat/src/v2/client/behaviour.rs | 439 ++++++++++++++ protocols/autonat/src/v2/client/handler.rs | 2 + .../src/v2/client/handler/dial_back.rs | 141 +++++ .../src/v2/client/handler/dial_request.rs | 343 +++++++++++ protocols/autonat/src/v2/generated/mod.rs | 2 + .../autonat/src/v2/generated/structs.proto | 54 ++ protocols/autonat/src/v2/generated/structs.rs | 403 +++++++++++++ protocols/autonat/src/v2/protocol.rs | 337 +++++++++++ protocols/autonat/src/v2/server.rs | 5 + protocols/autonat/src/v2/server/behaviour.rs | 156 +++++ protocols/autonat/src/v2/server/handler.rs | 8 + .../src/v2/server/handler/dial_back.rs | 140 +++++ .../src/v2/server/handler/dial_request.rs | 332 ++++++++++ protocols/autonat/tests/autonatv2.rs | 568 ++++++++++++++++++ 34 files changed, 3525 insertions(+), 80 deletions(-) create mode 100644 examples/autonatv2/Cargo.toml create mode 100644 examples/autonatv2/Dockerfile create mode 100644 examples/autonatv2/docker-compose.yml create mode 100644 examples/autonatv2/src/bin/autonatv2_client.rs create mode 100644 examples/autonatv2/src/bin/autonatv2_server.rs create mode 100644 protocols/autonat/src/v1.rs rename protocols/autonat/src/{ => v1}/behaviour.rs (99%) rename protocols/autonat/src/{ => v1}/behaviour/as_client.rs (100%) rename protocols/autonat/src/{ => v1}/behaviour/as_server.rs (99%) rename protocols/autonat/src/{ => v1}/generated/mod.rs (100%) rename protocols/autonat/src/{ => v1}/generated/structs.proto (100%) rename protocols/autonat/src/{ => v1}/generated/structs.rs (100%) rename protocols/autonat/src/{ => v1}/protocol.rs (100%) create mode 100644 protocols/autonat/src/v2.rs create mode 100644 protocols/autonat/src/v2/client.rs create mode 100644 protocols/autonat/src/v2/client/behaviour.rs create mode 100644 protocols/autonat/src/v2/client/handler.rs create mode 100644 protocols/autonat/src/v2/client/handler/dial_back.rs create mode 100644 protocols/autonat/src/v2/client/handler/dial_request.rs create mode 100644 protocols/autonat/src/v2/generated/mod.rs create mode 100644 protocols/autonat/src/v2/generated/structs.proto create mode 100644 protocols/autonat/src/v2/generated/structs.rs create mode 100644 protocols/autonat/src/v2/protocol.rs create mode 100644 protocols/autonat/src/v2/server.rs create mode 100644 protocols/autonat/src/v2/server/behaviour.rs create mode 100644 protocols/autonat/src/v2/server/handler.rs create mode 100644 protocols/autonat/src/v2/server/handler/dial_back.rs create mode 100644 protocols/autonat/src/v2/server/handler/dial_request.rs create mode 100644 protocols/autonat/tests/autonatv2.rs diff --git a/Cargo.lock b/Cargo.lock index cf0cde790c3..af3ceb9eb0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -528,6 +528,23 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "autonatv2" +version = "0.1.0" +dependencies = [ + "cfg-if", + "clap", + "libp2p", + "opentelemetry 0.21.0", + "opentelemetry-jaeger", + "opentelemetry_sdk 0.21.2", + "rand 0.8.5", + "tokio", + "tracing", + "tracing-opentelemetry 0.22.0", + "tracing-subscriber", +] + [[package]] name = "axum" version = "0.6.20" @@ -1120,6 +1137,15 @@ dependencies = [ "itertools", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -1146,12 +1172,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crunchy" @@ -2404,6 +2427,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "integer-encoding" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" + [[package]] name = "interceptor" version = "0.10.0" @@ -2454,7 +2483,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "wasm-logger", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -2664,9 +2693,13 @@ dependencies = [ "async-std", "async-trait", "asynchronous-codec", + "bytes", + "either", "futures", + "futures-bounded", "futures-timer", "libp2p-core", + "libp2p-identify", "libp2p-identity", "libp2p-request-response", "libp2p-swarm", @@ -2674,9 +2707,13 @@ dependencies = [ "quick-protobuf", "quick-protobuf-codec", "rand 0.8.5", + "rand_core 0.6.4", + "thiserror", + "tokio", "tracing", "tracing-subscriber", - "web-time", + "void", + "web-time 1.1.0", ] [[package]] @@ -2724,7 +2761,7 @@ dependencies = [ "tracing", "unsigned-varint 0.8.0", "void", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -2758,7 +2795,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -2833,7 +2870,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -2921,7 +2958,7 @@ dependencies = [ "tracing-subscriber", "uint", "void", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -2984,7 +3021,7 @@ dependencies = [ "libp2p-swarm", "pin-project", "prometheus-client", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -3076,7 +3113,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -3096,7 +3133,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -3193,7 +3230,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -3223,7 +3260,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -3252,7 +3289,7 @@ dependencies = [ "tracing", "tracing-subscriber", "void", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -3323,7 +3360,7 @@ dependencies = [ "trybuild", "void", "wasm-bindgen-futures", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -3741,13 +3778,13 @@ dependencies = [ "axum 0.7.5", "futures", "libp2p", - "opentelemetry", + "opentelemetry 0.23.0", "opentelemetry-otlp", - "opentelemetry_sdk", + "opentelemetry_sdk 0.23.0", "prometheus-client", "tokio", "tracing", - "tracing-opentelemetry", + "tracing-opentelemetry 0.24.0", "tracing-subscriber", ] @@ -4134,6 +4171,22 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "opentelemetry" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e32339a5dc40459130b3bd269e9892439f55b33e772d2a9d402a789baaf4e8a" +dependencies = [ + "futures-core", + "futures-sink", + "indexmap 2.2.1", + "js-sys", + "once_cell", + "pin-project-lite", + "thiserror", + "urlencoding", +] + [[package]] name = "opentelemetry" version = "0.23.0" @@ -4148,6 +4201,22 @@ dependencies = [ "thiserror", ] +[[package]] +name = "opentelemetry-jaeger" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e617c66fd588e40e0dbbd66932fdc87393095b125d4459b1a3a10feb1712f8a1" +dependencies = [ + "async-trait", + "futures-core", + "futures-util", + "opentelemetry 0.21.0", + "opentelemetry-semantic-conventions", + "opentelemetry_sdk 0.21.2", + "thrift", + "tokio", +] + [[package]] name = "opentelemetry-otlp" version = "0.16.0" @@ -4157,9 +4226,9 @@ dependencies = [ "async-trait", "futures-core", "http 0.2.9", - "opentelemetry", + "opentelemetry 0.23.0", "opentelemetry-proto", - "opentelemetry_sdk", + "opentelemetry_sdk 0.23.0", "prost", "thiserror", "tokio", @@ -4172,12 +4241,43 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "984806e6cf27f2b49282e2a05e288f30594f3dbc74eb7a6e99422bc48ed78162" dependencies = [ - "opentelemetry", - "opentelemetry_sdk", + "opentelemetry 0.23.0", + "opentelemetry_sdk 0.23.0", "prost", "tonic", ] +[[package]] +name = "opentelemetry-semantic-conventions" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5774f1ef1f982ef2a447f6ee04ec383981a3ab99c8e77a1a7b30182e65bbc84" +dependencies = [ + "opentelemetry 0.21.0", +] + +[[package]] +name = "opentelemetry_sdk" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f16aec8a98a457a52664d69e0091bac3a0abd18ead9b641cb00202ba4e0efe4" +dependencies = [ + "async-trait", + "crossbeam-channel", + "futures-channel", + "futures-executor", + "futures-util", + "glob", + "once_cell", + "opentelemetry 0.21.0", + "ordered-float 4.2.0", + "percent-encoding", + "rand 0.8.5", + "thiserror", + "tokio", + "tokio-stream", +] + [[package]] name = "opentelemetry_sdk" version = "0.23.0" @@ -4191,8 +4291,8 @@ dependencies = [ "glob", "lazy_static", "once_cell", - "opentelemetry", - "ordered-float", + "opentelemetry 0.23.0", + "ordered-float 4.2.0", "percent-encoding", "rand 0.8.5", "thiserror", @@ -4200,6 +4300,15 @@ dependencies = [ "tokio-stream", ] +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-float" version = "4.2.0" @@ -5926,6 +6035,28 @@ dependencies = [ "once_cell", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "thrift" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e54bc85fc7faa8bc175c4bab5b92ba8d9a3ce893d0e9f42cc455c8ab16a9e09" +dependencies = [ + "byteorder", + "integer-encoding", + "log", + "ordered-float 2.10.1", + "threadpool", +] + [[package]] name = "time" version = "0.3.36" @@ -6230,6 +6361,24 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-opentelemetry" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c67ac25c5407e7b961fafc6f7e9aa5958fd297aada2d20fa2ae1737357e55596" +dependencies = [ + "js-sys", + "once_cell", + "opentelemetry 0.21.0", + "opentelemetry_sdk 0.21.2", + "smallvec", + "tracing", + "tracing-core", + "tracing-log", + "tracing-subscriber", + "web-time 0.2.4", +] + [[package]] name = "tracing-opentelemetry" version = "0.24.0" @@ -6238,14 +6387,14 @@ checksum = "f68803492bf28ab40aeccaecc7021096bd256baf7ca77c3d425d89b35a7be4e4" dependencies = [ "js-sys", "once_cell", - "opentelemetry", - "opentelemetry_sdk", + "opentelemetry 0.23.0", + "opentelemetry_sdk 0.23.0", "smallvec", "tracing", "tracing-core", "tracing-log", "tracing-subscriber", - "web-time", + "web-time 1.1.0", ] [[package]] @@ -6429,6 +6578,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf8parse" version = "0.2.1" @@ -6632,6 +6787,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "web-time" version = "1.1.0" @@ -7227,7 +7392,7 @@ dependencies = [ "pin-project", "rand 0.8.5", "static_assertions", - "web-time", + "web-time 1.1.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 7eb1517d24c..3f00734ae3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ members = [ "core", "examples/autonat", + "examples/autonatv2", "examples/browser-webrtc", "examples/chat", "examples/dcutr", diff --git a/examples/autonatv2/Cargo.toml b/examples/autonatv2/Cargo.toml new file mode 100644 index 00000000000..6c862ee22e4 --- /dev/null +++ b/examples/autonatv2/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "autonatv2" +version = "0.1.0" +edition = "2021" +publish = false +license = "MIT or Apache-2.0" + +[package.metadata.release] +release = false + +[[bin]] +name = "autonatv2_client" + +[[bin]] +name = "autonatv2_server" + +[dependencies] +libp2p = { workspace = true, features = ["macros", "tokio", "tcp", "noise", "yamux", "autonat", "identify", "dns", "quic"] } +clap = { version = "4.4.18", features = ["derive"] } +tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread"] } +tracing = "0.1.40" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } +rand = "0.8.5" +opentelemetry = { version = "0.21.0", optional = true } +opentelemetry_sdk = { version = "0.21.1", optional = true, features = ["rt-tokio"] } +tracing-opentelemetry = { version = "0.22.0", optional = true } +opentelemetry-jaeger = { version = "0.20.0", optional = true, features = ["rt-tokio"] } +cfg-if = "1.0.0" + +[features] +jaeger = ["opentelemetry", "opentelemetry_sdk", "tracing-opentelemetry", "opentelemetry-jaeger"] +opentelemetry = ["dep:opentelemetry"] +opentelemetry_sdk = ["dep:opentelemetry_sdk"] +tracing-opentelemetry = ["dep:tracing-opentelemetry"] +opentelemetry-jaeger = ["dep:opentelemetry-jaeger"] + +[lints] +workspace = true diff --git a/examples/autonatv2/Dockerfile b/examples/autonatv2/Dockerfile new file mode 100644 index 00000000000..5a523649d80 --- /dev/null +++ b/examples/autonatv2/Dockerfile @@ -0,0 +1,20 @@ +FROM rust:1.75-alpine as builder + +RUN apk add musl-dev + +WORKDIR /workspace +COPY . . +RUN --mount=type=cache,target=./target \ + --mount=type=cache,target=/usr/local/cargo/registry \ + cargo build --release --package autonatv2 --bin autonatv2_server -F jaeger + +RUN --mount=type=cache,target=./target \ + mv ./target/release/autonatv2_server /usr/local/bin/autonatv2_server + +FROM alpine:latest + +COPY --from=builder /usr/local/bin/autonatv2_server /app/autonatv2_server + +EXPOSE 4884 + +ENTRYPOINT [ "/app/autonatv2_server", "-l", "4884" ] diff --git a/examples/autonatv2/docker-compose.yml b/examples/autonatv2/docker-compose.yml new file mode 100644 index 00000000000..75f44e7e6f9 --- /dev/null +++ b/examples/autonatv2/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3' + +services: + autonatv2: + build: + context: ../.. + dockerfile: examples/autonatv2/Dockerfile + ports: + - 4884:4884 + jaeger: + image: jaegertracing/all-in-one + ports: + - 6831:6831/udp + - 6832:6832/udp + - 16686:16686 + - 14268:14268 diff --git a/examples/autonatv2/src/bin/autonatv2_client.rs b/examples/autonatv2/src/bin/autonatv2_client.rs new file mode 100644 index 00000000000..de902514dd8 --- /dev/null +++ b/examples/autonatv2/src/bin/autonatv2_client.rs @@ -0,0 +1,111 @@ +use std::{error::Error, net::Ipv4Addr, time::Duration}; + +use clap::Parser; +use libp2p::{ + autonat, + futures::StreamExt, + identify, identity, + multiaddr::Protocol, + noise, + swarm::{dial_opts::DialOpts, NetworkBehaviour, SwarmEvent}, + tcp, yamux, Multiaddr, SwarmBuilder, +}; +use rand::rngs::OsRng; +use tracing_subscriber::EnvFilter; + +#[derive(Debug, Parser)] +#[clap(name = "libp2p autonatv2 client")] +struct Opt { + /// Port where the client will listen for incoming connections. + #[clap(short = 'p', long, default_value_t = 0)] + listen_port: u16, + + /// Address of the server where want to connect to. + #[clap(short = 'a', long)] + server_address: Multiaddr, + + /// Probe interval in seconds. + #[clap(short = 't', long, default_value = "2")] + probe_interval: u64, +} + +#[tokio::main] +async fn main() -> Result<(), Box> { + let _ = tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .try_init(); + + let opt = Opt::parse(); + + let mut swarm = SwarmBuilder::with_new_identity() + .with_tokio() + .with_tcp( + tcp::Config::default(), + noise::Config::new, + yamux::Config::default, + )? + .with_quic() + .with_dns()? + .with_behaviour(|key| Behaviour::new(key.public(), opt.probe_interval))? + .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(10))) + .build(); + + swarm.listen_on( + Multiaddr::empty() + .with(Protocol::Ip4(Ipv4Addr::UNSPECIFIED)) + .with(Protocol::Tcp(opt.listen_port)), + )?; + + swarm.dial( + DialOpts::unknown_peer_id() + .address(opt.server_address) + .build(), + )?; + + loop { + match swarm.select_next_some().await { + SwarmEvent::NewListenAddr { address, .. } => { + println!("Listening on {address:?}"); + } + SwarmEvent::Behaviour(BehaviourEvent::Autonat(autonat::v2::client::Event { + server, + tested_addr, + bytes_sent, + result: Ok(()), + })) => { + println!("Tested {tested_addr} with {server}. Sent {bytes_sent} bytes for verification. Everything Ok and verified."); + } + SwarmEvent::Behaviour(BehaviourEvent::Autonat(autonat::v2::client::Event { + server, + tested_addr, + bytes_sent, + result: Err(e), + })) => { + println!("Tested {tested_addr} with {server}. Sent {bytes_sent} bytes for verification. Failed with {e:?}."); + } + SwarmEvent::ExternalAddrConfirmed { address } => { + println!("External address confirmed: {address}"); + } + _ => {} + } + } +} + +#[derive(NetworkBehaviour)] +pub struct Behaviour { + autonat: autonat::v2::client::Behaviour, + identify: identify::Behaviour, +} + +impl Behaviour { + pub fn new(key: identity::PublicKey, probe_interval: u64) -> Self { + Self { + autonat: autonat::v2::client::Behaviour::new( + OsRng, + autonat::v2::client::Config::default() + .with_probe_interval(Duration::from_secs(probe_interval)), + ), + identify: identify::Behaviour::new(identify::Config::new("/ipfs/0.1.0".into(), key)), + } + } +} diff --git a/examples/autonatv2/src/bin/autonatv2_server.rs b/examples/autonatv2/src/bin/autonatv2_server.rs new file mode 100644 index 00000000000..849ed3b3b0a --- /dev/null +++ b/examples/autonatv2/src/bin/autonatv2_server.rs @@ -0,0 +1,87 @@ +use std::{error::Error, net::Ipv4Addr, time::Duration}; + +use cfg_if::cfg_if; +use clap::Parser; +use libp2p::{ + autonat, + futures::StreamExt, + identify, identity, + multiaddr::Protocol, + noise, + swarm::{NetworkBehaviour, SwarmEvent}, + tcp, yamux, Multiaddr, SwarmBuilder, +}; +use rand::rngs::OsRng; + +#[derive(Debug, Parser)] +#[clap(name = "libp2p autonatv2 server")] +struct Opt { + #[clap(short, long, default_value_t = 0)] + listen_port: u16, +} + +#[tokio::main] +async fn main() -> Result<(), Box> { + cfg_if! { + if #[cfg(feature = "jaeger")] { + use tracing_subscriber::layer::SubscriberExt; + use opentelemetry_sdk::runtime::Tokio; + let tracer = opentelemetry_jaeger::new_agent_pipeline() + .with_endpoint("jaeger:6831") + .with_service_name("autonatv2") + .install_batch(Tokio)?; + let telemetry = tracing_opentelemetry::layer().with_tracer(tracer); + let subscriber = tracing_subscriber::Registry::default() + .with(telemetry); + } else { + let subscriber = tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .finish(); + } + } + tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed"); + + let opt = Opt::parse(); + + let mut swarm = SwarmBuilder::with_new_identity() + .with_tokio() + .with_tcp( + tcp::Config::default(), + noise::Config::new, + yamux::Config::default, + )? + .with_quic() + .with_dns()? + .with_behaviour(|key| Behaviour::new(key.public()))? + .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60))) + .build(); + + swarm.listen_on( + Multiaddr::empty() + .with(Protocol::Ip4(Ipv4Addr::UNSPECIFIED)) + .with(Protocol::Tcp(opt.listen_port)), + )?; + + loop { + match swarm.select_next_some().await { + SwarmEvent::NewListenAddr { address, .. } => println!("Listening on {address:?}"), + SwarmEvent::Behaviour(event) => println!("{event:?}"), + e => println!("{e:?}"), + } + } +} + +#[derive(NetworkBehaviour)] +pub struct Behaviour { + autonat: autonat::v2::server::Behaviour, + identify: identify::Behaviour, +} + +impl Behaviour { + pub fn new(key: identity::PublicKey) -> Self { + Self { + autonat: autonat::v2::server::Behaviour::new(OsRng), + identify: identify::Behaviour::new(identify::Config::new("/ipfs/0.1.0".into(), key)), + } + } +} diff --git a/protocols/autonat/CHANGELOG.md b/protocols/autonat/CHANGELOG.md index 2a799221f7c..e171412aa58 100644 --- a/protocols/autonat/CHANGELOG.md +++ b/protocols/autonat/CHANGELOG.md @@ -3,6 +3,13 @@ - Due to the refactor of `Transport` it's no longer required to create a seperate transport for AutoNAT where port reuse is disabled. This information is now passed by the behaviour. See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568). +- Introduce the new AutoNATv2 protocol. + It's split into a client and a server part, represented in their respective modules + Features: + - The server now always dials back over a newly allocated port. + This more accurately reflects the reachability state for other peers and avoids accidental hole punching. + - The server can now test addresses different from the observed address (i.e., the connection to the server was made through a `p2p-circuit`). To mitigate against DDoS attacks, the client has to send more data to the server than the dial-back costs. + See [PR 5526](https://github.com/libp2p/rust-libp2p/pull/5526). diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index 7e31a7f3895..2c01d18dceb 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -3,32 +3,47 @@ name = "libp2p-autonat" edition = "2021" rust-version = { workspace = true } description = "NAT and firewall detection for libp2p" -authors = ["David Craven ", "Elena Frank "] version = "0.13.0" +authors = ["David Craven ", "Elena Frank ", "Hannes Furmans "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] categories = ["network-programming", "asynchronous"] + [dependencies] -async-trait = "0.1" +async-trait = { version = "0.1", optional = true } +asynchronous-codec = { workspace = true } +bytes = { version = "1", optional = true } +either = { version = "1.9.0", optional = true } futures = { workspace = true } +futures-bounded = { workspace = true, optional = true } futures-timer = "3.0" -web-time = { workspace = true } +web-time = { workspace = true, optional = true } libp2p-core = { workspace = true } -libp2p-swarm = { workspace = true } -libp2p-request-response = { workspace = true } libp2p-identity = { workspace = true } +libp2p-request-response = { workspace = true, optional = true } +libp2p-swarm = { workspace = true } quick-protobuf = "0.8" -rand = "0.8" tracing = { workspace = true } quick-protobuf-codec = { workspace = true } -asynchronous-codec = { workspace = true } +rand = "0.8" +rand_core = { version = "0.6", optional = true } +thiserror = { version = "1.0.52", optional = true } +void = { version = "1", optional = true } [dev-dependencies] +tokio = { version = "1", features = ["macros", "rt", "sync"]} async-std = { version = "1.10", features = ["attributes"] } libp2p-swarm-test = { path = "../../swarm-test" } -tracing-subscriber = { workspace = true, features = ["env-filter"] } +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +libp2p-identify = { workspace = true } +libp2p-swarm = { workspace = true, features = ["macros"]} + +[features] +default = ["v1", "v2"] +v1 = ["dep:libp2p-request-response", "dep:web-time", "dep:async-trait"] +v2 = ["dep:bytes", "dep:either", "dep:futures-bounded", "dep:thiserror", "dep:void", "dep:rand_core"] # Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling diff --git a/protocols/autonat/src/lib.rs b/protocols/autonat/src/lib.rs index 10c87b1e984..e49eaadcb83 100644 --- a/protocols/autonat/src/lib.rs +++ b/protocols/autonat/src/lib.rs @@ -1,41 +1,10 @@ -// Copyright 2021 Protocol Labs. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. +#![cfg_attr(docsrs, feature(doc_auto_cfg))] -//! Implementation of the [AutoNAT](https://github.com/libp2p/specs/blob/master/autonat/README.md) protocol. +#[cfg(feature = "v1")] +pub mod v1; -#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#[cfg(feature = "v2")] +pub mod v2; -mod behaviour; -mod protocol; - -pub use self::{ - behaviour::{ - Behaviour, Config, Event, InboundProbeError, InboundProbeEvent, NatStatus, - OutboundProbeError, OutboundProbeEvent, ProbeId, - }, - protocol::{ResponseError, DEFAULT_PROTOCOL_NAME}, -}; -pub use libp2p_request_response::{InboundFailure, OutboundFailure}; - -mod proto { - #![allow(unreachable_pub)] - include!("generated/mod.rs"); - pub(crate) use self::structs::{mod_Message::*, Message}; -} +#[cfg(feature = "v1")] +pub use v1::*; diff --git a/protocols/autonat/src/v1.rs b/protocols/autonat/src/v1.rs new file mode 100644 index 00000000000..c60e4805f40 --- /dev/null +++ b/protocols/autonat/src/v1.rs @@ -0,0 +1,45 @@ +// Copyright 2021 Protocol Labs. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +//! Implementation of the [AutoNAT](https://github.com/libp2p/specs/blob/master/autonat/README.md) protocol. +//! +//! ## Eventual Deprecation +//! This version of the protocol will eventually be deprecated in favor of [v2](crate::v2). +//! We recommend using v2 for new projects. + +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + +pub(crate) mod behaviour; +pub(crate) mod protocol; + +pub use self::{ + behaviour::{ + Behaviour, Config, Event, InboundProbeError, InboundProbeEvent, NatStatus, + OutboundProbeError, OutboundProbeEvent, ProbeId, + }, + protocol::{ResponseError, DEFAULT_PROTOCOL_NAME}, +}; +pub use libp2p_request_response::{InboundFailure, OutboundFailure}; + +pub(crate) mod proto { + #![allow(unreachable_pub)] + include!("v1/generated/mod.rs"); + pub(crate) use self::structs::{mod_Message::*, Message}; +} diff --git a/protocols/autonat/src/behaviour.rs b/protocols/autonat/src/v1/behaviour.rs similarity index 99% rename from protocols/autonat/src/behaviour.rs rename to protocols/autonat/src/v1/behaviour.rs index 64bebfb6233..7a717baed8d 100644 --- a/protocols/autonat/src/behaviour.rs +++ b/protocols/autonat/src/v1/behaviour.rs @@ -339,7 +339,7 @@ impl Behaviour { ConnectedPoint::Dialer { address, role_override: Endpoint::Dialer, - .. + port_use: _, } => { if let Some(event) = self.as_server().on_outbound_connection(&peer, address) { self.pending_actions @@ -349,7 +349,7 @@ impl Behaviour { ConnectedPoint::Dialer { address: _, role_override: Endpoint::Listener, - .. + port_use: _, } => { // Outgoing connection was dialed as a listener. In other words outgoing connection // was dialed as part of a hole punch. `libp2p-autonat` never attempts to hole diff --git a/protocols/autonat/src/behaviour/as_client.rs b/protocols/autonat/src/v1/behaviour/as_client.rs similarity index 100% rename from protocols/autonat/src/behaviour/as_client.rs rename to protocols/autonat/src/v1/behaviour/as_client.rs diff --git a/protocols/autonat/src/behaviour/as_server.rs b/protocols/autonat/src/v1/behaviour/as_server.rs similarity index 99% rename from protocols/autonat/src/behaviour/as_server.rs rename to protocols/autonat/src/v1/behaviour/as_server.rs index 8f1d6642de5..3ecdd3ac26e 100644 --- a/protocols/autonat/src/behaviour/as_server.rs +++ b/protocols/autonat/src/v1/behaviour/as_server.rs @@ -17,7 +17,6 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. - use super::{ Action, AutoNatCodec, Config, DialRequest, DialResponse, Event, HandleInnerEvent, ProbeId, ResponseError, diff --git a/protocols/autonat/src/generated/mod.rs b/protocols/autonat/src/v1/generated/mod.rs similarity index 100% rename from protocols/autonat/src/generated/mod.rs rename to protocols/autonat/src/v1/generated/mod.rs diff --git a/protocols/autonat/src/generated/structs.proto b/protocols/autonat/src/v1/generated/structs.proto similarity index 100% rename from protocols/autonat/src/generated/structs.proto rename to protocols/autonat/src/v1/generated/structs.proto diff --git a/protocols/autonat/src/generated/structs.rs b/protocols/autonat/src/v1/generated/structs.rs similarity index 100% rename from protocols/autonat/src/generated/structs.rs rename to protocols/autonat/src/v1/generated/structs.rs diff --git a/protocols/autonat/src/protocol.rs b/protocols/autonat/src/v1/protocol.rs similarity index 100% rename from protocols/autonat/src/protocol.rs rename to protocols/autonat/src/v1/protocol.rs diff --git a/protocols/autonat/src/v2.rs b/protocols/autonat/src/v2.rs new file mode 100644 index 00000000000..994497cb1a0 --- /dev/null +++ b/protocols/autonat/src/v2.rs @@ -0,0 +1,37 @@ +//! The second version of the autonat protocol. +//! +//! The implementation follows the [libp2p spec](https://github.com/libp2p/specs/blob/03718ef0f2dea4a756a85ba716ee33f97e4a6d6c/autonat/autonat-v2.md). +//! +//! The new version fixes the issues of the first version: +//! - The server now always dials back over a newly allocated port. This greatly reduces the risk of +//! false positives that often occured in the first version, when the clinet-server connection +//! occured over a hole-punched port. +//! - The server protects against DoS attacks by requiring the client to send more data to the +//! server then the dial back puts on the client, thus making the protocol unatractive for an +//! attacker. +//! +//! The protocol is seperated into two parts: +//! - The client part, which is implemented in the `client` module. (The client is the party that +//! wants to check if it is reachable from the outside.) +//! - The server part, which is implemented in the `server` module. (The server is the party +//! performing reachability checks on behalf of the client.) +//! +//! The two can be used together. + +use libp2p_swarm::StreamProtocol; + +pub mod client; +pub(crate) mod protocol; +pub mod server; + +pub(crate) mod generated { + #![allow(unreachable_pub)] + include!("v2/generated/mod.rs"); +} + +pub(crate) const DIAL_REQUEST_PROTOCOL: StreamProtocol = + StreamProtocol::new("/libp2p/autonat/2/dial-request"); +pub(crate) const DIAL_BACK_PROTOCOL: StreamProtocol = + StreamProtocol::new("/libp2p/autonat/2/dial-back"); + +type Nonce = u64; diff --git a/protocols/autonat/src/v2/client.rs b/protocols/autonat/src/v2/client.rs new file mode 100644 index 00000000000..d3272512f35 --- /dev/null +++ b/protocols/autonat/src/v2/client.rs @@ -0,0 +1,5 @@ +mod behaviour; +mod handler; + +pub use behaviour::Event; +pub use behaviour::{Behaviour, Config}; diff --git a/protocols/autonat/src/v2/client/behaviour.rs b/protocols/autonat/src/v2/client/behaviour.rs new file mode 100644 index 00000000000..97509c05443 --- /dev/null +++ b/protocols/autonat/src/v2/client/behaviour.rs @@ -0,0 +1,439 @@ +use std::{ + collections::{HashMap, VecDeque}, + task::{Context, Poll}, + time::Duration, +}; + +use either::Either; +use futures::FutureExt; +use futures_timer::Delay; +use libp2p_core::{transport::PortUse, Endpoint, Multiaddr}; +use libp2p_identity::PeerId; +use libp2p_swarm::{ + behaviour::ConnectionEstablished, ConnectionClosed, ConnectionDenied, ConnectionHandler, + ConnectionId, FromSwarm, NetworkBehaviour, NewExternalAddrCandidate, NotifyHandler, ToSwarm, +}; +use rand::prelude::*; +use rand_core::OsRng; +use std::fmt::{Debug, Display, Formatter}; + +use crate::v2::{protocol::DialRequest, Nonce}; + +use super::handler::{ + dial_back::{self, IncomingNonce}, + dial_request, +}; + +#[derive(Debug, Clone, Copy)] +pub struct Config { + /// How many candidates we will test at most. + pub(crate) max_candidates: usize, + + /// The interval at which we will attempt to confirm candidates as external addresses. + pub(crate) probe_interval: Duration, +} + +impl Config { + pub fn with_max_candidates(self, max_candidates: usize) -> Self { + Self { + max_candidates, + ..self + } + } + + pub fn with_probe_interval(self, probe_interval: Duration) -> Self { + Self { + probe_interval, + ..self + } + } +} + +impl Default for Config { + fn default() -> Self { + Self { + max_candidates: 10, + probe_interval: Duration::from_secs(5), + } + } +} + +pub struct Behaviour +where + R: RngCore + 'static, +{ + rng: R, + config: Config, + pending_events: VecDeque< + ToSwarm< + ::ToSwarm, + <::ConnectionHandler as ConnectionHandler>::FromBehaviour, + >, + >, + address_candidates: HashMap, + next_tick: Delay, + peer_info: HashMap, +} + +impl NetworkBehaviour for Behaviour +where + R: RngCore + 'static, +{ + type ConnectionHandler = Either; + + type ToSwarm = Event; + + fn handle_established_inbound_connection( + &mut self, + _: ConnectionId, + _: PeerId, + _: &Multiaddr, + _: &Multiaddr, + ) -> Result<::ConnectionHandler, ConnectionDenied> { + Ok(Either::Right(dial_back::Handler::new())) + } + + fn handle_established_outbound_connection( + &mut self, + _: ConnectionId, + _: PeerId, + _: &Multiaddr, + _: Endpoint, + _: PortUse, + ) -> Result<::ConnectionHandler, ConnectionDenied> { + Ok(Either::Left(dial_request::Handler::new())) + } + + fn on_swarm_event(&mut self, event: FromSwarm) { + match event { + FromSwarm::NewExternalAddrCandidate(NewExternalAddrCandidate { addr }) => { + self.address_candidates + .entry(addr.clone()) + .or_default() + .score += 1; + } + FromSwarm::ConnectionEstablished(ConnectionEstablished { + peer_id, + connection_id, + endpoint: _, + .. + }) => { + self.peer_info.insert( + connection_id, + ConnectionInfo { + peer_id, + supports_autonat: false, + }, + ); + } + FromSwarm::ConnectionClosed(ConnectionClosed { + peer_id, + connection_id, + .. + }) => { + let info = self + .peer_info + .remove(&connection_id) + .expect("inconsistent state"); + + if info.supports_autonat { + tracing::debug!(%peer_id, "Disconnected from AutoNAT server"); + } + } + _ => {} + } + } + + fn on_connection_handler_event( + &mut self, + peer_id: PeerId, + connection_id: ConnectionId, + event: ::ToBehaviour, + ) { + let (nonce, outcome) = match event { + Either::Right(IncomingNonce { nonce, sender }) => { + let Some((_, info)) = self + .address_candidates + .iter_mut() + .find(|(_, info)| info.is_pending_with_nonce(nonce)) + else { + let _ = sender.send(Err(std::io::Error::new( + std::io::ErrorKind::InvalidData, + format!("Received unexpected nonce: {nonce} from {peer_id}"), + ))); + return; + }; + + info.status = TestStatus::Received(nonce); + tracing::debug!(%peer_id, %nonce, "Successful dial-back"); + + let _ = sender.send(Ok(())); + + return; + } + Either::Left(dial_request::ToBehaviour::PeerHasServerSupport) => { + self.peer_info + .get_mut(&connection_id) + .expect("inconsistent state") + .supports_autonat = true; + return; + } + Either::Left(dial_request::ToBehaviour::TestOutcome { nonce, outcome }) => { + (nonce, outcome) + } + }; + + let ((tested_addr, bytes_sent), result) = match outcome { + Ok(address) => { + let received_dial_back = self + .address_candidates + .iter_mut() + .any(|(_, info)| info.is_received_with_nonce(nonce)); + + if !received_dial_back { + tracing::warn!( + %peer_id, + %nonce, + "Server reported reachbility but we never received a dial-back" + ); + return; + } + + self.pending_events + .push_back(ToSwarm::ExternalAddrConfirmed(address.0.clone())); + + (address, Ok(())) + } + Err(dial_request::Error::UnsupportedProtocol) => { + self.peer_info + .get_mut(&connection_id) + .expect("inconsistent state") + .supports_autonat = false; + + self.reset_status_to(nonce, TestStatus::Untested); // Reset so it will be tried again. + + return; + } + Err(dial_request::Error::Io(e)) => { + tracing::debug!( + %peer_id, + %nonce, + "Failed to complete AutoNAT probe: {e}" + ); + + self.reset_status_to(nonce, TestStatus::Untested); // Reset so it will be tried again. + + return; + } + Err(dial_request::Error::AddressNotReachable { + address, + bytes_sent, + error, + }) => { + self.reset_status_to(nonce, TestStatus::Failed); + + ((address, bytes_sent), Err(error)) + } + }; + + self.pending_events.push_back(ToSwarm::GenerateEvent(Event { + tested_addr, + bytes_sent, + server: peer_id, + result: result.map_err(|e| Error { inner: e }), + })); + } + + fn poll( + &mut self, + cx: &mut Context<'_>, + ) -> Poll::FromBehaviour>> + { + loop { + if let Some(event) = self.pending_events.pop_front() { + return Poll::Ready(event); + } + + if self.next_tick.poll_unpin(cx).is_ready() { + self.next_tick.reset(self.config.probe_interval); + + self.issue_dial_requests_for_untested_candidates(); + continue; + } + + return Poll::Pending; + } + } +} + +impl Behaviour +where + R: RngCore + 'static, +{ + pub fn new(rng: R, config: Config) -> Self { + Self { + rng, + next_tick: Delay::new(config.probe_interval), + config, + pending_events: VecDeque::new(), + address_candidates: HashMap::new(), + peer_info: HashMap::new(), + } + } + + /// Issues dial requests to random AutoNAT servers for the most frequently reported, untested candidates. + /// + /// In the current implementation, we only send a single address to each AutoNAT server. + /// This spreads our candidates out across all servers we are connected to which should give us pretty fast feedback on all of them. + fn issue_dial_requests_for_untested_candidates(&mut self) { + for addr in self.untested_candidates() { + let Some((conn_id, peer_id)) = self.random_autonat_server() else { + tracing::debug!("Not connected to any AutoNAT servers"); + return; + }; + + let nonce = self.rng.gen(); + self.address_candidates + .get_mut(&addr) + .expect("only emit candidates") + .status = TestStatus::Pending(nonce); + + self.pending_events.push_back(ToSwarm::NotifyHandler { + peer_id, + handler: NotifyHandler::One(conn_id), + event: Either::Left(DialRequest { + nonce, + addrs: vec![addr], + }), + }); + } + } + + /// Returns all untested candidates, sorted by the frequency they were reported at. + /// + /// More frequently reported candidates are considered to more likely be external addresses and thus tested first. + fn untested_candidates(&self) -> impl Iterator { + let mut entries = self + .address_candidates + .iter() + .filter(|(_, info)| info.status == TestStatus::Untested) + .map(|(addr, count)| (addr.clone(), *count)) + .collect::>(); + + entries.sort_unstable_by_key(|(_, info)| info.score); + + if entries.is_empty() { + tracing::debug!("No untested address candidates"); + } + + entries + .into_iter() + .rev() // `sort_unstable` is ascending + .take(self.config.max_candidates) + .map(|(addr, _)| addr) + } + + /// Chooses an active connection to one of our peers that reported support for the [`DIAL_REQUEST_PROTOCOL`](crate::v2::DIAL_REQUEST_PROTOCOL) protocol. + fn random_autonat_server(&mut self) -> Option<(ConnectionId, PeerId)> { + let (conn_id, info) = self + .peer_info + .iter() + .filter(|(_, info)| info.supports_autonat) + .choose(&mut self.rng)?; + + Some((*conn_id, info.peer_id)) + } + + fn reset_status_to(&mut self, nonce: Nonce, new_status: TestStatus) { + let Some((_, info)) = self + .address_candidates + .iter_mut() + .find(|(_, i)| i.is_pending_with_nonce(nonce) || i.is_received_with_nonce(nonce)) + else { + return; + }; + + info.status = new_status; + } + + // FIXME: We don't want test-only APIs in our public API. + #[doc(hidden)] + pub fn validate_addr(&mut self, addr: &Multiaddr) { + if let Some(info) = self.address_candidates.get_mut(addr) { + info.status = TestStatus::Received(self.rng.next_u64()); + } + } +} + +impl Default for Behaviour { + fn default() -> Self { + Self::new(OsRng, Config::default()) + } +} + +pub struct Error { + pub(crate) inner: dial_request::DialBackError, +} + +impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + Display::fmt(&self.inner, f) + } +} + +impl Debug for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + Debug::fmt(&self.inner, f) + } +} + +#[derive(Debug)] +pub struct Event { + /// The address that was selected for testing. + pub tested_addr: Multiaddr, + /// The amount of data that was sent to the server. + /// Is 0 if it wasn't necessary to send any data. + /// Otherwise it's a number between 30.000 and 100.000. + pub bytes_sent: usize, + /// The peer id of the server that was selected for testing. + pub server: PeerId, + /// The result of the test. If the test was successful, this is `Ok(())`. + /// Otherwise it's an error. + pub result: Result<(), Error>, +} + +struct ConnectionInfo { + peer_id: PeerId, + supports_autonat: bool, +} + +#[derive(Copy, Clone, Default)] +struct AddressInfo { + score: usize, + status: TestStatus, +} + +impl AddressInfo { + fn is_pending_with_nonce(&self, nonce: Nonce) -> bool { + match self.status { + TestStatus::Pending(c) => c == nonce, + _ => false, + } + } + + fn is_received_with_nonce(&self, nonce: Nonce) -> bool { + match self.status { + TestStatus::Received(c) => c == nonce, + _ => false, + } + } +} + +#[derive(Clone, Copy, Default, PartialEq)] +enum TestStatus { + #[default] + Untested, + Pending(Nonce), + Failed, + Received(Nonce), +} diff --git a/protocols/autonat/src/v2/client/handler.rs b/protocols/autonat/src/v2/client/handler.rs new file mode 100644 index 00000000000..e526c2fb44c --- /dev/null +++ b/protocols/autonat/src/v2/client/handler.rs @@ -0,0 +1,2 @@ +pub(crate) mod dial_back; +pub(crate) mod dial_request; diff --git a/protocols/autonat/src/v2/client/handler/dial_back.rs b/protocols/autonat/src/v2/client/handler/dial_back.rs new file mode 100644 index 00000000000..b94580e69ba --- /dev/null +++ b/protocols/autonat/src/v2/client/handler/dial_back.rs @@ -0,0 +1,141 @@ +use std::{ + io, + task::{Context, Poll}, + time::Duration, +}; + +use futures::channel::oneshot; +use futures_bounded::StreamSet; +use libp2p_core::upgrade::{DeniedUpgrade, ReadyUpgrade}; +use libp2p_swarm::{ + handler::{ConnectionEvent, FullyNegotiatedInbound, ListenUpgradeError}, + ConnectionHandler, ConnectionHandlerEvent, StreamProtocol, SubstreamProtocol, +}; +use void::Void; + +use crate::v2::{protocol, Nonce, DIAL_BACK_PROTOCOL}; + +pub struct Handler { + inbound: StreamSet>, +} + +impl Handler { + pub(crate) fn new() -> Self { + Self { + inbound: StreamSet::new(Duration::from_secs(5), 2), + } + } +} + +impl ConnectionHandler for Handler { + type FromBehaviour = Void; + type ToBehaviour = IncomingNonce; + type InboundProtocol = ReadyUpgrade; + type OutboundProtocol = DeniedUpgrade; + type InboundOpenInfo = (); + type OutboundOpenInfo = (); + + fn listen_protocol(&self) -> SubstreamProtocol { + SubstreamProtocol::new(ReadyUpgrade::new(DIAL_BACK_PROTOCOL), ()) + } + + fn poll( + &mut self, + cx: &mut Context<'_>, + ) -> Poll< + ConnectionHandlerEvent, + > { + loop { + match self.inbound.poll_next_unpin(cx) { + Poll::Pending => return Poll::Pending, + Poll::Ready(None) => continue, + Poll::Ready(Some(Err(err))) => { + tracing::debug!("Stream timed out: {err}"); + continue; + } + Poll::Ready(Some(Ok(Err(err)))) => { + tracing::debug!("Dial back handler failed with: {err:?}"); + continue; + } + Poll::Ready(Some(Ok(Ok(incoming_nonce)))) => { + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(incoming_nonce)); + } + } + } + } + + fn on_behaviour_event(&mut self, _event: Self::FromBehaviour) {} + + fn on_connection_event( + &mut self, + event: ConnectionEvent< + Self::InboundProtocol, + Self::OutboundProtocol, + Self::InboundOpenInfo, + Self::OutboundOpenInfo, + >, + ) { + match event { + ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { + protocol, .. + }) => { + if self.inbound.try_push(perform_dial_back(protocol)).is_err() { + tracing::warn!("Dial back request dropped, too many requests in flight"); + } + } + ConnectionEvent::ListenUpgradeError(ListenUpgradeError { error, .. }) => { + void::unreachable(error); + } + _ => {} + } + } +} + +struct State { + stream: libp2p_swarm::Stream, + oneshot: Option>>, +} + +#[derive(Debug)] +pub struct IncomingNonce { + pub nonce: Nonce, + pub sender: oneshot::Sender>, +} + +fn perform_dial_back( + stream: libp2p_swarm::Stream, +) -> impl futures::Stream> { + let state = State { + stream, + oneshot: None, + }; + futures::stream::unfold(state, |mut state| async move { + if let Some(ref mut receiver) = state.oneshot { + match receiver.await { + Ok(Ok(())) => {} + Ok(Err(e)) => return Some((Err(e), state)), + Err(_) => { + return Some(( + Err(io::Error::new(io::ErrorKind::Other, "Sender got cancelled")), + state, + )); + } + } + if let Err(e) = protocol::dial_back_response(&mut state.stream).await { + return Some((Err(e), state)); + } + return None; + } + + let nonce = match protocol::recv_dial_back(&mut state.stream).await { + Ok(nonce) => nonce, + Err(err) => { + return Some((Err(err), state)); + } + }; + + let (sender, receiver) = oneshot::channel(); + state.oneshot = Some(receiver); + Some((Ok(IncomingNonce { nonce, sender }), state)) + }) +} diff --git a/protocols/autonat/src/v2/client/handler/dial_request.rs b/protocols/autonat/src/v2/client/handler/dial_request.rs new file mode 100644 index 00000000000..9d2df8ee6b4 --- /dev/null +++ b/protocols/autonat/src/v2/client/handler/dial_request.rs @@ -0,0 +1,343 @@ +use futures::{channel::oneshot, AsyncWrite}; +use futures_bounded::FuturesMap; +use libp2p_core::{ + upgrade::{DeniedUpgrade, ReadyUpgrade}, + Multiaddr, +}; + +use libp2p_swarm::{ + handler::{ + ConnectionEvent, DialUpgradeError, FullyNegotiatedOutbound, OutboundUpgradeSend, + ProtocolsChange, + }, + ConnectionHandler, ConnectionHandlerEvent, Stream, StreamProtocol, StreamUpgradeError, + SubstreamProtocol, +}; +use std::{ + collections::VecDeque, + io, + iter::{once, repeat}, + task::{Context, Poll}, + time::Duration, +}; + +use crate::v2::{ + generated::structs::{mod_DialResponse::ResponseStatus, DialStatus}, + protocol::{ + Coder, DialDataRequest, DialDataResponse, DialRequest, Response, + DATA_FIELD_LEN_UPPER_BOUND, DATA_LEN_LOWER_BOUND, DATA_LEN_UPPER_BOUND, + }, + Nonce, DIAL_REQUEST_PROTOCOL, +}; + +#[derive(Debug)] +pub enum ToBehaviour { + TestOutcome { + nonce: Nonce, + outcome: Result<(Multiaddr, usize), Error>, + }, + PeerHasServerSupport, +} + +#[derive(thiserror::Error, Debug)] +pub enum Error { + #[error("Address is not reachable: {error}")] + AddressNotReachable { + address: Multiaddr, + bytes_sent: usize, + error: DialBackError, + }, + #[error("Peer does not support AutoNAT dial-request protocol")] + UnsupportedProtocol, + #[error("IO error: {0}")] + Io(io::Error), +} + +impl From for Error { + fn from(value: io::Error) -> Self { + Self::Io(value) + } +} + +#[derive(thiserror::Error, Debug)] +pub enum DialBackError { + #[error("server failed to establish a connection")] + NoConnection, + #[error("dial back stream failed")] + StreamFailed, +} + +pub struct Handler { + queued_events: VecDeque< + ConnectionHandlerEvent< + ::OutboundProtocol, + ::OutboundOpenInfo, + ::ToBehaviour, + >, + >, + outbound: FuturesMap>, + queued_streams: VecDeque< + oneshot::Sender< + Result< + Stream, + StreamUpgradeError< as OutboundUpgradeSend>::Error>, + >, + >, + >, +} + +impl Handler { + pub(crate) fn new() -> Self { + Self { + queued_events: VecDeque::new(), + outbound: FuturesMap::new(Duration::from_secs(10), 10), + queued_streams: VecDeque::default(), + } + } + + fn perform_request(&mut self, req: DialRequest) { + let (tx, rx) = oneshot::channel(); + self.queued_streams.push_back(tx); + self.queued_events + .push_back(ConnectionHandlerEvent::OutboundSubstreamRequest { + protocol: SubstreamProtocol::new(ReadyUpgrade::new(DIAL_REQUEST_PROTOCOL), ()), + }); + if self + .outbound + .try_push(req.nonce, start_stream_handle(req, rx)) + .is_err() + { + tracing::debug!("Dial request dropped, too many requests in flight"); + } + } +} + +impl ConnectionHandler for Handler { + type FromBehaviour = DialRequest; + type ToBehaviour = ToBehaviour; + type InboundProtocol = DeniedUpgrade; + type OutboundProtocol = ReadyUpgrade; + type InboundOpenInfo = (); + type OutboundOpenInfo = (); + + fn listen_protocol(&self) -> SubstreamProtocol { + SubstreamProtocol::new(DeniedUpgrade, ()) + } + + fn poll( + &mut self, + cx: &mut Context<'_>, + ) -> Poll< + ConnectionHandlerEvent, + > { + if let Some(event) = self.queued_events.pop_front() { + return Poll::Ready(event); + } + + match self.outbound.poll_unpin(cx) { + Poll::Ready((nonce, Ok(outcome))) => { + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + ToBehaviour::TestOutcome { nonce, outcome }, + )) + } + Poll::Ready((nonce, Err(_))) => { + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + ToBehaviour::TestOutcome { + nonce, + outcome: Err(Error::Io(io::ErrorKind::TimedOut.into())), + }, + )); + } + Poll::Pending => {} + } + + Poll::Pending + } + + fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + self.perform_request(event); + } + + fn on_connection_event( + &mut self, + event: ConnectionEvent< + Self::InboundProtocol, + Self::OutboundProtocol, + Self::InboundOpenInfo, + Self::OutboundOpenInfo, + >, + ) { + match event { + ConnectionEvent::DialUpgradeError(DialUpgradeError { error, .. }) => { + tracing::debug!("Dial request failed: {}", error); + match self.queued_streams.pop_front() { + Some(stream_tx) => { + let _ = stream_tx.send(Err(error)); + } + None => { + tracing::warn!( + "Opened unexpected substream without a pending dial request" + ); + } + } + } + ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { + protocol, .. + }) => match self.queued_streams.pop_front() { + Some(stream_tx) => { + if stream_tx.send(Ok(protocol)).is_err() { + tracing::debug!("Failed to send stream to dead handler"); + } + } + None => { + tracing::warn!("Opened unexpected substream without a pending dial request"); + } + }, + ConnectionEvent::RemoteProtocolsChange(ProtocolsChange::Added(mut added)) => { + if added.any(|p| p.as_ref() == DIAL_REQUEST_PROTOCOL) { + self.queued_events + .push_back(ConnectionHandlerEvent::NotifyBehaviour( + ToBehaviour::PeerHasServerSupport, + )); + } + } + _ => {} + } + } +} + +async fn start_stream_handle( + req: DialRequest, + stream_recv: oneshot::Receiver>>, +) -> Result<(Multiaddr, usize), Error> { + let stream = stream_recv + .await + .map_err(|_| io::Error::from(io::ErrorKind::BrokenPipe))? + .map_err(|e| match e { + StreamUpgradeError::NegotiationFailed => Error::UnsupportedProtocol, + StreamUpgradeError::Timeout => Error::Io(io::ErrorKind::TimedOut.into()), + StreamUpgradeError::Apply(v) => void::unreachable(v), + StreamUpgradeError::Io(e) => Error::Io(e), + })?; + + let mut coder = Coder::new(stream); + coder.send(req.clone()).await?; + + let (res, bytes_sent) = match coder.next().await? { + Response::Data(DialDataRequest { + addr_idx, + num_bytes, + }) => { + if addr_idx >= req.addrs.len() { + return Err(Error::Io(io::Error::new( + io::ErrorKind::InvalidInput, + "address index out of bounds", + ))); + } + if !(DATA_LEN_LOWER_BOUND..=DATA_LEN_UPPER_BOUND).contains(&num_bytes) { + return Err(Error::Io(io::Error::new( + io::ErrorKind::InvalidInput, + "requested bytes out of bounds", + ))); + } + + send_aap_data(&mut coder, num_bytes).await?; + + let Response::Dial(dial_response) = coder.next().await? else { + return Err(Error::Io(io::Error::new( + io::ErrorKind::InvalidInput, + "expected message", + ))); + }; + + (dial_response, num_bytes) + } + Response::Dial(dial_response) => (dial_response, 0), + }; + match coder.close().await { + Ok(_) => {} + Err(err) => { + if err.kind() == io::ErrorKind::ConnectionReset { + // The AutoNAT server may have already closed the stream (this is normal because the probe is finished), in this case we have this error: + // Err(Custom { kind: ConnectionReset, error: Stopped(0) }) + // so we silently ignore this error + } else { + return Err(err.into()); + } + } + } + + match res.status { + ResponseStatus::E_REQUEST_REJECTED => { + return Err(Error::Io(io::Error::new( + io::ErrorKind::Other, + "server rejected request", + ))) + } + ResponseStatus::E_DIAL_REFUSED => { + return Err(Error::Io(io::Error::new( + io::ErrorKind::Other, + "server refused dial", + ))) + } + ResponseStatus::E_INTERNAL_ERROR => { + return Err(Error::Io(io::Error::new( + io::ErrorKind::Other, + "server encountered internal error", + ))) + } + ResponseStatus::OK => {} + } + + let tested_address = req + .addrs + .get(res.addr_idx) + .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "address index out of bounds"))? + .clone(); + + match res.dial_status { + DialStatus::UNUSED => { + return Err(Error::Io(io::Error::new( + io::ErrorKind::InvalidInput, + "unexpected message", + ))) + } + DialStatus::E_DIAL_ERROR => { + return Err(Error::AddressNotReachable { + address: tested_address, + bytes_sent, + error: DialBackError::NoConnection, + }) + } + DialStatus::E_DIAL_BACK_ERROR => { + return Err(Error::AddressNotReachable { + address: tested_address, + bytes_sent, + error: DialBackError::StreamFailed, + }) + } + DialStatus::OK => {} + } + + Ok((tested_address, bytes_sent)) +} + +async fn send_aap_data(stream: &mut Coder, num_bytes: usize) -> io::Result<()> +where + I: AsyncWrite + Unpin, +{ + let count_full = num_bytes / DATA_FIELD_LEN_UPPER_BOUND; + let partial_len = num_bytes % DATA_FIELD_LEN_UPPER_BOUND; + for req in repeat(DATA_FIELD_LEN_UPPER_BOUND) + .take(count_full) + .chain(once(partial_len)) + .filter(|e| *e > 0) + .map(|data_count| { + DialDataResponse::new(data_count).expect("data count is unexpectedly too big") + }) + { + stream.send(req).await?; + } + + Ok(()) +} diff --git a/protocols/autonat/src/v2/generated/mod.rs b/protocols/autonat/src/v2/generated/mod.rs new file mode 100644 index 00000000000..e52c5a80bc0 --- /dev/null +++ b/protocols/autonat/src/v2/generated/mod.rs @@ -0,0 +1,2 @@ +// Automatically generated mod.rs +pub mod structs; diff --git a/protocols/autonat/src/v2/generated/structs.proto b/protocols/autonat/src/v2/generated/structs.proto new file mode 100644 index 00000000000..d298f43d047 --- /dev/null +++ b/protocols/autonat/src/v2/generated/structs.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +package structs; + +message Message { + oneof msg { + DialRequest dialRequest = 1; + DialResponse dialResponse = 2; + DialDataRequest dialDataRequest = 3; + DialDataResponse dialDataResponse = 4; + } +} + +message DialRequest { + repeated bytes addrs = 1; + fixed64 nonce = 2; +} + +message DialDataRequest { + uint32 addrIdx = 1; + uint64 numBytes = 2; +} + +enum DialStatus { + UNUSED = 0; + E_DIAL_ERROR = 100; + E_DIAL_BACK_ERROR = 101; + OK = 200; +} + +message DialResponse { + enum ResponseStatus { + E_INTERNAL_ERROR = 0; + E_REQUEST_REJECTED = 100; + E_DIAL_REFUSED = 101; + OK = 200; + } + + ResponseStatus status = 1; + uint32 addrIdx = 2; + DialStatus dialStatus = 3; +} + +message DialDataResponse { bytes data = 1; } + +message DialBack { fixed64 nonce = 1; } + +message DialBackResponse { + enum DialBackStatus { + OK = 0; + } + + DialBackStatus status = 1; +} diff --git a/protocols/autonat/src/v2/generated/structs.rs b/protocols/autonat/src/v2/generated/structs.rs new file mode 100644 index 00000000000..e188adb8a42 --- /dev/null +++ b/protocols/autonat/src/v2/generated/structs.rs @@ -0,0 +1,403 @@ +// Automatically generated rust module for 'structs.proto' file + +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(unused_imports)] +#![allow(unknown_lints)] +#![allow(clippy::all)] +#![cfg_attr(rustfmt, rustfmt_skip)] + + +use quick_protobuf::{MessageInfo, MessageRead, MessageWrite, BytesReader, Writer, WriterBackend, Result}; +use quick_protobuf::sizeofs::*; +use super::*; + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum DialStatus { + UNUSED = 0, + E_DIAL_ERROR = 100, + E_DIAL_BACK_ERROR = 101, + OK = 200, +} + +impl Default for DialStatus { + fn default() -> Self { + DialStatus::UNUSED + } +} + +impl From for DialStatus { + fn from(i: i32) -> Self { + match i { + 0 => DialStatus::UNUSED, + 100 => DialStatus::E_DIAL_ERROR, + 101 => DialStatus::E_DIAL_BACK_ERROR, + 200 => DialStatus::OK, + _ => Self::default(), + } + } +} + +impl<'a> From<&'a str> for DialStatus { + fn from(s: &'a str) -> Self { + match s { + "UNUSED" => DialStatus::UNUSED, + "E_DIAL_ERROR" => DialStatus::E_DIAL_ERROR, + "E_DIAL_BACK_ERROR" => DialStatus::E_DIAL_BACK_ERROR, + "OK" => DialStatus::OK, + _ => Self::default(), + } + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct Message { + pub msg: structs::mod_Message::OneOfmsg, +} + +impl<'a> MessageRead<'a> for Message { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.msg = structs::mod_Message::OneOfmsg::dialRequest(r.read_message::(bytes)?), + Ok(18) => msg.msg = structs::mod_Message::OneOfmsg::dialResponse(r.read_message::(bytes)?), + Ok(26) => msg.msg = structs::mod_Message::OneOfmsg::dialDataRequest(r.read_message::(bytes)?), + Ok(34) => msg.msg = structs::mod_Message::OneOfmsg::dialDataResponse(r.read_message::(bytes)?), + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for Message { + fn get_size(&self) -> usize { + 0 + + match self.msg { + structs::mod_Message::OneOfmsg::dialRequest(ref m) => 1 + sizeof_len((m).get_size()), + structs::mod_Message::OneOfmsg::dialResponse(ref m) => 1 + sizeof_len((m).get_size()), + structs::mod_Message::OneOfmsg::dialDataRequest(ref m) => 1 + sizeof_len((m).get_size()), + structs::mod_Message::OneOfmsg::dialDataResponse(ref m) => 1 + sizeof_len((m).get_size()), + structs::mod_Message::OneOfmsg::None => 0, + } } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + match self.msg { structs::mod_Message::OneOfmsg::dialRequest(ref m) => { w.write_with_tag(10, |w| w.write_message(m))? }, + structs::mod_Message::OneOfmsg::dialResponse(ref m) => { w.write_with_tag(18, |w| w.write_message(m))? }, + structs::mod_Message::OneOfmsg::dialDataRequest(ref m) => { w.write_with_tag(26, |w| w.write_message(m))? }, + structs::mod_Message::OneOfmsg::dialDataResponse(ref m) => { w.write_with_tag(34, |w| w.write_message(m))? }, + structs::mod_Message::OneOfmsg::None => {}, + } Ok(()) + } +} + +pub mod mod_Message { + +use super::*; + +#[derive(Debug, PartialEq, Clone)] +pub enum OneOfmsg { + dialRequest(structs::DialRequest), + dialResponse(structs::DialResponse), + dialDataRequest(structs::DialDataRequest), + dialDataResponse(structs::DialDataResponse), + None, +} + +impl Default for OneOfmsg { + fn default() -> Self { + OneOfmsg::None + } +} + +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct DialRequest { + pub addrs: Vec>, + pub nonce: u64, +} + +impl<'a> MessageRead<'a> for DialRequest { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.addrs.push(r.read_bytes(bytes)?.to_owned()), + Ok(17) => msg.nonce = r.read_fixed64(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for DialRequest { + fn get_size(&self) -> usize { + 0 + + self.addrs.iter().map(|s| 1 + sizeof_len((s).len())).sum::() + + if self.nonce == 0u64 { 0 } else { 1 + 8 } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + for s in &self.addrs { w.write_with_tag(10, |w| w.write_bytes(&**s))?; } + if self.nonce != 0u64 { w.write_with_tag(17, |w| w.write_fixed64(*&self.nonce))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct DialDataRequest { + pub addrIdx: u32, + pub numBytes: u64, +} + +impl<'a> MessageRead<'a> for DialDataRequest { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.addrIdx = r.read_uint32(bytes)?, + Ok(16) => msg.numBytes = r.read_uint64(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for DialDataRequest { + fn get_size(&self) -> usize { + 0 + + if self.addrIdx == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.addrIdx) as u64) } + + if self.numBytes == 0u64 { 0 } else { 1 + sizeof_varint(*(&self.numBytes) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.addrIdx != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.addrIdx))?; } + if self.numBytes != 0u64 { w.write_with_tag(16, |w| w.write_uint64(*&self.numBytes))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct DialResponse { + pub status: structs::mod_DialResponse::ResponseStatus, + pub addrIdx: u32, + pub dialStatus: structs::DialStatus, +} + +impl<'a> MessageRead<'a> for DialResponse { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.status = r.read_enum(bytes)?, + Ok(16) => msg.addrIdx = r.read_uint32(bytes)?, + Ok(24) => msg.dialStatus = r.read_enum(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for DialResponse { + fn get_size(&self) -> usize { + 0 + + if self.status == structs::mod_DialResponse::ResponseStatus::E_INTERNAL_ERROR { 0 } else { 1 + sizeof_varint(*(&self.status) as u64) } + + if self.addrIdx == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.addrIdx) as u64) } + + if self.dialStatus == structs::DialStatus::UNUSED { 0 } else { 1 + sizeof_varint(*(&self.dialStatus) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.status != structs::mod_DialResponse::ResponseStatus::E_INTERNAL_ERROR { w.write_with_tag(8, |w| w.write_enum(*&self.status as i32))?; } + if self.addrIdx != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.addrIdx))?; } + if self.dialStatus != structs::DialStatus::UNUSED { w.write_with_tag(24, |w| w.write_enum(*&self.dialStatus as i32))?; } + Ok(()) + } +} + +pub mod mod_DialResponse { + + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum ResponseStatus { + E_INTERNAL_ERROR = 0, + E_REQUEST_REJECTED = 100, + E_DIAL_REFUSED = 101, + OK = 200, +} + +impl Default for ResponseStatus { + fn default() -> Self { + ResponseStatus::E_INTERNAL_ERROR + } +} + +impl From for ResponseStatus { + fn from(i: i32) -> Self { + match i { + 0 => ResponseStatus::E_INTERNAL_ERROR, + 100 => ResponseStatus::E_REQUEST_REJECTED, + 101 => ResponseStatus::E_DIAL_REFUSED, + 200 => ResponseStatus::OK, + _ => Self::default(), + } + } +} + +impl<'a> From<&'a str> for ResponseStatus { + fn from(s: &'a str) -> Self { + match s { + "E_INTERNAL_ERROR" => ResponseStatus::E_INTERNAL_ERROR, + "E_REQUEST_REJECTED" => ResponseStatus::E_REQUEST_REJECTED, + "E_DIAL_REFUSED" => ResponseStatus::E_DIAL_REFUSED, + "OK" => ResponseStatus::OK, + _ => Self::default(), + } + } +} + +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct DialDataResponse { + pub data: Vec, +} + +impl<'a> MessageRead<'a> for DialDataResponse { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(10) => msg.data = r.read_bytes(bytes)?.to_owned(), + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for DialDataResponse { + fn get_size(&self) -> usize { + 0 + + if self.data.is_empty() { 0 } else { 1 + sizeof_len((&self.data).len()) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if !self.data.is_empty() { w.write_with_tag(10, |w| w.write_bytes(&**&self.data))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct DialBack { + pub nonce: u64, +} + +impl<'a> MessageRead<'a> for DialBack { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(9) => msg.nonce = r.read_fixed64(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for DialBack { + fn get_size(&self) -> usize { + 0 + + if self.nonce == 0u64 { 0 } else { 1 + 8 } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.nonce != 0u64 { w.write_with_tag(9, |w| w.write_fixed64(*&self.nonce))?; } + Ok(()) + } +} + +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Debug, Default, PartialEq, Clone)] +pub struct DialBackResponse { + pub status: structs::mod_DialBackResponse::DialBackStatus, +} + +impl<'a> MessageRead<'a> for DialBackResponse { + fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result { + let mut msg = Self::default(); + while !r.is_eof() { + match r.next_tag(bytes) { + Ok(8) => msg.status = r.read_enum(bytes)?, + Ok(t) => { r.read_unknown(bytes, t)?; } + Err(e) => return Err(e), + } + } + Ok(msg) + } +} + +impl MessageWrite for DialBackResponse { + fn get_size(&self) -> usize { + 0 + + if self.status == structs::mod_DialBackResponse::DialBackStatus::OK { 0 } else { 1 + sizeof_varint(*(&self.status) as u64) } + } + + fn write_message(&self, w: &mut Writer) -> Result<()> { + if self.status != structs::mod_DialBackResponse::DialBackStatus::OK { w.write_with_tag(8, |w| w.write_enum(*&self.status as i32))?; } + Ok(()) + } +} + +pub mod mod_DialBackResponse { + + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum DialBackStatus { + OK = 0, +} + +impl Default for DialBackStatus { + fn default() -> Self { + DialBackStatus::OK + } +} + +impl From for DialBackStatus { + fn from(i: i32) -> Self { + match i { + 0 => DialBackStatus::OK, + _ => Self::default(), + } + } +} + +impl<'a> From<&'a str> for DialBackStatus { + fn from(s: &'a str) -> Self { + match s { + "OK" => DialBackStatus::OK, + _ => Self::default(), + } + } +} + +} + diff --git a/protocols/autonat/src/v2/protocol.rs b/protocols/autonat/src/v2/protocol.rs new file mode 100644 index 00000000000..4077fd65f5d --- /dev/null +++ b/protocols/autonat/src/v2/protocol.rs @@ -0,0 +1,337 @@ +// change to quick-protobuf-codec + +use std::io; +use std::io::ErrorKind; + +use asynchronous_codec::{Framed, FramedRead, FramedWrite}; + +use futures::{AsyncRead, AsyncWrite, SinkExt, StreamExt}; +use libp2p_core::Multiaddr; + +use quick_protobuf_codec::Codec; +use rand::Rng; + +use crate::v2::{generated::structs as proto, Nonce}; + +const REQUEST_MAX_SIZE: usize = 4104; +pub(super) const DATA_LEN_LOWER_BOUND: usize = 30_000u32 as usize; +pub(super) const DATA_LEN_UPPER_BOUND: usize = 100_000u32 as usize; +pub(super) const DATA_FIELD_LEN_UPPER_BOUND: usize = 4096; + +fn new_io_invalid_data_err(msg: impl Into) -> io::Error { + io::Error::new(io::ErrorKind::InvalidData, msg.into()) +} + +pub(crate) struct Coder { + inner: Framed>, +} + +impl Coder +where + I: AsyncWrite + AsyncRead + Unpin, +{ + pub(crate) fn new(io: I) -> Self { + Self { + inner: Framed::new(io, Codec::new(REQUEST_MAX_SIZE)), + } + } + pub(crate) async fn close(mut self) -> io::Result<()> { + self.inner.close().await?; + Ok(()) + } +} + +impl Coder +where + I: AsyncRead + Unpin, +{ + pub(crate) async fn next(&mut self) -> io::Result + where + proto::Message: TryInto, + io::Error: From, + { + Ok(self.next_msg().await?.try_into()?) + } + + async fn next_msg(&mut self) -> io::Result { + self.inner + .next() + .await + .ok_or(io::Error::new( + ErrorKind::UnexpectedEof, + "no request to read", + ))? + .map_err(|e| io::Error::new(ErrorKind::InvalidData, e)) + } +} + +impl Coder +where + I: AsyncWrite + Unpin, +{ + pub(crate) async fn send(&mut self, msg: M) -> io::Result<()> + where + M: Into, + { + self.inner.send(msg.into()).await?; + Ok(()) + } +} + +#[derive(Debug, Clone, PartialEq)] +pub(crate) enum Request { + Dial(DialRequest), + Data(DialDataResponse), +} + +impl From for proto::Message { + fn from(val: DialRequest) -> Self { + let addrs = val.addrs.iter().map(|e| e.to_vec()).collect(); + let nonce = val.nonce; + + proto::Message { + msg: proto::mod_Message::OneOfmsg::dialRequest(proto::DialRequest { addrs, nonce }), + } + } +} + +impl From for proto::Message { + fn from(val: DialDataResponse) -> Self { + debug_assert!( + val.data_count <= DATA_FIELD_LEN_UPPER_BOUND, + "data_count too large" + ); + proto::Message { + msg: proto::mod_Message::OneOfmsg::dialDataResponse(proto::DialDataResponse { + data: vec![0; val.data_count], // One could use Cow::Borrowed here, but it will require a modification of the generated code and that will fail the CI + }), + } + } +} + +#[derive(Debug, Clone, PartialEq)] +pub struct DialRequest { + pub(crate) addrs: Vec, + pub(crate) nonce: u64, +} + +#[derive(Debug, Clone, PartialEq)] +pub(crate) struct DialDataResponse { + data_count: usize, +} + +impl DialDataResponse { + pub(crate) fn new(data_count: usize) -> Option { + if data_count <= DATA_FIELD_LEN_UPPER_BOUND { + Some(Self { data_count }) + } else { + None + } + } + + pub(crate) fn get_data_count(&self) -> usize { + self.data_count + } +} + +impl TryFrom for Request { + type Error = io::Error; + + fn try_from(msg: proto::Message) -> Result { + match msg.msg { + proto::mod_Message::OneOfmsg::dialRequest(proto::DialRequest { addrs, nonce }) => { + let addrs = addrs + .into_iter() + .map(|e| e.to_vec()) + .map(|e| { + Multiaddr::try_from(e).map_err(|err| { + new_io_invalid_data_err(format!("invalid multiaddr: {}", err)) + }) + }) + .collect::, io::Error>>()?; + Ok(Self::Dial(DialRequest { addrs, nonce })) + } + proto::mod_Message::OneOfmsg::dialDataResponse(proto::DialDataResponse { data }) => { + let data_count = data.len(); + Ok(Self::Data(DialDataResponse { data_count })) + } + _ => Err(new_io_invalid_data_err( + "expected dialResponse or dialDataRequest", + )), + } + } +} + +#[derive(Debug, Clone)] +pub(crate) enum Response { + Dial(DialResponse), + Data(DialDataRequest), +} + +#[derive(Debug, Clone)] +pub(crate) struct DialDataRequest { + pub(crate) addr_idx: usize, + pub(crate) num_bytes: usize, +} + +#[derive(Debug, Clone)] +pub(crate) struct DialResponse { + pub(crate) status: proto::mod_DialResponse::ResponseStatus, + pub(crate) addr_idx: usize, + pub(crate) dial_status: proto::DialStatus, +} + +impl TryFrom for Response { + type Error = io::Error; + + fn try_from(msg: proto::Message) -> Result { + match msg.msg { + proto::mod_Message::OneOfmsg::dialResponse(proto::DialResponse { + status, + addrIdx, + dialStatus, + }) => Ok(Response::Dial(DialResponse { + status, + addr_idx: addrIdx as usize, + dial_status: dialStatus, + })), + proto::mod_Message::OneOfmsg::dialDataRequest(proto::DialDataRequest { + addrIdx, + numBytes, + }) => Ok(Self::Data(DialDataRequest { + addr_idx: addrIdx as usize, + num_bytes: numBytes as usize, + })), + _ => Err(new_io_invalid_data_err( + "invalid message type, expected dialResponse or dialDataRequest", + )), + } + } +} + +impl From for proto::Message { + fn from(val: Response) -> Self { + match val { + Response::Dial(DialResponse { + status, + addr_idx, + dial_status, + }) => proto::Message { + msg: proto::mod_Message::OneOfmsg::dialResponse(proto::DialResponse { + status, + addrIdx: addr_idx as u32, + dialStatus: dial_status, + }), + }, + Response::Data(DialDataRequest { + addr_idx, + num_bytes, + }) => proto::Message { + msg: proto::mod_Message::OneOfmsg::dialDataRequest(proto::DialDataRequest { + addrIdx: addr_idx as u32, + numBytes: num_bytes as u64, + }), + }, + } + } +} + +impl DialDataRequest { + pub(crate) fn from_rng(addr_idx: usize, mut rng: R) -> Self { + let num_bytes = rng.gen_range(DATA_LEN_LOWER_BOUND..=DATA_LEN_UPPER_BOUND); + Self { + addr_idx, + num_bytes, + } + } +} + +const DIAL_BACK_MAX_SIZE: usize = 10; + +pub(crate) async fn dial_back(stream: impl AsyncWrite + Unpin, nonce: Nonce) -> io::Result<()> { + let msg = proto::DialBack { nonce }; + let mut framed = FramedWrite::new(stream, Codec::::new(DIAL_BACK_MAX_SIZE)); + + framed + .send(msg) + .await + .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; + + Ok(()) +} + +pub(crate) async fn recv_dial_back(stream: impl AsyncRead + Unpin) -> io::Result { + let framed = &mut FramedRead::new(stream, Codec::::new(DIAL_BACK_MAX_SIZE)); + let proto::DialBack { nonce } = framed + .next() + .await + .ok_or(io::Error::from(io::ErrorKind::UnexpectedEof))??; + Ok(nonce) +} + +pub(crate) async fn dial_back_response(stream: impl AsyncWrite + Unpin) -> io::Result<()> { + let msg = proto::DialBackResponse { + status: proto::mod_DialBackResponse::DialBackStatus::OK, + }; + let mut framed = FramedWrite::new( + stream, + Codec::::new(DIAL_BACK_MAX_SIZE), + ); + framed + .send(msg) + .await + .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; + + Ok(()) +} + +pub(crate) async fn recv_dial_back_response( + stream: impl AsyncRead + AsyncWrite + Unpin, +) -> io::Result<()> { + let framed = &mut FramedRead::new( + stream, + Codec::::new(DIAL_BACK_MAX_SIZE), + ); + let proto::DialBackResponse { status } = framed + .next() + .await + .ok_or(io::Error::from(io::ErrorKind::UnexpectedEof))??; + + if proto::mod_DialBackResponse::DialBackStatus::OK == status { + Ok(()) + } else { + Err(io::Error::new( + io::ErrorKind::InvalidData, + "invalid dial back response", + )) + } +} + +#[cfg(test)] +mod tests { + use crate::v2::generated::structs::{ + mod_Message::OneOfmsg, DialDataResponse as GenDialDataResponse, Message, + }; + + #[test] + fn message_correct_max_size() { + let message_bytes = quick_protobuf::serialize_into_vec(&Message { + msg: OneOfmsg::dialDataResponse(GenDialDataResponse { + data: vec![0; 4096], + }), + }) + .unwrap(); + assert_eq!(message_bytes.len(), super::REQUEST_MAX_SIZE); + } + + #[test] + fn dial_back_correct_size() { + let dial_back = super::proto::DialBack { nonce: 0 }; + let buf = quick_protobuf::serialize_into_vec(&dial_back).unwrap(); + assert!(buf.len() <= super::DIAL_BACK_MAX_SIZE); + + let dial_back_max_nonce = super::proto::DialBack { nonce: u64::MAX }; + let buf = quick_protobuf::serialize_into_vec(&dial_back_max_nonce).unwrap(); + assert!(buf.len() <= super::DIAL_BACK_MAX_SIZE); + } +} diff --git a/protocols/autonat/src/v2/server.rs b/protocols/autonat/src/v2/server.rs new file mode 100644 index 00000000000..25819307784 --- /dev/null +++ b/protocols/autonat/src/v2/server.rs @@ -0,0 +1,5 @@ +mod behaviour; +mod handler; + +pub use behaviour::Behaviour; +pub use behaviour::Event; diff --git a/protocols/autonat/src/v2/server/behaviour.rs b/protocols/autonat/src/v2/server/behaviour.rs new file mode 100644 index 00000000000..5f7b21d165b --- /dev/null +++ b/protocols/autonat/src/v2/server/behaviour.rs @@ -0,0 +1,156 @@ +use std::{ + collections::{HashMap, VecDeque}, + io, + task::{Context, Poll}, +}; + +use crate::v2::server::handler::dial_request::DialBackStatus; +use either::Either; +use libp2p_core::{transport::PortUse, Endpoint, Multiaddr}; +use libp2p_identity::PeerId; +use libp2p_swarm::dial_opts::PeerCondition; +use libp2p_swarm::{ + dial_opts::DialOpts, dummy, ConnectionDenied, ConnectionHandler, ConnectionId, DialFailure, + FromSwarm, NetworkBehaviour, ToSwarm, +}; +use rand_core::{OsRng, RngCore}; + +use crate::v2::server::handler::{ + dial_back, + dial_request::{self, DialBackCommand}, + Handler, +}; + +pub struct Behaviour +where + R: Clone + Send + RngCore + 'static, +{ + dialing_dial_back: HashMap, + pending_events: VecDeque< + ToSwarm< + ::ToSwarm, + <::ConnectionHandler as ConnectionHandler>::FromBehaviour, + >, + >, + rng: R, +} + +impl Default for Behaviour { + fn default() -> Self { + Self::new(OsRng) + } +} + +impl Behaviour +where + R: RngCore + Send + Clone + 'static, +{ + pub fn new(rng: R) -> Self { + Self { + dialing_dial_back: HashMap::new(), + pending_events: VecDeque::new(), + rng, + } + } +} + +impl NetworkBehaviour for Behaviour +where + R: RngCore + Send + Clone + 'static, +{ + type ConnectionHandler = Handler; + + type ToSwarm = Event; + + fn handle_established_inbound_connection( + &mut self, + _connection_id: ConnectionId, + peer: PeerId, + _local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result<::ConnectionHandler, ConnectionDenied> { + Ok(Either::Right(dial_request::Handler::new( + peer, + remote_addr.clone(), + self.rng.clone(), + ))) + } + + fn handle_established_outbound_connection( + &mut self, + connection_id: ConnectionId, + _peer: PeerId, + _addr: &Multiaddr, + _role_override: Endpoint, + _port_use: PortUse, + ) -> Result<::ConnectionHandler, ConnectionDenied> { + Ok(match self.dialing_dial_back.remove(&connection_id) { + Some(cmd) => Either::Left(Either::Left(dial_back::Handler::new(cmd))), + None => Either::Left(Either::Right(dummy::ConnectionHandler)), + }) + } + + fn on_swarm_event(&mut self, event: FromSwarm) { + if let FromSwarm::DialFailure(DialFailure { connection_id, .. }) = event { + if let Some(DialBackCommand { back_channel, .. }) = + self.dialing_dial_back.remove(&connection_id) + { + let dial_back_status = DialBackStatus::DialErr; + let _ = back_channel.send(Err(dial_back_status)); + } + } + } + + fn on_connection_handler_event( + &mut self, + peer_id: PeerId, + _connection_id: ConnectionId, + event: as ConnectionHandler>::ToBehaviour, + ) { + match event { + Either::Left(Either::Left(Ok(_))) => {} + Either::Left(Either::Left(Err(e))) => { + tracing::debug!("dial back error: {e:?}"); + } + Either::Left(Either::Right(v)) => void::unreachable(v), + Either::Right(Either::Left(cmd)) => { + let addr = cmd.addr.clone(); + let opts = DialOpts::peer_id(peer_id) + .addresses(Vec::from([addr])) + .condition(PeerCondition::Always) + .allocate_new_port() + .build(); + let conn_id = opts.connection_id(); + self.dialing_dial_back.insert(conn_id, cmd); + self.pending_events.push_back(ToSwarm::Dial { opts }); + } + Either::Right(Either::Right(status_update)) => self + .pending_events + .push_back(ToSwarm::GenerateEvent(status_update)), + } + } + + fn poll( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll as ConnectionHandler>::FromBehaviour>> { + if let Some(event) = self.pending_events.pop_front() { + return Poll::Ready(event); + } + Poll::Pending + } +} + +#[derive(Debug)] +pub struct Event { + /// All address that were submitted for testing. + pub all_addrs: Vec, + /// The address that was eventually tested. + pub tested_addr: Multiaddr, + /// The peer id of the client that submitted addresses for testing. + pub client: PeerId, + /// The amount of data that was requested by the server and was transmitted. + pub data_amount: usize, + /// The result of the test. + pub result: Result<(), io::Error>, +} diff --git a/protocols/autonat/src/v2/server/handler.rs b/protocols/autonat/src/v2/server/handler.rs new file mode 100644 index 00000000000..ffdad69c86f --- /dev/null +++ b/protocols/autonat/src/v2/server/handler.rs @@ -0,0 +1,8 @@ +use either::Either; +use libp2p_swarm::dummy; + +pub(crate) mod dial_back; +pub(crate) mod dial_request; + +pub(crate) type Handler = + Either, dial_request::Handler>; diff --git a/protocols/autonat/src/v2/server/handler/dial_back.rs b/protocols/autonat/src/v2/server/handler/dial_back.rs new file mode 100644 index 00000000000..3cacd4ff32b --- /dev/null +++ b/protocols/autonat/src/v2/server/handler/dial_back.rs @@ -0,0 +1,140 @@ +use std::{ + convert::identity, + io, + task::{Context, Poll}, + time::Duration, +}; + +use futures::{AsyncRead, AsyncWrite}; +use futures_bounded::FuturesSet; +use libp2p_core::upgrade::{DeniedUpgrade, ReadyUpgrade}; +use libp2p_swarm::{ + handler::{ConnectionEvent, DialUpgradeError, FullyNegotiatedOutbound}, + ConnectionHandler, ConnectionHandlerEvent, StreamProtocol, StreamUpgradeError, + SubstreamProtocol, +}; + +use crate::v2::{ + protocol::{dial_back, recv_dial_back_response}, + DIAL_BACK_PROTOCOL, +}; + +use super::dial_request::{DialBackCommand, DialBackStatus as DialBackRes}; + +pub(crate) type ToBehaviour = io::Result<()>; + +pub struct Handler { + pending_nonce: Option, + requested_substream_nonce: Option, + outbound: FuturesSet, +} + +impl Handler { + pub(crate) fn new(cmd: DialBackCommand) -> Self { + Self { + pending_nonce: Some(cmd), + requested_substream_nonce: None, + outbound: FuturesSet::new(Duration::from_secs(10), 5), + } + } +} + +impl ConnectionHandler for Handler { + type FromBehaviour = (); + type ToBehaviour = ToBehaviour; + type InboundProtocol = DeniedUpgrade; + type OutboundProtocol = ReadyUpgrade; + type InboundOpenInfo = (); + type OutboundOpenInfo = (); + + fn listen_protocol(&self) -> SubstreamProtocol { + SubstreamProtocol::new(DeniedUpgrade, ()) + } + + fn poll( + &mut self, + cx: &mut Context<'_>, + ) -> Poll< + ConnectionHandlerEvent, + > { + if let Poll::Ready(result) = self.outbound.poll_unpin(cx) { + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( + result + .map_err(|timeout| io::Error::new(io::ErrorKind::TimedOut, timeout)) + .and_then(identity), + )); + } + if let Some(cmd) = self.pending_nonce.take() { + self.requested_substream_nonce = Some(cmd); + return Poll::Ready(ConnectionHandlerEvent::OutboundSubstreamRequest { + protocol: SubstreamProtocol::new(ReadyUpgrade::new(DIAL_BACK_PROTOCOL), ()), + }); + } + Poll::Pending + } + + fn on_behaviour_event(&mut self, _event: Self::FromBehaviour) {} + + fn on_connection_event( + &mut self, + event: ConnectionEvent< + Self::InboundProtocol, + Self::OutboundProtocol, + Self::InboundOpenInfo, + Self::OutboundOpenInfo, + >, + ) { + match event { + ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { + protocol, .. + }) => { + if let Some(cmd) = self.requested_substream_nonce.take() { + if self + .outbound + .try_push(perform_dial_back(protocol, cmd)) + .is_err() + { + tracing::warn!("Dial back dropped, too many requests in flight"); + } + } else { + tracing::warn!("received dial back substream without nonce"); + } + } + ConnectionEvent::DialUpgradeError(DialUpgradeError { + error: StreamUpgradeError::NegotiationFailed | StreamUpgradeError::Timeout, + .. + }) => { + if let Some(cmd) = self.requested_substream_nonce.take() { + let _ = cmd.back_channel.send(Err(DialBackRes::DialBackErr)); + } + } + _ => {} + } + } +} + +async fn perform_dial_back( + mut stream: impl AsyncRead + AsyncWrite + Unpin, + DialBackCommand { + nonce, + back_channel, + .. + }: DialBackCommand, +) -> io::Result<()> { + let res = dial_back(&mut stream, nonce) + .await + .map_err(|_| DialBackRes::DialBackErr) + .map(|_| ()); + + let res = match res { + Ok(()) => recv_dial_back_response(stream) + .await + .map_err(|_| DialBackRes::DialBackErr) + .map(|_| ()), + Err(e) => Err(e), + }; + back_channel + .send(res) + .map_err(|_| io::Error::new(io::ErrorKind::Other, "send error"))?; + Ok(()) +} diff --git a/protocols/autonat/src/v2/server/handler/dial_request.rs b/protocols/autonat/src/v2/server/handler/dial_request.rs new file mode 100644 index 00000000000..9a3729d4ccf --- /dev/null +++ b/protocols/autonat/src/v2/server/handler/dial_request.rs @@ -0,0 +1,332 @@ +use std::{ + io, + task::{Context, Poll}, + time::Duration, +}; + +use either::Either; +use futures::{ + channel::{mpsc, oneshot}, + AsyncRead, AsyncWrite, SinkExt, StreamExt, +}; +use futures_bounded::FuturesSet; +use libp2p_core::{ + upgrade::{DeniedUpgrade, ReadyUpgrade}, + Multiaddr, +}; +use libp2p_identity::PeerId; +use libp2p_swarm::{ + handler::{ConnectionEvent, FullyNegotiatedInbound, ListenUpgradeError}, + ConnectionHandler, ConnectionHandlerEvent, StreamProtocol, SubstreamProtocol, +}; +use rand_core::RngCore; + +use crate::v2::{ + generated::structs::{mod_DialResponse::ResponseStatus, DialStatus}, + protocol::{Coder, DialDataRequest, DialRequest, DialResponse, Request, Response}, + server::behaviour::Event, + Nonce, DIAL_REQUEST_PROTOCOL, +}; + +#[derive(Debug, PartialEq)] +pub(crate) enum DialBackStatus { + /// Failure during dial + DialErr, + /// Failure during dial back + DialBackErr, +} + +#[derive(Debug)] +pub struct DialBackCommand { + pub(crate) addr: Multiaddr, + pub(crate) nonce: Nonce, + pub(crate) back_channel: oneshot::Sender>, +} + +pub struct Handler { + client_id: PeerId, + observed_multiaddr: Multiaddr, + dial_back_cmd_sender: mpsc::Sender, + dial_back_cmd_receiver: mpsc::Receiver, + inbound: FuturesSet, + rng: R, +} + +impl Handler +where + R: RngCore, +{ + pub(crate) fn new(client_id: PeerId, observed_multiaddr: Multiaddr, rng: R) -> Self { + let (dial_back_cmd_sender, dial_back_cmd_receiver) = mpsc::channel(10); + Self { + client_id, + observed_multiaddr, + dial_back_cmd_sender, + dial_back_cmd_receiver, + inbound: FuturesSet::new(Duration::from_secs(10), 10), + rng, + } + } +} + +impl ConnectionHandler for Handler +where + R: RngCore + Send + Clone + 'static, +{ + type FromBehaviour = void::Void; + type ToBehaviour = Either; + type InboundProtocol = ReadyUpgrade; + type OutboundProtocol = DeniedUpgrade; + type InboundOpenInfo = (); + type OutboundOpenInfo = (); + + fn listen_protocol(&self) -> SubstreamProtocol { + SubstreamProtocol::new(ReadyUpgrade::new(DIAL_REQUEST_PROTOCOL), ()) + } + + fn poll( + &mut self, + cx: &mut Context<'_>, + ) -> Poll< + ConnectionHandlerEvent, + > { + loop { + match self.inbound.poll_unpin(cx) { + Poll::Ready(Ok(event)) => { + if let Err(e) = &event.result { + tracing::warn!("inbound request handle failed: {:?}", e); + } + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(Either::Right( + event, + ))); + } + Poll::Ready(Err(e)) => { + tracing::warn!("inbound request handle timed out {e:?}"); + } + Poll::Pending => break, + } + } + if let Poll::Ready(Some(cmd)) = self.dial_back_cmd_receiver.poll_next_unpin(cx) { + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(Either::Left(cmd))); + } + Poll::Pending + } + + fn on_behaviour_event(&mut self, _event: Self::FromBehaviour) {} + + fn on_connection_event( + &mut self, + event: ConnectionEvent< + Self::InboundProtocol, + Self::OutboundProtocol, + Self::InboundOpenInfo, + Self::OutboundOpenInfo, + >, + ) { + match event { + ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { + protocol, .. + }) => { + if self + .inbound + .try_push(handle_request( + protocol, + self.observed_multiaddr.clone(), + self.client_id, + self.dial_back_cmd_sender.clone(), + self.rng.clone(), + )) + .is_err() + { + tracing::warn!( + "failed to push inbound request handler, too many requests in flight" + ); + } + } + ConnectionEvent::ListenUpgradeError(ListenUpgradeError { error, .. }) => { + tracing::debug!("inbound request failed: {:?}", error); + } + _ => {} + } + } +} + +enum HandleFail { + InternalError(usize), + RequestRejected, + DialRefused, + DialBack { + idx: usize, + result: Result<(), DialBackStatus>, + }, +} + +impl From for DialResponse { + fn from(value: HandleFail) -> Self { + match value { + HandleFail::InternalError(addr_idx) => Self { + status: ResponseStatus::E_INTERNAL_ERROR, + addr_idx, + dial_status: DialStatus::UNUSED, + }, + HandleFail::RequestRejected => Self { + status: ResponseStatus::E_REQUEST_REJECTED, + addr_idx: 0, + dial_status: DialStatus::UNUSED, + }, + HandleFail::DialRefused => Self { + status: ResponseStatus::E_DIAL_REFUSED, + addr_idx: 0, + dial_status: DialStatus::UNUSED, + }, + HandleFail::DialBack { idx, result } => Self { + status: ResponseStatus::OK, + addr_idx: idx, + dial_status: match result { + Err(DialBackStatus::DialErr) => DialStatus::E_DIAL_ERROR, + Err(DialBackStatus::DialBackErr) => DialStatus::E_DIAL_BACK_ERROR, + Ok(()) => DialStatus::OK, + }, + }, + } + } +} + +async fn handle_request( + stream: impl AsyncRead + AsyncWrite + Unpin, + observed_multiaddr: Multiaddr, + client: PeerId, + dial_back_cmd_sender: mpsc::Sender, + rng: impl RngCore, +) -> Event { + let mut coder = Coder::new(stream); + let mut all_addrs = Vec::new(); + let mut tested_addr_opt = None; + let mut data_amount = 0; + let response = handle_request_internal( + &mut coder, + observed_multiaddr.clone(), + dial_back_cmd_sender, + rng, + &mut all_addrs, + &mut tested_addr_opt, + &mut data_amount, + ) + .await + .unwrap_or_else(|e| e.into()); + let Some(tested_addr) = tested_addr_opt else { + return Event { + all_addrs, + tested_addr: observed_multiaddr, + client, + data_amount, + result: Err(io::Error::new( + io::ErrorKind::Other, + "client is not conformint to protocol. the tested address is not the observed address", + )), + }; + }; + if let Err(e) = coder.send(Response::Dial(response)).await { + return Event { + all_addrs, + tested_addr, + client, + data_amount, + result: Err(e), + }; + } + if let Err(e) = coder.close().await { + return Event { + all_addrs, + tested_addr, + client, + data_amount, + result: Err(e), + }; + } + Event { + all_addrs, + tested_addr, + client, + data_amount, + result: Ok(()), + } +} + +async fn handle_request_internal( + coder: &mut Coder, + observed_multiaddr: Multiaddr, + dial_back_cmd_sender: mpsc::Sender, + mut rng: impl RngCore, + all_addrs: &mut Vec, + tested_addrs: &mut Option, + data_amount: &mut usize, +) -> Result +where + I: AsyncRead + AsyncWrite + Unpin, +{ + let DialRequest { mut addrs, nonce } = match coder + .next() + .await + .map_err(|_| HandleFail::InternalError(0))? + { + Request::Dial(dial_request) => dial_request, + Request::Data(_) => { + return Err(HandleFail::RequestRejected); + } + }; + all_addrs.clone_from(&addrs); + let idx = 0; + let addr = addrs.pop().ok_or(HandleFail::DialRefused)?; + *tested_addrs = Some(addr.clone()); + *data_amount = 0; + if addr != observed_multiaddr { + let dial_data_request = DialDataRequest::from_rng(idx, &mut rng); + let mut rem_data = dial_data_request.num_bytes; + coder + .send(Response::Data(dial_data_request)) + .await + .map_err(|_| HandleFail::InternalError(idx))?; + while rem_data > 0 { + let data_count = match coder + .next() + .await + .map_err(|_e| HandleFail::InternalError(idx))? + { + Request::Dial(_) => { + return Err(HandleFail::RequestRejected); + } + Request::Data(dial_data_response) => dial_data_response.get_data_count(), + }; + rem_data = rem_data.saturating_sub(data_count); + *data_amount += data_count; + } + } + let (back_channel, rx) = oneshot::channel(); + let dial_back_cmd = DialBackCommand { + addr, + nonce, + back_channel, + }; + dial_back_cmd_sender + .clone() + .send(dial_back_cmd) + .await + .map_err(|_| HandleFail::DialBack { + idx, + result: Err(DialBackStatus::DialErr), + })?; + + let dial_back = rx.await.map_err(|_e| HandleFail::InternalError(idx))?; + if let Err(err) = dial_back { + return Err(HandleFail::DialBack { + idx, + result: Err(err), + }); + } + Ok(DialResponse { + status: ResponseStatus::OK, + addr_idx: idx, + dial_status: DialStatus::OK, + }) +} diff --git a/protocols/autonat/tests/autonatv2.rs b/protocols/autonat/tests/autonatv2.rs new file mode 100644 index 00000000000..abd0c4bd8eb --- /dev/null +++ b/protocols/autonat/tests/autonatv2.rs @@ -0,0 +1,568 @@ +use libp2p_autonat::v2::client::{self, Config}; +use libp2p_autonat::v2::server; +use libp2p_core::transport::TransportError; +use libp2p_core::Multiaddr; +use libp2p_swarm::{ + DialError, FromSwarm, NetworkBehaviour, NewExternalAddrCandidate, Swarm, SwarmEvent, +}; +use libp2p_swarm_test::SwarmExt; +use rand_core::OsRng; +use std::sync::Arc; +use std::time::Duration; +use tokio::sync::oneshot; +use tracing_subscriber::EnvFilter; + +#[tokio::test] +async fn confirm_successful() { + let _ = tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .try_init(); + let (mut alice, mut bob) = start_and_connect().await; + + let cor_server_peer = *alice.local_peer_id(); + let cor_client_peer = *bob.local_peer_id(); + let bob_external_addrs = Arc::new(bob.external_addresses().cloned().collect::>()); + let alice_bob_external_addrs = bob_external_addrs.clone(); + + let alice_task = async { + let _ = alice + .wait(|event| match event { + SwarmEvent::NewExternalAddrCandidate { .. } => Some(()), + _ => None, + }) + .await; + + let (dialed_peer_id, dialed_connection_id) = alice + .wait(|event| match event { + SwarmEvent::Dialing { + peer_id, + connection_id, + .. + } => peer_id.map(|peer_id| (peer_id, connection_id)), + _ => None, + }) + .await; + + assert_eq!(dialed_peer_id, cor_client_peer); + + let _ = alice + .wait(|event| match event { + SwarmEvent::ConnectionEstablished { + peer_id, + connection_id, + .. + } if peer_id == dialed_peer_id + && peer_id == cor_client_peer + && connection_id == dialed_connection_id => + { + Some(()) + } + _ => None, + }) + .await; + + let server::Event { + all_addrs, + tested_addr, + client, + data_amount, + result, + } = alice + .wait(|event| match event { + SwarmEvent::Behaviour(CombinedServerEvent::Autonat(status_update)) => { + Some(status_update) + } + _ => None, + }) + .await; + + assert_eq!(tested_addr, bob_external_addrs.first().cloned().unwrap()); + assert_eq!(data_amount, 0); + assert_eq!(client, cor_client_peer); + assert_eq!(&all_addrs[..], &bob_external_addrs[..]); + assert!(result.is_ok(), "Result: {result:?}"); + }; + + let bob_task = async { + bob.wait(|event| match event { + SwarmEvent::NewExternalAddrCandidate { address } => Some(address), + _ => None, + }) + .await; + let incoming_conn_id = bob + .wait(|event| match event { + SwarmEvent::IncomingConnection { connection_id, .. } => Some(connection_id), + _ => None, + }) + .await; + + let _ = bob + .wait(|event| match event { + SwarmEvent::ConnectionEstablished { + connection_id, + peer_id, + .. + } if incoming_conn_id == connection_id && peer_id == cor_server_peer => Some(()), + _ => None, + }) + .await; + + let client::Event { + tested_addr, + bytes_sent, + server, + result, + } = bob + .wait(|event| match event { + SwarmEvent::Behaviour(CombinedClientEvent::Autonat(status_update)) => { + Some(status_update) + } + _ => None, + }) + .await; + assert_eq!( + tested_addr, + alice_bob_external_addrs.first().cloned().unwrap() + ); + assert_eq!(bytes_sent, 0); + assert_eq!(server, cor_server_peer); + assert!(result.is_ok(), "Result is {result:?}"); + }; + + tokio::join!(alice_task, bob_task); +} + +#[tokio::test] +async fn dial_back_to_unsupported_protocol() { + let _ = tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .try_init(); + let (mut alice, mut bob) = bootstrap().await; + + let alice_peer_id = *alice.local_peer_id(); + + let test_addr: Multiaddr = "/ip4/127.0.0.1/udp/1234/quic/webtransport".parse().unwrap(); + let bob_test_addr = test_addr.clone(); + bob.behaviour_mut() + .autonat + .on_swarm_event(FromSwarm::NewExternalAddrCandidate( + NewExternalAddrCandidate { addr: &test_addr }, + )); + + let (bob_done_tx, bob_done_rx) = oneshot::channel(); + + let alice_task = async { + let (alice_dialing_peer, alice_conn_id) = alice + .wait(|event| match event { + SwarmEvent::Dialing { + peer_id, + connection_id, + } => peer_id.map(|e| (e, connection_id)), + _ => None, + }) + .await; + let mut outgoing_conn_error = alice + .wait(|event| match event { + SwarmEvent::OutgoingConnectionError { + connection_id, + peer_id: Some(peer_id), + error: DialError::Transport(transport_errs), + } if connection_id == alice_conn_id && alice_dialing_peer == peer_id => { + Some(transport_errs) + } + _ => None, + }) + .await; + if let Some((multiaddr, TransportError::MultiaddrNotSupported(not_supported_addr))) = + outgoing_conn_error.pop() + { + assert_eq!( + multiaddr, + test_addr.clone().with_p2p(alice_dialing_peer).unwrap() + ); + assert_eq!(not_supported_addr, multiaddr,); + } else { + panic!("Peers are empty"); + } + assert_eq!(outgoing_conn_error.len(), 0); + let data_amount = alice + .wait(|event| match event { + SwarmEvent::Behaviour(CombinedServerEvent::Autonat(server::Event { + all_addrs, + tested_addr, + client, + data_amount, + result: Ok(()), + })) if all_addrs == vec![test_addr.clone()] + && tested_addr == test_addr.clone() + && client == alice_dialing_peer => + { + Some(data_amount) + } + _ => None, + }) + .await; + + let handler = tokio::spawn(async move { + alice.loop_on_next().await; + }); + let _ = bob_done_rx.await; + handler.abort(); + data_amount + }; + + let bob_task = async { + let data_amount = bob + .wait(|event| match event { + SwarmEvent::Behaviour(CombinedClientEvent::Autonat(client::Event { + tested_addr, + bytes_sent, + server, + result: Err(_), + })) if server == alice_peer_id && tested_addr == bob_test_addr => Some(bytes_sent), + _ => None, + }) + .await; + bob_done_tx.send(()).unwrap(); + data_amount + }; + let (alice_amount, bob_amount) = tokio::join!(alice_task, bob_task); + assert_eq!(alice_amount, bob_amount); +} + +#[tokio::test] +async fn dial_back_to_non_libp2p() { + let _ = tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .try_init(); + let (mut alice, mut bob) = bootstrap().await; + let alice_peer_id = *alice.local_peer_id(); + + for addr_str in ["/ip4/169.150.247.38/tcp/32", "/ip6/::1/tcp/1000"] { + let addr: Multiaddr = addr_str.parse().unwrap(); + let bob_addr = addr.clone(); + bob.behaviour_mut() + .autonat + .on_swarm_event(FromSwarm::NewExternalAddrCandidate( + NewExternalAddrCandidate { addr: &addr }, + )); + + let alice_task = async { + let (alice_dialing_peer, alice_conn_id) = alice + .wait(|event| match event { + SwarmEvent::Dialing { + peer_id, + connection_id, + } => peer_id.map(|p| (p, connection_id)), + _ => None, + }) + .await; + let mut outgoing_conn_error = alice + .wait(|event| match event { + SwarmEvent::OutgoingConnectionError { + connection_id, + peer_id: Some(peer_id), + error: DialError::Transport(peers), + } if connection_id == alice_conn_id && peer_id == alice_dialing_peer => { + Some(peers) + } + _ => None, + }) + .await; + + if let Some((multiaddr, TransportError::Other(o))) = outgoing_conn_error.pop() { + assert_eq!( + multiaddr, + addr.clone().with_p2p(alice_dialing_peer).unwrap() + ); + let error_string = o.to_string(); + assert!( + error_string.contains("Connection refused"), + "Correct error string: {error_string} for {addr_str}" + ); + } else { + panic!("No outgoing connection errors"); + } + + alice + .wait(|event| match event { + SwarmEvent::Behaviour(CombinedServerEvent::Autonat(server::Event { + all_addrs, + tested_addr, + client, + data_amount, + result: Ok(()), + })) if all_addrs == vec![addr.clone()] + && tested_addr == addr + && alice_dialing_peer == client => + { + Some(data_amount) + } + _ => None, + }) + .await + }; + let bob_task = async { + bob.wait(|event| match event { + SwarmEvent::Behaviour(CombinedClientEvent::Autonat(client::Event { + tested_addr, + bytes_sent, + server, + result: Err(_), + })) if tested_addr == bob_addr && server == alice_peer_id => Some(bytes_sent), + _ => None, + }) + .await + }; + + let (alice_bytes_sent, bob_bytes_sent) = tokio::join!(alice_task, bob_task); + assert_eq!(alice_bytes_sent, bob_bytes_sent); + bob.behaviour_mut().autonat.validate_addr(&addr); + } +} + +#[tokio::test] +async fn dial_back_to_not_supporting() { + let _ = tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .try_init(); + + let (mut alice, mut bob) = bootstrap().await; + let alice_peer_id = *alice.local_peer_id(); + + let (bob_done_tx, bob_done_rx) = oneshot::channel(); + + let hannes = new_dummy().await; + let hannes_peer_id = *hannes.local_peer_id(); + let unreachable_address = hannes.external_addresses().next().unwrap().clone(); + let bob_unreachable_address = unreachable_address.clone(); + bob.behaviour_mut() + .autonat + .on_swarm_event(FromSwarm::NewExternalAddrCandidate( + NewExternalAddrCandidate { + addr: &unreachable_address, + }, + )); + + let handler = tokio::spawn(async { hannes.loop_on_next().await }); + + let alice_task = async { + let (alice_dialing_peer, alice_conn_id) = alice + .wait(|event| match event { + SwarmEvent::Dialing { + peer_id, + connection_id, + } => peer_id.map(|p| (p, connection_id)), + _ => None, + }) + .await; + alice + .wait(|event| match event { + SwarmEvent::OutgoingConnectionError { + connection_id, + peer_id: Some(peer_id), + error: DialError::WrongPeerId { obtained, .. }, + } if connection_id == alice_conn_id + && peer_id == alice_dialing_peer + && obtained == hannes_peer_id => + { + Some(()) + } + _ => None, + }) + .await; + + let data_amount = alice + .wait(|event| match event { + SwarmEvent::Behaviour(CombinedServerEvent::Autonat(server::Event { + all_addrs, + tested_addr, + client, + data_amount, + result: Ok(()), + })) if all_addrs == vec![unreachable_address.clone()] + && tested_addr == unreachable_address + && alice_dialing_peer == client => + { + Some(data_amount) + } + _ => None, + }) + .await; + tokio::select! { + _ = bob_done_rx => { + data_amount + } + _ = alice.loop_on_next() => { + unreachable!(); + } + } + }; + + let bob_task = async { + let bytes_sent = bob + .wait(|event| match event { + SwarmEvent::Behaviour(CombinedClientEvent::Autonat(client::Event { + tested_addr, + bytes_sent, + server, + result: Err(_), + })) if tested_addr == bob_unreachable_address && server == alice_peer_id => { + Some(bytes_sent) + } + _ => None, + }) + .await; + bob_done_tx.send(()).unwrap(); + bytes_sent + }; + + let (alice_bytes_sent, bob_bytes_sent) = tokio::join!(alice_task, bob_task); + assert_eq!(alice_bytes_sent, bob_bytes_sent); + handler.abort(); +} + +async fn new_server() -> Swarm { + let mut node = Swarm::new_ephemeral(|identity| CombinedServer { + autonat: libp2p_autonat::v2::server::Behaviour::default(), + identify: libp2p_identify::Behaviour::new(libp2p_identify::Config::new( + "/libp2p-test/1.0.0".into(), + identity.public().clone(), + )), + }); + node.listen().with_tcp_addr_external().await; + + node +} + +async fn new_client() -> Swarm { + let mut node = Swarm::new_ephemeral(|identity| CombinedClient { + autonat: libp2p_autonat::v2::client::Behaviour::new( + OsRng, + Config::default().with_probe_interval(Duration::from_millis(100)), + ), + identify: libp2p_identify::Behaviour::new(libp2p_identify::Config::new( + "/libp2p-test/1.0.0".into(), + identity.public().clone(), + )), + }); + node.listen().with_tcp_addr_external().await; + node +} + +#[derive(libp2p_swarm::NetworkBehaviour)] +#[behaviour(prelude = "libp2p_swarm::derive_prelude")] +struct CombinedServer { + autonat: libp2p_autonat::v2::server::Behaviour, + identify: libp2p_identify::Behaviour, +} + +#[derive(libp2p_swarm::NetworkBehaviour)] +#[behaviour(prelude = "libp2p_swarm::derive_prelude")] +struct CombinedClient { + autonat: libp2p_autonat::v2::client::Behaviour, + identify: libp2p_identify::Behaviour, +} + +async fn new_dummy() -> Swarm { + let mut node = Swarm::new_ephemeral(|identity| { + libp2p_identify::Behaviour::new(libp2p_identify::Config::new( + "/libp2p-test/1.0.0".into(), + identity.public().clone(), + )) + }); + node.listen().with_tcp_addr_external().await; + node +} + +async fn start_and_connect() -> (Swarm, Swarm) { + let mut alice = new_server().await; + let mut bob = new_client().await; + + bob.connect(&mut alice).await; + (alice, bob) +} + +async fn bootstrap() -> (Swarm, Swarm) { + let (mut alice, mut bob) = start_and_connect().await; + + let cor_server_peer = *alice.local_peer_id(); + let cor_client_peer = *bob.local_peer_id(); + + let alice_task = async { + let _ = alice + .wait(|event| match event { + SwarmEvent::NewExternalAddrCandidate { .. } => Some(()), + _ => None, + }) + .await; + + let (dialed_peer_id, dialed_connection_id) = alice + .wait(|event| match event { + SwarmEvent::Dialing { + peer_id, + connection_id, + .. + } => peer_id.map(|peer_id| (peer_id, connection_id)), + _ => None, + }) + .await; + + let _ = alice + .wait(|event| match event { + SwarmEvent::ConnectionEstablished { + peer_id, + connection_id, + .. + } if peer_id == dialed_peer_id + && peer_id == cor_client_peer + && connection_id == dialed_connection_id => + { + Some(()) + } + _ => None, + }) + .await; + + alice + .wait(|event| match event { + SwarmEvent::Behaviour(CombinedServerEvent::Autonat(_)) => Some(()), + _ => None, + }) + .await; + }; + + let bob_task = async { + bob.wait(|event| match event { + SwarmEvent::NewExternalAddrCandidate { address } => Some(address), + _ => None, + }) + .await; + let incoming_conn_id = bob + .wait(|event| match event { + SwarmEvent::IncomingConnection { connection_id, .. } => Some(connection_id), + _ => None, + }) + .await; + + let _ = bob + .wait(|event| match event { + SwarmEvent::ConnectionEstablished { + connection_id, + peer_id, + .. + } if incoming_conn_id == connection_id && peer_id == cor_server_peer => Some(()), + _ => None, + }) + .await; + + bob.wait(|event| match event { + SwarmEvent::Behaviour(CombinedClientEvent::Autonat(_)) => Some(()), + _ => None, + }) + .await; + }; + + tokio::join!(alice_task, bob_task); + (alice, bob) +} From 7b2a77e066a39fc052178bd4362792e6b63822ef Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Thu, 8 Aug 2024 17:36:25 +0300 Subject: [PATCH 207/246] chore(metrics): Add `/tls/ws` in protocol stack tests Pull-Request: #5540. --- misc/metrics/src/protocol_stack.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/misc/metrics/src/protocol_stack.rs b/misc/metrics/src/protocol_stack.rs index 59e8c0bfa6a..57760df79a1 100644 --- a/misc/metrics/src/protocol_stack.rs +++ b/misc/metrics/src/protocol_stack.rs @@ -23,5 +23,11 @@ mod tests { let protocol_stack = as_string(&ma); assert_eq!(protocol_stack, "/ip6/tcp/wss/p2p"); + + let ma = Multiaddr::try_from("/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/tcp/8000/tls/ws/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC").expect("testbad"); + + let protocol_stack = as_string(&ma); + + assert_eq!(protocol_stack, "/ip6/tcp/tls/ws/p2p"); } } From 4725f46f0d0e14f3ef4e88edc085729c1312dff6 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Thu, 8 Aug 2024 18:11:33 +0300 Subject: [PATCH 208/246] feat(websocket,websocket-websys): Add support for `/tls/ws` To keep backward compatibility the following rules were implemented: * On dialing, `/tls/ws` and `/wss` are equivalent. * On listening: * If user listens with `/tls/ws` then `/tls/ws` will be advertised. * If user listens with `/wss` then `/wss` will be advertised. Closes #2449 Closes #5509 Pull-Request: #5523. --- interop-tests/src/arch.rs | 4 +- transports/websocket-websys/CHANGELOG.md | 3 + transports/websocket-websys/src/lib.rs | 107 +++++++++++- transports/websocket/CHANGELOG.md | 2 + transports/websocket/src/framed.rs | 214 +++++++++++++++++++---- transports/websocket/src/lib.rs | 2 +- 6 files changed, 289 insertions(+), 43 deletions(-) diff --git a/interop-tests/src/arch.rs b/interop-tests/src/arch.rs index a7755b95977..df36f8e5baf 100644 --- a/interop-tests/src/arch.rs +++ b/interop-tests/src/arch.rs @@ -245,7 +245,7 @@ pub(crate) mod wasm { .with_behaviour(behaviour_constructor)? .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5))) .build(), - format!("/ip4/{ip}/tcp/0/wss"), + format!("/ip4/{ip}/tcp/0/tls/ws"), ), (Transport::Ws, Some(SecProtocol::Noise), Some(Muxer::Yamux)) => ( libp2p::SwarmBuilder::with_new_identity() @@ -262,7 +262,7 @@ pub(crate) mod wasm { .with_behaviour(behaviour_constructor)? .with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5))) .build(), - format!("/ip4/{ip}/tcp/0/wss"), + format!("/ip4/{ip}/tcp/0/tls/ws"), ), (Transport::WebRtcDirect, None, None) => ( libp2p::SwarmBuilder::with_new_identity() diff --git a/transports/websocket-websys/CHANGELOG.md b/transports/websocket-websys/CHANGELOG.md index 70d866e6141..d0aeb509823 100644 --- a/transports/websocket-websys/CHANGELOG.md +++ b/transports/websocket-websys/CHANGELOG.md @@ -2,6 +2,9 @@ - Implement refactored `Transport`. See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) +- Add support for `/tls/ws` and keep `/wss` backward compatible. + See [PR 5523](https://github.com/libp2p/rust-libp2p/pull/5523). + ## 0.3.3 - Fix use-after-free handler invocation from JS side. diff --git a/transports/websocket-websys/src/lib.rs b/transports/websocket-websys/src/lib.rs index d2589715bbb..f353d92b204 100644 --- a/transports/websocket-websys/src/lib.rs +++ b/transports/websocket-websys/src/lib.rs @@ -137,9 +137,10 @@ fn extract_websocket_url(addr: &Multiaddr) -> Option { _ => return None, }; - let (scheme, wspath) = match protocols.next() { - Some(Protocol::Ws(path)) => ("ws", path.into_owned()), - Some(Protocol::Wss(path)) => ("wss", path.into_owned()), + let (scheme, wspath) = match (protocols.next(), protocols.next()) { + (Some(Protocol::Tls), Some(Protocol::Ws(path))) => ("wss", path.into_owned()), + (Some(Protocol::Ws(path)), _) => ("ws", path.into_owned()), + (Some(Protocol::Wss(path)), _) => ("wss", path.into_owned()), _ => return None, }; @@ -453,3 +454,103 @@ impl Drop for Connection { .clear_interval_with_handle(self.inner.buffered_amount_low_interval); } } + +#[cfg(test)] +mod tests { + use super::*; + use libp2p_identity::PeerId; + + #[test] + fn extract_url() { + let peer_id = PeerId::random(); + + // Check `/tls/ws` + let addr = "/dns4/example.com/tcp/2222/tls/ws" + .parse::() + .unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "wss://example.com:2222/"); + + // Check `/tls/ws` with `/p2p` + let addr = format!("/dns4/example.com/tcp/2222/tls/ws/p2p/{peer_id}") + .parse() + .unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "wss://example.com:2222/"); + + // Check `/tls/ws` with `/ip4` + let addr = "/ip4/127.0.0.1/tcp/2222/tls/ws" + .parse::() + .unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "wss://127.0.0.1:2222/"); + + // Check `/tls/ws` with `/ip6` + let addr = "/ip6/::1/tcp/2222/tls/ws".parse::().unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "wss://[::1]:2222/"); + + // Check `/wss` + let addr = "/dns4/example.com/tcp/2222/wss" + .parse::() + .unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "wss://example.com:2222/"); + + // Check `/wss` with `/p2p` + let addr = format!("/dns4/example.com/tcp/2222/wss/p2p/{peer_id}") + .parse() + .unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "wss://example.com:2222/"); + + // Check `/wss` with `/ip4` + let addr = "/ip4/127.0.0.1/tcp/2222/wss".parse::().unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "wss://127.0.0.1:2222/"); + + // Check `/wss` with `/ip6` + let addr = "/ip6/::1/tcp/2222/wss".parse::().unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "wss://[::1]:2222/"); + + // Check `/ws` + let addr = "/dns4/example.com/tcp/2222/ws" + .parse::() + .unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "ws://example.com:2222/"); + + // Check `/ws` with `/p2p` + let addr = format!("/dns4/example.com/tcp/2222/ws/p2p/{peer_id}") + .parse() + .unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "ws://example.com:2222/"); + + // Check `/ws` with `/ip4` + let addr = "/ip4/127.0.0.1/tcp/2222/ws".parse::().unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "ws://127.0.0.1:2222/"); + + // Check `/ws` with `/ip6` + let addr = "/ip6/::1/tcp/2222/ws".parse::().unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "ws://[::1]:2222/"); + + // Check `/ws` with `/ip4` + let addr = "/ip4/127.0.0.1/tcp/2222/ws".parse::().unwrap(); + let url = extract_websocket_url(&addr).unwrap(); + assert_eq!(url, "ws://127.0.0.1:2222/"); + + // Check that `/tls/wss` is invalid + let addr = "/ip4/127.0.0.1/tcp/2222/tls/wss" + .parse::() + .unwrap(); + assert!(extract_websocket_url(&addr).is_none()); + + // Check non-ws address + let addr = "/ip4/127.0.0.1/tcp/2222".parse::().unwrap(); + assert!(extract_websocket_url(&addr).is_none()); + } +} diff --git a/transports/websocket/CHANGELOG.md b/transports/websocket/CHANGELOG.md index df51e2c807d..cd079cfdd5a 100644 --- a/transports/websocket/CHANGELOG.md +++ b/transports/websocket/CHANGELOG.md @@ -4,6 +4,8 @@ See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) - Allow wss connections on IP addresses. See [PR 5525](https://github.com/libp2p/rust-libp2p/pull/5525). +- Add support for `/tls/ws` and keep `/wss` backward compatible. + See [PR 5523](https://github.com/libp2p/rust-libp2p/pull/5523). ## 0.43.2 diff --git a/transports/websocket/src/framed.rs b/transports/websocket/src/framed.rs index 074271e672f..a547aea21ef 100644 --- a/transports/websocket/src/framed.rs +++ b/transports/websocket/src/framed.rs @@ -33,6 +33,7 @@ use soketto::{ connection::{self, CloseReason}, handshake, }; +use std::borrow::Cow; use std::net::IpAddr; use std::{collections::HashMap, ops::DerefMut, sync::Arc}; use std::{fmt, io, mem, pin::Pin, task::Context, task::Poll}; @@ -51,10 +52,7 @@ pub struct WsConfig { tls_config: tls::Config, max_redirects: u8, /// Websocket protocol of the inner listener. - /// - /// This is the suffix of the address provided in `listen_on`. - /// Can only be [`Protocol::Ws`] or [`Protocol::Wss`]. - listener_protos: HashMap>, + listener_protos: HashMap>, } impl WsConfig @@ -121,22 +119,19 @@ where id: ListenerId, addr: Multiaddr, ) -> Result<(), TransportError> { - let mut inner_addr = addr.clone(); - let proto = match inner_addr.pop() { - Some(p @ Protocol::Wss(_)) => { - if self.tls_config.server.is_some() { - p - } else { - tracing::debug!("/wss address but TLS server support is not configured"); - return Err(TransportError::MultiaddrNotSupported(addr)); - } - } - Some(p @ Protocol::Ws(_)) => p, - _ => { - tracing::debug!(address=%addr, "Address is not a websocket multiaddr"); - return Err(TransportError::MultiaddrNotSupported(addr)); - } - }; + let (inner_addr, proto) = parse_ws_listen_addr(&addr).ok_or_else(|| { + tracing::debug!(address=%addr, "Address is not a websocket multiaddr"); + TransportError::MultiaddrNotSupported(addr.clone()) + })?; + + if proto.use_tls() && self.tls_config.server.is_none() { + tracing::debug!( + "{} address but TLS server support is not configured", + proto.prefix() + ); + return Err(TransportError::MultiaddrNotSupported(addr)); + } + match self.transport.lock().listen_on(id, inner_addr) { Ok(()) => { self.listener_protos.insert(id, proto); @@ -175,11 +170,10 @@ where mut listen_addr, } => { // Append the ws / wss protocol back to the inner address. - let proto = self - .listener_protos + self.listener_protos .get(&listener_id) - .expect("Protocol was inserted in Transport::listen_on."); - listen_addr.push(proto.clone()); + .expect("Protocol was inserted in Transport::listen_on.") + .append_on_addr(&mut listen_addr); tracing::debug!(address=%listen_addr, "Listening on address"); TransportEvent::NewAddress { listener_id, @@ -190,11 +184,10 @@ where listener_id, mut listen_addr, } => { - let proto = self - .listener_protos + self.listener_protos .get(&listener_id) - .expect("Protocol was inserted in Transport::listen_on."); - listen_addr.push(proto.clone()); + .expect("Protocol was inserted in Transport::listen_on.") + .append_on_addr(&mut listen_addr); TransportEvent::AddressExpired { listener_id, listen_addr, @@ -226,13 +219,9 @@ where .listener_protos .get(&listener_id) .expect("Protocol was inserted in Transport::listen_on."); - let use_tls = match proto { - Protocol::Wss(_) => true, - Protocol::Ws(_) => false, - _ => unreachable!("Map contains only ws and wss protocols."), - }; - local_addr.push(proto.clone()); - send_back_addr.push(proto.clone()); + let use_tls = proto.use_tls(); + proto.append_on_addr(&mut local_addr); + proto.append_on_addr(&mut send_back_addr); let upgrade = self.map_upgrade(upgrade, send_back_addr.clone(), use_tls); TransportEvent::Incoming { listener_id, @@ -446,6 +435,48 @@ where } } +#[derive(Debug, PartialEq)] +pub(crate) enum WsListenProto<'a> { + Ws(Cow<'a, str>), + Wss(Cow<'a, str>), + TlsWs(Cow<'a, str>), +} + +impl<'a> WsListenProto<'a> { + pub(crate) fn append_on_addr(&self, addr: &mut Multiaddr) { + match self { + WsListenProto::Ws(path) => { + addr.push(Protocol::Ws(path.clone())); + } + // `/tls/ws` and `/wss` are equivalend, however we regenerate + // the one that user passed at `listen_on` for backward compatibility. + WsListenProto::Wss(path) => { + addr.push(Protocol::Wss(path.clone())); + } + WsListenProto::TlsWs(path) => { + addr.push(Protocol::Tls); + addr.push(Protocol::Ws(path.clone())); + } + } + } + + pub(crate) fn use_tls(&self) -> bool { + match self { + WsListenProto::Ws(_) => false, + WsListenProto::Wss(_) => true, + WsListenProto::TlsWs(_) => true, + } + } + + pub(crate) fn prefix(&self) -> &'static str { + match self { + WsListenProto::Ws(_) => "/ws", + WsListenProto::Wss(_) => "/wss", + WsListenProto::TlsWs(_) => "/tls/ws", + } + } +} + #[derive(Debug)] struct WsAddress { host_port: String, @@ -499,7 +530,14 @@ fn parse_ws_dial_addr(addr: Multiaddr) -> Result> { let (use_tls, path) = loop { match protocols.pop() { p @ Some(Protocol::P2p(_)) => p2p = p, - Some(Protocol::Ws(path)) => break (false, path.into_owned()), + Some(Protocol::Ws(path)) => match protocols.pop() { + Some(Protocol::Tls) => break (true, path.into_owned()), + Some(p) => { + protocols.push(p); + break (false, path.into_owned()); + } + None => return Err(Error::InvalidMultiaddr(addr)), + }, Some(Protocol::Wss(path)) => break (true, path.into_owned()), _ => return Err(Error::InvalidMultiaddr(addr)), } @@ -521,6 +559,22 @@ fn parse_ws_dial_addr(addr: Multiaddr) -> Result> { }) } +fn parse_ws_listen_addr(addr: &Multiaddr) -> Option<(Multiaddr, WsListenProto<'static>)> { + let mut inner_addr = addr.clone(); + + match inner_addr.pop()? { + Protocol::Wss(path) => Some((inner_addr, WsListenProto::Wss(path))), + Protocol::Ws(path) => match inner_addr.pop()? { + Protocol::Tls => Some((inner_addr, WsListenProto::TlsWs(path))), + p => { + inner_addr.push(p); + Some((inner_addr, WsListenProto::Ws(path))) + } + }, + _ => None, + } +} + // Given a location URL, build a new websocket [`Multiaddr`]. fn location_to_multiaddr(location: &str) -> Result> { match Url::parse(location) { @@ -537,7 +591,8 @@ fn location_to_multiaddr(location: &str) -> Result> { } let s = url.scheme(); if s.eq_ignore_ascii_case("https") | s.eq_ignore_ascii_case("wss") { - a.push(Protocol::Wss(url.path().into())) + a.push(Protocol::Tls); + a.push(Protocol::Ws(url.path().into())); } else if s.eq_ignore_ascii_case("http") | s.eq_ignore_ascii_case("ws") { a.push(Protocol::Ws(url.path().into())) } else { @@ -759,10 +814,95 @@ mod tests { use libp2p_identity::PeerId; use std::io; + #[test] + fn listen_addr() { + let tcp_addr = "/ip4/0.0.0.0/tcp/2222".parse::().unwrap(); + + // Check `/tls/ws` + let addr = tcp_addr + .clone() + .with(Protocol::Tls) + .with(Protocol::Ws("/".into())); + let (inner_addr, proto) = parse_ws_listen_addr(&addr).unwrap(); + assert_eq!(&inner_addr, &tcp_addr); + assert_eq!(proto, WsListenProto::TlsWs("/".into())); + + let mut listen_addr = tcp_addr.clone(); + proto.append_on_addr(&mut listen_addr); + assert_eq!(listen_addr, addr); + + // Check `/wss` + let addr = tcp_addr.clone().with(Protocol::Wss("/".into())); + let (inner_addr, proto) = parse_ws_listen_addr(&addr).unwrap(); + assert_eq!(&inner_addr, &tcp_addr); + assert_eq!(proto, WsListenProto::Wss("/".into())); + + let mut listen_addr = tcp_addr.clone(); + proto.append_on_addr(&mut listen_addr); + assert_eq!(listen_addr, addr); + + // Check `/ws` + let addr = tcp_addr.clone().with(Protocol::Ws("/".into())); + let (inner_addr, proto) = parse_ws_listen_addr(&addr).unwrap(); + assert_eq!(&inner_addr, &tcp_addr); + assert_eq!(proto, WsListenProto::Ws("/".into())); + + let mut listen_addr = tcp_addr.clone(); + proto.append_on_addr(&mut listen_addr); + assert_eq!(listen_addr, addr); + } + #[test] fn dial_addr() { let peer_id = PeerId::random(); + // Check `/tls/ws` + let addr = "/dns4/example.com/tcp/2222/tls/ws" + .parse::() + .unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "example.com:2222"); + assert_eq!(info.path, "/"); + assert!(info.use_tls); + assert_eq!(info.server_name, "example.com".try_into().unwrap()); + assert_eq!(info.tcp_addr, "/dns4/example.com/tcp/2222".parse().unwrap()); + + // Check `/tls/ws` with `/p2p` + let addr = format!("/dns4/example.com/tcp/2222/tls/ws/p2p/{peer_id}") + .parse() + .unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "example.com:2222"); + assert_eq!(info.path, "/"); + assert!(info.use_tls); + assert_eq!(info.server_name, "example.com".try_into().unwrap()); + assert_eq!( + info.tcp_addr, + format!("/dns4/example.com/tcp/2222/p2p/{peer_id}") + .parse() + .unwrap() + ); + + // Check `/tls/ws` with `/ip4` + let addr = "/ip4/127.0.0.1/tcp/2222/tls/ws" + .parse::() + .unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "127.0.0.1:2222"); + assert_eq!(info.path, "/"); + assert!(info.use_tls); + assert_eq!(info.server_name, "127.0.0.1".try_into().unwrap()); + assert_eq!(info.tcp_addr, "/ip4/127.0.0.1/tcp/2222".parse().unwrap()); + + // Check `/tls/ws` with `/ip6` + let addr = "/ip6/::1/tcp/2222/tls/ws".parse::().unwrap(); + let info = parse_ws_dial_addr::(addr).unwrap(); + assert_eq!(info.host_port, "[::1]:2222"); + assert_eq!(info.path, "/"); + assert!(info.use_tls); + assert_eq!(info.server_name, "::1".try_into().unwrap()); + assert_eq!(info.tcp_addr, "/ip6/::1/tcp/2222".parse().unwrap()); + // Check `/wss` let addr = "/dns4/example.com/tcp/2222/wss" .parse::() diff --git a/transports/websocket/src/lib.rs b/transports/websocket/src/lib.rs index 40d6db44471..cbc923613dd 100644 --- a/transports/websocket/src/lib.rs +++ b/transports/websocket/src/lib.rs @@ -84,7 +84,7 @@ use std::{ /// let cert = websocket::tls::Certificate::new(rcgen_cert.serialize_der().unwrap()); /// transport.set_tls_config(websocket::tls::Config::new(priv_key, vec![cert]).unwrap()); /// -/// let id = transport.listen_on(ListenerId::next(), "/ip4/127.0.0.1/tcp/0/wss".parse().unwrap()).unwrap(); +/// let id = transport.listen_on(ListenerId::next(), "/ip4/127.0.0.1/tcp/0/tls/ws".parse().unwrap()).unwrap(); /// /// let addr = future::poll_fn(|cx| Pin::new(&mut transport).poll(cx)).await.into_new_address().unwrap(); /// println!("Listening on {addr}"); From 0c143ffde97cad2c17c94033d0e2accdff37418f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 9 Aug 2024 17:31:22 +0100 Subject: [PATCH 209/246] chore: prepare libp2p 0.54 release Pull-Request: #5542. --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 22 +++++++++++----------- misc/allow-block-list/CHANGELOG.md | 4 ++++ misc/allow-block-list/Cargo.toml | 2 +- misc/connection-limits/CHANGELOG.md | 4 ++++ misc/connection-limits/Cargo.toml | 2 +- misc/memory-connection-limits/CHANGELOG.md | 4 ++++ misc/memory-connection-limits/Cargo.toml | 2 +- misc/webrtc-utils/CHANGELOG.md | 4 ++++ misc/webrtc-utils/Cargo.toml | 2 +- muxers/mplex/CHANGELOG.md | 4 ++++ muxers/mplex/Cargo.toml | 4 ++-- muxers/yamux/CHANGELOG.md | 4 ++++ muxers/yamux/Cargo.toml | 2 +- swarm-test/CHANGELOG.md | 4 ++++ swarm-test/Cargo.toml | 2 +- transports/noise/CHANGELOG.md | 4 ++++ transports/noise/Cargo.toml | 2 +- transports/plaintext/CHANGELOG.md | 4 ++++ transports/plaintext/Cargo.toml | 4 ++-- transports/pnet/CHANGELOG.md | 4 ++++ transports/pnet/Cargo.toml | 4 ++-- transports/tls/CHANGELOG.md | 4 ++++ transports/tls/Cargo.toml | 2 +- 24 files changed, 80 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af3ceb9eb0f..e0f448810fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2675,7 +2675,7 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" -version = "0.3.0" +version = "0.4.0" dependencies = [ "async-std", "libp2p-core", @@ -2718,7 +2718,7 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" -version = "0.3.1" +version = "0.4.0" dependencies = [ "async-std", "libp2p-core", @@ -2989,7 +2989,7 @@ dependencies = [ [[package]] name = "libp2p-memory-connection-limits" -version = "0.2.0" +version = "0.3.0" dependencies = [ "async-std", "libp2p-core", @@ -3026,7 +3026,7 @@ dependencies = [ [[package]] name = "libp2p-mplex" -version = "0.41.0" +version = "0.42.0" dependencies = [ "async-std", "asynchronous-codec", @@ -3061,7 +3061,7 @@ dependencies = [ [[package]] name = "libp2p-noise" -version = "0.44.0" +version = "0.45.0" dependencies = [ "asynchronous-codec", "bytes", @@ -3138,7 +3138,7 @@ dependencies = [ [[package]] name = "libp2p-plaintext" -version = "0.41.0" +version = "0.42.0" dependencies = [ "asynchronous-codec", "bytes", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "libp2p-pnet" -version = "0.24.0" +version = "0.25.0" dependencies = [ "futures", "libp2p-core", @@ -3375,7 +3375,7 @@ dependencies = [ [[package]] name = "libp2p-swarm-test" -version = "0.3.0" +version = "0.4.0" dependencies = [ "async-trait", "futures", @@ -3410,7 +3410,7 @@ dependencies = [ [[package]] name = "libp2p-tls" -version = "0.4.1" +version = "0.5.0" dependencies = [ "futures", "futures-rustls", @@ -3487,7 +3487,7 @@ dependencies = [ [[package]] name = "libp2p-webrtc-utils" -version = "0.2.1" +version = "0.3.0" dependencies = [ "asynchronous-codec", "bytes", @@ -3591,7 +3591,7 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.45.2" +version = "0.46.0" dependencies = [ "async-std", "either", diff --git a/Cargo.toml b/Cargo.toml index 3f00734ae3c..7d12e1f6318 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,9 +76,9 @@ asynchronous-codec = { version = "0.7.0" } futures-bounded = { version = "0.2.4" } futures-rustls = { version = "0.26.0", default-features = false } libp2p = { version = "0.54.0", path = "libp2p" } -libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" } +libp2p-allow-block-list = { version = "0.4.0", path = "misc/allow-block-list" } libp2p-autonat = { version = "0.13.0", path = "protocols/autonat" } -libp2p-connection-limits = { version = "0.3.1", path = "misc/connection-limits" } +libp2p-connection-limits = { version = "0.4.0", path = "misc/connection-limits" } libp2p-core = { version = "0.42.0", path = "core" } libp2p-dcutr = { version = "0.12.0", path = "protocols/dcutr" } libp2p-dns = { version = "0.42.0", path = "transports/dns" } @@ -88,14 +88,14 @@ libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.46.0", path = "protocols/kad" } libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" } -libp2p-memory-connection-limits = { version = "0.2.0", path = "misc/memory-connection-limits" } +libp2p-memory-connection-limits = { version = "0.3.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.14.2", path = "misc/metrics" } -libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" } -libp2p-noise = { version = "0.44.0", path = "transports/noise" } +libp2p-mplex = { version = "0.42.0", path = "muxers/mplex" } +libp2p-noise = { version = "0.45.0", path = "transports/noise" } libp2p-perf = { version = "0.4.0", path = "protocols/perf" } libp2p-ping = { version = "0.45.0", path = "protocols/ping" } -libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" } -libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } +libp2p-plaintext = { version = "0.42.0", path = "transports/plaintext" } +libp2p-pnet = { version = "0.25.0", path = "transports/pnet" } libp2p-quic = { version = "0.11.0", path = "transports/quic" } libp2p-relay = { version = "0.18.0", path = "protocols/relay" } libp2p-rendezvous = { version = "0.15.0", path = "protocols/rendezvous" } @@ -104,18 +104,18 @@ libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.2.0-alpha", path = "protocols/stream" } libp2p-swarm = { version = "0.45.0", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. -libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" } +libp2p-swarm-test = { version = "0.4.0", path = "swarm-test" } libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } -libp2p-tls = { version = "0.4.1", path = "transports/tls" } +libp2p-tls = { version = "0.5.0", path = "transports/tls" } libp2p-uds = { version = "0.41.0", path = "transports/uds" } libp2p-upnp = { version = "0.3.0", path = "protocols/upnp" } libp2p-webrtc = { version = "0.8.0-alpha", path = "transports/webrtc" } -libp2p-webrtc-utils = { version = "0.2.1", path = "misc/webrtc-utils" } +libp2p-webrtc-utils = { version = "0.3.0", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.4.0-alpha", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.44.0", path = "transports/websocket" } libp2p-websocket-websys = { version = "0.4.0", path = "transports/websocket-websys" } libp2p-webtransport-websys = { version = "0.4.0", path = "transports/webtransport-websys" } -libp2p-yamux = { version = "0.45.2", path = "muxers/yamux" } +libp2p-yamux = { version = "0.46.0", path = "muxers/yamux" } multiaddr = "0.18.1" multihash = "0.19.1" multistream-select = { version = "0.13.0", path = "misc/multistream-select" } diff --git a/misc/allow-block-list/CHANGELOG.md b/misc/allow-block-list/CHANGELOG.md index 7778e924886..0017cbc8648 100644 --- a/misc/allow-block-list/CHANGELOG.md +++ b/misc/allow-block-list/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.0 + + + ## 0.3.0 diff --git a/misc/allow-block-list/Cargo.toml b/misc/allow-block-list/Cargo.toml index c620e7f4a2b..4209d72ab4f 100644 --- a/misc/allow-block-list/Cargo.toml +++ b/misc/allow-block-list/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-allow-block-list" edition = "2021" rust-version = { workspace = true } description = "Allow/block list connection management for libp2p." -version = "0.3.0" +version = "0.4.0" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] diff --git a/misc/connection-limits/CHANGELOG.md b/misc/connection-limits/CHANGELOG.md index 4654281a83e..db88e99ffa7 100644 --- a/misc/connection-limits/CHANGELOG.md +++ b/misc/connection-limits/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.0 + + + ## 0.3.1 - Add function to mutate `ConnectionLimits`. diff --git a/misc/connection-limits/Cargo.toml b/misc/connection-limits/Cargo.toml index 8ecb0005cb1..56fe97f984b 100644 --- a/misc/connection-limits/Cargo.toml +++ b/misc/connection-limits/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-connection-limits" edition = "2021" rust-version = { workspace = true } description = "Connection limits for libp2p." -version = "0.3.1" +version = "0.4.0" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] diff --git a/misc/memory-connection-limits/CHANGELOG.md b/misc/memory-connection-limits/CHANGELOG.md index fc598872d50..9e580c5a1d2 100644 --- a/misc/memory-connection-limits/CHANGELOG.md +++ b/misc/memory-connection-limits/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0 + + + ## 0.2.0 diff --git a/misc/memory-connection-limits/Cargo.toml b/misc/memory-connection-limits/Cargo.toml index 9f7406599e7..f56ed33d5ad 100644 --- a/misc/memory-connection-limits/Cargo.toml +++ b/misc/memory-connection-limits/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-memory-connection-limits" edition = "2021" rust-version = { workspace = true } description = "Memory usage based connection limits for libp2p." -version = "0.2.0" +version = "0.3.0" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] diff --git a/misc/webrtc-utils/CHANGELOG.md b/misc/webrtc-utils/CHANGELOG.md index b69bf74bfc8..3bb31610fa1 100644 --- a/misc/webrtc-utils/CHANGELOG.md +++ b/misc/webrtc-utils/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0 + + + ## 0.2.1 - Fix end of stream handling when buffer is empty or not present. diff --git a/misc/webrtc-utils/Cargo.toml b/misc/webrtc-utils/Cargo.toml index d870e43781e..88f576f12d9 100644 --- a/misc/webrtc-utils/Cargo.toml +++ b/misc/webrtc-utils/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT" name = "libp2p-webrtc-utils" repository = "https://github.com/libp2p/rust-libp2p" rust-version = { workspace = true } -version = "0.2.1" +version = "0.3.0" publish = true [dependencies] diff --git a/muxers/mplex/CHANGELOG.md b/muxers/mplex/CHANGELOG.md index 48ab616e131..f0c2c0353da 100644 --- a/muxers/mplex/CHANGELOG.md +++ b/muxers/mplex/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.42.0 + + + ## 0.41.0 - Migrate to `{In,Out}boundConnectionUpgrade` traits. diff --git a/muxers/mplex/Cargo.toml b/muxers/mplex/Cargo.toml index 4fdb4dabedd..7f887c8b3b8 100644 --- a/muxers/mplex/Cargo.toml +++ b/muxers/mplex/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-mplex" edition = "2021" rust-version = { workspace = true } description = "Mplex multiplexing protocol for libp2p" -version = "0.41.0" +version = "0.42.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -38,7 +38,7 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } name = "split_send_size" harness = false -# Passing arguments to the docsrs builder in order to properly document cfg's. +# Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true diff --git a/muxers/yamux/CHANGELOG.md b/muxers/yamux/CHANGELOG.md index 295ee251f65..855b3a33773 100644 --- a/muxers/yamux/CHANGELOG.md +++ b/muxers/yamux/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.46.0 + + + ## 0.45.2 - Update `yamux` to version `v0.13.3`.` diff --git a/muxers/yamux/Cargo.toml b/muxers/yamux/Cargo.toml index 289f84fe1dd..0c52eca3fd4 100644 --- a/muxers/yamux/Cargo.toml +++ b/muxers/yamux/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-yamux" edition = "2021" rust-version = { workspace = true } description = "Yamux multiplexing protocol for libp2p" -version = "0.45.2" +version = "0.46.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/swarm-test/CHANGELOG.md b/swarm-test/CHANGELOG.md index 95223e60272..98027fcbea2 100644 --- a/swarm-test/CHANGELOG.md +++ b/swarm-test/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.0 + + + ## 0.3.0 diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index 1bd40bdace3..b285da34f87 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-swarm-test" -version = "0.3.0" +version = "0.4.0" edition = "2021" rust-version = { workspace = true } license = "MIT" diff --git a/transports/noise/CHANGELOG.md b/transports/noise/CHANGELOG.md index 78effb673d2..f599ae3533f 100644 --- a/transports/noise/CHANGELOG.md +++ b/transports/noise/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.45.0 + + + ## 0.44.0 - Migrate to `{In,Out}boundConnectionUpgrade` traits. diff --git a/transports/noise/Cargo.toml b/transports/noise/Cargo.toml index 76cf9475cc4..7f8e9004cd0 100644 --- a/transports/noise/Cargo.toml +++ b/transports/noise/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-noise" edition = "2021" rust-version = { workspace = true } description = "Cryptographic handshake protocol using the noise framework." -version = "0.44.0" +version = "0.45.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/transports/plaintext/CHANGELOG.md b/transports/plaintext/CHANGELOG.md index 42b53d12a88..91860c76590 100644 --- a/transports/plaintext/CHANGELOG.md +++ b/transports/plaintext/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.42.0 + + + ## 0.41.0 - Migrate to `{In,Out}boundConnectionUpgrade` traits. diff --git a/transports/plaintext/Cargo.toml b/transports/plaintext/Cargo.toml index 4f07c5fee6e..47a3191baa9 100644 --- a/transports/plaintext/Cargo.toml +++ b/transports/plaintext/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-plaintext" edition = "2021" rust-version = { workspace = true } description = "Plaintext encryption dummy protocol for libp2p" -version = "0.41.0" +version = "0.42.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -27,7 +27,7 @@ rand = "0.8" futures_ringbuf = "0.4.0" tracing-subscriber = { workspace = true, features = ["env-filter"] } -# Passing arguments to the docsrs builder in order to properly document cfg's. +# Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true diff --git a/transports/pnet/CHANGELOG.md b/transports/pnet/CHANGELOG.md index 1fbc2d08807..86d519e8640 100644 --- a/transports/pnet/CHANGELOG.md +++ b/transports/pnet/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.25.0 + + + ## 0.24.0 diff --git a/transports/pnet/Cargo.toml b/transports/pnet/Cargo.toml index e7b3bfc30ac..db5c72fb7cc 100644 --- a/transports/pnet/Cargo.toml +++ b/transports/pnet/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-pnet" edition = "2021" rust-version = { workspace = true } description = "Private swarm support for libp2p" -version = "0.24.0" +version = "0.25.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" @@ -29,7 +29,7 @@ libp2p-yamux = { workspace = true } quickcheck = { workspace = true } tokio = { workspace = true, features = ["full"] } -# Passing arguments to the docsrs builder in order to properly document cfg's. +# Passing arguments to the docsrs builder in order to properly document cfg's. # More information: https://docs.rs/about/builds#cross-compiling [package.metadata.docs.rs] all-features = true diff --git a/transports/tls/CHANGELOG.md b/transports/tls/CHANGELOG.md index 0343c690834..e27b8b4cf1f 100644 --- a/transports/tls/CHANGELOG.md +++ b/transports/tls/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.0 + + + ## 0.4.1 - Fix a panic caused by `rustls` parsing the libp2p TLS extension. diff --git a/transports/tls/Cargo.toml b/transports/tls/Cargo.toml index 41b4c215dd9..c27e14bb537 100644 --- a/transports/tls/Cargo.toml +++ b/transports/tls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-tls" -version = "0.4.1" +version = "0.5.0" edition = "2021" rust-version = { workspace = true } description = "TLS configuration based on libp2p TLS specs." From 2357b04a250a4593dc8b9508e5e8e4cfdc46a8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 9 Aug 2024 23:51:15 +0100 Subject: [PATCH 210/246] fix(swarm): release libp2p-swarm-derive 0.35.0 Release libp2p-swarm-derive 0.35.0 and update `libp2p-swarm` to it to fix `NetworkBehaviour` derive macro generation. Pull-Request: #5545. --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- swarm-derive/CHANGELOG.md | 5 +++++ swarm-derive/Cargo.toml | 2 +- swarm/CHANGELOG.md | 5 +++++ swarm/Cargo.toml | 2 +- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0f448810fa..70744c1bf40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3330,7 +3330,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.45.0" +version = "0.45.1" dependencies = [ "async-std", "criterion", @@ -3365,7 +3365,7 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.34.2" +version = "0.35.0" dependencies = [ "heck 0.5.0", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 7d12e1f6318..257c07c7c98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,8 +102,8 @@ libp2p-rendezvous = { version = "0.15.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.27.0", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.2.0-alpha", path = "protocols/stream" } -libp2p-swarm = { version = "0.45.0", path = "swarm" } -libp2p-swarm-derive = { version = "=0.34.2", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. +libp2p-swarm = { version = "0.45.1", path = "swarm" } +libp2p-swarm-derive = { version = "=0.35.0", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.4.0", path = "swarm-test" } libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } libp2p-tls = { version = "0.5.0", path = "transports/tls" } diff --git a/swarm-derive/CHANGELOG.md b/swarm-derive/CHANGELOG.md index 271025aee9f..25932459ba8 100644 --- a/swarm-derive/CHANGELOG.md +++ b/swarm-derive/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.35.0 + +- Implement refactored `Transport`. + See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) + ## 0.34.2 - Generate code for `libp2p-swarm`'s `FromSwarm::NewExternalAddrOfPeer` enum variant. diff --git a/swarm-derive/Cargo.toml b/swarm-derive/Cargo.toml index b31ea188962..91c643a459d 100644 --- a/swarm-derive/Cargo.toml +++ b/swarm-derive/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm-derive" edition = "2021" rust-version = { workspace = true } description = "Procedural macros of libp2p-swarm" -version = "0.34.2" +version = "0.35.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 9aeaa5a1ccc..b5fb72d68ac 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.45.1 + +- Update `libp2p-swarm-derive` to version `0.35.0`, see [PR XXXX] + +[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX ## 0.45.0 diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 375f51490a8..3d0b1a84eee 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition = "2021" rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.45.0" +version = "0.45.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" From c34668e2ca6ab6fad4e097fceeeccc1f4881b3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Sat, 10 Aug 2024 14:25:52 +0100 Subject: [PATCH 211/246] chore(swarm): add PR number to 0.45.1 release Pull-Request: #5548. --- swarm/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index b5fb72d68ac..e7931a60de2 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,8 +1,8 @@ ## 0.45.1 -- Update `libp2p-swarm-derive` to version `0.35.0`, see [PR XXXX] +- Update `libp2p-swarm-derive` to version `0.35.0`, see [PR 5545] -[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX +[PR 5545]: https://github.com/libp2p/rust-libp2p/pull/5545 ## 0.45.0 From 0ca13880bfece59ee01531d89297e62c3487980b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Sat, 10 Aug 2024 15:32:44 +0100 Subject: [PATCH 212/246] fix(quic): release libp2p-quic 0.11.1 closes #5546 Pull-Request: #5547. --- Cargo.lock | 2 +- Cargo.toml | 2 +- transports/quic/CHANGELOG.md | 6 ++++++ transports/quic/Cargo.toml | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70744c1bf40..65a3f27bbdf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3177,7 +3177,7 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.11.0" +version = "0.11.1" dependencies = [ "async-std", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 257c07c7c98..92562489ed5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,7 +96,7 @@ libp2p-perf = { version = "0.4.0", path = "protocols/perf" } libp2p-ping = { version = "0.45.0", path = "protocols/ping" } libp2p-plaintext = { version = "0.42.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.25.0", path = "transports/pnet" } -libp2p-quic = { version = "0.11.0", path = "transports/quic" } +libp2p-quic = { version = "0.11.1", path = "transports/quic" } libp2p-relay = { version = "0.18.0", path = "protocols/relay" } libp2p-rendezvous = { version = "0.15.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.27.0", path = "protocols/request-response" } diff --git a/transports/quic/CHANGELOG.md b/transports/quic/CHANGELOG.md index 2593af605df..6fc64c5df36 100644 --- a/transports/quic/CHANGELOG.md +++ b/transports/quic/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.11.1 + +- Update `libp2p-tls` to version `0.5.0`, see [PR 5547] + +[PR 5547]: https://github.com/libp2p/rust-libp2p/pull/5547 + ## 0.11.0 - Implement refactored `Transport`. diff --git a/transports/quic/Cargo.toml b/transports/quic/Cargo.toml index 1f540c9542a..42cc8e54edb 100644 --- a/transports/quic/Cargo.toml +++ b/transports/quic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-quic" -version = "0.11.0" +version = "0.11.1" authors = ["Parity Technologies "] edition = "2021" rust-version = { workspace = true } From 8f5f2680f7af095d5810922df155aa49c7e74e12 Mon Sep 17 00:00:00 2001 From: timesince Date: Tue, 13 Aug 2024 08:20:52 +0800 Subject: [PATCH 213/246] chore: fix some comments fix some comments Pull-Request: #5550. --- README.md | 2 +- protocols/autonat/src/v2.rs | 4 ++-- transports/tcp/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eeab866768d..d818c6ba7b4 100644 --- a/README.md +++ b/README.md @@ -102,4 +102,4 @@ Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). - [Substrate](https://github.com/paritytech/substrate) - Framework for blockchain innovation, used by [Polkadot](https://www.parity.io/technologies/polkadot/). - [Taple](https://github.com/opencanarias/taple-core) - Sustainable DLT for asset and process traceability by [OpenCanarias](https://www.opencanarias.com/en/). -- [Ceylon](https://github.com/ceylonai/ceylon) - A Multi-Agent System (MAS) Development Framwork. +- [Ceylon](https://github.com/ceylonai/ceylon) - A Multi-Agent System (MAS) Development Framework. diff --git a/protocols/autonat/src/v2.rs b/protocols/autonat/src/v2.rs index 994497cb1a0..cdc807ea303 100644 --- a/protocols/autonat/src/v2.rs +++ b/protocols/autonat/src/v2.rs @@ -4,8 +4,8 @@ //! //! The new version fixes the issues of the first version: //! - The server now always dials back over a newly allocated port. This greatly reduces the risk of -//! false positives that often occured in the first version, when the clinet-server connection -//! occured over a hole-punched port. +//! false positives that often occurred in the first version, when the clinet-server connection +//! occurred over a hole-punched port. //! - The server protects against DoS attacks by requiring the client to send more data to the //! server then the dial back puts on the client, thus making the protocol unatractive for an //! attacker. diff --git a/transports/tcp/src/lib.rs b/transports/tcp/src/lib.rs index 386caa78b0f..4c4fa7c6b84 100644 --- a/transports/tcp/src/lib.rs +++ b/transports/tcp/src/lib.rs @@ -173,7 +173,7 @@ impl Config { /// /// The new implementation works on a per-connaction basis, defined by the behaviour. This /// removes the necessaity to configure the transport for port reuse, instead the behaviour - /// requiring this behaviour can decide wether to use port reuse or not. + /// requiring this behaviour can decide whether to use port reuse or not. /// /// The API to configure port reuse is part of [`Transport`] and the option can be found in /// [`libp2p_core::transport::DialOpts`]. From 539bdd96834170a50b364ff7b1f7751157d52160 Mon Sep 17 00:00:00 2001 From: Dave Huseby Date: Mon, 12 Aug 2024 18:36:35 -0600 Subject: [PATCH 214/246] Create funding.json (#5553) ## Description ## Notes & open questions ## Change checklist - [ ] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] A changelog entry has been made in the appropriate crates --- funding.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 funding.json diff --git a/funding.json b/funding.json new file mode 100644 index 00000000000..bcf7fc2783d --- /dev/null +++ b/funding.json @@ -0,0 +1,5 @@ +{ + "opRetro": { + "projectId": "0x966804cb492e1a4bde5d781a676a44a23d69aa5dd2562fa7a4f95bb606021c8b" + } +} From 0861e39e31f4bc5b8696111878569d18e33e4d3c Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Tue, 13 Aug 2024 18:08:07 +0300 Subject: [PATCH 215/246] chore: Fix identity changelog link Noticed this when checking changelog of the last release Pull-Request: #5556. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c3466708c9..4fccb9a489e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## Main APIs - [`libp2p-core` CHANGELOG](core/CHANGELOG.md) +- [`libp2p-identity` CHANGELOG](identity/CHANGELOG.md) - [`libp2p-swarm` CHANGELOG](swarm/CHANGELOG.md) - [`libp2p-swarm-derive` CHANGELOG](swarm-derive/CHANGELOG.md) @@ -13,7 +14,6 @@ - [`libp2p-floodsub` CHANGELOG](protocols/floodsub/CHANGELOG.md) - [`libp2p-gossipsub` CHANGELOG](protocols/gossipsub/CHANGELOG.md) - [`libp2p-identify` CHANGELOG](protocols/identify/CHANGELOG.md) -- [`libp2p-identity` CHANGELOG](protocols/identity/CHANGELOG.md) - [`libp2p-kad` CHANGELOG](protocols/kad/CHANGELOG.md) - [`libp2p-mdns` CHANGELOG](protocols/mdns/CHANGELOG.md) - [`libp2p-ping` CHANGELOG](protocols/ping/CHANGELOG.md) From d9ee266bc03e7159e415e406e35ffafbb1660d42 Mon Sep 17 00:00:00 2001 From: Mivik <54128043+Mivik@users.noreply.github.com> Date: Wed, 14 Aug 2024 00:27:40 +0800 Subject: [PATCH 216/246] feat(kad): New provider record update strategy In `MemoryStore`, the number of provider records per key is limited by `max_providers_per_key`. Former implementations keep provider records sorted by their distance to the key, and only keep those with the smallest distance. This strategy is vulnerable to Sybil attack, in which an attacker can flood the network with false identities in order to eclipse a key. This commit change the strategy to simply keep old providers and ignore new ones. This new strategy however, can cause load imbalance, but can be mitigated by increasing `max_providers_per_key`. In addition, old implementations failed to keep `provided` and `providers` in sync, and this commit fixes this issue. Pull-Request: #5536. --- Cargo.lock | 4 +- Cargo.toml | 2 +- libp2p/CHANGELOG.md | 5 + libp2p/Cargo.toml | 2 +- protocols/kad/CHANGELOG.md | 5 + protocols/kad/Cargo.toml | 2 +- protocols/kad/src/record/store/memory.rs | 122 ++++++++++++----------- 7 files changed, 79 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65a3f27bbdf..c228c7e31ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2623,7 +2623,7 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libp2p" -version = "0.54.0" +version = "0.54.1" dependencies = [ "async-std", "async-trait", @@ -2928,7 +2928,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.46.0" +version = "0.46.1" dependencies = [ "arrayvec", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 92562489ed5..802779774cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.47.0", path = "protocols/gossipsub" } libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } -libp2p-kad = { version = "0.46.0", path = "protocols/kad" } +libp2p-kad = { version = "0.46.1", path = "protocols/kad" } libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.3.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.14.2", path = "misc/metrics" } diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index 7e1b95c6e75..f2041399042 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.54.1 + +- Update individual crates. + - Update to [`libp2p-kad` `v0.46.1`](protocols/kad/CHANGELOG.md#0461). + ## 0.54.0 - Update individual crates. diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index 68a76e52b58..b1017f5958c 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p" edition = "2021" rust-version = { workspace = true } description = "Peer-to-peer networking library" -version = "0.54.0" +version = "0.54.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index cbb5a4decf2..a41d6b9a131 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.46.1 + +- Use new provider record update strategy to prevent Sybil attack. + See [PR 5536](https://github.com/libp2p/rust-libp2p/pull/5536). + ## 0.46.0 - Included multiaddresses of found peers alongside peer IDs in `GetClosestPeers` query results. diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 72b29d00ef7..a00959fced6 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-kad" edition = "2021" rust-version = { workspace = true } description = "Kademlia protocol for libp2p" -version = "0.46.0" +version = "0.46.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/kad/src/record/store/memory.rs b/protocols/kad/src/record/store/memory.rs index 3bd3c56e30c..3fb6d2be3e8 100644 --- a/protocols/kad/src/record/store/memory.rs +++ b/protocols/kad/src/record/store/memory.rs @@ -152,38 +152,31 @@ impl RecordStore for MemoryStore { } .or_insert_with(Default::default); - if let Some(i) = providers.iter().position(|p| p.provider == record.provider) { - // In-place update of an existing provider record. - providers.as_mut()[i] = record; - } else { - // It is a new provider record for that key. - let local_key = self.local_key; - let key = kbucket::Key::new(record.key.clone()); - let provider = kbucket::Key::from(record.provider); - if let Some(i) = providers.iter().position(|p| { - let pk = kbucket::Key::from(p.provider); - provider.distance(&key) < pk.distance(&key) - }) { - // Insert the new provider. - if local_key.preimage() == &record.provider { + for p in providers.iter_mut() { + if p.provider == record.provider { + // In-place update of an existing provider record. + if self.local_key.preimage() == &record.provider { + self.provided.remove(p); self.provided.insert(record.clone()); } - providers.insert(i, record); - // Remove the excess provider, if any. - if providers.len() > self.config.max_providers_per_key { - if let Some(p) = providers.pop() { - self.provided.remove(&p); - } - } - } else if providers.len() < self.config.max_providers_per_key { - // The distance of the new provider to the key is larger than - // the distance of any existing provider, but there is still room. - if local_key.preimage() == &record.provider { - self.provided.insert(record.clone()); - } - providers.push(record); + *p = record; + return Ok(()); } } + + // If the providers list is full, we ignore the new provider. + // This strategy can mitigate Sybil attacks, in which an attacker + // floods the network with fake provider records. + if providers.len() == self.config.max_providers_per_key { + return Ok(()); + } + + // Otherwise, insert the new provider record. + if self.local_key.preimage() == &record.provider { + self.provided.insert(record.clone()); + } + providers.push(record); + Ok(()) } @@ -202,7 +195,9 @@ impl RecordStore for MemoryStore { let providers = e.get_mut(); if let Some(i) = providers.iter().position(|p| &p.provider == provider) { let p = providers.remove(i); - self.provided.remove(&p); + if &p.provider == self.local_key.preimage() { + self.provided.remove(&p); + } } if providers.is_empty() { e.remove(); @@ -221,11 +216,6 @@ mod tests { fn random_multihash() -> Multihash<64> { Multihash::wrap(SHA_256_MH, &rand::thread_rng().gen::<[u8; 32]>()).unwrap() } - - fn distance(r: &ProviderRecord) -> kbucket::Distance { - kbucket::Key::new(r.key.clone()).distance(&kbucket::Key::from(r.provider)) - } - #[test] fn put_get_remove_record() { fn prop(r: Record) { @@ -250,30 +240,6 @@ mod tests { quickcheck(prop as fn(_)) } - #[test] - fn providers_ordered_by_distance_to_key() { - fn prop(providers: Vec>) -> bool { - let mut store = MemoryStore::new(PeerId::random()); - let key = Key::from(random_multihash()); - - let mut records = providers - .into_iter() - .map(|p| ProviderRecord::new(key.clone(), p.into_preimage(), Vec::new())) - .collect::>(); - - for r in &records { - assert!(store.add_provider(r.clone()).is_ok()); - } - - records.sort_by_key(distance); - records.truncate(store.config.max_providers_per_key); - - records == store.providers(&key).to_vec() - } - - quickcheck(prop as fn(_) -> _) - } - #[test] fn provided() { let id = PeerId::random(); @@ -302,6 +268,46 @@ mod tests { assert_eq!(vec![rec.clone()], store.providers(&rec.key).to_vec()); } + #[test] + fn update_provided() { + let prv = PeerId::random(); + let mut store = MemoryStore::new(prv); + let key = random_multihash(); + let mut rec = ProviderRecord::new(key, prv, Vec::new()); + assert!(store.add_provider(rec.clone()).is_ok()); + assert_eq!( + vec![Cow::Borrowed(&rec)], + store.provided().collect::>() + ); + rec.expires = Some(Instant::now()); + assert!(store.add_provider(rec.clone()).is_ok()); + assert_eq!( + vec![Cow::Borrowed(&rec)], + store.provided().collect::>() + ); + } + + #[test] + fn max_providers_per_key() { + let config = MemoryStoreConfig::default(); + let key = kbucket::Key::new(Key::from(random_multihash())); + + let mut store = MemoryStore::with_config(PeerId::random(), config.clone()); + let peers = (0..config.max_providers_per_key) + .map(|_| PeerId::random()) + .collect::>(); + for peer in peers { + let rec = ProviderRecord::new(key.preimage().clone(), peer, Vec::new()); + assert!(store.add_provider(rec).is_ok()); + } + + // The new provider cannot be added because the key is already saturated. + let peer = PeerId::random(); + let rec = ProviderRecord::new(key.preimage().clone(), peer, Vec::new()); + assert!(store.add_provider(rec.clone()).is_ok()); + assert!(!store.providers(&rec.key).contains(&rec)); + } + #[test] fn max_provided_keys() { let mut store = MemoryStore::new(PeerId::random()); From 41f67c975cbdd686738a801dfb9e3533a6c96874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Mon, 19 Aug 2024 15:31:52 +0100 Subject: [PATCH 217/246] chore(metrics): release 0.15.0 Pull-Request: #5562. --- Cargo.lock | 2 +- Cargo.toml | 2 +- misc/metrics/CHANGELOG.md | 2 +- misc/metrics/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c228c7e31ac..8932f40a04c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3007,7 +3007,7 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.14.2" +version = "0.15.0" dependencies = [ "futures", "libp2p-core", diff --git a/Cargo.toml b/Cargo.toml index 802779774cb..ebd8e39c29d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,7 +89,7 @@ libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.46.1", path = "protocols/kad" } libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.3.0", path = "misc/memory-connection-limits" } -libp2p-metrics = { version = "0.14.2", path = "misc/metrics" } +libp2p-metrics = { version = "0.15.0", path = "misc/metrics" } libp2p-mplex = { version = "0.42.0", path = "muxers/mplex" } libp2p-noise = { version = "0.45.0", path = "transports/noise" } libp2p-perf = { version = "0.4.0", path = "protocols/perf" } diff --git a/misc/metrics/CHANGELOG.md b/misc/metrics/CHANGELOG.md index c36d7f95ebc..bd109c42811 100644 --- a/misc/metrics/CHANGELOG.md +++ b/misc/metrics/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.14.2 +## 0.15.0 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). diff --git a/misc/metrics/Cargo.toml b/misc/metrics/Cargo.toml index b75ea5ed0de..0b7a3c93b2f 100644 --- a/misc/metrics/Cargo.toml +++ b/misc/metrics/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-metrics" edition = "2021" rust-version = { workspace = true } description = "Metrics for libp2p" -version = "0.14.2" +version = "0.15.0" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" From d7beb55f672dce54017fa4b30f67ecb8d66b9810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Mon, 19 Aug 2024 17:17:02 +0100 Subject: [PATCH 218/246] chore(libp2p): release 0.54.1 Pull-Request: #5563. --- Cargo.toml | 2 +- libp2p/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ebd8e39c29d..31c3a8e4b9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,7 @@ rust-version = "1.75.0" asynchronous-codec = { version = "0.7.0" } futures-bounded = { version = "0.2.4" } futures-rustls = { version = "0.26.0", default-features = false } -libp2p = { version = "0.54.0", path = "libp2p" } +libp2p = { version = "0.54.1", path = "libp2p" } libp2p-allow-block-list = { version = "0.4.0", path = "misc/allow-block-list" } libp2p-autonat = { version = "0.13.0", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.4.0", path = "misc/connection-limits" } diff --git a/libp2p/CHANGELOG.md b/libp2p/CHANGELOG.md index f2041399042..72a624786d4 100644 --- a/libp2p/CHANGELOG.md +++ b/libp2p/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.54.1 - Update individual crates. - - Update to [`libp2p-kad` `v0.46.1`](protocols/kad/CHANGELOG.md#0461). + - Update to [`libp2p-metrics` `0.15.0`](misc/metrics/CHANGELOG.md#0150). ## 0.54.0 From 4dfc45bfec008405988edca2432c27ed5b93535f Mon Sep 17 00:00:00 2001 From: P1R0 Date: Wed, 21 Aug 2024 02:18:46 -0600 Subject: [PATCH 219/246] refactor: ping tutorial using tokio Solves issue #5554 also referenced first in #4449 Pull-Request: #5559. --- libp2p/src/tutorials/ping.rs | 131 +++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 60 deletions(-) diff --git a/libp2p/src/tutorials/ping.rs b/libp2p/src/tutorials/ping.rs index 309d5b36baa..31bf5ba3a14 100644 --- a/libp2p/src/tutorials/ping.rs +++ b/libp2p/src/tutorials/ping.rs @@ -44,7 +44,7 @@ //! 3. Adding `libp2p` as well as `futures` as dependencies in the //! `Cargo.toml` file. Current crate versions may be found at //! [crates.io](https://crates.io/). -//! We will also include `async-std` with the +//! We will also include `tokio` with the //! "attributes" feature to allow for an `async main`. //! At the time of writing we have: //! @@ -55,9 +55,9 @@ //! edition = "2021" //! //! [dependencies] -//! libp2p = { version = "0.52", features = ["tcp", "tls", "dns", "async-std", "noise", "yamux", "websocket", "ping", "macros"] } -//! futures = "0.3.21" -//! async-std = { version = "1.12.0", features = ["attributes"] } +//! libp2p = { version = "0.54", features = ["noise", "ping", "tcp", "tokio", "yamux"] } +//! futures = "0.3.30" +//! tokio = { version = "1.37.0", features = ["full"] } //! tracing-subscriber = { version = "0.3", features = ["env-filter"] } //! ``` //! @@ -74,9 +74,11 @@ //! use std::error::Error; //! use tracing_subscriber::EnvFilter; //! -//! #[async_std::main] +//! #[tokio::main] //! async fn main() -> Result<(), Box> { -//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init(); +//! let _ = tracing_subscriber::fmt() +//! .with_env_filter(EnvFilter::from_default_env()) +//! .try_init(); //! //! let mut swarm = libp2p::SwarmBuilder::with_new_identity(); //! @@ -89,7 +91,7 @@ //! ## Transport //! //! Next up we need to construct a transport. Each transport in libp2p provides encrypted streams. -//! E.g. combining TCP to establish connections, TLS to encrypt these connections and Yamux to run +//! E.g. combining TCP to establish connections, NOISE to encrypt these connections and Yamux to run //! one or more streams on a connection. Another libp2p transport is QUIC, providing encrypted //! streams out-of-the-box. We will stick to TCP for now. Each of these implement the [`Transport`] //! trait. @@ -97,17 +99,20 @@ //! ```rust //! use std::error::Error; //! use tracing_subscriber::EnvFilter; +//! use libp2p::{noise, tcp, yamux}; //! -//! #[async_std::main] +//! #[tokio::main] //! async fn main() -> Result<(), Box> { -//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init(); +//! let _ = tracing_subscriber::fmt() +//! .with_env_filter(EnvFilter::from_default_env()) +//! .try_init(); //! //! let mut swarm = libp2p::SwarmBuilder::with_new_identity() -//! .with_async_std() +//! .with_tokio() //! .with_tcp( -//! libp2p::tcp::Config::default(), -//! libp2p::tls::Config::new, -//! libp2p::yamux::Config::default, +//! tcp::Config::default(), +//! noise::Config::new, +//! yamux::Config::default, //! )?; //! //! Ok(()) @@ -137,20 +142,22 @@ //! With the above in mind, let's extend our example, creating a [`ping::Behaviour`](crate::ping::Behaviour) at the end: //! //! ```rust -//! use libp2p::ping; -//! use tracing_subscriber::EnvFilter; //! use std::error::Error; +//! use tracing_subscriber::EnvFilter; +//! use libp2p::{noise, ping, tcp, yamux}; //! -//! #[async_std::main] +//! #[tokio::main] //! async fn main() -> Result<(), Box> { -//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init(); +//! let _ = tracing_subscriber::fmt() +//! .with_env_filter(EnvFilter::from_default_env()) +//! .try_init(); //! //! let mut swarm = libp2p::SwarmBuilder::with_new_identity() -//! .with_async_std() +//! .with_tokio() //! .with_tcp( -//! libp2p::tcp::Config::default(), -//! libp2p::tls::Config::new, -//! libp2p::yamux::Config::default, +//! tcp::Config::default(), +//! noise::Config::new, +//! yamux::Config::default, //! )? //! .with_behaviour(|_| ping::Behaviour::default())?; //! @@ -166,20 +173,22 @@ //! to the [`Transport`] as well as events from the [`Transport`] to the [`NetworkBehaviour`]. //! //! ```rust -//! use libp2p::ping; //! use std::error::Error; //! use tracing_subscriber::EnvFilter; +//! use libp2p::{noise, ping, tcp, yamux}; //! -//! #[async_std::main] +//! #[tokio::main] //! async fn main() -> Result<(), Box> { -//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init(); +//! let _ = tracing_subscriber::fmt() +//! .with_env_filter(EnvFilter::from_default_env()) +//! .try_init(); //! //! let mut swarm = libp2p::SwarmBuilder::with_new_identity() -//! .with_async_std() +//! .with_tokio() //! .with_tcp( -//! libp2p::tcp::Config::default(), -//! libp2p::tls::Config::new, -//! libp2p::yamux::Config::default, +//! tcp::Config::default(), +//! noise::Config::new, +//! yamux::Config::default, //! )? //! .with_behaviour(|_| ping::Behaviour::default())? //! .build(); @@ -199,24 +208,25 @@ //! Thus, without any other behaviour in place, we would not be able to observe the pings. //! //! ```rust -//! use libp2p::ping; -//! use std::error::Error; -//! use std::time::Duration; +//! use std::{error::Error, time::Duration}; //! use tracing_subscriber::EnvFilter; +//! use libp2p::{noise, ping, tcp, yamux}; //! -//! #[async_std::main] +//! #[tokio::main] //! async fn main() -> Result<(), Box> { -//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init(); +//! let _ = tracing_subscriber::fmt() +//! .with_env_filter(EnvFilter::from_default_env()) +//! .try_init(); //! //! let mut swarm = libp2p::SwarmBuilder::with_new_identity() -//! .with_async_std() +//! .with_tokio() //! .with_tcp( -//! libp2p::tcp::Config::default(), -//! libp2p::tls::Config::new, -//! libp2p::yamux::Config::default, +//! tcp::Config::default(), +//! noise::Config::new, +//! yamux::Config::default, //! )? //! .with_behaviour(|_| ping::Behaviour::default())? -//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) // Allows us to observe pings indefinitely. +//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) //! .build(); //! //! Ok(()) @@ -250,24 +260,25 @@ //! remote peer. //! //! ```rust -//! use libp2p::{ping, Multiaddr}; -//! use std::error::Error; -//! use std::time::Duration; +//! use std::{error::Error, time::Duration}; //! use tracing_subscriber::EnvFilter; +//! use libp2p::{noise, ping, tcp, yamux, Multiaddr}; //! -//! #[async_std::main] +//! #[tokio::main] //! async fn main() -> Result<(), Box> { -//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init(); +//! let _ = tracing_subscriber::fmt() +//! .with_env_filter(EnvFilter::from_default_env()) +//! .try_init(); //! //! let mut swarm = libp2p::SwarmBuilder::with_new_identity() -//! .with_async_std() +//! .with_tokio() //! .with_tcp( -//! libp2p::tcp::Config::default(), -//! libp2p::tls::Config::new, -//! libp2p::yamux::Config::default, +//! tcp::Config::default(), +//! noise::Config::new, +//! yamux::Config::default, //! )? //! .with_behaviour(|_| ping::Behaviour::default())? -//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) // Allows us to observe pings indefinitely.. +//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) //! .build(); //! //! // Tell the swarm to listen on all interfaces and a random, OS-assigned @@ -293,26 +304,26 @@ //! outgoing connection in case we specify an address on the CLI. //! //! ```no_run -//! use futures::prelude::*; -//! use libp2p::swarm::SwarmEvent; -//! use libp2p::{ping, Multiaddr}; -//! use std::error::Error; -//! use std::time::Duration; +//! use std::{error::Error, time::Duration}; //! use tracing_subscriber::EnvFilter; +//! use libp2p::{noise, ping, tcp, yamux, Multiaddr, swarm::SwarmEvent}; +//! use futures::prelude::*; //! -//! #[async_std::main] +//! #[tokio::main] //! async fn main() -> Result<(), Box> { -//! tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init(); +//! let _ = tracing_subscriber::fmt() +//! .with_env_filter(EnvFilter::from_default_env()) +//! .try_init(); //! //! let mut swarm = libp2p::SwarmBuilder::with_new_identity() -//! .with_async_std() +//! .with_tokio() //! .with_tcp( -//! libp2p::tcp::Config::default(), -//! libp2p::tls::Config::new, -//! libp2p::yamux::Config::default, +//! tcp::Config::default(), +//! noise::Config::new, +//! yamux::Config::default, //! )? //! .with_behaviour(|_| ping::Behaviour::default())? -//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) // Allows us to observe pings indefinitely. +//! .with_swarm_config(|cfg| cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))) //! .build(); //! //! // Tell the swarm to listen on all interfaces and a random, OS-assigned From f0cbd4fb0cef8d1ae2298901eab95acb5f104ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Thu, 22 Aug 2024 18:49:08 +0100 Subject: [PATCH 220/246] chore(ci): update Rust stable version Pull-Request: #5568. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0465540d47..2c1dfc8aaef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -225,7 +225,7 @@ jobs: fail-fast: false matrix: rust-version: [ - 1.78.0, # current stable + 1.80.0, # current stable beta, ] steps: From de8cba961b16d2f418153c6ca550f39256d8c12b Mon Sep 17 00:00:00 2001 From: Panagiotis Ganelis <50522617+PanGan21@users.noreply.github.com> Date: Tue, 27 Aug 2024 10:25:13 +0300 Subject: [PATCH 221/246] feat(kad): emit `ToSwarm::NewExternalAddrOfPeer` (#5549) ## Description Updates `libp2p-kad` to emit new event `ToSwarm::NewExternalAddrOfPeer` whenever it discovers a new address through the DHT. Related: #5103 ## Notes & open questions ## Change checklist - [X] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [X] I have added tests that prove my fix is effective or that my feature works - [ ] A changelog entry has been made in the appropriate crates --------- Co-authored-by: Guillaume Michel --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/kad/CHANGELOG.md | 5 +++++ protocols/kad/Cargo.toml | 2 +- protocols/kad/src/behaviour.rs | 8 +++++++- protocols/kad/tests/client_mode.rs | 18 ++++++++++++++++-- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8932f40a04c..783480bb8b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2928,7 +2928,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.46.1" +version = "0.46.2" dependencies = [ "arrayvec", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 31c3a8e4b9e..8216c7a1787 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.47.0", path = "protocols/gossipsub" } libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } -libp2p-kad = { version = "0.46.1", path = "protocols/kad" } +libp2p-kad = { version = "0.46.2", path = "protocols/kad" } libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.3.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.15.0", path = "misc/metrics" } diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index a41d6b9a131..f4e25e0de05 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.46.2 + +- Emit `ToSwarm::NewExternalAddrOfPeer`. + See [PR 5549](https://github.com/libp2p/rust-libp2p/pull/5549) + ## 0.46.1 - Use new provider record update strategy to prevent Sybil attack. diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index a00959fced6..11a670933db 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-kad" edition = "2021" rust-version = { workspace = true } description = "Kademlia protocol for libp2p" -version = "0.46.1" +version = "0.46.2" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index fc3d8a1adaa..a541648707a 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -2562,13 +2562,19 @@ where // Drain applied pending entries from the routing table. if let Some(entry) = self.kbuckets.take_applied_pending() { let kbucket::Node { key, value } = entry.inserted; + let peer_id = key.into_preimage(); + self.queued_events + .push_back(ToSwarm::NewExternalAddrOfPeer { + peer_id, + address: value.first().clone(), + }); let event = Event::RoutingUpdated { bucket_range: self .kbuckets .bucket(&key) .map(|b| b.range()) .expect("Self to never be applied from pending."), - peer: key.into_preimage(), + peer: peer_id, is_new_peer: true, addresses: value, old_peer: entry.evicted.map(|n| n.key.into_preimage()), diff --git a/protocols/kad/tests/client_mode.rs b/protocols/kad/tests/client_mode.rs index 6aceeb27263..2c8d11beac7 100644 --- a/protocols/kad/tests/client_mode.rs +++ b/protocols/kad/tests/client_mode.rs @@ -23,14 +23,21 @@ async fn server_gets_added_to_routing_table_by_client() { let server_peer_id = *server.local_peer_id(); async_std::task::spawn(server.loop_on_next()); - let peer = client + let external_event_peer = client + .wait(|e| match e { + SwarmEvent::NewExternalAddrOfPeer { peer_id, .. } => Some(peer_id), + _ => None, + }) + .await; + let routing_updated_peer = client .wait(|e| match e { SwarmEvent::Behaviour(Kad(RoutingUpdated { peer, .. })) => Some(peer), _ => None, }) .await; - assert_eq!(peer, server_peer_id); + assert_eq!(external_event_peer, server_peer_id); + assert_eq!(routing_updated_peer, server_peer_id); } #[async_std::test] @@ -126,6 +133,12 @@ async fn set_client_to_server_mode() { let server_peer_id = *server.local_peer_id(); + let peer_id = client + .wait(|e| match e { + SwarmEvent::NewExternalAddrOfPeer { peer_id, .. } => Some(peer_id), + _ => None, + }) + .await; let client_event = client.wait(|e| match e { SwarmEvent::Behaviour(Kad(RoutingUpdated { peer, .. })) => Some(peer), _ => None, @@ -138,6 +151,7 @@ async fn set_client_to_server_mode() { let (peer, info) = futures::future::join(client_event, server_event).await; assert_eq!(peer, server_peer_id); + assert_eq!(peer_id, server_peer_id); assert!(info .protocols .iter() From aa9317fbdd88cc4c9a39ea608fa1d57e022297fc Mon Sep 17 00:00:00 2001 From: Probot <94048855+Prabhat1308@users.noreply.github.com> Date: Tue, 27 Aug 2024 18:32:30 +0530 Subject: [PATCH 222/246] fix: Change `__Nonexhaustive` to `__Invalid` and update web-sys (#5569) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Bumps up web-sys version to `0.3.70` fixes #5557 ## Change checklist - [X] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [X] A changelog entry has been made in the appropriate crates --------- Co-authored-by: Darius Clark Co-authored-by: João Oliveira Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- Cargo.lock | 54 +++++++++++-------- Cargo.toml | 2 +- transports/webrtc-websys/CHANGELOG.md | 5 ++ transports/webrtc-websys/Cargo.toml | 4 +- transports/webrtc-websys/src/connection.rs | 9 ++-- transports/webrtc-websys/src/sdp.rs | 8 +-- .../src/stream/poll_data_channel.rs | 3 +- transports/webtransport-websys/CHANGELOG.md | 2 + transports/webtransport-websys/Cargo.toml | 8 +-- wasm-tests/webtransport-tests/Cargo.toml | 8 +-- 10 files changed, 62 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 783480bb8b1..d4350c0496b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2571,9 +2571,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -3509,7 +3509,7 @@ dependencies = [ [[package]] name = "libp2p-webrtc-websys" -version = "0.4.0-alpha" +version = "0.4.0-alpha.2" dependencies = [ "bytes", "futures", @@ -3804,6 +3804,16 @@ dependencies = [ "unicase", ] +[[package]] +name = "minicov" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71e683cd655513b99affab7d317deb690528255a0d5f717f1024093c12b169" +dependencies = [ + "cc", + "walkdir", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -6677,19 +6687,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -6702,9 +6713,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -6714,9 +6725,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6724,9 +6735,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", @@ -6737,18 +6748,19 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-bindgen-test" -version = "0.3.42" +version = "0.3.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" +checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" dependencies = [ "console_error_panic_hook", "js-sys", + "minicov", "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", @@ -6757,9 +6769,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.42" +version = "0.3.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" +checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" dependencies = [ "proc-macro2", "quote", @@ -6779,9 +6791,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 8216c7a1787..bd6018b024f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,7 +111,7 @@ libp2p-uds = { version = "0.41.0", path = "transports/uds" } libp2p-upnp = { version = "0.3.0", path = "protocols/upnp" } libp2p-webrtc = { version = "0.8.0-alpha", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.3.0", path = "misc/webrtc-utils" } -libp2p-webrtc-websys = { version = "0.4.0-alpha", path = "transports/webrtc-websys" } +libp2p-webrtc-websys = { version = "0.4.0-alpha.2", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.44.0", path = "transports/websocket" } libp2p-websocket-websys = { version = "0.4.0", path = "transports/websocket-websys" } libp2p-webtransport-websys = { version = "0.4.0", path = "transports/webtransport-websys" } diff --git a/transports/webrtc-websys/CHANGELOG.md b/transports/webrtc-websys/CHANGELOG.md index 475b13727e6..5b8f2efb3b0 100644 --- a/transports/webrtc-websys/CHANGELOG.md +++ b/transports/webrtc-websys/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.0-alpha.2 + +- Bump version of web-sys and update `__Nonexhaustive` to `__Invalid`. + See [PR 5569](https://github.com/libp2p/rust-libp2p/pull/5569) + ## 0.4.0-alpha - Implement refactored `Transport`. diff --git a/transports/webrtc-websys/Cargo.toml b/transports/webrtc-websys/Cargo.toml index c874b33bfc7..453abe57f74 100644 --- a/transports/webrtc-websys/Cargo.toml +++ b/transports/webrtc-websys/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" name = "libp2p-webrtc-websys" repository = "https://github.com/libp2p/rust-libp2p" rust-version = { workspace = true } -version = "0.4.0-alpha" +version = "0.4.0-alpha.2" publish = true [dependencies] @@ -25,7 +25,7 @@ thiserror = "1" tracing = { workspace = true } wasm-bindgen = { version = "0.2.90" } wasm-bindgen-futures = { version = "0.4.42" } -web-sys = { version = "0.3.69", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] } +web-sys = { version = "0.3.70", features = ["Document", "Location", "MessageEvent", "Navigator", "RtcCertificate", "RtcConfiguration", "RtcDataChannel", "RtcDataChannelEvent", "RtcDataChannelInit", "RtcDataChannelState", "RtcDataChannelType", "RtcPeerConnection", "RtcSdpType", "RtcSessionDescription", "RtcSessionDescriptionInit", "Window"] } [lints] workspace = true diff --git a/transports/webrtc-websys/src/connection.rs b/transports/webrtc-websys/src/connection.rs index b858237da63..d0c6ccd2238 100644 --- a/transports/webrtc-websys/src/connection.rs +++ b/transports/webrtc-websys/src/connection.rs @@ -186,11 +186,11 @@ impl RtcPeerConnection { let certificate = JsFuture::from(certificate_promise).await?; - let mut config = RtcConfiguration::default(); + let config = RtcConfiguration::default(); // wrap certificate in a js Array first before adding it to the config object let certificate_arr = js_sys::Array::new(); certificate_arr.push(&certificate); - config.certificates(&certificate_arr); + config.set_certificates(&certificate_arr); let inner = web_sys::RtcPeerConnection::new_with_configuration(&config)?; @@ -214,8 +214,9 @@ impl RtcPeerConnection { let dc = match negotiated { true => { - let mut options = RtcDataChannelInit::new(); - options.negotiated(true).id(0); // id is only ever set to zero when negotiated is true + let options = RtcDataChannelInit::new(); + options.set_negotiated(true); + options.set_id(0); // id is only ever set to zero when negotiated is true self.inner .create_data_channel_with_data_channel_dict(LABEL, &options) diff --git a/transports/webrtc-websys/src/sdp.rs b/transports/webrtc-websys/src/sdp.rs index 439182ea4db..9e63fd92462 100644 --- a/transports/webrtc-websys/src/sdp.rs +++ b/transports/webrtc-websys/src/sdp.rs @@ -8,8 +8,8 @@ pub(crate) fn answer( server_fingerprint: Fingerprint, client_ufrag: &str, ) -> RtcSessionDescriptionInit { - let mut answer_obj = RtcSessionDescriptionInit::new(RtcSdpType::Answer); - answer_obj.sdp(&libp2p_webrtc_utils::sdp::answer( + let answer_obj = RtcSessionDescriptionInit::new(RtcSdpType::Answer); + answer_obj.set_sdp(&libp2p_webrtc_utils::sdp::answer( addr, server_fingerprint, client_ufrag, @@ -48,8 +48,8 @@ pub(crate) fn offer(offer: String, client_ufrag: &str) -> RtcSessionDescriptionI tracing::trace!(offer=%munged_sdp_offer, "Created SDP offer"); - let mut offer_obj = RtcSessionDescriptionInit::new(RtcSdpType::Offer); - offer_obj.sdp(&munged_sdp_offer); + let offer_obj = RtcSessionDescriptionInit::new(RtcSdpType::Offer); + offer_obj.set_sdp(&munged_sdp_offer); offer_obj } diff --git a/transports/webrtc-websys/src/stream/poll_data_channel.rs b/transports/webrtc-websys/src/stream/poll_data_channel.rs index dfd861de9df..3ec744342eb 100644 --- a/transports/webrtc-websys/src/stream/poll_data_channel.rs +++ b/transports/webrtc-websys/src/stream/poll_data_channel.rs @@ -143,7 +143,8 @@ impl PollDataChannel { RtcDataChannelState::Closing | RtcDataChannelState::Closed => { return Poll::Ready(Err(io::ErrorKind::BrokenPipe.into())) } - RtcDataChannelState::Open | RtcDataChannelState::__Nonexhaustive => {} + RtcDataChannelState::Open | RtcDataChannelState::__Invalid => {} + _ => {} } if self.overloaded.load(Ordering::SeqCst) { diff --git a/transports/webtransport-websys/CHANGELOG.md b/transports/webtransport-websys/CHANGELOG.md index 2aab226ab12..411117918bd 100644 --- a/transports/webtransport-websys/CHANGELOG.md +++ b/transports/webtransport-websys/CHANGELOG.md @@ -2,6 +2,8 @@ - Implement refactored `Transport`. See [PR 4568](https://github.com/libp2p/rust-libp2p/pull/4568) +- Bump version of web-sys and wasm-bindgen. + See [PR 5569](https://github.com/libp2p/rust-libp2p/pull/5569) ## 0.3.0 diff --git a/transports/webtransport-websys/Cargo.toml b/transports/webtransport-websys/Cargo.toml index 370158190b1..9541c49b737 100644 --- a/transports/webtransport-websys/Cargo.toml +++ b/transports/webtransport-websys/Cargo.toml @@ -15,7 +15,7 @@ categories = ["network-programming", "asynchronous"] [dependencies] futures = { workspace = true } -js-sys = "0.3.69" +js-sys = "0.3.70" libp2p-core = { workspace = true } libp2p-identity = { workspace = true } libp2p-noise = { workspace = true } @@ -24,9 +24,9 @@ multihash = { workspace = true } send_wrapper = { version = "0.6.0", features = ["futures"] } thiserror = "1.0.61" tracing = { workspace = true } -wasm-bindgen = "0.2.90" -wasm-bindgen-futures = "0.4.42" -web-sys = { version = "0.3.69", features = [ +wasm-bindgen = "0.2.93" +wasm-bindgen-futures = "0.4.43" +web-sys = { version = "0.3.70", features = [ "ReadableStreamDefaultReader", "WebTransport", "WebTransportBidirectionalStream", diff --git a/wasm-tests/webtransport-tests/Cargo.toml b/wasm-tests/webtransport-tests/Cargo.toml index cf51a510a3f..d7db378ab1a 100644 --- a/wasm-tests/webtransport-tests/Cargo.toml +++ b/wasm-tests/webtransport-tests/Cargo.toml @@ -17,10 +17,10 @@ libp2p-noise = { workspace = true } libp2p-webtransport-websys = { workspace = true } multiaddr = { workspace = true } multihash = { workspace = true } -wasm-bindgen = "0.2.90" -wasm-bindgen-futures = "0.4.42" -wasm-bindgen-test = "0.3.42" -web-sys = { version = "0.3.69", features = ["Response", "Window"] } +wasm-bindgen = "0.2.93" +wasm-bindgen-futures = "0.4.43" +wasm-bindgen-test = "0.3.43" +web-sys = { version = "0.3.70", features = ["Response", "Window"] } [lints] workspace = true From 56b6c62f6c71e8fa217e9e772d98824ba5d79c5c Mon Sep 17 00:00:00 2001 From: maqi Date: Wed, 28 Aug 2024 00:03:31 +0800 Subject: [PATCH 223/246] feat(kad): expose a kad query facility allowing dynamic num_results (#5555) ## Description This PR is to expose a kad query facility that allowing specify num_results dynamically. It is related to the [Sybil Defence issue](https://github.com/libp2p/rust-libp2p/issues/4769), that during the attempt of implementation on higher level code, it is find will be useful if libp2p-kad can expose such facility. The PR try not to cause any interference to the existing work flow, only introduce an `extra exposal`. ## Change checklist - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/kad/CHANGELOG.md | 5 +++ protocols/kad/Cargo.toml | 2 +- protocols/kad/src/behaviour.rs | 32 ++++++++++++++- protocols/kad/src/behaviour/test.rs | 64 ++++++++++++++++++++++++++++- protocols/kad/src/query.rs | 10 ++++- 7 files changed, 110 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4350c0496b..41ed8883c52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2928,7 +2928,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.46.2" +version = "0.47.0" dependencies = [ "arrayvec", "async-std", diff --git a/Cargo.toml b/Cargo.toml index bd6018b024f..c23bb8650f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.47.0", path = "protocols/gossipsub" } libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } -libp2p-kad = { version = "0.46.2", path = "protocols/kad" } +libp2p-kad = { version = "0.47.0", path = "protocols/kad" } libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" } libp2p-memory-connection-limits = { version = "0.3.0", path = "misc/memory-connection-limits" } libp2p-metrics = { version = "0.15.0", path = "misc/metrics" } diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index f4e25e0de05..12ccca2d7f1 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.47.0 + +- Expose a kad query facility allowing specify num_results dynamicly. + See [PR 5555](https://github.com/libp2p/rust-libp2p/pull/5555). + ## 0.46.2 - Emit `ToSwarm::NewExternalAddrOfPeer`. diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 11a670933db..5b95b8ac17d 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-kad" edition = "2021" rust-version = { workspace = true } description = "Kademlia protocol for libp2p" -version = "0.46.2" +version = "0.47.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index a541648707a..50715c53c74 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -732,6 +732,31 @@ where /// The result of the query is delivered in a /// [`Event::OutboundQueryProgressed{QueryResult::GetClosestPeers}`]. pub fn get_closest_peers(&mut self, key: K) -> QueryId + where + K: Into> + Into> + Clone, + { + self.get_closest_peers_inner(key, None) + } + + /// Initiates an iterative query for the closest peers to the given key. + /// The expected responding peers is specified by `num_results` + /// Note that the result is capped after exceeds K_VALUE + /// + /// The result of the query is delivered in a + /// [`Event::OutboundQueryProgressed{QueryResult::GetClosestPeers}`]. + pub fn get_n_closest_peers(&mut self, key: K, num_results: NonZeroUsize) -> QueryId + where + K: Into> + Into> + Clone, + { + // The inner code never expect higher than K_VALUE results to be returned. + // And removing such cap will be tricky, + // since it would involve forging a new key and additional requests. + // Hence bound to K_VALUE here to set clear expectation and prevent unexpected behaviour. + let capped_num_results = std::cmp::min(num_results, K_VALUE); + self.get_closest_peers_inner(key, Some(capped_num_results)) + } + + fn get_closest_peers_inner(&mut self, key: K, num_results: Option) -> QueryId where K: Into> + Into> + Clone, { @@ -740,6 +765,7 @@ where let info = QueryInfo::GetClosestPeers { key, step: ProgressStep::first(), + num_results, }; let peer_keys: Vec> = self.kbuckets.closest_keys(&target).collect(); self.queries.add_iter_closest(target, peer_keys, info) @@ -1485,7 +1511,7 @@ where }) } - QueryInfo::GetClosestPeers { key, mut step } => { + QueryInfo::GetClosestPeers { key, mut step, .. } => { step.last = true; Some(Event::OutboundQueryProgressed { @@ -1702,7 +1728,7 @@ where }, }), - QueryInfo::GetClosestPeers { key, mut step } => { + QueryInfo::GetClosestPeers { key, mut step, .. } => { step.last = true; Some(Event::OutboundQueryProgressed { id: query_id, @@ -3181,6 +3207,8 @@ pub enum QueryInfo { key: Vec, /// Current index of events. step: ProgressStep, + /// If required, `num_results` specifies expected responding peers + num_results: Option, }, /// A (repeated) query initiated by [`Behaviour::get_providers`]. diff --git a/protocols/kad/src/behaviour/test.rs b/protocols/kad/src/behaviour/test.rs index c4859f2f138..7409168ac2a 100644 --- a/protocols/kad/src/behaviour/test.rs +++ b/protocols/kad/src/behaviour/test.rs @@ -263,7 +263,7 @@ fn query_iter() { match swarms[0].behaviour_mut().query(&qid) { Some(q) => match q.info() { - QueryInfo::GetClosestPeers { key, step } => { + QueryInfo::GetClosestPeers { key, step, .. } => { assert_eq!(&key[..], search_target.to_bytes().as_slice()); assert_eq!(usize::from(step.count), 1); } @@ -425,6 +425,68 @@ fn unresponsive_not_returned_indirect() { })) } +// Test the result of get_closest_peers with different num_results +// Note that the result is capped after exceeds K_VALUE +#[test] +fn get_closest_with_different_num_results() { + let k_value = K_VALUE.get(); + for replication_factor in [5, k_value / 2, k_value] { + for num_results in k_value / 2..k_value * 2 { + get_closest_with_different_num_results_inner(num_results, replication_factor) + } + } +} + +fn get_closest_with_different_num_results_inner(num_results: usize, replication_factor: usize) { + let k_value = K_VALUE.get(); + let num_of_nodes = 3 * k_value; + let mut cfg = Config::new(PROTOCOL_NAME); + cfg.set_replication_factor(NonZeroUsize::new(replication_factor).unwrap()); + let swarms = build_connected_nodes_with_config(num_of_nodes, replication_factor - 1, cfg); + + let mut swarms = swarms + .into_iter() + .map(|(_addr, swarm)| swarm) + .collect::>(); + + // Ask first to search a random value. + let search_target = PeerId::random(); + let Some(num_results_nonzero) = std::num::NonZeroUsize::new(num_results) else { + panic!("Unexpected NonZeroUsize val of {num_results}"); + }; + swarms[0] + .behaviour_mut() + .get_n_closest_peers(search_target, num_results_nonzero); + + block_on(poll_fn(move |ctx| { + for swarm in &mut swarms { + loop { + match swarm.poll_next_unpin(ctx) { + Poll::Ready(Some(SwarmEvent::Behaviour(Event::OutboundQueryProgressed { + result: QueryResult::GetClosestPeers(Ok(ok)), + .. + }))) => { + assert_eq!(&ok.key[..], search_target.to_bytes().as_slice()); + if num_results > k_value { + assert_eq!(ok.peers.len(), k_value, "Failed with replication_factor: {replication_factor}, num_results: {num_results}"); + } else { + assert_eq!(ok.peers.len(), num_results, "Failed with replication_factor: {replication_factor}, num_results: {num_results}"); + } + + return Poll::Ready(()); + } + // Ignore any other event. + Poll::Ready(Some(_)) => (), + e @ Poll::Ready(_) => panic!("Unexpected return value: {e:?}"), + Poll::Pending => break, + } + } + } + + Poll::Pending + })) +} + #[test] fn get_record_not_found() { let mut swarms = build_nodes(3); diff --git a/protocols/kad/src/query.rs b/protocols/kad/src/query.rs index c598bac012e..1a895d9627c 100644 --- a/protocols/kad/src/query.rs +++ b/protocols/kad/src/query.rs @@ -138,8 +138,16 @@ impl QueryPool { T: Into + Clone, I: IntoIterator>, { + let num_results = match info { + QueryInfo::GetClosestPeers { + num_results: Some(val), + .. + } => val, + _ => self.config.replication_factor, + }; + let cfg = ClosestPeersIterConfig { - num_results: self.config.replication_factor, + num_results, parallelism: self.config.parallelism, ..ClosestPeersIterConfig::default() }; From 64c6eb299ce905b2f81fd1317ec616f56dd37986 Mon Sep 17 00:00:00 2001 From: Elias Rad <146735585+nnsW3@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:54:23 +0300 Subject: [PATCH 224/246] chore: fix spelling issues (#5522) Hello I found several spelling issues in your docs. Br, Elias. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- docs/maintainer-handbook.md | 2 +- examples/ipfs-kad/README.md | 2 +- wasm-tests/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/maintainer-handbook.md b/docs/maintainer-handbook.md index 6d36f6fe77c..0b090901216 100644 --- a/docs/maintainer-handbook.md +++ b/docs/maintainer-handbook.md @@ -31,7 +31,7 @@ This will have mergify approve your PR, thus fulfilling all requirements to auto Our CI checks that each crate which is modified gets a changelog entry. Whilst this is a good default safety-wise, it creates a lot of false-positives for changes that are internal and don't need a changelog entry. -For PRs that in the categories `chore`, `deps`, `refactor` and `docs`, this check is disabled automatically. +For PRs in the categories `chore`, `deps`, `refactor` and `docs`, this check is disabled automatically. Any other PR needs to explicitly disable this check if desired by applying the `internal-change` label. ## Dependencies diff --git a/examples/ipfs-kad/README.md b/examples/ipfs-kad/README.md index a46246a3920..05556c89382 100644 --- a/examples/ipfs-kad/README.md +++ b/examples/ipfs-kad/README.md @@ -87,5 +87,5 @@ Failed to insert the PK record ## Conclusion In conclusion, this example provides a practical demonstration of using the Rust P2P Library to interact with the Kademlia protocol on the IPFS network. -By examining the code and running the example, users can gain insights into the inner workings of Kademlia and how it performs various basic actions like getting the closes peers or inserting records into the DHT. +By examining the code and running the example, users can gain insights into the inner workings of Kademlia and how it performs various basic actions like getting the closest peers or inserting records into the DHT. This knowledge can be valuable when developing peer-to-peer applications or understanding decentralized networks. diff --git a/wasm-tests/README.md b/wasm-tests/README.md index 1d0902b106c..2538e48a145 100644 --- a/wasm-tests/README.md +++ b/wasm-tests/README.md @@ -8,4 +8,4 @@ Before you run the tests you need to install the following: # Run tests -Just call `run-all.sh` or `run.sh` in the test directory you are interested. +Just call `run-all.sh` or `run.sh` in the test directory if you are interested. From e63975d7742710d4498b941e151c5177e06392ce Mon Sep 17 00:00:00 2001 From: stormshield-frb <144998884+stormshield-frb@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:07:26 +0200 Subject: [PATCH 225/246] feat(allow-block-list): add getters and return results (#5572) ## Description Small changes to improve usability of the `allow-block-list` Behaviour. When trying to use it, we found ourselves wanting to known: - which were the current allowed or blocked peers: hence the new methods `allowed_peers` and `blocked_peers` - if the peer was already present in the set when adding or removing it from the set: that is why `allow/disallow_peer` and `block/unblock_peer` methods now return a boolean, allowing the end user the know if there was a change or not (in our case, we needed it in order to log something). ## Notes & open questions ## Change checklist - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates --- Cargo.lock | 2 +- Cargo.toml | 2 +- misc/allow-block-list/CHANGELOG.md | 6 +++ misc/allow-block-list/Cargo.toml | 2 +- misc/allow-block-list/src/lib.rs | 66 ++++++++++++++++++++++-------- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41ed8883c52..7f37b652c30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2675,7 +2675,7 @@ dependencies = [ [[package]] name = "libp2p-allow-block-list" -version = "0.4.0" +version = "0.4.1" dependencies = [ "async-std", "libp2p-core", diff --git a/Cargo.toml b/Cargo.toml index c23bb8650f3..8d63ac3ee1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ asynchronous-codec = { version = "0.7.0" } futures-bounded = { version = "0.2.4" } futures-rustls = { version = "0.26.0", default-features = false } libp2p = { version = "0.54.1", path = "libp2p" } -libp2p-allow-block-list = { version = "0.4.0", path = "misc/allow-block-list" } +libp2p-allow-block-list = { version = "0.4.1", path = "misc/allow-block-list" } libp2p-autonat = { version = "0.13.0", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.4.0", path = "misc/connection-limits" } libp2p-core = { version = "0.42.0", path = "core" } diff --git a/misc/allow-block-list/CHANGELOG.md b/misc/allow-block-list/CHANGELOG.md index 0017cbc8648..3cda0603ee4 100644 --- a/misc/allow-block-list/CHANGELOG.md +++ b/misc/allow-block-list/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.4.1 + +- Add getters & setters for the allowed/blocked peers. + Return a `bool` for every "insert/remove" function, informing if a change was performed. + See [PR 5572](https://github.com/libp2p/rust-libp2p/pull/5572). + ## 0.4.0 diff --git a/misc/allow-block-list/Cargo.toml b/misc/allow-block-list/Cargo.toml index 4209d72ab4f..1ff0ccff906 100644 --- a/misc/allow-block-list/Cargo.toml +++ b/misc/allow-block-list/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-allow-block-list" edition = "2021" rust-version = { workspace = true } description = "Allow/block list connection management for libp2p." -version = "0.4.0" +version = "0.4.1" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] diff --git a/misc/allow-block-list/src/lib.rs b/misc/allow-block-list/src/lib.rs index c877ab09c9b..7646638a651 100644 --- a/misc/allow-block-list/src/lib.rs +++ b/misc/allow-block-list/src/lib.rs @@ -94,44 +94,74 @@ pub struct BlockedPeers { } impl Behaviour { + /// Peers that are currently allowed. + pub fn allowed_peers(&self) -> &HashSet { + &self.state.peers + } + /// Allow connections to the given peer. - pub fn allow_peer(&mut self, peer: PeerId) { - self.state.peers.insert(peer); - if let Some(waker) = self.waker.take() { - waker.wake() + /// + /// Returns whether the peer was newly inserted. Does nothing if the peer was already present in the set. + pub fn allow_peer(&mut self, peer: PeerId) -> bool { + let inserted = self.state.peers.insert(peer); + if inserted { + if let Some(waker) = self.waker.take() { + waker.wake() + } } + inserted } /// Disallow connections to the given peer. /// /// All active connections to this peer will be closed immediately. - pub fn disallow_peer(&mut self, peer: PeerId) { - self.state.peers.remove(&peer); - self.close_connections.push_back(peer); - if let Some(waker) = self.waker.take() { - waker.wake() + /// + /// Returns whether the peer was present in the set. Does nothing if the peer was not present in the set. + pub fn disallow_peer(&mut self, peer: PeerId) -> bool { + let removed = self.state.peers.remove(&peer); + if removed { + self.close_connections.push_back(peer); + if let Some(waker) = self.waker.take() { + waker.wake() + } } + removed } } impl Behaviour { + /// Peers that are currently blocked. + pub fn blocked_peers(&self) -> &HashSet { + &self.state.peers + } + /// Block connections to a given peer. /// /// All active connections to this peer will be closed immediately. - pub fn block_peer(&mut self, peer: PeerId) { - self.state.peers.insert(peer); - self.close_connections.push_back(peer); - if let Some(waker) = self.waker.take() { - waker.wake() + /// + /// Returns whether the peer was newly inserted. Does nothing if the peer was already present in the set. + pub fn block_peer(&mut self, peer: PeerId) -> bool { + let inserted = self.state.peers.insert(peer); + if inserted { + self.close_connections.push_back(peer); + if let Some(waker) = self.waker.take() { + waker.wake() + } } + inserted } /// Unblock connections to a given peer. - pub fn unblock_peer(&mut self, peer: PeerId) { - self.state.peers.remove(&peer); - if let Some(waker) = self.waker.take() { - waker.wake() + /// + /// Returns whether the peer was present in the set. Does nothing if the peer was not present in the set. + pub fn unblock_peer(&mut self, peer: PeerId) -> bool { + let removed = self.state.peers.remove(&peer); + if removed { + if let Some(waker) = self.waker.take() { + waker.wake() + } } + removed } } From cefd22b8846ab005b311d5a3bc3d90c7e3a67872 Mon Sep 17 00:00:00 2001 From: stormshield-frb <144998884+stormshield-frb@users.noreply.github.com> Date: Thu, 29 Aug 2024 16:58:41 +0200 Subject: [PATCH 226/246] feat(kad): add `mode` getter on `Behaviour` (#5573) ## Description Small PR adding a getter for the `mode` attribute of the `kad::Behaviour` in order to get the mode that the DHT is operating in, at the moment. In our project, we needed to expose an API endpoint which included the mode that the DHT was operating. Having a getter was necessary so we are upstreaming this change. ## Notes & open questions ## Change checklist - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates --- protocols/kad/CHANGELOG.md | 3 +++ protocols/kad/src/behaviour.rs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 12ccca2d7f1..d0ab7986aad 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -2,6 +2,9 @@ - Expose a kad query facility allowing specify num_results dynamicly. See [PR 5555](https://github.com/libp2p/rust-libp2p/pull/5555). +- Add `mode` getter on `Behaviour`. + See [PR 5573](https://github.com/libp2p/rust-libp2p/pull/5573). + ## 0.46.2 diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 50715c53c74..0b15e507ba4 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -1111,6 +1111,11 @@ where } } + /// Get the [`Mode`] in which the DHT is currently operating. + pub fn mode(&self) -> Mode { + self.mode + } + fn reconfigure_mode(&mut self) { if self.connections.is_empty() { return; From 95f40ff87be47cf919f80d7c4d63257fecb227a3 Mon Sep 17 00:00:00 2001 From: Age Manning Date: Fri, 30 Aug 2024 22:36:28 +1000 Subject: [PATCH 227/246] chore: add funding.json (#5581) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This adds a FUNDING.json file to the main repo. This is required for various projects, however the immediate case is for registering for an optimism retropgf grant. --------- Co-authored-by: João Oliveira --- FUNDING.json | 5 +++++ funding.json | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 FUNDING.json delete mode 100644 funding.json diff --git a/FUNDING.json b/FUNDING.json new file mode 100644 index 00000000000..cce3fb3fe4c --- /dev/null +++ b/FUNDING.json @@ -0,0 +1,5 @@ +{ + "opRetro": { + "projectId": "0xdf1bb03d08808e2d789f5eac8462bdc560f1bb5b0877f0cf8c66ab53a0bc2f5c" + } +} diff --git a/funding.json b/funding.json deleted file mode 100644 index bcf7fc2783d..00000000000 --- a/funding.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "opRetro": { - "projectId": "0x966804cb492e1a4bde5d781a676a44a23d69aa5dd2562fa7a4f95bb606021c8b" - } -} From f38fb5c334079b170d9cf8365bf5824210606f36 Mon Sep 17 00:00:00 2001 From: P1R0 Date: Fri, 30 Aug 2024 11:06:02 -0600 Subject: [PATCH 228/246] chore(examples): remove unused dependency from rendezvous (#5580) ## Description Following on issue #4449 refactor: remove unnecesary dependencies rendezvous example (async-std) ## Notes & open questions in the rendezvous example there where unnecessary dependencies in the Cargo.toml ## Change checklist * Removed unnecessary dependencies on examples/rendezvous/Cargo.toml - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] A changelog entry has been made in the appropriate crates Co-authored-by: David E. Perez Negron R. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- Cargo.lock | 2 -- examples/rendezvous/Cargo.toml | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f37b652c30..d0e45e9bb1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4984,8 +4984,6 @@ dependencies = [ name = "rendezvous-example" version = "0.1.0" dependencies = [ - "async-std", - "async-trait", "futures", "libp2p", "tokio", diff --git a/examples/rendezvous/Cargo.toml b/examples/rendezvous/Cargo.toml index 5a0672dcec8..4eea38616f4 100644 --- a/examples/rendezvous/Cargo.toml +++ b/examples/rendezvous/Cargo.toml @@ -9,10 +9,8 @@ license = "MIT" release = false [dependencies] -async-std = { version = "1.12", features = ["attributes"] } -async-trait = "0.1" futures = { workspace = true } -libp2p = { path = "../../libp2p", features = [ "async-std", "identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] } +libp2p = { path = "../../libp2p", features = ["identify", "macros", "noise", "ping", "rendezvous", "tcp", "tokio", "yamux"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros", "time"] } tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } From f0589c8d47bee507cba6cb2d3c73942ef1611a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Tue, 3 Sep 2024 12:50:23 +0100 Subject: [PATCH 229/246] chore(ci): update Dockerfiles Rust version (#5587) --- misc/server/Dockerfile | 2 +- protocols/perf/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/server/Dockerfile b/misc/server/Dockerfile index 9d2742f97e8..1583fba6bef 100644 --- a/misc/server/Dockerfile +++ b/misc/server/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.73.0 as chef +FROM rust:1.75.0 as chef RUN wget -q -O- https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.62/cargo-chef-x86_64-unknown-linux-gnu.tar.gz | tar -zx -C /usr/local/bin RUN cargo install --locked --root /usr/local libp2p-lookup --version 0.6.4 WORKDIR /app diff --git a/protocols/perf/Dockerfile b/protocols/perf/Dockerfile index 6523e3bede1..1bd846cc228 100644 --- a/protocols/perf/Dockerfile +++ b/protocols/perf/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.67.0 as builder +FROM rust:1.75.0 as builder # Run with access to the target cache to speed up builds WORKDIR /workspace From 93169cc6fa4a35aa0b3d5ddbd9e393118e46f412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Tue, 3 Sep 2024 18:45:33 +0100 Subject: [PATCH 230/246] fix(gossipsub): Attempt to publish to at least mesh_n peers (#5578) ## Description With flood published disabled we've noticed that it can be the case that we have connected peers on topics but these peers are not in our mesh (perhaps due to their own mesh requirements). Currently, we fail to publish the message if there are no peers in our mesh. This PR adjusts this logic to always attempt to publish to at least mesh_n peers. If we have peers that are subscribed to a topic, we will now attempt to publish messages to them (provided they have the required score). This PR also simplies the peer and respective topics by moving the topic list each peer has subscribed to `PeerConnections` and removing both `peer_topics` and `topic_peers` from the main `Behaviour`. Per commit review is suggested. --------- Co-authored-by: Darius Clark Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/gossipsub/CHANGELOG.md | 5 + protocols/gossipsub/Cargo.toml | 2 +- protocols/gossipsub/src/behaviour.rs | 399 +++++++++------------ protocols/gossipsub/src/behaviour/tests.rs | 101 +++--- protocols/gossipsub/src/metrics.rs | 15 +- protocols/gossipsub/src/types.rs | 4 +- 8 files changed, 242 insertions(+), 288 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0e45e9bb1a..9c8eae458fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2838,7 +2838,7 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" -version = "0.47.0" +version = "0.47.1" dependencies = [ "async-std", "asynchronous-codec", diff --git a/Cargo.toml b/Cargo.toml index 8d63ac3ee1e..587bef4480a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,7 @@ libp2p-core = { version = "0.42.0", path = "core" } libp2p-dcutr = { version = "0.12.0", path = "protocols/dcutr" } libp2p-dns = { version = "0.42.0", path = "transports/dns" } libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" } -libp2p-gossipsub = { version = "0.47.0", path = "protocols/gossipsub" } +libp2p-gossipsub = { version = "0.47.1", path = "protocols/gossipsub" } libp2p-identify = { version = "0.45.0", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.47.0", path = "protocols/kad" } diff --git a/protocols/gossipsub/CHANGELOG.md b/protocols/gossipsub/CHANGELOG.md index 8e115052d31..c47a9f40f66 100644 --- a/protocols/gossipsub/CHANGELOG.md +++ b/protocols/gossipsub/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.47.1 + +- Attempt to publish to at least mesh_n peers when flood publish is disabled. + See [PR 5578](https://github.com/libp2p/rust-libp2p/pull/5578). + ## 0.47.0 diff --git a/protocols/gossipsub/Cargo.toml b/protocols/gossipsub/Cargo.toml index 4cb590bed0c..665f757fcb3 100644 --- a/protocols/gossipsub/Cargo.toml +++ b/protocols/gossipsub/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-gossipsub" edition = "2021" rust-version = { workspace = true } description = "Gossipsub protocol for libp2p" -version = "0.47.0" +version = "0.47.1" authors = ["Age Manning "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/gossipsub/src/behaviour.rs b/protocols/gossipsub/src/behaviour.rs index 0d1af1ada0c..16adb555a44 100644 --- a/protocols/gossipsub/src/behaviour.rs +++ b/protocols/gossipsub/src/behaviour.rs @@ -259,12 +259,6 @@ pub struct Behaviour { /// the set of [`ConnectionId`]s. connected_peers: HashMap, - /// A map of all connected peers - A map of topic hash to a list of gossipsub peer Ids. - topic_peers: HashMap>, - - /// A map of all connected peers to their subscribed topics. - peer_topics: HashMap>, - /// A set of all explicit peers. These are peers that remain connected and we unconditionally /// forward messages to, outside of the scoring system. explicit_peers: HashSet, @@ -443,8 +437,6 @@ where control_pool: HashMap::new(), publish_config: privacy.into(), duplicate_cache: DuplicateCache::new(config.duplicate_cache_time()), - topic_peers: HashMap::new(), - peer_topics: HashMap::new(), explicit_peers: HashSet::new(), blacklisted_peers: HashSet::new(), mesh: HashMap::new(), @@ -501,9 +493,9 @@ where /// Lists all known peers and their associated subscribed topics. pub fn all_peers(&self) -> impl Iterator)> { - self.peer_topics + self.connected_peers .iter() - .map(|(peer_id, topic_set)| (peer_id, topic_set.iter().collect())) + .map(|(peer_id, peer)| (peer_id, peer.topics.iter().collect())) } /// Lists all known peers and their associated protocol. @@ -535,7 +527,7 @@ where } // send subscription request to all peers - for peer in self.peer_topics.keys().copied().collect::>() { + for peer in self.connected_peers.keys().copied().collect::>() { tracing::debug!(%peer, "Sending SUBSCRIBE to peer"); let event = RpcOut::Subscribe(topic_hash.clone()); self.send_message(peer, event); @@ -563,7 +555,7 @@ where } // announce to all peers - for peer in self.peer_topics.keys().copied().collect::>() { + for peer in self.connected_peers.keys().copied().collect::>() { tracing::debug!(%peer, "Sending UNSUBSCRIBE to peer"); let event = RpcOut::Unsubscribe(topic_hash.clone()); self.send_message(peer, event); @@ -621,84 +613,103 @@ where let topic_hash = raw_message.topic.clone(); + let mut peers_on_topic = self + .connected_peers + .iter() + .filter(|(_, p)| p.topics.contains(&topic_hash)) + .map(|(peer_id, _)| peer_id) + .peekable(); + + if peers_on_topic.peek().is_none() { + return Err(PublishError::InsufficientPeers); + } + let mut recipient_peers = HashSet::new(); - if let Some(set) = self.topic_peers.get(&topic_hash) { - if self.config.flood_publish() { - // Forward to all peers above score and all explicit peers - recipient_peers.extend(set.iter().filter(|p| { - self.explicit_peers.contains(*p) - || !self.score_below_threshold(p, |ts| ts.publish_threshold).0 - })); - } else { - match self.mesh.get(&raw_message.topic) { - // Mesh peers - Some(mesh_peers) => { - recipient_peers.extend(mesh_peers); + if self.config.flood_publish() { + // Forward to all peers above score and all explicit peers + recipient_peers.extend(peers_on_topic.filter(|p| { + self.explicit_peers.contains(*p) + || !self.score_below_threshold(p, |ts| ts.publish_threshold).0 + })); + } else { + match self.mesh.get(&topic_hash) { + // Mesh peers + Some(mesh_peers) => { + // We have a mesh set. We want to make sure to publish to at least `mesh_n` + // peers (if possible). + let needed_extra_peers = self.config.mesh_n().saturating_sub(mesh_peers.len()); + + if needed_extra_peers > 0 { + // We don't have `mesh_n` peers in our mesh, we will randomly select extras + // and publish to them. + + // Get a random set of peers that are appropriate to send messages too. + let peer_list = get_random_peers( + &self.connected_peers, + &topic_hash, + needed_extra_peers, + |peer| { + !mesh_peers.contains(peer) + && !self.explicit_peers.contains(peer) + && !self + .score_below_threshold(peer, |pst| pst.publish_threshold) + .0 + }, + ); + recipient_peers.extend(peer_list); } - // Gossipsub peers - None => { - tracing::debug!(topic=%topic_hash, "Topic not in the mesh"); - // If we have fanout peers add them to the map. - if self.fanout.contains_key(&topic_hash) { - for peer in self.fanout.get(&topic_hash).expect("Topic must exist") { - recipient_peers.insert(*peer); - } - } else { - // We have no fanout peers, select mesh_n of them and add them to the fanout - let mesh_n = self.config.mesh_n(); - let new_peers = get_random_peers( - &self.topic_peers, - &self.connected_peers, - &topic_hash, - mesh_n, - { - |p| { - !self.explicit_peers.contains(p) - && !self - .score_below_threshold(p, |pst| { - pst.publish_threshold - }) - .0 - } - }, - ); - // Add the new peers to the fanout and recipient peers - self.fanout.insert(topic_hash.clone(), new_peers.clone()); - for peer in new_peers { - tracing::debug!(%peer, "Peer added to fanout"); - recipient_peers.insert(peer); - } + + recipient_peers.extend(mesh_peers); + } + // Gossipsub peers + None => { + tracing::debug!(topic=%topic_hash, "Topic not in the mesh"); + // If we have fanout peers add them to the map. + if self.fanout.contains_key(&topic_hash) { + for peer in self.fanout.get(&topic_hash).expect("Topic must exist") { + recipient_peers.insert(*peer); + } + } else { + // We have no fanout peers, select mesh_n of them and add them to the fanout + let mesh_n = self.config.mesh_n(); + let new_peers = + get_random_peers(&self.connected_peers, &topic_hash, mesh_n, { + |p| { + !self.explicit_peers.contains(p) + && !self + .score_below_threshold(p, |pst| pst.publish_threshold) + .0 + } + }); + // Add the new peers to the fanout and recipient peers + self.fanout.insert(topic_hash.clone(), new_peers.clone()); + for peer in new_peers { + tracing::debug!(%peer, "Peer added to fanout"); + recipient_peers.insert(peer); } - // We are publishing to fanout peers - update the time we published - self.fanout_last_pub - .insert(topic_hash.clone(), Instant::now()); } + // We are publishing to fanout peers - update the time we published + self.fanout_last_pub + .insert(topic_hash.clone(), Instant::now()); } + } - // Explicit peers - for peer in &self.explicit_peers { - if set.contains(peer) { - recipient_peers.insert(*peer); - } - } + // Explicit peers that are part of the topic + recipient_peers + .extend(peers_on_topic.filter(|peer_id| self.explicit_peers.contains(peer_id))); - // Floodsub peers - for (peer, connections) in &self.connected_peers { - if connections.kind == PeerKind::Floodsub - && !self - .score_below_threshold(peer, |ts| ts.publish_threshold) - .0 - { - recipient_peers.insert(*peer); - } + // Floodsub peers + for (peer, connections) in &self.connected_peers { + if connections.kind == PeerKind::Floodsub + && !self + .score_below_threshold(peer, |ts| ts.publish_threshold) + .0 + { + recipient_peers.insert(*peer); } } } - if recipient_peers.is_empty() { - return Err(PublishError::InsufficientPeers); - } - // If the message isn't a duplicate and we have sent it to some peers add it to the // duplicate cache and memcache. self.duplicate_cache.insert(msg_id.clone()); @@ -964,7 +975,6 @@ where if added_peers.len() < self.config.mesh_n() { // get the peers let new_peers = get_random_peers( - &self.topic_peers, &self.connected_peers, topic_hash, self.config.mesh_n() - added_peers.len(), @@ -1009,7 +1019,6 @@ where peer_id, vec![topic_hash], &self.mesh, - self.peer_topics.get(&peer_id), &mut self.events, &self.connected_peers, ); @@ -1056,7 +1065,6 @@ where // Select peers for peer exchange let peers = if do_px { get_random_peers( - &self.topic_peers, &self.connected_peers, topic_hash, self.config.prune_peers(), @@ -1107,7 +1115,6 @@ where peer, topic_hash, &self.mesh, - self.peer_topics.get(&peer), &mut self.events, &self.connected_peers, ); @@ -1118,7 +1125,7 @@ where /// Checks if the given peer is still connected and if not dials the peer again. fn check_explicit_peer_connection(&mut self, peer_id: &PeerId) { - if !self.peer_topics.contains_key(peer_id) { + if !self.connected_peers.contains_key(peer_id) { // Connect to peer tracing::debug!(peer=%peer_id, "Connecting to explicit peer"); self.events.push_back(ToSwarm::Dial { @@ -1329,17 +1336,19 @@ where let mut do_px = self.config.do_px(); + let Some(connected_peer) = self.connected_peers.get_mut(peer_id) else { + tracing::error!(peer_id = %peer_id, "Peer non-existent when handling graft"); + return; + }; + // For each topic, if a peer has grafted us, then we necessarily must be in their mesh // and they must be subscribed to the topic. Ensure we have recorded the mapping. for topic in &topics { - self.peer_topics - .entry(*peer_id) - .or_default() - .insert(topic.clone()); - self.topic_peers - .entry(topic.clone()) - .or_default() - .insert(*peer_id); + if connected_peer.topics.insert(topic.clone()) { + if let Some(m) = self.metrics.as_mut() { + m.inc_topic_peers(topic); + } + } } // we don't GRAFT to/from explicit peers; complain loudly if this happens @@ -1441,7 +1450,6 @@ where *peer_id, vec![&topic_hash], &self.mesh, - self.peer_topics.get(peer_id), &mut self.events, &self.connected_peers, ); @@ -1514,7 +1522,6 @@ where *peer_id, topic_hash, &self.mesh, - self.peer_topics.get(peer_id), &mut self.events, &self.connected_peers, ); @@ -1825,7 +1832,7 @@ where let mut unsubscribed_peers = Vec::new(); - let Some(subscribed_topics) = self.peer_topics.get_mut(propagation_source) else { + let Some(peer) = self.connected_peers.get_mut(propagation_source) else { tracing::error!( peer=%propagation_source, "Subscription by unknown peer" @@ -1841,7 +1848,7 @@ where let filtered_topics = match self .subscription_filter - .filter_incoming_subscriptions(subscriptions, subscribed_topics) + .filter_incoming_subscriptions(subscriptions, &peer.topics) { Ok(topics) => topics, Err(s) => { @@ -1857,29 +1864,24 @@ where for subscription in filtered_topics { // get the peers from the mapping, or insert empty lists if the topic doesn't exist let topic_hash = &subscription.topic_hash; - let peer_list = self.topic_peers.entry(topic_hash.clone()).or_default(); match subscription.action { SubscriptionAction::Subscribe => { - if peer_list.insert(*propagation_source) { + if peer.topics.insert(topic_hash.clone()) { tracing::debug!( peer=%propagation_source, topic=%topic_hash, "SUBSCRIPTION: Adding gossip peer to topic" ); - } - // add to the peer_topics mapping - subscribed_topics.insert(topic_hash.clone()); + if let Some(m) = self.metrics.as_mut() { + m.inc_topic_peers(topic_hash); + } + } // if the mesh needs peers add the peer to the mesh if !self.explicit_peers.contains(propagation_source) - && matches!( - self.connected_peers - .get(propagation_source) - .map(|v| &v.kind), - Some(PeerKind::Gossipsubv1_1) | Some(PeerKind::Gossipsub) - ) + && matches!(peer.kind, PeerKind::Gossipsubv1_1 | PeerKind::Gossipsub) && !Self::score_below_threshold_from_scores( &self.peer_score, propagation_source, @@ -1922,16 +1924,18 @@ where })); } SubscriptionAction::Unsubscribe => { - if peer_list.remove(propagation_source) { + if peer.topics.remove(topic_hash) { tracing::debug!( peer=%propagation_source, topic=%topic_hash, "SUBSCRIPTION: Removing gossip peer from topic" ); + + if let Some(m) = self.metrics.as_mut() { + m.dec_topic_peers(topic_hash); + } } - // remove topic from the peer_topics mapping - subscribed_topics.remove(topic_hash); unsubscribed_peers.push((*propagation_source, topic_hash.clone())); // generate an unsubscribe event to be polled application_event.push(ToSwarm::GenerateEvent(Event::Unsubscribed { @@ -1940,10 +1944,6 @@ where })); } } - - if let Some(m) = self.metrics.as_mut() { - m.set_topic_peers(topic_hash, peer_list.len()); - } } // remove unsubscribed peers from the mesh if it exists @@ -1958,7 +1958,6 @@ where *propagation_source, topics_joined, &self.mesh, - self.peer_topics.get(propagation_source), &mut self.events, &self.connected_peers, ); @@ -2039,7 +2038,6 @@ where for (topic_hash, peers) in self.mesh.iter_mut() { let explicit_peers = &self.explicit_peers; let backoffs = &self.backoffs; - let topic_peers = &self.topic_peers; let outbound_peers = &self.outbound_peers; // drop all peers with negative score, without PX @@ -2087,18 +2085,13 @@ where ); // not enough peers - get mesh_n - current_length more let desired_peers = self.config.mesh_n() - peers.len(); - let peer_list = get_random_peers( - topic_peers, - &self.connected_peers, - topic_hash, - desired_peers, - |peer| { + let peer_list = + get_random_peers(&self.connected_peers, topic_hash, desired_peers, |peer| { !peers.contains(peer) && !explicit_peers.contains(peer) && !backoffs.is_backoff_with_slack(topic_hash, peer) && *scores.get(peer).unwrap_or(&0.0) >= 0.0 - }, - ); + }); for peer in &peer_list { let current_topic = to_graft.entry(*peer).or_insert_with(Vec::new); current_topic.push(topic_hash.clone()); @@ -2154,10 +2147,9 @@ where if outbound <= self.config.mesh_outbound_min() { // do not remove anymore outbound peers continue; - } else { - // an outbound peer gets removed - outbound -= 1; } + // an outbound peer gets removed + outbound -= 1; } // remove the peer @@ -2180,19 +2172,14 @@ where // if we have not enough outbound peers, graft to some new outbound peers if outbound < self.config.mesh_outbound_min() { let needed = self.config.mesh_outbound_min() - outbound; - let peer_list = get_random_peers( - topic_peers, - &self.connected_peers, - topic_hash, - needed, - |peer| { + let peer_list = + get_random_peers(&self.connected_peers, topic_hash, needed, |peer| { !peers.contains(peer) && !explicit_peers.contains(peer) && !backoffs.is_backoff_with_slack(topic_hash, peer) && *scores.get(peer).unwrap_or(&0.0) >= 0.0 && outbound_peers.contains(peer) - }, - ); + }); for peer in &peer_list { let current_topic = to_graft.entry(*peer).or_insert_with(Vec::new); current_topic.push(topic_hash.clone()); @@ -2249,7 +2236,6 @@ where // GRAFT if median < thresholds.opportunistic_graft_threshold { let peer_list = get_random_peers( - topic_peers, &self.connected_peers, topic_hash, self.config.opportunistic_graft_peers(), @@ -2308,22 +2294,22 @@ where Some((_, thresholds, _, _)) => thresholds.publish_threshold, _ => 0.0, }; - for peer in peers.iter() { + for peer_id in peers.iter() { // is the peer still subscribed to the topic? - let peer_score = *scores.get(peer).unwrap_or(&0.0); - match self.peer_topics.get(peer) { - Some(topics) => { - if !topics.contains(topic_hash) || peer_score < publish_threshold { + let peer_score = *scores.get(peer_id).unwrap_or(&0.0); + match self.connected_peers.get(peer_id) { + Some(peer) => { + if !peer.topics.contains(topic_hash) || peer_score < publish_threshold { tracing::debug!( topic=%topic_hash, "HEARTBEAT: Peer removed from fanout for topic" ); - to_remove_peers.push(*peer); + to_remove_peers.push(*peer_id); } } None => { // remove if the peer has disconnected - to_remove_peers.push(*peer); + to_remove_peers.push(*peer_id); } } } @@ -2340,17 +2326,12 @@ where ); let needed_peers = self.config.mesh_n() - peers.len(); let explicit_peers = &self.explicit_peers; - let new_peers = get_random_peers( - &self.topic_peers, - &self.connected_peers, - topic_hash, - needed_peers, - |peer_id| { + let new_peers = + get_random_peers(&self.connected_peers, topic_hash, needed_peers, |peer_id| { !peers.contains(peer_id) && !explicit_peers.contains(peer_id) && *scores.get(peer_id).unwrap_or(&0.0) < publish_threshold - }, - ); + }); peers.extend(new_peers); } } @@ -2432,17 +2413,12 @@ where ) }; // get gossip_lazy random peers - let to_msg_peers = get_random_peers_dynamic( - &self.topic_peers, - &self.connected_peers, - topic_hash, - n_map, - |peer| { + let to_msg_peers = + get_random_peers_dynamic(&self.connected_peers, topic_hash, n_map, |peer| { !peers.contains(peer) && !self.explicit_peers.contains(peer) && !self.score_below_threshold(peer, |ts| ts.gossip_threshold).0 - }, - ); + }); tracing::debug!("Gossiping IHAVE to {} peers", to_msg_peers.len()); @@ -2492,7 +2468,6 @@ where peer, vec![topic], &self.mesh, - self.peer_topics.get(&peer), &mut self.events, &self.connected_peers, ); @@ -2543,7 +2518,6 @@ where *peer, topic_hash, &self.mesh, - self.peer_topics.get(peer), &mut self.events, &self.connected_peers, ); @@ -2577,11 +2551,11 @@ where // Add explicit peers for peer_id in &self.explicit_peers { - if let Some(topics) = self.peer_topics.get(peer_id) { + if let Some(peer) = self.connected_peers.get(peer_id) { if Some(peer_id) != propagation_source && !originating_peers.contains(peer_id) && Some(peer_id) != message.source.as_ref() - && topics.contains(&message.topic) + && peer.topics.contains(&message.topic) { recipient_peers.insert(*peer_id); } @@ -2790,6 +2764,7 @@ where .or_insert(PeerConnections { kind: PeerKind::Floodsub, connections: vec![], + topics: Default::default(), }) .connections .push(connection_id); @@ -2798,9 +2773,6 @@ where return; // Not our first connection to this peer, hence nothing to do. } - // Insert an empty set of the topics of this peer until known. - self.peer_topics.insert(peer_id, Default::default()); - if let Some((peer_score, ..)) = &mut self.peer_score { peer_score.add_peer(peer_id); } @@ -2843,28 +2815,26 @@ where if remaining_established != 0 { // Remove the connection from the list - if let Some(connections) = self.connected_peers.get_mut(&peer_id) { - let index = connections + if let Some(peer) = self.connected_peers.get_mut(&peer_id) { + let index = peer .connections .iter() .position(|v| v == &connection_id) .expect("Previously established connection to peer must be present"); - connections.connections.remove(index); + peer.connections.remove(index); // If there are more connections and this peer is in a mesh, inform the first connection // handler. - if !connections.connections.is_empty() { - if let Some(topics) = self.peer_topics.get(&peer_id) { - for topic in topics { - if let Some(mesh_peers) = self.mesh.get(topic) { - if mesh_peers.contains(&peer_id) { - self.events.push_back(ToSwarm::NotifyHandler { - peer_id, - event: HandlerIn::JoinedMesh, - handler: NotifyHandler::One(connections.connections[0]), - }); - break; - } + if !peer.connections.is_empty() { + for topic in &peer.topics { + if let Some(mesh_peers) = self.mesh.get(topic) { + if mesh_peers.contains(&peer_id) { + self.events.push_back(ToSwarm::NotifyHandler { + peer_id, + event: HandlerIn::JoinedMesh, + handler: NotifyHandler::One(peer.connections[0]), + }); + break; } } } @@ -2874,7 +2844,7 @@ where // remove from mesh, topic_peers, peer_topic and the fanout tracing::debug!(peer=%peer_id, "Peer disconnected"); { - let Some(topics) = self.peer_topics.get(&peer_id) else { + let Some(peer) = self.connected_peers.get(&peer_id) else { debug_assert!( self.blacklisted_peers.contains(&peer_id), "Disconnected node not in connected list" @@ -2883,7 +2853,7 @@ where }; // remove peer from all mappings - for topic in topics { + for topic in peer.topics.iter() { // check the mesh for the topic if let Some(mesh_peers) = self.mesh.get_mut(topic) { // check if the peer is in the mesh and remove it @@ -2895,24 +2865,8 @@ where }; } - // remove from topic_peers - if let Some(peer_list) = self.topic_peers.get_mut(topic) { - if !peer_list.remove(&peer_id) { - // debugging purposes - tracing::warn!( - peer=%peer_id, - "Disconnected node: peer not in topic_peers" - ); - } - if let Some(m) = self.metrics.as_mut() { - m.set_topic_peers(topic, peer_list.len()) - } - } else { - tracing::warn!( - peer=%peer_id, - topic=%topic, - "Disconnected node: peer with topic not in topic_peers" - ); + if let Some(m) = self.metrics.as_mut() { + m.dec_topic_peers(topic); } // remove from fanout @@ -2926,11 +2880,6 @@ where self.px_peers.remove(&peer_id); self.outbound_peers.remove(&peer_id); - // Remove peer from peer_topics and connected_peers - // NOTE: It is possible the peer has already been removed from all mappings if it does not - // support the protocol. - self.peer_topics.remove(&peer_id); - // If metrics are enabled, register the disconnection of a peer based on its protocol. if let Some(metrics) = self.metrics.as_mut() { let peer_kind = &self @@ -3190,7 +3139,6 @@ fn peer_added_to_mesh( peer_id: PeerId, new_topics: Vec<&TopicHash>, mesh: &HashMap>, - known_topics: Option<&BTreeSet>, events: &mut VecDeque>, connections: &HashMap, ) { @@ -3204,8 +3152,8 @@ fn peer_added_to_mesh( conn.connections[0] }; - if let Some(topics) = known_topics { - for topic in topics { + if let Some(peer) = connections.get(&peer_id) { + for topic in &peer.topics { if !new_topics.contains(&topic) { if let Some(mesh_peers) = mesh.get(topic) { if mesh_peers.contains(&peer_id) { @@ -3231,7 +3179,6 @@ fn peer_removed_from_mesh( peer_id: PeerId, old_topic: &TopicHash, mesh: &HashMap>, - known_topics: Option<&BTreeSet>, events: &mut VecDeque>, connections: &HashMap, ) { @@ -3243,8 +3190,8 @@ fn peer_removed_from_mesh( .first() .expect("There should be at least one connection to a peer."); - if let Some(topics) = known_topics { - for topic in topics { + if let Some(peer) = connections.get(&peer_id) { + for topic in &peer.topics { if topic != old_topic { if let Some(mesh_peers) = mesh.get(topic) { if mesh_peers.contains(&peer_id) { @@ -3267,28 +3214,19 @@ fn peer_removed_from_mesh( /// filtered by the function `f`. The number of peers to get equals the output of `n_map` /// that gets as input the number of filtered peers. fn get_random_peers_dynamic( - topic_peers: &HashMap>, connected_peers: &HashMap, topic_hash: &TopicHash, // maps the number of total peers to the number of selected peers n_map: impl Fn(usize) -> usize, mut f: impl FnMut(&PeerId) -> bool, ) -> BTreeSet { - let mut gossip_peers = match topic_peers.get(topic_hash) { - // if they exist, filter the peers by `f` - Some(peer_list) => peer_list - .iter() - .copied() - .filter(|p| { - f(p) && match connected_peers.get(p) { - Some(connections) if connections.kind == PeerKind::Gossipsub => true, - Some(connections) if connections.kind == PeerKind::Gossipsubv1_1 => true, - _ => false, - } - }) - .collect(), - None => Vec::new(), - }; + let mut gossip_peers = connected_peers + .iter() + .filter(|(_, p)| p.topics.contains(topic_hash)) + .filter(|(peer_id, _)| f(peer_id)) + .filter(|(_, p)| p.kind == PeerKind::Gossipsub || p.kind == PeerKind::Gossipsubv1_1) + .map(|(peer_id, _)| *peer_id) + .collect::>(); // if we have less than needed, return them let n = n_map(gossip_peers.len()); @@ -3309,13 +3247,12 @@ fn get_random_peers_dynamic( /// Helper function to get a set of `n` random gossipsub peers for a `topic_hash` /// filtered by the function `f`. fn get_random_peers( - topic_peers: &HashMap>, connected_peers: &HashMap, topic_hash: &TopicHash, n: usize, f: impl FnMut(&PeerId) -> bool, ) -> BTreeSet { - get_random_peers_dynamic(topic_peers, connected_peers, topic_hash, |_| n, f) + get_random_peers_dynamic(connected_peers, topic_hash, |_| n, f) } /// Validates the combination of signing, privacy and message validation to ensure the @@ -3355,8 +3292,6 @@ impl fmt::Debug for Behaviour>(), "First peer should be subscribed to three topics" ); - let peer_topics = gs.peer_topics.get(&peers[1]).unwrap().clone(); + let peer1 = gs.connected_peers.get(&peers[1]).unwrap(); assert!( - peer_topics == topic_hashes.iter().take(3).cloned().collect(), + peer1.topics + == topic_hashes + .iter() + .take(3) + .cloned() + .collect::>(), "Second peer should be subscribed to three topics" ); assert!( - !gs.peer_topics.contains_key(&unknown_peer), + !gs.connected_peers.contains_key(&unknown_peer), "Unknown peer should not have been added" ); for topic_hash in topic_hashes[..3].iter() { - let topic_peers = gs.topic_peers.get(topic_hash).unwrap().clone(); + let topic_peers = gs + .connected_peers + .iter() + .filter(|(_, p)| p.topics.contains(topic_hash)) + .map(|(peer_id, _)| *peer_id) + .collect::>(); assert!( topic_peers == peers[..2].iter().cloned().collect(), "Two peers should be added to the first three topics" @@ -894,13 +914,21 @@ fn test_handle_received_subscriptions() { &peers[0], ); - let peer_topics = gs.peer_topics.get(&peers[0]).unwrap().clone(); - assert!( - peer_topics == topic_hashes[1..3].iter().cloned().collect(), + let peer = gs.connected_peers.get(&peers[0]).unwrap().clone(); + assert_eq!( + peer.topics, + topic_hashes[1..3].iter().cloned().collect::>(), "Peer should be subscribed to two topics" ); - let topic_peers = gs.topic_peers.get(&topic_hashes[0]).unwrap().clone(); // only gossipsub at the moment + // only gossipsub at the moment + let topic_peers = gs + .connected_peers + .iter() + .filter(|(_, p)| p.topics.contains(&topic_hashes[0])) + .map(|(peer_id, _)| *peer_id) + .collect::>(); + assert!( topic_peers == peers[1..2].iter().cloned().collect(), "Only the second peers should be in the first topic" @@ -924,9 +952,8 @@ fn test_get_random_peers() { for _ in 0..20 { peers.push(PeerId::random()) } - - gs.topic_peers - .insert(topic_hash.clone(), peers.iter().cloned().collect()); + let mut topics = BTreeSet::new(); + topics.insert(topic_hash.clone()); gs.connected_peers = peers .iter() @@ -936,52 +963,32 @@ fn test_get_random_peers() { PeerConnections { kind: PeerKind::Gossipsubv1_1, connections: vec![ConnectionId::new_unchecked(0)], + topics: topics.clone(), }, ) }) .collect(); - let random_peers = - get_random_peers(&gs.topic_peers, &gs.connected_peers, &topic_hash, 5, |_| { - true - }); + let random_peers = get_random_peers(&gs.connected_peers, &topic_hash, 5, |_| true); assert_eq!(random_peers.len(), 5, "Expected 5 peers to be returned"); - let random_peers = get_random_peers( - &gs.topic_peers, - &gs.connected_peers, - &topic_hash, - 30, - |_| true, - ); + let random_peers = get_random_peers(&gs.connected_peers, &topic_hash, 30, |_| true); assert!(random_peers.len() == 20, "Expected 20 peers to be returned"); assert!( random_peers == peers.iter().cloned().collect(), "Expected no shuffling" ); - let random_peers = get_random_peers( - &gs.topic_peers, - &gs.connected_peers, - &topic_hash, - 20, - |_| true, - ); + let random_peers = get_random_peers(&gs.connected_peers, &topic_hash, 20, |_| true); assert!(random_peers.len() == 20, "Expected 20 peers to be returned"); assert!( random_peers == peers.iter().cloned().collect(), "Expected no shuffling" ); - let random_peers = - get_random_peers(&gs.topic_peers, &gs.connected_peers, &topic_hash, 0, |_| { - true - }); + let random_peers = get_random_peers(&gs.connected_peers, &topic_hash, 0, |_| true); assert!(random_peers.is_empty(), "Expected 0 peers to be returned"); // test the filter - let random_peers = - get_random_peers(&gs.topic_peers, &gs.connected_peers, &topic_hash, 5, |_| { - false - }); + let random_peers = get_random_peers(&gs.connected_peers, &topic_hash, 5, |_| false); assert!(random_peers.is_empty(), "Expected 0 peers to be returned"); - let random_peers = get_random_peers(&gs.topic_peers, &gs.connected_peers, &topic_hash, 10, { + let random_peers = get_random_peers(&gs.connected_peers, &topic_hash, 10, { |peer| peers.contains(peer) }); assert!(random_peers.len() == 10, "Expected 10 peers to be returned"); diff --git a/protocols/gossipsub/src/metrics.rs b/protocols/gossipsub/src/metrics.rs index e044ca67e71..7d4acada3c7 100644 --- a/protocols/gossipsub/src/metrics.rs +++ b/protocols/gossipsub/src/metrics.rs @@ -355,12 +355,17 @@ impl Metrics { } } - /// Register how many peers do we known are subscribed to this topic. - pub(crate) fn set_topic_peers(&mut self, topic: &TopicHash, count: usize) { + /// Increase the number of peers that are subscribed to this topic. + pub(crate) fn inc_topic_peers(&mut self, topic: &TopicHash) { if self.register_topic(topic).is_ok() { - self.topic_peers_count - .get_or_create(topic) - .set(count as i64); + self.topic_peers_count.get_or_create(topic).inc(); + } + } + + /// Decrease the number of peers that are subscribed to this topic. + pub(crate) fn dec_topic_peers(&mut self, topic: &TopicHash) { + if self.register_topic(topic).is_ok() { + self.topic_peers_count.get_or_create(topic).dec(); } } diff --git a/protocols/gossipsub/src/types.rs b/protocols/gossipsub/src/types.rs index d1b92ff0ba8..a88f4822ac2 100644 --- a/protocols/gossipsub/src/types.rs +++ b/protocols/gossipsub/src/types.rs @@ -24,8 +24,8 @@ use libp2p_identity::PeerId; use libp2p_swarm::ConnectionId; use prometheus_client::encoding::EncodeLabelValue; use quick_protobuf::MessageWrite; -use std::fmt; use std::fmt::Debug; +use std::{collections::BTreeSet, fmt}; use crate::rpc_proto::proto; #[cfg(feature = "serde")] @@ -77,6 +77,8 @@ pub(crate) struct PeerConnections { pub(crate) kind: PeerKind, /// Its current connections. pub(crate) connections: Vec, + /// Subscribed topics. + pub(crate) topics: BTreeSet, } /// Describes the types of peers that can exist in the gossipsub context. From 5137e4e4e710aaf3c38c2507a4e65b76d99a4834 Mon Sep 17 00:00:00 2001 From: P1R0 Date: Tue, 3 Sep 2024 16:58:15 -0600 Subject: [PATCH 231/246] refactor(examples): use tokio instead of async-std in identify example (#5579) ## Description Following on issue #4449 refactor: use tokio instead of async-std in the identify example and remove unnecesary dependencies ## Notes & open questions ## Change checklist * Removed unnecessary dependencies on examples/identify/Cargo.toml - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] A changelog entry has been made in the appropriate crates --------- Co-authored-by: David E. Perez Negron R. Co-authored-by: Darius Clark --- Cargo.lock | 3 +-- examples/identify/Cargo.toml | 5 ++--- examples/identify/src/main.rs | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c8eae458fc..5c419ed0348 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2311,10 +2311,9 @@ dependencies = [ name = "identify-example" version = "0.1.0" dependencies = [ - "async-std", - "async-trait", "futures", "libp2p", + "tokio", "tracing", "tracing-subscriber", ] diff --git a/examples/identify/Cargo.toml b/examples/identify/Cargo.toml index cbe569b9d07..8d12699afa7 100644 --- a/examples/identify/Cargo.toml +++ b/examples/identify/Cargo.toml @@ -9,10 +9,9 @@ license = "MIT" release = false [dependencies] -async-std = { version = "1.12", features = ["attributes"] } -async-trait = "0.1" +tokio = { version = "1.37.0", features = ["full"] } futures = { workspace = true } -libp2p = { path = "../../libp2p", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "tokio","yamux"] } +libp2p = { path = "../../libp2p", features = ["identify", "noise", "tcp", "tokio", "yamux"] } tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } diff --git a/examples/identify/src/main.rs b/examples/identify/src/main.rs index 916317a5a43..22474061da6 100644 --- a/examples/identify/src/main.rs +++ b/examples/identify/src/main.rs @@ -25,14 +25,14 @@ use libp2p::{core::multiaddr::Multiaddr, identify, noise, swarm::SwarmEvent, tcp use std::{error::Error, time::Duration}; use tracing_subscriber::EnvFilter; -#[async_std::main] +#[tokio::main] async fn main() -> Result<(), Box> { let _ = tracing_subscriber::fmt() .with_env_filter(EnvFilter::from_default_env()) .try_init(); let mut swarm = libp2p::SwarmBuilder::with_new_identity() - .with_async_std() + .with_tokio() .with_tcp( tcp::Config::default(), noise::Config::new, From 3837e33cd4c40ae703138e6aed6f6c9d52928a80 Mon Sep 17 00:00:00 2001 From: Benno Date: Thu, 5 Sep 2024 18:05:20 +0200 Subject: [PATCH 232/246] feat(identify): add hide_listen_addrs config option (#5507) ## Description Implements #4010, which was closed. It was closed because it appeared that the Identify specification doesn't dictate this feature. But, in the discussion on the specs repo (https://github.com/libp2p/specs/pull/597) it is mentioned that this might very well be an implementation detail. This PR introduces a `hide_listen_addrs` flag that will prevent our listen addresses to be included, effectively only sharing our external addresses. ## Notes & open questions An alternative implementation would be to allow us to filter the addresses we are sending out, by providing a closure I imagine. ## Change checklist - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [x] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates --------- Co-authored-by: Darius Clark --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/identify/CHANGELOG.md | 5 ++ protocols/identify/Cargo.toml | 2 +- protocols/identify/src/behaviour.rs | 23 ++++++++-- protocols/identify/tests/smoke.rs | 71 +++++++++++++++++++++++++++++ 6 files changed, 97 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c419ed0348..4c12e6fb984 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2874,7 +2874,7 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.45.0" +version = "0.45.1" dependencies = [ "async-std", "asynchronous-codec", diff --git a/Cargo.toml b/Cargo.toml index 587bef4480a..da8d32e1a4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,7 @@ libp2p-dcutr = { version = "0.12.0", path = "protocols/dcutr" } libp2p-dns = { version = "0.42.0", path = "transports/dns" } libp2p-floodsub = { version = "0.45.0", path = "protocols/floodsub" } libp2p-gossipsub = { version = "0.47.1", path = "protocols/gossipsub" } -libp2p-identify = { version = "0.45.0", path = "protocols/identify" } +libp2p-identify = { version = "0.45.1", path = "protocols/identify" } libp2p-identity = { version = "0.2.9" } libp2p-kad = { version = "0.47.0", path = "protocols/kad" } libp2p-mdns = { version = "0.46.0", path = "protocols/mdns" } diff --git a/protocols/identify/CHANGELOG.md b/protocols/identify/CHANGELOG.md index 275f7114b28..c5778ff92ee 100644 --- a/protocols/identify/CHANGELOG.md +++ b/protocols/identify/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.45.1 + +- Add `hide_listen_addrs` option to prevent leaking (local) listen addresses. + See [PR 5507](https://github.com/libp2p/rust-libp2p/pull/5507). + ## 0.45.0 - Address translation is moved here from `libp2p-core`. diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index cdc5ce587de..c3fb585c99c 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-identify" edition = "2021" rust-version = { workspace = true } description = "Nodes identification protocol for libp2p" -version = "0.45.0" +version = "0.45.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/identify/src/behaviour.rs b/protocols/identify/src/behaviour.rs index 6590ccd6588..c8672674c1a 100644 --- a/protocols/identify/src/behaviour.rs +++ b/protocols/identify/src/behaviour.rs @@ -147,6 +147,12 @@ pub struct Config { /// /// Disabled by default. pub cache_size: usize, + + /// Whether to include our listen addresses in our responses. If enabled, + /// we will effectively only share our external addresses. + /// + /// Disabled by default. + pub hide_listen_addrs: bool, } impl Config { @@ -160,6 +166,7 @@ impl Config { interval: Duration::from_secs(5 * 60), push_listen_addr_updates: false, cache_size: 100, + hide_listen_addrs: false, } } @@ -189,6 +196,12 @@ impl Config { self.cache_size = cache_size; self } + + /// Configures whether we prevent sending out our listen addresses. + pub fn with_hide_listen_addrs(mut self, b: bool) -> Self { + self.hide_listen_addrs = b; + self + } } impl Behaviour { @@ -258,11 +271,11 @@ impl Behaviour { } fn all_addresses(&self) -> HashSet { - self.listen_addresses - .iter() - .chain(self.external_addresses.iter()) - .cloned() - .collect() + let mut addrs = HashSet::from_iter(self.external_addresses.iter().cloned()); + if !self.config.hide_listen_addrs { + addrs.extend(self.listen_addresses.iter().cloned()); + }; + addrs } fn emit_new_external_addr_candidate_event( diff --git a/protocols/identify/tests/smoke.rs b/protocols/identify/tests/smoke.rs index 49ae9f0726f..d624005408e 100644 --- a/protocols/identify/tests/smoke.rs +++ b/protocols/identify/tests/smoke.rs @@ -222,6 +222,77 @@ async fn emits_unique_listen_addresses() { assert!(reported_addrs.contains(&(swarm2_peer_id, swarm2_tcp_listen_addr))); } +#[async_std::test] +async fn hides_listen_addresses() { + let _ = tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env()) + .try_init(); + + let mut swarm1 = Swarm::new_ephemeral(|identity| { + identify::Behaviour::new( + identify::Config::new("a".to_string(), identity.public()) + .with_agent_version("b".to_string()) + .with_interval(Duration::from_secs(1)) + .with_cache_size(10), + ) + }); + let mut swarm2 = Swarm::new_ephemeral(|identity| { + identify::Behaviour::new( + identify::Config::new("c".to_string(), identity.public()) + .with_agent_version("d".to_string()) + .with_hide_listen_addrs(true), + ) + }); + + let (_swarm2_mem_listen_addr, swarm2_tcp_listen_addr) = + swarm2.listen().with_tcp_addr_external().await; + let swarm2_peer_id = *swarm2.local_peer_id(); + swarm1.connect(&mut swarm2).await; + + async_std::task::spawn(swarm2.loop_on_next()); + + let swarm_events = futures::stream::poll_fn(|cx| swarm1.poll_next_unpin(cx)) + .take(8) + .collect::>() + .await; + + let infos = swarm_events + .iter() + .filter_map(|e| match e { + SwarmEvent::Behaviour(identify::Event::Received { info, .. }) => Some(info.clone()), + _ => None, + }) + .collect::>(); + + assert!( + infos.len() > 1, + "should exchange identify payload more than once" + ); + + let listen_addrs = infos + .iter() + .map(|i| i.listen_addrs.clone()) + .collect::>(); + + for addrs in listen_addrs { + assert_eq!(addrs.len(), 1); + assert!(addrs.contains(&swarm2_tcp_listen_addr)); + } + + let reported_addrs = swarm_events + .iter() + .filter_map(|e| match e { + SwarmEvent::NewExternalAddrOfPeer { peer_id, address } => { + Some((*peer_id, address.clone())) + } + _ => None, + }) + .collect::>(); + + assert_eq!(reported_addrs.len(), 1, "To have one TCP address of remote"); + assert!(reported_addrs.contains(&(swarm2_peer_id, swarm2_tcp_listen_addr))); +} + #[async_std::test] async fn identify_push() { let _ = tracing_subscriber::fmt() From cdc9638ac1256f8a5305adb2f50a188de8874a0f Mon Sep 17 00:00:00 2001 From: Piotr Galar Date: Fri, 13 Sep 2024 19:18:30 +0200 Subject: [PATCH 233/246] chore: parameterise s3 build cache setup (#5586) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we're setting up a new cache bucket, we'd like to be able to control its' configuration via GitHub vars/secrets fully. FYI, the secrets are not set up yet. --------- Co-authored-by: João Oliveira Co-authored-by: Guillaume Michel --- .github/workflows/docker-image.yml | 8 +------- .github/workflows/interop-test.yml | 17 +++++++++-------- scripts/build-interop-image.sh | 4 ++-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 21863d0ed39..5cbfc20d69d 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -6,7 +6,6 @@ on: - 'master' tags: - 'libp2p-server-**' - pull_request: jobs: server: @@ -34,11 +33,6 @@ jobs: with: context: . file: ./misc/server/Dockerfile - push: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} # Only push image if we have the required permissions, i.e. not running from a fork - cache-from: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' && type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=rust-libp2p-server }} - cache-to: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' && type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=rust-libp2p-server }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - env: - AWS_ACCESS_KEY_ID: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }} diff --git a/.github/workflows/interop-test.yml b/.github/workflows/interop-test.yml index f3950897089..1d70ca2eaee 100644 --- a/.github/workflows/interop-test.yml +++ b/.github/workflows/interop-test.yml @@ -24,8 +24,9 @@ jobs: - name: Build ${{ matrix.flavour }} image run: ./scripts/build-interop-image.sh env: - AWS_ACCESS_KEY_ID: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }} + AWS_BUCKET_NAME: ${{ vars.S3_LIBP2P_BUILD_CACHE_BUCKET_NAME }} + AWS_ACCESS_KEY_ID: ${{ vars.S3_LIBP2P_BUILD_CACHE_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_LIBP2P_BUILD_CACHE_AWS_SECRET_ACCESS_KEY }} FLAVOUR: ${{ matrix.flavour }} - name: Run ${{ matrix.flavour }} tests @@ -33,9 +34,9 @@ jobs: with: test-filter: ${{ matrix.flavour }}-rust-libp2p-head extra-versions: ${{ github.workspace }}/interop-tests/${{ matrix.flavour }}-ping-version.json - s3-cache-bucket: libp2p-by-tf-aws-bootstrap - s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }} - s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }} + s3-cache-bucket: ${{ vars.S3_LIBP2P_BUILD_CACHE_BUCKET_NAME }} + s3-access-key-id: ${{ vars.S3_LIBP2P_BUILD_CACHE_AWS_ACCESS_KEY_ID }} + s3-secret-access-key: ${{ secrets.S3_LIBP2P_BUILD_CACHE_AWS_SECRET_ACCESS_KEY }} worker-count: 16 run-holepunching-interop: name: Run hole-punch interoperability tests @@ -50,7 +51,7 @@ jobs: with: test-filter: rust-libp2p-head extra-versions: ${{ github.workspace }}/hole-punching-tests/version.json - s3-cache-bucket: libp2p-by-tf-aws-bootstrap - s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }} - s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }} + s3-cache-bucket: ${{ vars.S3_LIBP2P_BUILD_CACHE_BUCKET_NAME }} + s3-access-key-id: ${{ vars.S3_LIBP2P_BUILD_CACHE_AWS_ACCESS_KEY_ID }} + s3-secret-access-key: ${{ secrets.S3_LIBP2P_BUILD_CACHE_AWS_SECRET_ACCESS_KEY }} worker-count: 16 diff --git a/scripts/build-interop-image.sh b/scripts/build-interop-image.sh index 28a8db9188d..ad6ef78b153 100755 --- a/scripts/build-interop-image.sh +++ b/scripts/build-interop-image.sh @@ -6,13 +6,13 @@ CACHE_TO="" # If we have credentials, write to cache if [[ -n "${AWS_SECRET_ACCESS_KEY}" ]]; then - CACHE_TO="--cache-to type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head" + CACHE_TO="--cache-to type=s3,mode=max,bucket=${AWS_BUCKET_NAME},region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head" fi docker buildx build \ --load \ $CACHE_TO \ - --cache-from type=s3,mode=max,bucket=libp2p-by-tf-aws-bootstrap,region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head \ + --cache-from type=s3,mode=max,bucket=${AWS_BUCKET_NAME},region=us-east-1,prefix=buildCache,name=${FLAVOUR}-rust-libp2p-head \ -t ${FLAVOUR}-rust-libp2p-head \ . \ -f interop-tests/Dockerfile.${FLAVOUR} From a2a281609a0a64b211f7917aa856924983b63200 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sat, 14 Sep 2024 00:33:14 +0200 Subject: [PATCH 234/246] fix(autonat): reject inbound dial request from peer if its not connected (#5597) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description As discovered and described in the issue below, there are situations where an incoming AutoNAT dial can come from a non-connected peer. However `resolve_inbound_request` expects that this situation cannot occur. This PR adds a check upfront and refuses the incoming dial when no connected peer is found. Fixes https://github.com/libp2p/rust-libp2p/issues/5570. ## Change checklist - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates Co-authored-by: João Oliveira --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/autonat/CHANGELOG.md | 3 +++ protocols/autonat/Cargo.toml | 2 +- protocols/autonat/src/v1/behaviour/as_server.rs | 15 +++++++++++++++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c12e6fb984..b3d1cd0d76d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2687,7 +2687,7 @@ dependencies = [ [[package]] name = "libp2p-autonat" -version = "0.13.0" +version = "0.13.1" dependencies = [ "async-std", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index da8d32e1a4a..c9fe928096d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,7 @@ futures-bounded = { version = "0.2.4" } futures-rustls = { version = "0.26.0", default-features = false } libp2p = { version = "0.54.1", path = "libp2p" } libp2p-allow-block-list = { version = "0.4.1", path = "misc/allow-block-list" } -libp2p-autonat = { version = "0.13.0", path = "protocols/autonat" } +libp2p-autonat = { version = "0.13.1", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.4.0", path = "misc/connection-limits" } libp2p-core = { version = "0.42.0", path = "core" } libp2p-dcutr = { version = "0.12.0", path = "protocols/dcutr" } diff --git a/protocols/autonat/CHANGELOG.md b/protocols/autonat/CHANGELOG.md index e171412aa58..f1aeda6ac18 100644 --- a/protocols/autonat/CHANGELOG.md +++ b/protocols/autonat/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.13.1 +- Verify that an incoming AutoNAT dial comes from a connected peer. See [PR 5597](https://github.com/libp2p/rust-libp2p/pull/5597). + ## 0.13.0 - Due to the refactor of `Transport` it's no longer required to create a seperate transport for diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index 2c01d18dceb..0c0e757641d 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-autonat" edition = "2021" rust-version = { workspace = true } description = "NAT and firewall detection for libp2p" -version = "0.13.0" +version = "0.13.1" authors = ["David Craven ", "Elena Frank ", "Hannes Furmans "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/autonat/src/v1/behaviour/as_server.rs b/protocols/autonat/src/v1/behaviour/as_server.rs index 3ecdd3ac26e..1289bd53d24 100644 --- a/protocols/autonat/src/v1/behaviour/as_server.rs +++ b/protocols/autonat/src/v1/behaviour/as_server.rs @@ -107,6 +107,21 @@ impl<'a> HandleInnerEvent for AsServer<'a> { }, } => { let probe_id = self.probe_id.next(); + if !self.connected.contains_key(&peer) { + tracing::debug!( + %peer, + "Reject inbound dial request from peer since it is not connected" + ); + + return VecDeque::from([ToSwarm::GenerateEvent(Event::InboundProbe( + InboundProbeEvent::Error { + probe_id, + peer, + error: InboundProbeError::Response(ResponseError::DialRefused), + }, + ))]); + } + match self.resolve_inbound_request(peer, request) { Ok(addrs) => { tracing::debug!( From fd4e1e1e89189af938460a182ad3c2374654c7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 20 Sep 2024 22:37:32 +0100 Subject: [PATCH 235/246] chore(ci): only run interop tests on commits to master (#5604) ## Description This is done as temporary measure to unblock PR merging as the CI is currently broken Co-authored-by: Guillaume Michel --- .github/workflows/interop-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/interop-test.yml b/.github/workflows/interop-test.yml index 1d70ca2eaee..558adcda66c 100644 --- a/.github/workflows/interop-test.yml +++ b/.github/workflows/interop-test.yml @@ -1,6 +1,5 @@ name: Interoperability Testing on: - pull_request: push: branches: - "master" From c6cf7fec6913aa590622aeea16709fce6e9c99a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Tue, 24 Sep 2024 16:00:02 +0100 Subject: [PATCH 236/246] fix(ci): address cargo-deny advisories (#5596) ## Description by updating: - `bytes` to 1.7.1, `1.6.0` was [yanked](https://crates.io/crates/bytes/1.6.0) - `quinn-proto` to 0.11.8 to address [RUSTSEC-2024-0373](https://rustsec.org/advisories/RUSTSEC-2024-0373.html) - thirtyfour-macros to 0.1.11 to remove `proc-macro-error` dependency and address [RUSTSEC-2024-0370](https://rustsec.org/advisories/RUSTSEC-2024-0370.html) --- Cargo.lock | 73 ++++++++++++------------------- examples/autonatv2/Dockerfile | 2 +- hole-punching-tests/Dockerfile | 2 +- interop-tests/Dockerfile.chromium | 2 +- interop-tests/Dockerfile.native | 2 +- misc/server/Dockerfile | 2 +- protocols/perf/Dockerfile | 2 +- 7 files changed, 33 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b3d1cd0d76d..4c3498a0635 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -833,9 +833,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] @@ -4584,30 +4584,6 @@ dependencies = [ "elliptic-curve", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.85" @@ -4724,7 +4700,7 @@ dependencies = [ "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash", + "rustc-hash 1.1.0", "rustls 0.23.11", "thiserror", "tokio", @@ -4733,14 +4709,14 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.2" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e974563a4b1c2206bbc61191ca4da9c22e4308b4c455e8906751cc7828393f08" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ "bytes", "rand 0.8.5", "ring 0.17.8", - "rustc-hash", + "rustc-hash 2.0.0", "rustls 0.23.11", "slab", "thiserror", @@ -5206,6 +5182,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc_version" version = "0.4.0" @@ -5471,18 +5453,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -5513,9 +5495,9 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", @@ -6002,30 +5984,29 @@ dependencies = [ [[package]] name = "thirtyfour-macros" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cae91d1c7c61ec65817f1064954640ee350a50ae6548ff9a1bdd2489d6ffbb0" +checksum = "b72d056365e368fc57a56d0cec9e41b02fb4a3474a61c8735262b1cfebe67425" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -6576,9 +6557,9 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna 0.5.0", diff --git a/examples/autonatv2/Dockerfile b/examples/autonatv2/Dockerfile index 5a523649d80..6bc92e4d11b 100644 --- a/examples/autonatv2/Dockerfile +++ b/examples/autonatv2/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.75-alpine as builder +FROM rust:1.81-alpine as builder RUN apk add musl-dev diff --git a/hole-punching-tests/Dockerfile b/hole-punching-tests/Dockerfile index af00ef2272f..403cc301fc6 100644 --- a/hole-punching-tests/Dockerfile +++ b/hole-punching-tests/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.75.0 as builder +FROM rust:1.81.0 as builder # Run with access to the target cache to speed up builds WORKDIR /workspace diff --git a/interop-tests/Dockerfile.chromium b/interop-tests/Dockerfile.chromium index a6b0fc89e82..86edbc5b9d2 100644 --- a/interop-tests/Dockerfile.chromium +++ b/interop-tests/Dockerfile.chromium @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.75.0 as chef +FROM rust:1.81 as chef RUN rustup target add wasm32-unknown-unknown RUN wget -q -O- https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz | tar -zx -C /usr/local/bin --strip-components 1 --wildcards "wasm-pack-*/wasm-pack" RUN wget -q -O- https://github.com/WebAssembly/binaryen/releases/download/version_115/binaryen-version_115-x86_64-linux.tar.gz | tar -zx -C /usr/local/bin --strip-components 2 --wildcards "binaryen-version_*/bin/wasm-opt" diff --git a/interop-tests/Dockerfile.native b/interop-tests/Dockerfile.native index b122ac72991..499c73437fc 100644 --- a/interop-tests/Dockerfile.native +++ b/interop-tests/Dockerfile.native @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM lukemathwalker/cargo-chef:0.1.62-rust-1.75.0 as chef +FROM lukemathwalker/cargo-chef:0.1.67-rust-bullseye as chef WORKDIR /app FROM chef AS planner diff --git a/misc/server/Dockerfile b/misc/server/Dockerfile index 1583fba6bef..24ae2b9fd99 100644 --- a/misc/server/Dockerfile +++ b/misc/server/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.75.0 as chef +FROM rust:1.81.0 as chef RUN wget -q -O- https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.62/cargo-chef-x86_64-unknown-linux-gnu.tar.gz | tar -zx -C /usr/local/bin RUN cargo install --locked --root /usr/local libp2p-lookup --version 0.6.4 WORKDIR /app diff --git a/protocols/perf/Dockerfile b/protocols/perf/Dockerfile index 1bd846cc228..f68ea6ef211 100644 --- a/protocols/perf/Dockerfile +++ b/protocols/perf/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.5-labs -FROM rust:1.75.0 as builder +FROM rust:1.81.0 as builder # Run with access to the target cache to speed up builds WORKDIR /workspace From f3e0e554821ca9233f202e80d1bae9e27cfb3ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Wed, 25 Sep 2024 10:36:01 +0100 Subject: [PATCH 237/246] chore(ci): address beta clippy lints (#5606) Co-authored-by: Darius Clark --- misc/allow-block-list/src/lib.rs | 2 ++ misc/connection-limits/src/lib.rs | 4 ++++ misc/memory-connection-limits/src/lib.rs | 2 ++ misc/memory-connection-limits/tests/util/mod.rs | 2 ++ misc/quick-protobuf-codec/src/lib.rs | 1 + .../autonat/src/v2/client/handler/dial_back.rs | 2 ++ .../autonat/src/v2/client/handler/dial_request.rs | 2 ++ protocols/autonat/src/v2/server/behaviour.rs | 2 ++ .../autonat/src/v2/server/handler/dial_request.rs | 2 ++ protocols/dcutr/src/behaviour.rs | 2 ++ protocols/dcutr/src/handler/relayed.rs | 8 ++++++++ protocols/gossipsub/src/handler.rs | 4 ++++ protocols/gossipsub/src/transform.rs | 1 + protocols/kad/src/handler.rs | 2 ++ protocols/perf/src/client/handler.rs | 4 ++++ protocols/perf/src/server/handler.rs | 8 ++++++++ protocols/ping/src/handler.rs | 2 ++ protocols/relay/src/behaviour.rs | 2 ++ protocols/relay/src/behaviour/handler.rs | 2 ++ protocols/relay/src/priv_client.rs | 2 ++ protocols/relay/src/priv_client/handler.rs | 6 ++++++ protocols/request-response/src/cbor.rs | 2 ++ protocols/request-response/src/handler.rs | 6 ++++++ protocols/stream/src/handler.rs | 4 ++++ swarm/src/behaviour/toggle.rs | 4 ++++ swarm/src/connection.rs | 10 ++++++++++ swarm/src/connection/pool/task.rs | 4 ++++ swarm/src/dummy.rs | 14 ++++++++++++++ swarm/src/handler/pending.rs | 8 ++++++++ swarm/src/upgrade.rs | 1 + swarm/tests/swarm_derive.rs | 2 ++ transports/quic/src/hole_punching.rs | 2 ++ 32 files changed, 119 insertions(+) diff --git a/misc/allow-block-list/src/lib.rs b/misc/allow-block-list/src/lib.rs index 7646638a651..56de29d1985 100644 --- a/misc/allow-block-list/src/lib.rs +++ b/misc/allow-block-list/src/lib.rs @@ -271,6 +271,8 @@ where _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/misc/connection-limits/src/lib.rs b/misc/connection-limits/src/lib.rs index b02e52f25a1..05a9b639f26 100644 --- a/misc/connection-limits/src/lib.rs +++ b/misc/connection-limits/src/lib.rs @@ -355,6 +355,8 @@ impl NetworkBehaviour for Behaviour { _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -586,6 +588,8 @@ mod tests { _connection_id: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/misc/memory-connection-limits/src/lib.rs b/misc/memory-connection-limits/src/lib.rs index 7b5803a61aa..757ff770487 100644 --- a/misc/memory-connection-limits/src/lib.rs +++ b/misc/memory-connection-limits/src/lib.rs @@ -190,6 +190,8 @@ impl NetworkBehaviour for Behaviour { _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/misc/memory-connection-limits/tests/util/mod.rs b/misc/memory-connection-limits/tests/util/mod.rs index d18aa78fd22..01e8cd9f655 100644 --- a/misc/memory-connection-limits/tests/util/mod.rs +++ b/misc/memory-connection-limits/tests/util/mod.rs @@ -116,6 +116,8 @@ impl NetworkBehaviour _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/misc/quick-protobuf-codec/src/lib.rs b/misc/quick-protobuf-codec/src/lib.rs index 166ee82ff08..32cee8eccac 100644 --- a/misc/quick-protobuf-codec/src/lib.rs +++ b/misc/quick-protobuf-codec/src/lib.rs @@ -12,6 +12,7 @@ mod generated; pub use generated::test as proto; /// [`Codec`] implements [`Encoder`] and [`Decoder`], uses [`unsigned_varint`] +/// /// to prefix messages with their length and uses [`quick_protobuf`] and a provided /// `struct` implementing [`MessageRead`] and [`MessageWrite`] to do the encoding. pub struct Codec { diff --git a/protocols/autonat/src/v2/client/handler/dial_back.rs b/protocols/autonat/src/v2/client/handler/dial_back.rs index b94580e69ba..98a41a82504 100644 --- a/protocols/autonat/src/v2/client/handler/dial_back.rs +++ b/protocols/autonat/src/v2/client/handler/dial_back.rs @@ -83,6 +83,8 @@ impl ConnectionHandler for Handler { tracing::warn!("Dial back request dropped, too many requests in flight"); } } + // TODO: remove when Rust 1.82 is MSRVprotocols/autonat/src/v2/client/handler/dial_back.rs + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ListenUpgradeError { error, .. }) => { void::unreachable(error); } diff --git a/protocols/autonat/src/v2/client/handler/dial_request.rs b/protocols/autonat/src/v2/client/handler/dial_request.rs index 9d2df8ee6b4..85ad176ec30 100644 --- a/protocols/autonat/src/v2/client/handler/dial_request.rs +++ b/protocols/autonat/src/v2/client/handler/dial_request.rs @@ -216,6 +216,8 @@ async fn start_stream_handle( .map_err(|e| match e { StreamUpgradeError::NegotiationFailed => Error::UnsupportedProtocol, StreamUpgradeError::Timeout => Error::Io(io::ErrorKind::TimedOut.into()), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(v) => void::unreachable(v), StreamUpgradeError::Io(e) => Error::Io(e), })?; diff --git a/protocols/autonat/src/v2/server/behaviour.rs b/protocols/autonat/src/v2/server/behaviour.rs index 5f7b21d165b..9264c728fe4 100644 --- a/protocols/autonat/src/v2/server/behaviour.rs +++ b/protocols/autonat/src/v2/server/behaviour.rs @@ -112,6 +112,8 @@ where Either::Left(Either::Left(Err(e))) => { tracing::debug!("dial back error: {e:?}"); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Left(Either::Right(v)) => void::unreachable(v), Either::Right(Either::Left(cmd)) => { let addr = cmd.addr.clone(); diff --git a/protocols/autonat/src/v2/server/handler/dial_request.rs b/protocols/autonat/src/v2/server/handler/dial_request.rs index 9a3729d4ccf..14ddb153416 100644 --- a/protocols/autonat/src/v2/server/handler/dial_request.rs +++ b/protocols/autonat/src/v2/server/handler/dial_request.rs @@ -143,6 +143,8 @@ where ); } } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ListenUpgradeError { error, .. }) => { tracing::debug!("inbound request failed: {:?}", error); } diff --git a/protocols/dcutr/src/behaviour.rs b/protocols/dcutr/src/behaviour.rs index 574c96205fa..babd56bd28e 100644 --- a/protocols/dcutr/src/behaviour.rs +++ b/protocols/dcutr/src/behaviour.rs @@ -314,6 +314,8 @@ impl NetworkBehaviour for Behaviour { .or_default() += 1; self.queued_events.push_back(ToSwarm::Dial { opts }); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(never) => void::unreachable(never), }; } diff --git a/protocols/dcutr/src/handler/relayed.rs b/protocols/dcutr/src/handler/relayed.rs index eba58f89313..72af9fec264 100644 --- a/protocols/dcutr/src/handler/relayed.rs +++ b/protocols/dcutr/src/handler/relayed.rs @@ -115,6 +115,8 @@ impl Handler { self.attempts += 1; } // A connection listener denies all incoming substreams, thus none can ever be fully negotiated. + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] future::Either::Right(output) => void::unreachable(output), } } @@ -153,6 +155,8 @@ impl Handler { ::InboundProtocol, >, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(error.into_inner()); } @@ -164,6 +168,8 @@ impl Handler { >, ) { let error = match error { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(v) => void::unreachable(v), StreamUpgradeError::NegotiationFailed => outbound::Error::Unsupported, StreamUpgradeError::Io(e) => outbound::Error::Io(e), @@ -298,6 +304,8 @@ impl ConnectionHandler for Handler { ConnectionEvent::FullyNegotiatedOutbound(fully_negotiated_outbound) => { self.on_fully_negotiated_outbound(fully_negotiated_outbound) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(listen_upgrade_error) => { self.on_listen_upgrade_error(listen_upgrade_error) } diff --git a/protocols/gossipsub/src/handler.rs b/protocols/gossipsub/src/handler.rs index 88def13a521..8e3b3a8b022 100644 --- a/protocols/gossipsub/src/handler.rs +++ b/protocols/gossipsub/src/handler.rs @@ -493,6 +493,8 @@ impl ConnectionHandler for Handler { .. }) => match protocol { Either::Left(protocol) => handler.on_fully_negotiated_inbound(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(v) => void::unreachable(v), }, ConnectionEvent::FullyNegotiatedOutbound(fully_negotiated_outbound) => { @@ -504,6 +506,8 @@ impl ConnectionHandler for Handler { }) => { tracing::debug!("Dial upgrade error: Protocol negotiation timeout"); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::DialUpgradeError(DialUpgradeError { error: StreamUpgradeError::Apply(e), .. diff --git a/protocols/gossipsub/src/transform.rs b/protocols/gossipsub/src/transform.rs index 6f57d9fc46b..4831f9781b0 100644 --- a/protocols/gossipsub/src/transform.rs +++ b/protocols/gossipsub/src/transform.rs @@ -28,6 +28,7 @@ use crate::{Message, RawMessage, TopicHash}; /// A general trait of transforming a [`RawMessage`] into a [`Message`]. The +/// /// [`RawMessage`] is obtained from the wire and the [`Message`] is used to /// calculate the [`crate::MessageId`] of the message and is what is sent to the application. /// diff --git a/protocols/kad/src/handler.rs b/protocols/kad/src/handler.rs index 5e7c2e21b8b..17c483da709 100644 --- a/protocols/kad/src/handler.rs +++ b/protocols/kad/src/handler.rs @@ -501,6 +501,8 @@ impl Handler { // is a `Void`. let protocol = match protocol { future::Either::Left(p) => p, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] future::Either::Right(p) => void::unreachable(p), }; diff --git a/protocols/perf/src/client/handler.rs b/protocols/perf/src/client/handler.rs index 2a2c5499fc2..55fafad7fcc 100644 --- a/protocols/perf/src/client/handler.rs +++ b/protocols/perf/src/client/handler.rs @@ -112,6 +112,8 @@ impl ConnectionHandler for Handler { >, ) { match event { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { protocol, .. }) => void::unreachable(protocol), @@ -144,6 +146,8 @@ impl ConnectionHandler for Handler { result: Err(error.into()), })); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ListenUpgradeError { info: (), error }) => { void::unreachable(error) } diff --git a/protocols/perf/src/server/handler.rs b/protocols/perf/src/server/handler.rs index ddfe8f881e5..4cb535a452c 100644 --- a/protocols/perf/src/server/handler.rs +++ b/protocols/perf/src/server/handler.rs @@ -73,6 +73,8 @@ impl ConnectionHandler for Handler { } fn on_behaviour_event(&mut self, v: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(v) } @@ -98,16 +100,22 @@ impl ConnectionHandler for Handler { tracing::warn!("Dropping inbound stream because we are at capacity"); } } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { info, .. }) => { void::unreachable(info) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::DialUpgradeError(DialUpgradeError { info, .. }) => { void::unreachable(info) } ConnectionEvent::AddressChange(_) | ConnectionEvent::LocalProtocolsChange(_) | ConnectionEvent::RemoteProtocolsChange(_) => {} + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ListenUpgradeError { info: (), error }) => { void::unreachable(error) } diff --git a/protocols/ping/src/handler.rs b/protocols/ping/src/handler.rs index 2816cdc4048..7b36b2d4b3d 100644 --- a/protocols/ping/src/handler.rs +++ b/protocols/ping/src/handler.rs @@ -210,6 +210,8 @@ impl Handler { "ping protocol negotiation timed out", )), }, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(e) => void::unreachable(e), StreamUpgradeError::Io(e) => Failure::Other { error: Box::new(e) }, }; diff --git a/protocols/relay/src/behaviour.rs b/protocols/relay/src/behaviour.rs index 463febf9f2f..46419ae64e3 100644 --- a/protocols/relay/src/behaviour.rs +++ b/protocols/relay/src/behaviour.rs @@ -366,6 +366,8 @@ impl NetworkBehaviour for Behaviour { ) { let event = match event { Either::Left(e) => e, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(v) => void::unreachable(v), }; diff --git a/protocols/relay/src/behaviour/handler.rs b/protocols/relay/src/behaviour/handler.rs index 92557287099..23e90f4b3f8 100644 --- a/protocols/relay/src/behaviour/handler.rs +++ b/protocols/relay/src/behaviour/handler.rs @@ -449,6 +449,8 @@ impl Handler { StreamUpgradeError::Timeout => outbound_stop::Error::Io(io::ErrorKind::TimedOut.into()), StreamUpgradeError::NegotiationFailed => outbound_stop::Error::Unsupported, StreamUpgradeError::Io(e) => outbound_stop::Error::Io(e), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(v) => void::unreachable(v), }; diff --git a/protocols/relay/src/priv_client.rs b/protocols/relay/src/priv_client.rs index f8d1d9c9eb2..8bbc813ec4c 100644 --- a/protocols/relay/src/priv_client.rs +++ b/protocols/relay/src/priv_client.rs @@ -236,6 +236,8 @@ impl NetworkBehaviour for Behaviour { ) { let handler_event = match handler_event { Either::Left(e) => e, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(v) => void::unreachable(v), }; diff --git a/protocols/relay/src/priv_client/handler.rs b/protocols/relay/src/priv_client/handler.rs index 662d63cc742..05fdd5673ae 100644 --- a/protocols/relay/src/priv_client/handler.rs +++ b/protocols/relay/src/priv_client/handler.rs @@ -445,6 +445,8 @@ impl ConnectionHandler for Handler { let _ = next.send(Ok(ev.protocol)); } } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(ev) => void::unreachable(ev.error), ConnectionEvent::DialUpgradeError(ev) => { if let Some(next) = self.pending_streams.pop_front() { @@ -583,6 +585,8 @@ fn into_reserve_error(e: StreamUpgradeError) -> outbound_hop::ReserveError StreamUpgradeError::Timeout => { outbound_hop::ReserveError::Io(io::ErrorKind::TimedOut.into()) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(never) => void::unreachable(never), StreamUpgradeError::NegotiationFailed => outbound_hop::ReserveError::Unsupported, StreamUpgradeError::Io(e) => outbound_hop::ReserveError::Io(e), @@ -594,6 +598,8 @@ fn into_connect_error(e: StreamUpgradeError) -> outbound_hop::ConnectError StreamUpgradeError::Timeout => { outbound_hop::ConnectError::Io(io::ErrorKind::TimedOut.into()) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(never) => void::unreachable(never), StreamUpgradeError::NegotiationFailed => outbound_hop::ConnectError::Unsupported, StreamUpgradeError::Io(e) => outbound_hop::ConnectError::Io(e), diff --git a/protocols/request-response/src/cbor.rs b/protocols/request-response/src/cbor.rs index 44d82be2630..a27d069e758 100644 --- a/protocols/request-response/src/cbor.rs +++ b/protocols/request-response/src/cbor.rs @@ -143,6 +143,8 @@ mod codec { fn decode_into_io_error(err: cbor4ii::serde::DecodeError) -> io::Error { match err { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] cbor4ii::serde::DecodeError::Core(DecodeError::Read(e)) => { io::Error::new(io::ErrorKind::Other, e) } diff --git a/protocols/request-response/src/handler.rs b/protocols/request-response/src/handler.rs index f0467593f85..0591b37dc30 100644 --- a/protocols/request-response/src/handler.rs +++ b/protocols/request-response/src/handler.rs @@ -240,6 +240,8 @@ where self.pending_events .push_back(Event::OutboundUnsupportedProtocols(message.request_id)); } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Apply(e) => void::unreachable(e), StreamUpgradeError::Io(e) => { self.pending_events.push_back(Event::OutboundStreamFailed { @@ -256,6 +258,8 @@ where ::InboundProtocol, >, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(error) } } @@ -484,6 +488,8 @@ where ConnectionEvent::DialUpgradeError(dial_upgrade_error) => { self.on_dial_upgrade_error(dial_upgrade_error) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::ListenUpgradeError(listen_upgrade_error) => { self.on_listen_upgrade_error(listen_upgrade_error) } diff --git a/protocols/stream/src/handler.rs b/protocols/stream/src/handler.rs index f63b93c1761..bf80e30c3c6 100644 --- a/protocols/stream/src/handler.rs +++ b/protocols/stream/src/handler.rs @@ -96,6 +96,8 @@ impl ConnectionHandler for Handler { } fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -143,6 +145,8 @@ impl ConnectionHandler for Handler { swarm::StreamUpgradeError::Timeout => { OpenStreamError::Io(io::Error::from(io::ErrorKind::TimedOut)) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] swarm::StreamUpgradeError::Apply(v) => void::unreachable(v), swarm::StreamUpgradeError::NegotiationFailed => { OpenStreamError::UnsupportedProtocol(p) diff --git a/swarm/src/behaviour/toggle.rs b/swarm/src/behaviour/toggle.rs index 398c919ae86..5d72534c91e 100644 --- a/swarm/src/behaviour/toggle.rs +++ b/swarm/src/behaviour/toggle.rs @@ -210,6 +210,8 @@ where ) { let out = match out { future::Either::Left(out) => out, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] future::Either::Right(v) => void::unreachable(v), }; @@ -251,6 +253,8 @@ where let err = match err { Either::Left(e) => e, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right(v) => void::unreachable(v), }; diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index 603a5b0d7c4..2f9afc38418 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -1189,10 +1189,14 @@ mod tests { >, ) { match event { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { protocol, .. }) => void::unreachable(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { protocol, .. @@ -1200,6 +1204,8 @@ mod tests { ConnectionEvent::DialUpgradeError(DialUpgradeError { error, .. }) => { self.error = Some(error) } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::AddressChange(_) | ConnectionEvent::ListenUpgradeError(_) | ConnectionEvent::LocalProtocolsChange(_) @@ -1208,6 +1214,8 @@ mod tests { } fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -1283,6 +1291,8 @@ mod tests { } fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } diff --git a/swarm/src/connection/pool/task.rs b/swarm/src/connection/pool/task.rs index 08674fd2ee5..13977a17b85 100644 --- a/swarm/src/connection/pool/task.rs +++ b/swarm/src/connection/pool/task.rs @@ -105,6 +105,8 @@ pub(crate) async fn new_for_pending_outgoing_connection( }) .await; } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Left((Ok(v), _)) => void::unreachable(v), Either::Right((Ok((address, output, errors)), _)) => { let _ = events @@ -143,6 +145,8 @@ pub(crate) async fn new_for_pending_incoming_connection( }) .await; } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Left((Ok(v), _)) => void::unreachable(v), Either::Right((Ok(output), _)) => { let _ = events diff --git a/swarm/src/dummy.rs b/swarm/src/dummy.rs index 6e1b4d56eb9..0bd8c06862d 100644 --- a/swarm/src/dummy.rs +++ b/swarm/src/dummy.rs @@ -49,6 +49,8 @@ impl NetworkBehaviour for Behaviour { _: ConnectionId, event: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -76,6 +78,8 @@ impl crate::handler::ConnectionHandler for ConnectionHandler { } fn on_behaviour_event(&mut self, event: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(event) } @@ -98,19 +102,29 @@ impl crate::handler::ConnectionHandler for ConnectionHandler { >, ) { match event { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { protocol, .. }) => void::unreachable(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { protocol, .. }) => void::unreachable(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::DialUpgradeError(DialUpgradeError { info: _, error }) => match error { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] StreamUpgradeError::Timeout => unreachable!(), StreamUpgradeError::Apply(e) => void::unreachable(e), StreamUpgradeError::NegotiationFailed | StreamUpgradeError::Io(_) => { unreachable!("Denied upgrade does not support any protocols") } }, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::AddressChange(_) | ConnectionEvent::ListenUpgradeError(_) | ConnectionEvent::LocalProtocolsChange(_) diff --git a/swarm/src/handler/pending.rs b/swarm/src/handler/pending.rs index 23b9adcfd90..9601f5cf78b 100644 --- a/swarm/src/handler/pending.rs +++ b/swarm/src/handler/pending.rs @@ -52,6 +52,8 @@ impl ConnectionHandler for PendingConnectionHandler { } fn on_behaviour_event(&mut self, v: Self::FromBehaviour) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(v) } @@ -74,9 +76,13 @@ impl ConnectionHandler for PendingConnectionHandler { >, ) { match event { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { protocol, .. }) => void::unreachable(protocol), + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { protocol, info: _info, @@ -87,6 +93,8 @@ impl ConnectionHandler for PendingConnectionHandler { void::unreachable(_info); } } + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] ConnectionEvent::AddressChange(_) | ConnectionEvent::DialUpgradeError(_) | ConnectionEvent::ListenUpgradeError(_) diff --git a/swarm/src/upgrade.rs b/swarm/src/upgrade.rs index 53b627458c9..f6c6648a373 100644 --- a/swarm/src/upgrade.rs +++ b/swarm/src/upgrade.rs @@ -121,6 +121,7 @@ where } /// Wraps around a type that implements [`OutboundUpgradeSend`], [`InboundUpgradeSend`], or +/// /// both, and implements [`OutboundUpgrade`](upgrade::OutboundUpgrade) and/or /// [`InboundUpgrade`](upgrade::InboundUpgrade). /// diff --git a/swarm/tests/swarm_derive.rs b/swarm/tests/swarm_derive.rs index 919ed0cab7f..667f68408cf 100644 --- a/swarm/tests/swarm_derive.rs +++ b/swarm/tests/swarm_derive.rs @@ -577,6 +577,8 @@ fn custom_out_event_no_type_parameters() { _connection: ConnectionId, message: THandlerOutEvent, ) { + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] void::unreachable(message); } diff --git a/transports/quic/src/hole_punching.rs b/transports/quic/src/hole_punching.rs index 605799af5e1..a38d123a6a4 100644 --- a/transports/quic/src/hole_punching.rs +++ b/transports/quic/src/hole_punching.rs @@ -20,6 +20,8 @@ pub(crate) async fn hole_puncher( match futures::future::select(P::sleep(timeout_duration), punch_holes_future).await { Either::Left(_) => Error::HandshakeTimedOut, Either::Right((Err(hole_punch_err), _)) => hole_punch_err, + // TODO: remove when Rust 1.82 is MSRV + #[allow(unreachable_patterns)] Either::Right((Ok(never), _)) => match never {}, } } From 8ceadaac5aec4b462463ef4082d6af577a3158b1 Mon Sep 17 00:00:00 2001 From: stormshield-frb <144998884+stormshield-frb@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:17:47 +0200 Subject: [PATCH 238/246] fix(swarm): don't report `NewExternalAddrCandidate` if already confirmed (#5582) ## Description Currently, `NewExternalAddrCandidate` events are emitted for every connections. However, we continue to get this event even when `autonat` has already confirmed that this address is external. So we should not continue to advertise the "candidate" event. ## Notes & open questions We have made the changes in the `swarm` instead of `identify` because it does not make it necessary to duplicate the `ConfirmedExternalAddr` vector in the `identify` Behaviour. Moreover, if any future Behaviour emit `NewExternalAddrCandidate`, the same rule will also be applied. I had to edit the `autonat_v2` tests which were always expecting a `NewExternalAddrCandidate` but the address was already confirmed. ## Change checklist - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates --------- Co-authored-by: Darius Clark Co-authored-by: Guillaume Michel --- Cargo.lock | 2 +- Cargo.toml | 2 +- protocols/autonat/tests/autonatv2.rs | 38 +++++++++++++--------------- swarm/CHANGELOG.md | 5 ++++ swarm/Cargo.toml | 2 +- swarm/src/lib.rs | 14 +++++----- 6 files changed, 34 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c3498a0635..79eb2eb4ad5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3329,7 +3329,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.45.1" +version = "0.45.2" dependencies = [ "async-std", "criterion", diff --git a/Cargo.toml b/Cargo.toml index c9fe928096d..32f72c5e252 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,7 +102,7 @@ libp2p-rendezvous = { version = "0.15.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.27.0", path = "protocols/request-response" } libp2p-server = { version = "0.12.7", path = "misc/server" } libp2p-stream = { version = "0.2.0-alpha", path = "protocols/stream" } -libp2p-swarm = { version = "0.45.1", path = "swarm" } +libp2p-swarm = { version = "0.45.2", path = "swarm" } libp2p-swarm-derive = { version = "=0.35.0", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. libp2p-swarm-test = { version = "0.4.0", path = "swarm-test" } libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } diff --git a/protocols/autonat/tests/autonatv2.rs b/protocols/autonat/tests/autonatv2.rs index abd0c4bd8eb..3d792172445 100644 --- a/protocols/autonat/tests/autonatv2.rs +++ b/protocols/autonat/tests/autonatv2.rs @@ -1,5 +1,6 @@ use libp2p_autonat::v2::client::{self, Config}; use libp2p_autonat::v2::server; +use libp2p_core::multiaddr::Protocol; use libp2p_core::transport::TransportError; use libp2p_core::Multiaddr; use libp2p_swarm::{ @@ -21,17 +22,10 @@ async fn confirm_successful() { let cor_server_peer = *alice.local_peer_id(); let cor_client_peer = *bob.local_peer_id(); - let bob_external_addrs = Arc::new(bob.external_addresses().cloned().collect::>()); - let alice_bob_external_addrs = bob_external_addrs.clone(); + let bob_tcp_listeners = Arc::new(tcp_listeners(&bob)); + let alice_bob_tcp_listeners = bob_tcp_listeners.clone(); let alice_task = async { - let _ = alice - .wait(|event| match event { - SwarmEvent::NewExternalAddrCandidate { .. } => Some(()), - _ => None, - }) - .await; - let (dialed_peer_id, dialed_connection_id) = alice .wait(|event| match event { SwarmEvent::Dialing { @@ -76,10 +70,10 @@ async fn confirm_successful() { }) .await; - assert_eq!(tested_addr, bob_external_addrs.first().cloned().unwrap()); + assert_eq!(tested_addr, bob_tcp_listeners.first().cloned().unwrap()); assert_eq!(data_amount, 0); assert_eq!(client, cor_client_peer); - assert_eq!(&all_addrs[..], &bob_external_addrs[..]); + assert_eq!(&all_addrs[..], &bob_tcp_listeners[..]); assert!(result.is_ok(), "Result: {result:?}"); }; @@ -122,7 +116,7 @@ async fn confirm_successful() { .await; assert_eq!( tested_addr, - alice_bob_external_addrs.first().cloned().unwrap() + alice_bob_tcp_listeners.first().cloned().unwrap() ); assert_eq!(bytes_sent, 0); assert_eq!(server, cor_server_peer); @@ -446,7 +440,7 @@ async fn new_client() -> Swarm { identity.public().clone(), )), }); - node.listen().with_tcp_addr_external().await; + node.listen().await; node } @@ -490,13 +484,6 @@ async fn bootstrap() -> (Swarm, Swarm) { let cor_client_peer = *bob.local_peer_id(); let alice_task = async { - let _ = alice - .wait(|event| match event { - SwarmEvent::NewExternalAddrCandidate { .. } => Some(()), - _ => None, - }) - .await; - let (dialed_peer_id, dialed_connection_id) = alice .wait(|event| match event { SwarmEvent::Dialing { @@ -566,3 +553,14 @@ async fn bootstrap() -> (Swarm, Swarm) { tokio::join!(alice_task, bob_task); (alice, bob) } + +fn tcp_listeners(swarm: &Swarm) -> Vec { + swarm + .listeners() + .filter(|addr| { + addr.iter() + .any(|protocol| matches!(protocol, Protocol::Tcp(_))) + }) + .cloned() + .collect::>() +} diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index e7931a60de2..c5d10872d40 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.45.2 + +- Don't report `NewExternalAddrCandidate` for confirmed external addresses. + See [PR 5582](https://github.com/libp2p/rust-libp2p/pull/5582). + ## 0.45.1 - Update `libp2p-swarm-derive` to version `0.35.0`, see [PR 5545] diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 3d0b1a84eee..cdee67f3fb3 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition = "2021" rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.45.1" +version = "0.45.2" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 81b1ca1a68d..12280e99f07 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1140,12 +1140,14 @@ where self.pending_handler_event = Some((peer_id, handler, event)); } ToSwarm::NewExternalAddrCandidate(addr) => { - self.behaviour - .on_swarm_event(FromSwarm::NewExternalAddrCandidate( - NewExternalAddrCandidate { addr: &addr }, - )); - self.pending_swarm_events - .push_back(SwarmEvent::NewExternalAddrCandidate { address: addr }); + if !self.confirmed_external_addr.contains(&addr) { + self.behaviour + .on_swarm_event(FromSwarm::NewExternalAddrCandidate( + NewExternalAddrCandidate { addr: &addr }, + )); + self.pending_swarm_events + .push_back(SwarmEvent::NewExternalAddrCandidate { address: addr }); + } } ToSwarm::ExternalAddrConfirmed(addr) => { self.add_external_address(addr.clone()); From 89d78dda296fc3747d3760f73d4b6c558e34c8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 4 Oct 2024 14:35:08 +0100 Subject: [PATCH 239/246] chore(autonat-v2): fix dial_back_to_non_libp2p test (#5621) ## Description By avoiding dialing an external address Co-authored-by: Guillaume Michel --- protocols/autonat/tests/autonatv2.rs | 147 +++++++++++++-------------- 1 file changed, 72 insertions(+), 75 deletions(-) diff --git a/protocols/autonat/tests/autonatv2.rs b/protocols/autonat/tests/autonatv2.rs index 3d792172445..f22a2e51470 100644 --- a/protocols/autonat/tests/autonatv2.rs +++ b/protocols/autonat/tests/autonatv2.rs @@ -232,87 +232,84 @@ async fn dial_back_to_non_libp2p() { let (mut alice, mut bob) = bootstrap().await; let alice_peer_id = *alice.local_peer_id(); - for addr_str in ["/ip4/169.150.247.38/tcp/32", "/ip6/::1/tcp/1000"] { - let addr: Multiaddr = addr_str.parse().unwrap(); - let bob_addr = addr.clone(); - bob.behaviour_mut() - .autonat - .on_swarm_event(FromSwarm::NewExternalAddrCandidate( - NewExternalAddrCandidate { addr: &addr }, - )); - - let alice_task = async { - let (alice_dialing_peer, alice_conn_id) = alice - .wait(|event| match event { - SwarmEvent::Dialing { - peer_id, - connection_id, - } => peer_id.map(|p| (p, connection_id)), - _ => None, - }) - .await; - let mut outgoing_conn_error = alice - .wait(|event| match event { - SwarmEvent::OutgoingConnectionError { - connection_id, - peer_id: Some(peer_id), - error: DialError::Transport(peers), - } if connection_id == alice_conn_id && peer_id == alice_dialing_peer => { - Some(peers) - } - _ => None, - }) - .await; - - if let Some((multiaddr, TransportError::Other(o))) = outgoing_conn_error.pop() { - assert_eq!( - multiaddr, - addr.clone().with_p2p(alice_dialing_peer).unwrap() - ); - let error_string = o.to_string(); - assert!( - error_string.contains("Connection refused"), - "Correct error string: {error_string} for {addr_str}" - ); - } else { - panic!("No outgoing connection errors"); - } + let addr_str = "/ip6/::1/tcp/1000"; + let addr: Multiaddr = addr_str.parse().unwrap(); + let bob_addr = addr.clone(); + bob.behaviour_mut() + .autonat + .on_swarm_event(FromSwarm::NewExternalAddrCandidate( + NewExternalAddrCandidate { addr: &addr }, + )); - alice - .wait(|event| match event { - SwarmEvent::Behaviour(CombinedServerEvent::Autonat(server::Event { - all_addrs, - tested_addr, - client, - data_amount, - result: Ok(()), - })) if all_addrs == vec![addr.clone()] - && tested_addr == addr - && alice_dialing_peer == client => - { - Some(data_amount) - } - _ => None, - }) - .await - }; - let bob_task = async { - bob.wait(|event| match event { - SwarmEvent::Behaviour(CombinedClientEvent::Autonat(client::Event { + let alice_task = async { + let (alice_dialing_peer, alice_conn_id) = alice + .wait(|event| match event { + SwarmEvent::Dialing { + peer_id, + connection_id, + } => peer_id.map(|p| (p, connection_id)), + _ => None, + }) + .await; + let mut outgoing_conn_error = alice + .wait(|event| match event { + SwarmEvent::OutgoingConnectionError { + connection_id, + peer_id: Some(peer_id), + error: DialError::Transport(peers), + } if connection_id == alice_conn_id && peer_id == alice_dialing_peer => Some(peers), + _ => None, + }) + .await; + + if let Some((multiaddr, TransportError::Other(o))) = outgoing_conn_error.pop() { + assert_eq!( + multiaddr, + addr.clone().with_p2p(alice_dialing_peer).unwrap() + ); + let error_string = o.to_string(); + assert!( + error_string.contains("Connection refused"), + "Correct error string: {error_string} for {addr_str}" + ); + } else { + panic!("No outgoing connection errors"); + } + + alice + .wait(|event| match event { + SwarmEvent::Behaviour(CombinedServerEvent::Autonat(server::Event { + all_addrs, tested_addr, - bytes_sent, - server, - result: Err(_), - })) if tested_addr == bob_addr && server == alice_peer_id => Some(bytes_sent), + client, + data_amount, + result: Ok(()), + })) if all_addrs == vec![addr.clone()] + && tested_addr == addr + && alice_dialing_peer == client => + { + Some(data_amount) + } _ => None, }) .await - }; + }; + let bob_task = async { + bob.wait(|event| match event { + SwarmEvent::Behaviour(CombinedClientEvent::Autonat(client::Event { + tested_addr, + bytes_sent, + server, + result: Err(_), + })) if tested_addr == bob_addr && server == alice_peer_id => Some(bytes_sent), + _ => None, + }) + .await + }; - let (alice_bytes_sent, bob_bytes_sent) = tokio::join!(alice_task, bob_task); - assert_eq!(alice_bytes_sent, bob_bytes_sent); - bob.behaviour_mut().autonat.validate_addr(&addr); - } + let (alice_bytes_sent, bob_bytes_sent) = tokio::join!(alice_task, bob_task); + assert_eq!(alice_bytes_sent, bob_bytes_sent); + bob.behaviour_mut().autonat.validate_addr(&addr); } #[tokio::test] From b83dd95c384fefc0aca489f5ffefa74c72db0d9d Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Fri, 4 Oct 2024 15:50:57 +0200 Subject: [PATCH 240/246] chore: update interop test run condition (#5611) ## Description Follow up to https://github.com/libp2p/rust-libp2p/pull/5604. Interop tests only work on the main `rust-libp2p` repo, and not on forks, because of the S3 cache (introduced in https://github.com/libp2p/rust-libp2p/pull/5586). The interop tests currently don't run in the PRs, but they run after the PRs are merged to `master`. This PR is trying to run interop tests in PR that are branches of the main repo (not forks). --- .github/workflows/interop-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/interop-test.yml b/.github/workflows/interop-test.yml index 558adcda66c..57d0f1a692d 100644 --- a/.github/workflows/interop-test.yml +++ b/.github/workflows/interop-test.yml @@ -11,6 +11,7 @@ concurrency: jobs: run-transport-interop: name: Run transport interoperability tests + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository runs-on: ${{ fromJSON(github.repository == 'libp2p/rust-libp2p' && '["self-hosted", "linux", "x64", "4xlarge"]' || '"ubuntu-latest"') }} strategy: matrix: @@ -39,6 +40,7 @@ jobs: worker-count: 16 run-holepunching-interop: name: Run hole-punch interoperability tests + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository runs-on: ${{ fromJSON(github.repository == 'libp2p/rust-libp2p' && '["self-hosted", "linux", "x64", "4xlarge"]' || '"ubuntu-latest"') }} steps: - uses: actions/checkout@v4 From 7669b1696bf62fa82e2a1da959cf537dc98959ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Fri, 4 Oct 2024 15:45:16 +0100 Subject: [PATCH 241/246] deps: update metrics example dependencies (#5617) ## Description and address cargo-deny [RUSTSEC-2024-0376](https://rustsec.org/advisories/RUSTSEC-2024-0376.html) --- Cargo.lock | 196 +++++++++++++---------------------- examples/metrics/Cargo.toml | 8 +- examples/metrics/src/main.rs | 8 +- 3 files changed, 80 insertions(+), 132 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79eb2eb4ad5..38c3436237a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -545,34 +545,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "axum" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" -dependencies = [ - "async-trait", - "axum-core 0.3.4", - "bitflags 1.3.2", - "bytes", - "futures-util", - "http 0.2.9", - "http-body 0.4.5", - "hyper 0.14.27", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "sync_wrapper 0.1.2", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "axum" version = "0.7.5" @@ -580,13 +552,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", - "axum-core 0.4.3", + "axum-core", "bytes", "futures-util", - "http 1.0.0", + "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.1.0", + "hyper 1.4.1", "hyper-util", "itoa", "matchit", @@ -607,23 +579,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "axum-core" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http 0.2.9", - "http-body 0.4.5", - "mime", - "rustversion", - "tower-layer", - "tower-service", -] - [[package]] name = "axum-core" version = "0.4.3" @@ -633,7 +588,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.0.0", + "http 1.1.0", "http-body 1.0.0", "http-body-util", "mime", @@ -779,7 +734,7 @@ name = "browser-webrtc-example" version = "0.1.0" dependencies = [ "anyhow", - "axum 0.7.5", + "axum", "futures", "js-sys", "libp2p", @@ -1940,7 +1895,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http 1.0.0", + "http 1.1.0", "indexmap 2.2.1", "slab", "tokio", @@ -2131,9 +2086,9 @@ dependencies = [ [[package]] name = "http" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -2158,7 +2113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" dependencies = [ "bytes", - "http 1.0.0", + "http 1.1.0", ] [[package]] @@ -2169,7 +2124,7 @@ checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" dependencies = [ "bytes", "futures-util", - "http 1.0.0", + "http 1.1.0", "http-body 1.0.0", "pin-project-lite", ] @@ -2224,20 +2179,21 @@ dependencies = [ [[package]] name = "hyper" -version = "1.1.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", "futures-util", "h2 0.4.4", - "http 1.0.0", + "http 1.1.0", "http-body 1.0.0", "httparse", "httpdate", "itoa", "pin-project-lite", + "smallvec", "tokio", "want", ] @@ -2249,8 +2205,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ "futures-util", - "http 1.0.0", - "hyper 1.1.0", + "http 1.1.0", + "hyper 1.4.1", "hyper-util", "rustls 0.22.4", "rustls-pki-types", @@ -2261,14 +2217,15 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "hyper 0.14.27", + "hyper 1.4.1", + "hyper-util", "pin-project-lite", "tokio", - "tokio-io-timeout", + "tower-service", ] [[package]] @@ -2279,7 +2236,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.1.0", + "hyper 1.4.1", "hyper-util", "native-tls", "tokio", @@ -2289,20 +2246,19 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.3" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.0.0", + "http 1.1.0", "http-body 1.0.0", - "hyper 1.1.0", + "hyper 1.4.1", "pin-project-lite", "socket2 0.5.7", "tokio", - "tower", "tower-service", "tracing", ] @@ -2456,7 +2412,7 @@ name = "interop-tests" version = "0.1.0" dependencies = [ "anyhow", - "axum 0.7.5", + "axum", "console_error_panic_hook", "either", "futures", @@ -3295,7 +3251,7 @@ dependencies = [ name = "libp2p-server" version = "0.12.7" dependencies = [ - "axum 0.7.5", + "axum", "base64 0.22.1", "clap", "futures", @@ -3774,16 +3730,16 @@ dependencies = [ name = "metrics-example" version = "0.1.0" dependencies = [ - "axum 0.7.5", + "axum", "futures", "libp2p", - "opentelemetry 0.23.0", + "opentelemetry 0.25.0", "opentelemetry-otlp", - "opentelemetry_sdk 0.23.0", + "opentelemetry_sdk 0.25.0", "prometheus-client", "tokio", "tracing", - "tracing-opentelemetry 0.24.0", + "tracing-opentelemetry 0.26.0", "tracing-subscriber", ] @@ -4198,9 +4154,9 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b69a91d4893e713e06f724597ad630f1fa76057a5e1026c0ca67054a9032a76" +checksum = "803801d3d3b71cd026851a53f974ea03df3d179cb758b260136a6c9e22e196af" dependencies = [ "futures-core", "futures-sink", @@ -4228,16 +4184,16 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" -version = "0.16.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c69209c05319cdf7460c6d4c055ed102be242a0a6245835d7bc42c6ec7f54" +checksum = "596b1719b3cab83addb20bcbffdf21575279d9436d9ccccfe651a3bf0ab5ab06" dependencies = [ "async-trait", "futures-core", - "http 0.2.9", - "opentelemetry 0.23.0", + "http 1.1.0", + "opentelemetry 0.25.0", "opentelemetry-proto", - "opentelemetry_sdk 0.23.0", + "opentelemetry_sdk 0.25.0", "prost", "thiserror", "tokio", @@ -4246,12 +4202,12 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.6.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "984806e6cf27f2b49282e2a05e288f30594f3dbc74eb7a6e99422bc48ed78162" +checksum = "2c43620e8f93359eb7e627a3b16ee92d8585774986f24f2ab010817426c5ce61" dependencies = [ - "opentelemetry 0.23.0", - "opentelemetry_sdk 0.23.0", + "opentelemetry 0.25.0", + "opentelemetry_sdk 0.25.0", "prost", "tonic", ] @@ -4289,21 +4245,20 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd" +checksum = "e0da0d6b47a3dbc6e9c9e36a0520e25cf943e046843818faaa3f87365a548c82" dependencies = [ "async-trait", "futures-channel", "futures-executor", "futures-util", "glob", - "lazy_static", "once_cell", - "opentelemetry 0.23.0", - "ordered-float 4.2.0", + "opentelemetry 0.25.0", "percent-encoding", "rand 0.8.5", + "serde_json", "thiserror", "tokio", "tokio-stream", @@ -4618,9 +4573,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.3" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" dependencies = [ "bytes", "prost-derive", @@ -4628,9 +4583,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", "itertools", @@ -4978,10 +4933,10 @@ dependencies = [ "futures-core", "futures-util", "h2 0.4.4", - "http 1.0.0", + "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.1.0", + "hyper 1.4.1", "hyper-rustls", "hyper-tls", "hyper-util", @@ -5965,7 +5920,7 @@ dependencies = [ "async-trait", "base64 0.22.1", "futures", - "http 1.0.0", + "http 1.1.0", "indexmap 2.2.1", "parking_lot", "paste", @@ -6120,16 +6075,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.3.0" @@ -6164,9 +6109,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -6223,23 +6168,26 @@ dependencies = [ [[package]] name = "tonic" -version = "0.11.0" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", - "axum 0.6.20", - "base64 0.21.7", + "axum", + "base64 0.22.1", "bytes", - "h2 0.3.26", - "http 0.2.9", - "http-body 0.4.5", - "hyper 0.14.27", + "h2 0.4.4", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.4.1", "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project", "prost", + "socket2 0.5.7", "tokio", "tokio-stream", "tower", @@ -6277,7 +6225,7 @@ dependencies = [ "bitflags 2.4.1", "bytes", "futures-util", - "http 1.0.0", + "http 1.1.0", "http-body 1.0.0", "http-body-util", "http-range-header", @@ -6369,14 +6317,14 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.24.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f68803492bf28ab40aeccaecc7021096bd256baf7ca77c3d425d89b35a7be4e4" +checksum = "5eabc56d23707ad55ba2a0750fc24767125d5a0f51993ba41ad2c441cc7b8dea" dependencies = [ "js-sys", "once_cell", - "opentelemetry 0.23.0", - "opentelemetry_sdk 0.23.0", + "opentelemetry 0.25.0", + "opentelemetry_sdk 0.25.0", "smallvec", "tracing", "tracing-core", diff --git a/examples/metrics/Cargo.toml b/examples/metrics/Cargo.toml index 2b82668f52a..129b1abb1f3 100644 --- a/examples/metrics/Cargo.toml +++ b/examples/metrics/Cargo.toml @@ -12,13 +12,13 @@ release = false futures = { workspace = true } axum = "0.7" libp2p = { path = "../../libp2p", features = ["tokio", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] } -opentelemetry = { version = "0.23.0", features = ["metrics"] } -opentelemetry-otlp = { version = "0.16.0", features = ["metrics"] } -opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio", "metrics"] } +opentelemetry = { version = "0.25.0", features = ["metrics"] } +opentelemetry-otlp = { version = "0.25.0", features = ["metrics"] } +opentelemetry_sdk = { version = "0.25.0", features = ["rt-tokio", "metrics"] } prometheus-client = { workspace = true } tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } -tracing-opentelemetry = "0.24.0" +tracing-opentelemetry = "0.26.0" tracing-subscriber = { workspace = true, features = ["env-filter"] } [lints] diff --git a/examples/metrics/src/main.rs b/examples/metrics/src/main.rs index 99a9ca66aaf..1755c769053 100644 --- a/examples/metrics/src/main.rs +++ b/examples/metrics/src/main.rs @@ -25,7 +25,7 @@ use libp2p::core::Multiaddr; use libp2p::metrics::{Metrics, Recorder}; use libp2p::swarm::{NetworkBehaviour, SwarmEvent}; use libp2p::{identify, identity, noise, ping, tcp, yamux}; -use opentelemetry::KeyValue; +use opentelemetry::{trace::TracerProvider, KeyValue}; use prometheus_client::registry::Registry; use std::error::Error; use std::time::Duration; @@ -90,7 +90,7 @@ async fn main() -> Result<(), Box> { } fn setup_tracing() -> Result<(), Box> { - let tracer = opentelemetry_otlp::new_pipeline() + let provider = opentelemetry_otlp::new_pipeline() .tracing() .with_exporter(opentelemetry_otlp::new_exporter().tonic()) .with_trace_config(opentelemetry_sdk::trace::Config::default().with_resource( @@ -102,10 +102,10 @@ fn setup_tracing() -> Result<(), Box> { .with(tracing_subscriber::fmt::layer().with_filter(EnvFilter::from_default_env())) .with( tracing_opentelemetry::layer() - .with_tracer(tracer) + .with_tracer(provider.tracer("libp2p-subscriber")) .with_filter(EnvFilter::from_default_env()), ) - .try_init()?; + .init(); Ok(()) } From fcff3f80401895362060f8e448ec992b6db7fb9b Mon Sep 17 00:00:00 2001 From: P1R0 Date: Fri, 4 Oct 2024 16:40:47 -0600 Subject: [PATCH 242/246] refactor(examples): use tokio instead of async-std in relay-server (#5600) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Following on issue #4449 refactor: use tokio instead of async-std in the relay-servert example and remove unnecessary dependencies ## Notes & open questions Fails on testing with the [whole punch tutorial](https://docs.rs/libp2p/0.54.1/libp2p/tutorials/hole_punching/index.html) possibly because of my networking topology. connection established event registered. I will publish the logs and testing information as a comment ## Change checklist * Removed unnecessary dependencies on examples/relay-server/Cargo.toml * Updated tokio version to "1.37.0" - [ ] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] A changelog entry has been made in the appropriate crates --------- Co-authored-by: David E. Perez Negron R. Co-authored-by: Guillaume Michel Co-authored-by: João Oliveira --- Cargo.lock | 3 +-- examples/relay-server/Cargo.toml | 5 ++-- examples/relay-server/src/main.rs | 42 +++++++++++++++---------------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 38c3436237a..91767968898 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4901,11 +4901,10 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" name = "relay-server-example" version = "0.1.0" dependencies = [ - "async-std", - "async-trait", "clap", "futures", "libp2p", + "tokio", "tracing", "tracing-subscriber", ] diff --git a/examples/relay-server/Cargo.toml b/examples/relay-server/Cargo.toml index 12d3e2467ce..7385cf6c033 100644 --- a/examples/relay-server/Cargo.toml +++ b/examples/relay-server/Cargo.toml @@ -10,10 +10,9 @@ release = false [dependencies] clap = { version = "4.5.6", features = ["derive"] } -async-std = { version = "1.12", features = ["attributes"] } -async-trait = "0.1" +tokio = { version = "1.37.0", features = ["full"] } futures = { workspace = true } -libp2p = { path = "../../libp2p", features = [ "async-std", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay", "quic"] } +libp2p = { path = "../../libp2p", features = ["tokio", "noise", "macros", "ping", "tcp", "identify", "yamux", "relay", "quic"] } tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } diff --git a/examples/relay-server/src/main.rs b/examples/relay-server/src/main.rs index bf5817454f8..46a122d0717 100644 --- a/examples/relay-server/src/main.rs +++ b/examples/relay-server/src/main.rs @@ -22,8 +22,7 @@ #![doc = include_str!("../README.md")] use clap::Parser; -use futures::executor::block_on; -use futures::stream::StreamExt; +use futures::StreamExt; use libp2p::{ core::multiaddr::Protocol, core::Multiaddr, @@ -35,7 +34,8 @@ use std::error::Error; use std::net::{Ipv4Addr, Ipv6Addr}; use tracing_subscriber::EnvFilter; -fn main() -> Result<(), Box> { +#[tokio::main] +async fn main() -> Result<(), Box> { let _ = tracing_subscriber::fmt() .with_env_filter(EnvFilter::from_default_env()) .try_init(); @@ -46,7 +46,7 @@ fn main() -> Result<(), Box> { let local_key: identity::Keypair = generate_ed25519(opt.secret_key_seed); let mut swarm = libp2p::SwarmBuilder::with_existing_identity(local_key) - .with_async_std() + .with_tokio() .with_tcp( tcp::Config::default(), noise::Config::new, @@ -81,27 +81,25 @@ fn main() -> Result<(), Box> { .with(Protocol::QuicV1); swarm.listen_on(listen_addr_quic)?; - block_on(async { - loop { - match swarm.next().await.expect("Infinite Stream.") { - SwarmEvent::Behaviour(event) => { - if let BehaviourEvent::Identify(identify::Event::Received { - info: identify::Info { observed_addr, .. }, - .. - }) = &event - { - swarm.add_external_address(observed_addr.clone()); - } - - println!("{event:?}") + loop { + match swarm.next().await.expect("Infinite Stream.") { + SwarmEvent::Behaviour(event) => { + if let BehaviourEvent::Identify(identify::Event::Received { + info: identify::Info { observed_addr, .. }, + .. + }) = &event + { + swarm.add_external_address(observed_addr.clone()); } - SwarmEvent::NewListenAddr { address, .. } => { - println!("Listening on {address:?}"); - } - _ => {} + + println!("{event:?}") + } + SwarmEvent::NewListenAddr { address, .. } => { + println!("Listening on {address:?}"); } + _ => {} } - }) + } } #[derive(NetworkBehaviour)] From 93ad28c4cce236b1657241ba623ea30077565afd Mon Sep 17 00:00:00 2001 From: Guillaume Michel Date: Sat, 5 Oct 2024 01:07:49 +0200 Subject: [PATCH 243/246] fix(server): removing dependency on libp2p-lookup (#5610) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Remove dependency on [`libp2p-lookup`](https://github.com/mxinden/libp2p-lookup) which is no longer maintained, and [makes checks fail](https://github.com/libp2p/rust-libp2p/actions/runs/11016492372/job/30628121728). ## Change checklist - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates --------- Co-authored-by: João Oliveira --- Cargo.lock | 2 +- Cargo.toml | 8 ++++++-- misc/server/CHANGELOG.md | 30 ++++++++++++++++++++++++++++++ misc/server/Cargo.toml | 20 ++++++++++++++++++-- misc/server/Dockerfile | 2 -- misc/server/README.md | 7 ------- 6 files changed, 55 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91767968898..28107c00ee9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3249,7 +3249,7 @@ dependencies = [ [[package]] name = "libp2p-server" -version = "0.12.7" +version = "0.12.8" dependencies = [ "axum", "base64 0.22.1", diff --git a/Cargo.toml b/Cargo.toml index 32f72c5e252..cc677013fa9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,7 +100,7 @@ libp2p-quic = { version = "0.11.1", path = "transports/quic" } libp2p-relay = { version = "0.18.0", path = "protocols/relay" } libp2p-rendezvous = { version = "0.15.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.27.0", path = "protocols/request-response" } -libp2p-server = { version = "0.12.7", path = "misc/server" } +libp2p-server = { version = "0.12.8", path = "misc/server" } libp2p-stream = { version = "0.2.0-alpha", path = "protocols/stream" } libp2p-swarm = { version = "0.45.2", path = "swarm" } libp2p-swarm-derive = { version = "=0.35.0", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. @@ -151,4 +151,8 @@ clippy.manual_let_else = "warn" clippy.dbg_macro = "warn" [workspace.metadata.release] -pre-release-hook = ["/bin/sh", '-c', '/bin/sh $WORKSPACE_ROOT/scripts/add-changelog-header.sh'] # Nested use of shell to expand variables. +pre-release-hook = [ + "/bin/sh", + '-c', + '/bin/sh $WORKSPACE_ROOT/scripts/add-changelog-header.sh', +] # Nested use of shell to expand variables. diff --git a/misc/server/CHANGELOG.md b/misc/server/CHANGELOG.md index 5369163460c..fe48de0f553 100644 --- a/misc/server/CHANGELOG.md +++ b/misc/server/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.12.8 + +### Changed + +- Remove deprecated [`libp2p-lookup`](https://github.com/mxinden/libp2p-lookup) from Dockerfile. + See [PR 5610](https://github.com/libp2p/rust-libp2p/pull/5610). + ## 0.12.7 ### Changed @@ -31,6 +38,7 @@ ## 0.12.3 ### Changed + - Add libp2p-lookup to Dockerfile to enable healthchecks. ### Fixed @@ -42,14 +50,18 @@ [PR 4467]: https://github.com/libp2p/rust-libp2p/pull/4467 ## 0.12.2 + ### Fixed + - Adhere to `--metrics-path` flag and listen on `0.0.0.0:8888` (default IPFS metrics port). [PR 4392] [PR 4392]: https://github.com/libp2p/rust-libp2p/pull/4392 ## 0.12.1 + ### Changed + - Move to tokio and hyper. See [PR 4311]. - Move to distroless Docker base image. @@ -58,39 +70,57 @@ [PR 4311]: https://github.com/libp2p/rust-libp2p/pull/4311 ## 0.8.0 + ### Changed + - Remove mplex support. ## 0.7.0 + ### Changed + - Update to libp2p v0.47.0. ## 0.6.0 - 2022-05-05 + ### Changed + - Update to libp2p v0.44.0. ## 0.5.4 - 2022-01-11 + ### Changed + - Pull latest autonat changes. ## 0.5.3 - 2021-12-25 + ### Changed + - Update dependencies. - Pull in autonat fixes. ## 0.5.2 - 2021-12-20 + ### Added + - Add support for libp2p autonat protocol via `--enable-autonat`. ## 0.5.1 - 2021-12-20 + ### Fixed + - Update dependencies. - Fix typo in command line flag `--enable-kademlia`. ## 0.5.0 - 2021-11-18 + ### Changed + - Disable Kademlia protocol by default. ## 0.4.0 - 2021-11-18 + ### Fixed + - Update dependencies. diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 798ecfa07a9..0954e2f38d8 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-server" -version = "0.12.7" +version = "0.12.8" authors = ["Max Inden "] edition = "2021" repository = "https://github.com/libp2p/rust-libp2p" @@ -16,7 +16,23 @@ clap = { version = "4.5.6", features = ["derive"] } futures = { workspace = true } futures-timer = "3" axum = "0.7" -libp2p = { workspace = true, features = ["autonat", "dns", "tokio", "noise", "tcp", "yamux", "identify", "kad", "ping", "relay", "metrics", "rsa", "macros", "quic", "websocket"] } +libp2p = { workspace = true, features = [ + "autonat", + "dns", + "tokio", + "noise", + "tcp", + "yamux", + "identify", + "kad", + "ping", + "relay", + "metrics", + "rsa", + "macros", + "quic", + "websocket", +] } prometheus-client = { workspace = true } serde = "1.0.203" serde_derive = "1.0.125" diff --git a/misc/server/Dockerfile b/misc/server/Dockerfile index 24ae2b9fd99..12a8982eb3f 100644 --- a/misc/server/Dockerfile +++ b/misc/server/Dockerfile @@ -1,7 +1,6 @@ # syntax=docker/dockerfile:1.5-labs FROM rust:1.81.0 as chef RUN wget -q -O- https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.62/cargo-chef-x86_64-unknown-linux-gnu.tar.gz | tar -zx -C /usr/local/bin -RUN cargo install --locked --root /usr/local libp2p-lookup --version 0.6.4 WORKDIR /app FROM chef AS planner @@ -17,5 +16,4 @@ COPY . . RUN cargo build --release --package libp2p-server FROM gcr.io/distroless/cc -COPY --from=builder /usr/local/bin/libp2p-server /usr/local/bin/libp2p-lookup /usr/local/bin/ CMD ["libp2p-server"] diff --git a/misc/server/README.md b/misc/server/README.md index 0da1bd8abd9..f9a5d65124a 100644 --- a/misc/server/README.md +++ b/misc/server/README.md @@ -25,7 +25,6 @@ Options: -h, --help Print help ``` - ``` cargo run -- --config ~/.ipfs/config @@ -33,9 +32,3 @@ Local peer id: PeerId("12D3KooWSa1YEeQVSwvoqAMhwjKQ6kqZQckhWPb3RWEGV3sZGU6Z") Listening on "/ip4/127.0.0.1/udp/4001/quic" [...] ``` - -The Docker container includes [libp2-lookup](https://github.com/mxinden/libp2p-lookup/) to enable adding a proper healthcheck for container startup, e.g. - -``` shell -docker run --health-cmd 'libp2p-lookup direct --address /ip4/127.0.0.1/tcp/4001/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa' /home/ipfs/.ipfs:/ipfs ghcr.io/libp2p/rust-libp2p-server --config /ipfs/config -``` From 9a45db3f82b760c93099e66ec77a7a772d1f6cd3 Mon Sep 17 00:00:00 2001 From: Darius Clark Date: Tue, 8 Oct 2024 10:16:59 -0400 Subject: [PATCH 244/246] chore: update igd-next to 0.15.1 (#5625) ## Description Resolves #5506. ## Notes & open questions ## Change checklist - [ ] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates --- Cargo.lock | 102 +++++++++--------------------------- Cargo.toml | 2 +- protocols/upnp/CHANGELOG.md | 4 ++ protocols/upnp/Cargo.toml | 4 +- 4 files changed, 32 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28107c00ee9..3d77ed104dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -556,9 +556,9 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body", "http-body-util", - "hyper 1.4.1", + "hyper", "hyper-util", "itoa", "matchit", @@ -589,7 +589,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body", "http-body-util", "mime", "pin-project-lite", @@ -1865,25 +1865,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.9", - "indexmap 2.2.1", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "h2" version = "0.4.4" @@ -2095,17 +2076,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes", - "http 0.2.9", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.0" @@ -2125,7 +2095,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body", "pin-project-lite", ] @@ -2153,30 +2123,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "hyper" -version = "0.14.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.9", - "http-body 0.4.5", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2 0.4.9", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "hyper" version = "1.4.1" @@ -2186,9 +2132,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.4", + "h2", "http 1.1.0", - "http-body 1.0.0", + "http-body", "httparse", "httpdate", "itoa", @@ -2206,7 +2152,7 @@ checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.4.1", + "hyper", "hyper-util", "rustls 0.22.4", "rustls-pki-types", @@ -2221,7 +2167,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "hyper 1.4.1", + "hyper", "hyper-util", "pin-project-lite", "tokio", @@ -2236,7 +2182,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.4.1", + "hyper", "hyper-util", "native-tls", "tokio", @@ -2254,8 +2200,8 @@ dependencies = [ "futures-channel", "futures-util", "http 1.1.0", - "http-body 1.0.0", - "hyper 1.4.1", + "http-body", + "hyper", "pin-project-lite", "socket2 0.5.7", "tokio", @@ -2326,16 +2272,18 @@ dependencies = [ [[package]] name = "igd-next" -version = "0.14.3" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "064d90fec10d541084e7b39ead8875a5a80d9114a2b18791565253bae25f49e4" +checksum = "76b0d7d4541def58a37bf8efc559683f21edce7c82f0d866c93ac21f7e098f93" dependencies = [ "async-trait", "attohttpc", "bytes", "futures", - "http 0.2.9", - "hyper 0.14.27", + "http 1.1.0", + "http-body-util", + "hyper", + "hyper-util", "log", "rand 0.8.5", "tokio", @@ -3399,7 +3347,7 @@ dependencies = [ [[package]] name = "libp2p-upnp" -version = "0.3.0" +version = "0.3.1" dependencies = [ "futures", "futures-timer", @@ -4931,11 +4879,11 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.4.4", + "h2", "http 1.1.0", - "http-body 1.0.0", + "http-body", "http-body-util", - "hyper 1.4.1", + "hyper", "hyper-rustls", "hyper-tls", "hyper-util", @@ -6176,11 +6124,11 @@ dependencies = [ "axum", "base64 0.22.1", "bytes", - "h2 0.4.4", + "h2", "http 1.1.0", - "http-body 1.0.0", + "http-body", "http-body-util", - "hyper 1.4.1", + "hyper", "hyper-timeout", "hyper-util", "percent-encoding", @@ -6225,7 +6173,7 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.0", + "http-body", "http-body-util", "http-range-header", "httpdate", diff --git a/Cargo.toml b/Cargo.toml index cc677013fa9..9e18af5f706 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -108,7 +108,7 @@ libp2p-swarm-test = { version = "0.4.0", path = "swarm-test" } libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } libp2p-tls = { version = "0.5.0", path = "transports/tls" } libp2p-uds = { version = "0.41.0", path = "transports/uds" } -libp2p-upnp = { version = "0.3.0", path = "protocols/upnp" } +libp2p-upnp = { version = "0.3.1", path = "protocols/upnp" } libp2p-webrtc = { version = "0.8.0-alpha", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.3.0", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.4.0-alpha.2", path = "transports/webrtc-websys" } diff --git a/protocols/upnp/CHANGELOG.md b/protocols/upnp/CHANGELOG.md index 21e90f9534b..d9c24f8efcc 100644 --- a/protocols/upnp/CHANGELOG.md +++ b/protocols/upnp/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.1 +- update igd-next to 0.15.1. + See [PR XXXX](https://github.com/libp2p/rust-libp2p/pull/XXXX). + ## 0.3.0 diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index e9c7414236d..209733f53e6 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-upnp" edition = "2021" rust-version = "1.60.0" description = "UPnP support for libp2p transports" -version = "0.3.0" +version = "0.3.1" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] @@ -13,7 +13,7 @@ publish = true [dependencies] futures = { workspace = true } futures-timer = "3.0.3" -igd-next = "0.14.3" +igd-next = "0.15.1" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } tokio = { workspace = true, default-features = false, features = ["rt"], optional = true } From d3228adf64cf68f419eeb0b18a5c0b762d29abbe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 09:00:56 +0000 Subject: [PATCH 245/246] deps: bump Swatinem/rust-cache from 2.7.3 to 2.7.5 (#5633) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.7.3 to 2.7.5.

Release notes

Sourced from Swatinem/rust-cache's releases.

v2.7.5

What's Changed

New Contributors

Full Changelog: https://github.com/Swatinem/rust-cache/compare/v2.7.3...v2.7.5

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Swatinem/rust-cache&package-manager=github_actions&previous-version=2.7.3&new-version=2.7.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/cache-factory.yml | 2 +- .github/workflows/ci.yml | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cache-factory.yml b/.github/workflows/cache-factory.yml index 8c49b335f1b..7623b56f450 100644 --- a/.github/workflows/cache-factory.yml +++ b/.github/workflows/cache-factory.yml @@ -22,7 +22,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 with: shared-key: stable-cache diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c1dfc8aaef..daee569d047 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 with: shared-key: stable-cache save-if: false @@ -149,7 +149,7 @@ jobs: - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 with: key: ${{ matrix.target }} save-if: ${{ github.ref == 'refs/heads/master' }} @@ -174,7 +174,7 @@ jobs: - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 with: save-if: ${{ github.ref == 'refs/heads/master' }} @@ -195,7 +195,7 @@ jobs: - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 with: key: ${{ matrix.features }} save-if: ${{ github.ref == 'refs/heads/master' }} @@ -212,7 +212,7 @@ jobs: - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 with: save-if: ${{ github.ref == 'refs/heads/master' }} @@ -238,7 +238,7 @@ jobs: - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 with: save-if: ${{ github.ref == 'refs/heads/master' }} @@ -254,7 +254,7 @@ jobs: - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 with: save-if: ${{ github.ref == 'refs/heads/master' }} @@ -273,7 +273,7 @@ jobs: - uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0 - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 with: shared-key: stable-cache save-if: false @@ -365,7 +365,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 - run: cargo install --version 0.10.0 pb-rs --locked @@ -391,7 +391,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + - uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5 - run: cargo metadata --locked --format-version=1 > /dev/null cargo-deny: From 812a7cdf5d229610bb8eda1f106eee5ac3f699d2 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Wed, 16 Oct 2024 01:32:02 +0800 Subject: [PATCH 246/246] feat: make runtime features optional in swarm-test (#5551) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Sometimes a test uses custom swarm building logic and doesn't need `fn new_ephemeral`, and sometimes a test uses `tokio` runtime other than `async-std`. This PR adds the `tokio` runtime support and makes both `async-std` and `tokio` runtimes optional behind features to make it more flexible. ## Notes & open questions ## Change checklist - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [x] A changelog entry has been made in the appropriate crates --------- Co-authored-by: João Oliveira --- Cargo.lock | 2 +- Cargo.toml | 2 +- swarm-test/CHANGELOG.md | 7 +++++ swarm-test/Cargo.toml | 12 +++++-- swarm-test/src/lib.rs | 69 ++++++++++++++++++++++++++++++++--------- 5 files changed, 72 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d77ed104dc..40ff97009de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3278,7 +3278,7 @@ dependencies = [ [[package]] name = "libp2p-swarm-test" -version = "0.4.0" +version = "0.4.1" dependencies = [ "async-trait", "futures", diff --git a/Cargo.toml b/Cargo.toml index 9e18af5f706..7b52e4a7b42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,7 +104,7 @@ libp2p-server = { version = "0.12.8", path = "misc/server" } libp2p-stream = { version = "0.2.0-alpha", path = "protocols/stream" } libp2p-swarm = { version = "0.45.2", path = "swarm" } libp2p-swarm-derive = { version = "=0.35.0", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. -libp2p-swarm-test = { version = "0.4.0", path = "swarm-test" } +libp2p-swarm-test = { version = "0.4.1", path = "swarm-test" } libp2p-tcp = { version = "0.42.0", path = "transports/tcp" } libp2p-tls = { version = "0.5.0", path = "transports/tls" } libp2p-uds = { version = "0.41.0", path = "transports/uds" } diff --git a/swarm-test/CHANGELOG.md b/swarm-test/CHANGELOG.md index 98027fcbea2..33eebb2412c 100644 --- a/swarm-test/CHANGELOG.md +++ b/swarm-test/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.4.1 + +- Add `tokio` runtime support and make `tokio` and `async-std` runtimes optional behind features. + See [PR 5551]. + +[PR 5551]: https://github.com/libp2p/rust-libp2p/pull/5551 + ## 0.4.0 diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index b285da34f87..fa51454dd58 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-swarm-test" -version = "0.4.0" +version = "0.4.1" edition = "2021" rust-version = { workspace = true } license = "MIT" @@ -16,13 +16,19 @@ async-trait = "0.1.80" libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-plaintext = { workspace = true } -libp2p-swarm = { workspace = true, features = ["async-std"] } -libp2p-tcp = { workspace = true, features = ["async-io"] } +libp2p-swarm = { workspace = true } +libp2p-tcp = { workspace = true } libp2p-yamux = { workspace = true } futures = { workspace = true } rand = "0.8.5" tracing = { workspace = true } futures-timer = "3.0.3" +[features] +default = ["async-std"] + +async-std = ["libp2p-swarm/async-std", "libp2p-tcp/async-io"] +tokio = ["libp2p-swarm/tokio", "libp2p-tcp/tokio"] + [lints] workspace = true diff --git a/swarm-test/src/lib.rs b/swarm-test/src/lib.rs index 48f5bcbf4ef..bcab6e5b700 100644 --- a/swarm-test/src/lib.rs +++ b/swarm-test/src/lib.rs @@ -21,14 +21,10 @@ use async_trait::async_trait; use futures::future::{BoxFuture, Either}; use futures::{FutureExt, StreamExt}; -use libp2p_core::{ - multiaddr::Protocol, transport::MemoryTransport, upgrade::Version, Multiaddr, Transport, -}; -use libp2p_identity::{Keypair, PeerId}; -use libp2p_plaintext as plaintext; +use libp2p_core::{multiaddr::Protocol, Multiaddr}; +use libp2p_identity::PeerId; use libp2p_swarm::dial_opts::PeerCondition; -use libp2p_swarm::{self as swarm, dial_opts::DialOpts, NetworkBehaviour, Swarm, SwarmEvent}; -use libp2p_yamux as yamux; +use libp2p_swarm::{dial_opts::DialOpts, NetworkBehaviour, Swarm, SwarmEvent}; use std::fmt::Debug; use std::future::IntoFuture; use std::time::Duration; @@ -38,12 +34,23 @@ use std::time::Duration; pub trait SwarmExt { type NB: NetworkBehaviour; - /// Create a new [`Swarm`] with an ephemeral identity. + /// Create a new [`Swarm`] with an ephemeral identity and the `async-std` runtime. /// - /// The swarm will use a [`MemoryTransport`] together with a [`plaintext::Config`] authentication layer and - /// [`yamux::Config`] as the multiplexer. However, these details should not be relied upon by the test + /// The swarm will use a [`libp2p_core::transport::MemoryTransport`] together with a [`libp2p_plaintext::Config`] authentication layer and + /// [`libp2p_yamux::Config`] as the multiplexer. However, these details should not be relied upon by the test /// and may change at any time. - fn new_ephemeral(behaviour_fn: impl FnOnce(Keypair) -> Self::NB) -> Self + #[cfg(feature = "async-std")] + fn new_ephemeral(behaviour_fn: impl FnOnce(libp2p_identity::Keypair) -> Self::NB) -> Self + where + Self: Sized; + + /// Create a new [`Swarm`] with an ephemeral identity and the `tokio` runtime. + /// + /// The swarm will use a [`libp2p_core::transport::MemoryTransport`] together with a [`libp2p_plaintext::Config`] authentication layer and + /// [`libp2p_yamux::Config`] as the multiplexer. However, these details should not be relied upon by the test + /// and may change at any time. + #[cfg(feature = "tokio")] + fn new_ephemeral_tokio(behaviour_fn: impl FnOnce(libp2p_identity::Keypair) -> Self::NB) -> Self where Self: Sized; @@ -200,18 +207,50 @@ where { type NB = B; - fn new_ephemeral(behaviour_fn: impl FnOnce(Keypair) -> Self::NB) -> Self + #[cfg(feature = "async-std")] + fn new_ephemeral(behaviour_fn: impl FnOnce(libp2p_identity::Keypair) -> Self::NB) -> Self where Self: Sized, { + use libp2p_core::{transport::MemoryTransport, upgrade::Version, Transport as _}; + use libp2p_identity::Keypair; + let identity = Keypair::generate_ed25519(); let peer_id = PeerId::from(identity.public()); let transport = MemoryTransport::default() .or_transport(libp2p_tcp::async_io::Transport::default()) .upgrade(Version::V1) - .authenticate(plaintext::Config::new(&identity)) - .multiplex(yamux::Config::default()) + .authenticate(libp2p_plaintext::Config::new(&identity)) + .multiplex(libp2p_yamux::Config::default()) + .timeout(Duration::from_secs(20)) + .boxed(); + + Swarm::new( + transport, + behaviour_fn(identity), + peer_id, + libp2p_swarm::Config::with_async_std_executor() + .with_idle_connection_timeout(Duration::from_secs(5)), // Some tests need connections to be kept alive beyond what the individual behaviour configures., + ) + } + + #[cfg(feature = "tokio")] + fn new_ephemeral_tokio(behaviour_fn: impl FnOnce(libp2p_identity::Keypair) -> Self::NB) -> Self + where + Self: Sized, + { + use libp2p_core::{transport::MemoryTransport, upgrade::Version, Transport as _}; + use libp2p_identity::Keypair; + + let identity = Keypair::generate_ed25519(); + let peer_id = PeerId::from(identity.public()); + + let transport = MemoryTransport::default() + .or_transport(libp2p_tcp::tokio::Transport::default()) + .upgrade(Version::V1) + .authenticate(libp2p_plaintext::Config::new(&identity)) + .multiplex(libp2p_yamux::Config::default()) .timeout(Duration::from_secs(20)) .boxed(); @@ -219,7 +258,7 @@ where transport, behaviour_fn(identity), peer_id, - swarm::Config::with_async_std_executor() + libp2p_swarm::Config::with_tokio_executor() .with_idle_connection_timeout(Duration::from_secs(5)), // Some tests need connections to be kept alive beyond what the individual behaviour configures., ) }