1842 Commits

Author SHA1 Message Date
dependabot[bot]
59bba65ac0
build(deps): Update async-std-resolver requirement from 0.20 to 0.21 (#2543)
* build(deps): Update async-std-resolver requirement from 0.20 to 0.21

Updates the requirements on [async-std-resolver](https://github.com/bluejekyll/trust-dns) to permit the latest version.
- [Release notes](https://github.com/bluejekyll/trust-dns/releases)
- [Changelog](https://github.com/bluejekyll/trust-dns/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bluejekyll/trust-dns/compare/v0.20.0...v0.21.1)

---
updated-dependencies:
- dependency-name: async-std-resolver
  dependency-type: direct:production
...

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

* build(deps): Update trust-dns-resolver requirement from 0.20 to 0.21

Updates the requirements on [trust-dns-resolver](https://github.com/bluejekyll/trust-dns) to permit the latest version.
- [Release notes](https://github.com/bluejekyll/trust-dns/releases)
- [Changelog](https://github.com/bluejekyll/trust-dns/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bluejekyll/trust-dns/compare/v0.20.0...v0.21.1)

---
updated-dependencies:
- dependency-name: trust-dns-resolver
  dependency-type: direct:production
...

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

* transports/dns: Bump patch version

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-03-02 14:10:53 +01:00
Max Inden
b919d0002a
swarm/src/lib: Improve connection counting for test_behaviour_disconnect_all (#2532) 2022-03-02 12:10:57 +01:00
dependabot[bot]
a179dbb449
build(deps): Bump actions/checkout from 2.4.0 to 3 (#2544)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.4.0...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-02 11:26:08 +01:00
Thomas Eizinger
d1f472b3c0
core/src/transport: Don't print inner error when returning as source (#2533)
According to
https://github.com/rust-lang/project-error-handling/issues/44#issuecomment-858151860,
we should not be printing the inner error AND returning it as source. Libraries
like `anyhow` will traverse the chain of `source` errors and build up a composed
error message. Printing it and returning the same error from `source` results in
duplicate error messages in that case.
2022-03-01 15:39:01 +01:00
Karatus
fd31d61a7f
examples/chat-tokio.rs: Fix typo (#2541) 2022-02-28 10:50:07 +01:00
Friedel Ziegelmayer
e2fcc47da6
swarm/src/behaviour: Remove Send bound from NetworkBehaviour (#2535)
The bound is no longer needed across the libp2p-XXX crates.

Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-28 10:27:58 +01:00
Max Inden
99855b1d10
*: Apply clippy suggestions (#2540) 2022-02-28 10:05:17 +01:00
Max Inden
b1859464c9
*: Prepare v0.43.0 (#2531) 2022-02-22 14:05:19 +01:00
Max Inden
fd2be38faf
swarm/: Rename ProtocolsHandler to ConnectionHandler (#2527)
A `ProtocolsHandler`, now `ConnectionHandler`, handels a connection, not
a protocol. Thus the name `CONNECTIONHandler` is more appropriate.

Next to the rename of `ProtocolsHandler` this commit renames the `mod
protocols_handler` to `mod handler`. Finally all combinators (e.g.
`ProtocolsHandlerSelect`) are renamed appropriately.
2022-02-21 13:32:24 +01:00
Marco Munizaga
6511e6ba45
core/src/signed_envelope/: Return signing key with payload (#2522)
Remove `SignedEnvelope::payload` in favor of
`SignedEnvelope::payload_and_signing_key`. The caller is expected to check that
the returned signing key makes sense in the payload's context.
2022-02-21 10:45:57 +01:00
Max Inden
2ff9acee22
swarm/: Make NodeHandlerWrapper an impl detail of connection (#2523)
Previously one would wrap a `ProtocolsHandler` into a
`NodeHandlerWrapper` as early as possible, even though the functionality
of `NodeHandlerWrapper` is only needed within `mod connection`.

This commit makes `NodeHandlerWrapper` an implementation detail of `mod
connection`, thus neither `mod protocols_handler`, `mod pool` nor the
root level (`libp2p-swarm`) need to bother about the abstraction.

In addition to the above, this commit:

- Renames `NodeHandlerWrapper` to `HandlerWrapper`. The word `Node` is
  outdated.
- Removes `NodeHandlerWrapperBuilder`. With this simplification it is no
  longer needed.
- Folds `NodeHandlerWrapperError` into `ConnectionError`. No need for
  upper layers to be aware of the fact that `ProtocolHandler`s are
  wrapped.
2022-02-18 11:32:58 +01:00
Max Inden
eeb3504d5f
swarm/src/lib: Rework connection exports (#2525) 2022-02-17 21:12:37 +01:00
Nazar Mokrynskyi
65cc8994a6
*: Derive Debug and Clone(#2495)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-16 16:16:54 +01:00
Age Manning
9f1114d8b9
protocols/gossipsub: Add IWANT and memcache misses metrics (#2518)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-16 15:54:24 +01:00
dependabot[bot]
80bbb6224f
build(deps): Update parking_lot requirement from 0.11.0 to 0.12.0 (#2463)
* build(deps): Update parking_lot requirement from 0.11.0 to 0.12.0

Updates the requirements on [parking_lot](https://github.com/Amanieu/parking_lot) to permit the latest version.
- [Release notes](https://github.com/Amanieu/parking_lot/releases)
- [Changelog](https://github.com/Amanieu/parking_lot/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Amanieu/parking_lot/compare/0.11.0...0.12.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-16 15:16:04 +01:00
Max Inden
8ffa84e786
swarm/src: Remove ConnectionHandler (#2519)
The `ConnectionHandler` trait is not exposed to users. The only
implementor of `ConnectionHandler` is `NodeHandlerWrapper`. Thus
`ConnectionHandler` is a superfluous abstraction. This commit removes
`ConnectionHandler`.

Next to this large change, this commit removes the `Tmuxer` trait
parameter. `Swarm` enforces dynamic dispatching via `StreamMuxerBox`
anyways, thus the trait parameter is useless.

As a follow up to this commit one could rename `ProtocolsHandler` to
`ConnectionHandler` and `NodeHandlerWrapper` to
`ConnectionHandlerWrapper` or just `Wrapper`.
2022-02-16 13:15:52 +01:00
Laurent Senta
df4905d798
core/src: Take ref of key in SignedEnvelope & PeerRecord (#2516) 2022-02-15 23:47:32 +01:00
Elena Frank
dceb72bfe2
protocols/autonat: Fix flaky test (#2480) 2022-02-15 14:12:41 +01:00
Max Inden
146ed5f45e
swarm/: Report aborted connections (#2517)
Disconnect pending connections with `Swarm::disconnect` and eport aborted
connections via `SwarmEvent::OutgoingConnectionError`.

Co-authored-by: Jack Maloney <git@jmmaloney4.xyz>
Co-authored-by: Marco Munizaga <git@marcopolo.io>
2022-02-15 10:19:55 +01:00
Divma
e66f04f41b
protocols/gossipsub: Do not overwrite msg's peers if put again into mcache (#2493)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-14 15:49:00 +01:00
Age Manning
60666f5455
protocols/gossipsub: Revert back to wasm_timer for interval (#2506)
Removed the custom interval implementation and removes support for
wasm32-unknown-unknown. See https://github.com/libp2p/rust-libp2p/issues/2497
for details.

Co-authored-by: Diva M <divma@protonmail.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-14 11:24:58 +01:00
Max Inden
7fc342e6c0
{core,swarm}: Remove Network abstraction (#2492)
This commit removes the `Network` abstraction, thus managing `Listeners`
and the connection `Pool` in `Swarm` directly. This is done under the
assumption that noone uses the `Network` abstraction directly, but
instead everyone always uses it through `Swarm`. Both `Listeners` and
`Pool` are moved from `libp2p-core` into `libp2p-swarm`. Given that they
are no longer exposed via `Network`, they can be treated as an
implementation detail of `libp2p-swarm` and `Swarm`.

This change does not include any behavioural changes.

This change has the followin benefits:

- Removal of `NetworkEvent`, which was mostly an isomorphism of
  `SwarmEvent`.
- Removal of the never-directly-used `Network` abstraction.
- Removal of now obsolete verbose `Peer` (`core/src/network/peer.rs`)
  construct.
- Removal of `libp2p-core` `DialOpts`, which is a direct mapping of
  `libp2p-swarm` `DialOpts`.
- Allowing breaking changes to the connection handling and `Swarm` API
  interface without a breaking change in `libp2p-core` and thus a
  without a breaking change in `/transport` protocols.

This change enables the following potential future changes:

- Removal of `NodeHandler` and `ConnectionHandler`. Thus allowing to
  rename `ProtocolsHandler` into `ConnectionHandler`.
- Moving `NetworkBehaviour` and `ProtocolsHandler` into `libp2p-core`,
  having `libp2p-xxx` protocol crates only depend on `libp2p-core` and
  thus allowing general breaking changes to `Swarm` without breaking all
  `libp2p-xxx` crates.
2022-02-13 21:57:38 +01:00
Max Inden
861e15dabb
src/tutorials: Add hole punching tutorial (#2460) 2022-02-10 16:36:20 +01:00
Frederik-Baetens
b39770b8e9
swarm/src/behaviour: Document impact of blocking code (#2482)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-09 20:26:59 +01:00
Max Inden
44d63d8ed4
core/src/: Validate PeerRecord signature matching peer ID (#2491)
Co-authored-by: Marco Munizaga <git@marcopolo.io>
2022-02-09 16:39:02 +01:00
Age Manning
e6f034c132
protocols/gossipsub: Remove outdated warning (#2496)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-09 16:24:08 +01:00
Max Inden
4eb3d15db1
protocols/dcutr: Add changelog (#2499) 2022-02-09 16:09:00 +01:00
Divma
dc8433e3fc
swarm/src/behaviour: Merge inject_* paired methods (#2445)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-09 16:08:28 +01:00
Frederik-Baetens
5a95a46cd3
protocols/: Add documentation on peer discovery (#2465)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-09 15:54:07 +01:00
Max Inden
0bb8ee98d5
protocols/: Implement Direct Connection Upgrade through Relay (DCUtR) (#2438)
Enables two peers to coordinate a hole punch (direct connection upgrade)
via a relayed connection.

See https://github.com/libp2p/specs/blob/master/relay/DCUtR.md for
specification.
2022-02-08 15:56:35 +01:00
Nazar Mokrynskyi
bd41e0461e
protocols/kad: Require owned key in get_record (#2477)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-07 22:56:30 +01:00
Divma
78f5981856
protocols/gossipsub: Emit gossip of all non empty topics (#2481)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-07 20:00:46 +01:00
Jacob
ab7ed43b4a
core/src/transport/memory: Test parse_memory_addr with PeerId (#2468)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-07 19:32:07 +01:00
dependabot[bot]
8d13666167
build(deps): Update snow requirement from 0.8.0 to 0.9.0 (#2472)
* build(deps): Update snow requirement from 0.8.0 to 0.9.0

Updates the requirements on [snow](https://github.com/mcginty/snow) to permit the latest version.
- [Release notes](https://github.com/mcginty/snow/releases)
- [Commits](https://github.com/mcginty/snow/compare/v0.8.0...v0.9.0)

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

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-02-04 17:05:10 +01:00
Volker Mische
a2c93fc766
*: Update multihash and multiaddr (#2469)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-03 17:38:41 +01:00
Max Inden
1b6ffb1164
core/: Add Display implementation for DialError (#2473)
Co-authored-by: Frederik Baetens <baetens.fr@gmail.com>
2022-02-03 12:49:01 +01:00
Max Inden
3f4dbb1717
{misc,protocols/gossipsub}: Move to prometheus-client (#2442)
`open-metrics-client` has been accepted as the official Prometheus Rust
client and thus renamed to `prometheus-client`.

See https://groups.google.com/g/prometheus-developers/c/E67ByGmVQKM
2022-02-03 11:31:41 +01:00
Max Inden
fbdd208da6
swarm/src/protocols_handler: Document alternative to Event::Close (#2470)
There are 3 ways to close a connection:

1. `ProtocolsHandlerEvent::Close`
2. `KeepAlive::No` via `ProtocolsHandler::connection_keep_alive`
3. `NetworkBehaviourAction::CloseConnection`

This commit references (2) as an alternative to (1) in the documentation
of (1).
2022-02-02 21:54:06 +01:00
Max Inden
ea180aa3a8
*: Prepare v0.42.1 (#2467) 2022-02-02 15:59:32 +01:00
Max Inden
e04e95adcd
transports/tcp/: Call take_error on TCP socket (#2458)
Within `Provider::new_stream` we wait for the socket to become writable
(`stream.writable`), before returning it as a stream. In other words, we
are waiting for the socket to connect before returning it as a new TCP
connection.  Waiting to connect before returning it as a new TCP
connection allows us to catch TCP connection establishment errors early.

While `stream.writable` drives the process of connecting, it does not
surface potential connection errors themselves. These need to be
explicitly collected via `TcpSocket::take_error`. If not explicitly
collected, they will surface on future operations on the socket.

For now this commit explicitly calls `TcpSocket::take_error` when using
`async-io` only. `tokio` introduced the method (`take_error`) in
https://github.com/tokio-rs/tokio/pull/4364 though later reverted it in
https://github.com/tokio-rs/tokio/pull/4392. Once re-reverted, the same
patch can be applied when using `libp2p-tcp` with tokio.

---

One example on how this bug surfaces today:

A `/dnsaddr/xxx` `Multiaddr` can potentially resolve to multiple IP
addresses, e.g. to the IPv4 and the IPv6 addresses of a node.
`libp2p-dns` tries dialing each of them in sequence using `libp2p-tcp`,
returning the first that `libp2p-tcp` reports as successful.

Say that the local node tries the IPv6 address first. In the scenario
where the local node's networking stack does not support IPv6, e.g. has
no IPv6 route, the connection attempt to the resolved IPv6 address of
the remote node fails. Given that `libp2p-tcp` does not call
`TcpSocket::take_error`, it would falsly report the TCP connection
attempt as successful. `libp2p-dns` would receive the "successful" TCP
connection for the IPv6 address from `libp2p-tcp` and would not attempt
to dial the IPv4 address, even though it supports IPv4, and instead
bubble up the "successful" IPv6 TCP connection. Only later, when writing
or reading from the "successful" IPv6 TCP connection, would the IPv6
error surface.

Co-authored-by: Oliver Wangler <oliver@wngr.de>
2022-02-01 19:59:34 +01:00
Max Inden
6338b25e4b
protocols/relay/src/v2: Remove empty peer entries in self.reservations (#2464)
When a peer disconnects, reservations associated with that peer are removed from
the set of reservations of the peer. In case the set of reservations for the
peer is now empty, remove the entire peer.

Same when a reservation times out.
2022-02-01 19:32:58 +01:00
Elena Frank
13ded7f6a8
protocols/autonat/tests: Ignore irrelevant events (#2450)
Ignore `SwarmEvent::ExpiredListenAddr` in tests.
Print swarm event on panic.

Co-authored-by: Max Inden <mail@max-inden.de>
2022-01-29 12:33:15 +01:00
Roland Kuhn
45bb66f862
CHANGELOG.md: Fix link to yamux changelog (#2455) 2022-01-29 12:14:26 +01:00
Max Inden
1201af6904
README: Advertise biweekly community calls (#2454) 2022-01-28 18:46:59 +01:00
Max Inden
73c103e694
protocols/autonat/Cargo.toml: Add description field (#2452)
Without one can not publish the crate to crates.io.
2022-01-27 12:17:02 +01:00
Max Inden
e6ccfbc4e7
*: Prepare v0.42.0 (#2440) 2022-01-27 11:29:09 +01:00
folex
320a1cde00
protocols/kad: Add Kademlia::get_closest_local_peers (#2436)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-01-22 11:43:07 +01:00
Max Inden
a26b6ab7f0
protocols/autonat: Add changelog and start version at v0.1.0 (#2444)
The `libp2p-autonat` crate has never been released, thus it should start at
`v0.1.0`.
2022-01-20 13:18:05 +01:00
hanabi1224
fad99808ac
*: Update tokio, lru and prost (#2443) 2022-01-20 09:43:32 +01:00
dependabot[bot]
d52ab1baac
build(deps): Update rmp-serde requirement from 0.15 to 1.0 (#2439)
Updates the requirements on [rmp-serde](https://github.com/3Hren/msgpack-rust) to permit the latest version.
- [Release notes](https://github.com/3Hren/msgpack-rust/releases)
- [Commits](https://github.com/3Hren/msgpack-rust/compare/rmp-serde/v0.15.0...rmp-serde/v1.0.0)

---
updated-dependencies:
- dependency-name: rmp-serde
  dependency-type: direct:production
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-19 21:06:02 +01:00