2044 Commits

Author SHA1 Message Date
Thomas Eizinger
cafa37ea21
feat(noise): deprecate LegacyConfig without replacement (#3265)
As the name implies, `LegacyConfig` allows users to interact with older versions of the noise protocol. These are not interoperable and we've been supporting them for a long time now. Hopefully, users have migrated away from it since. To not directly break them, we officially deprecate now without a replacement.
2023-01-11 05:36:35 +00:00
Elena Frank
87dc7b6e51
fix(autonat): update examples (#3310)
Fix AutoNAT examples that became outdated due to #2959 and #2618.
2023-01-10 17:33:20 +00:00
João Oliveira
20ce07c7d3
refactor(dcutr): remove ActionBuilder. (#3304)
addresses #3299
2023-01-10 03:43:59 +00:00
Max Inden
8f70fedbbf
docs(README): Add João to list of maintainers (#3295)
@jxs made multiple [significant contributions](https://github.com/libp2p/rust-libp2p/pulls?q=is%3Apr+is%3Aclosed+author%3Ajxs) to rust-libp2p across the various crates and helped as a maintainer for the past 3 months. I suggest we (officially) add him to the list of rust-libp2p maintainers.
2023-01-09 14:00:43 +00:00
Max Inden
5b8c3d2901
fix(quic): Identify /quic as QUIC address (#3288)
Identify multiaddress with `/quic` (draft 29) as QUIC address in case `support_draft_29` is `true`.

Without this patch the Rust punchr client would discard any QUIC addresses with `/quic` in its `Transport::address_translation`. Thus `/quic` based observed addresses from `libp2p-identify` would not be added to the local set of external addresses and thus QUIC would not be available as a transport for hole punching.
2023-01-06 09:32:18 +00:00
dependabot[bot]
a124258851
deps: update lru requirement from 0.8.0 to 0.9.0 (#3294) 2023-01-04 19:09:43 +00:00
dependabot[bot]
ac6b78b2c9
deps: bump actions/stale from 6 to 7 (#3274) 2023-01-04 18:41:56 +00:00
Elena Frank
bda1420f1f
fix(examples): subscribe to topic in chat-tokio (#3296)
With #3097, subscribing to the floodsub topic in `examples/chat-tokio.rs` was removed. I assume this was unintentional (cc @umgefahren), so this PR adds it back.
2023-01-04 17:10:12 +00:00
Elena Frank
30640968ac
fix: typo in ExternalAddresses::on_swarm_event (#3297)
Fix typo `swarn` -> `swarm`.
2023-01-04 16:41:34 +00:00
Max Inden
dae99a59d7
fix(swarm): Remove expired addresses (#3286)
Once an address expired, don't `insert` but `remove` it from the `HashSet`.
2023-01-04 16:09:30 +00:00
Max Inden
2621528639
chore(metrics): Upgrade to prometheus-client v0.19.0 (#3207) 2023-01-03 19:42:32 +00:00
João Oliveira
9c96bbb54b
refactor(relay): revise public API to follow naming convention (#3238)
Continues addressing https://github.com/libp2p/rust-libp2p/issues/2217.
2023-01-02 20:21:46 +00:00
Thomas Eizinger
68d0f882bd
ci: install protoc from repositories where possible (#3258)
With the addition of more CI jobs, we are constantly running into API limits on setting up protoc. For all jobs that run on ubuntu, we can install it from `apt` instead.

On ubuntu 22.04, which is what `ubuntu-latest` points to, this installs `protoc v3.12.4`.
2022-12-30 12:58:28 +00:00
Thomas Eizinger
72e52f43fc
ci: ensure PR titles are no longer than 72 characters (#3267)
GitHub wraps the titles of commits if they are longer than 72 characters. See fbd4192e2a for example.

There is a convention that titles should be no more than 50 characters: https://cbea.ms/git-commit/#limit-50
This however makes crafting the message quite difficult, esp. with our use of conventional commit messages, thus limiting it to 72 seems more reasonable as that is where tooling (.e.g GitHub) seems to "break".
2022-12-30 12:05:07 +00:00
Max Inden
56b3b8fe5a
fix(kad): Skip invalid multiaddr (#3284)
With this commit `libp2p-kad` no longer discards the whole peer payload in case an addr is invalid, but instead logs the failure, skips the invalid multiaddr and parses the remaining payload.

See https://github.com/libp2p/rust-libp2p/issues/3244 for details.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2022-12-27 11:59:52 +00:00
Max Inden
e4d67c504d
fix(identify): Don't fail on unknown multiaddr protocol (#3279)
With this commit `libp2p-identify` no longer discards the whole identify payload in case a listen addr of the remote node is invalid, but instead logs the failure, skips the invalid multiaddr and parses the remaining identify payload.

This is especially relevant when rolling out a new protocol to a live network. Say that most nodes of a network run on an implementation version v1. Say that the `multiaddr` implementation is not aware of the `webrtc/` protocol. Say that a new version (v2) is rolled out to the network with support for the `webrtc/` protocol, listening via `webrtc/` by default. In such case all v1 nodes would discard all identify payloads of v2 nodes, given that the v2 identify payloads would contain the `webrtc/` protocol in their `listen_addr` addresses.

See https://github.com/libp2p/rust-libp2p/issues/3244 for details.
2022-12-24 13:20:55 +00:00
Thomas Eizinger
7dae6502ed
ci: fix typo configuration of PR validation action (#3278) 2022-12-23 20:19:57 +00:00
Thomas Eizinger
5782a96af2
refactor(swarm)!: don't be generic over Transport (#3272)
Ever since we moved `Pool` into `libp2p-swarm`, we always use it with the same `Transport`: `Boxed`. It is thus unnecessary for us to be overly generic over what kind of `Transport` we are using. This allows us to remove a few type parameters from the implementation which overall simplifies things.

This is technically a breaking change because I am removing a type parameter from two exported type aliases:

- `PendingInboundConnectionError`
- `PendingOutboundConnectionError`

Those have always only be used with `std::io::Error` in our API but it is still a breaking change.
2022-12-23 00:13:34 +00:00
StemCll
aca3454c91
refactor(gossipsub): remove derive-builder dev-dependency (#3270)
Remove the `derive_builder` dev-dependency in gossipsub. We can manually implement the builder functionality on top of the `Default` instance of `InjectNodes`.

Resolved #3228.
2022-12-22 23:47:23 +00:00
Thomas Eizinger
d5f4acc6ed
refactor(swarm): express dial logic linearly (#3253)
Previously, the logic within `Swarm::dial` involved fairly convoluted `match` expressions. This patch refactors this function to use new utility functions introduced on `DialOpts` to handle one concern at a time.

This has the advantage that we are covering slightly more cases now. Because we are parsing the `PeerId` only once at the top, checks like banning will now also act on dials that specify the `PeerId` as part of the `/p2p` protocol.
2022-12-22 16:44:58 +00:00
Thomas Eizinger
1765ae0395
feat(kademlia)!: use GATs on RecordStore trait (#3239)
Previously, we applied a lifetime onto the entire `RecordStore` to workaround Rust not having GATs. With Rust 1.65.0 we now have GATs so we can remove this workaround.

Related https://github.com/libp2p/rust-libp2p/issues/3240. Without this change, we would have to specify HRTB in various places.
2022-12-22 16:17:59 +00:00
Thomas Eizinger
65ec5454ae
ci(dependabot): disable automatic rebase of PRs (#3266)
Currently, we have dependabot configured to automatically rebase PRs as soon as the base branches changes. This however causes two problems:

1. It unnecessarily consumes CI resources because dependabot rebases all open dependency PRs at once upon every merge of a PR into `master`.
2. It does not interact well with our strategy of dismissing reviews on updates to the PR: https://github.com/libp2p/rust-libp2p/pull/3226#event-8074236930

Overall, the rebasing of dependency PRs is a way to fix merge conflicts and to ensure that CI still passes even on the latest version of the base branch. The latter is already ensured by our merge queue and the former can be triggered manually with `@dependabot rebase`, thus disabling automatic rebasing is the better configuration for our setup.
2022-12-22 15:07:13 +00:00
dependabot[bot]
1b4624f74a
deps: Update base64 requirement from 0.13.0 to 0.20.0 (#3226) 2022-12-21 03:35:25 +00:00
Thomas Eizinger
13a59a38d3
ci(caching): split caches by matrix variables (#3257)
Previously, some of the caches for these job runs were overlapping. By incorporating the relevant matrix variables into the cache key, every instance of this job gets its own cache.
2022-12-20 10:24:39 +00:00
Pasha Podolsky
929cbb4670
deps!: Update multiaddr & multihash to 0.17.0 (#3196) 2022-12-20 08:52:08 +00:00
Thomas Eizinger
93335b8818
refactor(dcutr): reshape public API to follow naming guidelines (#3214)
With this patch, the naming of types follows the guidelines discussed in #2217.
2022-12-20 05:03:40 +00:00
dependabot[bot]
06aa694d0a
deps: Bump actions/upload-pages-artifact from 1.0.6 to 1.0.7 (#3259) 2022-12-20 03:57:26 +00:00
dependabot[bot]
ee775137f3
deps(noise): Update ed25519-compact requirement from 1.0.11 to 2.0.4 (#3232) 2022-12-20 01:48:15 +00:00
Thomas Eizinger
88fa8e66b8
refactor(gossipsub): don't store messages within Arc (#3243)
Currently, we store messages to be sent to the `ConnectionHandler` in an `Arc`. However, we never actually clone these messages as we can see with this patch, hence we remove this wrapping.

Related: https://github.com/libp2p/rust-libp2p/pull/3242
2022-12-20 00:59:25 +00:00
Max Inden
de61a74d33
fix(libp2p): Don't specify monorepo dev dependencies by version (#3261)
There is no need to specify dev dependencies from the monorepo by version. Versions can be inferred from the dependencies `Cargo.toml`. Specifying the version increases maintenance overhead, as they have to be bumped manually.
2022-12-19 23:41:07 +00:00
Thomas Eizinger
5458446205
feat(noise): deprecate non-compliant implementation (#3227)
For the last [two years](https://github.com/libp2p/rust-libp2p/blob/master/CHANGELOG.md#version-0190-2020-05-18), we have been carrying around a non-compliant implementation of the noise protocol for libp2p. It is time to follow through on the announcement in that changelog entry and deprecate it. Users should use the spec compliant implementation instead.

1. This will reduce the maintenance effort of our codebase.
2. We will improve compile-times because we no longer need to depend on `libsodium` to test cryptography that is only part of the non-compliant implementation.
3. It will simplify usage of `rust-libp2p` because users cannot accidentally choose the wrong implementation.
2022-12-19 13:28:07 +00:00
Nazar Mokrynskyi
fbd4192e2a
fix(kademlia): downgrade reusable stream dropping warning to debug log (#3234)
There is nothing wrong about being near the edge of the concurrency Kademlia allows. If there was an older stream about to be reused, it doesn't mean there was anything wrong to warn about.
2022-12-19 12:54:39 +00:00
Nick Loadholtes
2dd188e897
feat(floodsub): make use of prost-codec (#3224)
This patch addresses #2500 for the `libp2p-floodsub` crate.

For this PR the existing code was upgraded to use `Framed` with the `prost_codec::Codec` as the standard codec for handling the RPC message format serialization/deserialization.
2022-12-19 11:41:38 +00:00
Anton
76abab9e20
feat: log bandwidth on substream instead of socket level (#3180)
Previously, the `with_bandwidth_logging` extension to `Transport` would track the bytes sent and received on a socket level. This however only works in conjunction with `Transport` upgrades where a separate multiplexer is negotiated on top of a regular stream.

With QUIC and WebRTC landing, this no longer works as those `Transport`s bring their own multiplexing stack. To still allow for tracking of bandwidth, we refactor the `with_bandwidth_logging` extension to count the bytes send on all substreams opened through a `StreamMuxer`. This works, regardless of the underlying transport technology. It does omit certain layers. However, there isn't necessarily a "correct" layer to count bandwidth on because you can always go down another layer (IP, Ethernet, etc).

Closes #3157.
2022-12-19 07:26:19 +00:00
Hannes
160ddc58f2
docs: Add link to rustdocs for master to README (#3197)
I added a link to the master docs to the [README](README.md).
2022-12-19 06:34:29 +00:00
Max Inden
fb45ce3773
fix(metrics): Update connections_establishment_duration buckets (#3256)
Currently the `libp2p_swarm_connections_establishment_duration` metric has the following buckets:

```
// exponential_buckets(1e-3, 2., 10)

[0.001, 0.002, 0.004, 0.008, 0.016, 0.032, 0.064, 0.128, 0.256, 0.512]
```

It is unlikely that a connection is established in 1ms, even within a datacenter. It is very likely that libp2p connection establishment takes longer than 512ms over the internet.

This commit proposes the following buckets:

```
// exponential_buckets(0.01, 1.5, 20)

[0.01, 0.015, 0.0225, 0.03375, 0.050625, 0.0759375, 0.11390625, 0.170859375, 0.2562890625,
0.38443359375, 0.576650390625, 0.8649755859375, 1.29746337890625, 1.946195068359375,
2.9192926025390626, 4.378938903808594, 6.568408355712891, 9.852612533569337, 14.778918800354004,
22.168378200531006]
```

- Buckets start at 10ms.
- Reasonably high resolution in the sub-second area.
- Largest bucket at 22s, e.g. for a relayed connection.
- Unfortunately rather obscure numbers.
2022-12-17 20:49:09 +00:00
Thomas Eizinger
67c741e050
docs(README): fix invalid markdown link (#3250) 2022-12-17 17:57:49 +00:00
Thomas Eizinger
8c139f2d3b
chore: apply suggestions from beta clippy (#3251) 2022-12-17 02:01:45 +00:00
Thomas Eizinger
56398cbb8d
ci(cache): only save caches on master branch (#3249)
Previously, we would always save certain smaller caches like clippy etc on each PR. This still amounts to a lot of caches. With this patch, we conditionally only save them when the workflow is run on the master branch. This gives most pull requests a good base to work with to speed them up significantly without us keeping around a lot of caches and have GitHub invalidate them constantly.

On master, the condition evaluates to `true` which saves the cache: https://github.com/thomaseizinger/rust-libp2p/actions/runs/3699904381/jobs/6267774899#step:5:3
On pull-requests, the condition evaluates to `false` which skips saving it: https://github.com/thomaseizinger/rust-libp2p/actions/runs/3700055536/jobs/6268096357#step:4:3
2022-12-17 00:54:20 +00:00
Thomas Eizinger
e9d5a3014f
ci(cache): override rust version in cache factory for MSRV cache (#3248)
Previously, we forgot to override the default Rust version used to the newly installed one for the MSRV cache. This caused `swatinem/rust-cache` to compute the wrong cache key. See https://github.com/libp2p/rust-libp2p/actions/runs/3697491863/jobs/6262555434#step:5:21 for example.

This caused all pull-requests to not actually find this cache and rebuild everything from scratch: https://github.com/libp2p/rust-libp2p/actions/runs/3699757580/jobs/6267459677#step:6:21

With this patch, we are now considering the correct Rust version: https://github.com/thomaseizinger/rust-libp2p/actions/runs/3699821930/jobs/6267596081#step:5:21
2022-12-16 21:25:19 +00:00
Thomas Eizinger
e960aabefa
docs(pnet): use backticks for referencing types (#3252)
With the update to Rust 1.66, rustdoc is (rightfully) complaining about us writing bad HTML. `<u8>` is interpreted as an unclosed HTML tag. See https://github.com/libp2p/rust-libp2p/actions/runs/3708901592/jobs/6286942010#step:6:1380 for example.
2022-12-16 20:37:31 +00:00
Thomas Eizinger
f6f42968e2
refactor(autonat): buffer entire actions instead of events (#3241)
Previously, we used to buffer events separately and emit actions directly. That is unnecessary. We can have a single place where we return from the `poll` loop and shove all actions into the same buffer.
2022-12-15 16:22:55 +00:00
Max Inden
856e7516ef
fix(quic): Feature flag via async-std and not async-io (#3245)
Feature flag `RECEIVE_BUFFER_SIZE` via `async-std` and not `async-io` feature.
2022-12-15 15:42:22 +00:00
Roland Kuhn
c1e68b75c0
feat(core): Log protocol upgrades on trace (#3128)
Previously, every inbound or outbound upgrade generated a log at `debug` level, without information about the upgrade.
This commit changes it such that successful upgrades are logged at `trace` level (due to ubiquitous use of OneShot handlers) and that the negotiated protocol name is included in the message.
2022-12-14 18:04:50 +00:00
Thomas Eizinger
15ad7987f2
refactor(swarm): don't use task_event_buffer_size for pending connections (#3187)
The task for a pending connection only ever sends one event into this channel: Either a success or a failure. Cloning a sender adds one slot to the capacity of the channel. Hence, we can start this capacity at 0 and have the `cloning` of the `Sender` take care of properly increasing the capacity.
2022-12-14 16:50:06 +00:00
Hannes
d79c93abdb
chore: Implement latest clippy warnings (#3220)
As I do frequently, I corrected for the latest clippy warnings. This will make sure the CI won't complain in the future. We could automate this btw and maybe run the nightly version of clippy.
2022-12-14 15:45:04 +00:00
Thomas Eizinger
be3ec6c62b
refactor(swarm)!: deprecate PollParameters where possible (#3153)
This patch deprecates 3 out of 4 functions on `PollParameters`:

- `local_peer_id`
- `listened_addresses`
- `external_addresses`

The addresses can be obtained by inspecting the `FromSwarm` event. To make this easier, we introduce two utility structs in `libp2p-swarm`:

- `ExternalAddresses`
- `ListenAddresses`

A node's `PeerId` is always known to the caller, thus we can require them to pass it in.

Related: #3124.
2022-12-14 00:50:08 +00:00
Thomas Eizinger
5fe0dc44bd
ci(caching): make caching more effective (#3215)
Currently, we create a new cache for each workflow run for each crate. That ends up blowing the maximum allowed cache size of 10GB and GitHub deletes the least-recently used cache again. Effectively, this means we don't have any caching.

This patch introduces a cache factory workflow that only runs on master and always _saves_ a new cache. The CI workflow run for pull-requests on the other hand only restore these caches but don't save them.
2022-12-13 22:37:19 +00:00
João Oliveira
f80c7141ab
feat: move Identify I/O from NetworkBehaviour to ConnectionHandler (#3208)
Addresses #2885
2022-12-13 20:24:31 +00:00
Max Inden
c39d25ea08
chore(ROADMAP): Mark Kademlia efficient querying as done (#3233)
With https://github.com/libp2p/rust-libp2p/pull/2712 merged, this can be marked as done.
2022-12-13 12:57:08 +00:00