Skip to content

Commit

Permalink
Merge branch 'master' into 4075-relay
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarus authored Aug 1, 2023
2 parents 1b39aaf + c86b665 commit aa09aa3
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/actions/cargo-semver-checks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
runs:
using: "composite"
steps:
- run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.20.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.22.1/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin
shell: bash

- name: Get released version
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ jobs:
echo "code=${RESPONSE_CODE}" >> $GITHUB_OUTPUT
- uses: ./.github/actions/cargo-semver-checks
if: steps.check-released.outputs.code == 200 # Workaround until https://github.com/obi1kenobi/cargo-semver-check/issues/146 is shipped.
if: steps.check-released.outputs.code == 200 && !contains(fromJSON('["libp2p-swarm-derive"]'), env.CRATE) # Workaround until https://github.com/obi1kenobi/cargo-semver-check/issues/146 is shipped.
with:
crate: env.CRATE
crate: ${{ env.CRATE }}

- name: Enforce no dependency on meta crate
run: |
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ libp2p-floodsub = { version = "0.43.0", path = "protocols/floodsub" }
libp2p-gossipsub = { version = "0.45.0", path = "protocols/gossipsub" }
libp2p-identify = { version = "0.43.0", path = "protocols/identify" }
libp2p-identity = { version = "0.2.2" }
libp2p-kad = { version = "0.44.3", path = "protocols/kad" }
libp2p-kad = { version = "0.44.4", path = "protocols/kad" }
libp2p-mdns = { version = "0.44.0", path = "protocols/mdns" }
libp2p-metrics = { version = "0.13.1", path = "misc/metrics" }
libp2p-mplex = { version = "0.40.0", path = "muxers/mplex" }
Expand Down
16 changes: 8 additions & 8 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ This is a living document. Input is always welcome e.g. via GitHub issues or pul
This is the roadmap of the Rust implementation of libp2p. See also the [general libp2p project
roadmap](https://github.com/libp2p/specs/blob/master/ROADMAP.md).

## QUIC - evaluate and move to quinn

| Category | Status | Target Completion | Tracking | Dependencies | Dependents |
|--------------|--------|-------------------|---------------------------------------------------|--------------|------------|
| Connectivity | todo | Q3/2023 | https://github.com/libp2p/rust-libp2p/issues/2883 | | |

We added alpha support for QUIC in Q4/2022 wrapping `quinn-proto`. Evaluate using `quinn` directly, replacing the wrapper.

## Attempt to switch from webrtc-rs to str0m

| Category | Status | Target Completion | Tracking | Dependencies | Dependents |
Expand Down Expand Up @@ -180,3 +172,11 @@ QUIC](https://github.com/libp2p/specs/blob/master/relay/DCUtR.md#the-protocol).

Kademlia client mode will enhance routing table health and thus have a positive impact on all
Kademlia operations.

## QUIC - evaluate and move to quinn

| Category | Status | Target Completion | Tracking | Dependencies | Dependents |
|--------------|--------|-------------------|---------------------------------------------------|--------------|------------|
| Connectivity | done | Q3/2023 | https://github.com/libp2p/rust-libp2p/issues/2883 | | |

We added alpha support for QUIC in Q4/2022 wrapping `quinn-proto`. Evaluate using `quinn` directly, replacing the wrapper.
9 changes: 8 additions & 1 deletion protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## 0.44.3 - unreleased
## 0.44.4 - unreleased

- Implement common traits on `RoutingUpdate`.
See [PR 4270].

[PR 4270]: https://github.com/libp2p/rust-libp2p/pull/4270

## 0.44.3

- Prevent simultaneous dials to peers.
See [PR 4224].
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-kad"
edition = "2021"
rust-version = "1.65.0"
description = "Kademlia protocol for libp2p"
version = "0.44.3"
version = "0.44.4"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
1 change: 1 addition & 0 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,7 @@ impl fmt::Display for NoKnownPeers {
impl std::error::Error for NoKnownPeers {}

/// The possible outcomes of [`Kademlia::add_address`].
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RoutingUpdate {
/// The given peer and address has been added to the routing
/// table.
Expand Down
4 changes: 4 additions & 0 deletions protocols/relay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
## 0.16.1 - unreleased

- Export `RateLimiter` type.
See [PR 3742].

- Add functions to access data within `Limit`.
See [PR 4162].

[PR 3742]: https://github.com/libp2p/rust-libp2p/pull/3742
[PR 4162]: https://github.com/libp2p/rust-libp2p/pull/4162

## 0.16.0
Expand Down
34 changes: 34 additions & 0 deletions protocols/relay/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,40 @@ pub struct Config {
pub circuit_src_rate_limiters: Vec<Box<dyn rate_limiter::RateLimiter>>,
}

impl Config {
pub fn reservation_rate_per_peer(mut self, limit: NonZeroU32, interval: Duration) -> Self {
self.reservation_rate_limiters
.push(rate_limiter::new_per_peer(
rate_limiter::GenericRateLimiterConfig { limit, interval },
));
self
}

pub fn circuit_src_per_peer(mut self, limit: NonZeroU32, interval: Duration) -> Self {
self.circuit_src_rate_limiters
.push(rate_limiter::new_per_peer(
rate_limiter::GenericRateLimiterConfig { limit, interval },
));
self
}

pub fn reservation_rate_per_ip(mut self, limit: NonZeroU32, interval: Duration) -> Self {
self.reservation_rate_limiters
.push(rate_limiter::new_per_ip(
rate_limiter::GenericRateLimiterConfig { limit, interval },
));
self
}

pub fn circuit_src_per_ip(mut self, limit: NonZeroU32, interval: Duration) -> Self {
self.circuit_src_rate_limiters
.push(rate_limiter::new_per_ip(
rate_limiter::GenericRateLimiterConfig { limit, interval },
));
self
}
}

impl std::fmt::Debug for Config {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Config")
Expand Down
12 changes: 6 additions & 6 deletions protocols/relay/src/behaviour/rate_limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ use std::time::Duration;

/// Allows rate limiting access to some resource based on the [`PeerId`] and
/// [`Multiaddr`] of a remote peer.
///
/// See [`new_per_peer`] and [`new_per_ip`] for precast implementations. Use
/// [`GenericRateLimiter`] to build your own, e.g. based on the autonomous system
/// number of a peers IP address.
//
// See [`new_per_peer`] and [`new_per_ip`] for precast implementations. Use
// [`GenericRateLimiter`] to build your own, e.g. based on the autonomous system
// number of a peers IP address.
pub trait RateLimiter: Send {
fn try_next(&mut self, peer: PeerId, addr: &Multiaddr, now: Instant) -> bool;
}
Expand Down Expand Up @@ -80,9 +80,9 @@ pub(crate) struct GenericRateLimiter<Id> {
/// Configuration for a [`GenericRateLimiter`].
#[derive(Debug, Clone, Copy)]
pub(crate) struct GenericRateLimiterConfig {
/// The maximum number of tokens in the bucket at any point in time.
// The maximum number of tokens in the bucket at any point in time.
pub(crate) limit: NonZeroU32,
/// The interval at which a single token is added to the bucket.
// The interval at which a single token is added to the bucket.
pub(crate) interval: Duration,
}

Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod proto {
};
}

pub use behaviour::{Behaviour, CircuitId, Config, Event};
pub use behaviour::{rate_limiter::RateLimiter, Behaviour, CircuitId, Config, Event};
pub use protocol::{HOP_PROTOCOL_NAME, STOP_PROTOCOL_NAME};

/// Types related to the relay protocol inbound.
Expand Down

0 comments on commit aa09aa3

Please sign in to comment.