925 Commits

Author SHA1 Message Date
Victor Ermolaev
75ae7b0461
protocols/floodsub: Propagate messages only to target peers (#2360)
Propagate messages only to the target peers and not all connected peers.

Co-authored-by: Victor Ermolaev <victorermolaev@gmail.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2021-12-06 17:08:29 +01:00
Victor Ermolaev
4401ffa8b3
protocols/mdns/: Generate peer expiry and fix IPv6 support (#2359)
Co-authored-by: Victor Ermolaev <victorermolaev@gmail.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2021-12-06 16:52:31 +01:00
Thomas Eizinger
2d61fe296f
*: Fix clippy errors from upgrade to Rust 1.57 (#2365)
* core: Mark "unused" field with "_"

We need to keep this marker type to ensure that the type continues
to be required to be pinned.

* tranports/noise: Derive `Default` for `Config`

`false` is the default for `bool`, we can derive this.

* protocols/request-response: Remove unused fields

These are already included the `RequestResponseMessage::Request`
variant.

* *: Allow clippy's large-enum-variant lint

Tackling these suggestions would require performance measurement
which we don't want to do at this stage.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-12-06 16:13:42 +01:00
dependabot[bot]
2370b5ef74
build(deps): Update lru requirement from 0.6 to 0.7 (#2364)
Updates the requirements on [lru](https://github.com/jeromefroe/lru-rs) to permit the latest version.
- [Release notes](https://github.com/jeromefroe/lru-rs/releases)
- [Changelog](https://github.com/jeromefroe/lru-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jeromefroe/lru-rs/compare/0.6.0...0.7.0)

---
updated-dependencies:
- dependency-name: lru
  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>
2021-11-29 19:15:20 +01:00
Elena Frank
29e91c7338
protocols/request-response: Handle address change on connection (#2362) 2021-11-29 18:59:44 +01:00
Max Inden
16ce66272a
protocols/request-response: Remove unused crate lru (#2358) 2021-11-26 18:08:16 +01:00
Dan Shields
a7ed1d6b6e
*: Migrate to Rust 2021 edition (#2339)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-11-26 17:34:58 +01:00
Divma
fd417517ca
swarm/: Patch reporting on banned peer connections (#2350)
Don't report events of a connection to the `NetworkBehaviour`, if connection has
been established while the remote peer was banned. Among other guarantees this
upholds that `NetworkBehaviour::inject_event` is never called without a previous
`NetworkBehaviour::inject_connection_established` for said connection.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-11-26 16:48:12 +01:00
Pancy
f0000d56cd
protocols/mdns: Use a random alphanumeric string for peer name (#2311)
With https://github.com/libp2p/specs/pull/368 the definition of the _peer name_
changed in the mDNS specification.

> peer-name is the case-insensitive unique identifier of the peer, and is less
> than 64 characters.
>
> As the this field doesn't carry any meaning, it is sufficient to ensure the
> uniqueness of this identifier. Peers SHOULD generate a random, lower-case
> alphanumeric string of least 32 characters in length when booting up their
> node. Peers SHOULD NOT use their Peer ID here because a future Peer ID could
> exceed the DNS label limit of 63 characters.

https://github.com/libp2p/specs/blob/master/discovery/mdns.md

This commit adjusts `libp2p-mdns` accordingly.

Also see https://github.com/libp2p/go-libp2p/pull/1222 for the corresponding
change on the Golang side.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-11-25 20:15:00 +01:00
dependabot[bot]
4d688329a3
build(deps): Update open-metrics-client requirement from 0.12.0 to 0.13.0 (#2355)
* build(deps): Update open-metrics-client requirement

Updates the requirements on [open-metrics-client](https://github.com/mxinden/rust-open-metrics-client) to permit the latest version.
- [Release notes](https://github.com/mxinden/rust-open-metrics-client/releases)
- [Changelog](https://github.com/mxinden/rust-open-metrics-client/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mxinden/rust-open-metrics-client/compare/v0.12.0...v0.13.0)

---
updated-dependencies:
- dependency-name: open-metrics-client
  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>
2021-11-24 17:26:03 +01:00
Max Inden
4bd44c812a
*: Prepare v0.41.0 (#2342) 2021-11-16 16:39:42 +01:00
Divma
2066a192ad
protocols/gossipsub: Add mesh metrics (#2316)
Enable instrumenting mesh through metrics and add gossipsub to
misc/metrics.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-11-16 14:59:39 +01:00
Marco Munizaga
c4f7877853
protocols/identify: Check multiaddr has valid peer id component prior to caching (#2338)
Check multiaddr has valid peer id component or none at all. We don't want to
cache a multiaddr with a purposely wrong multiaddr. e.g. something that ends
with .../p2p/some-other-peer. While this should fail to dial because we [check
this before
dialing](https://github.com/libp2p/rust-libp2p/blob/master/core/src/connection/pool/concurrent_dial.rs#L144),
it's better to not cache this in the first place.
2021-11-16 13:05:47 +01:00
Max Inden
220f84a97f
swarm/: Enable advanced dialing requests (#2317)
Enable advanced dialing requests both on `Swarm` and via
`NetworkBehaviourAction`. Users can now trigger a dial with a specific
set of addresses, optionally extended via
`NetworkBehaviour::addresses_of_peer`. In addition the whole process is
now modelled in a type safe way via the builder pattern.

Example of a `NetworkBehaviour` requesting a dial to a specific peer
with a set of addresses additionally extended through
`NetworkBehaviour::addresses_of_peer`:

```rust
NetworkBehaviourAction::Dial {
    opts: DialOpts::peer_id(peer_id)
              .condition(PeerCondition::Always)
              .addresses(addresses)
              .extend_addresses_through_behaviour()
              .build(),
    handler,
}
```

Example of a user requesting a dial to an unknown peer with a single
address via `Swarm`:

```rust
swarm1.dial(
    DialOpts::unknown_peer_id()
        .address(addr2.clone())
        .build()
)
```
2021-11-15 14:17:23 +01:00
Max Inden
82730f8a92
protocols/rendezvous/tests/harness: Use module name instead of mod.rs (#2335)
To be consistent with the rest of the codebase, use harness.rs instead
of mod.rs.

See also https://github.com/libp2p/rust-libp2p/pull/1400
2021-11-13 22:53:03 +01:00
Divma
8b68026bb0
protocols/gossipsub: Update topic_peers (#2325)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-11-04 00:21:51 +01:00
Max Inden
012287ad1e
Merge branch 'libp2p/v0.40' into master (#2324)
* *: Prepare v0.40.0 release (#2323)

* Cargo.toml: Remove rc suffix
2021-11-02 20:40:48 +01:00
pradt2
7c2253d89d
protocols/kad: Populate the key field to fix go-libp2p interop (#2309)
populate the `key` field when converting `kadrequestmsg::putvalue` to
`proto::message`.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-10-30 16:30:17 +02:00
Max Inden
06c339c141
protocols/kad: Refactor KademliaEvent (#2321)
Rename `KademliaEvent::InboundRequestServed` to `KademliaEvent::InboundRequest` and move
`InboundPutRecordRequest` into `InboundRequest::PutRecord` and `InboundAddProviderRequest` into
`InboundRequest::AddProvider`.

Co-authored-by: supercmmetry <vishaals2000@gmail.com>
2021-10-30 15:50:45 +02:00
Max Inden
ff5d455ccf
*: Enable libp2p to run via wasm32-unknown-unknown in the browser (#2320)
Changes needed to get libp2p to run via `wasm32-unknown-unknown` in the browser
(both main thread and inside web workers).

Replaces wasm-timer with futures-timer and instant.

Co-authored-by: Oliver Wangler <oliver@wngr.de>
2021-10-30 12:41:30 +02:00
Max Inden
8ea60af589
*: Prepare v0.40.0-rc.3 release candidate (#2313) 2021-10-27 19:27:31 +02:00
Max Inden
185b763803
protocols/identify: Disable address cache by default (#2312)
See https://github.com/libp2p/rust-libp2p/issues/2302 for details.
2021-10-27 18:25:37 +02:00
Max Inden
a430e6bffc
protocols/kad: Export KademliaBucketInserts (#2294) 2021-10-15 15:30:16 +02:00
Max Inden
a905665b8b
*: Prepare v0.40.0-rc.1 release (#2290) 2021-10-15 11:15:05 +02:00
Max Inden
40c5335e3b
core/: Concurrent dial attempts (#2248)
Concurrently dial address candidates within a single dial attempt.

Main motivation for this feature is to increase success rate on hole punching
(see https://github.com/libp2p/rust-libp2p/issues/1896#issuecomment-885894496
for details). Though, as a nice side effect, as one would expect, it does
improve connection establishment time.

Cleanups and fixes done along the way:

- Merge `pool.rs` and `manager.rs`.

- Instead of manually implementing state machines in `task.rs` use
  `async/await`.

- Fix bug where `NetworkBehaviour::inject_connection_closed` is called without a
  previous `NetworkBehaviour::inject_connection_established` (see
  https://github.com/libp2p/rust-libp2p/issues/2242).

- Return handler to behaviour on incoming connection limit error. Missed in
  https://github.com/libp2p/rust-libp2p/issues/2242.
2021-10-14 18:05:07 +02:00
dependabot[bot]
c0d7d4a9eb
build(deps): Update prost-build requirement from 0.8 to 0.9 (#2288)
Updates the requirements on [prost-build](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: prost-build
  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-10-14 14:44:34 +02:00
dependabot[bot]
3cc102da91
build(deps): Update prost requirement from 0.8 to 0.9 (#2287)
Updates the requirements on [prost](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: prost
  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-10-14 14:16:54 +02:00
Thomas Eizinger
6d3ab8a3de
protocols/identify: Assist in peer discovery based on reported listen addresses from other peers (#2232)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-10-13 21:46:34 +02:00
Vishaal Selvaraj
3eb0344832
protocols/kad: Remove outdated TODO (#2282)
Signed-off-by: supercmmetry <vishaals2000@gmail.com>
2021-10-10 13:43:58 +02:00
dependabot[bot]
937b59de89
build(deps): Update lru requirement from 0.6 to 0.7 (#2267)
Updates the requirements on [lru](https://github.com/jeromefroe/lru-rs) to permit the latest version.
- [Release notes](https://github.com/jeromefroe/lru-rs/releases)
- [Changelog](https://github.com/jeromefroe/lru-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jeromefroe/lru-rs/compare/0.6.0...0.7.0)

---
updated-dependencies:
- dependency-name: lru
  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-10-05 23:26:13 +02:00
Oliver Wangler
9f331e517f
protocols/rendezvous: Export Cookie (#2256)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-10-01 18:45:19 +02:00
McFranko
decfeadc0d
protocols/gossipsub: Implement std::error::Error for error types (#2254)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-10-01 18:23:08 +02:00
stuart nelson
c13f03354b
protocols/kad: Check local store on get_providers (#2221) 2021-09-27 18:22:10 +02:00
Age Manning
d93a5ab11c
protocols/gossipsub: Handle unsupported peers (#2241)
Previously, peers that did not support gossipsub were removed from the
connection-id mappings.

This can cause the connection_id mappings to go out of sync with those managed
by the swarm. This PR corrects this and adds an extra event that can inform the
user that a peer that does not support the protocol has connected. The user can
then optionally handle peers that don't support the protocol.
2021-09-27 09:21:37 +02:00
Oliver Wangler
303490103b
protocols/rendezvous: Improve examples (#2229)
* Add support for the `Identify` protocol to the server, such that the
  `register_with_identify` example works as intended
* Add discovery loop to the `discovery` example and demonstrate cookie
  usage
* Drop explicit dependency on async_std

Co-authored-by: Max Inden <mail@max-inden.de>
2021-09-25 18:39:49 +02:00
Pierre Krieger
f030b15be0
protocols/request-response: Remove throttled module (#2236)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Max Inden <mail@max-inden.de>
2021-09-25 18:18:06 +02:00
Thomas Eizinger
e83e1b3d0b
swarm-derive/: Make event_process = false the default (#2214)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-09-14 15:28:08 +02:00
Roman
b79fd02f0b
*: Fix clippy warnings (#2227) 2021-09-14 15:00:05 +02:00
Roman
5f68c74177
protocols/rendezvous: Update prost (#2226)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-09-14 12:53:59 +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
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
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