Skip to content

Commit

Permalink
Merge branch 'master' into rename-relay
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger committed Dec 20, 2022
2 parents 6f63553 + 93335b8 commit 48e8201
Show file tree
Hide file tree
Showing 28 changed files with 395 additions and 361 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
echo "<meta http-equiv=\"refresh\" content=\"0; url=libp2p\">" > target/doc/index.html
cp -r target/doc/* ./host-docs
- name: Upload documentation
uses: actions/upload-pages-artifact@v1.0.6
uses: actions/upload-pages-artifact@v1.0.7
with:
path: "host-docs/"

Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@

# 0.51.0 [unreleased]

- Count bandwidth at the application level. Previously `BandwidthLogging` would implement `Transport` and now implements `StreamMuxer` ([PR 3180](https://github.com/libp2p/rust-libp2p/pull/3180)).
- `BandwidthLogging::new` now requires a 2nd argument: `Arc<BandwidthSinks>`
- Remove `BandwidthFuture`
- Rename `BandwidthConnecLogging` to `InstrumentedStream`
- Remove `SimpleProtocol` due to being unused. See [`libp2p::core::upgrade`](https://docs.rs/libp2p/0.50.0/libp2p/core/upgrade/index.html) for alternatives. See [PR 3191].

- Update individual crates.
- Update to [`libp2p-dcutr` `v0.9.0`](protocols/dcutr/CHANGELOG.md#090).

Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ env_logger = "0.10.0"
clap = { version = "4.0.13", features = ["derive"] }
tokio = { version = "1.15", features = ["io-util", "io-std", "macros", "rt", "rt-multi-thread"] }

libp2p-mplex = { path = "muxers/mplex" }
libp2p-noise = { path = "transports/noise" }
libp2p-tcp = { path = "transports/tcp", features = ["tokio"] }

[workspace]
members = [
"core",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![dependency status](https://deps.rs/repo/github/libp2p/rust-libp2p/status.svg?style=flat-square)](https://deps.rs/repo/github/libp2p/rust-libp2p)
[![Crates.io](https://img.shields.io/crates/v/libp2p.svg)](https://crates.io/crates/libp2p)
[![docs.rs](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/libp2p)
[![docs.rs master](https://img.shields.io/badge/docs-master-blueviolet)](https://libp2p.github.io/rust-libp2p/libp2p/)

This repository is the central place for Rust development of the [libp2p](https://libp2p.io) spec.

Expand Down
20 changes: 10 additions & 10 deletions misc/metrics/src/dcutr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,30 @@ enum EventType {
DirectConnectionUpgradeFailed,
}

impl From<&libp2p_dcutr::behaviour::Event> for EventType {
fn from(event: &libp2p_dcutr::behaviour::Event) -> Self {
impl From<&libp2p_dcutr::Event> for EventType {
fn from(event: &libp2p_dcutr::Event) -> Self {
match event {
libp2p_dcutr::behaviour::Event::InitiatedDirectConnectionUpgrade {
libp2p_dcutr::Event::InitiatedDirectConnectionUpgrade {
remote_peer_id: _,
local_relayed_addr: _,
} => EventType::InitiateDirectConnectionUpgrade,
libp2p_dcutr::behaviour::Event::RemoteInitiatedDirectConnectionUpgrade {
libp2p_dcutr::Event::RemoteInitiatedDirectConnectionUpgrade {
remote_peer_id: _,
remote_relayed_addr: _,
} => EventType::RemoteInitiatedDirectConnectionUpgrade,
libp2p_dcutr::behaviour::Event::DirectConnectionUpgradeSucceeded {
remote_peer_id: _,
} => EventType::DirectConnectionUpgradeSucceeded,
libp2p_dcutr::behaviour::Event::DirectConnectionUpgradeFailed {
libp2p_dcutr::Event::DirectConnectionUpgradeSucceeded { remote_peer_id: _ } => {
EventType::DirectConnectionUpgradeSucceeded
}
libp2p_dcutr::Event::DirectConnectionUpgradeFailed {
remote_peer_id: _,
error: _,
} => EventType::DirectConnectionUpgradeFailed,
}
}
}

impl super::Recorder<libp2p_dcutr::behaviour::Event> for Metrics {
fn record(&self, event: &libp2p_dcutr::behaviour::Event) {
impl super::Recorder<libp2p_dcutr::Event> for Metrics {
fn record(&self, event: &libp2p_dcutr::Event) {
self.events
.get_or_create(&EventLabels {
event: event.into(),
Expand Down
4 changes: 2 additions & 2 deletions misc/metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ pub trait Recorder<Event> {
}

#[cfg(feature = "dcutr")]
impl Recorder<libp2p_dcutr::behaviour::Event> for Metrics {
fn record(&self, event: &libp2p_dcutr::behaviour::Event) {
impl Recorder<libp2p_dcutr::Event> for Metrics {
fn record(&self, event: &libp2p_dcutr::Event) {
self.dcutr.record(event)
}
}
Expand Down
2 changes: 1 addition & 1 deletion misc/metrics/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,5 +396,5 @@ impl<TTransErr> From<&libp2p_swarm::PendingInboundConnectionError<TTransErr>>
}

fn create_connection_establishment_duration_histogram() -> Histogram {
Histogram::new(exponential_buckets(1e-3, 2., 10))
Histogram::new(exponential_buckets(0.01, 1.5, 20))
}
4 changes: 4 additions & 0 deletions protocols/dcutr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

- Require the node's local `PeerId` to be passed into the constructor of `libp2p_dcutr::Behaviour`. See [PR 3153].

- Rename types in public API to follow naming conventions defined in [issue 2217]. See [PR 3214].

[PR 3213]: https://github.com/libp2p/rust-libp2p/pull/3213
[PR 3153]: https://github.com/libp2p/rust-libp2p/pull/3153
[issue 2217]: https://github.com/libp2p/rust-libp2p/issues/2217
[PR 3214]: https://github.com/libp2p/rust-libp2p/pull/3214

# 0.8.0

Expand Down
10 changes: 5 additions & 5 deletions protocols/dcutr/examples/dcutr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn main() -> Result<(), Box<dyn Error>> {
relay_client: client::Behaviour,
ping: ping::Behaviour,
identify: identify::Behaviour,
dcutr: dcutr::behaviour::Behaviour,
dcutr: dcutr::Behaviour,
}

#[derive(Debug)]
Expand All @@ -123,7 +123,7 @@ fn main() -> Result<(), Box<dyn Error>> {
Ping(ping::Event),
Identify(identify::Event),
Relay(client::Event),
Dcutr(dcutr::behaviour::Event),
Dcutr(dcutr::Event),
}

impl From<ping::Event> for Event {
Expand All @@ -144,8 +144,8 @@ fn main() -> Result<(), Box<dyn Error>> {
}
}

impl From<dcutr::behaviour::Event> for Event {
fn from(e: dcutr::behaviour::Event) -> Self {
impl From<dcutr::Event> for Event {
fn from(e: dcutr::Event) -> Self {
Event::Dcutr(e)
}
}
Expand All @@ -157,7 +157,7 @@ fn main() -> Result<(), Box<dyn Error>> {
"/TODO/0.0.1".to_string(),
local_key.public(),
)),
dcutr: dcutr::behaviour::Behaviour::new(local_peer_id),
dcutr: dcutr::Behaviour::new(local_peer_id),
};

let mut swarm = match ThreadPool::new() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ pub enum Event {
},
DirectConnectionUpgradeFailed {
remote_peer_id: PeerId,
error: UpgradeError,
error: Error,
},
}

#[derive(Debug, Error)]
pub enum UpgradeError {
pub enum Error {
#[error("Failed to dial peer.")]
Dial,
#[error("Failed to establish substream: {0}.")]
Expand Down Expand Up @@ -164,7 +164,7 @@ impl Behaviour {
.into(),
NetworkBehaviourAction::GenerateEvent(Event::DirectConnectionUpgradeFailed {
remote_peer_id: peer_id,
error: UpgradeError::Dial,
error: Error::Dial,
})
.into(),
]);
Expand Down Expand Up @@ -236,7 +236,7 @@ impl NetworkBehaviour for Behaviour {
self.queued_actions.push_back(
NetworkBehaviourAction::GenerateEvent(Event::DirectConnectionUpgradeFailed {
remote_peer_id: event_source,
error: UpgradeError::Handler(error),
error: Error::Handler(error),
})
.into(),
);
Expand All @@ -260,7 +260,7 @@ impl NetworkBehaviour for Behaviour {
self.queued_actions.push_back(
NetworkBehaviourAction::GenerateEvent(Event::DirectConnectionUpgradeFailed {
remote_peer_id: event_source,
error: UpgradeError::Handler(error),
error: Error::Handler(error),
})
.into(),
);
Expand Down
35 changes: 32 additions & 3 deletions protocols/dcutr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,43 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub mod behaviour;
mod behaviour_impl; // TODO: Rename back `behaviour` once deprecation symbols are removed.
mod handler;
mod protocol;
#[allow(clippy::derive_partial_eq_without_eq)]
mod message_proto {
include!(concat!(env!("OUT_DIR"), "/holepunch.pb.rs"));
}

pub use behaviour_impl::Behaviour;
pub use behaviour_impl::Error;
pub use behaviour_impl::Event;
pub use protocol::PROTOCOL_NAME;
pub type InboundUpgradeError = protocol::inbound::UpgradeError;
pub type OutboundUpgradeError = protocol::outbound::UpgradeError;
pub mod inbound {
pub use crate::protocol::inbound::UpgradeError;
}
pub mod outbound {
pub use crate::protocol::outbound::UpgradeError;
}

#[deprecated(
since = "0.9.0",
note = "Use `libp2p_dcutr::inbound::UpgradeError` instead.`"
)]
pub type InboundUpgradeError = inbound::UpgradeError;

#[deprecated(
since = "0.9.0",
note = "Use `libp2p_dcutr::outbound::UpgradeError` instead.`"
)]
pub type OutboundUpgradeError = outbound::UpgradeError;
pub mod behaviour {
#[deprecated(since = "0.9.0", note = "Use `libp2p_dcutr::Behaviour` instead.`")]
pub type Behaviour = crate::Behaviour;

#[deprecated(since = "0.9.0", note = "Use `libp2p_dcutr::Event` instead.`")]
pub type Event = crate::Event;

#[deprecated(since = "0.9.0", note = "Use `libp2p_dcutr::Error` instead.`")]
pub type UpgradeError = crate::Error;
}
14 changes: 7 additions & 7 deletions protocols/dcutr/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn connect() {

pool.run_until(wait_for_connection_established(&mut src, &dst_relayed_addr));
match pool.run_until(wait_for_dcutr_event(&mut src)) {
dcutr::behaviour::Event::RemoteInitiatedDirectConnectionUpgrade {
dcutr::Event::RemoteInitiatedDirectConnectionUpgrade {
remote_peer_id,
remote_relayed_addr,
} if remote_peer_id == dst_peer_id && remote_relayed_addr == dst_relayed_addr => {}
Expand Down Expand Up @@ -125,7 +125,7 @@ fn build_client() -> Swarm<Client> {
transport,
Client {
relay: behaviour,
dcutr: dcutr::behaviour::Behaviour::new(local_peer_id),
dcutr: dcutr::Behaviour::new(local_peer_id),
},
local_peer_id,
)
Expand Down Expand Up @@ -153,13 +153,13 @@ where
)]
struct Client {
relay: relay::client::Behaviour,
dcutr: dcutr::behaviour::Behaviour,
dcutr: dcutr::Behaviour,
}

#[derive(Debug)]
enum ClientEvent {
Relay(relay::client::Event),
Dcutr(dcutr::behaviour::Event),
Dcutr(dcutr::Event),
}

impl From<relay::client::Event> for ClientEvent {
Expand All @@ -168,8 +168,8 @@ impl From<relay::client::Event> for ClientEvent {
}
}

impl From<dcutr::behaviour::Event> for ClientEvent {
fn from(event: dcutr::behaviour::Event) -> Self {
impl From<dcutr::Event> for ClientEvent {
fn from(event: dcutr::Event) -> Self {
ClientEvent::Dcutr(event)
}
}
Expand Down Expand Up @@ -242,7 +242,7 @@ async fn wait_for_new_listen_addr(client: &mut Swarm<Client>, new_addr: &Multiad
}
}

async fn wait_for_dcutr_event(client: &mut Swarm<Client>) -> dcutr::behaviour::Event {
async fn wait_for_dcutr_event(client: &mut Swarm<Client>) -> dcutr::Event {
loop {
match client.select_next_some().await {
SwarmEvent::Behaviour(ClientEvent::Dcutr(e)) => return e,
Expand Down
4 changes: 4 additions & 0 deletions protocols/floodsub/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- Update to `libp2p-swarm` `v0.42.0`.

- Read and write protocols messages via `prost-codec`. See [PR 3224].

[pr 3224]: https://github.com/libp2p/rust-libp2p/pull/3224

# 0.41.0

- Update to `libp2p-core` `v0.38.0`.
Expand Down
2 changes: 2 additions & 0 deletions protocols/floodsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]

[dependencies]
asynchronous-codec = "0.6"
cuckoofilter = "0.5.0"
fnv = "1.0"
futures = "0.3.1"
libp2p-core = { version = "0.38.0", path = "../../core" }
libp2p-swarm = { version = "0.42.0", path = "../../swarm" }
log = "0.4"
prost = "0.11"
prost-codec = { version = "0.3", path = "../../misc/prost-codec" }
rand = "0.8"
smallvec = "1.6.1"
thiserror = "1.0.37"
Expand Down
Loading

0 comments on commit 48e8201

Please sign in to comment.