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/nat: turn stop caring into stop requesting #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

dbadoy
Copy link
Owner

@dbadoy dbadoy commented Dec 23, 2022

Existing logic just ignores the response when the timeout passes. This actually means that the request is still sent to the NAT. This method returns nil if the 3rd request fails (after 1 second), but the goroutine continues to run and exits after making a total of 9 requests to the NAT. This PR turns stop caring into stop requesting with a small change(i.g. this is an optimization for NAT, not an optimization for the geth client).

cmd/bootnode, p2p: use an alternate port mapped to NAT

* temp

* rede

* remove meaningless field

* temp comment

* set refresh time to param

* server: use channel enr.Entry

* server: rename `changedport` to `changeport`

* server: apply new nat-refresh `ethereum discovery`

* p2p/nat: add some comment

* p2p/nat: use `DefaultMapTimeout`

* p2p: fixed

* p2p/server: impr

* p2p/server: syntax change

* cmd/bootnode: add comments

* add p2p.Server changeport

* all: fix comments

* p2p/server: syntax changes

* cmd/bootnode: do not change UDPAddr Port

* p2p: remove incorrect `for` context

* p2p: add what needs to be addressed

* p2p/nat: use AddPortMapping if supported

* asynchronous port set

* remove unused variables

* change return format in `changePort`

* cmd/bootnode: consistent log

* p2p/server: rename `refreshLogger` to `newLogger`

* cmd/bootnode: fix incorrect if-else

* fix

* change log orders

* rename `natRefresh` to `natMapLoop`

* p2p: remove `changeport` in Server main loop

* server: remove duplicate code

* typo

* typo

* cmd/bootnode: consistent log message

* p2p: fix comments

test code about port change on localnode

cmd/bootnode: add log

improve test logic , add some comments

p2p/nat: add comments about not supported

p2p: remove unnecessary conversion in test
This reverts commit dd6fe4c.
@dbadoy
Copy link
Owner Author

dbadoy commented Dec 23, 2022

However, if the first request fails, it is highly likely that the requesting to a wrong (or NAT-PMP not supported) NAT address. So it doesn't appear to be NAT optimization (reduce unnecessary requests) which is its original purpose.

@dbadoy dbadoy changed the title p2p/nat: turn stop caring into stop requesting p2p/nat: turn stop caring into stop requesting Dec 23, 2022
Copy link

@ray-themedium ray-themedium left a comment

Choose a reason for hiding this comment

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

NOOP

@fjl fjl force-pushed the master branch 2 times, most recently from de30212 to 619d9da Compare July 12, 2023 00:20
@dbadoy dbadoy force-pushed the master branch 2 times, most recently from 267c80e to b058cf4 Compare July 16, 2023 04:19
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