2044 Commits

Author SHA1 Message Date
Thomas Eizinger
868c3805b8
ci: enforce PR titles to follow the conventional commit specification (#3204)
As per decision in https://github.com/libp2p/rust-libp2p/pull/3083, we want to use the conventional commits in our repository. To make sure this actually happens, this patch adds a workflow that validates PR titles to follow this convention. Together with our mergify configuration, these PR titles end up being the commit message title when squash-merging a pull request.

Related: https://github.com/libp2p/rust-libp2p/pull/3083
Related: https://github.com/libp2p/github-mgmt/pull/93
2022-12-13 12:37:15 +00:00
João Oliveira
f828db60cb
refactor(request-response): revise public API to follow naming convention (#3159) 2022-12-13 12:11:42 +00:00
Thomas Eizinger
cbf0a273cd
ci(mergify): dismiss approvals on push once send-it is applied (#3231)
Currently, a user can push code after it has been approved and the send-it label applied. We only want to merge code that we actually looked at. Use mergify to dismiss approvals in such circumstances.
2022-12-13 22:33:37 +11:00
Thomas Eizinger
bffe4153bc
fix(dcutr): rename error types to bypass cargo-semver-checks hickup (#3213)
`cargo semver-checks` is still missing features in regards to properly detecting renamed exports. To make our CI pass again, we remove the renamed export, replace it with type-aliases and deprecate them to point users types exported under a module which now follows the conventions set in #2217.
2022-12-13 04:14:57 +00:00
João Oliveira
7dedc351d7
fix: feature-gate symbols to resolve dead-code warning (#3175) 2022-12-13 01:33:00 +00:00
Thomas Eizinger
d7363a53d3
fix: Remove circular dependencies across workspace (#3023)
Circular dependencies are problematic in several ways:

- They result in cognitive overhead for developers, in trying to figure out what depends on what.
- They present `cargo` with limits in what order the crates can be compiled in.
- They invalidate build caches unnecessarily thus forcing `cargo` to rebuild certain crates.
- They cause problems with tooling such as `release-please`.

To actually break the circular dependencies, this patch inlines the uses of `development_transport` in the examples and tests for all sub-crates. This is only meant to be a short-term fix until https://github.com/libp2p/rust-libp2p/issues/3111 and https://github.com/libp2p/rust-libp2p/pull/2888 are fixed.

To ensure we don't accidentally reintroduce this dependency, we add a basic CI that queries `cargo metadata` using `jq`.

Resolves https://github.com/libp2p/rust-libp2p/issues/3053.
Fixes https://github.com/libp2p/rust-libp2p/issues/3223.
Related: https://github.com/libp2p/rust-libp2p/pull/2918#discussion_r976514245
Related: https://github.com/googleapis/release-please/issues/1662
2022-12-12 20:58:01 +00:00
John Turpish
f8f19baad0
time to establish connection (#3134)
Implementing #2745 , adding  a metric to break down time from connection pending to connection established, per protocol stack.

````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1

lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 14:40:36 +00:00
Piotr Galar
63ffc7fb0f
docs: update security policy with private vulnerability reports info (#3168)
This PR updates the security policy to encourage users to file security vulnerability reports through https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability

The private vulnerability reports will show up here: https://github.com/libp2p/rust-libp2p/security/advisories?state=triage
The maintainers will receive GitHub notification about new private vulnerability reports.
2022-12-12 14:17:05 +00:00
dependabot[bot]
2c8a41c256
build(deps): Bump actions/upload-pages-artifact from 1.0.4 to 1.0.6 (#3219) 2022-12-12 12:22:48 +00:00
Max Inden
7c10942058
chore: Bump libp2p-swarm dependents (#3225)
Follow-up to https://github.com/libp2p/rust-libp2p/pull/3170#issuecomment-1344847006
2022-12-12 11:30:23 +00:00
Max Inden
4fe518de86
feat!: Remove simple::SimpleProtocol (#3191)
Due to lack of usage, remove the `simple::SimpleProtocol`. Users may look at `libp2p::core::upgrade`
for alternatives.
2022-12-09 18:56:30 +01:00
Hannes
8cb79f4c79
chore(swarm): Remove deprecated functions (#3170)
Remove functions deprecated in 0.41.0.
2022-12-09 15:44:08 +01:00
Thomas Eizinger
1c2712c1bc
ci: fix path to interop test plan composition file (#3203) 2022-12-07 12:47:30 +01:00
Thomas Eizinger
4da65089f8
fix(ci): avoid rate limits on GitHub API by supplying auth token (#3199)
Supply token to protoc install.
2022-12-07 09:44:50 +01:00
Justin Restivo
5755942d77
chore(README): Add HotShot as notable user (#3184) 2022-12-06 13:14:37 +01:00
Elena Frank
dfc5ec8e7d
feat(quic): Add draft-29 support (#3151)
Add support for QUIC draft-29 / the `quic` codepoint.  This enables both dialing and listening on `quic` addresses.
The motivation for adding support is to allow users to connect to old go-libp2p nodes that don't support the `quic-v1` codepoint.

**Per default support is disabled.**
2022-12-02 20:43:04 +01:00
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
Hannes
82a9e2cc74
feat: Host rustdoc of master on GitHub pages (#3126)
This PR hosts the documentation of the current master branch on GitHub Pages. The URL should be: https://libp2p.github.io/rust-libp2p
2022-12-02 15:40:35 +01:00
Max Inden
be0b62a78f
fix(derive): Release breaking change as v0.31.0 (#3178)
`libp2p-swarm-derive` released a breaking change (https://github.com/libp2p/rust-libp2p/pull/3011)
as a patch release `v0.30.2`.

This patch:

1. Prepares a new minor release of `libp2p-swarm-derive`.
2. Prepares a patch release for `libp2p-swarm` to use the minor release of `libp2p-swarm-derive`.

As a follow up we can yank the `libp2p-swarm-derive` `v0.30.2` release. In addition we might want to
release `libp2p-swarm-derive` `v0.30.3` containing all patches but https://github.com/libp2p/rust-libp2p/pull/3011.
2022-11-29 17:45:58 +01:00
Max Inden
5b4eab7baf
fix(tls): add description and repository to Cargo.toml (#3167) 2022-11-25 11:12:46 +01:00
Max Inden
87308f0bc8
chore: Prepare rust-libp2p v0.50.0 release (#3163) 2022-11-25 09:37:55 +00:00
Elena Frank
7b9611e130
fix(quic): allow closing stream after remote dropped it (#3164)
- Only send `STOP_SENDING` on a stream when dropping it if the remote did not finish the stream yet.
- Only call `quinn_proto::SendStream::finish` once. (A second call to it will always fail. Though I don't think this was the issue in #3144.)
- Add tests for reading and writing to streams after the remote dropped. Also adds a smoke test for backpressure.

Fixes #3144.
2022-11-25 09:05:50 +00:00
Friedel Ziegelmayer
a99718162b
protocols/kad: Improve options to efficiently retrieve (#2712) 2022-11-25 08:29:46 +00:00
Hannes
cff84f1897
feat(swarm): Add wasm-bindgen executor (#3115) 2022-11-24 22:12:35 +00:00
Max Inden
98336b7885
Revert "chore: Enforce conventional commit PR title" (#3165)
Revert "chore: Enforce conventional commit PR title (#3083)"

This reverts commit 611286be819b9bbca6acc793e420cafaea8eb0cd.
2022-11-24 21:26:33 +01:00
Thomas Eizinger
611286be81
chore: Enforce conventional commit PR title (#3083) 2022-11-23 20:32:27 +01:00
Hannes
76dba1773b
fix(swarm): Make executors pub and add convenience constructors for SwarmBuilder (#3155)
Addresses issues raised here: https://github.com/libp2p/rust-libp2p/pull/3097#discussion_r1026526312
2022-11-23 18:19:22 +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
Anton Kaliaev
babacc5555
fix(webrtc): Don't append /p2p to listen addresses (#3154)
This aligns with what other transports do.

Related: https://github.com/libp2p/rust-libp2p/pull/2622#discussion_r1024844957.
2022-11-23 16:33:36 +00:00
Michael G
b99a2137ac
docs(swarm): Reword Swarm top-level doc string (#3132) 2022-11-23 02:16:40 +00:00
Thomas Eizinger
2c96d644f9
feat: Better error reporting when features are disabled (#2972)
In case support for e.g. RSA keys is disabled at compile-time, we will now print a better error message. For example:

> Failed to dial Some(PeerId("QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt")): Failed to negotiate transport protocol(s): [(/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt): : Handshake failed: Handshake failed: Invalid public key: Key decoding error: RSA keys are unsupported)]

Fixes #2971.
2022-11-23 00:51:47 +00:00
Predrag Gruevski
9b182778e1
chore(ci): Add --locked flag to cargo install step (#3129)
This PR tweaks the installation of `cargo-semver-checks` to make it use the `--locked` flag.

Installing binaries with their locked dependency versions makes it less likely that you might run into issues caused by bugs in dependency libraries, since your installed dependency versions match the versions used in the binary's own test environment.

This is a recommendation that applies to most Rust binary tools. For example, here's cargo-nextest recommending the same: https://nexte.st/book/installing-from-source.html#installing-from-cratesio
2022-11-20 21:48:24 +00:00
Thomas Eizinger
8678dc7569
chore(meta): Remove unnecessary quic module (#3139) 2022-11-18 19:40:10 +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
Thomas Eizinger
05c079422e
fix(webrtc): Don't emit addresses from other interfaces (#3142)
Previously, we would always run `IfWatcher`, even if we were only listening on a specific interface. This patch fixes this behaviour and aligns it with how `libp2p-quic` operates.
2022-11-18 10:24:46 +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
Anton Kaliaev
a714864885
feat: Add WebRTC transport (#2622)
Hey 👋 This is a WebRTC transport implemented in accordance w/ the [spec](https://github.com/libp2p/specs/pull/412). It's based on the [webrtc-rs](https://github.com/webrtc-rs/webrtc) library.

Resolves: #1066.
2022-11-17 05:17:31 +00:00
Thomas Eizinger
43fdfe27ea
chore(mergify): Don't ask dependabot to resolve conflicts (#3122) 2022-11-16 10:28:03 +11:00
John Turpish
69efe63229
misc/metrics: Add protocols label to address-specific metrics (#2982)
Previously, we would only track the metrics like the number of open connections. With this patch, we extend these metrics with a `protocols` label that contains a "protocol stack". A protocol stack is a multi-address with all variable parts removed. For example, `/ip4/127.0.0.1/tcp/1234` turns into `/ip4/tcp`.

Resolves https://github.com/libp2p/rust-libp2p/issues/2758.
2022-11-15 20:45:14 +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
Roland Kuhn
d8fe7bf49f
transports/tcp: Update if-watch to v3.0.0 (#3101)
Update to `if-watch` version 3.0.0 and pass through features, such that `libp2p-tcp/async-io` selects `if-watch/smol` and `libp2p-tcp/tokio` brings in `if-watch/tokio`.
The mDNS part is already done in #3096.
2022-11-15 12:34:38 +00:00
Matthias Beyer
ca8bcd8288
core: Expose peer_id::ParseError (#3113) 2022-11-15 11:58:42 +00:00
Thomas Eizinger
9dadf5c830
muxers/yamux: Mitigation of unnecessary stream drops (#3071) 2022-11-15 10:40:55 +00:00
yojoe
368705a146
docs(core): Document byte format of PeerId (#3084)
PeerId data is more than just a multihash of the public key.

See discussion: https://github.com/libp2p/rust-libp2p/discussions/3079
2022-11-15 01:22:11 +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
Thomas Eizinger
5b3612bb29
test: Remove dialer_can_receive stream muxer test (#3108)
Various muxer implementations struggle to fulfill this test. In practice, it doesn't matter much because we always run `multistream-select` on top of a newly negotiated stream so we never end up actually reading from a stream that we have never written to.

Relevant discussion: https://github.com/kpp/rust-libp2p/pull/27#discussion_r1012128418
2022-11-14 21:09:19 +00:00
Roman
0f5c491d91
feat(transports/quic): Add implementation based on quinn-proto (#2289)
Co-authored-by: Demi Marie Obenour <demiobenour@gmail.com>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: David Craven <david@craven.ch>
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: elenaf9 <elena.frank@protonmail.com>
Co-authored-by: Marco Munizaga <marco@marcopolo.io>
2022-11-14 13:12:16 +01:00