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, p2p/discover: add signed ENR generation #17753

Merged
merged 15 commits into from
Oct 12, 2018
Merged

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Sep 25, 2018

This PR adds enode.LocalNode. This new object is the keeper of the local node record.
For now, a new version of the record is produced every time the client restarts. We'll make it
smarter to avoid that in the future.

it.gcContact(now)
it.gcStatements(now)
for host := range it.statements {
if _, ok := it.contact[host]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should also return true if you have received the statement before the contact.

@fjl
Copy link
Contributor Author

fjl commented Oct 1, 2018

@zsfelfoldi PTAL

Copy link
Contributor

@zsfelfoldi zsfelfoldi left a comment

Choose a reason for hiding this comment

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

Looks good as far as I can tell

if ln.staticIP != nil {
newIP = ln.staticIP
} else if ip, port := predictAddr(ln.udpTrack); ip != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ok to use the static IP with the fallback UDP port? Shouldn't we add a StaticUDP parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't make sense because there is no way to set such a port via anything in geth.

@fjl
Copy link
Contributor Author

fjl commented Oct 10, 2018

I'm still debugging the hang in the tests on CI. The test that hangs is the swarm discovery simulation.

fjl added 15 commits October 11, 2018 20:35
LocalNode produces signed node records for the local node.
Startup is much faster because it doesn't need to wait for the external
IP query anymore.
The discovery protocol sends pings to previously-unseen nodes after
receiving a ping from them. This means there will always be a contact
entry and PredictFullConeNAT will always return false. Fix it by
checking that the contact occurred after the IP statement.
This makes the node URL in logs correct immediately after startup.
This prevents indefinite memory growth if Predict* isn't called.
This fixes a leveldb crash in tests.
@fjl fjl merged commit 6f607de into ethereum:master Oct 12, 2018
@karalabe karalabe added this to the 1.8.18 milestone Nov 7, 2018
@wanwiset25 wanwiset25 mentioned this pull request Jun 3, 2024
19 tasks
wanwiset25 pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Jun 19, 2024
This PR adds enode.LocalNode and integrates it into the p2p
subsystem. This new object is the keeper of the local node
record. For now, a new version of the record is produced every
time the client restarts. We'll make it smarter to avoid that in
the future.

There are a couple of other changes in this commit: discovery now
waits for all of its goroutines at shutdown and the p2p server
now closes the node database after discovery has shut down. This
fixes a leveldb crash in tests. p2p server startup is faster
because it doesn't need to wait for the external IP query
anymore.
wanwiset25 pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Jun 28, 2024
This PR adds enode.LocalNode and integrates it into the p2p
subsystem. This new object is the keeper of the local node
record. For now, a new version of the record is produced every
time the client restarts. We'll make it smarter to avoid that in
the future.

There are a couple of other changes in this commit: discovery now
waits for all of its goroutines at shutdown and the p2p server
now closes the node database after discovery has shut down. This
fixes a leveldb crash in tests. p2p server startup is faster
because it doesn't need to wait for the external IP query
anymore.
wanwiset25 added a commit to XinFinOrg/XDPoSChain that referenced this pull request Aug 23, 2024
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.

3 participants