123 Commits

Author SHA1 Message Date
Adin Schmahmann
f9a79c5ca8 go fmt + import reordering 2020-03-24 03:16:38 -04:00
Adin Schmahmann
a21162d55c make the query logic panic if the state is invalid 2020-03-24 03:16:38 -04:00
Adin Schmahmann
de9d5ae745 fix lookup followup goroutine cancellation 2020-03-24 03:16:38 -04:00
Adin Schmahmann
8656be1b86 more comments 2020-03-24 03:16:38 -04:00
Adin Schmahmann
c9d93bdaa9 go fmt 2020-03-23 02:15:13 -04:00
Adin Schmahmann
b04ec8ab88 move lookup result construction into its own function 2020-03-23 02:15:13 -04:00
Adin Schmahmann
9476ad8683 query state transitions bug fixes. fix wrapper function to take into account disjoint paths. Adjust test to take into account new query behavior (i.e. GetClosestPeers is no longer guaranteed to find k peers if the routing tables are invalid, e.g. ring setups) 2020-03-23 02:15:13 -04:00
Adin Schmahmann
a4fcc84647 add wrapper lookup function to ensure that the top k returned peers from a lookup have all been queried even for beta < k. Modified the structure returned from lookups to be a useful subset of the full query state. 2020-03-23 02:15:13 -04:00
Petar Maymounkov
f9f08b5f5a Addressing PR comments. Documentation. Naming fixes. 2020-03-23 02:15:13 -04:00
Adin Schmahmann
f65f5626b1 fix: simple async query bugs 2020-03-23 02:15:13 -04:00
Adin Schmahmann
516cd0b49d refactor(dht): stopFn no longer takes any state. Beta publicly exposed as the Resiliency parameter. 2020-03-23 02:15:13 -04:00
Petar Maymounkov
49b07fa585 Fully async implementation of Kademlia lookup. 2020-03-23 02:09:19 -04:00
Adin Schmahmann
2dfbbc4693 tmp 2020-03-23 02:09:19 -04:00
Adin Schmahmann
075afe8528 fix: protect rng with a mutex 2020-03-23 01:59:57 -04: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
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