224 Commits

Author SHA1 Message Date
Thomas Eizinger
f4ce1fe9ae
swarm/pool: Misc refactoring (#3073)
* Remove unreachable error case

Instead of taking the connection out of the map again, construct
the event to be returned with the data we already have available.

* Remove `Pool::get` and `PoolConnection`

These are effectively not used.

* Replace `iter_pending_info` with its only usage: `is_dialing`

* Add `is_for_same_remote_as` convenience function

* Remove `PendingConnection`

* Rename `PendingConnectionInfo` to `PendingConnection`

With the latter being gone, the name is now free.

* Merge `EstablishedConnectionInfo` and `EstablishedConnection`

This is a leftover from when `Pool` was still in `libp2p-core` and
one of them was a public API and the other one wasn't.

All of this is private to `libp2p-swarm` so we no longer need to
differentiate.

* Don't `pub use` out of `pub(crate)` modules
2022-11-02 18:47:00 +00:00
João Oliveira
64e38bd6b4
swarm/: Link ThreadPool in documentation (#3067) 2022-11-02 15:09:55 +00:00
João Oliveira
49679d31e7
swarm/CHANGELOG.md: Fix version mismatch with v0.40.1 (#3063) 2022-11-02 13:41:28 +00:00
Thomas Eizinger
71131e0622
*: Don't leak prost dependency in error types (#3058)
With the current design, a major version bump of `prost` leaks into
all consumers of `prost-codec`.
2022-11-02 12:02:21 +00:00
Hannes
fcadc83aca
*: Use auto_doc_cfg instead of doc(cfg) attributes (#2983)
Co-authored-by: João Oliveira <hello@jxs.pt>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2022-10-24 13:00:20 +11:00
Roland Kuhn
c84a0fb86b
swarm: Improve rendering of ConnectionLimit error (#3043) 2022-10-20 10:46:23 +11:00
Max Inden
d530e5112c
*: Prepare v0.49.0 (#2931) 2022-10-14 15:30:16 +01:00
Thomas Eizinger
bdf9209824
swarm: Split off "keep alive" functionality from DummyConnectionHandler (#2859)
Previously, the `DummyConnectionHandler` offered a "keep alive" functionality,
i.e. it allowed users to set the value of what is returned from
`ConnectionHandler::keep_alive`. This handler is primarily used in tests or
`NetworkBehaviour`s that don't open any connections (like mDNS). In all of these
cases, it is statically known whether we want to keep connections alive. As
such, this functionality is better represented by a static
`KeepAliveConnectionHandler` that always returns `KeepAlive::Yes` and a
`DummyConnectionHandler` that always returns `KeepAlive::No`.

To follow the naming conventions described in
https://github.com/libp2p/rust-libp2p/issues/2217, we introduce a top-level
`keep_alive` and `dummy` behaviour in `libp2p-swarm` that contains both the
`NetworkBehaviour` and `ConnectionHandler` implementation for either case.
2022-10-05 17:50:11 +01:00
Thomas Eizinger
1b793242e6
.cargo: Run clippy on ALL the source files (#2949) 2022-10-04 18:24:38 +11:00
David D
e6da99e4f8
.github/workflows: Deny cargo doc warnings in CI (#2936)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2022-10-04 12:01:45 +11:00
João Oliveira
a7a96e5502
protocols/identify: Revise symbol naming (#2927) 2022-10-04 11:17:31 +11:00
Thomas Eizinger
1da75b2b25
protocols/ping: Properly deprecate types with Ping prefix (#2937)
Co-authored-by: Elena Frank <elena.frank@protonmail.com>
Co-authored-by:  João Oliveira <hello@jxs.pt>
2022-10-01 00:19:34 +10:00
Thomas Eizinger
f6bb846c36
*: Remove default features from all crates (#2918)
Remove default features. You need to enable required features
explicitly now. As a quick workaround, you may want to use the
new `full` feature which activates all features.
2022-09-29 16:32:22 +01:00
Darius Clark
121a11c7f1
swarm: Provide peer_id to inject_dial_failure on connection limit error (#2928) 2022-09-23 12:57:52 +02:00
Roman
e530118fb0
build(deps): Bump rand to 0.8 and quickcheck to 1 (#2857)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-09-22 18:48:32 +10:00
Thomas Eizinger
a4d1e58836
swarm/connection: Enforce limit on inbound substreams via StreamMuxer (#2861)
* Provide separate functions for injecting in- and outbound streams

* Inline `HandlerWrapper` into `Connection`

* Only poll for new inbound streams if we are below the limit

* yamux: Buffer inbound streams in `StreamMuxer::poll`
2022-09-21 15:02:21 +02:00
Thomas Eizinger
45faefa36c
*: Unfiy how we depend on crates across the workspace (#2886) 2022-09-19 17:32:02 +10:00
Thomas Eizinger
66c275520d
swarm/: Fix rare test failure of multiple_addresses_err (#2882)
In case we accidentally generate the same port twice, we will try to
issue two dial attempts to the same address but also expect two dial
errors which is exactly what this test is trying to catch.
Unfortunately, the assertion is badly written and does not catch
duplicate inputs.
2022-09-11 08:55:26 +02:00
Max Inden
83c67954e9
*: Prepare v0.48.0 (#2869) 2022-09-07 09:44:51 +02:00
Alexander Shishenko
8644c65a22
core/: Introduce rsa feature flag to avoid ring dependency (#2860)
- Introduce `rsa` feature flag to `libp2p-core`.
- Expose `rsa` feature in `libp2p`.
- Add `rsa` feature to `libp2p` `default`.
2022-09-07 08:16:22 +02:00
Max Inden
6855ab943b
swarm-derive/: Remove support for ignoring fields on struct (#2842)
With the removal of `NetworkBehaviourEventProcess` there is no more need for
ignoring fields.
2022-08-29 07:39:47 +02:00
Max Inden
247b5536d4
swarm-derive/: Remove support for custom poll method (#2841)
With the removal of `NetworkBehaviourEventProcess` there is no more need for a
custom poll method.
2022-08-28 10:51:49 +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
Max Inden
4253080a43
*: Prepare v0.47.0 (#2830) 2022-08-22 05:14:04 +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
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
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
Kourosh
a4110a2b69
*: Remove inject_connected / inject_disconnected from docs (#2805) 2022-08-10 10:20:31 +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
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
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
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
072d7364a1
swarm/CHANGELOG: Merge unreleased section v0.36.2 with v0.37.0 (#2727) 2022-06-26 14:24:50 +02:00
Thomas Eizinger
0f40e513cc
core/muxing: Replace Into<io::Error> bound on StreamMuxer with std::error::Error (#2710)
* core/muxing: Remove `Into<io::Error>` bound from `StreamMuxer::Error`

This allows us to preserve the type information of a muxer's concrete
error as long as possible. For `StreamMuxerBox`, we leverage `io::Error`'s
capability of wrapping any error that implements `Into<Box<dyn Error>>`.

* Use `?` in `Connection::poll`

* Use `?` in `muxing::boxed::Wrap`

* Use `futures::ready!` in `muxing::boxed::Wrap`

* Fill PR number into changelog

* Put `Error + Send + Sync` bounds directly on `StreamMuxer::Error`

* Move `Send + Sync` bounds to higher layers

* Use `map_inbound_stream` helper

* Update changelog to match new implementation
2022-06-24 08:26:49 +02:00
Thomas Eizinger
eb490c08e9
core/muxing: Force StreamMuxer::Substream to implement Async{Read,Write} (#2707)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-06-23 21:52:11 +10:00
Max Inden
7eaa9c7bb7
swarm/src/connection: Extend log when exceeding streams limit (#2716)
Log peer ID and stream limit as well as reference config option when limit is
exceeded. This should help folks running into this limit debug what is going on.
2022-06-22 06:02:55 +02:00
Max Inden
802d00e645
*: Prepare v0.45.1 (#2700) 2022-06-09 15:26:56 +02:00
Max Inden
2acbb457cd
swarm/: Limit negotiating inbound substreams per connection (#2697)
This limit is shared across all `ConnectionHandler`s on a single connection. It
only enforces a limit on the number of negotiating substreams. Once negotiated a
`ConnectionHandler` manages the lifecycle of the substream and has to enforce
limits themselves.
2022-06-08 11:48:46 +02:00
Max Inden
6e1e314872
*: Prepare v0.45.0 (#2662) 2022-05-31 13:12:53 +02:00
Thomas Eizinger
25c8bc24de
core/muxing: Rename close to poll_close (#2666)
It is common practise to prefix functions that return a `Poll` with
`poll_`.
2022-05-29 16:27:40 +02:00
Max Inden
9a5fec874d
swarm/src/connection: Prioritize handler over negotiating streams (#2638)
The `HandlerWrapper` polls three components:

1. `ConnectionHandler`
2. Outbound negotiating streams
3. Inbound negotiating streams

The `ConnectionHandler` itself might itself poll already negotiated streams.

By polling the three components above in the listed order one:

- Prioritizes local work and work coming from negotiated streams over
  negotiating streams.
- Prioritizes outbound negotiating streams over inbound negotiating
  streams, i.e. outbound requests over inbound requests.
2022-05-18 11:05:08 +02:00
Chad Nehemiah
d97893d293
swarm(-derive)/: Rename references of protocol handler to connection handler (#2640) 2022-05-18 09:52:50 +02:00
Carson Farmer
5cf68902ce
swarm/: Remove redundant doc strings on behaviour trait (#2634)
Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
2022-05-09 17:53:01 +02:00
Max Inden
afc5b8d8cd
swarm/src/lib: Prioritize Behaviour over Pool and Pool over Listeners (#2627)
Have the main event loop (`Swarm::poll_next_event`) prioritize:

1. Work on `NetworkBehaviour` over work on `Pool`, thus prioritizing
   local work over work coming from a remote.

2. Work on `Pool` over work on `ListenersStream`, thus prioritizing work
   on existing connections over upgrading new incoming connections.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2022-05-05 20:15:24 +02:00
Max Inden
3cfbf89a3a
swarm/src/connection/pool: Remove 'a lifetime in PoolEvent (#2625)
Simplifies `PoolEvent`, no longer carrying a reference to an
`EstablishedConnection` or the `Pool`, but instead the `PeerId`,
`ConnectionId` and `ConnectedPoint` directly.

Co-authored-by: Elena Frank <elena.frank@protonmail.com>
2022-05-04 10:33:40 +02:00
Max Inden
3e1ed95cf6
swarm/src/connection: Prioritize handler over connection (#2626)
Prioritize work in handler over work on connection, thus prioritizing local work
over work coming from a remote.
2022-05-03 22:26:28 +02:00
Hubert
70d38520fd
*: Activate clippy::style lint group (#2620) 2022-05-03 13:11:48 +02:00