Skip to content
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
207c7ba
adding #[non_exhaustive] to key enums
dhuseby Oct 2, 2023
42a018f
fix swarm/CHANGELOG.md
dhuseby Oct 2, 2023
cd26395
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 2, 2023
9a844b2
fix clippy CI error
dhuseby Oct 2, 2023
c7d8084
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 2, 2023
8edbc27
Update swarm/CHANGELOG.md
dhuseby Oct 3, 2023
f0ecf33
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 3, 2023
1e9561c
Merge branch 'add-non_exhaustive' of github:dhuseby/rust-libp2p into …
dhuseby Oct 3, 2023
2c8ec27
more cleanup
dhuseby Oct 3, 2023
32fbbfa
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 3, 2023
607b6b5
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 3, 2023
36c4ced
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 30, 2023
b87bf96
fixing merge errors
dhuseby Oct 30, 2023
32ba7cd
pinning libp2p-swarm-derive for safety
dhuseby Oct 30, 2023
b8fd915
integrating review changes
dhuseby Oct 31, 2023
1797e27
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 31, 2023
733e617
Update Cargo.toml
dhuseby Oct 31, 2023
eee905f
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 31, 2023
30f1665
Simplify derive code
thomaseizinger Nov 1, 2023
717a577
Fix clippy warnings
thomaseizinger Nov 1, 2023
5e9bf98
Merge branch 'add-non_exhaustive' of github:dhuseby/rust-libp2p into …
dhuseby Nov 1, 2023
c750a58
move swarm-derive comment to the same line in Cargo.toml
dhuseby Nov 1, 2023
789e094
Merge branch 'master' into add-non_exhaustive
dhuseby Nov 1, 2023
344e012
updating CHANGELOGs
dhuseby Nov 1, 2023
21efd9e
fixing kad CHANGELOG
dhuseby Nov 1, 2023
e6aff9f
add libp2p-swarm-derive version pin test
dhuseby Nov 1, 2023
3277209
Revert "updating CHANGELOGs"
thomaseizinger Nov 2, 2023
c85bb0b
Revert "add libp2p-swarm-derive version pin test"
thomaseizinger Nov 2, 2023
3c3e7b5
Extend check to cover pinned version
thomaseizinger Nov 2, 2023
cdd21aa
Merge branch 'master' into add-non_exhaustive
dhuseby Nov 2, 2023
f796df0
update CHANGELOG for swarm-derive
dhuseby Nov 2, 2023
f0c4e0a
Merge branch 'add-non_exhaustive' of github:dhuseby/rust-libp2p into …
dhuseby Nov 2, 2023
e37cbc4
revert swarm-derive/CHANGELOG update
dhuseby Nov 2, 2023
81d7835
Merge branch 'master' into add-non_exhaustive
mergify[bot] Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,19 @@ jobs:
with:
tool: tomlq

- name: Enforce libp2p-swarm-derive version is pinned and matches latest version
if: env.CRATE == 'libp2p-swarm-derive'
run: |
PACKAGE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .version')
SPECIFIED_VERSION=$(tomlq "workspace.dependencies.$CRATE.version" --file ./Cargo.toml)

echo "Package version: $PACKAGE_VERSION";
echo "Specified version: $SPECIFIED_VERSION";

test "=$PACKAGE_VERSION" = "$SPECIFIED_VERSION"

- name: Enforce version in `workspace.dependencies` matches latest version
if: env.CRATE != 'libp2p'
if: env.CRATE != 'libp2p' && env.CRATE != 'libp2p-swarm-derive'
run: |
PACKAGE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .version')
SPECIFIED_VERSION=$(tomlq "workspace.dependencies.$CRATE.version" --file ./Cargo.toml)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.26.0", path = "protocols/request-response" }
libp2p-server = { version = "0.12.3", path = "misc/server" }
libp2p-swarm = { version = "0.44.0", path = "swarm" }
libp2p-swarm-derive = { version = "0.34.0", path = "swarm-derive" }
libp2p-swarm-derive = { version = "=0.34.0", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" }
libp2p-tcp = { version = "0.41.0", path = "transports/tcp" }
libp2p-tls = { version = "0.3.0", path = "transports/tls" }
Expand Down
4 changes: 3 additions & 1 deletion misc/allow-block-list/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## 0.3.0 - unreleased

- Clean up on_swarm_event handler.
See [PR 4581](https://github.com/libp2p/rust-libp2p/pull/4581).

## 0.2.0
## 0.2.0

- Raise MSRV to 1.65.
See [PR 3715].
Expand Down
18 changes: 1 addition & 17 deletions misc/allow-block-list/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,23 +231,7 @@ where
Ok(dummy::ConnectionHandler)
}

fn on_swarm_event(&mut self, event: FromSwarm) {
match event {
FromSwarm::ConnectionClosed(_) => {}
FromSwarm::ConnectionEstablished(_) => {}
FromSwarm::AddressChange(_) => {}
FromSwarm::DialFailure(_) => {}
FromSwarm::ListenFailure(_) => {}
FromSwarm::NewListener(_) => {}
FromSwarm::NewListenAddr(_) => {}
FromSwarm::ExpiredListenAddr(_) => {}
FromSwarm::ListenerError(_) => {}
FromSwarm::ListenerClosed(_) => {}
FromSwarm::NewExternalAddrCandidate(_) => {}
FromSwarm::ExternalAddrExpired(_) => {}
FromSwarm::ExternalAddrConfirmed(_) => {}
}
}
fn on_swarm_event(&mut self, _event: FromSwarm) {}

fn on_connection_handler_event(
&mut self,
Expand Down
2 changes: 2 additions & 0 deletions misc/connection-limits/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.3.0 - unreleased

- Add `_ => {}` arm to `#[non_exhaustive]` enum `match`es
See [PR 4581](https://github.com/libp2p/rust-libp2p/pull/4581).

## 0.2.1

Expand Down
10 changes: 1 addition & 9 deletions misc/connection-limits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,18 +340,10 @@ impl NetworkBehaviour for Behaviour {
FromSwarm::DialFailure(DialFailure { connection_id, .. }) => {
self.pending_outbound_connections.remove(&connection_id);
}
FromSwarm::AddressChange(_) => {}
FromSwarm::ListenFailure(ListenFailure { connection_id, .. }) => {
self.pending_inbound_connections.remove(&connection_id);
}
FromSwarm::NewListener(_) => {}
FromSwarm::NewListenAddr(_) => {}
FromSwarm::ExpiredListenAddr(_) => {}
FromSwarm::ListenerError(_) => {}
FromSwarm::ListenerClosed(_) => {}
FromSwarm::NewExternalAddrCandidate(_) => {}
FromSwarm::ExternalAddrExpired(_) => {}
FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}

Expand Down
2 changes: 2 additions & 0 deletions misc/metrics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.14.0 - unreleased

- Add `_ => {}` arm to `#[non_exhaustive]` enum `match`es
See [PR 4581](https://github.com/libp2p/rust-libp2p/pull/4581).
- Add metrics for `SwarmEvent::{NewExternalAddrCandidate,ExternalAddrConfirmed,ExternalAddrExpired}`.
See [PR 4721](https://github.com/libp2p/rust-libp2p/pull/4721).

Expand Down
51 changes: 22 additions & 29 deletions misc/metrics/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::sync::{Arc, Mutex};

use crate::protocol_stack;
use instant::Instant;
use libp2p_swarm::{ConnectionId, SwarmEvent};
use libp2p_swarm::{ConnectionId, DialError, SwarmEvent};
use prometheus_client::encoding::{EncodeLabelSet, EncodeLabelValue};
use prometheus_client::metrics::counter::Counter;
use prometheus_client::metrics::family::Family;
Expand Down Expand Up @@ -185,11 +185,11 @@ impl Metrics {
}
}

impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleErr>> for Metrics {
fn record(&self, event: &libp2p_swarm::SwarmEvent<TBvEv, THandleErr>) {
impl<TBvEv, THandleErr> super::Recorder<SwarmEvent<TBvEv, THandleErr>> for Metrics {
fn record(&self, event: &SwarmEvent<TBvEv, THandleErr>) {
match event {
libp2p_swarm::SwarmEvent::Behaviour(_) => {}
libp2p_swarm::SwarmEvent::ConnectionEstablished {
SwarmEvent::Behaviour(_) => {}
SwarmEvent::ConnectionEstablished {
endpoint,
established_in: time_taken,
connection_id,
Expand All @@ -208,7 +208,7 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
.expect("lock not to be poisoned")
.insert(*connection_id, Instant::now());
}
libp2p_swarm::SwarmEvent::ConnectionClosed {
SwarmEvent::ConnectionClosed {
endpoint,
connection_id,
cause,
Expand All @@ -231,14 +231,14 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
.as_secs_f64(),
);
}
libp2p_swarm::SwarmEvent::IncomingConnection { send_back_addr, .. } => {
SwarmEvent::IncomingConnection { send_back_addr, .. } => {
self.connections_incoming
.get_or_create(&AddressLabels {
protocols: protocol_stack::as_string(send_back_addr),
})
.inc();
}
libp2p_swarm::SwarmEvent::IncomingConnectionError {
SwarmEvent::IncomingConnectionError {
error,
send_back_addr,
..
Expand All @@ -250,7 +250,7 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
})
.inc();
}
libp2p_swarm::SwarmEvent::OutgoingConnectionError { error, peer_id, .. } => {
SwarmEvent::OutgoingConnectionError { error, peer_id, .. } => {
let peer = match peer_id {
Some(_) => PeerStatus::Known,
None => PeerStatus::Unknown,
Expand All @@ -263,7 +263,7 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
};

match error {
libp2p_swarm::DialError::Transport(errors) => {
DialError::Transport(errors) => {
for (_multiaddr, error) in errors {
match error {
libp2p_core::transport::TransportError::MultiaddrNotSupported(
Expand All @@ -277,39 +277,31 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
};
}
}
libp2p_swarm::DialError::LocalPeerId { .. } => {
record(OutgoingConnectionError::LocalPeerId)
}
libp2p_swarm::DialError::NoAddresses => {
record(OutgoingConnectionError::NoAddresses)
}
libp2p_swarm::DialError::DialPeerConditionFalse(_) => {
DialError::LocalPeerId { .. } => record(OutgoingConnectionError::LocalPeerId),
DialError::NoAddresses => record(OutgoingConnectionError::NoAddresses),
DialError::DialPeerConditionFalse(_) => {
record(OutgoingConnectionError::DialPeerConditionFalse)
}
libp2p_swarm::DialError::Aborted => record(OutgoingConnectionError::Aborted),
libp2p_swarm::DialError::WrongPeerId { .. } => {
record(OutgoingConnectionError::WrongPeerId)
}
libp2p_swarm::DialError::Denied { .. } => {
record(OutgoingConnectionError::Denied)
}
DialError::Aborted => record(OutgoingConnectionError::Aborted),
DialError::WrongPeerId { .. } => record(OutgoingConnectionError::WrongPeerId),
DialError::Denied { .. } => record(OutgoingConnectionError::Denied),
};
}
libp2p_swarm::SwarmEvent::NewListenAddr { address, .. } => {
SwarmEvent::NewListenAddr { address, .. } => {
self.new_listen_addr
.get_or_create(&AddressLabels {
protocols: protocol_stack::as_string(address),
})
.inc();
}
libp2p_swarm::SwarmEvent::ExpiredListenAddr { address, .. } => {
SwarmEvent::ExpiredListenAddr { address, .. } => {
self.expired_listen_addr
.get_or_create(&AddressLabels {
protocols: protocol_stack::as_string(address),
})
.inc();
}
libp2p_swarm::SwarmEvent::ListenerClosed { addresses, .. } => {
SwarmEvent::ListenerClosed { addresses, .. } => {
for address in addresses {
self.listener_closed
.get_or_create(&AddressLabels {
Expand All @@ -318,10 +310,10 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
.inc();
}
}
libp2p_swarm::SwarmEvent::ListenerError { .. } => {
SwarmEvent::ListenerError { .. } => {
self.listener_error.inc();
}
libp2p_swarm::SwarmEvent::Dialing { .. } => {
SwarmEvent::Dialing { .. } => {
self.dial_attempt.inc();
}
SwarmEvent::NewExternalAddrCandidate { address } => {
Expand All @@ -345,6 +337,7 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
})
.inc();
}
_ => {}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion protocols/autonat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## 0.12.0 - unreleased

- Add `_ => {}` arm to `#[non_exhaustive]` enum `match`es
See [PR 4581](https://github.com/libp2p/rust-libp2p/pull/4581).
- Remove `Clone`, `PartialEq` and `Eq` implementations on `Event` and its sub-structs.
The `Event` also contains errors which are not clonable or comparable.
See [PR 3914](https://github.com/libp2p/rust-libp2p/pull/3914).

## 0.11.0
## 0.11.0

- Raise MSRV to 1.65.
See [PR 3715].
Expand Down
1 change: 1 addition & 0 deletions protocols/autonat/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ impl NetworkBehaviour for Behaviour {
self.inner.on_swarm_event(listener_closed)
}
confirmed @ FromSwarm::ExternalAddrConfirmed(_) => self.inner.on_swarm_event(confirmed),
_ => {}
}
}

Expand Down
4 changes: 3 additions & 1 deletion protocols/dcutr/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.11.0 - unreleased

- Add `_ => {}` arm to `#[non_exhaustive]` enum `match`es
See [PR 4581](https://github.com/libp2p/rust-libp2p/pull/4581).
- Add `ConnectionId` to `Event::DirectConnectionUpgradeSucceeded` and `Event::DirectConnectionUpgradeFailed`.
See [PR 4558](https://github.com/libp2p/rust-libp2p/pull/4558).
- Exchange address _candidates_ instead of external addresses in `CONNECT`.
Expand All @@ -9,7 +11,7 @@
We now only emit a single event: whether the hole-punch was successful or not.
See [PR XXXX](https://github.com/libp2p/rust-libp2p/pull/XXXX).

## 0.10.0
## 0.10.0

- Raise MSRV to 1.65.
See [PR 3715].
Expand Down
11 changes: 1 addition & 10 deletions protocols/dcutr/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,7 @@ impl NetworkBehaviour for Behaviour {
FromSwarm::NewExternalAddrCandidate(NewExternalAddrCandidate { addr }) => {
self.address_candidates.add(addr.clone());
}
FromSwarm::AddressChange(_)
| FromSwarm::ConnectionEstablished(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions protocols/dcutr/src/handler/relayed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ impl ConnectionHandler for Handler {
ConnectionEvent::DialUpgradeError(dial_upgrade_error) => {
self.on_dial_upgrade_error(dial_upgrade_error)
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::LocalProtocolsChange(_)
| ConnectionEvent::RemoteProtocolsChange(_) => {}
_ => {}
}
}
}
2 changes: 2 additions & 0 deletions protocols/floodsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.44.0 - unreleased

- Add `_ => {}` arm to `#[non_exhaustive]` enum `match`es
See [PR 4581](https://github.com/libp2p/rust-libp2p/pull/4581).
- Change publish to require `data: impl Into<Bytes>` to internally avoid any costly cloning / allocation.
See [PR 4754](https://github.com/libp2p/rust-libp2p/pull/4754).

Expand Down
12 changes: 1 addition & 11 deletions protocols/floodsub/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,7 @@ impl NetworkBehaviour for Floodsub {
FromSwarm::ConnectionClosed(connection_closed) => {
self.on_connection_closed(connection_closed)
}
FromSwarm::AddressChange(_)
| FromSwarm::DialFailure(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.46.0 - unreleased

- Add `_ => {}` arm to `#[non_exhaustive]` enum `match`es
See [PR 4581](https://github.com/libp2p/rust-libp2p/pull/4581).
- Remove `fast_message_id_fn` mechanism from `Config`.
See [PR 4285](https://github.com/libp2p/rust-libp2p/pull/4285).
- Remove deprecated `gossipsub::Config::idle_timeout` in favor of `SwarmBuilder::idle_connection_timeout`.
Expand Down
11 changes: 1 addition & 10 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3442,16 +3442,7 @@ where
self.on_connection_closed(connection_closed)
}
FromSwarm::AddressChange(address_change) => self.on_address_change(address_change),
FromSwarm::DialFailure(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions protocols/gossipsub/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,7 @@ impl ConnectionHandler for Handler {
}) => {
log::debug!("Protocol negotiation failed: {e}")
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::ListenUpgradeError(_)
| ConnectionEvent::LocalProtocolsChange(_)
| ConnectionEvent::RemoteProtocolsChange(_) => {}
_ => {}
}
}
Handler::Disabled(_) => {}
Expand Down
4 changes: 3 additions & 1 deletion protocols/identify/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
## 0.44.0 - unreleased

- Add `_ => {}` arm to `#[non_exhaustive]` enum `match`es
See [PR 4581](https://github.com/libp2p/rust-libp2p/pull/4581).
- Add `Info` to the `libp2p-identify::Event::Pushed` to report pushed info.
See [PR 4527](https://github.com/libp2p/rust-libp2p/pull/4527)
- Remove deprecated `initial_delay`.
Identify requests are always sent instantly after the connection has been established.
See [PR 4735](https://github.com/libp2p/rust-libp2p/pull/4735)
- Don't repeatedly report the same observed address as a `NewExternalAddrCandidate`.
Instead, only report each observed address once per connection.
This allows users to probabilistically deem an address as external if it gets reported as a candidate repeatedly.
This allows users to probabilistically deem an address as external if it gets reported as a candidate repeatedly.
See [PR 4721](https://github.com/libp2p/rust-libp2p/pull/4721).

## 0.43.1
Expand Down
Loading