327 Commits

Author SHA1 Message Date
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
Adin Schmahmann
075afe8528 fix: protect rng with a mutex 2020-03-23 01:59:57 -04:00
Aarsh Shah
f4e0b0d25b change tests 2020-03-16 22:11:37 +05:30
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
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
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
c4e94ce0fe first pass at proper kad 2020-03-04 22:11:53 -08:00
Aarsh Shah
14422102c9 close context correctly 2020-03-04 17:28:50 +05:30
Vibhav Pant
28f2f2ab96
Provide the entire config object to makeDHT. 2020-02-18 16:18:52 +05:30
Vibhav Pant
fececcc819
Make the Routing Table's latency tolerance configurable. 2020-02-17 20:06:29 +05:30
Aarsh Shah
50d524dfbb remove incorrect doc 2020-02-04 10:22:28 +05:30
Adin Schmahmann
5d2e3df37d make all key types loggable 2019-12-19 12:04:25 -05:00
Adin Schmahmann
3e24f352aa provider record keys can be an arbitrary byte array less than 80 bytes instead of only a multihash 2019-12-19 12:00:51 -05:00
Adin Schmahmann
a4b38eebee feat(dht): provider records use multihashes instead of CIDs 2019-12-19 12:00:51 -05:00
Steven Allen
2e6adb8c2b
Merge pull request #400 from libp2p/feat/disable-providers
feat: allow disabling value and provider storage/messages
2019-12-12 18:05:53 +01:00
Henrique Dias
0449555dde make BaseConnMgrScore const
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-12-12 17:56:30 +01:00
Henrique Dias
e4dae1c931 call it common prefix len
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-12-12 17:55:50 +01:00
Henrique Dias
dca21f6a05 fix: prioritize closer peers
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
2019-12-12 17:17:45 +01:00
Steven Allen
0be0cbc50e feat: refresh and wait
We'd like to be able to refresh then _wait_ for the refresh to finish in the testground DHT tests. That way, we can:

1. Start and disable _auto_ refresh.
2. Bootstrap.
3. Refresh a couple of times till we're stable.
4. Wait to _stop_ refreshing.
5. Disconnect from and forget about all peers _not_ in our routing tables.
6. Run the actual tests without interference from the bootstrapping logic.
2019-12-10 15:41:20 +01:00
Steven Allen
c2b72b250d doc(options): document that disabling values/providers should only be done on forked dhts 2019-12-05 19:11:46 -05:00
Steven Allen
52747fc1f0 feat: allow disabling value and provider storage/messages
fixes #274
2019-12-05 19:11:46 -05:00
Steven Allen
0d48254082 chore(dep): update
Update deps:

* Switch to multiformats/go-base32
* Regenerate protobuf decoding code
2019-12-02 13:05:53 -05:00
Aarsh Shah
7a39667d70 make max record age configurable 2019-11-15 10:54:09 +08:00
Raúl Kripalani
a33b0b97a4 inline struct for RoutingTable config. 2019-11-05 23:55:32 +00:00
Steven Allen
ef319676a9 chore: rename bootstrap to refresh
As pointed out by raul, bootstrapping and refreshing are not the same thing.
Bootstrapping is the initial setup (i.e., connect to some initial nodes to get
started). Refreshing is the process of refreshing the routing table.
2019-11-05 23:33:53 +00:00
Steven Allen
ed244cd485 feat(bootstrap): simplify bootstrapping
* Rename triggerAutoBootstrap to autoBootstrap. This variable used to control
_triggering_ only but now completely disables automatic bootstrapping.
* Remove the BootstrapConfig. We introduced this before we switched to
functional options. Now that we're breaking the interfaces anyways, we might as
well use functional options all the way (easier to extend).
* Always query self (feedback from @raulk).
* Important: don't abort the bootstrap process if we timeout finding ourselves.
2019-11-05 22:33:05 +00:00
Steven Allen
98cf91494d chore(bootstrap): remove unecessary request structure 2019-11-05 11:15:23 +00:00
Aarsh Shah
da6edafb21 make Bootstrap() async and latestSelfWalk a dht field 2019-11-02 11:37:44 +08:00
Aarsh Shah
7cce5bdd96 make bootstrap synchronous & get tests to work 2019-11-02 00:37:15 +08:00
Steven Allen
e2842f0317 feat(bootstrap): autobootstrap
1. Auto bootstrap on start.
2. Make `Bootstrap(ctx)` trigger a bootstrap but not _start_ the bootstrapping
   process.
2019-11-01 00:38:28 -07:00
Aarsh Shah
00fffba0aa Update dht_bootstrap.go
1) on connecting to a new peer  -> trigger self & bucket bootstrap if RT size goes below thereshold
2) accept formatting & doc suggestions in the review
3) remove RT recovery code for now -> will address in a separate PR once #383 goes in

changes as per review
2019-10-11 14:10:19 +09:00
Aarsh Shah
f4630f62d5 1) seed RT whenever it becomes empty
2) seed RT if empty before starting bootstrap incase 1 hasn't fired
3) pass bootstrap config as option while creating Dht
4) replace all bootstrap function with 1 function
2019-10-11 13:17:36 +09:00
Steven Allen
232357eab2 chore: smaller diff 2019-10-11 13:14:07 +09:00
aarshkshah1992
585d6725be refresh a bucket whenever we lookup a key in it 2019-10-11 13:13:53 +09:00
Aarsh Shah
f7353aac3b reset timer on bucket 2019-10-11 13:13:53 +09:00
Raúl Kripalani
fed99afe6e
Make routing table bucket size configurable (#396) 2019-10-04 22:12:00 +09:00
Aarsh Shah
36578e2be3 Striped locks for atomic Dht updates (#374)
Implement striped locking for datastore puts.
2019-07-22 20:47:45 -07:00
Raúl Kripalani
31765355df
migrate to consolidated types. (#344) 2019-05-26 23:33:15 +01:00
Adrian Lanzafame
cf9bd9b649 Add opencensus basic metrics (#317)
Add initial set of metrics exposed via OpenCensus.
2019-04-15 13:18:47 +10:00
Matt Joiner
86d78dc072
golangci-lint run -D errcheck (#298) 2019-03-14 11:07:15 +11:00
Matt Joiner
08c34b4d83
New node methods for tools and otherwise (#265)
* Add IpfsDHT.{Bootstrap{Random,Self},Peer{Id,Key}}
* Include client mode tests, support for Ping, and uncruft setupDHTs
* Include xerrors in deps
2019-03-06 08:10:38 +11:00
Raúl Kripalani
120a585ebf Revert "Test go mod in travis and use major versioning in import paths (#236)"
This reverts commit 7e68ac3c60c15243c7d2e622b91aed92245a2677.
2019-02-12 14:12:53 +00:00
Adrian Lanzafame
7e68ac3c60 Test go mod in travis and use major versioning in import paths (#236) 2019-02-12 17:38:06 +11:00
Matt Joiner
8b37385468 Rename log to logger 2019-02-03 13:14:35 +11:00
Matt Joiner
2d2bb5513c
Tidy up bootstrapping (#235)
* Remove signal bootstrapping

Remove IpfsDHT.BootstrapOnSignal.

* Type check expected interfaces on IpfsDHT

* Simplify the bootstrap logic

* Tidy up a few other things

* Include BootstrapOnce

* Add comment about duplicating sanity checks

* Use existing import naming convention

* Defer error wrapping until we need it

* Restore existing query count behaviour
2019-01-31 10:06:56 +11:00
Steven Allen
201eea5e0b
Revert "Tidy up bootstrapping" 2019-01-24 14:06:38 -08:00
Matt Joiner
f91dc28913 Type check expected interfaces on IpfsDHT 2019-01-24 09:52:55 +11:00