380 Commits

Author SHA1 Message Date
dependabot[bot]
61725ca772
deps: bump wasm-bindgen-futures from 0.4.35 to 0.4.36
Pull-Request: #3968.
2023-05-22 19:28:36 +00:00
dependabot[bot]
ba5ca84292
deps: bump js-sys from 0.3.62 to 0.3.63
Pull-Request: #3969.
2023-05-22 19:08:57 +00:00
dependabot[bot]
9867fcebb6
deps: bump quinn-proto from 0.9.3 to 0.10.1
Pull-Request: #3938.
2023-05-22 08:47:51 +00:00
dependabot[bot]
a2ad916bc4
deps: bump wasm-bindgen from 0.2.85 to 0.2.86
Pull-Request: #3961.
2023-05-18 16:05:23 +00:00
dependabot[bot]
74fa48b43f
deps: bump tokio from 1.28.0 to 1.28.1
Pull-Request: #3931.
2023-05-18 15:47:10 +00:00
dependabot[bot]
b3fa954d4b
deps: bump libc from 0.2.143 to 0.2.144
Pull-Request: #3932.
2023-05-18 15:08:56 +00:00
Thomas Eizinger
fbd471cd79
feat(websocket): remove deflate compression option
This option is the only reason we pull in a dependency on the shared `zlib` library. Unfortunately, we cannot use a pure Rust backend here because that one does not support configuring the window bits of the deflate algorithm which is used in the deflate websocket extension.

Using websockets in libp2p is already crazy inefficient because you end up with double encryption when using `/wss` (which is enforced by browsers if your website is served via https). A good encryption algorithm like noise or TLS produces an output that looks completely random. Any attempt in compressing this is pretty much wasted CPU power.

Thus, I think removing this configuration option does not really hurt and allows us to remove the dependency on the `zlib` shared library.

Pull-Request: #3949.
2023-05-16 09:40:00 +00:00
dependabot[bot]
3f88fb6059
deps: bump js-sys from 0.3.61 to 0.3.62
Pull-Request: #3930.
2023-05-15 21:00:03 +00:00
dependabot[bot]
2512b6cd18
deps: bump pin-project from 1.0.12 to 1.1.0
Pull-Request: #3937.
2023-05-15 17:49:21 +00:00
dependabot[bot]
3021814e6b
deps: bump socket2 from 0.5.2 to 0.5.3
Pull-Request: #3934.
2023-05-15 17:30:19 +00:00
dependabot[bot]
86ea8fe4aa
deps: bump wasm-bindgen-futures from 0.4.34 to 0.4.35
Pull-Request: #3935.
2023-05-15 17:08:16 +00:00
Thomas Eizinger
5c785b92e7
feat(plaintext): remove Plaintext1Config
`Plaintext2Config` works with the upgrade infrastructure and is thus preferable.

Related: #3915.

Pull-Request: #3940.
2023-05-15 12:38:44 +00:00
Thomas Coratger
6e36e8aa35
feat(swarm): rename associated types for message passing
Previously, the associated types on `NetworkBehaviour` and `ConnectionHandler` carried generic names like `InEvent` and `OutEvent`. These names are _correct_ in that `OutEvent`s are passed out and `InEvent`s are passed in but they don't help users understand how these types are used.

In theory, a `ConnectionHandler` could be used separately from `NetworkBehaviour`s but that is highly unlikely. Thus, we rename these associated types to indicate, where the message is going to be sent to:

- `NetworkBehaviour::OutEvent` is renamed to `ToSwarm`: It describes the message(s) a `NetworkBehaviour` can emit to the `Swarm`. The user is going to receive those in `SwarmEvent::Behaviour`.
- `ConnectionHandler::InEvent` is renamed to `FromBehaviour`: It describes the message(s) a `ConnectionHandler` can receive from its behaviour via `ConnectionHandler::on_swarm_event`. The `NetworkBehaviour` can send it via the `ToSwarm::NotifyHandler` command.
- `ConnectionHandler::OutEvent` is renamed to `ToBehaviour`: It describes the message(s) a `ConnectionHandler` can send back to the behaviour via the now also renamed `ConnectionHandlerEvent::NotifyBehaviour` (previously `ConnectionHandlerEvent::Custom`)

Resolves: #2854.

Pull-Request: #3848.
2023-05-14 10:58:08 +00:00
Darius Clark
5b32c8a0d2
feat(transport): allow ListenerId to be user-controlled
`Transport::listen_on` is an asynchronous operation. It returns immediately but the actual process of establishing a listening socket happens as part of `Transport::poll` which will return one or more `TransportEvent`s related to a particular `listen_on` call.

Currently, `listen_on` returns a `ListenerId` which allows the user of the `Transport` interface to correlate the events with a particular `listen_on` call. This "user" is the `Swarm` runtime. Currently, a user of libp2p establishes a new listening socket by talking to the `Swarm::listen_on` interface and it is not possible to do the same thing via the `NetworkBehaviour` trait.

Within the `NetworkBehaviour` trait, we emit _commands_ to the `Swarm` like `ToSwarm::Dial`. These commands don't have a "return value" like a synchronous function does and thus, if we were to add a `ToSwarm::ListenOn` command, it could not receive the `ListenerId` from the `Transport`.

To fix this and to be consistent with our [coding guidelines](https://github.com/libp2p/rust-libp2p/blob/master/docs/coding-guidelines.md#allow-correlating-asynchronous-responses-to-their-requests) we change the interface of `Transport::listen_on` to require the user to pass in a `ListenerId`. This will allow us to construct a command in a `NetworkBehaviour` that remembers this ID which enables precise tracking of which events containing a `ListenerId` correlate which a particular `listen_on` command.

This is especially important in the context of listening on wildcard addresses like `0.0.0.0` because we end up binding to multiple network interfaces and thus emit multiple events for a single `listen_on` call.

Pull-Request: #3567.
2023-05-14 09:42:51 +00:00
Thomas Eizinger
1bf6264cbe
feat: properly encapsulate quick_protobuf::Error
I noticed that we also still leak that dependency in several crates by providing a `From` impl so I've removed that one as well.

Resolves #3534.

Pull-Request: #3894.
2023-05-12 02:26:01 +00:00
dependabot[bot]
b3caae5a88
deps: bump libc from 0.2.142 to 0.2.143
Pull-Request: #3892.
2023-05-08 10:22:04 +00:00
Thomas Eizinger
b507fe298f
feat(noise): remove deprecated legacy handshakes
This patch removes all deprecated legacy code from `libp2p-noise` and attempts to collapse all the abstraction layers into something a lot simpler.

Pull-Request: #3511.
2023-05-08 05:30:15 +00:00
Thomas Eizinger
2130923aa5
ci: remove protoc installation
With all crates have received a release since https://github.com/libp2p/rust-libp2p/issues/3024, building the baseline rustdoc no longer required `protoc` and we can thus remove it from our CI entirely.

Resolves #3539.

Pull-Request: #3858.
2023-05-08 04:08:44 +00:00
Thomas Coratger
14938043cf
feat(identity): make Keypair and Publickey opaque
`Keypair` and `Publickey` are rendered opaque:
- `Keypair` is replaced by a private `KeyPairInner` enum that is encapsulated inside the `Keypair` `pub struct`
- `Publickey` is replaced by a private `PublickeyInner` enum that is encapsulated inside the `Publickey` `pub struct`

Resolves #3860.

Pull-Request: #3866.
2023-05-05 20:17:47 +00:00
Thomas Eizinger
c93f753018
feat: replace ProtocolName with AsRef<str>
Previously, a protocol could be any sequence of bytes as long as it started with `/`. Now, we directly parse a protocol as `String` which enforces it to be valid UTF8.

To notify users of this change, we delete the `ProtocolName` trait. The new requirement is that users need to provide a type that implements `AsRef<str>`.

We also add a `StreamProtocol` newtype in `libp2p-swarm` which provides an easy way for users to ensure their protocol strings are compliant. The newtype enforces that protocol strings start with `/`. `StreamProtocol` also implements `AsRef<str>`, meaning users can directly use it in their upgrades.

`multistream-select` by itself only changes marginally with this patch. The only thing we enforce in the type-system is that protocols must implement `AsRef<str>`.

Resolves: #2831.

Pull-Request: #3746.
2023-05-04 04:47:11 +00:00
dependabot[bot]
30d0f598ef
deps: bump socket2 from 0.4.9 to 0.5.2
Pull-Request: #3873.
2023-05-03 09:00:15 +00:00
Thomas Eizinger
4ca888580c
refactor(noise): implement tests using futures_ringbuf
Instead of creating a connection via a TCP transport, we can use the `futures_ringbuf` crate and run the noise encryption on an in-memory transport. This removes the dependency on the `libp2p_core::upgrade::apply` function and takes less code to implement.

Related #3748.

Pull-Request: #3773.
2023-05-02 12:15:22 +00:00
Thomas Eizinger
996b5c8bd0
chore: leverage cargo's workspace inheritance
Previously, we would specify the version and path of our workspace dependencies in each of our crates. This is error prone as https://github.com/libp2p/rust-libp2p/pull/3658#discussion_r1153278072 for example shows. Problems like these happened in the past too.

There is no need for us to ever depend on a earlier version than the most current one in our crates. It thus makes sense that we manage this version in a single place.

Cargo supports a feature called "workspace inheritance" which allows us to share a dependency declaration across a workspace and inherit it with `{ workspace = true }`.

We do this for all our workspace dependencies and for the MSRV.

Resolves #3787.

Pull-Request: #3715.
2023-05-02 09:14:14 +00:00
Max Inden
2d9ae3800f
chore: prepare patch releases on top of v0.51.3
Note that this does not release v0.51.4, i.e. there is no patch release of the meta crate `libp2p`.

Pull-Request: #3854.
2023-05-01 02:56:32 +00:00
Thomas Eizinger
b1cdf8d4bb
feat(yamux): rename symbols to follow module-based naming convention
Implements our naming convention for the `libp2p-yamux` crate.

Related: #2217.

Pull-Request: #3852.
2023-05-01 02:25:52 +00:00
Thomas Eizinger
2f5270ba76
feat(noise): deprecate all handshake patterns apart from XX
In the libp2p specs, the only handshake pattern that is specified is the XX handshake. Support for other handshake patterns can be added through external modules. While we are at it, we rename the remaining types to following the laid out naming convention.

The tests for handshakes other than XX are removed. The handshakes still work as we don't touch them in this patch.

Related #2217.

Pull-Request: #3768.
2023-04-28 13:50:31 +00:00
dependabot[bot]
8a0e61e3ac
deps: bump tokio from 1.27.0 to 1.28.0
Pull-Request: #3834.
2023-04-28 10:49:08 +00:00
Thomas Eizinger
4dd2e0eb59
refactor(plaintext): implement tests with futures_ringbuf
Instead of doing an entire connection establishment dance, we simply use a futures-aware ringbuffer to implement the test. This removes the dependency of `libp2p-plaintext` on the `libp2p_core::upgrade::apply` function.

Related #3748.

Pull-Request: #3770.
2023-04-26 13:12:57 +00:00
Thomas Eizinger
7fa8beff21
refactor(deflate): implement tests with futures_ringbuf
Previously, we used a TCP transport to test the deflate compression. Really, all we need is an in-memory ringbuffer that we can plug in at both ends. This PR uses `futures_ringbuf` for that.

Related #3748.

Pull-Request: #3771.
2023-04-26 12:37:28 +00:00
Thomas Eizinger
135942d319
chore: enforce unreachable_pub lint
The `unreachable_pub` lint makes us aware of uses of `pub` that are not actually reachable from the crate root. This is considered good because it means reading a `pub` somewhere means it is actually public API. Some of our crates are quite large and keeping their entire API surface in your head is difficult.

We should strive for most items being `pub(crate)`. This lint helps us enforce that.

Pull-Request: #3735.
2023-04-26 07:31:56 +00:00
Thomas Eizinger
5657f5c9aa
fix: apply suggestions from clippy beta (1.70)
Pull-Request: #3819.
2023-04-25 09:18:40 +00:00
dependabot[bot]
2065348867
deps: bump libc from 0.2.141 to 0.2.142
Pull-Request: #3815.
2023-04-24 18:09:41 +00:00
DrHuangMHT
058c2d85ec
refactor(identity): follow naming conventions for conversion methods
This PR renames some method names that don't follow Rust naming conventions or behave differently from what the name suggests:
- Enforce "try" prefix on all methods that return `Result`.
- Enforce "encode" method name for methods that return encoded bytes.
- Enforce "to_bytes" method name for methods that return raw bytes.
- Enforce "decode" method name for methods that convert encoded key.
- Enforce "from_bytes" method name for methods that convert raw bytes.

Pull-Request: #3775.
2023-04-14 08:55:13 +00:00
dependabot[bot]
7144734ba6
deps: bump libc from 0.2.140 to 0.2.141
Pull-Request: #3757.
2023-04-10 14:48:34 +00:00
dependabot[bot]
235043c013
deps: bump yasna from 0.5.1 to 0.5.2
Pull-Request: #3756.
2023-04-10 13:58:49 +00:00
dependabot[bot]
ecb55bbd86
deps: bump hex-literal from 0.4.0 to 0.4.1
Pull-Request: #3750.
2023-04-10 11:24:08 +00:00
dependabot[bot]
23c3d24610
deps: bump if-watch from 3.0.0 to 3.0.1
Pull-Request: #3730.
2023-04-09 14:27:58 +00:00
dependabot[bot]
bdc618e9c7
deps: bump tempfile from 3.4.0 to 3.5.0
Pull-Request: #3720.
2023-04-05 15:35:00 +00:00
dependabot[bot]
17dd72755d
deps: bump tokio from 1.26.0 to 1.27.0
Pull-Request: #3729.
2023-04-05 14:37:42 +00:00
dependabot[bot]
95fa913923
deps: bump multiaddr from 0.17.0 to 0.17.1
Pull-Request: #3688.
2023-04-04 13:38:53 +00:00
dependabot[bot]
e350630caf
deps: bump webpki-roots from 0.22.6 to 0.23.0
Pull-Request: #3723.
2023-04-04 10:23:21 +00:00
dependabot[bot]
5604538357
deps: bump hex-literal from 0.3.4 to 0.4.0
Pull-Request: #3727.
2023-04-03 16:40:47 +00:00
dependabot[bot]
6e93df79ae
deps: bump quinn-proto from 0.9.2 to 0.9.3
Pull-Request: #3726.
2023-04-03 15:45:41 +00:00
dependabot[bot]
0ff0ef7a35
deps: bump futures from 0.3.27 to 0.3.28
Pull-Request: #3725.
2023-04-03 14:43:42 +00:00
Max Inden
d7396706d0
fix(changelog): Make release heading levels consistent
See `##` for release headings everywhere. This is consistent with markdown conventions of one `#` per document and in line with https://keepachangelog.com/.

See report in https://github.com/libp2p/rust-libp2p/issues/3531.

Pull-Request: #3561.
2023-03-30 21:04:01 +00:00
Thomas Eizinger
dfa7bd6b57
refactor: don't depend on multihash features
All we need from the multihash is for it to be a data structure that we pass around. We only ever use the identity "hasher" and the sha256 hasher. Those are easily implemented without depending the (fairly heavy) machinery in `multihash`.

Unfortunately, this patch by itself does not yet lighten our dependency tree because `multiaddr` activates those features unconditionally. I opened a companion PR for this: https://github.com/multiformats/rust-multiaddr/pull/77.

https://github.com/multiformats/rust-multiaddr/pull/77 is another breaking change and we are trying to delay those at the moment. However, it will (hopefully) land eventually which should then be much easier to implement.

Fixes #3276.

Pull-Request: #3514.
2023-03-30 17:47:35 +00:00
Max Inden
486ac8baf2
chore: prepare libp2p v0.51.2
Depends-On: #3693.

Pull-Request: #3694.
2023-03-29 13:04:18 +00:00
dependabot[bot]
ce55601683
deps: bump async-io from 1.12.0 to 1.13.0
Pull-Request: #3683.
2023-03-29 10:59:41 +00:00
Max Inden
1a85e24ef9
fix(quic): Downgrade driver shutdown log line from info to debug
No need to inform the user each time the quic socket driver is shutting down.

Pull-Request: #3672.
2023-03-24 17:09:22 +00:00
dependabot[bot]
7e9581c4ef
deps: bump thiserror from 1.0.39 to 1.0.40
Pull-Request: #3637.
2023-03-24 14:17:02 +00:00