1842 Commits

Author SHA1 Message Date
Max Inden
a3dec471c0
docs/coding-guidelines: Document limit on number of tasks (#2839)
Add guideline to limit number of tasks being spawned.
2022-08-26 09:02:14 +02:00
Max Inden
ca07ce4d64
swarm/behaviour: Remove deprecated NetworkBehaviourEventProcess (#2840)
Removes the `NetworkBehaviourEventProcess` and all its associated logic.

See deprecation pull request https://github.com/libp2p/rust-libp2p/pull/2784.

Find rational in https://github.com/libp2p/rust-libp2p/pull/2751.
2022-08-26 07:08:33 +02:00
dependabot[bot]
d92cab8581
build(deps): Update p256 requirement from 0.10.0 to 0.11.0 (#2636)
* build(deps): Update p256 requirement from 0.10.0 to 0.11.0

Updates the requirements on [p256](https://github.com/RustCrypto/elliptic-curves) to permit the latest version.
- [Release notes](https://github.com/RustCrypto/elliptic-curves/releases)
- [Commits](https://github.com/RustCrypto/elliptic-curves/commits/p256/v0.10.1)

---
updated-dependencies:
- dependency-name: p256
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* core/: Bump version and add changelog entry

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-08-23 09:51:58 +02:00
Elena Frank
d610e4b0fb
protocols/dcutr: Disable libp2p-core default features (#2836) 2022-08-23 09:12:00 +02:00
Max Inden
4253080a43
*: Prepare v0.47.0 (#2830) 2022-08-22 05:14:04 +02:00
Max Inden
217dd2ca22
clippy.toml: Create config and disallow unbounded channels (#2823)
When using channels (e.g. `futures::channel::mpsc` or `std::sync::mpsc`)
always use the bounded variant, never use the unbounded variant. When
using a bounded channel, a slow consumer eventually slows down a fast
producer once the channel bound is reached, ideally granting the slow
consumer more system resources e.g. CPU time, keeping queues small and
thus latencies low.  When using an unbounded channel a fast producer
continues being a fast producer, growing the channel buffer
indefinitely, increasing latency until the illusion of unboundedness
breaks and the system runs out of memory.

One may use an unbounded channel if one enforces backpressure through an
out-of-band mechanism, e.g. the consumer granting the producer
send-tokens through a side-channel.
2022-08-20 07:31:45 +02:00
Thomas Eizinger
3d3666e1a6
*: Enforce no clippy warnings for examples (#2826) 2022-08-20 05:48:22 +02:00
Elena Frank
8931860b2f
core/identity: Allow clippy::large-enum-variant on Keypair (#2827) 2022-08-19 05:06:55 +02:00
Max Inden
475289c19c
docs/coding-guidelines: Add document (#2780)
Add document outlining a set of coding guidelines followed and to be
followed across the rust-libp2p code base.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2022-08-17 09:03:20 +02:00
Max Inden
a2738fd555
swarm-derive/: Derive Debug for generated OutEvent (#2821)
When generating an `OutEvent` `enum` definition for a user, derive `Debug`
for that `enum`.

Why not derive `Clone`, `PartialEq` and `Eq` for the generated `enum`
definition?

While it is fine to require all sub-`OutEvent`s to implement
`Debug`, the same does not apply to traits like `Clone`. I
suggest users that need `Clone` to define their own `OutEvent`.
2022-08-17 08:40:32 +02:00
dependabot[bot]
d2c50530e9
build(deps): Update prometheus-client requirement from 0.17.0 to 0.18.0 (#2822)
* build(deps): Update prometheus-client requirement from 0.17.0 to 0.18.0

Updates the requirements on [prometheus-client](https://github.com/prometheus/client_rust) to permit the latest version.
- [Release notes](https://github.com/prometheus/client_rust/releases)
- [Changelog](https://github.com/prometheus/client_rust/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_rust/compare/v0.17.0...v0.18.0)

---
updated-dependencies:
- dependency-name: prometheus-client
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-17 07:02:21 +02:00
Max Inden
67266c6a66
swarm-derive/: Add where clause of behaviour to generated out event (#2819)
When generating the `OutEvent` for a `NetworkBehaviour`, add the `where` clause of the
`NetworkBehaviour` `struct` to the generated `enum`.
2022-08-17 06:43:47 +02:00
Max Inden
8dc0188a1d
swarm/src/connection: Test max_negotiating_inbound_streams (#2785)
Test that `HandlerWrapper` upholds the provided
`max_negotiating_inbound_streams` limit.
2022-08-16 10:15:31 +02:00
dependabot[bot]
6a9fa3d930
build(deps): Update prost requirement from 0.10 to 0.11 (#2788)
* build(deps): Update prost-build requirement from 0.10 to 0.11

Updates the requirements on [prost-build](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: prost-build
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): Update prost requirement from 0.10 to 0.11

Updates the requirements on [prost](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: prost
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-16 08:49:09 +02:00
Max Inden
878c49fa14
swarm/src/behaviour: Deprecate NetworkBehaviourEventProcess (#2784)
In preparation for https://github.com/libp2p/rust-libp2p/pull/2751.
2022-08-16 06:58:17 +02:00
qidu
0e5a25dea8
examples/file-sharing: Support binary files (#2786) 2022-08-16 05:12:28 +02:00
Thomas Eizinger
cef505685c
core/muxing: Generalise StreamMuxer::poll_address_change to poll (#2797)
This is to allow general-purpose background work to be performed
by implementations.
2022-08-16 04:50:17 +02:00
Elena Frank
06aaea67f3
*: Fix clippy::derive-partial-eq-without-eq (#2818) 2022-08-14 04:03:04 +02:00
Max Inden
0a01c81c7b
misc/multistream-select: Replace msg.get(0) with msg.first() (#2816) 2022-08-13 12:46:45 +02:00
Kourosh
a4110a2b69
*: Remove inject_connected / inject_disconnected from docs (#2805) 2022-08-10 10:20:31 +02:00
Kourosh
1012579d77
protocols/: Remove passing default variant to WithPeerId::condition (#2802) 2022-08-10 09:50:24 +02:00
Max Inden
3da8b423c2
README: Point to security@libp2p.io (#2799) 2022-08-08 10:57:11 +02:00
Max Inden
e2b83b7c8f
SECURITY.md: Document supported releases and security mail addr (#2800) 2022-08-08 08:14:46 +02:00
Max Inden
579b1be5d5
swarm-derive/: Generate OutEvent if not provided (#2792)
Generate `NetworkBehaviour::OutEvent` if not provided through
`#[behaviour(out_event = "MyOutEvent")]` and event processing is
disabled (default).
2022-08-08 07:18:32 +02:00
Thomas Eizinger
028decec69
core/muxing: Have functions on StreamMuxer take Pin<&mut Self> (#2765)
Co-authored-by: Elena Frank <elena.frank@protonmail.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-08-03 23:12:11 +10:00
Luke Hinds
2b9e212682
examples/README.md: Fix tutorial link (#2790) 2022-08-02 08:46:50 +02:00
Elena Frank
eaf3f3a7fb
.cargo: Check all features in custom-clippy (#2771) 2022-07-28 03:35:35 +02:00
Elena Frank
09c690862e
protocols/dcutr: Fix clippy lints (#2772) 2022-07-28 03:04:36 +02:00
Thomas Eizinger
56c492cf41
core/muxing: Drop Sync requirement for StreamMuxer on StreamMuxerBox (#2775)
`StreamMuxerBox` is never shared across threads but owned by a single
connection. Restricting it to be `Sync` unnecessarily limits the design
space around the `StreamMuxer` trait and its implementations.
2022-07-27 08:23:07 +02:00
Elena Frank
ce963dfcaa
core: fix clippy::op-ref, clippy::needless-borrow (#2770) 2022-07-25 17:57:50 +02:00
Elena Frank
74f01e47c9
transports/tcp: fix clippy::from-over-into (#2774) 2022-07-25 17:33:31 +02:00
Thomas Eizinger
0ec3bbccb2
core/muxing: Remove Unpin requirement from StreamMuxer::Substream (#2776) 2022-07-25 16:49:22 +02:00
Elena Frank
c19a211dfd
misc/metrics: fix clippy::assign-op-pattern (#2773) 2022-07-25 10:45:43 +02:00
Thomas Eizinger
f85a9909ac
core/tests: Remove unnecessary util module (#2764) 2022-07-25 17:34:05 +10:00
Elena Frank
95713ab91c
core: fix PR number in changelog entry (#2769) 2022-07-23 19:48:52 +01:00
Thomas Eizinger
2e2c117dab
core/tests: Remove unnecessary Arc (#2763) 2022-07-22 11:59:55 +02:00
Thomas Eizinger
f15a3dc4e0
core/muxing: Drop Unpin requirement from SubstreamBox (#2762)
We are already boxing the given object so we might as well pin to
to avoid the `Unpin` trait bound.
2022-07-22 11:40:27 +02:00
dependabot[bot]
51a847128c
build(deps): Update prometheus-client requirement from 0.16.0 to 0.17.0 (#2761)
* build(deps): Update prometheus-client requirement from 0.16.0 to 0.17.0

Updates the requirements on [prometheus-client](https://github.com/prometheus/client_rust) to permit the latest version.
- [Release notes](https://github.com/prometheus/client_rust/releases)
- [Changelog](https://github.com/prometheus/client_rust/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_rust/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: prometheus-client
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-22 11:20:39 +02:00
Hubert
163c5c1752
README.md: Add crates.io and docs.rs badges (#2766) 2022-07-22 06:58:41 +10:00
tgmichel
c8066df232
*: Update to if-watch 1.1.1 (#2754) 2022-07-19 09:14:00 +02:00
Max Inden
66c2319230
transports/tcp: Bump to v0.35.0 (#2760)
Follow up on https://github.com/libp2p/rust-libp2p/pull/2724/. Given that
libp2p-core is bumped to v0.35.0, libp2p-tcp needs to be bumped as well.
2022-07-19 08:57:50 +02:00
dependabot[bot]
e95232cfaa
build(deps): Bump Swatinem/rust-cache from 1.4.0 to 2.0.0 (#2759)
* build(deps): Bump Swatinem/rust-cache from 1.4.0 to 2.0.0

Bumps [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) from 1.4.0 to 2.0.0.
- [Release notes](https://github.com/Swatinem/rust-cache/releases)
- [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md)
- [Commits](cb2cf0cc7c...6720f05bc4)

---
updated-dependencies:
- dependency-name: Swatinem/rust-cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-19 04:04:26 +02:00
Thomas Eizinger
1a553db596
core/muxing: Flatten StreamMuxer interface to poll_{inbound,outbound,address_change,close} (#2724)
Instead of having a mix of `poll_event`, `poll_outbound` and `poll_close`, we
flatten the entire interface of `StreamMuxer` into 4 individual functions:

- `poll_inbound`
- `poll_outbound`
- `poll_address_change`
- `poll_close`

This design is closer to the design of other async traits like `AsyncRead` and
`AsyncWrite`. It also allows us to delete the `StreamMuxerEvent`.
2022-07-18 05:20:11 +02:00
Max Inden
d4f8ec2d48
misc/metrics: Track # connected nodes supporting specific protocol (#2734)
* misc/metrics: Explicitly delegate event recording to each recorder

This allows delegating a single event to multiple `Recorder`s. That enables e.g. the
`identify::Metrics` `Recorder` to act both on `IdentifyEvent` and `SwarmEvent`. The latter enables
it to garbage collect per peer data on disconnects.

* protocols/dcutr: Expose PROTOCOL_NAME

* protocols/identify: Expose PROTOCOL_NAME and PUSH_PROTOCOL_NAME

* protocols/ping: Expose PROTOCOL_NAME

* protocols/relay: Expose HOP_PROTOCOL_NAME and STOP_PROTOCOL_NAME

* misc/metrics: Track # connected nodes supporting specific protocol

An example metric exposed with this patch:

```
libp2p_identify_protocols{protocol="/ipfs/ping/1.0.0"} 10
```

This implies that 10 of the currently connected nodes support the ping protocol.
2022-07-15 09:16:03 +02:00
Max Inden
7c8a97739f
swarm/src/handler: Document responsibility limiting inbound streams (#2752)
Document that the `ConnectionHandler` implementation has to enforce a limit on
the number of inbound substreams.
2022-07-14 06:15:19 +02:00
Chad Nehemiah
d0da3a0973
swarm/: Set default dial concurrency factor to 8 (#2741) 2022-07-07 11:20:03 +02:00
Roman
2f2b7cbec1
*: Bump swarm-derive version and prepare v0.46.1 (#2747) 2022-07-06 01:48:30 +02:00
Max Inden
7df6bae520
*: Prepare v0.46.0 (#2730) 2022-07-05 13:09:58 +02:00
Elena Frank
62622a1bad
core/src/transport: Poll Transport directly, remove Transport::Listener (#2652)
Remove the concept of individual `Transport::Listener` streams from `Transport`.
Instead the `Transport` is polled directly via `Transport::poll`. The
`Transport` is now responsible for driving its listeners.
2022-07-04 04:16:57 +02:00
Max Inden
b28cdb31f9
protocols/identify: Fix race condition in discover_peer_after_disconnect (#2744)
**Summary** of the plot of the `discover_peer_after_disconnect` test:

1. `swarm2` connects to `swarm1`.
2. `swarm2` requests an identify response from `swarm1`.
3. `swarm1` sends the response to `swarm2`.
4. `swarm2` disconnects from `swarm1`.
5. `swarm2` tries to disconnect.

**Problem**

`libp2p-identify` sets `KeepAlive::No` when it identified the remote. Thus `swarm1` might
identify` `swarm2` before `swarm2` identified `swarm1`. `swarm1` then sets `KeepAlive::No` and thus closes the
connection to `swarm2` before `swarm2` identified `swarm1`. In such case the unit test
`discover_peer_after_disconnect hangs indefinitely.

**Solution**

Add an initial delay to `swarm1` requesting an identification from `swarm2`, thus ensuring `swarm2`
is always able to identify `swarm1`.
2022-07-04 03:58:16 +02:00