1842 Commits

Author SHA1 Message Date
Max Inden
9b1f405012
misc/metrics/src/kad: Set query_duration lowest bucket to 0.1 sec (#2219)
Probability for a Kademlia query to return in less than 100 milliseconds
is low, thus increasing the lower bucket to improve accuracy within the
higher ranges.
2021-09-08 18:44:03 +02:00
David Craven
67722c534d
protocols/mdns: Do not fire all timers at the same time. (#2212)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-09-07 19:04:57 +02:00
Max Inden
733a0b6ce4
core/src/network/event.rs: Fix typo (#2218) 2021-09-07 17:08:45 +02:00
Thomas Eizinger
adcfdc0750
protocols/rendezvous: Implement protocol (#2107)
Implement the libp2p rendezvous protocol.

> A lightweight mechanism for generalized peer discovery. It can be used for
bootstrap purposes, real time peer discovery, application specific routing, and
so on.

Co-authored-by: rishflab <rishflab@hotmail.com>
Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-09-07 16:36:52 +02:00
Thomas Eizinger
c1ae8a046c
protocols/ping: Revise naming of symbols (#2215)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-09-06 16:10:48 +02:00
Thomas Eizinger
6924e5ef7a
core/: Remove deprecated read/write functions (#2213)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-09-06 08:04:30 +02:00
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]
b55ee69645
build(deps): Update salsa20 requirement from 0.8 to 0.9 (#2206)
* build(deps): Update salsa20 requirement from 0.8 to 0.9

Updates the requirements on [salsa20](https://github.com/RustCrypto/stream-ciphers) to permit the latest version.
- [Release notes](https://github.com/RustCrypto/stream-ciphers/releases)
- [Commits](https://github.com/RustCrypto/stream-ciphers/compare/ctr-v0.8.0...salsa20-v0.9.0)

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

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

* *: Bump pnet to v0.22

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2021-08-30 12:53:09 +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
Max Inden
1e9fcf90ea
core/: Remove DisconnectedPeer::set_connected and Pool::add (#2195)
This logic seems to be a leftover of
https://github.com/libp2p/rust-libp2p/pull/889 and unused today.
2021-08-19 20:17:18 +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
Max Inden
49acf2eb5b
swarm/src/protocols_handler: Impl ProtocolsHandler on either::Either (#2192)
Implement ProtocolsHandler on either::Either representing either of two
ProtocolsHandler implementations.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-08-17 18:02:06 +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
a5b6a0b694
examples/README: Give an overview over the many examples (#2194) 2021-08-16 21:43:40 +02:00
Max Inden
d3f5a1e79a
examples/: Add file sharing example (#2186)
Basic file sharing application with peers either providing or locating
and getting files by name.

While obviously showcasing how to build a basic file sharing
application, the actual goal of this example is **to show how to
integrate rust-libp2p into a larger application**.

Architectural properties

- Clean clonable async/await interface ([`Client`]) to interact with the
network layer.

- Single task driving the network layer, no locks required.
2021-08-16 20:02:11 +02:00
Max Inden
0afed65c74
README: Mention security@ipfs.io 2021-08-16 16:07:38 +02:00
Max Inden
98bc5e6486
misc/metrics: Add auxiliary crate to record events as OpenMetrics (#2063)
This commit adds an auxiliary crate recording protocol and Swarm events
and exposing them as metrics in the OpenMetrics format.
2021-08-13 22:51:54 +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
Philipp
7391b6e3f3
Cargo.toml: Reexport wasm-bindgen feature from parking_lot (#2180)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-08-11 12:11:54 +02:00
Max Inden
a0d690e259
swarm/src/lib: Refactor trait usage (#2182)
- Removes the `Swarm` type alias, renaming `ExpandedSwarm` to `Swarm`.
- Remove `TInEvent`, `TOutEvent` and `THandler` trait parameters on
`Swarm`, instead deriving them through `TBehaviour`. Move derive logic
to separate type aliases.
- Simplify trait bounds on `Swarm` main `impl` and `Stream` `impl`.
2021-08-09 15:29:58 +02:00
Elena Frank
68b5f743ad
src/tutorial,examples/: Enhance docs on multiaddrs (#2187)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-08-09 15:07:14 +02:00
Max Inden
4c028e081a
swarm/src/behaviour: Update DialAddress doc comment (#2179)
With 45f07bf8639fd9056e4ffe52298ca113a0308951 `Network::dial` accepts a
`Multiaddr` with a `PeerId`. With that in mind the doc comment on
`NetworkBehaviourAction::DialAddress` is outdated.
2021-08-08 21:59:14 +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
dependabot[bot]
ae9a14eaa0
build(deps): Bump styfle/cancel-workflow-action from 0.9.0 to 0.9.1 (#2167)
Bumps [styfle/cancel-workflow-action](https://github.com/styfle/cancel-workflow-action) from 0.9.0 to 0.9.1.
- [Release notes](https://github.com/styfle/cancel-workflow-action/releases)
- [Commits](https://github.com/styfle/cancel-workflow-action/compare/0.9.0...0.9.1)

---
updated-dependencies:
- dependency-name: styfle/cancel-workflow-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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>
2021-08-02 20:53:28 +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
Age Manning
76f1fcbee3
core: Add a total established connection limit (#2137)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-30 19:22:53 +02:00
izolyomi
99c7078bcf
core/identity: Document using external fixed keys for network identity (#2165)
Co-authored-by: István Zólyomi <istvan.zolyomi@iop-ventures.com>
Co-authored-by: Ruben De Smet <ruben.de.smet@rubdos.be>
Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-28 21:43:51 +02:00
Ruben De Smet
50b0957dfe
core/: Add Keypair::to_protobuf_encoding (#2142)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-07-28 17:59:08 +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]
e437c009dc
build(deps): Update libsecp256k1 requirement from 0.5.0 to 0.6.0 (#2151)
Updates the requirements on [libsecp256k1](https://github.com/paritytech/libsecp256k1) to permit the latest version.
- [Release notes](https://github.com/paritytech/libsecp256k1/releases)
- [Changelog](https://github.com/paritytech/libsecp256k1/blob/master/CHANGELOG.md)
- [Commits](https://github.com/paritytech/libsecp256k1/commits)

---
updated-dependencies:
- dependency-name: libsecp256k1
  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-23 10:54:15 +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
b814231251
swarm-derive: Update to v0.24.0 (#2136) 2021-07-12 22:20:34 +02:00
Max Inden
b5c6fa6281
*: Prepare v0.39.0 release (#2132) 2021-07-12 21:24:58 +02:00
dependabot[bot]
ee11922d97
build(deps): Update multiaddr requirement from 0.12.0 to 0.13.0 (#2129)
* build(deps): Update multiaddr requirement from 0.12.0 to 0.13.0

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.12.0...v0.13.0)

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

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

* build(deps): Update multihash requirement from 0.13 to 0.14

Updates the requirements on [multihash](https://github.com/multiformats/rust-multihash) to permit the latest version.
- [Release notes](https://github.com/multiformats/rust-multihash/releases)
- [Commits](https://github.com/multiformats/rust-multihash/compare/v0.13.0...v0.14.0)

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>
2021-07-09 16:21:12 +02:00
Max Inden
a368ee34dc
.github/dependabot: Disable pull request limit (#2128)
Increase pull request limit to 9999, practically disabling the limit.
2021-07-09 15:41:13 +02:00
dependabot[bot]
fe6172b565
build(deps): Update env_logger requirement from 0.6 to 0.8 (#2127) 2021-07-09 13:25:14 +00: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