733 Commits

Author SHA1 Message Date
Max Inden
c161acfb50
*: Dial with handler and return handler on error and closed (#2191)
Require `NetworkBehaviourAction::{DialPeer,DialAddress}` to contain a
`ProtocolsHandler`. This allows a behaviour to attach custom state to its
handler. The behaviour would no longer need to track this state separately
during connection establishment, thus reducing state required in a behaviour.
E.g. in the case of `libp2p-kad` the behaviour can include a `GetRecord` request
in its handler, or e.g. in the case of `libp2p-request-response` the behaviour
can include the first request in the handler.

Return `ProtocolsHandler` on connection error and close. This allows a behaviour
to extract its custom state previously included in the handler on connection
failure and connection closing. E.g. in the case of `libp2p-kad` the behaviour
could extract the attached `GetRecord` from the handler of the failed connection
and then start another connection attempt with a new handler with the same
`GetRecord` or bubble up an error to the user.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-08-31 17:00:51 +02:00
dependabot[bot]
d617105233
build(deps): Update minicbor requirement from 0.10 to 0.11 (#2200)
Updates the requirements on [minicbor](https://gitlab.com/twittner/minicbor) to permit the latest version.
- [Release notes](https://gitlab.com/twittner/minicbor/tags)
- [Changelog](https://gitlab.com/twittner/minicbor/blob/master/CHANGELOG.md)
- [Commits](https://gitlab.com/twittner/minicbor/compare/minicbor-v0.10.0...minicbor-v0.11.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-26 17:11:08 +02:00
Max Inden
25004c4697
protocols/gossipsub: Use ed25519 in tests (#2197)
With f2905c07f1246c3c3fdc1cde95f7e9c5c1c9b01a the secp256k1 feature is
disabled by default. Instead of enabling it in the dev-dependency,
simply use ed25519.
2021-08-19 21:03:11 +02:00
Ruben De Smet
f2905c07f1
*: Make libp2p-core default features optional (#2181)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-08-18 12:08:45 +02:00
Ruben De Smet
c58f697ef0
protocols/kad: Enable filtering of (provider) records (#2163)
Introduce `KademliaStoreInserts` option, which allows to filter records.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-08-17 16:20:50 +02:00
Max Inden
ce23cbe76a
protocols/gossipsub: Fix inconsistency in mesh peer tracking (#2189)
Co-authored-by: Age Manning <Age@AgeManning.com>
2021-08-11 17:37:10 +02:00
Max Inden
f701b24ec0
*: Format with rustfmt (#2188)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-08-11 13:12:12 +02:00
Max Inden
008561283e
core/: Remove TInEvent and TOutEvent (#2183)
TInEvent and TOutEvent are implied through THandler and thus
superflucious. Both are removed in favor of a derivation through
THandler.
2021-08-11 12:41:28 +02:00
Thomas Eizinger
9d6562229f
*/: Replace Into with From (#2169)
Unless restricted by orphan rules, implementing `From` is superior
because it implies `Into` but leaves the choice to the user, which
one to use. Especially for errors, `From` is convenient because that
is what `?` builds on.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-08-03 15:55:36 +02:00
David Craven
e1f1af899b
protocols/mdns: Add IPv6 support (#2161)
Signed-off-by: Emil Majchrzak <majchrzakemil@gitlab.com>

Co-authored-by: Emil Majchrzak <majchrzakemil@gitlab.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2021-08-03 14:55:06 +02:00
ethDreamer
a696039c74
protocols/gossipsub: Convert message_id_fn's to closures (#2103)
This will allow capturing variables in these closures so that we can
make these functions aware of the forkId (necessary for altair).

Co-authored-by: Max Inden <mail@max-inden.de>
2021-08-03 14:29:56 +02:00
dependabot[bot]
3e914e59e2
build(deps): Update minicbor requirement from 0.9 to 0.10 (#2178)
Updates the requirements on [minicbor](https://gitlab.com/twittner/minicbor) to permit the latest version.
- [Release notes](https://gitlab.com/twittner/minicbor/tags)
- [Changelog](https://gitlab.com/twittner/minicbor/blob/master/CHANGELOG.md)
- [Commits](https://gitlab.com/twittner/minicbor/compare/minicbor-v0.9.0...minicbor-v0.10.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-03 14:04:49 +02:00
Max Inden
841b09aa69
protocols/relay/tests: Remove unused DummyPollParameters (#2172) 2021-07-31 21:40:50 +02:00
Thomas Eizinger
1e001a2e0e
protocols/ping: Don't force close conn if not supported by remote (#2149)
Don't close connection if ping protocol is unsupported by remote. Previously, a
failed protocol negotation for ping caused a force close of the connection. As a
result, all nodes in a network had to support ping. To allow networks where some
nodes don't support ping, we now emit `PingFailure::Unsupported` once for every
connection on which ping is not supported.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-30 22:21:21 +02:00
Thomas Eizinger
ad90167042
swarm/: Provide additional default impls on NetworkBehaviour (#2150)
Not all implementations of `NetworkBehaviour` need all callbacks.
We've have been adding new callbacks with default implementations
for a while now. There is no reason the initial ones cannot also
be defaulted, thus making it easier create new implementations.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-30 19:48:32 +02:00
Thomas Eizinger
7877929af2
.github/: Enforce no clippy warnings (#2148)
* Fix remaining clippy warnings.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-26 11:22:46 +02:00
dependabot[bot]
ed0c8f7139
build(deps): Update minicbor requirement from 0.8 to 0.9 (#2155)
Updates the requirements on [minicbor](https://gitlab.com/twittner/minicbor) to permit the latest version.
- [Release notes](https://gitlab.com/twittner/minicbor/tags)
- [Changelog](https://gitlab.com/twittner/minicbor/blob/master/CHANGELOG.md)
- [Commits](https://gitlab.com/twittner/minicbor/compare/minicbor-v0.8.0...minicbor-v0.9.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-22 22:57:49 +02:00
Ruben De Smet
371a7dab2c
to/into consistency for PublicKey and PeerId (#2145)
- Change `PublicKey::into_protobuf_encoding` to
  `PublicKey::to_protobuf_encoding`.

- Change `PublicKey::into_peer_id` to `PublicKey::to_peer_id`.

- Change `PeerId::from_public_key(PublicKey)` to
  `PeerId::from_public_key(&PublicKey)`.

- Add `From<&PublicKey> for PeerId`.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-22 22:34:13 +02:00
Thomas Eizinger
20183c1ea1
*: Fix clippy warnings (#2139)
* Fix needless question mark operator

* Don't convert from u64 to u64

LocalStreamId is already a u64, no need to convert.

* Don't use `.into()` to convert to the same type

* Don't specify lifetime if it can be inferred

* Use `vec!` macro if we immediately push to it

This creates the vector with the appropriate capacity.

* Don't index array when taking a reference is enough

Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-16 15:11:25 +02:00
dependabot[bot]
e1646a524b
build(deps): Update env_logger requirement from 0.8.1 to 0.9.0 (#2141)
Updates the requirements on [env_logger](https://github.com/env-logger-rs/env_logger) to permit the latest version.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.8.3...v0.9.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-15 10:43:04 +02:00
Max Inden
b5c6fa6281
*: Prepare v0.39.0 release (#2132) 2021-07-12 21:24:58 +02:00
Ruben De Smet
f600f7a518
protocols/kad: Fix number of remaining bootstrap requests. (#2125)
Fixes #2121

Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: @izolyomi
2021-07-09 15:02:29 +02:00
Elena Frank
99da27bd97
*: Patch prost / prost-build version to v0.8 (#2126) 2021-07-09 14:38:03 +02:00
Max Inden
05a4b16bb3
protocols/kad/behaviour: Remove false assert on connected_peers (#2120)
Given the following scenario:

1. Remote peer X connects and is added to `connected_peers`.
2. Remote peer X opens a Kademlia substream and thus confirms that it supports
   the Kademlia protocol.
3. Remote peer X is added to the routing table as `Connected`.
4. Remote peer X disconnects and is thus marked as `Disconnected` in the routing
   table.
5. Remote peer Y connects and is added to `connected_peers`.
6. Remote peer X re-connects and is added to `connected_peers`.
7. Remote peer Y opens a Kademlia substream and thus confirms that it supports
   the Kademlia protocol.
8. Remote peer Y is added to the routing table. Given that the bucket is already
   full the call to `entry.insert` returns `kbucket::InsertResult::Pending {
   disconnected }` where disconnected is peer X.

While peer X is in `connected_peers` it has not yet (re-) confirmed that it
supports the Kademlia routing protocol and thus is still tracked as
`Disconnected` in the routing table. The `debug_assert` removed in this pull
request does not capture this scenario.
2021-07-08 14:48:40 +02:00
Elena Frank
a414afd83c
swarm/: include ListenerId in SwarmEvents (#2123)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-08 11:41:33 +02:00
Thomas Eizinger
c1ef4bffd2
core/: Redesign upgrade::{write_one, write_with_len_prefix, read_one} (#2111)
1. Deprecating the `write_one` function

  Semantically, this function is a composition of `write_with_len_prefix` and
  `io.close()`. This represents a footgun because the `close` functionality is
  not obvious and only mentioned in the docs. Using this function multiple times
  on a single substream will produces hard to debug behaviour.

2. Deprecating `read_one` and `write_with_len_prefix` functions

3. Introducing `write_length_prefixed` and `read_length_prefixed`

- These functions are symmetric and do exactly what you would expect, just
  writing to the socket without closing
- They also have a symmetric interface (no more custom errors, just `io::Error`)

Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-03 16:23:10 +02:00
Sergey O. Boyko
4eb0659e4d
swarm/: Allow disconnecting from Swarm and NetworkBehaviour (#2110)
Add `ExpandedSwarm::disconnect_peer_id` and
`NetworkBehaviourAction::CloseConnection` to close connections to a specific
peer via an `ExpandedSwarm` or `NetworkBehaviour`.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-02 19:35:51 +02:00
r-zig
f9491e7e81
protocols/relay: Simplify running the relay example (#2080)
Simplify running the relay example with all peers run via docker compose.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-06-30 22:13:36 +02:00
Max Inden
904880f5e9
protocols/kad: Extend emitted events with basic information (#2087)
* Expose kbucket range on RoutingUpdated.

* Expose inbound request information.

* Expose whether routing update is new peer.
2021-06-28 14:14:31 +02:00
Elena Frank
e8fed53598
swarm/: Drive ExpandedSwarm via Stream trait only (#2100)
Change `Stream` implementation of `ExpandedSwarm` to return all
`SwarmEvents` instead of only the `NetworkBehaviour`'s events.

Remove `ExpandedSwarm::next_event`. Users can use `<ExpandedSwarm as
StreamExt>::next` instead.

Remove `ExpandedSwarm::next`. Users can use `<ExpandedSwarm as
StreamExt>::filter_map` instead.
2021-06-14 20:41:44 +02:00
David Craven
d45606ac97
protocols/gossipsub: Reduce log levels (#2101) 2021-06-12 08:11:55 +02:00
Max Inden
28fe6eda28
*: Use upstream multiaddr crate (#2075)
Use multiaddr instead of parity-multiaddr, removing the latter from the
repository.
2021-05-27 14:04:33 +02:00
Age Manning
a4728198a4
protocols/gossipsub: Fix minor lints and spelling (#2079) 2021-05-26 14:54:42 +02:00
Max Inden
0b7ee3fa92
*: Prepare v0.38.0 (#2072) 2021-05-17 12:43:24 +02:00
Age Manning
c5bcada2c2
protocols/gossipsub: Rework connection keep-alive (#2043)
Keep connections to peers in a mesh alive. Allow closing idle connections to
peers not in a mesh.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-05-14 09:16:50 +02:00
Max Inden
43a8ad8fc2
protocols/relay/examples: Add client server instructions (#2060)
Add instructions on how to run a three node example where a listening
relay client listens via a relay server and a dialing relay client dials
the listening relay client via the relay server.
2021-05-10 15:39:56 +02:00
David Craven
8988ac247e
protocols/mdns: Fix discovered event emission. (#2065)
mdns keeps rediscovering nodes. this PR changes that to only emit events for new
nodes it discovered. In addition we make sure to only send a query if it is
really needed. Some logging is added for debugging purposes.
2021-05-06 17:08:29 +02:00
Tomas Zemanovic
6257a8d402
protocols/gossipsub: Remove regex-filter feature flag (#2056)
Remove `regex-filter` feature flag thus always enabling
`regex::RegexSubscriptionFilter`.
2021-04-27 15:00:13 +02:00
David Craven
29d969be34
protocols/mdns: Fix timely discovery after listening on new address (#2053)
If you start listening after mdns joined a multicast group, the peers may not
discover eachother until the 5min timeout expires.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-04-21 16:07:38 +02:00
Max Inden
42441dbd86
*: Prepare v0.37.0 release (#2049) 2021-04-13 20:15:15 +02:00
David Craven
05aa794552
Derive debug for RelayConfig. (#2048)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-04-12 22:30:09 +02:00
David Craven
687145d784
protocols: Derive debug for MemoryStoreConfig and IdentifyConfig (#2029) 2021-04-12 13:30:30 +02:00
Max Inden
2d995a62e7
*: Fix redundant_semicolons warnings (#2039) 2021-04-10 21:40:06 +02:00
Max Inden
7cf8ac0862
protocols/identify: Emit Push event after successful identification push (#2030) 2021-04-10 19:46:57 +02:00
Thomas Eizinger
385af35047
Implement std::error::Error for InboundFailure and OutboundFailure (#2033)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-04-08 13:14:34 +02:00
dependabot[bot]
bb2df42019
build(deps): update derive_builder requirement from 0.9.0 to 0.10.0 (#2026)
* build(deps): update derive_builder requirement from 0.9.0 to 0.10.0

Updates the requirements on [derive_builder](https://github.com/colin-kiegel/rust-derive-builder) to permit the latest version.
- [Release notes](https://github.com/colin-kiegel/rust-derive-builder/releases)
- [Commits](https://github.com/colin-kiegel/rust-derive-builder/compare/v0.9.0...v0.10.0)

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

* protocols/gossipsub/CHANGELOG: Add entry

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2021-04-01 13:57:29 +02:00
David Craven
7779b8e2c1
swarm: Extend NetworkBehaviour callbacks. (#2011)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-03-24 17:21:53 +01:00
Roman S. Borschel
be2fb4ea8a Update mdns changelog. 2021-03-23 09:54:04 +01:00
David Craven
987c244f09
Derive Clone, Debug. (#2007)
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2021-03-23 09:53:06 +01:00
Roman Borschel
c8d69ab2e2
[identify] Add configurable automatic push on listen addr changes. (#2004)
* Add configurable automatic push of listen addr changes.

* Update changelog and cleanup.
2021-03-22 10:53:30 +01:00