Skip to content

Commit

Permalink
Merge branch 'master' into use-wtransport
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarus authored Feb 25, 2025
2 parents d7e3610 + 1c9b3ca commit c349032
Show file tree
Hide file tree
Showing 26 changed files with 89 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.36.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.39.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.6

Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ libp2p-kad = { version = "0.47.0", path = "protocols/kad" }
libp2p-mdns = { version = "0.47.0", path = "protocols/mdns" }
libp2p-memory-connection-limits = { version = "0.4.0", path = "misc/memory-connection-limits" }
libp2p-metrics = { version = "0.16.0", path = "misc/metrics" }
libp2p-mplex = { version = "0.43.0", path = "muxers/mplex" }
libp2p-mplex = { version = "0.43.1", path = "muxers/mplex" }
libp2p-noise = { version = "0.46.0", path = "transports/noise" }
libp2p-perf = { version = "0.4.0", path = "protocols/perf" }
libp2p-ping = { version = "0.46.0", path = "protocols/ping" }
Expand All @@ -110,7 +110,7 @@ libp2p-upnp = { version = "0.4.0", path = "protocols/upnp" }
libp2p-webrtc = { version = "0.9.0-alpha", path = "transports/webrtc" }
libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" }
libp2p-webrtc-websys = { version = "0.4.0", path = "transports/webrtc-websys" }
libp2p-websocket = { version = "0.45.0", path = "transports/websocket" }
libp2p-websocket = { version = "0.45.1", path = "transports/websocket" }
libp2p-websocket-websys = { version = "0.5.0", path = "transports/websocket-websys" }
libp2p-webtransport = { version = "0.1.0", path = "transports/webtransport" }
libp2p-webtransport-websys = { version = "0.5.0", path = "transports/webtransport-websys" }
Expand Down
6 changes: 3 additions & 3 deletions core/tests/transport_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use libp2p_core::{
Endpoint,
};
use libp2p_identity as identity;
use libp2p_mplex::MplexConfig;
use libp2p_mplex::Config;
use libp2p_noise as noise;
use multiaddr::{Multiaddr, Protocol};
use rand::random;
Expand Down Expand Up @@ -89,7 +89,7 @@ async fn upgrade_pipeline() {
.apply(HelloUpgrade {})
.apply(HelloUpgrade {})
.apply(HelloUpgrade {})
.multiplex(MplexConfig::default())
.multiplex(Config::default())
.boxed();

let dialer_keys = identity::Keypair::generate_ed25519();
Expand All @@ -100,7 +100,7 @@ async fn upgrade_pipeline() {
.apply(HelloUpgrade {})
.apply(HelloUpgrade {})
.apply(HelloUpgrade {})
.multiplex(MplexConfig::default())
.multiplex(Config::default())
.boxed();

let listen_addr1 = Multiaddr::from(Protocol::Memory(random::<u64>()));
Expand Down
10 changes: 5 additions & 5 deletions interop-tests/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub(crate) mod native {
.with_tcp(
tcp::Config::default(),
tls::Config::new,
mplex::MplexConfig::default,
mplex::Config::default,
)?
.with_behaviour(behaviour_constructor)?
.build(),
Expand All @@ -82,7 +82,7 @@ pub(crate) mod native {
.with_tcp(
tcp::Config::default(),
noise::Config::new,
mplex::MplexConfig::default,
mplex::Config::default,
)?
.with_behaviour(behaviour_constructor)?
.build(),
Expand All @@ -103,7 +103,7 @@ pub(crate) mod native {
(Transport::Ws, Some(SecProtocol::Tls), Some(Muxer::Mplex)) => (
libp2p::SwarmBuilder::with_new_identity()
.with_tokio()
.with_websocket(tls::Config::new, mplex::MplexConfig::default)
.with_websocket(tls::Config::new, mplex::Config::default)
.await?
.with_behaviour(behaviour_constructor)?
.build(),
Expand All @@ -121,7 +121,7 @@ pub(crate) mod native {
(Transport::Ws, Some(SecProtocol::Noise), Some(Muxer::Mplex)) => (
libp2p::SwarmBuilder::with_new_identity()
.with_tokio()
.with_websocket(noise::Config::new, mplex::MplexConfig::default)
.with_websocket(noise::Config::new, mplex::Config::default)
.await?
.with_behaviour(behaviour_constructor)?
.build(),
Expand Down Expand Up @@ -235,7 +235,7 @@ pub(crate) mod wasm {
noise::Config::new(&local_key)
.context("failed to initialise noise")?,
)
.multiplex(mplex::MplexConfig::new()))
.multiplex(mplex::Config::new()))
})?
.with_behaviour(behaviour_constructor)?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
Expand Down
10 changes: 2 additions & 8 deletions libp2p/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,7 @@ mod tests {
.with_tcp(
Default::default(),
libp2p_tls::Config::new,
(
libp2p_yamux::Config::default,
libp2p_mplex::MplexConfig::default,
),
(libp2p_yamux::Config::default, libp2p_mplex::Config::default),
)
.unwrap()
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
Expand All @@ -201,10 +198,7 @@ mod tests {
.with_tcp(
Default::default(),
(libp2p_tls::Config::new, libp2p_noise::Config::new),
(
libp2p_yamux::Config::default,
libp2p_mplex::MplexConfig::default,
),
(libp2p_yamux::Config::default, libp2p_mplex::Config::default),
)
.unwrap()
.with_behaviour(|_| libp2p_swarm::dummy::Behaviour)
Expand Down
2 changes: 1 addition & 1 deletion libp2p/src/builder/phase/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ macro_rules! impl_websocket_builder {
{
let security_upgrade = security_upgrade.into_security_upgrade(&self.keypair)
.map_err(WebsocketErrorInner::SecurityUpgrade)?;
let websocket_transport = libp2p_websocket::WsConfig::new(
let websocket_transport = libp2p_websocket::Config::new(
$dnsTcp.await.map_err(WebsocketErrorInner::Dns)?,
)
.upgrade(libp2p_core::upgrade::Version::V1Lazy)
Expand Down
2 changes: 1 addition & 1 deletion misc/quick-protobuf-codec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ mod tests {

let mut src = BytesMut::new();
src.extend_from_slice(encoded_length);
src.extend(std::iter::repeat(0).take(length));
src.extend(std::iter::repeat_n(0, length));
src
}

Expand Down
5 changes: 5 additions & 0 deletions muxers/mplex/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.43.1

- Rename `MplexConfig` to `Config` for consistency with other crates (see [discussion 2174](https://github.com/libp2p/rust-libp2p/discussions/2174)).
See [PR 5870](https://github.com/libp2p/rust-libp2p/pull/5870).

## 0.43.0

<!-- Update to libp2p-core v0.43.0 -->
Expand Down
2 changes: 1 addition & 1 deletion muxers/mplex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-mplex"
edition = "2021"
rust-version = { workspace = true }
description = "Mplex multiplexing protocol for libp2p"
version = "0.43.0"
version = "0.43.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
4 changes: 2 additions & 2 deletions muxers/mplex/benches/split_send_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fn run(
}

fn tcp_transport(split_send_size: usize) -> BenchTransport {
let mut mplex = mplex::MplexConfig::default();
let mut mplex = mplex::Config::default();
mplex.set_split_send_size(split_send_size);

libp2p_tcp::async_io::Transport::new(libp2p_tcp::Config::default().nodelay(true))
Expand All @@ -198,7 +198,7 @@ fn tcp_transport(split_send_size: usize) -> BenchTransport {
}

fn mem_transport(split_send_size: usize) -> BenchTransport {
let mut mplex = mplex::MplexConfig::default();
let mut mplex = mplex::Config::default();
mplex.set_split_send_size(split_send_size);

transport::MemoryTransport::default()
Expand Down
14 changes: 7 additions & 7 deletions muxers/mplex/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) const DEFAULT_MPLEX_PROTOCOL_NAME: &str = "/mplex/6.7.0";

/// Configuration for the multiplexer.
#[derive(Debug, Clone)]
pub struct MplexConfig {
pub struct Config {
/// Maximum number of simultaneously used substreams.
pub(crate) max_substreams: usize,
/// Maximum number of frames buffered per substream.
Expand All @@ -40,9 +40,9 @@ pub struct MplexConfig {
pub(crate) protocol_name: &'static str,
}

impl MplexConfig {
impl Config {
/// Builds the default configuration.
pub fn new() -> MplexConfig {
pub fn new() -> Config {
Default::default()
}

Expand Down Expand Up @@ -108,7 +108,7 @@ impl MplexConfig {
pub enum MaxBufferBehaviour {
/// Reset the substream whose frame buffer overflowed.
///
/// > **Note**: If more than [`MplexConfig::set_max_buffer_size()`] frames
/// > **Note**: If more than [`Config::set_max_buffer_size()`] frames
/// > are received in succession for a substream in the context of
/// > trying to read data from a different substream, the former substream
/// > may be reset before application code had a chance to read from the
Expand All @@ -130,9 +130,9 @@ pub enum MaxBufferBehaviour {
Block,
}

impl Default for MplexConfig {
fn default() -> MplexConfig {
MplexConfig {
impl Default for Config {
fn default() -> Config {
Config {
max_substreams: 128,
max_buffer_len: 32,
max_buffer_behaviour: MaxBufferBehaviour::Block,
Expand Down
16 changes: 8 additions & 8 deletions muxers/mplex/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use smallvec::SmallVec;

use crate::{
codec::{Codec, Frame, LocalStreamId, RemoteStreamId},
MaxBufferBehaviour, MplexConfig,
Config, MaxBufferBehaviour,
};
/// A connection identifier.
///
Expand Down Expand Up @@ -70,7 +70,7 @@ pub(crate) struct Multiplexed<C> {
/// The underlying multiplexed I/O stream.
io: Fuse<Framed<C, Codec>>,
/// The configuration.
config: MplexConfig,
config: Config,
/// The buffer of new inbound substreams that have not yet
/// been drained by `poll_next_stream`. This buffer is
/// effectively bounded by `max_substreams - substreams.len()`.
Expand Down Expand Up @@ -122,7 +122,7 @@ where
C: AsyncRead + AsyncWrite + Unpin,
{
/// Creates a new multiplexed I/O stream.
pub(crate) fn new(io: C, config: MplexConfig) -> Self {
pub(crate) fn new(io: C, config: Config) -> Self {
let id = ConnectionId(rand::random());
tracing::debug!(connection=%id, "New multiplexed connection");
Multiplexed {
Expand Down Expand Up @@ -1168,9 +1168,9 @@ mod tests {
}
}

impl Arbitrary for MplexConfig {
fn arbitrary(g: &mut Gen) -> MplexConfig {
MplexConfig {
impl Arbitrary for Config {
fn arbitrary(g: &mut Gen) -> Config {
Config {
max_substreams: g.gen_range(1..100),
max_buffer_len: g.gen_range(1..1000),
max_buffer_behaviour: MaxBufferBehaviour::arbitrary(g),
Expand Down Expand Up @@ -1236,7 +1236,7 @@ mod tests {
.with_env_filter(EnvFilter::from_default_env())
.try_init();

fn prop(cfg: MplexConfig, overflow: NonZeroU8) {
fn prop(cfg: Config, overflow: NonZeroU8) {
let mut r_buf = BytesMut::new();
let mut codec = Codec::new();

Expand Down Expand Up @@ -1374,7 +1374,7 @@ mod tests {
.with_env_filter(EnvFilter::from_default_env())
.try_init();

fn prop(cfg: MplexConfig, num_streams: NonZeroU8) {
fn prop(cfg: Config, num_streams: NonZeroU8) {
let num_streams = cmp::min(cfg.max_substreams, num_streams.get() as usize);

// Setup the multiplexed connection.
Expand Down
11 changes: 7 additions & 4 deletions muxers/mplex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ use std::{

use bytes::Bytes;
use codec::LocalStreamId;
pub use config::{MaxBufferBehaviour, MplexConfig};
pub use config::{Config, MaxBufferBehaviour};
use futures::{prelude::*, ready};
use libp2p_core::{
muxing::{StreamMuxer, StreamMuxerEvent},
upgrade::{InboundConnectionUpgrade, OutboundConnectionUpgrade, UpgradeInfo},
};
use parking_lot::Mutex;

impl UpgradeInfo for MplexConfig {
#[deprecated = "Use `Config` instead"]
pub type MplexConfig = Config;

impl UpgradeInfo for Config {
type Info = &'static str;
type InfoIter = iter::Once<Self::Info>;

Expand All @@ -52,7 +55,7 @@ impl UpgradeInfo for MplexConfig {
}
}

impl<C> InboundConnectionUpgrade<C> for MplexConfig
impl<C> InboundConnectionUpgrade<C> for Config
where
C: AsyncRead + AsyncWrite + Unpin,
{
Expand All @@ -68,7 +71,7 @@ where
}
}

impl<C> OutboundConnectionUpgrade<C> for MplexConfig
impl<C> OutboundConnectionUpgrade<C> for Config
where
C: AsyncRead + AsyncWrite + Unpin,
{
Expand Down
8 changes: 3 additions & 5 deletions muxers/mplex/tests/compliance.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
use libp2p_mplex::MplexConfig;
use libp2p_mplex::Config;

#[async_std::test]
async fn close_implies_flush() {
let (alice, bob) =
libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::<MplexConfig, _, _>()
.await;
libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::<Config, _, _>().await;

libp2p_muxer_test_harness::close_implies_flush(alice, bob).await;
}

#[async_std::test]
async fn read_after_close() {
let (alice, bob) =
libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::<MplexConfig, _, _>()
.await;
libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::<Config, _, _>().await;

libp2p_muxer_test_harness::read_after_close(alice, bob).await;
}
2 changes: 1 addition & 1 deletion muxers/yamux/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ yamux013 = { version = "0.13.3", package = "yamux" }
tracing = { workspace = true }

[dev-dependencies]
async-std = { version = "1.7.0", features = ["attributes"] }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
libp2p-muxer-test-harness = { path = "../test-harness" }

# Passing arguments to the docsrs builder in order to properly document cfg's.
Expand Down
4 changes: 2 additions & 2 deletions muxers/yamux/tests/compliance.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use libp2p_yamux::Config;

#[async_std::test]
#[tokio::test]
async fn close_implies_flush() {
let (alice, bob) =
libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::<Config, _, _>().await;

libp2p_muxer_test_harness::close_implies_flush(alice, bob).await;
}

#[async_std::test]
#[tokio::test]
async fn read_after_close() {
let (alice, bob) =
libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::<Config, _, _>().await;
Expand Down
Loading

0 comments on commit c349032

Please sign in to comment.