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

p2p/dnsdisc: add enode.Iterator API #20437

Merged
merged 6 commits into from
Dec 12, 2019
Merged

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Dec 9, 2019

These changes make it possible to use DNS-based discovery as a node discovery source in p2p.Server. There are a couple of other improvements to p2p/dnsdisc in this PR:

  • The client now rate-limits DNS requests using golang.org/x/time/rate.
  • Link handling is much simpler and has higher test coverage.
  • TestIteratorLinkUpdates is stabler and doesn't fail on 1/50 runs anymore.

fjl added 5 commits December 6, 2019 13:20
This changes the dnsdisc.Client API to support the enode.Iterator
interface.
This improves the way links are handled when the link root changes.
Previously, sync would simply remove all links from the current tree and
garbage-collect all unreachable trees before syncing the new list of
links.

This behavior isn't great in certain cases: Consider a structure where
trees A, B, and C reference each other and D links to A. If D's link
root changed, the sync code would first remove trees A, B and C, only to
re-sync them later when the link to A was found again.

The fix for this problem is to track the current set of links in each
clientTree and removing old links only AFTER all links are synced.
@fjl fjl requested a review from zsfelfoldi as a code owner December 9, 2019 10:48
@fjl fjl added this to the 1.9.10 milestone Dec 9, 2019
p2p/dnsdisc/client.go Outdated Show resolved Hide resolved
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

LGTM. Code is not yet active, needs flag and config integration. We can do that in a followup PR to avoid bitrotting this one.

@karalabe karalabe merged commit 191364c into ethereum:master Dec 12, 2019
enriquefynn pushed a commit to enriquefynn/go-ethereum that referenced this pull request Mar 10, 2021
* p2p/dnsdisc: add support for enode.Iterator

This changes the dnsdisc.Client API to support the enode.Iterator
interface.

* p2p/dnsdisc: rate-limit DNS requests

* p2p/dnsdisc: preserve linked trees across root updates

This improves the way links are handled when the link root changes.
Previously, sync would simply remove all links from the current tree and
garbage-collect all unreachable trees before syncing the new list of
links.

This behavior isn't great in certain cases: Consider a structure where
trees A, B, and C reference each other and D links to A. If D's link
root changed, the sync code would first remove trees A, B and C, only to
re-sync them later when the link to A was found again.

The fix for this problem is to track the current set of links in each
clientTree and removing old links only AFTER all links are synced.

* p2p/dnsdisc: deflake iterator test

* cmd/devp2p: adapt dnsClient to new p2p/dnsdisc API

* p2p/dnsdisc: tiny comment fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants