1237 Commits

Author SHA1 Message Date
Aarsh Shah
b5f8c63599 remove replace 2020-03-27 16:27:01 +05:30
Aarsh Shah
6d1dcd28fc bump peerstore 2020-03-27 16:23:12 +05:30
Aarsh Shah
e09d7fed36 signed peer recs 2020-03-27 15:59:02 +05:30
Adin Schmahmann
99716d16b4 build(deps): bump go-libp2p and kbucket repos 2020-03-24 14:06:27 -04: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
Aarsh Shah
e56c237633
Merge pull request #497 from libp2p/feat/change-rt-validation
RT peer validation should also include support for the DHT protocol
2020-03-24 15:55:50 +05:30
Adin Schmahmann
8eade909a7 feat: calling FindProvidersAsync with a count of zero now completes the query 2020-03-23 01:59:57 -04:00
Adin Schmahmann
147dc1244d cleanup: documentation and code cleanup for search/getvalue quorum defaulting to zero 2020-03-23 01:59:57 -04:00
Adin Schmahmann
075afe8528 fix: protect rng with a mutex 2020-03-23 01:59:57 -04:00
Adin Schmahmann
42addc4c24 fix(test): increase timeout for notification tests since it's slow on Windows 2020-03-23 01:59:57 -04:00
Aarsh Shah
c8909e958e queries can take longer 2020-03-20 10:17:43 +05:30
Aarsh Shah
a4a6e824d8 fix validation 2020-03-19 18:29:55 +05:30
Aarsh Shah
d7b6b1b091 change peer validation func 2020-03-19 18:27:06 +05:30
Adin Schmahmann
7c27400a1e
Merge pull request #495 from libp2p/feat/fix-tests
Fix test logging & document timing issue on Windows
2020-03-17 13:13:06 -04:00
Aarsh Shah
45c403c1bc document test failure 2020-03-17 22:39:56 +05:30
Aarsh Shah
f4e0b0d25b change tests 2020-03-16 22:11:37 +05:30
Aarsh Shah
e42ee94214 Cypress Disjoint Query & Query Termination code cleanup (#489)
* kpeerset refactoring
* query code cleanup
2020-03-13 15:04:25 -07:00
Aarsh Shah
fbb1b3668a RT connectivity changes 2020-03-10 14:51:28 -07:00
Adin Schmahmann
7ada018b2a Upgrade DHT version (#479)
* upgraded the protocol id to version 2 (i.e. /kad/2.0.0) and made it so v2 peers running in server mode respond to queries from v1 peers. Note: v2 peers will only send queries using the v2 protocol, will only add v2 peers to their routing tables, and will only tell v1 peers about v2 peers.
* to run a forked network we now use network specific protocol prefixes instead of manually setting protocol IDs. Use the ProtocolPrefix option instead of the Protocols option.
* emit errors during initialization if the user misuses the default protocol prefix by setting parameters inconsistent with the default protocol's network specification
* since the Client option has been deprecated it's been removed from the dht's options. While deprecated it is still available in the dht options package. Setting `Client(false)` now puts the node into ModeAuto.
2020-03-10 16:22:41 -04:00
Steven Allen
d440bbf0c4 feat: move options to main package and make internals private (#486)
* feat: move options to main package and make internals private

Rationale:

1. This allows us to make private options for testing.
2. This removes an import for DHT users.
3. This makes options much easier to discover.
4. This makes it possible to make the config/options internals private.

We originally put them in a sub-package to avoid poluting the root namespace,
but that isn't really necessary.

This keeps the old package (for now) to avoid breaking too much.
2020-03-10 16:21:56 -04:00
Adin Schmahmann
c24a52fc7c
Enable switching DHT between client and server modes (#469)
* created Mode(ModeOpt) option for choosing between auto/client/server modes
* Auto mode internally switches the DHT between client and server modes based on the EvtLocalReachabilityChanged event emitted on the event bus (e.g. by AutoNAT)
* routing table management of peers that switch between client and server mode while we are connected to them (i.e. are in auto mode)
* removed Client(bool) option, becoming a DHT client is specified using Mode(ModeClient) instead
2020-03-06 14:56:03 -05:00
Adin Schmahmann
bf4986ec8f made deprecated util values have comments that satisfy golint 2020-03-06 14:38:15 -05:00
Steven Allen
376300a6ff
fix: actually ignore deadline exceeded errors in Provide (#480) 2020-03-06 00:00:51 -05:00
Steven Allen
e50572360e fix: improve context deadline handling
1. Continue to best-effort provide, but still return an error when we fail to
send provider records to the _best_ peers.
2. Continue returning the best peer's we've found in GetClosestPeers, but also
return an error to indicate that we didn't find the closest ones.

And fix the hang test.
2020-03-05 20:01:39 -08:00
Adin Schmahmann
5d313b134c Utilize identify events to add peers to the routing table (#472)
* feat: consume identify events to evaluate routing table addition
* fix: routing table no longer gets an update just because new messages have arrived or been sent
* fix: add already connected peers into the routing table before listening to events

Co-authored-by: Raúl Kripalani <raul.kripalani@gmail.com>
Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com>
2020-03-04 22:26:30 -08: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
6b25a6c008 try another peer sorting metric. fix bug in when findproviders returns 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
0ef814afd2 test: switch tests to use dht.bucketSize instead of KValue for queries 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
1984feb89e added todo comment about FindPeer and peer connectedness 2020-03-04 22:11:53 -08:00
Adin Schmahmann
c79bac3a7a SearchValue will only update k closest peers to have latest record 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
a9e21d2672 Search/GetValues stops if using quorum 2020-03-04 22:11:53 -08:00
Adin Schmahmann
5cabdf6d13 fix refreshing buckets during query. getting topK peers is more efficient. 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
dbb3d2c0a2
Merge pull request #462 from libp2p/fix/observe-context-in-message-sender
fix: obey the context when sending messages to peers
v0.5.1
2020-03-04 22:10:51 -08:00
Steven Allen
a92f79b9d3
Merge pull request #477 from libp2p/feat/cancel-dht-context
Close context correctly
2020-03-04 15:18:18 -08:00
Aarsh Shah
14422102c9 close context correctly 2020-03-04 17:28:50 +05:30
Steven Allen
da53c0b6b0
Merge pull request #475 from libp2p/test/benchmark-find-peer
add benchmark for handleFindPeer
2020-03-03 18:35:30 -08:00
Steven Allen
cf1c489d50
Merge pull request #474 from libp2p/feat/log-names
give views names again
2020-03-03 18:24:30 -08:00
whyrusleeping
5bc18f622f add benchmark for handleFindPeer 2020-03-03 18:10:11 -08:00
Adrian Lanzafame
315dea5b59 give views names again 2020-03-03 18:07:08 -08:00
Steven Allen
c2631d9569
Merge pull request #464 from MichaelMure/fix-metrics
metrics: record message/request event even in case of error
2020-03-02 22:51:22 -08:00
Steven Allen
4d2a8a70eb
Merge pull request #470 from libp2p/dependabot/go_modules/github.com/multiformats/go-multiaddr-0.2.1
build(deps): bump github.com/multiformats/go-multiaddr from 0.2.0 to 0.2.1
2020-03-02 22:23:24 -08:00
Michael Muré
faa56381cb
net: address PR comments regarding metrics 2020-03-02 13:11:56 +01:00