2486 Commits

Author SHA1 Message Date
Max Inden
2910c985e8
fix(examples): call Swarm::add_external_address in dcutr and relay
> Observed addresses (aka. external address candidates) of the local node, reported by a remote node
> via `libp2p-identify`, are no longer automatically considered confirmed external addresses, in
> other words they are no longer trusted by default. Instead users need to confirm the reported
> observed address either manually, or by using `libp2p-autonat`. In trusted environments users can
> simply extract observed addresses from a `libp2p-identify::Event::Received { info:
> libp2p_identify::Info { observed_addr }}` and confirm them via `Swarm::add_external_address`.

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

Pull-Request: #4052.
2023-06-09 03:26:24 +00:00
Darius Clark
c2230f9948
feat(swarm): allow NetworkBehaviours to create and remove listeners
This extends `ToSwarm` to add `ToSwarm::ListenOn` and `ToSwarm::RemoveListener`, which allows creating and removing listeners from a `NetworkBehaviour`.

Resolves https://github.com/libp2p/rust-libp2p/issues/3291.

Pull-Request: #3292.
2023-06-09 01:34:33 +00:00
Thomas Coratger
4532302917
refactor(identity): fix import warnings in keypair.rs
- Adding conditional `cfg` in `keypair.rs` imports.
- Adding `#[allow(unused_variables)]` on the top of the `sign` function.

Pull-Request: #4047.
2023-06-08 09:27:33 +00:00
Thomas Eizinger
f66420c2b1
deps: run cargo update
This removes multiple duplicate dependencies from our lockfile. Unsure why dependabot hasn't done these yet.

Pull-Request: #4044.
2023-06-08 06:16:11 +00:00
Max Inden
e0f9de3683
chore(kad): extend changelog entry on client/server mode
Pull-Request: #4050.
2023-06-08 05:51:12 +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
Thomas Coratger
d2dab94b76
feat(request-response): use cbor codec in ping example
Remove the use of the core `upgrade::transfer` module in `ping` example (`request-response` protocol) in favor of `cbor` codec.

Related #4011.

Pull-Request: #4046.
2023-06-07 13:01:40 +00:00
Max Inden
59f073df82
chore(identity): remove "unreleased" from v0.2.0 changelog entry
Pull-Request: #4048.
2023-06-07 10:44:26 +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
Thomas Eizinger
a728cca27f
chore(libp2p): remove non-existent features from cfgs
These features have long been removed and the `cfg` statement can thus be simplified.

Pull-Request: #4042.
2023-06-06 20:41:19 +00:00
Thomas Coratger
90d6a77e6a
feat(examples): use cbor codec in file-sharing example
Remove the use of the core `upgrade::transfer` module in `file-sharing` example in favor of `cbor` codec.

Related #4011.

Pull-Request: #4036.
2023-06-06 20:10:22 +00:00
Thomas Eizinger
61128713eb
feat(core): remove deprecated identity module
Related: #3647.

Pull-Request: #4040.
2023-06-06 19:22:50 +00:00
Thomas Eizinger
23d499b9dd
feat(libp2p): remove quic and webrtc re-export
These two re-exports are deprecated because they are both in alpha status. Users should depend on them directly.

Related: #3647.

Pull-Request: #4041.
2023-06-06 18:30:56 +00:00
Thomas Eizinger
0db9937ee5
feat: remove multiaddr dependency from libp2p-identity
Related: https://github.com/multiformats/rust-multiaddr/issues/73.
Depends-On: https://github.com/libp2p/rust-libp2p/pull/3514.

Pull-Request: #3656.
2023-06-06 17:27:13 +00:00
Max Inden
86e8018016
chore(rendezvous): remove unused dependency mplex
Pull-Request: #4034.
2023-06-06 05:25:40 +00:00
Max Inden
38b7bd617e
chore(multistream-select): replace mplex with yamux in tests
Pull-Request: #4033.
2023-06-06 05:06:43 +00:00
Max Inden
fb4f6dfe31
chore(multistream-select): use futures_ringbuf
Pull-Request: #4032.
2023-06-06 04:29:41 +00:00
Thomas Eizinger
09d04fa35c
ci: bump Rust version for clippy job to 1.70.0
Pull-Request: #4031.
2023-06-06 03:20:53 +00:00
dependabot[bot]
f2253abdd3
deps: bump libc from 0.2.144 to 0.2.145
Pull-Request: #4028.
2023-06-05 21:03:08 +00:00
Thomas Eizinger
2f8e1489c9
fix(swarm): make test not flaky
In the unlikely event that we generated a random number twice, the 2nd address would not get added. Ensure we loop until we have 20 addresses.

Pull-Request: #4030.
2023-06-05 20:37:06 +00:00
Thomas Eizinger
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
dependabot[bot]
68af6669ab
deps: bump webpki-roots from 0.23.0 to 0.23.1
Pull-Request: #4024.
2023-06-05 14:37:48 +00:00
dependabot[bot]
c723df461f
deps: bump clap from 4.3.0 to 4.3.1
Pull-Request: #4027.
2023-06-05 10:59:28 +00:00
dependabot[bot]
49eed8c4fd
deps: bump once_cell from 1.17.1 to 1.18.0
Pull-Request: #4026.
2023-06-05 10:41:11 +00:00
dependabot[bot]
62441a07d4
deps: bump syn from 2.0.16 to 2.0.18
Pull-Request: #4025.
2023-06-05 10:22:07 +00:00
dependabot[bot]
1dbdb6a008
deps: bump futures_ringbuf from 0.3.1 to 0.4.0
Pull-Request: #4023.
2023-06-05 09:53:02 +00:00
Max Inden
c9b386b2e3
fix(relay): log when accepting reservation without external addresses
Pull-Request: #4022.
2023-06-05 03:36:09 +00:00
Thomas Coratger
a4450d41c0
feat(dcutr): keep connection alive while we are using it
Similar to #3876, we now compute `connection_keep_alive` based on whether we are still using the connection, applied to the `dcutr` protocol.

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

Pull-Request: #3960.
2023-06-04 07:43:01 +00:00
Thomas Coratger
75edcfcdb0
docs(examples): add a README to each example
Resolves #3853.

Pull-Request: #3974.
2023-06-01 07:40:22 +00:00
Thomas Coratger
87e863e8c9
refactor(dcutr): remove direct::Handler
With recent refactorings in `libp2p-swarm`, there is no more need for `handler::direct` at all.

Resolves #4013.

Pull-Request: #4016.
2023-06-01 04:34:28 +00:00
Thomas Eizinger
92c8cc451f
feat(kad): implement automatic client mode
Currently, the kademlia behaviour can only learn that the remote node supports kademlia on a particular connection if we successfully negotiate a stream to them.

Using the newly introduced abstractions from #3651, we don't have to attempt to establish a stream to the remote to learn whether they support kademlia on a connection but we can directly learn it from the `ConnectionEvent::RemoteProtocolsChange` event. This happens directly once a connection is established which should overall benefit the DHT.

Clients do not advertise the kademlia protocol and thus we will immediately learn that a given connection is not suitable for kadmelia requests. We may receive inbound messages from it but this does not affect the routing table.

Resolves: #2032.

Pull-Request: #3877.
2023-05-31 09:02:19 +00:00
Max Inden
7f865448c0
fix(metrics/swarm): correct metric, name and help
Pull-Request: #4014.
2023-05-31 02:10:41 +00:00
Arpan Kapoor
5321a4479b
fix(dcutr): always check for relayed connection first
For a non-relay connection, check if it corresponds to a direct connection upgrade.

As discussed in #3964.

Pull-Request: #3982.
2023-05-31 01:14:10 +00:00
dependabot[bot]
b73f7209c5
deps: bump bs58 from 0.4.0 to 0.5.0
Pull-Request: #3999.
2023-05-30 19:27:34 +00:00
Thomas Eizinger
ddc2b879e2
fix: apply suggestions from 1.71 clippy beta
Pull-Request: #4009.
2023-05-30 13:30:04 +00:00
Max Inden
efb117e236
fix(ping): remove debug_assert on protocol negotiation timeout
The negotiation of the ping protocol can timeout, thus a debug_assert is not correct. Return an `std::io::Error` instead.

Pull-Request: #3995.
2023-05-30 03:21:52 +00:00
Max Inden
a8a00e7ad7
fix(metrics/identify): remove newline in metric description
Pull-Request: #4005.
2023-05-30 03:03:16 +00:00
dependabot[bot]
d67c133794
deps: bump quote from 1.0.27 to 1.0.28
Pull-Request: #4004.
2023-05-30 02:44:20 +00:00
dependabot[bot]
616abb6c3b
deps: bump regex from 1.8.1 to 1.8.3
Pull-Request: #4003.
2023-05-30 02:25:45 +00:00
dependabot[bot]
34e1780498
deps: bump criterion from 0.4.0 to 0.5.1
Pull-Request: #4002.
2023-05-30 02:06:57 +00:00
dependabot[bot]
e880d8380f
deps: bump proc-macro2 from 1.0.58 to 1.0.59
Pull-Request: #3997.
2023-05-29 10:36:00 +00:00
dependabot[bot]
34d87a8208
deps: bump log from 0.4.17 to 0.4.18
Pull-Request: #4000.
2023-05-29 10:17:23 +00:00
dependabot[bot]
95eca886f2
deps: bump tokio from 1.28.1 to 1.28.2
Pull-Request: #4001.
2023-05-29 09:59:17 +00:00
Max Inden
21e26d7e23
fix(metrics/kad): don't add period to metric help text
This is added automatically by the `prometheus-client` crate.

Pull-Request: #3996.
2023-05-29 09:11:18 +00:00
Max Inden
9b765fa202
fix(perf): remove --secret-key-seed flag
There is no need for the flag, given that rust-libp2p allows dialing multiaddr without `/p2p`.

Pull-Request: #3994.
2023-05-29 08:04:52 +00:00
dependabot[bot]
c5dd0a2e14
deps: bump base64 from 0.21.0 to 0.21.2
Pull-Request: #3993.
2023-05-28 06:36:18 +00:00
Max Inden
92af0d1281
refactor(perf): use libp2p-request-response
Rewrite `libp2p-perf` protocol using `libp2p-request-response`. Additionally adjust to latest conventions, e.g. the final JSON output.

Pull-Request: #3646.
2023-05-28 05:51:53 +00:00
Max Inden
d4c4078e6d
fix(libp2p): don't re-export libp2p-perf
This commit removes the `libp2p-perf` protocol from `libp2p` crate. To use `libp2p-perf` one needs to import it directly. Rational beeing that `libp2p-perf`'s API is not yet stable enough and will most likely require breaking changes in the near future.

Pull-Request: #3990.
2023-05-26 08:38:55 +00:00
Max Inden
bbba8b3f65
fix(yamux): don't register waker on success
In case `self.poll_inner` returns `Poll::Ready` there is no need to register `self.inbound_stream_waker`. With this commit, `self.inbound_stream_waker` is only registered in case `self.poll_inner` returned `Poll::Pending`.

Pull-Request: #3989.
2023-05-26 04:40:57 +00:00
Max Inden
a5a00205c2
chore(roadmap): update
- Update target completions.
- Introduce QUIC hole punching item.
- Add address pipeline and AutoNATv2.
- Reword WebRTC item (not move to str0m) to entail both `/webrtc` and `/webrtc-direct`.

Pull-Request: #3958.
2023-05-26 01:42:36 +00:00