103 Commits

Author SHA1 Message Date
dependabot[bot]
c5f5b80c5e
build(deps): Update env_logger requirement from 0.9.0 to 0.10.0 (#3166)
Updates the requirements on [env_logger](https://github.com/rust-cli/env_logger) to permit the latest version.
- [Release notes](https://github.com/rust-cli/env_logger/releases)
- [Changelog](https://github.com/rust-cli/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-cli/env_logger/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: env_logger
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-02 18:06:09 +01:00
Max Inden
87308f0bc8
chore: Prepare rust-libp2p v0.50.0 release (#3163) 2022-11-25 09:37:55 +00:00
Thomas Eizinger
0c85839dab
.github/workflows: Refactor CI jobs (#3090)
We refactor our continuous integration workflow with the following goals in mind:

- Run as few jobs as possible
- Have the jobs finish as fast as possible
- Have the jobs redo as little work as possible

There are only so many jobs that GitHub Actions will run in parallel.
Thus, it makes sense to not create massive matrices but instead group
things together meaningfully.

The new `test` job will:

- Run once for each crate
- Ensure that the crate compiles on its specified MSRV
- Ensure that the tests pass
- Ensure that there are no semver violations

This is an improvement to before because we are running all of these
in parallel which speeds up execution and highlights more errors at
once. Previously, tests run later in the pipeline would not get run
at all until you make sure the "first" one passes.

We also previously did not verify the MSRV of each crate, making the
setting in the `Cargo.toml` rather pointless.

The new `cross` job supersedes the existing `wasm` job.

This is an improvement because we now also compile the crate for
windows and MacOS. Something that wasn't checked before.
We assume that checking MSRV and the tests under Linux is good enough.
Hence, this job only checks for compile-errors.

The new `feature_matrix` ensures we compile correctly with certain feature combinations.

`libp2p` exposes a fair few feature-flags. Some of the combinations
are worth checking independently. For the moment, this concerns only
the executor related transports together with the executor flags but
this list can easily be extended.

The new `clippy` job runs for `stable` and `beta` rust.

Clippy gets continuously extended with new lints. Up until now, we would only
learn about those as soon as a new version of Rust is released and CI would
run the new lints. This leads to unrelated failures in CI. Running clippy on with `beta`
Rust gives us a heads-up of 6 weeks before these lints land on stable.

Fixes #2951.
2022-11-18 11:04:16 +00:00
João Oliveira
7803524a76
swarm/handler: replace inject_* methods (#3085)
Previously, we had one callback for each kind of message that a `ConnectionHandler` would receive from either its `NetworkBehaviour` or the connection itself.

With this patch, we combine these functions, resulting in two callbacks:

- `on_behaviour_event`
- `on_connection_event`

Resolves #3080.
2022-11-17 17:19:36 +00:00
João Oliveira
3df3c88f3d
swarm/behaviour: Replace inject_* with on_event (#3011) 2022-11-17 09:28:40 +00:00
Hannes
d5ea93dd71
feat(swarm): Make executor for connection tasks explicit (#3097)
Previously, the executor for connection tasks silently defaulted to a `futures::executor::ThreadPool`. This causes issues such as https://github.com/libp2p/rust-libp2p/issues/2230.

With this patch, we force the user to choose, which executor they want to run the connection tasks on which results in overall simpler API with less footguns.

Closes #3068.
2022-11-15 14:26:03 +00:00
Thomas Eizinger
afb777e937
swarm-derive: Add prelude configuration option to NetworkBehaviour macro (#3055)
Currently, our `NetworkBehaviour` derive macro depends on the `libp2p` crate to be in scope. This prevents standalone usage which forces us to depend on `libp2p` in all our tests where we want to derive a `NetworkBehaviour`.

This PR introduces a `prelude` option that - by default - points to `libp2p::swarm::derive_prelude`, a new module added to `libp2p_swarm`. With this config option, users of `libp2p_swarm` can now refer to the macro without depending on `libp2p`, breaking the circular dependency in our workspace. For consistency with the ecosystem, the macro is now also re-exported by `libp2p_swarm` instead of `libp2p` at the same position as the trait that it implements.

Lastly, we introduce an off-by-default `macros` feature flag that shrinks the dependency tree for users that don't need the derive macro.
2022-11-12 23:59:14 +00:00
Hannes
c32f03c317
*: Fix newly raised clippy warnings (#3106)
Fixed minor issues raised by clippy to improve correctness and readablitity.
2022-11-11 20:30:58 +00:00
João Oliveira
280c51ef83
*: Link to libp2p/specs in doc comments (#3077) 2022-11-04 10:32:41 +00:00
Thomas Eizinger
71131e0622
*: Don't leak prost dependency in error types (#3058)
With the current design, a major version bump of `prost` leaks into
all consumers of `prost-codec`.
2022-11-02 12:02:21 +00:00
Thomas Eizinger
4d1b165982
transports/tcp: Unify symbol naming (#2961)
Co-authored-by: Elena Frank <elena.frank@protonmail.com>
2022-10-24 15:41:08 +11:00
Hannes
fcadc83aca
*: Use auto_doc_cfg instead of doc(cfg) attributes (#2983)
Co-authored-by: João Oliveira <hello@jxs.pt>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2022-10-24 13:00:20 +11:00
Max Inden
d530e5112c
*: Prepare v0.49.0 (#2931) 2022-10-14 15:30:16 +01:00
Qinxuan Chen
d9a2e6c1bd
build(deps): Update clap to v4 (#3015) 2022-10-14 15:51:23 +11:00
Thomas Eizinger
eb10af7a4b
protocols/{relay,dcutr}: Replace std::time::SystemTime with instant::SystemTime (#2991) 2022-10-12 14:09:47 +01:00
Thomas Eizinger
bdf9209824
swarm: Split off "keep alive" functionality from DummyConnectionHandler (#2859)
Previously, the `DummyConnectionHandler` offered a "keep alive" functionality,
i.e. it allowed users to set the value of what is returned from
`ConnectionHandler::keep_alive`. This handler is primarily used in tests or
`NetworkBehaviour`s that don't open any connections (like mDNS). In all of these
cases, it is statically known whether we want to keep connections alive. As
such, this functionality is better represented by a static
`KeepAliveConnectionHandler` that always returns `KeepAlive::Yes` and a
`DummyConnectionHandler` that always returns `KeepAlive::No`.

To follow the naming conventions described in
https://github.com/libp2p/rust-libp2p/issues/2217, we introduce a top-level
`keep_alive` and `dummy` behaviour in `libp2p-swarm` that contains both the
`NetworkBehaviour` and `ConnectionHandler` implementation for either case.
2022-10-05 17:50:11 +01:00
Thomas Eizinger
1b793242e6
.cargo: Run clippy on ALL the source files (#2949) 2022-10-04 18:24:38 +11:00
João Oliveira
a7a96e5502
protocols/identify: Revise symbol naming (#2927) 2022-10-04 11:17:31 +11:00
Thomas Eizinger
1da75b2b25
protocols/ping: Properly deprecate types with Ping prefix (#2937)
Co-authored-by: Elena Frank <elena.frank@protonmail.com>
Co-authored-by:  João Oliveira <hello@jxs.pt>
2022-10-01 00:19:34 +10:00
Thomas Eizinger
f6bb846c36
*: Remove default features from all crates (#2918)
Remove default features. You need to enable required features
explicitly now. As a quick workaround, you may want to use the
new `full` feature which activates all features.
2022-09-29 16:32:22 +01:00
Roman
e530118fb0
build(deps): Bump rand to 0.8 and quickcheck to 1 (#2857)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-09-22 18:48:32 +10:00
Thomas Eizinger
45faefa36c
*: Unfiy how we depend on crates across the workspace (#2886) 2022-09-19 17:32:02 +10:00
Thomas Eizinger
2c739e9bdb
protocols/noise: Introduce NoiseAuthenticated::xx constructor with X25519 DH key exchange (#2887)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-09-16 11:41:35 +10:00
Max Inden
83c67954e9
*: Prepare v0.48.0 (#2869) 2022-09-07 09:44:51 +02:00
Alexander Shishenko
8644c65a22
core/: Introduce rsa feature flag to avoid ring dependency (#2860)
- Introduce `rsa` feature flag to `libp2p-core`.
- Expose `rsa` feature in `libp2p`.
- Add `rsa` feature to `libp2p` `default`.
2022-09-07 08:16:22 +02:00
Divma
36a2773861
*: Update changelogs for prost dep update (#2851) 2022-08-30 10:03:54 +02:00
Max Inden
ca07ce4d64
swarm/behaviour: Remove deprecated NetworkBehaviourEventProcess (#2840)
Removes the `NetworkBehaviourEventProcess` and all its associated logic.

See deprecation pull request https://github.com/libp2p/rust-libp2p/pull/2784.

Find rational in https://github.com/libp2p/rust-libp2p/pull/2751.
2022-08-26 07:08:33 +02:00
Max Inden
4253080a43
*: Prepare v0.47.0 (#2830) 2022-08-22 05:14:04 +02:00
dependabot[bot]
6a9fa3d930
build(deps): Update prost requirement from 0.10 to 0.11 (#2788)
* build(deps): Update prost-build requirement from 0.10 to 0.11

Updates the requirements on [prost-build](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: prost-build
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): Update prost requirement from 0.10 to 0.11

Updates the requirements on [prost](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: prost
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-16 08:49:09 +02:00
Elena Frank
06aaea67f3
*: Fix clippy::derive-partial-eq-without-eq (#2818) 2022-08-14 04:03:04 +02:00
Thomas Eizinger
1a553db596
core/muxing: Flatten StreamMuxer interface to poll_{inbound,outbound,address_change,close} (#2724)
Instead of having a mix of `poll_event`, `poll_outbound` and `poll_close`, we
flatten the entire interface of `StreamMuxer` into 4 individual functions:

- `poll_inbound`
- `poll_outbound`
- `poll_address_change`
- `poll_close`

This design is closer to the design of other async traits like `AsyncRead` and
`AsyncWrite`. It also allows us to delete the `StreamMuxerEvent`.
2022-07-18 05:20:11 +02:00
Max Inden
d4f8ec2d48
misc/metrics: Track # connected nodes supporting specific protocol (#2734)
* misc/metrics: Explicitly delegate event recording to each recorder

This allows delegating a single event to multiple `Recorder`s. That enables e.g. the
`identify::Metrics` `Recorder` to act both on `IdentifyEvent` and `SwarmEvent`. The latter enables
it to garbage collect per peer data on disconnects.

* protocols/dcutr: Expose PROTOCOL_NAME

* protocols/identify: Expose PROTOCOL_NAME and PUSH_PROTOCOL_NAME

* protocols/ping: Expose PROTOCOL_NAME

* protocols/relay: Expose HOP_PROTOCOL_NAME and STOP_PROTOCOL_NAME

* misc/metrics: Track # connected nodes supporting specific protocol

An example metric exposed with this patch:

```
libp2p_identify_protocols{protocol="/ipfs/ping/1.0.0"} 10
```

This implies that 10 of the currently connected nodes support the ping protocol.
2022-07-15 09:16:03 +02:00
Chad Nehemiah
d0da3a0973
swarm/: Set default dial concurrency factor to 8 (#2741) 2022-07-07 11:20:03 +02:00
Max Inden
7df6bae520
*: Prepare v0.46.0 (#2730) 2022-07-05 13:09:58 +02:00
Elena Frank
62622a1bad
core/src/transport: Poll Transport directly, remove Transport::Listener (#2652)
Remove the concept of individual `Transport::Listener` streams from `Transport`.
Instead the `Transport` is polled directly via `Transport::poll`. The
`Transport` is now responsible for driving its listeners.
2022-07-04 04:16:57 +02:00
pj50
f814b21f5a
protocols/relay: Don't duplicate p2p protocol in relay reservation (#2696) (#2701) 2022-06-27 06:54:40 +02:00
Thomas Eizinger
eb490c08e9
core/muxing: Force StreamMuxer::Substream to implement Async{Read,Write} (#2707)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-06-23 21:52:11 +10:00
Max Inden
802d00e645
*: Prepare v0.45.1 (#2700) 2022-06-09 15:26:56 +02:00
Max Inden
0d3787ed04
protocols/relay: Limit inbound streams (#2698)
* protocols/relay: Use prost-codec

* protocols/relay: Respond to at most one incoming reservation request

Also changes poll order prioritizing

- Error handling over everything.
- Queued events over existing circuits.
- Existing circuits over accepting new circuits.
- Reservation management of existing reservation over new reservation
  requests.

* protocols/relay: Deny <= 8 incoming circuit requests with one per peer

* protocols/relay: Deny new circuits before accepting new circuits
2022-06-08 17:33:24 +02:00
Max Inden
6e1e314872
*: Prepare v0.45.0 (#2662) 2022-05-31 13:12:53 +02:00
Hubert
70d38520fd
*: Activate clippy::style lint group (#2620) 2022-05-03 13:11:48 +02:00
Max Inden
2ad905f35a
{core,swarm}/: Don't require Transport: Clone and take &mut (#2529)
Previously `libp2p-swarm` required a `Transport` to be `Clone`. Methods
on `Transport`, e.g. `Transport::dial` would take ownership, requiring
e.g. a `Clone::clone` before calling `Transport::dial`.

The requirement of `Transport` to be `Clone` is no longer needed in
`libp2p-swarm`. E.g.  concurrent dialing can be done without a clone per
dial.

This commit removes the requirement of `Clone` for `Transport` in
`libp2p-swarm`. As a follow-up methods on `Transport` no longer take
ownership, but instead a mutable reference (`&mut self`).

On the one hand this simplifies `libp2p-swarm`, on the other it
simplifies implementations of `Transport`.
2022-04-06 20:23:16 +02:00
dependabot[bot]
7a1147877a
build(deps): Update prost-build requirement from 0.9 to 0.10 (#2596)
* build(deps): Update prost-build requirement from 0.9 to 0.10

Updates the requirements on [prost-build](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/commits)

---
updated-dependencies:
- dependency-name: prost-build
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* .github/workflow: Don't run integration test in container

* .github/workflow: Don't run doc step in container

* .github/workflows: Remove component docs

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-04-06 15:54:42 +02:00
TotalKrill
90140a6eaf
*: Change structopt to native clap derive implementations (#2600)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-04-05 21:56:44 +02:00
dependabot[bot]
680604f3d3
build(deps): Update prost requirement from 0.9 to 0.10 (#2597)
Updates the requirements on [prost](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/commits)

---
updated-dependencies:
- dependency-name: prost
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-04-05 21:35:54 +02:00
Max Inden
f26adbcd84
*: Prepare libp2p v0.44.0 (#2604) 2022-04-04 18:27:41 +02:00
Max Inden
4d796fdca1
protocols/{dcutr,relay}: Expose error types (#2605)
Co-authored-by: canewsin <canews.in@gmail.com>
2022-04-04 11:32:54 +02:00
Max Inden
6cc3b4ec52
*: Import libp2p with default-features = false (#2574)
* *: Import `libp2p` with `default-features = false`

While not a win in most cases, it reduces compile time for tests of
individual crates.

* Cargo.toml: Set features for examples
2022-03-22 11:22:17 +01:00
Max Inden
108c970a59
protocols/relay: Remove support for Circuit Relay v1 protocol (#2549) 2022-03-11 12:12:10 +01:00
Friedel Ziegelmayer
e2fcc47da6
swarm/src/behaviour: Remove Send bound from NetworkBehaviour (#2535)
The bound is no longer needed across the libp2p-XXX crates.

Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-28 10:27:58 +01:00