Commit Graph

361 Commits

Author SHA1 Message Date
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
30d0f598ef deps: bump socket2 from 0.4.9 to 0.5.2
Pull-Request: #3873.
2023-05-03 09:00:15 +00:00
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
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
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
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
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
8a0e61e3ac deps: bump tokio from 1.27.0 to 1.28.0
Pull-Request: #3834.
2023-04-28 10:49:08 +00:00
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
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
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
5657f5c9aa fix: apply suggestions from clippy beta (1.70)
Pull-Request: #3819.
2023-04-25 09:18:40 +00:00
2065348867 deps: bump libc from 0.2.141 to 0.2.142
Pull-Request: #3815.
2023-04-24 18:09:41 +00:00
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
7144734ba6 deps: bump libc from 0.2.140 to 0.2.141
Pull-Request: #3757.
2023-04-10 14:48:34 +00:00
235043c013 deps: bump yasna from 0.5.1 to 0.5.2
Pull-Request: #3756.
2023-04-10 13:58:49 +00:00
ecb55bbd86 deps: bump hex-literal from 0.4.0 to 0.4.1
Pull-Request: #3750.
2023-04-10 11:24:08 +00:00
23c3d24610 deps: bump if-watch from 3.0.0 to 3.0.1
Pull-Request: #3730.
2023-04-09 14:27:58 +00:00
bdc618e9c7 deps: bump tempfile from 3.4.0 to 3.5.0
Pull-Request: #3720.
2023-04-05 15:35:00 +00:00
17dd72755d deps: bump tokio from 1.26.0 to 1.27.0
Pull-Request: #3729.
2023-04-05 14:37:42 +00:00
95fa913923 deps: bump multiaddr from 0.17.0 to 0.17.1
Pull-Request: #3688.
2023-04-04 13:38:53 +00:00
e350630caf deps: bump webpki-roots from 0.22.6 to 0.23.0
Pull-Request: #3723.
2023-04-04 10:23:21 +00:00
5604538357 deps: bump hex-literal from 0.3.4 to 0.4.0
Pull-Request: #3727.
2023-04-03 16:40:47 +00:00
6e93df79ae deps: bump quinn-proto from 0.9.2 to 0.9.3
Pull-Request: #3726.
2023-04-03 15:45:41 +00:00
0ff0ef7a35 deps: bump futures from 0.3.27 to 0.3.28
Pull-Request: #3725.
2023-04-03 14:43:42 +00:00
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
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
486ac8baf2 chore: prepare libp2p v0.51.2
Depends-On: #3693.

Pull-Request: #3694.
2023-03-29 13:04:18 +00:00
ce55601683 deps: bump async-io from 1.12.0 to 1.13.0
Pull-Request: #3683.
2023-03-29 10:59:41 +00:00
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
7e9581c4ef deps: bump thiserror from 1.0.39 to 1.0.40
Pull-Request: #3637.
2023-03-24 14:17:02 +00:00
0e468655a4 feat(webrtc): make Fingerprint type public
`Certificate#fingerprint()` returns `Fingerprint`, but since it's not
public, I was not able to test it in my project. I.e. before this change it was
not possible to do:

```
cert.fingerprint() == Fingerprint::raw([1u8 ...])
```

Pull-Request: #3648.
2023-03-21 22:33:43 +00:00
06d644b63d deps: bump x509-parser from 0.14.0 to 0.15.0
Pull-Request: #3640.
2023-03-20 15:30:09 +00:00
2ec5402474 feat(swarm): enforce creation of Swarm via SwarmBuilder
Mark constructors `Swarm::with_X_executor` as deprecated.
Move the deprecated functionality to `SwarmBuilder::with_X_executor`
Use `SwarmBuilder` throughout.

Resolves #3186.
Resolves #3107.

Pull-Request: #3588.
2023-03-13 19:53:14 +00:00
34d7af818b deps: bump snow from 0.9.1 to 0.9.2
Pull-Request: #3600.
2023-03-13 12:05:06 +00:00
9d0ec7e074 deps: bump futures from 0.3.26 to 0.3.27
Pull-Request: #3597.
2023-03-13 11:35:04 +00:00
2e6564f786 deps: bump libc from 0.2.139 to 0.2.140
Pull-Request: #3601.
2023-03-13 11:00:58 +00:00
3959b2ccef docs: Prepare v0.51.1 (#3594) 2023-03-12 16:42:57 +01:00
2a14df25eb feat: introduce libp2p-identity crate
This patch combines the `libp2p_core::identity` and `libp2p_core::peer_id` modules into a new crate: `libp2p-identity`.

Resolves https://github.com/libp2p/rust-libp2p/issues/3349.

Pull-Request: #3350.
2023-03-12 15:46:58 +01:00
83ef657500 fix(webrtc): gracefully handle resets of individual connections
Fixes https://github.com/libp2p/rust-libp2p/issues/3574

Pull-Request: #3575.
2023-03-10 17:40:59 +00:00
aedecf709c feat(tls): Promote to v0.1.0
Promotes `libp2p-tls` to `v0.1.0` thus removing the complexity of cargo's handling of `-alpha` releases for `libp2p-tls`.

Pull-Request: #3581.
2023-03-10 11:49:03 +00:00
0cad636eba fix: move changelog entries to correct version
Whilst https://github.com/libp2p/rust-libp2p/pull/3312 was in development, we pushed a new release out and forgot to move the changelog entries to the new version. Unfortunately, this is all still very manual until we have a solution for https://github.com/libp2p/rust-libp2p/issues/2902 so this stuff keeps happening.

Pull-Request: #3541.
2023-03-10 10:59:49 +00:00
645b229d43 deps: bump thiserror from 1.0.38 to 1.0.39
Pull-Request: #3554.
2023-03-08 12:59:53 +00:00
2c10cd838a refactor(uds): Move WASM feature flagging to root Cargo.toml
Crates that don't compile for WASM are feature flagged in the root `Cargo.toml`, expcept for `libp2p-uds`. This commit removes the inconsistency.

As a side-effect, this might help prevent bugs like https://github.com/libp2p/rust-libp2p/pull/3502 going forward.

Pull-Request: #3503.
2023-03-07 14:02:13 +00:00
6b73dac59b feat(noise): remove tests for deprecated protocol
With `0.51`, we finally officially deprecated the non-spec compliant version of noise. This one needs a very heavy dependency for testing: `libsodium-sys-stable`.

I propose to remove the tests now. The actual implementation is not yet removed because it would be a breaking change. Once we decide to make the next breaking change, we can also include the removal of the deprecated API.

Pull-Request: #3510.
2023-03-07 13:30:47 +00:00
050504fbe5 fix(libp2p-quic): pin and update tls prerelease dep
Pin libp2p-quic's tls prerelease dependency and update it

Pull-Request: #3548.
2023-03-03 20:16:00 +00:00
db82e0210e feat: migrate to quick-protobuf
Instead of relying on `protoc` and buildscripts, we generate the bindings using `pb-rs` and version them within our codebase. This makes for a better IDE integration, a faster build and an easier use of `rust-libp2p` because we don't force the `protoc` dependency onto them.

Resolves #3024.

Pull-Request: #3312.
2023-03-02 10:45:07 +00:00
52a32ffac1 fix(pnet): flush nonce in handshake
Previously, we did not flush the nonce within the handshake to the stream. This caused problems when `pnet` was composed with the websocket transport. Inserting a flush fixes these compatibility problems.

Resolves https://github.com/libp2p/rust-libp2p/issues/3475.

Pull-Request: #3476.
2023-02-28 04:34:54 +00:00
b8d95ff974 deps: bump tempfile from 3.3.0 to 3.4.0
Pull-Request: #3520.
2023-02-28 03:25:42 +00:00
1a9cf4f776 fix(uds): Bump version
https://github.com/libp2p/rust-libp2p/pull/3196/ forgot to bump `libp2p-uds`. `libp2p-uds` was updated to `libp2p-core` `v0.39.0` thus requiring the version bump.

This has happened before, see https://github.com/libp2p/rust-libp2p/pull/2720.

Pull-Request: #3502.
2023-02-24 13:21:06 +00:00