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

Client Discovery Improvements #3120

Merged
merged 11 commits into from
Oct 27, 2023
Merged

Client Discovery Improvements #3120

merged 11 commits into from
Oct 27, 2023

Conversation

holgerd77
Copy link
Member

This PR improves DiscV4 discovery in various ways.

First it adds an explicit logging message for discovery on startup. This is helpful since it remains often somewhat unclear if and what form of discovery is running.

Second it expands the --bootnodes option for the client to also accept a bootnode.txt file (e.g. from EthPandaOps devnet-10 config.

Third it introduces a new confirmed-peers mechanism for devp2p DPT. This allows to set a higher quality bar for sendNeighbour requests by only send to peers which have been manually confirmed. Otherwise discovery is hammering out requests like crazy to - mainly - mainnet peers not finding any needle in this haystack which rendered the feature more or less useless for all networks except mainnet (in fact we had deactivated in client for everything except mainnet).

Now only peers who are on the correct network and where a network connection was/is possible get the findNeighbour requests. This makes discV4 discovery requests acceptable again.

I was able to re-activate peer discovery by default for small networks - here devnet-10 - and have a slowly growing peer base (here the yellow numbers)! 🎉

grafik

Still need to do some testing - also write some tests - but I am confident that this approach works adequately and we can likely merge in.

@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

Merging #3120 (0196597) into master (ffd9ede) will decrease coverage by 10.70%.
The diff coverage is n/a.

❗ Current head 0196597 differs from pull request most recent head 69f7351. Consider uploading reports for the commit 69f7351 to get more accurate results

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block ?
blockchain ?
client ?
common ?
ethash ?
evm 71.87% <ø> (ø)
statemanager ?
trie ?
tx ?
util 87.57% <ø> (ø)
vm 75.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@holgerd77
Copy link
Member Author

Ok, I did some additional improvements and tested under different network conditions (small devnet, testnet, mainnet), following results:

  • testnets (like Holesky): previously discV4 deactivated (too much noise), now with onlyConfirmed: -> helps finding peers (tested with DNS deactivated)
  • small testnets (like devnet-10): previously no discovery, now with onlyConfirmed: most useful case, helps finding new peers at all
  • mainnet: reduces peer discovery speed (since most peers are mainnet anyhow): -> have deactivated

I have also added a descent new test suite with mockups, see dpt.spec.ts.

Open for review. 🙂

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

One comment, and am still tracking down where the filter for the network is 🤔 (see discord, have to track down a long event queue and likely take a wrong path somewhere there)

*/
confirmPeer(id: string) {
if (this._confirmedPeers.size < 5000) {
this._confirmedPeers.add(id)
Copy link
Member

Choose a reason for hiding this comment

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

Peers are never removed from _confirmedPeers, so at some point we cannot confirm new peers since the set is full? Should the peer id be removed on removePeer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that was the lazy version assuming a very slow growth. But removing on removePeer definitely make sense, will add. 👍

@jochem-brouwer
Copy link
Member

Also, the CI fails on the new tests 🤔

@holgerd77 holgerd77 force-pushed the client-discovery-improvements branch from df49bac to 02cfaba Compare October 27, 2023 12:51
Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

LGTM

@acolytec3 acolytec3 merged commit b848033 into master Oct 27, 2023
42 checks passed
@holgerd77 holgerd77 deleted the client-discovery-improvements branch October 27, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants