Commit Graph

2610 Commits

Author SHA1 Message Date
05c079422e fix(webrtc): Don't emit addresses from other interfaces (#3142)
Previously, we would always run `IfWatcher`, even if we were only listening on a specific interface. This patch fixes this behaviour and aligns it with how `libp2p-quic` operates.
2022-11-18 10:24:46 +00:00
08510dd523 mdns: update if-watch to 3.0.0 (#3096) 2022-11-18 01:12:23 +00:00
7803524a76 swarm/handler: replace inject_* methods (#3085)
Previously, we had one callback for each kind of message that a `ConnectionHandler` would receive from either its `NetworkBehaviour` or the connection itself.

With this patch, we combine these functions, resulting in two callbacks:

- `on_behaviour_event`
- `on_connection_event`

Resolves #3080.
2022-11-17 17:19:36 +00:00
6d49bf4a53 fix: Allow libp2p-mdns to compile without feature-flags (#3131)
Currently, `libp2p-mdns` fails to compile unless we enable the `tokio` runtime feature flag. This is caused by missing `cfg` statements upstream. See https://github.com/bluejekyll/trust-dns/issues/1830.

Until this is fixed upstream, we temporarily enable the `tokio-runtime` feature of `trust-dns-proto`.
2022-11-17 12:06:30 +00:00
3df3c88f3d swarm/behaviour: Replace inject_* with on_event (#3011) 2022-11-17 09:28:40 +00:00
a714864885 feat: Add WebRTC transport (#2622)
Hey 👋 This is a WebRTC transport implemented in accordance w/ the [spec](https://github.com/libp2p/specs/pull/412). It's based on the [webrtc-rs](https://github.com/webrtc-rs/webrtc) library.

Resolves: #1066.
2022-11-17 05:17:31 +00:00
43fdfe27ea chore(mergify): Don't ask dependabot to resolve conflicts (#3122) 2022-11-16 10:28:03 +11:00
69efe63229 misc/metrics: Add protocols label to address-specific metrics (#2982)
Previously, we would only track the metrics like the number of open connections. With this patch, we extend these metrics with a `protocols` label that contains a "protocol stack". A protocol stack is a multi-address with all variable parts removed. For example, `/ip4/127.0.0.1/tcp/1234` turns into `/ip4/tcp`.

Resolves https://github.com/libp2p/rust-libp2p/issues/2758.
2022-11-15 20:45:14 +00:00
d5ea93dd71 feat(swarm): Make executor for connection tasks explicit (#3097)
Previously, the executor for connection tasks silently defaulted to a `futures::executor::ThreadPool`. This causes issues such as https://github.com/libp2p/rust-libp2p/issues/2230.

With this patch, we force the user to choose, which executor they want to run the connection tasks on which results in overall simpler API with less footguns.

Closes #3068.
2022-11-15 14:26:03 +00:00
d8fe7bf49f transports/tcp: Update if-watch to v3.0.0 (#3101)
Update to `if-watch` version 3.0.0 and pass through features, such that `libp2p-tcp/async-io` selects `if-watch/smol` and `libp2p-tcp/tokio` brings in `if-watch/tokio`.
The mDNS part is already done in #3096.
2022-11-15 12:34:38 +00:00
ca8bcd8288 core: Expose peer_id::ParseError (#3113) 2022-11-15 11:58:42 +00:00
9dadf5c830 muxers/yamux: Mitigation of unnecessary stream drops (#3071) 2022-11-15 10:40:55 +00:00
368705a146 docs(core): Document byte format of PeerId (#3084)
PeerId data is more than just a multihash of the public key.

See discussion: https://github.com/libp2p/rust-libp2p/discussions/3079
2022-11-15 01:22:11 +00:00
5f196dd231 refactor(mdns): Parse messages using trust-dns-proto instead of dns-parse (#3102) 2022-11-14 22:35:18 +00:00
5b3612bb29 test: Remove dialer_can_receive stream muxer test (#3108)
Various muxer implementations struggle to fulfill this test. In practice, it doesn't matter much because we always run `multistream-select` on top of a newly negotiated stream so we never end up actually reading from a stream that we have never written to.

Relevant discussion: https://github.com/kpp/rust-libp2p/pull/27#discussion_r1012128418
2022-11-14 21:09:19 +00:00
0f5c491d91 feat(transports/quic): Add implementation based on quinn-proto (#2289)
Co-authored-by: Demi Marie Obenour <demiobenour@gmail.com>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: David Craven <david@craven.ch>
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: elenaf9 <elena.frank@protonmail.com>
Co-authored-by: Marco Munizaga <marco@marcopolo.io>
2022-11-14 13:12:16 +01:00
7daa0c1145 *: Remove lazy_static in favor of once_cell (#3110) 2022-11-14 04:24:52 +00:00
8b378d56d3 deps: Update to multiaddr v0.16.0 (#3117) 2022-11-13 23:38:27 +01:00
e2737c7b71 protocols/kad: Expose NoKnownPeers (#3114) 2022-11-13 22:08:28 +00:00
cafa73444b .github/: Use Description for commit message and add Notes (#3082) 2022-11-13 20:01:24 +01:00
afb777e937 swarm-derive: Add prelude configuration option to NetworkBehaviour macro (#3055)
Currently, our `NetworkBehaviour` derive macro depends on the `libp2p` crate to be in scope. This prevents standalone usage which forces us to depend on `libp2p` in all our tests where we want to derive a `NetworkBehaviour`.

This PR introduces a `prelude` option that - by default - points to `libp2p::swarm::derive_prelude`, a new module added to `libp2p_swarm`. With this config option, users of `libp2p_swarm` can now refer to the macro without depending on `libp2p`, breaking the circular dependency in our workspace. For consistency with the ecosystem, the macro is now also re-exported by `libp2p_swarm` instead of `libp2p` at the same position as the trait that it implements.

Lastly, we introduce an off-by-default `macros` feature flag that shrinks the dependency tree for users that don't need the derive macro.
2022-11-12 23:59:14 +00:00
c32f03c317 *: Fix newly raised clippy warnings (#3106)
Fixed minor issues raised by clippy to improve correctness and readablitity.
2022-11-11 20:30:58 +00:00
90df86d9e7 Update ROADMAP.md based on previous feedback. (#3091)
Co-authored-by: Prithvi Shahi <shahi.prithvi@gmail.com>
2022-11-10 11:08:00 -08:00
e1e6413fc0 build(deps): Bump Swatinem/rust-cache from 2.1.0 to 2.2.0 (#3104) 2022-11-10 12:14:17 +00:00
313ed588fe build(deps): Bump Swatinem/rust-cache from 2.0.1 to 2.1.0 (#3093) 2022-11-08 08:23:07 +00:00
ba14ffdd42 protocols/identify: Change default cache_size of Config to 100 (#2995)
`Config` struct's member `cache_size` now defaults to `100`.
2022-11-04 19:40:30 +00:00
280c51ef83 *: Link to libp2p/specs in doc comments (#3077) 2022-11-04 10:32:41 +00:00
1ba9e4579d protocols/gossipsub: Make use of prost-codec (#3070) 2022-11-04 10:12:08 +00:00
b528d336cd *: Fix clippy warnings introduced by Rust 1.65 release (#3081) 2022-11-04 09:40:09 +00:00
f9b4af3d9d build(deps): Update rcgen requirement from 0.9.2 to 0.10.0 (#3059) 2022-11-03 01:40:53 +00:00
95e27ece8e .github: Add mergify configuration (#3026) 2022-11-03 12:25:12 +11:00
53d445e61c protocols/kademlia: Refactor stream state machines (#3074)
* Refactor `InboundSubstreamState` to implement `Stream`

This allows us to use `stream::SelectAll` instead of iterating
through the states ourselves. It also allows us to fix an existing
TODO where we don't properly close a stream.

* Refactor `OutboundSubstreamState` to implement `Stream`

* Remove unnecessary keep_alive changes

The same thing is happening further down.

* Remove code duplication in answering requests

* Debug assert that we can answer every request
2022-11-02 19:20:55 +00:00
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
64e38bd6b4 swarm/: Link ThreadPool in documentation (#3067) 2022-11-02 15:09:55 +00:00
df659e5bcd core/muxer: Remove deprecated functions (#3031) 2022-11-02 15:09:12 +00:00
49679d31e7 swarm/CHANGELOG.md: Fix version mismatch with v0.40.1 (#3063) 2022-11-02 13:41:28 +00:00
ee5c9b7202 build(deps): Update multiaddr requirement from 0.14.0 to 0.15.0 (#3051)
Updates the requirements on [multiaddr](https://github.com/multiformats/rust-multiaddr) to permit the latest version.
- [Release notes](https://github.com/multiformats/rust-multiaddr/releases)
- [Changelog](https://github.com/multiformats/rust-multiaddr/blob/master/CHANGELOG.md)
- [Commits](https://github.com/multiformats/rust-multiaddr/compare/v0.14.0...v0.15.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-02 12:57:21 +00:00
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
b42f28630e ROADMAP: Follow ups on recent review (#3062)
* ROADMAP: Remove project board for now

* ROADMAP: Encourage feedback

* ROADMAP: Remove TLS

* ROADMAP: Link to specs/ROADMAP.md

* ROADMAP: Prioritize QUIC beyond the first iteration

* ROADMAP: No longer mark QUIC as experimental
2022-10-26 10:20:34 +01:00
5bce6edff9 examples/gossipsub-chat: Add mDNS peer discovery (#2996)
Co-authored-by: João Oliveira <hello@jxs.pt>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-10-26 11:43:14 +11:00
437b387159 CHANGELOG.md: Move libp2p-tls to correct version (#3057)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-10-25 22:09:46 +11:00
4d1b165982 transports/tcp: Unify symbol naming (#2961)
Co-authored-by: Elena Frank <elena.frank@protonmail.com>
2022-10-24 15:41:08 +11:00
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
159a10b812 transports/tls: Add libp2p-tls as per spec (#2945)
Co-authored-by: David Craven <david@craven.ch>
Co-authored-by: Demi Marie Obenour <demiobenour@gmail.com>
Co-authored-by: Elena Frank <elena.frank@protonmail.com>
Co-authored-by: Max Inden <mail@max-inden.de
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Roman Proskuryakov <r.proskuryakoff@gmail.com>
2022-10-24 11:54:44 +11:00
a0adaf6a54 build(deps): Bump Swatinem/rust-cache from 2.0.0 to 2.0.1 (#3033)
* build(deps): Bump Swatinem/rust-cache from 2.0.0 to 2.0.1

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

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

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

* Apply suggestions from code review

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-10-21 19:03:44 +01:00
d10d433b9f build(deps): Update ed25519-compact requirement from 1.0.11 to 2.0.2 (#3016)
Updates the requirements on [ed25519-compact](https://github.com/jedisct1/rust-ed25519-compact) to permit the latest version.
- [Release notes](https://github.com/jedisct1/rust-ed25519-compact/releases)
- [Commits](https://github.com/jedisct1/rust-ed25519-compact/compare/1.0.11...2.0.2)

---
updated-dependencies:
- dependency-name: ed25519-compact
  dependency-type: direct:production
...

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

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-10-21 16:18:35 +01:00
56a4a946c6 Roadmap.md: Discuss the near term future of rust-libp2p (#2997)
The items in this roadmap are ordered by importance where importance is defined as:

- Enable others to build with rust-libp2p before building components ourself.
  - e.g.[cross behaviour communication](#cross-behaviour-communication) over[Kademlia client
    mode](#kademlia-client-mode) where the former enables the latter
- Invest into tools that enable us to work more efficiently
  - e.g.[Testground](#testground-abstraction) and [release process](#release-process)
- Better do one thing well than many things close to right.
  - e.g. deprioritize [BitSwap implementation](#bitswap-implementation) and continue on
    [QUIC](#quic-support) even once first ieration is merged. That does not imply that we won't
    support community members implementing it.
- Improve existing components before introducing new ones.
  - e.g.[Kademlia client mode](#kademlia-client-mode) before [WebTransport](#webtransport)
2022-10-20 21:37:02 +01:00
cec1a8d26f docs/release: Document cargo-release process and mention root changelog (#3028)
* docs/release: Document cargo-release process

* docs/release: Document update to root level changelog.md
2022-10-20 20:56:02 +01:00
4a4d4ad5c9 protocols/identify: Fix Identify protocol link in module doc (#3047) 2022-10-20 14:59:30 +01:00
3e4a0640fd Cargo.toml: Remove deprecated executor-specific features (#3001)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-10-20 14:17:20 +11:00