From a6566e600a7569a60ed856363b0d553659b4a73a Mon Sep 17 00:00:00 2001 From: leonzchang Date: Tue, 17 Oct 2023 17:25:51 +0800 Subject: [PATCH 1/7] remove KeepAlive::Until and set_connection_keep_alive --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- protocols/perf/CHANGELOG.md | 7 +++++++ protocols/perf/Cargo.toml | 2 +- protocols/perf/src/client.rs | 1 - protocols/perf/src/server.rs | 1 - protocols/request-response/CHANGELOG.md | 7 +++++++ protocols/request-response/Cargo.toml | 2 +- protocols/request-response/src/handler.rs | 16 ++++------------ protocols/request-response/src/lib.rs | 10 ---------- 10 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c540816dade..7352bd6c60e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2817,7 +2817,7 @@ dependencies = [ [[package]] name = "libp2p-perf" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow", "async-trait", @@ -2992,7 +2992,7 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.25.2" +version = "0.26.0" dependencies = [ "async-std", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 8d57d1dd9e9..6442d4f7caf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,7 +91,7 @@ libp2p-metrics = { version = "0.13.1", path = "misc/metrics" } libp2p-mplex = { version = "0.40.0", path = "muxers/mplex" } libp2p-muxer-test-harness = { path = "muxers/test-harness" } libp2p-noise = { version = "0.43.2", path = "transports/noise" } -libp2p-perf = { version = "0.2.0", path = "protocols/perf" } +libp2p-perf = { version = "0.2.1", path = "protocols/perf" } libp2p-ping = { version = "0.43.1", path = "protocols/ping" } libp2p-plaintext = { version = "0.40.1", path = "transports/plaintext" } libp2p-pnet = { version = "0.23.1", path = "transports/pnet" } @@ -99,7 +99,7 @@ libp2p-quic = { version = "0.9.3", path = "transports/quic" } libp2p-relay = { version = "0.16.2", path = "protocols/relay" } libp2p-rendezvous = { version = "0.13.1", path = "protocols/rendezvous" } libp2p-upnp = { version = "0.1.1", path = "protocols/upnp" } -libp2p-request-response = { version = "0.25.2", path = "protocols/request-response" } +libp2p-request-response = { version = "0.26.0", path = "protocols/request-response" } libp2p-server = { version = "0.12.3", path = "misc/server" } libp2p-swarm = { version = "0.43.6", path = "swarm" } libp2p-swarm-derive = { version = "0.33.0", path = "swarm-derive" } diff --git a/protocols/perf/CHANGELOG.md b/protocols/perf/CHANGELOG.md index e46a94e981a..4a1f7bbf7b0 100644 --- a/protocols/perf/CHANGELOG.md +++ b/protocols/perf/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.2.1 - unreleased + + ## 0.2.0 - Raise MSRV to 1.65. diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index c61deb37c29..5e9ecad5202 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.2.0" +version = "0.2.1" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/perf/src/client.rs b/protocols/perf/src/client.rs index 93c2086a49e..6ef671a429a 100644 --- a/protocols/perf/src/client.rs +++ b/protocols/perf/src/client.rs @@ -59,7 +59,6 @@ pub struct Behaviour { impl Default for Behaviour { fn default() -> Self { let mut req_resp_config = request_response::Config::default(); - req_resp_config.set_connection_keep_alive(Duration::from_secs(60 * 5)); req_resp_config.set_request_timeout(Duration::from_secs(60 * 5)); Self { connected: Default::default(), diff --git a/protocols/perf/src/server.rs b/protocols/perf/src/server.rs index 79f77c74650..ea361755ec3 100644 --- a/protocols/perf/src/server.rs +++ b/protocols/perf/src/server.rs @@ -38,7 +38,6 @@ pub struct Behaviour { impl Default for Behaviour { fn default() -> Self { let mut req_resp_config = request_response::Config::default(); - req_resp_config.set_connection_keep_alive(Duration::from_secs(60 * 5)); req_resp_config.set_request_timeout(Duration::from_secs(60 * 5)); Self { diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index 485fa911396..af0c44b0a65 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.26.0 - unreleased +- Remove usage of `KeepAlive::Until` and `request_response::Config::set_connection_keep_alive` + in favor of `SwarmBuilder::idle_connection_timeout`. + See [PR xxxx]. + +[PR xxxx]: https://github.com/libp2p/rust-libp2p/pull/xxxx + ## 0.25.2 - unreleased - ## 0.2.0 - Raise MSRV to 1.65. diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index 75e2dea74c0..3a40b0de25d 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.2.1" +version = "0.2.0" authors = ["Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" From a98b4ac74d95a594d42600391f1a2930723da457 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 20 Oct 2023 12:34:27 +1100 Subject: [PATCH 4/7] Update protocols/request-response/CHANGELOG.md --- protocols/request-response/CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index 651ae3dcce1..872d1320e7e 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,9 +1,7 @@ ## 0.26.0 - unreleased -- Remove usage of `KeepAlive::Until` and `request_response::Config::set_connection_keep_alive` in favor of `SwarmBuilder::idle_connection_timeout`. - See [PR 4679]. - -[PR 4679]: https://github.com/libp2p/rust-libp2p/pull/4679 +- Remove `request_response::Config::set_connection_keep_alive` in favor of `SwarmBuilder::idle_connection_timeout`. + See [PR 4679](https://github.com/libp2p/rust-libp2p/pull/4679). ## 0.25.2 From 52c97477b72b9ea62d22fbdf3e6fd5157538837c Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 20 Oct 2023 12:35:14 +1100 Subject: [PATCH 5/7] Apply suggestions from code review --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc2356e2c76..112df8b4219 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2817,7 +2817,7 @@ dependencies = [ [[package]] name = "libp2p-perf" -version = "0.2.1" +version = "0.2.0" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 53ff2a44247..f07bba03da8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,7 +91,7 @@ libp2p-metrics = { version = "0.14.0", 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.2.1", path = "protocols/perf" } +libp2p-perf = { version = "0.2.0", path = "protocols/perf" } 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" } From a335cdef97ad3e03221a7efe9d285fa21d5d4d1f Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 20 Oct 2023 12:44:33 +1100 Subject: [PATCH 6/7] Fix compile error --- protocols/request-response/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/protocols/request-response/src/lib.rs b/protocols/request-response/src/lib.rs index b37b6e49c62..9520a0b686d 100644 --- a/protocols/request-response/src/lib.rs +++ b/protocols/request-response/src/lib.rs @@ -748,7 +748,6 @@ where self.inbound_protocols.clone(), self.codec.clone(), self.config.request_timeout, - self.config.connection_keep_alive, self.next_inbound_id.clone(), ); From 5006e3d988ed01f8b3ce434d104d18dcfd30be33 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 20 Oct 2023 15:35:15 +1100 Subject: [PATCH 7/7] Shorten times to be within idle connection timeout --- protocols/rendezvous/tests/rendezvous.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/rendezvous/tests/rendezvous.rs b/protocols/rendezvous/tests/rendezvous.rs index 64cd294eefa..67b4bc6ad57 100644 --- a/protocols/rendezvous/tests/rendezvous.rs +++ b/protocols/rendezvous/tests/rendezvous.rs @@ -370,7 +370,7 @@ async fn registration_on_clients_expire() { let roberts_peer_id = *robert.local_peer_id(); tokio::spawn(robert.loop_on_next()); - let registration_ttl = 3; + let registration_ttl = 1; alice .behaviour_mut() @@ -389,7 +389,7 @@ async fn registration_on_clients_expire() { event => panic!("Unexpected event: {event:?}"), } - tokio::time::sleep(Duration::from_secs(registration_ttl + 5)).await; + tokio::time::sleep(Duration::from_secs(registration_ttl + 1)).await; let event = bob.select_next_some().await; let error = bob.dial(*alice.local_peer_id()).unwrap_err();