Skip to content

Commit

Permalink
Merge branch 'master' into kademlia-poll-bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
PanGan21 authored Dec 1, 2023
2 parents f2aaad2 + a83c30a commit 4d43c33
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 29 deletions.
9 changes: 4 additions & 5 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ libp2p = { version = "0.53.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.0", path = "misc/connection-limits" }
libp2p-core = { version = "0.41.1", path = "core" }
libp2p-core = { version = "0.41.2", path = "core" }
libp2p-dcutr = { version = "0.11.0", 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-identify = { version = "0.44.1", path = "protocols/identify" }
libp2p-identity = { version = "0.2.8" }
libp2p-kad = { version = "0.45.2", path = "protocols/kad" }
libp2p-kad = { version = "0.45.3", 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" }
Expand All @@ -94,7 +94,7 @@ libp2p-perf = { version = "0.3.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" }
libp2p-quic = { version = "0.10.1", path = "transports/quic" }
libp2p-quic = { version = "0.10.2", path = "transports/quic" }
libp2p-relay = { version = "0.17.1", path = "protocols/relay" }
libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.26.1", path = "protocols/request-response" }
Expand All @@ -107,7 +107,7 @@ libp2p-tls = { version = "0.3.0", path = "transports/tls" }
libp2p-uds = { version = "0.40.0", path = "transports/uds" }
libp2p-upnp = { version = "0.2.0", path = "protocols/upnp" }
libp2p-webrtc = { version = "0.7.0-alpha", path = "transports/webrtc" }
libp2p-webrtc-utils = { version = "0.1.0", path = "misc/webrtc-utils" }
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" }
Expand Down
5 changes: 5 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.41.2

- Implement `std::fmt::Display` on `ListenerId`.
See [PR 4936](https://github.com/libp2p/rust-libp2p/pull/4936).

## 0.41.1

- Implement `{In,Out}boundConnectionUpgrade` for `SelectUpgrade`.
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-core"
edition = "2021"
rust-version = { workspace = true }
description = "Core traits and structs of libp2p"
version = "0.41.1"
version = "0.41.2"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
6 changes: 6 additions & 0 deletions core/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ impl ListenerId {
}
}

impl std::fmt::Display for ListenerId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}

/// Event produced by [`Transport`]s.
pub enum TransportEvent<TUpgr, TErr> {
/// A new address is being listened on.
Expand Down
5 changes: 5 additions & 0 deletions misc/webrtc-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.0

- Update to latest version of `libp2p-noise`.
See [PR 4968](https://github.com/libp2p/rust-libp2p/pull/4968).

## 0.1.0

- Initial release.
Expand Down
2 changes: 1 addition & 1 deletion misc/webrtc-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT"
name = "libp2p-webrtc-utils"
repository = "https://github.com/libp2p/rust-libp2p"
rust-version = { workspace = true }
version = "0.1.0"
version = "0.2.0"
publish = true

[dependencies]
Expand Down
6 changes: 4 additions & 2 deletions misc/webrtc-utils/src/noise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ use libp2p_noise as noise;

use crate::fingerprint::Fingerprint;

pub use noise::Error;

pub async fn inbound<T>(
id_keys: identity::Keypair,
stream: T,
client_fingerprint: Fingerprint,
server_fingerprint: Fingerprint,
) -> Result<PeerId, libp2p_noise::Error>
) -> Result<PeerId, Error>
where
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
{
Expand All @@ -54,7 +56,7 @@ pub async fn outbound<T>(
stream: T,
server_fingerprint: Fingerprint,
client_fingerprint: Fingerprint,
) -> Result<PeerId, libp2p_noise::Error>
) -> Result<PeerId, Error>
where
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
{
Expand Down
5 changes: 5 additions & 0 deletions protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.45.3

- The progress of the close query iterator shall be decided by ANY of the new peers.
See [PR 4932](https://github.com/libp2p/rust-libp2p/pull/4932).

## 0.45.2

- Automatically `bootstrap` every 5 minutes.
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 = { workspace = true }
description = "Kademlia protocol for libp2p"
version = "0.45.2"
version = "0.45.3"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
17 changes: 9 additions & 8 deletions protocols/kad/src/query/peers/closest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,14 @@ impl ClosestPeersIter {
},
}

let num_closest = self.closest_peers.len();
let mut progress = false;

// Incorporate the reported closer peers into the iterator.
//
// The iterator makes progress if:
// 1, the iterator did not yet accumulate enough closest peers.
// OR
// 2, any of the new peers is closer to the target than any peer seen so far
// (i.e. is the first entry after being incorporated)
let mut progress = self.closest_peers.len() < self.config.num_results.get();
for peer in closer_peers {
let key = peer.into();
let distance = self.target.distance(&key);
Expand All @@ -187,11 +191,8 @@ impl ClosestPeersIter {
state: PeerState::NotContacted,
};
self.closest_peers.entry(distance).or_insert(peer);
// The iterator makes progress if the new peer is either closer to the target
// than any peer seen so far (i.e. is the first entry), or the iterator did
// not yet accumulate enough closest peers.
progress = self.closest_peers.keys().next() == Some(&distance)
|| num_closest < self.config.num_results.get();

progress = self.closest_peers.keys().next() == Some(&distance) || progress;
}

// Update the iterator state.
Expand Down
5 changes: 5 additions & 0 deletions transports/quic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.10.2

- Change `max_idle_timeout`to 10s.
See [PR XXXX](https://github.com/libp2p/rust-libp2p/pull/XXXX).

## 0.10.1

- Allow disabling path MTU discovery.
Expand Down
2 changes: 1 addition & 1 deletion transports/quic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libp2p-quic"
version = "0.10.1"
version = "0.10.2"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
rust-version = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions transports/quic/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ impl Config {
server_tls_config,
support_draft_29: false,
handshake_timeout: Duration::from_secs(5),
max_idle_timeout: 30 * 1000,
max_idle_timeout: 10 * 1000,
max_concurrent_stream_limit: 256,
keep_alive_interval: Duration::from_secs(15),
keep_alive_interval: Duration::from_secs(5),
max_connection_data: 15_000_000,

// Ensure that one stream is not consuming the whole connection.
Expand Down
2 changes: 2 additions & 0 deletions transports/webrtc-websys/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- Bump version in order to publish a new version dependent on latest `libp2p-core`.
See [PR 4959](https://github.com/libp2p/rust-libp2p/pull/4959).
- Remove `libp2p_noise` from the public API.
See [PR 4969](https://github.com/libp2p/rust-libp2p/pull/4969).

## 0.2.0-alpha

Expand Down
1 change: 0 additions & 1 deletion transports/webrtc-websys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ hex = "0.4.3"
js-sys = { version = "0.3" }
libp2p-core = { workspace = true }
libp2p-identity = { workspace = true }
libp2p-noise = { workspace = true }
libp2p-webrtc-utils = { workspace = true }
send_wrapper = { version = "0.6.0", features = ["futures"] }
serde = { version = "1.0", features = ["derive"] }
Expand Down
9 changes: 7 additions & 2 deletions transports/webrtc-websys/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ pub enum Error {
Connection(String),

#[error("Authentication error")]
Authentication(#[from] libp2p_noise::Error),
Authentication(#[from] AuthenticationError),
}

/// New-type wrapper to hide `libp2p_noise` from the public API.
#[derive(thiserror::Error, Debug)]
#[error(transparent)]
pub struct AuthenticationError(pub(crate) libp2p_webrtc_utils::noise::Error);

impl Error {
pub(crate) fn from_js_value(value: JsValue) -> Self {
let s = if value.is_instance_of::<js_sys::Error>() {
Expand All @@ -38,7 +43,7 @@ impl Error {
}
}

impl std::convert::From<wasm_bindgen::JsValue> for Error {
impl From<JsValue> for Error {
fn from(value: JsValue) -> Self {
Error::from_js_value(value)
}
Expand Down
5 changes: 4 additions & 1 deletion transports/webrtc-websys/src/upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::Error;
use crate::connection::RtcPeerConnection;
use crate::error::AuthenticationError;
use crate::sdp;
use crate::Connection;
use libp2p_identity::{Keypair, PeerId};
Expand Down Expand Up @@ -48,7 +49,9 @@ async fn outbound_inner(
tracing::trace!(?local_fingerprint);
tracing::trace!(?remote_fingerprint);

let peer_id = noise::outbound(id_keys, channel, remote_fingerprint, local_fingerprint).await?;
let peer_id = noise::outbound(id_keys, channel, remote_fingerprint, local_fingerprint)
.await
.map_err(AuthenticationError)?;

tracing::debug!(peer=%peer_id, "Remote peer identified");

Expand Down

0 comments on commit 4d43c33

Please sign in to comment.