1168 Commits

Author SHA1 Message Date
Mikhail Zabaluev
b61c3f9d04
Update libp2p-dns doc to include /dns/ support (#1634)
Now that /dns/ is supported, it should be mentioned in
the documentation as well.
2020-06-29 15:05:11 +02:00
Toralf Wittner
7fd69ecf3f
Fix spelling mistake. (#1627) 2020-06-24 15:19:01 +02:00
Toralf Wittner
c9f121201c
Release v0.20.1 (#1624)
- Update `libp2p-kad` CHANGELOG and increment version to 0.20.1.
- Update `libp2p` version to 0.20.1.
- Fix some linter warning in `libp2p-gossipsub` and increment
  version to 0.19.3 and update CHANGELOG.
2020-06-23 11:51:49 +02:00
Toralf Wittner
32cb0a56bd
kad: Avoid from/into IteratorIndex. (#1623)
This caused problems with type inference.
2020-06-23 11:28:43 +02:00
Toralf Wittner
0eef487ef8
Prepare release. (#1620) 2020-06-22 11:41:28 +02:00
Max Inden
e8e41f4efb
CHANGELOG.md: Add entry for disjoint-paths feature in libp2p-kad (#1617) 2020-06-19 13:57:10 +02:00
Max Inden
9dd2d662e9
protocols/kad: Implement S-Kademlia's lookup over disjoint paths v2 (#1473)
The extension paper S-Kademlia includes a proposal for lookups over
disjoint paths. Within vanilla Kademlia, queries keep track of the
closest nodes in a single bucket. Any adversary along the path can thus
influence all future paths, in case they can come up with the
next-closest (not overall closest) hops. S-Kademlia tries to solve the
attack above by querying over disjoint paths using multiple buckets.

To adjust the libp2p Kademlia implementation accordingly this change-set
introduces an additional peers iterator: `ClosestDisjointPeersIter`.
This new iterator wraps around a set of `ClosestPeersIter`
`ClosestDisjointPeersIter` enforces that each of the `ClosestPeersIter`
explore disjoint paths by having each peer instantly return that was
queried by a different iterator before.
2020-06-19 12:22:26 +02:00
Pierre Krieger
00fc223487
Deprecate StreamMuxer::is_remote_acknowledged (#1616) 2020-06-19 11:59:24 +02:00
Toralf Wittner
563d3374ed
Update CHANGELOG and increment version to 0.19.2 (#1615) 2020-06-19 11:13:02 +02:00
Toralf Wittner
168b00ed3e
Add CHANGELOG and increment version to 0.19.2 (#1614) 2020-06-18 17:02:23 +02:00
Toralf Wittner
859aa59bd8
Avoid recursive dependencies due to tests. (#1609)
Remove `version` from workspace `dev-dependencies`.
2020-06-18 10:27:47 +02:00
Thomas Eizinger
44236b5ba3
Bump snow to version 0.7.0 (#1610) 2020-06-16 14:58:06 +02:00
Toralf Wittner
b983c94c59
Update to soketto v0.4.0 (#1603)
* Update to soketto v0.4.0

* Remove patch section from Cargo.toml

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2020-06-15 16:23:07 +02:00
kericfrank
569113e368
Update README.md (#1607)
Add marcopoloprotocol to the list
2020-06-15 16:06:29 +02:00
Rüdiger Klaehn
926274e88c
Add PartialOrd and Ord for PeerId (#1594)
for using PeerId in order based collections. Ord uses borrow to be
consistent with equality.
2020-06-15 16:04:43 +02:00
Roman Borschel
e8bf34fcf1
[libp2p-ping] Properly close the substream in the InboundUpgrade. (#1606)
Not doing so may result in FIN/RST frames being sent before
earlier data frames. See https://github.com/paritytech/yamux/pull/81#issuecomment-643169973.
2020-06-12 17:41:04 +02:00
Taiki Endo
9aaf042410
Remove uses of pin_project::project attribute (#1604)
pin-project will deprecate the project attribute due to some unfixable
limitations.

Refs: https://github.com/taiki-e/pin-project/issues/225
2020-06-09 18:01:57 +02:00
Pierre Krieger
cacd7300de
Fix MultiHandler panicking when empty (#1598) 2020-06-05 11:48:53 +02:00
Pierre Krieger
c76327e6b5
Pin async-std in a different way (#1600) 2020-06-05 11:14:02 +02:00
Rüdiger Klaehn
7c63bbf975
Update README.md (#1597)
Add rust-ipfs to the list of notable users

Not sure if it is notable enough, but it is open source and looking for contributors, so it would be cool to have it listed here.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-06-05 10:56:26 +02:00
Pierre Krieger
a4eb67a40d
Fix some libp2p-kad types not being reexported (#1595)
* Fix QueryRef/QueryMut not being reexported

* More reexports
2020-06-02 10:33:32 +02:00
Qinxuan Chen
ce1b3aab04
Fix tcp-tokio feature (#1582)
Signed-off-by: koushiro <koushiro.cqx@gmail.com>

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2020-05-26 13:47:41 +02:00
Roman Borschel
fbccf4c72a
Readd lost noise upgrades. (#1580) 2020-05-25 18:39:56 +02:00
Pierre Krieger
baac0366f2
Also bump core-derive (#1593) 2020-05-25 16:17:37 +02:00
Pierre Krieger
a921b7cb73
Publish v0.19.1 (#1592) 2020-05-25 16:02:30 +02:00
Eduardo Leegwater Simões
93ff335c96
Fully qualified std::result::Result in macros (#1587)
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2020-05-25 15:27:49 +02:00
Roman Borschel
25dc7c08e3
Temporarily bound all async-std dependencies. (#1589)
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-05-25 14:49:16 +02:00
Pierre Krieger
e0cf026bbb
Try revert to nightly-2020-05-20 (#1590) 2020-05-25 13:28:21 +02:00
Pierre Krieger
34faf94538
Publish 0.19.0 (#1579) v0.19.0 2020-05-18 15:45:21 +02:00
Pierre Krieger
162a0be0c2
Display the identity hash of PeerIds when relevant (#1576)
* Display the identity hash of PeerIds when relevant

* Add CHANGELOG entry
2020-05-18 12:42:51 +02:00
Kevin Zhang
2fbd1a5503
Keep consistency with Upgrade Inbound by using PING_SIZE (#1578)
although 32 is prefect fine in our case, it would be consistent to use the const value PING_SIZE.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-05-18 11:14:31 +02:00
Thomas Eizinger
bbc67351d3
Extend feature-flags to allow choosing runtime for libp2p-tcp (#1471)
* Extend feature-flags to allow choosing runtime for libp2p-tcp

* Added CHANGELOG entry

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-05-18 10:37:42 +02:00
Mikhail Zabaluev
82156deac5
Support /dns protocol in multiaddr (#1575)
* Add /dns protocol support to multiaddr

The /dns protocol has been added to the spec and has had a de-facto
meaning for years.
See https://github.com/multiformats/multiaddr/pull/100

This adds address parsing and encoding support for /dns to the multiaddr
format library.

* Cover Dns protocol in multiaddr property tests

* transports/dns: Support the /dns protocol

* Support /dns protocol in address translation

* Translate an FQDN URL into a /dns multiaddr

* transports/websocket: Support /dns multiaddr

* Use the /dns protocol in websocket redirects

The whole thing with back-translating from an redirect URL looks a bit
baroque, but at least now the transport does not completely ignore IPv6
addresses resolved from a hostname in a redirect URL.

* Add CHANGELOG entry

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-05-18 10:21:55 +02:00
Roman Borschel
3a96ebf57f
More insight into Kademlia queries. (#1567)
* [libp2p-kad] Provide more insight and control into Kademlia queries.

More insight: The API allows iterating over the active queries and
inspecting their state and execution statistics.

More control: The API allows aborting queries prematurely
at any time.

To that end, API operations that initiate new queries return the query ID
and multi-phase queries such as `put_record` retain the query ID across all
phases, each phase being executed by a new (internal) query.

* Cleanup

* Cleanup

* Update examples and re-exports.

* Incorporate review feedback.

* Update CHANGELOG

* Update CHANGELOG

Co-authored-by: Max Inden <mail@max-inden.de>
2020-05-16 10:43:09 +02:00
Pierre Krieger
c271f6f56b
Make the number of events buffered to/from tasks configurable (#1574)
* Make the number of events buffered to/from tasks configurable

* Assign a PR number

* Fix comment

* Apply suggestions from code review

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>

* Rename variables

* Apply suggestions from code review

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2020-05-15 14:40:10 +02:00
David Craven
0443fea157
Update to latest multihash. (#1566)
* Update to latest multihash.

* Update changelog.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-05-13 17:51:11 +02:00
Rüdiger Klaehn
a83654ca4c
Add a method to create a pre shared key when you already have the raw bytes (#1570) 2020-05-13 17:08:12 +02:00
Max Inden
06721128f1
protocols/kad: Remove unnecessary PeerId conversion for fixed iter (#1573)
`FixedPeersIter` requires the initial set of peers to be passed as
`PeerId`s and not as `Key<PeerId>`s. This commit removes the unnecessary
conversion.
2020-05-13 16:47:02 +02:00
Max Inden
70e797112f
protocols/kad/query/closest: Make quickcheck deterministic (#1571)
Instead of creating unconstrained random number generators in quickcheck
tests to generate test data, have quickcheck provide a `Seed` to seed
those random number generators and thus make the test execution
deterministic / reproducible.
2020-05-12 21:31:20 +02:00
Roman Borschel
5ba7c4831b
Permit concurrent dialing attempts per peer. (#1506)
* Permit concurrent dialing attempts per peer.

This is a follow-up to https://github.com/libp2p/rust-libp2p/pull/1440
and relates to https://github.com/libp2p/rust-libp2p/issues/925.
This change permits multiple dialing attempts per peer.
Note though that `libp2p-swarm` does not yet make use of this ability,
retaining the current behaviour. The essence of the changes are that the
`Peer` API now provides `Peer::dial()`, i.e. regardless of the state in
which the peer is. A dialing attempt is always made up of one or more
addresses tried sequentially, as before, but now there can be multiple
dialing attempts per peer. A configurable per-peer limit for outgoing
connections and thus concurrent dialing attempts is also included.

* Introduce `DialError` in `libp2p-swarm`.

For a cleaner API and to treat the case of no addresses
for a peer as an error, such that a `NetworkBehaviourAction::DialPeer`
request is always matched up with either `inject_connection_established`
or `inject_dial_error`.

* Fix rustdoc link.

* Add `DialPeerCondition::Always`.

* Adapt to master.

* Update changelog.
2020-05-12 13:10:18 +02:00
Max Inden
44c0c76981
protocols/kad/query/fixed: Decrease num_waiting on failure (#1572)
Make sure to decrease `num_waiting` when being notified of a peer
failure to allow an additional peer to be queried.

Given that `FixedPeersIter` is initialized with `replication_factor` by
`QueryPool` this bug will not surface today.
2020-05-12 12:23:40 +02:00
Roman Borschel
bd5e81fedb
Spec-compliant Noise Protocol (#1545)
* Add spec-compliant x25519 protocol.

* Cosmetic protobuf spec compliance.

* Keep support for IK/IX. Update changelog.

* Update docs.

* CI
2020-05-06 14:30:23 +02:00
Pierre Krieger
69fd8ac195
Update CI to clang-10 (#1565) 2020-05-06 13:50:18 +02:00
Max Inden
1be34fd7a3
protocols/gossipsub: Correct max transmit size error handling (#1558)
If a user sends a message that is over the maximum transmission size gossipsub
will disconnect from the peer being sent the message.

This PR updates the logic to simply emit an error, not send the over-sized
message but maintain the long-lived streams for future messages.

Co-authored-by: Age Manning <Age@AgeManning.com>
2020-04-28 16:18:35 +02:00
Arjan Topolovec
3d4ae5da4b
fix: NetworkBehaviour crash if ignoring a non-last struct field (#1554)
Macro was using field_n (field index including ignored fields) for calculations instad of
enum_n (field index excluding ignored fields). When calculating te nesting the calculation
was made between the number of non-ignored fields and a field_n that lead to and overflow.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-04-28 11:38:25 +02:00
Toralf Wittner
bdbab32392
tcp: Set IPV6_V6ONLY for IPv6 listeners. (#1555)
* tcp: Set IPV6_V6ONLY for IPv6 listeners.

The current behaviour of listening on an IPv6 address varies depending
on the operating system's IP address stack implementation. Some support
IPv4-mapped IPv6 addresses (e.g. Linux and newer versions of Windows)
so a single IPv6 address would support IPv4-mapped addresses too.
Others do not (e.g. OpenBSD). If they do, then some support them by
default (e.g. Linux) and some do not (e.g. Windows).

This PR attempts to implement the same behaviour accross operating
systems. The strategy is as follows:

Disable IPv4-mapped IPv6 addresses, hence the socket option IPV6_V6ONLY
is always set to true.

This allows binding two sockets to the same port and also avoids the
problem of comparing mixed addresses which leads issues such as #1552.

* Update CHANGELOG and address review concerns.

* Update CHANGELOG.md

Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-04-24 19:07:27 +02:00
Max Inden
f187fd4d1c
CHANGELOG: Add changelog entry for 9f981a4bb6 (#1550) 2020-04-20 10:05:17 +02:00
Max Inden
9f981a4bb6
src/query/peers/closest: Consider K_VALUE peers at initialization (#1536)
* protocols/kad/query/peers/closest: Consider K_VALUE nodes at init

By considering `K_VALUE` at `ClosestPeersIter` initialization, the initial peer
set length is independent of `num_results` and thus of the `replication_factor`.

* protocols/kad/src/behaviour/test: Enable building single nodes

Introduces the `build_node` function to build a single not connected
node. Along the way replace the notion of a `port_base` with returning
the actual `Multiaddr` of the node.

* protocols/kad/behaviour/test: Fix bootstrap test initialization

When looking for the closest node to a key, Kademlia considers
ALPHA_VALUE nodes to query at initialization. If `num_groups` is larger
than ALPHA_VALUE the remaining locally known nodes will not be
considered. Given that no other node is aware of them other than node 1,
they would be lost entirely. To prevent the above restrict `num_groups`
to be equal or smaller than ALPHA_VALUE.

* protocols/kad/behaviour/test: Fix put_record and get_provider

In the past, when trying to find the closest nodes to a key, Kademlia
would consider `num_result` amount of nodes to query out of all the
nodes it is aware of.

Both the `put_record` and the `get_provider` tests initialized their
swarms in the same way. The tests took the replication factor to use as
an input. The number of results to get was equal to the replication
factor. The amount of swarms to start was twice the replication factor.
Nodes would be grouped in two groups a replication factor nodes. The
first node would be aware of all of the nodes in the first group. The
last node of the first group would be aware of all the nodes in the
second group.

By coincidence (I assume) these numbers played together very well. At
initialization the first node would consider `num_results` amount of
peers (see first paragraph). It would then contact each of them. As the
first node is aware of the last node of the first group which in turn is
aware of all nodes in the second group, the first node would eventually
discover all nodes.

Recently the amount of nodes Kademlia considers at initialization when
looking for the nodes closest to a key was changed to only consider
ALPHA nodes.

With this in mind playing through the test setup above again would
result in (1) `replication_factor - ALPHA` nodes being entirely lost as
the first node would never consider them and (2) the first node probably
never contacting the last node out of the first group and thus not
discovering any nodes of the second group.

To keep the multi hop discovery in place while not basing ones test
setup on the lucky assumption of Kademlia considering replication factor
amount of nodes at initialization, this patch alters the two tests:

Build a fully connected set of nodes and one addition node (the first
node). Connect the first node to a single node of the fully connected
set (simulating a boot node). Continue as done previously.

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2020-04-17 19:57:35 +02:00
Pierre Krieger
87b5efb3e8
Make sure inject_dial_failure is called (#1549)
* Make sure inject_dial_failure is called

* Update CHANGELOG

* Make libp2p-kad tests pass

* Fix again

* Update swarm/src/lib.rs

Co-Authored-By: Toralf Wittner <tw@dtex.org>

* Revert "Fix again"

This reverts commit 80c0d3d908aff282d492f213d2ce34d12489167d.

* Bump versions and CHANGELOG

* Oops, didn't bump libp2p-swarm in libp2p

Co-authored-by: Toralf Wittner <tw@dtex.org>
v0.18.1
2020-04-17 18:13:16 +02:00
Max Inden
77a34c0a0d
protocols/kad/query/peers/closest: Make at_capacity use max (#1548)
When not making progress for `parallelism` time a `ClosestPeersIter`
becomes `State::Stalled`. When stalled an iterator is allowed to make
more parallel requests up to `num_results`. If `num_results` is smaller
than `parallelism` make sure to still allow up to `parallelism` requests
in-flight.

Co-Authored-By: Roman Borschel <romanb@users.noreply.github.com>
2020-04-16 15:33:09 +02:00