117 Commits

Author SHA1 Message Date
Will Scott
90907b584c
Merge branch 'cypress' of github.com:libp2p/go-libp2p-kad-dht into feat/peer-filtering 2020-03-31 17:08:20 -07:00
Aarsh Shah
314213d5d8 Remove disjoint queries (#503)
* remove disjoint queries
* remove globally queried check
* removed dht rng field and mutex
* removed the Disjoint option

Co-authored-by: Adin Schmahmann <adin.schmahmann@gmail.com>
2020-03-26 19:25:49 -04:00
Will Scott
f01285e6dc
Merge remote-tracking branch 'origin/cypress' into feat/peer-filtering 2020-03-24 15:14:38 -07:00
Adin Schmahmann
fcbc5f9e7f
Asynchronous lookups (#498)
* feat(query): fully async implementation of Kademlia lookup. peers returned from the lookup are not guaranteed to be alive (i.e. we're only guaranteed to have dialed the closest beta peers to the target), but given stable and correct routing tables the expectation that most of the peers returned are alive is high.
* feat(query): add wrapper lookup followup function to followup after the lookup is completed and ensure that the closest k returned peers from a lookup have been queried even for beta < k
* refactor(query) modified the structure returned from lookups to be a useful subset of the full query state instead of the entire query state
* feat(options): beta parameter exposed as the Resiliency parameter
* feat(routing): do not mark the routing table as updated after a FindPeer query
* feat(routing): FindPeer can return addresses even if not Connected as long as it was either recently connected (CanConnect) or was discovered during the lookup
* feat(bootstrap): bootstrap logic now uses GetClosestPeers instead of FindPeer
* refactor(dht): stopFn no longer takes any state
* fix(test): changed GetClosestPeers test to only assume beta instead of k peers since that is now more appropriate given the query logic changes and that the routing tables in that test are bad, i.e. a ring network with arbitrary peerIDs

Co-authored-by: Petar Maymounkov <petarm@gmail.com>
Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com>
2020-03-24 11:17:48 -04:00
Adin Schmahmann
075afe8528 fix: protect rng with a mutex 2020-03-23 01:59:57 -04:00
Will Scott
899af0f69f
Merge remote-tracking branch 'origin/cypress' into origin/feat/peer-filtering 2020-03-19 15:25:28 -07:00
Will Scott
c032ad8c1b
address outstanding discussion 2020-03-19 15:22:13 -07:00
Aarsh Shah
e42ee94214 Cypress Disjoint Query & Query Termination code cleanup (#489)
* kpeerset refactoring
* query code cleanup
2020-03-13 15:04:25 -07:00
Adin Schmahmann
c6155bea81 add configurable peer filtering 2020-03-06 15:11:47 -05:00
Adin Schmahmann
8ef9d774c9 cleanup unused code 2020-03-04 22:11:53 -08:00
Adin Schmahmann
b4f7fda731 check for stopping the query in between dialing and querying 2020-03-04 22:11:53 -08:00
Adin Schmahmann
f94a3f2bd4 options: KValue and AlphaValue global variables no longer used internally. Concurrency option now sets alpha. DisjointPaths option now sets d. Default number of disjoint paths is now bucketSize/2. 2020-03-04 22:11:53 -08:00
Adin Schmahmann
79648b84e4 fix: use dht.bucketSize instead of KValue for queries 2020-03-04 22:11:53 -08:00
Adin Schmahmann
6469073a4b query switches from alpha mode to k mode if no peers closer than one we have heard about (in a given path) has been found 2020-03-04 22:11:53 -08:00
Adin Schmahmann
719a16ff88 error on queries to empty routing table 2020-03-04 22:11:53 -08:00
Adin Schmahmann
68b116932f fix Search/GetValue to be Kad compliant. Default quorum is now 0 which means do not abort the query early 2020-03-04 22:11:53 -08:00
Adin Schmahmann
c4e94ce0fe first pass at proper kad 2020-03-04 22:11:53 -08:00
Adin Schmahmann
c01366876c upgrade deprecated query events 2020-03-04 22:11:53 -08:00
Steven Allen
e6a4d6a3dd fix(query): cancel the context when the query finishes 2020-02-27 17:47:15 -08:00
Raúl Kripalani
31765355df
migrate to consolidated types. (#344) 2019-05-26 23:33:15 +01:00
Steven Allen
1cccee0f65 query: fix a goroutine leak when the routing table is empty
When the routing table is empty, `Run` would fail but _not_ close the
process (leaking some query goroutines). This patch fixes this in multiple
places by:

1. Not starting queries with no peers.
2. Failing queries with no peers earlier.
2019-04-26 12:55:45 -07:00
Steven Allen
3c9f5bcd92 query: fix error "leak"
Long-running queries can build up large error sets that we never actually use.
This is exacerbated by https://github.com/libp2p/go-libp2p-swarm/pull/115.

fixes https://github.com/libp2p/go-libp2p-swarm/issues/119
2019-04-24 08:36:53 -07:00
Matt Joiner
86d78dc072
golangci-lint run -D errcheck (#298) 2019-03-14 11:07:15 +11:00
Raúl Kripalani
b649bcbec6 defer dialqueue action until initial peers have been added. 2019-03-13 21:25:36 +00:00
Matt Joiner
ac6772539b
Add find peer success addr to peerstore (#296)
When a peer is found, add its addr to the peerstore, just like the addresses for closer peers are added. In particular this is helpful for followup queries by the DHT user.
2019-03-12 20:08:07 +11:00
Steven Allen
c78d1e6786 fix(dialQueue): account for failed dials
fixes #276
2019-02-26 19:57:54 -07:00
Matt Joiner
61d3de0d41 Fix deadline handling in runBootstrap subqueries 2019-02-15 14:53:03 +11:00
Matt Joiner
8b37385468 Rename log to logger 2019-02-03 13:14:35 +11:00
Raúl Kripalani
ebcfcd46a6 make dial queue parameters configurable. 2019-02-01 13:43:27 +11:00
Matt Joiner
7246a3b0f4 Fix races with DialQueue variables 2019-01-31 13:08:45 +11:00
Raúl Kripalani
74d22f3f5e park waiters in slice; revise closure logic. 2019-01-30 23:25:10 +00:00
Raúl Kripalani
f2df3ec540 fix shutdown logic; fix timer logic. 2019-01-29 20:49:04 +00:00
Raúl Kripalani
abacfe5fc9 refactor interface of Consume(). 2019-01-29 16:47:42 +00:00
Raúl Kripalani
5e74c4a6f2 introduce adaptive queue for DHT dials.
This patch introduces an adaptive dial queue that spawns a dynamically sized
set of goroutines to preemptively stage dials for later handoff to the DHT
protocol for RPC. It identifies backpressure on both ends (dial consumers and
dial producers), and takes compensating action by adjusting the worker pool.

We start with `DialQueueMinParallelism` number of workers (6), and scale up
and down based on demand and supply of dialled peers.

The following events trigger scaling:
- we scale up when we can't immediately return a successful dial to a new
  consumer.
- we scale down when we've been idle for a while waiting for new dial
  attempts.
- we scale down when we complete a dial and realise nobody was waiting for it.

Dialler throttling (e.g. FD limit exceeded) is a concern, as we can easily
spin up more workers to compensate, and end up adding fuel to the fire. Since
we have no deterministic way to detect this for now, we hard-limit concurrency
to `DialQueueMaxParallelism` (20).
2019-01-29 00:56:12 +00:00
Gustvo Chain
70d5802fce Remove outdated package documentation
Both, dht.go and dht_bootstrap.go duplicate the package documentation.
The whole block had been moved to doc.go

Also query.go provides documentation for query package but now it
belongs to dht package, so it's been removed.
2019-01-09 14:21:14 +11:00
Steven Allen
eb3e7fe95f fix a potential DHT query hang
Without this, one of the workers may hang when trying to re-grab the rate-limit
after dialing. I believe this may be what's causing some of our DHT requests to
stall (evidence: massive goroutine buildup on the gateways).
2018-12-26 22:29:25 -08:00
Jeromy
6b33279a0f make getclosestpeers only return peers we can actually connect to 2018-06-06 22:49:17 -07:00
Jeromy
1290c4ef29 better check for connectedness 2018-06-06 22:49:14 -07:00
Michael Muré
2026fcb558
document and clean small things 2018-04-01 12:38:15 +02:00
Jeromy
00b46e0cf7 Fixes for dht findpeer queries
First, we use Alpha instead of K as the number of peers we grab from the
routing table (as per the kademlia paper).

Second, we don't use a size limited set for the 'GetClosestPeers' query.
We're going to process more than K peers before we find the K closest
peers.

Third, Change GetClosestPeers to actually return the K Closest peers,
not a hodge podge of peers that it found on the way to finding the
closest peers.
2017-03-05 21:36:46 -08:00
Jeromy
6894f33507 update dependencies after package extraction funtime 2016-10-05 12:34:28 -07:00
Jeromy
e00b3ca0a4 use stdlib context and clean up deps 2016-09-30 10:24:03 -07:00
Jeromy
c372d79e42 switch to strings and cids instead of keys 2016-09-30 10:13:57 -07:00
George Antoniadis
30d43d22e0 Fix dependencies 2016-09-02 20:21:23 +01:00
George Antoniadis
5f3e63aa46 Undo gx rewrites and add gx package.json 2016-08-21 17:18:58 +01:00
Jakub Sztandera
22af8d1151 Update go-log in whole dependency tree (#2898)
* Update golog in go-ipfs

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p for go-log

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p-secio for go-log

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p-crypto for go-log

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p-peer for go-log

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Import peersore, it wasn't imported

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update peerstore

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update peer

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update secio

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
2016-06-24 09:38:07 -07:00
Jeromy
63b6db0589 pull in libp2p updates with utp fixes
License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
2016-06-11 10:33:44 -07:00
Jakub Sztandera
2b3334c4a4 Update go-log
https://github.com/ipfs/go-log/pull/3

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
2016-06-09 23:37:09 +02:00
Jeromy
5f777f323b update libp2p to v3.3.1
License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
2016-06-01 16:45:46 -07:00
Jeromy
26beb1f3d0 update go-libp2p 3.2.2, nil maddr fixes
License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
2016-05-17 10:23:10 -07:00