2752 Commits

Author SHA1 Message Date
Max Inden
4195840f92
chore(roadmap): move kad client mode to done
Pull-Request: #4094.


  
Co-Authored-By: Max Inden <mail@max-inden.de>
2023-06-20 09:15:09 +00:00
Max Inden
fd803e2697
chore(quic,webrtc): prepare v0.8.0-alpha & v0.5.0-alpha
Pull-Request: #4089.


  
Co-Authored-By: Max Inden <mail@max-inden.de>
2023-06-20 07:27:10 +00:00
Thomas Eizinger
42566869b2
chore: use path dependencies for all cyclic dev-dependencies
We have two "interface" crates in our workspace: `libp2p-core` and `libp2p-swarm`. Most crates depend on both of these. To compile the tests for this crate, we often need a concrete implementation to some of these interfaces. When specifying a workspace-inherited dependency, we don't get to choose to omit the `version` field next to the path. If a dependency is `path`-only however, it will be tripped by `cargo` during the release process which is why all of this worked before our move to workspace inheritance.

With this patch, we change the minimum amount of dependencies necessary back to `path` dependencies to allowing releasing of our crates.

Related: #4053.

Pull-Request: #4091.


  
Co-Authored-By: Thomas Eizinger <thomas@eizinger.io>
2023-06-20 06:42:53 +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
Denis Garus
c4ab04c57c
feat(rendezvous): directly return error from register
Resolves #4070.

Pull-Request: #4073.
2023-06-17 11:19:41 +00:00
Denis Garus
b8ceeccdc6
refactor(rendezvous): rewrite using libp2p-request-response
Fixes [#3878](https://github.com/libp2p/rust-libp2p/issues/3878).

Pull-Request: #4051.


  
Co-Authored-By: Thomas Eizinger <thomas@eizinger.io>
2023-06-14 17:49:23 +00:00
Thomas Eizinger
14530af261
ci: attribute co-authorship of a PR based on its commits
It often happens that multiple people contribute to a single PR. To correctly attribute authorship, GitHub supports the `Co-authored-by` convention. This line however needs to be at the very end of the commit message.

Because we are also automatically adding the pull-request number to the commit message, we cannot add these lines ourselves. Doing this manually is error-prone anyway so with this patch, we are extending the commit message template to automatically populate this from the commits within the pull request.

Pull-Request: #4069.
2023-06-14 18:00:19 +02:00
GitHub
2c6c058bb7 chore: Update .github/workflows/semantic-pull-request.yml [skip ci] 2023-06-14 09:04:10 +00:00
Yiannis M
755e3417f7
feat(noise): add WebTransport certhashes extension
The extension for WebTransport certhashes was added and can be configured via `Config::with_webtransport_certhashes`.

In case of initiator, these certhashes will be used to validate the ones reported by responder. In case of responder, these certhashes will be reported to initiator.

Resolves #3988.

Pull-Request: #3991.
2023-06-13 12:03:35 +00:00
Arpan Kapoor
cf3e4c6860
feat(quic): implement hole punching
Implement `Transport::dial_as_listener` for QUIC as specified by the [DCUtR spec](https://github.com/libp2p/specs/blob/master/relay/DCUtR.md).

To facilitate hole punching in QUIC, one side needs to send random UDP packets to establish a mapping in the routing table of the NAT device. If successful, our listener will emit a new inbound connection. This connection needs to then be sent to the dialing task. We achieve this by storing a `HashMap` of hole punch attempts indexed by the remote's `SocketAddr`. A matching incoming connection is then sent via a oneshot channel to the dialing task which continues with upgrading the connection.

Related #2883.

Pull-Request: #3964.
2023-06-13 11:42:18 +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
dependabot[bot]
db93fa1657
deps: bump proc-macro2 from 1.0.59 to 1.0.60
Pull-Request: #4059.
2023-06-13 10:50:17 +00:00
dependabot[bot]
d263ee67a9
deps: bump log from 0.4.18 to 0.4.19
Pull-Request: #4058.
2023-06-13 10:29:36 +00:00
Thomas Eizinger
f93719cfd3
refactor(wasm-ext): replace parity-send-wrapper with send-wrapper
Co-authored-by: Yiannis Marangos <yiannis@eiger.co>

Related: #4065.

Pull-Request: #4066.
2023-06-12 16:14:42 +00:00
Nathaniel Cook
4a1703f046
feat(swarm): add ConnectionDenied::downcast_ref
Prior to this change it was only possible to downcast a `ConnectionDenied` error when you had ownership of it which isn't the case inside `NetworkBehaviour`s. This change allows downcasting by reference.

See https://github.com/libp2p/rust-libp2p/discussions/4018.

Pull-Request: #4020.
2023-06-12 15:26:09 +00:00
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