Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

feat: periodically fill the routing table with KADIds #215

Merged
merged 9 commits into from
Sep 3, 2021

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Feb 5, 2021

In order to make queries in fewer hops it's useful to fill the routing
table with imaginary peers that have IDs that are uniformly distributed
over the sha2-256 value space. This means we've always got a peer
ID on hand that's kind of xor-close to anything we might be looking up.

We can then issue period DHT queries for any actual existant peers that
are close to our imaginary peers to ensure we've got a good range of
peers we know about, so making queries requires fewer hops to locate
ones that are xor-close to the data we are interested in.

Related to #183

BREAKING CHANGE: .start() is now async and random walk has been removed

@achingbrain achingbrain changed the title eat: periodically fill the routing table with KADIds feat: periodically fill the routing table with KADIds Feb 5, 2021
Base automatically changed from feat/add-types to master February 8, 2021 12:26
In order to make queries in fewer hops it's useful to fill the routing
table with imaginary peers that have IDs that are uniformly distributed
over the sha2-256 value space.  This means we've always got a peer
ID on hand that's kind of xor-close to anything we might be looking up.

We can then issue period DHT queries for any actual existant peers that
are close to our imaginary peers to ensure we've got a good range of
peers we know about, so making queries requires fewer hops to locate
ones that are xor-close to the data we are interested in.
@achingbrain achingbrain force-pushed the feat/ensure-routing-tables-have-contacts branch from 52056ff to b5335ba Compare February 8, 2021 16:08
@lidel
Copy link
Member

lidel commented Apr 19, 2021

Waiting for latest libp2p release.

@lidel lidel added the status/blocked Unable to be worked further until needs are met label Apr 19, 2021
@BigLep BigLep added status/ready Ready to be worked and removed status/blocked Unable to be worked further until needs are met labels May 3, 2021
@BigLep
Copy link

BigLep commented May 3, 2021

@achingbrain : we removed "status/blocked" given llibp2p release has happened.

@lidel lidel assigned achingbrain and unassigned achingbrain May 17, 2021
@lidel
Copy link
Member

lidel commented May 31, 2021

@achingbrain (q from triage) we assume this is mostly done, and you want to rebase this?

@BigLep
Copy link

BigLep commented Jun 14, 2021

2021-06-14 note: this will get picked up by @achingbrain after Multiformats work.

@lidel lidel added status/blocked Unable to be worked further until needs are met and removed status/ready Ready to be worked labels Jun 25, 2021
@lidel lidel marked this pull request as draft July 30, 2021 14:11
@achingbrain achingbrain marked this pull request as ready for review August 26, 2021 07:47
@achingbrain achingbrain removed the status/blocked Unable to be worked further until needs are met label Aug 26, 2021
Copy link
Member

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good, way more clear routing-table!

With the periodically fill of the routing table, I think we can just drop the random walk? What do you think? From what I remember, go also dropped it


// Start random walk, it will not run if it's disabled
this.randomWalk.start()
return Promise.all([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a breaking change message to the commit so that we do not forget it on merge?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -54,6 +54,7 @@
"heap": "~0.2.6",
"interface-datastore": "^5.1.1",
"it-first": "^1.0.4",
"it-length": "^1.0.3",
"it-length-prefixed": "^5.0.2",
"it-pipe": "^1.1.0",
"k-bucket": "^5.1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want to get rid of xor-distance below, right? 🎉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

// @ts-ignore
const KBuck = require('k-bucket')
const { xor: uint8ArrayXor } = require('uint8arrays/xor')
const GENERATED_PREFIXES = require('./generated-prefix-list.json')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should have a browser empty list? I know we do not recommend using the DHT in the browser, but there are users who run it. It also will be part of the bundle, if we not have a browser alternative

Copy link
Member Author

@achingbrain achingbrain Sep 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they use it in the browser and we've removed random walk, it probably shouldn't be an empty list otherwise peer discovery will not work properly, or at least will be very slow.

We could always have a 'light' version that's like, 1/4 of the values or something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, good point. Ok, I think we can start with a 1/4 of the list for now. These are the kind of things I wish JS testground had shipped.

We will likely need to revisit, but we will need to revisit all browser story either way. So, yes, let's do 1/4 for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -0,0 +1,85 @@
package main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we really want this in the tests, or a top level folder

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's useful to show we're working with the same data

Copy link
Member

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vasco-santos vasco-santos merged commit 10f0cc8 into master Sep 3, 2021
@vasco-santos vasco-santos deleted the feat/ensure-routing-tables-have-contacts branch September 3, 2021 08:20
vasco-santos added a commit that referenced this pull request Sep 3, 2021
vasco-santos pushed a commit that referenced this pull request Sep 3, 2021
In order to make queries in fewer hops it's useful to fill the routing
table with imaginary peers that have IDs that are uniformly distributed
over the sha2-256 value space.  This means we've always got a peer
ID on hand that's kind of xor-close to anything we might be looking up.

We can then issue period DHT queries for any actual existant peers that
are close to our imaginary peers to ensure we've got a good range of
peers we know about, so making queries requires fewer hops to locate
ones that are xor-close to the data we are interested in.

BREAKING CHANGE: .start() is now async and random walk has been removed
This was linked to issues Nov 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Table refresh Bootstrapping
4 participants