1387 Commits

Author SHA1 Message Date
Joonas Koivunen
ab6fecd9f3
Fix DialPeerCondition::Always handling (#1937)
* fix: always dial with condition Always

* chore: changelog note

* refactor: exhaustive DialPeerCondition matching

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2021-01-27 11:05:35 +01:00
Oliver Wangler
8aeb7b3db0
Allow OneShotHandler's max_dial_negotiate limit to be configurable. (#1936)
* Allow OneShotHandler's `max_dial_negotiate` limit to be configurable.

* Update version and CHANGELOG.,

Co-authored-by: Roman S. Borschel <roman@parity.io>
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2021-01-27 10:44:08 +01:00
Roman Borschel
ac9798297b
Rename and move libp2p-core-derive as libp2p-swarm-derive. (#1935) 2021-01-26 22:49:08 +01:00
Max Inden
6400719ae9
protocols/request-response: Add forgotten changelog entry 2021-01-21 15:40:26 +01:00
Max Inden
25ea8b67ff
*: Update changelogs and cargo tomls for req-resp patch 2021-01-21 14:36:58 +01:00
Tejas Sanap
5d22e30cc9
protocols/req-resp: Make is_pending_outbound return true on pending connection (#1928)
`is_pending_outbound` should return true if the connection
to the mentioned peer hasn't been established, yet.

Closes issue: #1885

Signed-off-by: Tejas Sanap <sanap.tejas@gmail.com>
2021-01-21 14:34:58 +01:00
Max Inden
bbd3df64ed
*: Update changelogs and cargo tomls for gossipsub change 2021-01-20 10:50:23 +01:00
Age Manning
eac43d144f
protocols/gossipsub: Prevent non-published messages being added to caches (#1930)
Currently, Gossipsub messages may not be published on a topic if there are no
subscribed peers on that topic, however they are being added to a duplicate
cache. If the messages are content-addressed, this prevents the user from
attempting to republish the message in the future.

This commit modifies the logic such that messages are only added to the caches
(duplicate, memcache and published_messages) if the message could be published
to at least one peer.

Previously, a failed publish would be added the memcache. This meant that the
router would gossip about a failed publish, such that if a peer joined the topic
after the failed publish (but within the gossip history time window) the message
could still be propagated to the newly connected peers. With this PR, a failed
publish now definitively indicates the message will not be published on the
network and the user is required to re-submit at a later time, once sufficient
peers exist on the topic.
2021-01-20 10:47:05 +01:00
dependabot[bot]
2c4de90356
Bump styfle/cancel-workflow-action from 0.6.0 to 0.7.0 (#1922)
Bumps [styfle/cancel-workflow-action](https://github.com/styfle/cancel-workflow-action) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/styfle/cancel-workflow-action/releases)
- [Commits](https://github.com/styfle/cancel-workflow-action/compare/0.6.0...d7e57e26a6f753933f8ef746a37097a61375236b)

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-01-14 20:16:14 +01:00
wackbyte
75b5fdfbca
Fix a typo in gossipsub (#1921) 2021-01-13 08:44:07 +01:00
Max Inden
9aaa624147
protocols/gossipsub/Cargo.toml: Fix feature name typo 2021-01-12 21:07:18 +01:00
Max Inden
db02cfae37
*: Prepare v0.34.0 release (#1918)
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2021-01-12 20:33:43 +01:00
Max Inden
a10f4e2879
*: Update to tokio v1.0.1 (#1919)
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2021-01-12 15:50:24 +01:00
quininer
a223e4ba9d
[websocket] Switch async-tls to futures-rustls (#1889)
* [websocket] Switch async-tls to async-rustls

* Switch to futures-rustls

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2021-01-12 15:18:44 +01:00
Max Inden
477f7ae6c4
*: Update to prost-build v0.7 (#1917) 2021-01-12 14:41:07 +01:00
dependabot[bot]
7367927bd8
Update uint requirement from 0.8 to 0.9 (#1915)
Updates the requirements on [uint](https://github.com/paritytech/parity-common) to permit the latest version.
- [Release notes](https://github.com/paritytech/parity-common/releases)
- [Commits](https://github.com/paritytech/parity-common/compare/uint-v0.8.3...uint-v0.9.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-01-12 13:53:51 +01:00
Roman Borschel
ec0f8a3150
[tcp] Port-reuse, async-io, if-watch (#1887)
* Update tomls.

* Let transports decide when to translate.

* Improve tcp transport.

* Update stuff.

* Remove background task. Enhance documentation.

To avoid spawning a background task and thread within
`TcpConfig::new()`, with communication via unbounded channels,
a `TcpConfig` now keeps track of the listening addresses
for port reuse in an `Arc<RwLock>`. Furthermore, an `IfWatcher`
is only used by a `TcpListenStream` if it listens on any interface
and directly polls the `IfWatcher` both for initialisation and
new events.

Includes some documentation and test enhancements.

* Reintroduce feature flags for tokio vs async-io.

To avoid having an extra reactor thread running for tokio
users and to make sure all TCP I/O uses the mio-based
tokio reactor.

Thereby run tests with both backends.

* Add missing files.

* Fix docsrs attributes.

* Update transports/tcp/src/lib.rs

Co-authored-by: Max Inden <mail@max-inden.de>

* Restore chat-tokio example.

* Forward poll_write_vectored for tokio's AsyncWrite.

* Update changelogs.

Co-authored-by: David Craven <david@craven.ch>
Co-authored-by: Max Inden <mail@max-inden.de>
2021-01-12 13:35:11 +01:00
Max Inden
c98b9ef407
*: Switch futures_codec to asynchronous-codec (#1908)
`futures-codec` has not been updated in the recent months. It still
depends on `bytes` `v0.5` preventing all downstream dependencies to
upgrade to `bytes` `v1.0`.

This commit replaces `futures_codec` in favor of `asynchronous-codec`
The latter is a fully upgraded fork of the former.

In addition this commit upgrades:

- bytes to v1
- unsigned-varint to v0.6.0
- prost to v0.7
2021-01-12 12:48:37 +01:00
Roman S. Borschel
aa2547ef6d Prepare parity-multiaddr-0.10.1 2021-01-12 11:01:35 +01:00
Pierre Krieger
eeaffd32ce
Update onion_addr.rs (#1912) 2021-01-12 10:56:58 +01:00
Max Inden
5be6a8bb72
protocols/kad: Prepare v0.27.1 patch release 2021-01-11 12:26:04 +01:00
Ivan Zderadicka
6538745b64
protocols/kad: Add From impl for kbucket::Key (#1909)
- From<record::Key>
- From<Vec<u8>

This will enable to use additional types in kad.get_closest_peers as it was
possible in pre 0.33 version.

Co-authored-by: Max Inden <mail@max-inden.de>
2021-01-11 12:23:36 +01:00
Age Manning
df7e73ec47
protocols/gossipsub: Add Gossipsub v1.1 support
This commit upgrades the current gossipsub implementation to support the [v1.1
spec](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md).

It adds a number of features, bug fixes and performance improvements. 

Besides support for all new 1.1 features, other improvements that are of particular note: 

- Improved duplicate LRU-time cache (this was previously a severe bottleneck for
  large message throughput topics)
- Extended message validation configuration options
- Arbitrary topics (users can now implement their own hashing schemes)
- Improved message validation handling - Invalid messages are no longer dropped
  but sent to the behaviour for application-level processing (including scoring)
- Support for floodsub, gossipsub v1 and gossipsub v2
- Protobuf encoding has been shifted into the behaviour. This has permitted two
  improvements:
     1. Message size verification during publishing (report to the user if the
        message is too large before attempting to send).
     2. Message fragmentation. If an RPC is too large it is fragmented into its
        sub components and sent in smaller chunks.

Additional Notes

The peer eXchange protocol defined in the v1.1 spec is inactive in its current
form. The current implementation permits sending `PeerId` in `PRUNE` messages,
however a `PeerId` is not sufficient to form a new connection to a peer. A
`Signed Address Record` is required to safely transmit peer identity
information. Once these are confirmed (https://github.com/libp2p/specs/pull/217)
a future PR will implement these and make PX usable.

Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Rüdiger Klaehn <rklaehn@protonmail.com>
Co-authored-by: blacktemplar <blacktemplar@a1.net>
Co-authored-by: Rüdiger Klaehn <rklaehn@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Roman S. Borschel <roman@parity.io>
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
Co-authored-by: David Craven <david@craven.ch>
2021-01-07 08:19:31 +01:00
Max Inden
d918e9a79d
*: Update changelogs and cargo tomls for new reqresp release 2021-01-04 18:51:05 +01:00
David Craven
6a85eb46fc
Re-export throttled-specific response channel (#1902) 2021-01-04 18:45:01 +01:00
Max Inden
47c5c80433
docs/release: Only choose crate name not bench name (#1897)
Some `Cargo.toml` files contain multiple `name` fields, e.g. the crate name and
the benchmark name (see
https://github.com/libp2p/rust-libp2p/blob/master/core/Cargo.toml). Only choose
the first one when constructing the tag.
2020-12-18 11:35:39 +01:00
Max Inden
dd9f56e7f9
*CHANGELOG.md: Prepare v0.33.0 release (#1895) 2020-12-18 10:03:20 +01:00
Max Inden
22817b5d2b
swarm: Remove NotifyHandler::All (#1880)
Remove `NotifyHandler::All` thus removing the requirement for events
send from a `NetworkBehaviour` to a `ProtocolsHandler` to be `Clone`. An
implementor of `NetworkBehaviour` can still notify all
`ProtocolHandler`s for a given peer by emitting one `NotifyHandler`
event per connection to that peer.
2020-12-17 11:01:45 +01:00
dependabot[bot]
6c970f0dda
Update pin-project requirement from 0.4.17 to 1.0.2 (#1894)
Updates the requirements on [pin-project](https://github.com/taiki-e/pin-project) to permit the latest version.
- [Release notes](https://github.com/taiki-e/pin-project/releases)
- [Changelog](https://github.com/taiki-e/pin-project/blob/master/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/pin-project/commits/v1.0.2)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-16 17:50:45 +01:00
Max Inden
6d3e2b514f
Cargo.toml: Add deflate and pnet to workspace (#1893) 2020-12-16 17:31:36 +01:00
Max Inden
447b2d315d
*: Update Cargo tomls and changelogs for libp2p-pnet v0.20.0 2020-12-16 17:02:14 +01:00
elenaf9
80a1ac845e
fix(pns): patch salsa20 dependency (#1892)
Co-authored-by: Max Inden <mail@max-inden.de>
2020-12-16 16:56:49 +01:00
Max Inden
0968b049fe
protocols/request-response: Derive Clone for {Inbound,Outbound}Failure (#1891) 2020-12-16 16:38:45 +01:00
Max Inden
3af5ba45f3
protocols/request-response: Emit InboundFailure::ConnectionClosed (#1886)
A user of libp2p-request-response is guaranteed to receive an additional event
after receiving a request via `RequestResponseEvent::Message`.

After receiving the request:

- If the user responds in time and the connection is still alive, the
user can expect a `ResponseSent`.

- If the user drops the response channel, the user can expect an
`InboundFailure::ResponseOmission`.

- If the user does not respond in time, the user can expect an
`InboundFailure::Timeout`.

Thus far the user did not receive an event when the connection to the
peer closes. With this commit:

- If the connection to the peer closes before the users calls
`send_response` or after the user calls `send_response` but before the
response can be send on the network, the user can expect an
`InboundFailure::ConnectionClosed`.
2020-12-16 16:03:35 +01:00
David Craven
23b0aa016f
Stack allocated PeerId (#1874)
* Stack allocate PeerId.

* Update stuff.

* Upgrade rusttls to fix build.

* Remove unnecessary manual implementations.

* Remove PeerId::into_bytes.

* Remove bytes dependency.

* Perform some cleanup.

* Use Into<kbucket::Key<K>>.

* Update versions and changelogs.

* Fix PR link.

* Fix benchmarks.

Co-authored-by: Roman S. Borschel <roman@parity.io>
2020-12-15 14:40:39 +01:00
dependabot[bot]
a26f6aa674
Update async-tls requirement from 0.10.2 to 0.11.0 (#1884)
* Update async-tls requirement from 0.10.2 to 0.11.0

Updates the requirements on [async-tls](https://github.com/async-std/async-tls) to permit the latest version.
- [Release notes](https://github.com/async-std/async-tls/releases)
- [Commits](https://github.com/async-std/async-tls/compare/v0.10.2...v0.11.0)

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

* *: Prepare release

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2020-12-10 09:16:08 +01:00
Roman Borschel
7985c81911
[websocket] Update minimum async-tls patch version. (#1881)
* Update minimum async-tls patch version.

After the upgrade to rustls 0.19, this is the minimum
version required to build.

* Prepare libp2p patch.
2020-12-09 16:31:17 +01:00
Roman Borschel
9b5d5dbc61
Prepare v0.32 (#1879) 2020-12-08 12:07:20 +01:00
Max Inden
0ef4c2d461
core/benches: Add PeerId sort_vec benchmark (#1878) 2020-12-08 11:48:03 +01:00
Roman Borschel
4c1657ea0f
[mdns] Split response packets if necessary. (#1877)
* [mdns] Split response packets.

Prevent MDNS response packets becoming too large by creating
multi-packet responses. Also skip addresses that don't fit
into a TXT record or contain invalid characters.

* Update protocols/mdns/src/dns.rs

Co-authored-by: Max Inden <mail@max-inden.de>

* Refactor response packet construction.

* Update mdns changelog.

Co-authored-by: Max Inden <mail@max-inden.de>
2020-12-08 11:47:35 +01:00
Max Inden
e665a818d7
core/benches: Add rudimentary benchmark for PeerId::from_bytes and clone (#1875)
* core: Add rudimentary benchmark for PeerId::from_bytes and clone

* .github/workflow: Include benchmarks

To ensure changes through pull requests won't make benchmarks fail to
compile or run, run them as part of CI.
2020-12-07 18:06:41 +01:00
Roman Borschel
3edc467d75
[request-response] Refine success & error reporting for inbound requests. (#1867)
* Refine error reporting for inbound request handling.

At the moment one can neither get confirmation when a
response has been sent on the underlying transport, nor
is one aware of response omissions. The latter was
originally intended as a feature for support of
one-way protocols, which seems like a bad idea in
hindsight. The lack of notification for sent
responses may prohibit implementation of some
request-response protocols that need to ensure
a happens-before relation between sending a
response and a subsequent request, besides uses
for collecting statistics.

Even with these changes, there is no active notification
for failed inbound requests as a result of connections
unexpectedly closing, as is the case for outbound requests.
Instead, for pending inbound requests this scenario
can be identified if necessary by the absense of both
`InboundFailure` and `ResponseSent` events for a particular
previously received request. Interest in this situation is
not expected to be common and would otherwise require
explicitly tracking all inbound requests in the `RequestResponse`
behaviour, which would be a pity. `RequestResponse::send_response`
now also synchronously returns an error if the inbound upgrade
handling the request has been aborted, due to timeout or
closing of the connection, giving more options for graceful
error handling for inbound requests.

As an aside, the `Throttled` wrapper now no longer emits
inbound or outbound error events occurring in the context
of sending credit requests or responses. This is in addition
to not emitting `ResponseSent` events for ACK responses of
credit grants.

* Update protocols/request-response/src/lib.rs

Co-authored-by: Max Inden <mail@max-inden.de>

* Address some minor clippy warnings. (#1868)

* Track pending credit request IDs.

In order to avoid emitting events relating to credit grants or acks
on the public API. The public API should only emit events relating
to the actual requests and responses sent by client code.

* Small cleanup

* Cleanup

* Update versions and changelogs.

* Unreleased

Co-authored-by: Max Inden <mail@max-inden.de>
2020-12-07 13:07:47 +01:00
Roman S. Borschel
12e50b13d0 Update top-level libp2p-websocket patch version. 2020-12-07 12:47:52 +01:00
Roman S. Borschel
226e1058e1 Prepare libp2p-websocket-0.26.1 2020-12-07 12:41:52 +01:00
dependabot[bot]
e41a963649
Update rustls requirement from 0.18.0 to 0.19.0 (#1852)
Updates the requirements on [rustls](https://github.com/ctz/rustls) to permit the latest version.
- [Release notes](https://github.com/ctz/rustls/releases)
- [Changelog](https://github.com/ctz/rustls/blob/main/OLDCHANGES.md)
- [Commits](https://github.com/ctz/rustls/compare/v/0.18.0...v/0.19.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-07 12:37:25 +01:00
David Craven
505a17dfc2
Adds support for handling interface changes to mdns behaviour. (#1830)
* mdns: handle address changes.

* Update examples.

* Use async-io.

* Fix tokio-chat.

* Address review comments.

* Update if-watch.

* Poll interfaces correctly.

* Use socket2 and remove wasm-time.

* Update if-watch.

* Update versions and changelogs.

* Further changelog updates.

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
Co-authored-by: Roman S. Borschel <roman@parity.io>
2020-12-03 13:30:52 +01:00
Roman S. Borschel
4bdb61be0d Prepare multistream-select-0.9.1 2020-12-02 16:41:59 +01:00
Roman Borschel
86402311fc
[multistream-select] Listener conformity for failed negotiations. (#1871)
* [multistream-select] Listener conformity for failed negotiations.

When `V1Lazy` is used and the listener does not support the
optimistic (and singular) proposal of the dialer, it currently
happens that dialer and listener get a different outcome of
the negotiation. The dialer eventually detects the failed
negotiation as soon as it tries to read from the stream, but
the listener either encounters an invalid message or unexpected
premature EOF, depending on the payload that the dialer sent
prematurely after its protocol proposal. In these cases the
listener must be lenient and fail the negotiation "normally",
i.e. not with a protocol violation or an I/O error.

* Update misc/multistream-select/src/tests.rs

Co-authored-by: Max Inden <mail@max-inden.de>

* Refine error handling.

Only be lenient with garbage or sudden EOF when reading
just after having sent a protocol rejection.

* Update misc/multistream-select/src/listener_select.rs

Co-authored-by: Max Inden <mail@max-inden.de>

Co-authored-by: Max Inden <mail@max-inden.de>
2020-12-02 16:40:58 +01:00
Roman Borschel
2cd2e6d654
Address some minor clippy warnings. (#1868) 2020-11-30 16:45:40 +01:00
Max Inden
afc5d0ef82
.github/workflow: Don't require nightly for doc link check (#1866)
The `broken_intra_doc_links` lint stabilized with Rust `v1.48`, thus the
special usage of `nightly` is not needed anymore in the pipeline step.
2020-11-30 11:11:20 +01:00