2077 Commits

Author SHA1 Message Date
Thomas Eizinger
a25ab7e444
refactor(gossipsub): use dummy handler instead of calling new_handler (#3384)
The gossipsub tests are calling lifecycle functions of the `NetworkBehaviour` that aren't meant to be called outside of `Swarm`. This already surfaced as a problem in https://github.com/libp2p/rust-libp2p/pull/3327 and it is coming up again in https://github.com/libp2p/rust-libp2p/pull/3254 where `new_handler` gets deprecated.

Try to mitigate that by constructing a dummy handler instead. Functionally, there is no difference as in both cases, the given handler has never seen a connection.
2023-01-25 11:51:51 +00:00
João Oliveira
62c0532de6
ci: Interop tests fixes and updates pending from #3331 (#3360) 2023-01-24 22:28:57 +00:00
Thomas Eizinger
d3dc398134
refactor(relay): directly store actions instead of events (#3372)
Storing `NetworkBehaviourAction`s within the behaviour is more flexible than only storing `OutEvent`s. Additionally, I find expression-oriented code easier to reason about because it typically doesn't contain side-effects.
2023-01-24 21:00:13 +00:00
Nazar Mokrynskyi
520523b696
feat(kad): Limit number of active outbound streams (#3287)
Limit number of active outbound streams to not exceed configured number of streams.

Resolves https://github.com/libp2p/rust-libp2p/issues/3236.
2023-01-24 18:22:35 +00:00
Thomas Eizinger
687fba8b06
fix(ci): apply shorter timeout to cache download (#3376)
Sometimes, GitHub Actions gets stuck in downloading the cache. My hypothesis is that because we have so many jobs, some of them get rate-limited and end up failing the download.

Typically, GitHub Actions downloads with a speed of 100MB/s. With the maximum allowed cache size of 10GB, any cache download should not take longer than 100 seconds. With this patch, we set the timeout to 120 seconds for the continuous integration workflow.

Upon failure, the job will continue with a cache-miss which is nice because it means the workflow will continue and not fail.

More information here: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout

Example workflows:

- https://github.com/libp2p/rust-libp2p/actions/runs/3992478158/jobs/6848975863
- https://github.com/libp2p/rust-libp2p/actions/runs/3992492999/jobs/6848989008
- https://github.com/libp2p/rust-libp2p/actions/runs/3992564680/jobs/6849012006
2023-01-24 14:29:23 +00:00
Thomas Eizinger
47fe699f5e
feat(ci): download cargo-semver-checks instead of building it (#3378)
This is much quicker to execute. To keep our CI reproducible, I opted to link to a specific version instead of the "latest" release. Updating to a new version is as easy as switching out the version number in the URL.
2023-01-24 13:59:10 +00:00
Max Inden
ba4015d0d2
docs(roadmap): Update WebRTC browser-to-browser entry (#3355)
- Add dependency on WASM support and move below WASM entry
- List browser-to-browser spec dependency.
2023-01-24 11:16:45 +00:00
João Oliveira
9e1f775478
fix(autonat): Skip unparsable multiaddr (#3363)
With this commit `libp2p-autonat` no longer discards the whole remote payload in case an addr is unparsable, but instead logs the failure and skips the unparsable multiaddr.

See libp2p#3244 for details.
2023-01-24 08:49:59 +00:00
Max Inden
d73613251f
docs(roadmap): Mark WebRTC browser-to-server as done (#3357)
- Added in https://github.com/libp2p/rust-libp2p/pull/2622
- Interoperability tests added in https://github.com/libp2p/test-plans/pull/100
2023-01-24 02:51:00 +00:00
João Oliveira
d7ee0e4d35
fix(swarm)!: make on_connection_handler_event impl mandatory. (#3364)
Sorry I missed this on https://github.com/libp2p/rust-libp2p/pull/3264
2023-01-24 01:10:26 +00:00
Elena Frank
dcfa7ecf5d
feat(quic): Wake transport when adding a new dialer or listener (#3342)
Wake `quic::GenTransport` if a new dialer or listener is added.
2023-01-23 23:39:13 +00:00
Thomas Eizinger
778f7a2d1a
feat(core)!: make ConnectionIds globally unique (#3327)
Instead of offering a public constructor, users are now no longer able to construct `ConnectionId`s at all. They only public API exposed are the derived traits. Internally, `ConnectionId`s are monotonically incremented using a static atomic counter, thus no two connections will ever get assigned the same ID.
2023-01-23 16:29:41 +00:00
Max Inden
b0b035b2ff
docs(roadmap): Remove milestones section (#3359)
I suggest we remove the milestones section. @p-shahi let me know if you feel strongly about keeping it.

- Most items in milestones are either done or outdated
- Milestones are already tracked on each item
- Items are ordered by priority / date
2023-01-23 13:59:30 +00:00
Thomas Eizinger
4b41f5a994
refactor(core)!: remove EitherOutput (#3341)
The trick with this one is to use `futures::Either` everywhere where we may wrap something that implements any of the `futures` traits. This includes the output of `EitherFuture` itself. We also need to implement `StreamMuxer` on `future::Either` because `StreamMuxer`s may be the the `Output` of `InboundUpgrade`.
2023-01-23 12:31:30 +00:00
Max Inden
8d6a2fc4a9
docs(roadmap): Mark alpha QUIC as done and add quinn work (#3356)
- Implementation based on `quinn-proto` was added in https://github.com/libp2p/rust-libp2p/pull/2289
- Add new entry to evaluate using `quinn` directly
2023-01-23 07:01:59 +00:00
Max Inden
f522057a80
docs(roadmap): Remove bitswap entry (#3358)
We will not implement Bitswap anytime soon. See
https://github.com/libp2p/rust-libp2p/issues/2632#issuecomment-1309147441 for rational.
2023-01-22 21:22:33 +00:00
Thomas Eizinger
d82c2a1a7a
refactor(swarm): simplify DialOpts (#3335)
Instead of tracking an inner enum, move all fields of `Opts` into `DialOpts`, setting them directly once we construct them. This makes the getters a lot simpler to implement and reduces code duplication.
2023-01-19 23:30:09 +00:00
Thomas Eizinger
b5a3f81c3d
refactor(swarm)!: don't share event buffer for established connections (#3188)
Currently, we only have a single channel for all established connections. This requires us to construct the channel ahead of time, before we even have a connection. As it turns out, sharing this buffer across all connections actually has downsides. In particular, this means a single, very busy connection can starve others by filling up this buffer, forcing other connections to wait until they can emit an event.
2023-01-19 22:49:11 +00:00
João Oliveira
a34411c528
ci: update interop workflow (#3331)
Addresses https://github.com/libp2p/test-plans/pull/99
2023-01-19 20:20:37 +00:00
Thomas Eizinger
73cbbe2967
refactor(core)!: remove EitherFuture2 (#3340)
We can completely replace `EitherFuture2` with `EitherFuture`. `EitherFuture` itself cannot be removed for now because the `Future` implementation on `future::Either` forces both `Future`s to evaluate to the same type.
2023-01-18 10:17:18 +00:00
Thomas Eizinger
475dc80a07
refactor!: Move ConnectionId and PendingPoint to libp2p-swarm (#3346)
Both of these are only needed as part of `libp2p-swarm`. Them residing in `libp2p-core` is a left-over from when `libp2p-core` still contained `Pool`.
2023-01-18 08:56:32 +00:00
Thomas Eizinger
db2cd43826
refactor(core)!: remove EitherUpgrade (#3339)
We don't need to define our own type here, we can simply implement `UpgradeInfo`, `InboundUpgrade` and `OutboundUpgrade` on `either::Either`.
2023-01-18 02:35:07 +00:00
Thomas Eizinger
8cd14e6a3a
refactor(relay): introduce Handler::new functions (#3334) 2023-01-18 01:29:43 +00:00
Thomas Eizinger
c18939f8dc
refactor(core)!: remove EitherTransport (#3338)
We don't need to define our own type here, we can simply implement `Transport` on `either::Either`.
2023-01-18 00:58:09 +00:00
Thomas Eizinger
f4fed3880b
refactor(core)!: remove EitherError in favor of either::Either (#3337)
Defining our own `EitherError` type has no value now that `Either` provides the same implementation.

Related: https://github.com/libp2p/rust-libp2p/issues/3271
2023-01-17 23:05:59 +00:00
Thomas Eizinger
29a77164f1
fix(ci): properly escape PR title (#3318)
Within double quoted strings, bash tries to evaluate everything within backticks as a command. The GitHub security guide recommends to use an intermediary environment variable instead: https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable

See https://github.com/libp2p/rust-libp2p/actions/runs/3889880383/jobs/6638520274#step:3:11.
2023-01-17 22:13:09 +00:00
João Oliveira
735945db30
refactor(tcp): Rename TcpListenStream to ListenStream (#3324) 2023-01-17 10:58:16 +00:00
Thomas Eizinger
e3c7023350
fix(gossipsub): allow clippy beta lint (#3321)
It doesn't appear that https://github.com/rust-lang/rust-clippy/issues/10061 is going to be fixed any time soon. In the meantime, our CI is "red" which is misleading because we purposely don't require this CI check. It will however hit stable in ~ 2 weeks at which point our required clippy CI check will fail.

Suppress clippy lint with an `allow` to make it pass.
2023-01-13 12:28:04 +00:00
Thomas Eizinger
91ebe7b395
fix(ci): revert "Trigger Quic as Transport wakeup on dial" (#3322) 2023-01-13 11:31:32 +00:00
João Oliveira
4c65c7d7c7
refactor(swarm): remove deprecated inject calls (#3264)
Finishes work first started with https://github.com/libp2p/rust-libp2p/issues/2832
2023-01-12 11:21:02 +00:00
Max Inden
3cc824796d
fix(dcutr): Skip unparsable multiaddr (#3320)
With this commit `libp2p-dcutr` no longer discards the whole remote payload in case an addr is unparsable, but instead logs the failure and skips the unparsable multiaddr.

See https://github.com/libp2p/rust-libp2p/issues/3244 for details.
2023-01-12 08:46:31 +00:00
Max Inden
7665e74cdb
fix(quic): Trigger Quic as Transport wakeup on dial (#3306)
Scenario: rust-libp2p node A dials rust-libp2p node B. B listens on a QUIC address. A dials B via the `libp2p-quic` `Transport` wrapped in a `libp2p-dns` `Transport`.

Note that `libp2p-dns` in itself is not relevant here. Only the fact that `libp2p-dns` delays a dial is relevant, i.e. that it first does other async stuff (DNS lookup) before creating the QUIC dial. In fact, dialing an IP address through the DNS `Transport` where no DNS resolution is needed triggers the below just fine.

1. A calls `Swarm::dial` which creates a `libp2p-dns` dial.
2. That dial is spawned onto the connection `Pool`, thus starting the DNS resolution.
3. A continuously calls `Swarm::poll`.
4. `libp2p-quic` `Transport::poll` is called, finding no dialers in `self.dialer` given that the spawned dial is still only resolving the DNS address.
5. On the spawned connection task:
1. The DNS resolution finishes.
2. Thus calling `Transport::dial` on `libp1p-quic` (note that the DNS dial has a clone of the QUIC `Transport` wrapped in an `Arc<Mutex<_>>`).
3. That adds a dialer to `self.dialer`. Note that there are no listeners, i.e. `Swarm::listen_on` was never called.
4. `DialerState::new_dial` is called which adds a message to `self.pending_dials` and wakes `self.waker`. Given that on the last `Transport::poll` there was no `self.dialer`, that waker is empty.

Result: The message is stuck in the `DialerState::pending_dials`. The message is never send to the endpoint driver. The dial never succeeds.

This commit fixes the above, waking the `<Quic as Transport>:poll` method.
2023-01-11 14:41:34 +00:00
Thomas Eizinger
1b6c915813
refactor(gossipsub): remove unnecessary trait bounds (#3317)
Trait bounds on struct declarations should be avoided as much as possible because they creep into every reference of the type. To supply default type parameters, we don't need the trait bounds.
2023-01-11 09:53:20 +00:00
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