476 Commits

Author SHA1 Message Date
Denis Garus
efea4902a5
refactor(relay): move stream-handling away from {In,Out}boundUpgrade
Fixes: #4075.

Pull-Request: #4275.
2023-09-20 08:11:36 +00:00
Sumit
c52a2fc3af
feat(swarm): allow configuration to idle connection timeout
Previously, a connection would be shut down immediately as soon as its `ConnectionHandler` reports `KeepAlive::No`. As we have gained experience with libp2p, it turned out that this isn't ideal.

For one, tests often need to keep connections alive longer than the configured protocols require. Plus, some usecases require connections to be kept alive in general.

Both of these needs are currently served by the `keep_alive::Behaviour`. That one does essentially nothing other than statically returning `KeepAlive::Yes` from its `ConnectionHandler`.

It makes much more sense to deprecate `keep_alive::Behaviour` and instead allow users to globally configure an `idle_conncetion_timeout` on the `Swarm`. This timeout comes into effect once a `ConnectionHandler` reports `KeepAlive::No`. To start with, this timeout is 0. Together with https://github.com/libp2p/rust-libp2p/issues/3844, this will allow us to move towards a much more aggressive closing of idle connections, together with a more ergonomic way of opting out of this behaviour.

Fixes #4121.

Pull-Request: #4161.
2023-09-19 22:32:29 +00:00
dependabot[bot]
3ee8ab6581
deps: bump serde_json from 1.0.106 to 1.0.107
Pull-Request: #4515.
2023-09-18 09:41:40 +00:00
Doug A
f5e644da8f
feat(webrtc): add WebRTC for WASM environments
This PR implements `Transport` for WebRTC for browsers by using web-sys. Only the `webrtc-direct` spec is implemented. The `webrtc` spec for connecting two browsers with each other is left to a future PR.

Related: https://github.com/libp2p/specs/issues/475.
Related #2617.
Supersedes: #4229.

Pull-Request: #4248.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2023-09-17 19:13:11 +00:00
chirag-bgh
4ea42c99eb
refactor(server): remove spawning of 2nd tokio runtime
Closes #4448.

Pull-Request: #4454.
2023-09-13 02:45:50 +00:00
sufferpurrityxd
b0c3da7f87
feat(swarm): log local peer id on swarm creation
Closes https://github.com/libp2p/rust-libp2p/issues/4394.

Pull-Request: #4439.
2023-09-12 10:09:27 +00:00
Max Inden
0e64d71196
fix(server): filter out /quic in favor of /quic-v1
Configuration files generated by Kubo <= v0.22 list both `/quic` and `/quic-v1` listen addresses with the same UDP port. Given that we enable draft-29, the two addresses are treated the same by rust-libp2p's QUIC implementation. Though calling `listen_on` with both results in an "Address already in use" error by the OS on the second call. To prevent this from happening filter out `/quic` addresses in favor of `/quic-v1`.

Pull-Request: #4467.
2023-09-12 03:03:38 +00:00
dependabot[bot]
0df1a96e3c
deps: bump base64 from 0.21.3 to 0.21.4
Pull-Request: #4479.
2023-09-11 23:32:09 +00:00
Mario Camou
ce8f38cc16
feat(misc/server): add libp2p-lookup to rust-libp2p-server
As mentioned in #4444, we need to include https://github.com/mxinden/libp2p-lookup/ in the image so that we can enable a healthcheck when it starts up.

Pull-Request: #4466.
2023-09-11 16:51:54 +00:00
dependabot[bot]
ae3cef14cb
deps: bump serde_json from 1.0.105 to 1.0.106
Pull-Request: #4481.
2023-09-11 14:13:30 +00:00
dependabot[bot]
c1bccd5c1c
deps: bump base64 from 0.21.2 to 0.21.3
Pull-Request: #4401.
2023-09-04 09:43:13 +00:00
Max Inden
96213b37c6
fix(misc/server): adhere to --metrics-path and listen on 0.0.0.0:8888
This commit reverts the previous metrics behavior. Namely:

- adhering to --metrics-path flag
- listening on 0.0.0.0:8888 instead of 127.0.0.1:8080

Note that 8888 is the default IPFS debug (aka. metrics) port.

See https://github.com/mxinden/rust-libp2p-server/blob/master/src/metric_server.rs for previous behavior.

Pull-Request: #4392.
2023-08-30 14:39:07 +00:00
dependabot[bot]
e36e8ce445
deps: bump serde from 1.0.185 to 1.0.188
Pull-Request: #4398.
2023-08-28 08:41:54 +00:00
Max Inden
9946890b53
fix(misc/server): import libp2p as workspace dependency
One needs to specify a version of `libp2p` dependeny in `misc/server/Cargo.toml` or import as a workspace dependency, in order to publish to crates.io.

This commit does the latter for the sake of consistency with the other libp2p-* dependencies.

Pull-Request: #4391.
2023-08-25 08:44:15 +00:00
Max Inden
f265f39e70
fix(misc/server): add repository URL to Cargo.toml
Pull-Request: #4390.
2023-08-24 16:10:34 +00:00
Max Inden
e8759c85c2
chore: prepare libp2p v0.52.3
- Addresses TLS CVE:
- https://github.com/libp2p/rust-libp2p/pull/4381
- https://github.com/libp2p/rust-libp2p/pull/4378
- Stable QUIC https://github.com/libp2p/rust-libp2p/pull/4325
- New rust-libp2p-server release https://github.com/libp2p/rust-libp2p/pull/4311

Pull-Request: #4387.
2023-08-24 12:47:59 +00:00
Max Inden
e974efb755
feat: add rust-libp2p-server to monorepo
Moves https://github.com/mxinden/rust-libp2p-server to the rust-libp2p monorepository.

> # Rust libp2p Server
>
> A rust-libp2p based server implementation running:
>
> - the [Kademlia protocol](https://github.com/libp2p/specs/tree/master/kad-dht)
>
> - the [Circuit Relay v2 protocol](https://github.com/libp2p/specs/blob/master/relay/circuit-v2.md)
>
> - the [AutoNAT protocol](https://github.com/libp2p/specs/blob/master/autonat/README.md)

Pull-Request: #4311.
2023-08-21 18:49:42 +00:00
dependabot[bot]
1d6d016641
deps: bump serde from 1.0.183 to 1.0.185
Pull-Request: #4363.
2023-08-21 14:03:51 +00:00
dependabot[bot]
eb83367430
deps: bump clap from 4.3.21 to 4.3.23
Pull-Request: #4359.
2023-08-21 09:37:15 +00:00
dependabot[bot]
608e2dbb19
deps: bump serde_json from 1.0.104 to 1.0.105
Pull-Request: #4347.
2023-08-19 22:41:44 +00:00
dependabot[bot]
d3da24f312
deps: bump pin-project from 1.1.2 to 1.1.3
Pull-Request: #4296.
2023-08-18 21:29:40 +00:00
Max Inden
16b2f1563d
chore: use workspace rust-version
Pull-Request: #4344.
2023-08-18 09:02:22 +00:00
dependabot[bot]
8022769daf
deps: bump clap from 4.3.19 to 4.3.21
Pull-Request: #4319.
2023-08-14 09:20:07 +00:00
Max Inden
5a8eb793fe
chore: prepare libp2p v0.52.2
Pull-Request: #4312.
2023-08-11 10:10:42 +00:00
hanabi1224
b5d993267f
feat: memory based connection limits
Implements memory-based connection limits where the user can specify an absolute or a relative limit of the process' memory usage in relation to the available system memory.

Related: #4252.

Pull-Request: #4281.
2023-08-08 16:29:21 +00:00
dependabot[bot]
72fd50ae6c
deps: bump serde from 1.0.179 to 1.0.183
Pull-Request: #4294.
2023-08-07 09:14:58 +00:00
dependabot[bot]
55f05aa6c8
deps: bump serde from 1.0.178 to 1.0.179
Pull-Request: #4271.
2023-07-31 09:00:23 +00:00
Age Manning
53df98298a
fix(connection-limits): correct connection tracking
The connection limit behaviour was not taking into account connection errors. Also, it was using the behaviour events to indicate established connections which is not always going to be the case because other behaviours can deny the connections (thanks @divagant-martian).

Closes #4249

Pull-Request: #4250.
2023-07-26 13:36:14 +00:00
dependabot[bot]
b52c3ac317
deps: bump serde from 1.0.171 to 1.0.175
Pull-Request: #4246.
2023-07-24 16:19:48 +00:00
Onur
660fadba35
chore(gossipsub): include in libp2p meta crate when compiling for wasm
Since https://github.com/libp2p/rust-libp2p/pull/3973, gossipsub now fully supports wasm targets. It functions properly when added as a dependency on its own. However, when trying to use it under libp2p by activating a feature, it's not possible and the compiler will raise an error like `unresolved import libp2p::gossipsub`. This pull request enables the use of gossipsub for wasm targets when it's activated as a feature of the libp2p dependency.

Pull-Request: #4217.
2023-07-20 07:48:21 +00:00
dependabot[bot]
132688961f
deps: bump clap from 4.3.11 to 4.3.12
Pull-Request: #4206.
2023-07-19 13:10:14 +00:00
dependabot[bot]
42be5b5d16
deps: bump serde from 1.0.168 to 1.0.171
Pull-Request: #4199.
2023-07-19 11:18:10 +00:00
dependabot[bot]
c70f3245dc
deps: bump prometheus-client from 0.21.1 to 0.21.2
Pull-Request: #4173.
2023-07-19 11:01:53 +00:00
Benno
30024f38d4
fix: clippy useless_conversion and useless_vec
Pull-Request: #4190.
2023-07-16 03:31:37 +00:00
dependabot[bot]
2f288523b0
deps: bump clap from 4.3.10 to 4.3.11
Pull-Request: #4178.
2023-07-11 11:44:04 +00:00
dependabot[bot]
1246d832a4
deps: bump serde_json from 1.0.99 to 1.0.100
Pull-Request: #4172.
2023-07-11 09:31:49 +00:00
dependabot[bot]
a92a801cce
deps: bump smallvec from 1.10.0 to 1.11.0
Pull-Request: #4171.
2023-07-11 08:58:09 +00:00
dependabot[bot]
62ab42aecb
deps: bump clap from 4.3.8 to 4.3.10
Pull-Request: #4144.
2023-07-03 16:46:28 +00:00
dependabot[bot]
ed4b4644d1
deps: bump pin-project from 1.1.0 to 1.1.2
Pull-Request: #4146.
2023-07-03 15:34:26 +00:00
Thomas Eizinger
d5475fccde
fix(test): only listen on 127.0.0.1 for ephemeral swarm
This resolves an issue where our tests were depending on the number of network interfaces available on the local machine.

Related #4110.

Pull-Request: #4122.


  
Co-Authored-By: Thomas Eizinger <thomas@eizinger.io>
2023-06-27 01:21:47 +00:00
dependabot[bot]
6241b92fe4
deps: bump clap from 4.3.3 to 4.3.8
Pull-Request: #4118.
2023-06-26 10:43:20 +00:00
dependabot[bot]
26801481fa
deps: bump serde_json from 1.0.97 to 1.0.99
Pull-Request: #4119.
2023-06-26 10:19:34 +00:00
dependabot[bot]
e28f0326c7
deps: bump clap from 4.3.2 to 4.3.3
Pull-Request: #4061.
2023-06-20 15:23:15 +00:00
dependabot[bot]
0d5c1eae16
deps: bump serde_json from 1.0.96 to 1.0.97
Pull-Request: #4085.
2023-06-20 14:16:12 +00:00
Thomas Eizinger
78c150d0df
chore: don't use workspace inheritance for dev-dependencies
Using workspace inheritance breaks `cargo release` because it cannot resolve that the dev-dependencies should only use a `path` and not a version.

Pull-Request: #4097.


  
Co-Authored-By: Thomas Eizinger <thomas@eizinger.io>
2023-06-20 12:24:28 +00:00
Thomas Eizinger
755de30757
fix(multistream-select): remove cyclic dependency to libp2p-core
All of the removed `dev-dependencies` are only for testing the upgrade procedure in `libp2p-core`. Ironically, this test does not use a single API of `multistream-select`. Thus, this test is simply misplaced in this crate. If we wanted to retain it, it should probably go into `libp2p` itself as that one already depends on all required crates.

Related: #4053.

Pull-Request: #4090.


  
Co-Authored-By: Thomas Eizinger <thomas@eizinger.io>
2023-06-20 05:41:15 +00:00
Max Inden
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
dependabot[bot]
2a6311f473
deps: bump serde from 1.0.163 to 1.0.164
Pull-Request: #4060.
2023-06-13 11:11:59 +00:00
Thomas Eizinger
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
Max Inden
76cb76ca7d
fix(multistream-select): don't wait for negotiation in poll_close
With `Version::V1Lazy` and negotiation of a single protocol, a stream initiator optimistically
sends application data right after proposing its protocol. More specifically an application can
write data via `AsyncWrite::poll_write` even though the remote has not yet confirmed the stream protocol.

This saves one round-trip.

``` mermaid
sequenceDiagram
A->>B: "/multistream/1.0.0"
A->>B: "/perf/1.0.0"
A->>B: <some-perf-protocol-data>
B->>A: "/multistream/1.0.0"
B->>A: "/perf/1.0.0"
B->>A: <some-perf-protocol-data>
```

When considering stream closing, i.e. `AsyncWrite::poll_close`, and using stream closing as an
operation in ones protocol, e.g. using stream closing to signal the end of a request, this becomes tricky.

The behavior without this commit was as following:

``` mermaid
sequenceDiagram
A->>B: "/multistream/1.0.0"
A->>B: "/perf/1.0.0"
A->>B: <some-perf-protocol-data>
Note left of A: Call `AsyncWrite::poll_close` which first waits for the<br/>optimistic multistream-select negotiation to finish, before closing the stream,<br/> i.e. setting the FIN bit.
B->>A: "/multistream/1.0.0"
B->>A: "/perf/1.0.0"
Note right of B: Waiting for A to close the stream (i.e. set the `FIN` bit)<br/>before sending the response.
A->>B: FIN
B->>A: <some-perf-protocol-data>
```

The above takes 2 round trips:

1. Send the optimistic multistream-select protocol proposals as well as the initiator protocol
payload and waits for the confirmation of the protocols.
2. Close the stream, i.e. sends the `FIN` bit and waits for the responder protocol payload.

This commit proposes that the stream initiator should not wait for the multistream-select protocol
confirmation when closing the stream, but close the stream within the first round-trip.

``` mermaid
sequenceDiagram
A->>B: "/multistream/1.0.0"
A->>B: "/perf/1.0.0"
A->>B: <some-perf-protocol-data>
A->>B: FIN
B->>A: "/multistream/1.0.0"
B->>A: "/perf/1.0.0"
B->>A: <some-perf-protocol-data>
```

This takes 1 round-trip.

The downside of this commit is, that the stream initiator will no longer notice a negotiation error
when closing the stream. They will only notice it when reading from the stream. E.g. say that B does
not support "/perf/1.0.0", A will only notice on `AsyncRead::poll_read`, not on
`AsyncWrite::poll_close`. This is problematic for protocols where A only sends data, but never
receives data, i.e. never calls `AsyncRead::poll_read`. Though one can argue that such protocol is
flawed in the first place. With a response-less protocol, as even if negotiation succceeds, A
doesn't know whether B received the protocol payload.

Pull-Request: #4019.
2023-06-06 21:00:20 +00:00