Commit Graph

660 Commits

Author SHA1 Message Date
94432d83ad deps: bump smallvec from 1.11.0 to 1.11.1
Pull-Request: #4551.
2023-09-25 08:33:29 +00:00
600b6af314 chore: prepare non-breaking releases
Crates to be released:

- core
- misc/futures-bounded
- misc/server
- misc/webrtc-utils
- protocols/kad
- protocols/ping
- protocols/upnp
- swarm
- transports/webrtc-websys
- transports/webrtc

Pull-Request: #4537.
2023-09-22 11:02:02 +00:00
5d740a8665 refactor(core): blanket implementation of connection upgrade
Introduces blanket implementation of `{In,Out}boundConnectionUpgrade` and uses it in transport upgrade infrastructure.

Resolves: #4307.

Pull-Request: #4316.
2023-09-20 01:36:39 +00:00
6715281d92 feat: implement Debug trait
Pull-Request: #4426.
2023-09-06 14:44:43 +00:00
d3da24f312 deps: bump pin-project from 1.1.2 to 1.1.3
Pull-Request: #4296.
2023-08-18 21:29:40 +00:00
12c98dca35 deps: bump either from 1.8.1 to 1.9.0
Pull-Request: #4243.
2023-07-24 16:02:14 +00:00
30024f38d4 fix: clippy useless_conversion and useless_vec
Pull-Request: #4190.
2023-07-16 03:31:37 +00:00
a92a801cce deps: bump smallvec from 1.10.0 to 1.11.0
Pull-Request: #4171.
2023-07-11 08:58:09 +00:00
2671375cc4 fix(core/choice): log on dial and fix listen log
- Fixes typo in `<OrTransport as Transport>::listen_on` using the word "dial" instead of "listen_on".
- Adds logging to `<OrTransport as Transport>::dial`.

Follow-up to https://github.com/libp2p/rust-libp2p/pull/4133

Pull-Request: #4164.
2023-07-10 01:47:31 +00:00
7308221237 feat(core): add logs for OrTransport when trying addresses
Currently, when trying addresses in `listen_on` via `OrTransport`, there are no logs to facilitate debugging. This PR corrects that by providing adequate logs via `std::any::type_name` method.

Resolves #4072.

Pull-Request: #4133.
2023-07-05 00:52:16 +00:00
ed4b4644d1 deps: bump pin-project from 1.1.0 to 1.1.2
Pull-Request: #4146.
2023-07-03 15:34:26 +00:00
1eedcb5fcc fix(core/transport): update doc commment
`Boxed` is not generic over the error but over `Output` (i.e. `O`) only.

Pull-Request: #4137.
2023-07-03 04:01:34 +00:00
42566869b2 chore: use path dependencies for all cyclic dev-dependencies
We have two "interface" crates in our workspace: `libp2p-core` and `libp2p-swarm`. Most crates depend on both of these. To compile the tests for this crate, we often need a concrete implementation to some of these interfaces. When specifying a workspace-inherited dependency, we don't get to choose to omit the `version` field next to the path. If a dependency is `path`-only however, it will be tripped by `cargo` during the release process which is why all of this worked before our move to workspace inheritance.

With this patch, we change the minimum amount of dependencies necessary back to `path` dependencies to allowing releasing of our crates.

Related: #4053.

Pull-Request: #4091.


  
Co-Authored-By: Thomas Eizinger <thomas@eizinger.io>
2023-06-20 06:42:53 +00:00
8776fa8766 chore: prepare libp2p v0.52.0 release
Pull-Request: #4053.


  
Co-Authored-By: Max Inden <mail@max-inden.de>
  

  
Co-Authored-By: Thomas Eizinger <thomas@eizinger.io>
2023-06-19 11:49:39 +00:00
ed14630672 feat: leverage type-safe /p2p in multiaddr
This updates `multiaddr` to version `0.19`.

Depends-On: #3656.
Depends-On: https://github.com/multiformats/rust-multiaddr/pull/83.
Resolves: #4039.

Pull-Request: #4037.
2023-06-08 01:38:18 +00:00
61128713eb feat(core): remove deprecated identity module
Related: #3647.

Pull-Request: #4040.
2023-06-06 19:22:50 +00:00
1d3db7d9a8 fix(core): remove UpgradeError from public API
Not making this private was an oversight from an earlier refactoring.

Related: #3915.

Pull-Request: #4012.
2023-06-05 15:16:04 +00:00
49eed8c4fd deps: bump once_cell from 1.17.1 to 1.18.0
Pull-Request: #4026.
2023-06-05 10:41:11 +00:00
801023f468 feat(gossipsub): allow compiling for WASM
This modification removes deprecated dependency `wasm_timer` and enables wasm compatibility on the gossibsup protocol by simply substituting the `wasm_timer::Instant` with `instant::Instant`(which supports `fn checked_add`) and `wasm_timer::Interval` with `futures_ticker::Ticker`.

Pull-Request: #3973.
2023-05-25 06:19:47 +00:00
2512b6cd18 deps: bump pin-project from 1.0.12 to 1.1.0
Pull-Request: #3937.
2023-05-15 17:49:21 +00:00
08f0b5e9c9 feat(core): make the upgrade module an implementation detail
Resolves: #3748.

Pull-Request: #3915.
2023-05-15 13:24:18 +00:00
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
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
3fde13220b feat(transport): Add GlobalOnly Transport implementation
Upstreams the `GlobalOnly` transport from @mxinden's kademlia-exporter to rust-libp2p.

Source: https://github.com/mxinden/kademlia-exporter/blob/master/src/exporter/client/global_only.rs.

Resolves: #3669.

Pull-Request: #3814.
2023-05-10 11:36:04 +00:00
15c623c29a feat(core): remove SingletonMuxer
This is effectively dead code as nothing within `rust-libp2p` uses it. Users should provide it themselves if they need it.

Pull-Request: #3883.
2023-05-08 05:10:37 +00:00
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
2d81b99c90 chore(core): remove deprecated upgrades
Related https://github.com/libp2p/rust-libp2p/issues/3647.

Pull-Request: #3867.
2023-05-02 18:11:28 +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
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
d66c8271b5 refactor(core): remove EitherIter
`EitherIter` is an implementation detail and can be removed without breaking users.

Related: https://github.com/libp2p/rust-libp2p/pull/3746.

Pull-Request: #3841.
2023-04-27 13:04:16 +00:00
fadcc43e69 refactor(core): remove InfoIterChain
This type can be replaced with std-lib components.

Related: https://github.com/libp2p/rust-libp2p/pull/3746.

Pull-Request: #3842.
2023-04-27 12:50:06 +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
e5dbeb3e08 feat(core): deprecate OptionalUpgrade
This is dead-code, we don't use it in our codebase. I am suggesting to remove it because it creates an unnecessary API surface.

Related: https://github.com/libp2p/rust-libp2p/pull/3747.
Related: https://github.com/libp2p/rust-libp2p/issues/3271.

Pull-Request: #3806.
2023-04-26 06:05:45 +00:00
585a84e182 feat(core): deprecate {In,Out}boundUpgradeExt
These functions were only used for some code in the interop-tests which is easily mitigated and perhaps even easier to understand now. We can thus deprecate these functions and their related types and thereby reduce the API surface of `libp2p-core` and the maintenance burden.

This change is motivated by the work around making protocols always strings which requires/required updates to all these upgrades.

Related #3806.
Related #3271.
Related #3745.

Pull-Request: #3807.
2023-04-25 12:26:16 +00:00
0fe9791829 feat(core): deprecate upgrade::from_fn
This functionality isn't needed anywhere in `rust-libp2p` so we can deprecate and later remove it and thus reduce our API surface. Users relying on this function can vendor it.

Pull-Request: #3747.
2023-04-19 22:07:42 +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
95fa913923 deps: bump multiaddr from 0.17.0 to 0.17.1
Pull-Request: #3688.
2023-04-04 13:38:53 +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
9d0ec7e074 deps: bump futures from 0.3.26 to 0.3.27
Pull-Request: #3597.
2023-03-13 11:35:04 +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
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
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
bc88900641 deps: update p256 requirement from 0.11.1 to 0.12.0
Pull-Request: #3336.
2023-03-01 04:34:49 +00:00
71015ee16f docs: prepare v0.51.0
A large release with lots of changes I am looking forward to. Sorry for the long release cadence.

Anything folks would like to see included that is not yet in `master`? As usual I would like to only block on bug fixes.

Pull-Request: #3491.
2023-02-24 10:42:29 +00:00
d80d92dc45 feat(ci): lint against usages of variables with underscore
Prefixing a variable with an underscore (`_`) in Rust indicates that it is not used. Through refactorings, it can sometimes happen that we do end up using such a variable. In this case, the underscore should be removed.

Clippy can help us with this.

Pull-Request: #3484.
2023-02-24 08:34:59 +00:00
6383e1e8bd deps: update base64 requirement from 0.20.0 to 0.21.0
Pull-Request: #3315.
2023-02-24 00:36:59 +00:00