1842 Commits

Author SHA1 Message Date
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
dependabot[bot]
144dc12fb6
build(deps): Bump actions/checkout from 2.3.5 to 2.4.0 (#2326)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.5 to 2.4.0.
- [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.3.5...v2.4.0)

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

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-15 12:13:23 +01:00
Max Inden
b13466e470
transports/websocket: Update rustls and webpki-roots (#2336)
Co-authored-by: quininer <quininer@live.com>
2021-11-14 23:27:13 +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
b8f0e44b27
transports/websocket: Handle websocket CLOSE with reason code (#2319)
Pass websocket CLOSE reason to the app as an
`Incoming::Closed(soketto::CloseReason)`.

This PR is a companion to https://github.com/paritytech/soketto/pull/31 and lets
applications know what the remote end claimed to be the reason for closing the
connection (if any).

`IncomingData` is now renamed to `Incoming` and the actual data (text or binary)
is moved into its own `Data` enum, which in turn allows `into_bytes()` and the
`AsRef` impl to apply more sanely to something that is actually data.

Co-authored-by: David Palm <dvdplm@gmail.com>
2021-10-30 12:19:22 +02:00
Max Inden
997cc9a078
swarm/src/behaviour: Fix outdated comment on derive's out_event (#2318)
The default behaviour changed with
https://github.com/libp2p/rust-libp2p/pull/2214. This updates the doc
comment.

Initially raised in
https://github.com/libp2p/rust-libp2p/pull/2290#issuecomment-944415562.
2021-10-30 11:20:31 +02:00
Max Inden
8ea60af589
*: Prepare v0.40.0-rc.3 release candidate (#2313) 2021-10-27 19:27:31 +02:00
Oliver Wangler
6e76435b80
core/: Help the compiler disambiguate usize inference (#2310)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-10-27 18:49:51 +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
4ef57383a6
swarm/src/lib: Continue polling network when behaviour is blocked (#2304)
With https://github.com/libp2p/rust-libp2p/pull/2248 a connection task
`await`s sending an event to the behaviour before polling for new events
from the behaviour [1].

When `Swarm::poll` is unable to deliver an event to a connection task it
returns `Poll::Pending` even though (a) polling `Swarm::network` might be
able to make progress (`network_not_ready` being `false`) and (b) it
does not register a waker to be woken up [2].

In combination this can lead to a deadlock where a connection task waits
to send an event to the behaviour and `Swarm::poll` returns
`Poll::Pending` failing to send an event to the connection task, not
registering a waiker in order to be polled again.

With this commit `Swarm::poll` will only return `Poll::Pending`, when
failing to deliver an event to a connection task, if the network is
unable to make progress (i.e. `network_not_ready` being `true`).

In the long-run `Swarm::poll` should likely be redesigned, prioritizing
the behaviour over the network, given the former is the control plane
and the latter potentially yields new work from the outside.

[1]: ca1b7cf043/core/src/connection/pool/task.rs (L224-L232)
[2]: ca1b7cf043/swarm/src/lib.rs (L756-L783)
2021-10-26 22:23:55 +02:00
Qinxuan Chen
97509519c5
core/: Update libsecp256k1 from 0.6 to 0.7 (#2306)
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
2021-10-22 12:09:02 +02:00
Max Inden
cd2588e182
core/tests/connection_limit: Fix flake in max_established_incoming (#2295)
The test `max_established_incoming` starts two networks with a
configured connection limit, spawns up to `limit + 1` connections and
expects the last connection to be closed due to being over the limit.

The previous test implementation depended on both networks to handle
each connection in sequence, which is not always the case.

E.g. while network 2 might expect the last connection to close, network
1 might finish upgrading the last connection before the second to last
  connection, thus expecting the second to last connection to close.

This commit drives network 1 and 2 in sequence and ensures both networks
are finished upgrading a connection before starting a new connection. In
addition it upgrade the test to use `quickcheck`.
2021-10-20 20:22:53 +02:00
dependabot[bot]
ca1b7cf043
build(deps): Bump actions/checkout from 2.3.4 to 2.3.5 (#2300)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.4 to 2.3.5.
- [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.3.4...v2.3.5)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2021-10-18 18:12:30 +02:00
Max Inden
a430e6bffc
protocols/kad: Export KademliaBucketInserts (#2294) 2021-10-15 15:30:16 +02:00
Max Inden
2d13f99d30
Cargo.toml: Fix version typo (#2292) 2021-10-15 11:55:44 +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
Elena Frank
7718d1de38
core/connection/listeners: Create event on remove_listener (#2261)
Create a `ListenersEvent::Closed` when a listener is removed via
`Swarm::remove_listener`. This makes it more consistent with `Swarm::listen_on`,
and also informs the Swarm about the associated expired addresses.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-10-11 22:38:55 +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
r-zig
57f34f6f26
core/src/connections: Avoid call to contains twice (#2279) 2021-10-08 10:18:34 +02:00
Max Inden
5ef430b8d8
misc/metrics/examples: Set openmetrics-text content-type (#2278)
Set "openmetrics-text" content type on HTTP GET response. Makes sure
Prometheus server parses returned metrics via OpenMetrics format instead
of legacy Prometheus format.
2021-10-07 14:07:25 +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
Max Inden
d60a6d55dc
transports/websocket/: Update to soketto v0.7.0 #2271
Co-authored-by: James Wilson <james@jsdw.me>
2021-10-05 23:10:28 +02:00
Thomas Eizinger
e9ac6d2a6a
.github/workflows/ci: Improve cache effectiveness (#2260)
To have caches operate at its maximum usefulness, we need to have a
1-to-1 mapping between build-comamnd and cache key. Otherwise rustc
has to rebuild certain artifacts because they were not in the cache.

By using matrices, we make github parallelise some of our jobs. This
has a double positive impact on CI runtime. Not only are our caches
more effective now, several jobs are now run in parallel.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-10-05 09:46:08 +02:00
Sztergbaum Roman
c7abb6f70c
transports/noise: Fix compilation with additional generic-array features (#2264)
For crate that depends on `generic-array = { version = "0.14.3", features =
["serde", "more_lengths"] }` It's seems that `as_ref()` is ambiguous.
2021-10-04 20:14:50 +02:00
Max Inden
5cbd4735dd
README: Add Thomas as maintainer (#2257)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-10-02 10:07:42 +10: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
jolestar
c860f5a3a7
README: Add starcoin to rust-libp2p users (#2246)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-09-26 16:14:27 +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
Noel Kwan
3c0f5c7848
src/tutorial.rs: Display ping events (#2234)
Co-authored-by: Max Inden <mail@max-inden.de>
2021-09-25 15:58:04 +02:00
Denis Pisarev
6f7a19e753
.github/workflows/ci.yml: Use swatinem/rust-cache (#2228) 2021-09-25 15:22:33 +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
Max Inden
2a6a1cc0d3
.github/workflows/ci.yml: Use clang 11 (#2233) 2021-09-14 12:21:11 +02:00
Max Inden
fcb2f62752
misc/metrics/src/swarm: Expose role on connections_closed (#2220)
Expose whether closed connection was a Dialer or Listener.
2021-09-09 15:35:45 +02:00