Skip to content

Shift IP-related ENR fields as optional#1668

Merged
djrtwo merged 1 commit into
ethereum:v011xfrom
AgeManning:enr-update
Mar 24, 2020
Merged

Shift IP-related ENR fields as optional#1668
djrtwo merged 1 commit into
ethereum:v011xfrom
AgeManning:enr-update

Conversation

@AgeManning

@AgeManning AgeManning commented Mar 18, 2020

Copy link
Copy Markdown
Contributor

Description

In Lighthouse we had these fields always defined as specified. However in a recent update to our discv5 which removes NAT'd peers from the DHT we realised it makes more sense to have nodes that have not sorted out their NAT traversal (i.e do not know or do not have external IP/PORTS that other peers can connect on) that their ENR's do not contain any IP/PORTs.

Nodes without IP/PORTs should still be able to connect and discover other peers, but it will be less likely (depending on implementations) that these peers would be added to a local node routing table.

It makes it clearer that nodes without an IP/PORT do not have a contactable address and will save us time trying to connect to a local IP/PORT which is not globally contactable.

Lighthouse by default, will have ENRs without any IP/PORT field (unless loaded from a previous state), although we set a TCP port (as this is not update-able from discovery). As they discover peers and their peers inform the node that they are contactable on a specific IP/PORT, the node will update it's ENR with IP/PORT field and get added to the DHT. This also ensures that the ENR doesn't get updated unless it is contactable from a wider audience.

@djrtwo

djrtwo commented Mar 19, 2020

Copy link
Copy Markdown
Contributor

So the point here is that some peers will be behind a NAT and thus their ENR's won't have some of these fields.

This isn't necessarily a problem when it comes to using ENRs for DHT discovery because you couldn't discover such peers anyway. But it is a problem if we use ENRs for other usecases such as option 2 in #1637

^ that all check out?

@AgeManning

AgeManning commented Mar 20, 2020

Copy link
Copy Markdown
Contributor Author

Yeah, I guess this is more of a discv5 implementation issue for whether it effects DHT discovery. A chat with felix prompted me that ENR's could not specify IPs.

If a node connects to you and asks you for peers and you don't know this node. You get it's ENR. Depending on the implementation, you need to know whether to add this new node to your routing table or not. If the connecting node doesn't have an IP field you just ignore it.

I think it helps in general if node's haven't specified a specific IP, we can assume they are non-contactable, rather than attempting to connect and finding out after a timeout. For example, you start a new node without specifying a contactable IP, and try and connect to it's ENR. We can now have specific errors such as: "this node has no contactable address" rather than "could not connect to node for some reason". It gives us an extra state to work with.

I've found issues with setting the IP to whatever the local listening address is. In general its non-contactable and in these cases I think it's better to just not have an IP field.

@djrtwo

djrtwo commented Mar 20, 2020

Copy link
Copy Markdown
Contributor

I see, thanks for the clarification.
This makes sense to me.

Any other comments? @arnetheduck @mkalinin @nisdas @fjl

@arnetheduck

Copy link
Copy Markdown
Contributor

+1 from us (cc @kdeme)

@fjl

fjl commented Mar 23, 2020

Copy link
Copy Markdown

I think this change is good.

@djrtwo djrtwo changed the base branch from dev to v011x March 23, 2020 16:26
@djrtwo djrtwo changed the base branch from v011x to dev March 23, 2020 16:26
@djrtwo

djrtwo commented Mar 23, 2020

Copy link
Copy Markdown
Contributor

@AgeManning Can you rebase to v011x? I'll release this asap

@nisdas

nisdas commented Mar 24, 2020

Copy link
Copy Markdown
Contributor

this looks good to me 👍

@AgeManning AgeManning changed the base branch from dev to v011x March 24, 2020 04:01

@djrtwo djrtwo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thank you!

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.

5 participants