398 Commits

Author SHA1 Message Date
folex
51bdf2757d Fix kad behaviour test.rs 2020-04-21 19:54:30 +03:00
folex
807217653a fluence janus branch 2020-04-20 19:36:17 +03:00
folex
5e49b42b77 Merge Libp2p 0.18 & 0.18.1 2020-04-20 19:34:21 +03:00
folex
9863c11cd3 Merge branch 'master' into fluence_master
# Conflicts:
#	CHANGELOG.md
#	Cargo.toml
#	core/Cargo.toml
#	misc/core-derive/Cargo.toml
#	misc/peer-id-generator/Cargo.toml
#	muxers/mplex/Cargo.toml
#	muxers/yamux/Cargo.toml
#	protocols/deflate/Cargo.toml
#	protocols/floodsub/Cargo.toml
#	protocols/gossipsub/Cargo.toml
#	protocols/identify/Cargo.toml
#	protocols/kad/Cargo.toml
#	protocols/kad/src/behaviour.rs
#	protocols/kad/src/behaviour/test.rs
#	protocols/mdns/Cargo.toml
#	protocols/noise/Cargo.toml
#	protocols/ping/Cargo.toml
#	protocols/plaintext/Cargo.toml
#	protocols/pnet/Cargo.toml
#	protocols/secio/Cargo.toml
#	swarm/Cargo.toml
#	swarm/src/lib.rs
#	transports/dns/Cargo.toml
#	transports/tcp/Cargo.toml
#	transports/uds/Cargo.toml
#	transports/wasm-ext/Cargo.toml
#	transports/websocket/Cargo.toml
2020-04-20 19:29:58 +03:00
folex
8d8901302b
Better routing table printing (#8) 2020-04-20 16:22:13 +03: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
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
Pierre Krieger
aa71158e5c
Publish 0.18.0 (#1547) 2020-04-09 16:54:01 +02:00
Joonas Koivunen
80ea2f6fd7
feat: allow sent messages seen as subscribed (#1520)
* feat: allow sent messages seen as subscribed

minor feature to allow mimicing the behaviour expected by ipfs api tests.

* refactor: rename per review comments

* refactor: rename Floodsub::options to config

* chore: update changelog

* Update CHANGELOG.md

Co-Authored-By: Max Inden <mail@max-inden.de>

Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-04-09 15:15:17 +02:00
Max Inden
c1191d5f83
protocols/kad/behaviour: Return peers independent of record existence (#1544)
A node receiving a `GetRecord` request first checks whether it has the
given record. If it does have the record it does not return closer
nodes.

A node that knows the record for the given key is likely within a
neighborhood of nodes that know the record as well. In addition the node
likely knows its neighboorhood well.

When querying for a key with a quorum of 1 the above behavior of only
returning the record but not any close peers is fine. Once one queries
with a higher quorum having a node respond with the record as well as
close nodes is likely going to speed up the query, given that the
returned peers probably know the record as well.
2020-04-08 10:31:45 +02:00
vms
9d078e87ea another fix 2020-04-06 14:26:00 +03:00
vms
910ffd580c wip 2020-04-06 13:48:36 +03:00
vms
077b3301ab libp2p 0.17 2020-04-06 12:55:56 +03:00
Pierre Krieger
3ae02a56a5
Bump to 0.17.0 (#1537) 2020-04-01 19:53:34 +02:00
folex
ec0b5dc364
Log bucket table (#5) 2020-04-01 12:52:37 +03:00
Roman Borschel
be970466b3
Full support for multiple connections per peer in libp2p-swarm. (#1519)
* [libp2p-swarm] Make the multiple connections per peer first-class.

This commit makes the notion of multiple connections per peer
first-class in the API of libp2p-swarm, introducing the new
callbacks `inject_connection_established` and
`inject_connection_closed`. The `endpoint` parameter from
`inject_connected` and `inject_disconnected` is removed,
since the first connection to open may not be the last
connection to close, i.e. it cannot be guaranteed,
as was previously the case, that the endpoints passed
to these callbacks match up.

* Have identify track all addresses.

So that identify requests can be answered with the correct
observed address of the connection on which the request
arrives.

* Cleanup

* Cleanup

* Improve the `Peer` state API.

* Remove connection ID from `SwarmEvent::Dialing`.

* Mark `DialPeerCondition` non-exhaustive.

* Re-encapsulate `NetworkConfig`.

To retain the possibility of not re-exposing all
network configuration choices, thereby providing
a more convenient API on the \`SwarmBuilder\`.

* Rework Swarm::dial API.

* Update CHANGELOG.

* Doc formatting tweaks.
2020-03-31 15:41:13 +02:00
Max Inden
2296a87b73
protocols/kad/behaviour: Use HashSet to deduplicate GetProviders (#1528)
Given that the order of `PeerId`s within the `GetProvidersOk.providers`
set is irrelevant but duplication is at best confusing this commit makes
use of a `HashSet` instead of a `Vec` to return unique `PeerId`s only.
2020-03-31 12:00:17 +02:00
folex
034c3e41fe Fix typo in test 2020-03-30 15:04:12 +03:00
folex
b067a022f0 set trust graph branch to master 2020-03-30 12:45:06 +03:00
folex
49a51609dd println => log 2020-03-30 11:59:17 +03:00
folex
4f3d6bc587 Tests in weighted 2020-03-29 17:19:34 +03:00
folex
7bc74a0e51 Merge branch 'weighted_tests' into weighted_bucket 2020-03-29 14:13:51 +03:00
folex
c65a93b00e log public key in weight calculation 2020-03-29 00:35:32 +03:00
folex
a644735e6e start_providing log 2020-03-28 20:47:51 +03:00
folex
b22934be64 hide public key from Debug 2020-03-28 20:24:55 +03:00
folex
d8451e549c log providers 2020-03-28 20:00:50 +03:00
folex
bd888cefd9 log get_providers 2020-03-28 17:14:45 +03:00
folex
8e2cd08956 better logs 2020-03-28 16:57:19 +03:00
folex
5d20ec9ece fix tests in kbucket.rs 2020-03-28 15:57:17 +03:00
folex
ce86462a05 fix closest lgos 2020-03-27 20:18:42 +03:00
folex
816ccac1ff weighted: logs 2020-03-27 19:57:05 +03:00
folex
0a4cd14efa Closest iterators: lots of logs 2020-03-27 19:48:12 +03:00
folex
6ef8f2c299 print calculated weight 2020-03-27 18:39:25 +03:00
folex
d6d11c4748 libp2p core 0.16.0 2020-03-27 14:00:20 +03:00
folex
9db560ede6 libp2p-core 0.16.8 2020-03-27 12:46:10 +03:00
folex
204d574add depend on trust graph via git 2020-03-27 12:30:22 +03:00
folex
3d52a6b021 Sort weighted bucket iter() by weight 2020-03-26 19:06:44 +03:00
folex
3c03467a52 Merge branch 'weighted_bucket' into weighted_tests
# Conflicts:
#	protocols/kad/src/kbucket/weighted.rs
2020-03-26 12:26:18 +03:00
folex
f60d004675 Use Vec instead of ArrayVec 2020-03-26 12:24:03 +03:00
folex
135a181ec3 arbitrary weights 2020-03-26 11:45:42 +03:00
folex
dca9099507 First test for weighted bucket 2020-03-25 20:26:50 +03:00
folex
442847eb64 merge & fix kad/behaviour tests 2020-03-25 18:11:21 +03:00
folex
53b3c34de5 Merge branch 'master' into weighted_bucket
# Conflicts:
#	protocols/kad/src/behaviour.rs
#	protocols/kad/src/behaviour/test.rs
2020-03-25 17:52:38 +03:00
folex
5ff311d38d remove commented line 2020-03-25 17:46:48 +03:00
folex
c895ec386a extend full_bucket_discard_pending test 2020-03-25 17:33:20 +03:00
folex
e53e4b9059 fix bucket_update test 2020-03-25 17:28:59 +03:00
folex
cdcbbf7e89 Integrate TrustGraph into kademlia 2020-03-24 21:20:06 +03:00
folex
091e45374f weighted bucket: enable bucket_update 2020-03-24 21:00:54 +03:00
folex
5b901ab090 weighted bucket: fix full_bucket test 2020-03-24 20:26:33 +03:00
folex
1e9e42065a weighted bucket: implement update_pending 2020-03-24 19:27:06 +03:00