Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

advertising services on discv5 - benchmarks and optimisations #6216

Open
2 tasks
emhane opened this issue Jan 24, 2024 · 0 comments
Open
2 tasks

advertising services on discv5 - benchmarks and optimisations #6216

emhane opened this issue Jan 24, 2024 · 0 comments
Labels
A-devp2p Related to the Ethereum P2P protocol A-discv5 Related to discv5 discovery A-networking Related to networking in general C-enhancement New feature or request M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity S-needs-benchmark This set of changes needs performance benchmarking to double-check that they help S-needs-design This issue requires design work to think about how it would best be accomplished

Comments

@emhane
Copy link
Member

emhane commented Jan 24, 2024

Describe the feature

advertising a random topic on discv5 is straight forward: the topic gets hashed, and that hash is then looked up using a FINDNODE request, just as a node_id. all the closest_peers of that hash are expected to store info on that service, like for example a directory of nodes that preform that service. however, when nodes are looking up the same topic hashes, for example hash("reth_node"), than the sorry nodes that by chance have a similar node_id to hash("reth_node") will be DoS:ed by benevolent peers that just want to connect to a reth node.

devp2p made progress on this research topic, summarised in this paper DISCv5: Robust Service Discovery in Ethereum Ecosystem. the research question was how to set the topic-radius, the log2distance from a topic-hash, described in this issue ethereum/devp2p#112. peers within the topic radius need to store info on the topic. the rule to uphold, is that info on a topic should be dispersed enough among the nodes surrounding it, so that a query for the topic resolves successfully before any peers are overloaded with queries for that same topic.

I implemented this for sigp/discv5 and tested it in testground. moving on, it would be nice to:

  • benchmark the discv5 topics code
  • implement kbuckets optimisation that allows for Robust Service Discovery to scale

benchmark the discv5 code

how to run a single testground test case.

it should be possible to figure out how to run the test cases topic-query and reg-topic by comparing it to the command, linked above, for running the find-node test case. note: I only got it to work with 30 instances max, could be due to this "Configure RAM settings before you run docker on Mac", I didn't get as far as to try out configuring docker.

implement kbuckets optimisation that allows for topdisc to scale

for topics to scale, we will have to implement a way for virtualising topic overlays on top of the original kbuckets. it's described in detail in sigp/discv5#193. (there is even a pretty diagram, in a linked issue).

the issue suggests implementing an AsNode trait, to avoid breaking the existing API used in kbuckets. but doing implementing Deref and DerefMut on some type RwLock<T> is likely to end up unsafe. we will probably have to break the used inside of kbuckets to access the fields of a node, by using the following design pattern. makes the diff a bit bigger, but no worries.

pub fn with_node<F, T>(&self, f: F) -> T
where
    F: FnOnce(&Node) -> T,
{
    f(&self.val.lock().unwrap())
}

pub fn with_node_mut<F, T>(&self, f: F) -> T
where
    F: FnOnce(&mut Node) -> T,
{
    f(&mut self.val.lock().unwrap())
}

Additional context

for continuing topdisc research, we are best of forking discv5 so we can manage our own prs and progress step by step.

@emhane emhane added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Jan 24, 2024
@emhane emhane changed the title topdisc, advertising services on discv5 - benchmarks and optimisations advertising services on discv5 - benchmarks and optimisations Jan 24, 2024
@emhane emhane added D-complex Quite challenging from either a design or technical perspective Ask for help! S-needs-design This issue requires design work to think about how it would best be accomplished S-needs-investigation This issue requires detective work to figure out what's going wrong S-needs-benchmark This set of changes needs performance benchmarking to double-check that they help A-devp2p Related to the Ethereum P2P protocol A-networking Related to networking in general A-discv5 Related to discv5 discovery M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity and removed D-complex Quite challenging from either a design or technical perspective Ask for help! S-needs-investigation This issue requires detective work to figure out what's going wrong labels Jan 24, 2024
@DaniPopes DaniPopes removed the S-needs-triage This issue needs to be labelled label Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devp2p Related to the Ethereum P2P protocol A-discv5 Related to discv5 discovery A-networking Related to networking in general C-enhancement New feature or request M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity S-needs-benchmark This set of changes needs performance benchmarking to double-check that they help S-needs-design This issue requires design work to think about how it would best be accomplished
Projects
Status: Todo
Development

No branches or pull requests

2 participants