2359 Commits

Author SHA1 Message Date
DrHuangMHT
b8411d173f
feat(identity): allow importing and exporting secp256k1 keys
Related: #3681

Pull-Request: #3887.
2023-05-05 13:17:46 +00:00
Thomas Eizinger
eecfe2f094
feat(swarm): report outcome of handling SwarmEvent
Previously, a user wouldn't know whether passing a `SwarmEvent` to `ListenAddresses` or `ExternalAddresses` changed the state. We now return a boolean where `true` indicates that we handled the event **and** changed state as a result.

The API is inspired by `HashSet::insert` and the like.

Pull-Request: #3865.
2023-05-05 07:46:31 +00:00
DrHuangMHT
1eb929b38a
feat(identity): allow importing and exporting ECDSA keys
Implement encoding to/decoding from DER-encoded secret key document for `ecdsa::SecretKey`.
Implement encoding to/decoding from protobuf format for ECDSA keys.
Bump dependency `p256` from 0.12 to 0.13.
Bump dependency `sec1` from 0.3.0 to 0.7

Related: #3681.

Pull-Request: #3863.
2023-05-04 18:36:05 +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
dependabot[bot]
8acbabdaf6
deps: bump clap from 4.2.6 to 4.2.7
Pull-Request: #3870.
2023-05-02 19:57:44 +00:00
dependabot[bot]
6a22bd3df0
deps: bump clap from 4.2.5 to 4.2.6
Pull-Request: #3869.
2023-05-02 19:38:16 +00:00
dependabot[bot]
55e8aea237
deps: bump prometheus-client from 0.19.0 to 0.20.0
Pull-Request: #3754.
2023-05-02 18:49:51 +00:00
Thomas Eizinger
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
Thomas Eizinger
62a06f9ac0
fix(ci): use env variables to ensure escaping
Environment variables are properly escaped in GitHub, thus reducing the risk of code injection.

Pull-Request: #3790.
2023-05-02 17:36:35 +00:00
Hannes
4bd4653fa9
chore(request-response): remove deprecated items
Related: https://github.com/libp2p/rust-libp2p/issues/3647.

Pull-Request: #3703.
2023-05-02 16:17:15 +00:00
Hannes
25d14349cc
chore(gossipsub): remove deprecated items
Removes deprecated items from gossipsub and make certain modules crate-private.

Related https://github.com/libp2p/rust-libp2p/issues/3647.

Pull-Request: #3862.
2023-05-02 16:02:21 +00:00
Bogdan
f858ec6237
feat(identify): immediately run identify protocol on new connections
Previously, and for unknown legacy reasons, we waited for a configurable delay (default 500ms) upon new connections before we ran the identify protocol. This unnecessarily slows down applications that wait for the identify handshake to complete before performing further actions.

Resolves #3485.

Pull-Request: #3545.
2023-05-02 14:24:56 +00:00
dependabot[bot]
9fc2da0180
deps: bump anyhow from 1.0.70 to 1.0.71
Pull-Request: #3856.
2023-05-02 14:11:57 +00:00
dependabot[bot]
e135e55065
deps: bump flate2 from 1.0.25 to 1.0.26
Pull-Request: #3857.
2023-05-02 13:58:44 +00:00
Hannes
cacfb59781
chore(dcutr): remove deprecated items
Removes deprecated items from `libp2p-dcutr`.

Related https://github.com/libp2p/rust-libp2p/issues/3647

Pull-Request: #3700.
2023-05-02 13:30:04 +00:00
Hannes
3e5f64345b
chore(identify): remove deprecated items
Related: https://github.com/libp2p/rust-libp2p/issues/3647.

Pull-Request: #3698.
2023-05-02 13:15:34 +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 Coratger
c728824440
feat(relay): hide internals of Connection
Relayed connections to other peers are created from streams to the relay itself. Internally, such a connection has different states. These however are not relevant to the user and should be encapsulated to allow for more backwards-compatible changes. The only interface exposed is `AsyncRead` and `AsyncWrite`.

Resolves: #3255.

Pull-Request: #3829.
2023-05-02 11:49:07 +00:00
Hannes
30d2c75206
chore(mdns): remove deprecated items
Related: https://github.com/libp2p/rust-libp2p/issues/3647.

Pull-Request: #3699.
2023-05-02 11:32:28 +00:00
DrHuangMHT
02d87155a5
feat(mdns): change mdns::Event to hold Vec
In previous PR #3606 we've made `mdns::Event` `Clone`, but cloning single-use iterators doesn't sound right. Also you have to create an iterator from the actual data returned before putting it into events. So in this PR the iterators are replaced by `Vec`, as it's the type the data originally come from.



Related #3612.

Pull-Request: #3621.
2023-05-02 11:13:41 +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
Thomas Eizinger
d1fadc592d
fix(identity): handle warnings related to feature flags
Some of the feature-flags weren't set correctly and thus produced warnings for unused code. We can fix this by using absolute paths instead of imports and allow `dead_code` for the error constructor. It might be possible to write a correct `cfg` for this as well but I think it will be very verbose, hence I didn't bother.

Pull-Request: #3859.
2023-05-01 14:10:37 +00:00
Darius Clark
c8a064b74c
chore(doc): Add missing PR to yamux CHANGELOG.md
Add missing PR to yamux CHANGELOG.md

Pull-Request: #3855.
2023-05-01 08:22:39 +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
dependabot[bot]
193d2a1a6c
deps: bump sha3 from 0.10.6 to 0.10.7
Pull-Request: #3799.
2023-04-28 14:36:12 +00:00
dependabot[bot]
cfdf5c3345
deps: bump clap from 4.2.4 to 4.2.5
Pull-Request: #3849.
2023-04-28 14:21:17 +00:00
Thomas Eizinger
e3a1650933
feat(identify): do not implicitly dial on push
Previously, we would implicitly establish a connection when the user wanted to push identify information to a peer. I believe that this is the wrong behaviour. Instead, I am suggesting to log a message that we are skipping the push to this peer.

Additionally, the way this is currently implemented does not make much sense. Dialing a peer takes time. In case we don't have a connection at all, it could be that we drop the push requests because there isn't an active handler and thus we would have unnecessarily established the connection.

Instead of fixing this - which would require buffering the push messages - I think we should just remove the implicit dial.

Pull-Request: #3843.
2023-04-28 14:06:33 +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
Thomas Eizinger
99ad3b6eaf
refactor(kad): don't use OutboundOpenInfo
As part of pushing #3268 forward, remove the use of `OutboundOpenInfo` from `libp2p-kad`.

Related #3268.

Pull-Request: #3760.
2023-04-28 13:37:06 +00:00
dependabot[bot]
4ebb4d0a30
deps: bump serde_json from 1.0.95 to 1.0.96
Pull-Request: #3798.
2023-04-28 12:00:43 +00:00
Thomas Eizinger
8445079622
refactor(perf): don't use OutboundOpenInfo
Instead of passing the command along, we store it in a buffer and retrieve it once the stream is upgraded.

Related: https://github.com/libp2p/rust-libp2p/issues/3268.

Pull-Request: #3763.
2023-04-28 11:47:10 +00:00
Thomas Eizinger
66466c43af
refactor(dcutr): don't use OutboundOpenInfo
In a previous refactoring, we actually removed the usage of this openinfo so this is just removing dead code.

Related: #3268.

Pull-Request: #3762.
2023-04-28 11:33:31 +00:00
dependabot[bot]
a836bb471f
deps: bump clap from 4.2.1 to 4.2.4
Pull-Request: #3808.
2023-04-28 11:19:43 +00:00
dependabot[bot]
a0613e4af8
deps: bump hyper from 0.14.25 to 0.14.26
Pull-Request: #3797.
2023-04-28 11:03:03 +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 Coratger
3f6f08d8e0
feat(request-response): make handler and codec modules private
Resolves #3704.

Pull-Request: #3847.
2023-04-28 10:12:07 +00:00
Thomas Eizinger
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
Thomas Eizinger
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
Piotr Galar
31dbcabe7c
ci: enable cargo debug logging in semver-checks
This PR enables debug logging on requests from cargo to the registry in semver-checks action (https://github.com/rust-lang/cargo/issues/7662#issuecomment-561809348). Hopefully, it will let us debug the network issue reported here: https://github.com/libp2p/rust-libp2p/pull/3782#issuecomment-1523346255

Pull-Request: #3838.
2023-04-27 12:31:06 +00:00
Thomas Eizinger
9d1058df7b
fix(gossipsub): always honor support_floodsub setting
Previously, we only honored the `support_floodsub` setting when the user did not specify a custom protocol for gossipsub. This patch fixes this and allows users to advertise floodsub even when they use a custom protocol.

Pull-Request: #3837.
2023-04-27 05:20:19 +00:00
Thomas Eizinger
71805caaec
refactor(gossipsub): miscellaneous tidy-up of config tests
- Move helpers to the bottom
- Restructure tests to follow arrange-act-assert
- Only set necessary options on builder for each test

Pull-Request: #3836.
2023-04-26 17:05:08 +00:00
dependabot[bot]
e0d74bd78f
deps: bump tokio-util from 0.7.7 to 0.7.8
Pull-Request: #3833.
2023-04-26 14:42:02 +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
35132c4ab6
refactor(muxer): replace MemoryTransport with futures_ringbuf
Instead of relying on the `MemoryTransport` to provide us with a duplex stream, we use the `futures_ringbuf` crate. This saves us several lines of code and removes the dependency on `libp2p_core::upgrade::apply`.

Related #3748.

Pull-Request: #3772.
2023-04-26 12:55:06 +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
Predrag Gruevski
ed392af864
feat(ci): use cargo-semver-checks v0.20 for a massive perf improvement
`cargo-semver-checks` v0.20 uses Trustfall's newly-added optimization API to make semver-checking scale as `O(n)` instead of `O(n^2)`. On one large crate this was a 2354x speedup: 5h3min turned into 7.7s!

Pull-Request: #3822.
2023-04-26 11:18:30 +00:00
Thomas Eizinger
58085418d1
feat(ci): bump version for stable clippy to 1.69
Pull-Request: #3820.
2023-04-26 08:17:07 +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