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

Use the IP address given in the ping #301

Merged
merged 5 commits into from Jul 2, 2019
Merged

Use the IP address given in the ping #301

merged 5 commits into from Jul 2, 2019

Conversation

nambrot
Copy link
Contributor

@nambrot nambrot commented Jun 25, 2019

Description

In the upstream v4 version of the discovery protocol, geth will use the source IP of the UDP connection to advertise the endpoint to other peers. However, when a node is behind a NAT, the source IP is not guaranteed to be the external IP under which that peer would be available. This PR naively will use the passed IP address to save it to its peer table and advertise to other peers. For a bit more background, also see celo-org/celo-monorepo#3877

It should be noted that two other changes should be made:

  • We should verify that the passed IP address is indeed reachable by said peer to avoid us falsely advertising a node that does not want to participate in the network.
  • Pongs currently can appear to be unsolicited, not entirely sure what is causing that.

Sister-PR to celo-org/celo-monorepo#3952

Tested

  • Deployed a bunch of test networks to see if peers can connect to each other.

Fixes celo-org/celo-monorepo#3877

@nambrot nambrot requested a review from asaj as a code owner June 25, 2019 14:58
@asaj
Copy link
Contributor

asaj commented Jun 25, 2019

Pongs currently can appear to be unsolicited, not entirely sure what is causing that.
What are the implications of this?

@asaj
Copy link
Contributor

asaj commented Jun 25, 2019

There seem to be a lot of open issues with this, are you sure that it makes sense to merge these PRs?

@asaj asaj assigned nambrot and unassigned asaj Jun 25, 2019
@nambrot
Copy link
Contributor Author

nambrot commented Jun 26, 2019

Yeah, the assignment wasn't meant as a indication of merging, but as a way to solicit feedback. You are right that in the current state it's not ready to merge

Pongs currently can appear to be unsolicited, not entirely sure what is causing that.
What are the implications of this?

They get ignored, but might indicate that just changing to the external IP address when saving the peer might not be sufficient

t.send(from, fromID, pongPacket, &pong{
To: makeEndpoint(from, req.From.TCP),
ReplyTok: mac,
Expiration: uint64(time.Now().Add(expiration).Unix()),
})

// Ping back if our last pong on file is too far in the past.
n := wrapNode(enode.NewV4(req.senderKey, from.IP, int(req.From.TCP), from.Port))
n := wrapNode(enode.NewV4(req.senderKey, senderFrom, int(req.From.TCP), int(req.From.UDP)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to handle the case if req.From is nil for the port?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah so this is where I dont yet fully understand when it would be nil for me know how to handle it? Under what circumstances would it be?

Copy link
Contributor

@kevjue kevjue left a comment

Choose a reason for hiding this comment

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

LGTM! I also checked that the verification/bonding logic still works with using the req.From.IP, as opposed to the source ip, and that LGTM as well.

@kevjue kevjue assigned nambrot and unassigned nambrot and kevjue Jun 27, 2019
@kevjue
Copy link
Contributor

kevjue commented Jun 27, 2019

  • We should verify that the passed IP address is indeed reachable by said peer to avoid us falsely advertising a node that does not want to participate in the network.

Wouldn't the bonding/verification of pings address this concern?

https://github.com/celo-org/geth/blob/a379f8673f9fe17436a47e2fde2e56aa9ff1be45/p2p/discover/udp.go#L669

@kevjue
Copy link
Contributor

kevjue commented Jun 27, 2019

  • Pongs currently can appear to be unsolicited, not entirely sure what is causing that.

That is odd. Do you think that it's a show stopper in getting this merged? Or would a follow up post-alphanet PR suffice?

IMO, a follow up one is fine.

@kevjue
Copy link
Contributor

kevjue commented Jun 28, 2019

  • Pongs currently can appear to be unsolicited, not entirely sure what is causing that.

Follow up question: Are you getting pongs from nodes outside of your network? When I set up an isolated validator running on it's own machine, I was seeing a lot of discovery messages from random computers. Perhaps that is what you are seeing?

@asaj
Copy link
Contributor

asaj commented Jun 29, 2019

  • Pongs currently can appear to be unsolicited, not entirely sure what is causing that.

Follow up question: Are you getting pongs from nodes outside of your network? When I set up an isolated validator running on it's own machine, I was seeing a lot of discovery messages from random computers. Perhaps that is what you are seeing?

+1, I've experienced this as well in the past.

@nambrot
Copy link
Contributor Author

nambrot commented Jul 1, 2019

Wouldn't the bonding/verification of pings address this concern?

It would if we ping'd at the passed IP address, which this PR currently does not

That is odd. Do you think that it's a show stopper in getting this merged? Or would a follow up post-alphanet PR suffice?

I don't think it is a show-stopper, though it would be valuable to have a theory why this happens, which I do not.

Pongs currently can appear to be unsolicited, not entirely sure what is causing that.
Follow up question: Are you getting pongs from nodes outside of your network? When I set up an isolated validator running on it's own machine, I was seeing a lot of discovery messages from random computers. Perhaps that is what you are seeing?

Yes, I believe there must be nodes that just ping all IP addresses effectively? Or we possibly ping out to other bootnodes

@nambrot
Copy link
Contributor Author

nambrot commented Jul 1, 2019

@kevjue Note that I modified the PR at 32a855a to not take loopbacks which seems to be the case if one does not specify the --nat flag

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.

None yet

3 participants