733 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
Friedel Ziegelmayer
a99718162b
protocols/kad: Improve options to efficiently retrieve (#2712) 2022-11-25 08:29:46 +00:00
Thomas Eizinger
2a5a5180e9
fix(kad): Don't wait for behaviour after receiving AddProvider (#3152)
Previously, we would erroneously always go into the `WaitingUser` (now called `WaitingBehaviour`) state after receiving a message on an inbound stream. However, the `AddProvider` message does not warrant a "response" from the behaviour. Thus, any incoming `AddProvider` message would result in a stale substream that would eventually be dropped as soon as more than 32 inbound streams have been opened.

With this patch, we inline the message handling into the upper match block and perform the correct state transition upon each message. For `AddProvider`, we go back into `WaitingMessage` because the spec mandates that we need to be ready to receive more messages on an inbound stream.

Fixes #3048.
2022-11-23 17:46:43 +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
08510dd523
mdns: update if-watch to 3.0.0 (#3096) 2022-11-18 01:12:23 +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
Thomas Eizinger
6d49bf4a53
fix: Allow libp2p-mdns to compile without feature-flags (#3131)
Currently, `libp2p-mdns` fails to compile unless we enable the `tokio` runtime feature flag. This is caused by missing `cfg` statements upstream. See https://github.com/bluejekyll/trust-dns/issues/1830.

Until this is fixed upstream, we temporarily enable the `tokio-runtime` feature of `trust-dns-proto`.
2022-11-17 12:06:30 +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
João Oliveira
5f196dd231
refactor(mdns): Parse messages using trust-dns-proto instead of dns-parse (#3102) 2022-11-14 22:35:18 +00:00
Matthias Beyer
e2737c7b71
protocols/kad: Expose NoKnownPeers (#3114) 2022-11-13 22:08:28 +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
efarg
ba14ffdd42
protocols/identify: Change default cache_size of Config to 100 (#2995)
`Config` struct's member `cache_size` now defaults to `100`.
2022-11-04 19:40:30 +00:00
João Oliveira
280c51ef83
*: Link to libp2p/specs in doc comments (#3077) 2022-11-04 10:32:41 +00:00
Nick Loadholtes
1ba9e4579d
protocols/gossipsub: Make use of prost-codec (#3070) 2022-11-04 10:12:08 +00:00
Thomas Eizinger
b528d336cd
*: Fix clippy warnings introduced by Rust 1.65 release (#3081) 2022-11-04 09:40:09 +00:00
Thomas Eizinger
53d445e61c
protocols/kademlia: Refactor stream state machines (#3074)
* Refactor `InboundSubstreamState` to implement `Stream`

This allows us to use `stream::SelectAll` instead of iterating
through the states ourselves. It also allows us to fix an existing
TODO where we don't properly close a stream.

* Refactor `OutboundSubstreamState` to implement `Stream`

* Remove unnecessary keep_alive changes

The same thing is happening further down.

* Remove code duplication in answering requests

* Debug assert that we can answer every request
2022-11-02 19:20:55 +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
João Oliveira
4a4d4ad5c9
protocols/identify: Fix Identify protocol link in module doc (#3047) 2022-10-20 14:59:30 +01: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
Hannes
87ab49e812
protocols/mdns: Update to if-watch v2.0.0 (#2978) 2022-10-05 21:23:50 +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
Hannes
da0403dc45
protocols/mdns: Removed obsolete lazy static use from mdns (#2977)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-10-05 10:26:30 +11:00
Thomas Eizinger
f13f9edeb4
protocols/identify: Fix bad changelog entries and manifest version (#2974)
Fix bad changelog entries and manifest version for libp2p-identify
2022-10-04 18:06:45 +01:00
Thomas Eizinger
a905a36cbc
protocols/mdns: Optimise InterfaceState::poll for low latency (#2939) 2022-10-04 18:45:39 +11:00
Thomas Eizinger
1b793242e6
.cargo: Run clippy on ALL the source files (#2949) 2022-10-04 18:24:38 +11:00
David D
e6da99e4f8
.github/workflows: Deny cargo doc warnings in CI (#2936)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2022-10-04 12:01:45 +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
Ryan Plauche
cce296e55e
protocols/{autonat,dcutr}: Fixing filename collision in examples (#2959)
Co-authored-by: Ryan Plauche <ryan@littlebearlabs.io>
2022-09-30 13:58:35 +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
Thomas Eizinger
b28ab2c6bc
build(deps): Update lru to 0.8.0 (#2908)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-09-27 11:39:10 +10: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
Hannes
c81b06a9b2
*: Fix various clippy warnings (#2900) 2022-09-16 16:30:11 +02: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
Dmitry Markin
5906140d38
protocols/kad: Remove deprecated set_protocol_name() (#2866) 2022-09-15 15:30:32 +02:00
Roman
72bade1799
build(deps): Update env_logger to 0.9 and criterion to 0.4 (#2896) 2022-09-14 13:01:41 +10:00
Alexander Shishenko
c650dc19db
*: Replace _serde with dep:serde in Cargo.toml (#2868) 2022-09-08 18:30:43 +10:00
Max Inden
83c67954e9
*: Prepare v0.48.0 (#2869) 2022-09-07 09:44:51 +02:00
Thomas Eizinger
2eca38cca0
core/upgrade/: Add ReadyUpgrade (#2855) 2022-09-07 09:08:23 +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
Alexander Shishenko
b8c3b282ee
protocols/gossipsub: Allow publishing to anything that implements Into<TopicHash> (#2862) 2022-09-05 06:31:13 +02:00
Dmitry Markin
cee199afca
protocols/kad: Support multiple protocol names (#2846)
Add support for multiple Kademlia protocol names to allow
protocol name upgrades.
2022-09-03 02:46:50 +02:00