Skip to content

Conversation

@fjl
Copy link
Contributor

@fjl fjl commented May 17, 2024

enode.Node has separate accessor functions for getting the IP, UDP port and TCP port. These methods performed separate checks for attributes set in the ENR.

With this PR, the accessor methods will now return cached information, and the endpoint is determined when the node is created. The logic to determine the preferred endpoint is now more correct, and considers how 'global' each address is when both IPv4 and IPv6 addresses are present in the ENR.

This is an alternative to #29736.

@fjl
Copy link
Contributor Author

fjl commented May 17, 2024

Still a bit WIP, needs some more fixes to tests.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@fjl
Copy link
Contributor Author

fjl commented May 21, 2024

Fixed the test by allowing unspecified IP in node. I'm doing this to allow nodes with 0.0.0.0 to round-trip the enode:// URL encoding/parsing. We check for a valid IP in discovery, so it shouldn't cause any issues.

@fjl fjl added this to the 1.14.4 milestone May 23, 2024
@fjl fjl merged commit cc9e2bd into ethereum:master May 23, 2024
jorgemmsilva pushed a commit to iotaledger/go-ethereum that referenced this pull request Jun 17, 2024
enode.Node has separate accessor functions for getting the IP, UDP port and TCP port.
These methods performed separate checks for attributes set in the ENR.

With this PR, the accessor methods will now return cached information, and the endpoint is
determined when the node is created. The logic to determine the preferred endpoint is now
more correct, and considers how 'global' each address is when both IPv4 and IPv6 addresses
are present in the ENR.
maoueh pushed a commit to streamingfast/go-ethereum that referenced this pull request Aug 1, 2024
enode.Node has separate accessor functions for getting the IP, UDP port and TCP port.
These methods performed separate checks for attributes set in the ENR.

With this PR, the accessor methods will now return cached information, and the endpoint is
determined when the node is created. The logic to determine the preferred endpoint is now
more correct, and considers how 'global' each address is when both IPv4 and IPv6 addresses
are present in the ENR.
@atenjin
Copy link

atenjin commented Feb 19, 2025

Hey guy, in this pr, when bootnodes is using DNS rather than a pure ip, it will cause geth shudown when start:

INFO [02-19|18:54:26.410] Loaded most recent local block           number=0 hash=9723ca..2dcb17 td=0 age=5mo4w3h
WARN [02-19|18:54:26.410] Loaded snapshot journal                  diffs=missing
INFO [02-19|18:54:26.411] Initialized transaction indexer          range="last 2350000 blocks"
INFO [02-19|18:54:26.411] Initialising Ethereum protocol           network=202,402,181,627 dbversion=8
INFO [02-19|18:54:26.411] Resuming state snapshot generation       root=917176..1a9062 at=7bb8ad..8c83a9 accounts=1187 slots=1061 storage=200.07KiB dangling=0 elapsed="209.698µs"
INFO [02-19|18:54:26.411] Loaded local transaction journal         transactions=0 dropped=0
INFO [02-19|18:54:26.412] Enabled snap sync                        head=0 hash=9723ca..2dcb17
INFO [02-19|18:54:26.412] Gasprice oracle is ignoring threshold set threshold=2
WARN [02-19|18:54:26.412] Unclean shutdown detected                booted=2025-02-19T18:52:45+0800 age=1m41s
WARN [02-19|18:54:26.413] Engine API enabled                       protocol=eth
INFO [02-19|18:54:26.413] Starting peer-to-peer node               instance=Geth/v0.1.0-untagged-acea1259-20250213/linux-amd64/go1.22.9
INFO [02-19|18:54:26.468] Generated state snapshot                 accounts=2335 slots=2084 storage=392.54KiB dangling=0 elapsed=57.821ms
Fatal: Error starting protocol stack: bad bootstrap node "enode://e678ad93232957b75742ec8fbda3aaa557ade5407dc70c4377f4690291054be0ef082d6axxxxxxxxxxxxxxxxxxxxxxxxxxxxx@testnet-mux-aws.xxx.xxx:30970": missing IP address

jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Jul 23, 2025
enode.Node has separate accessor functions for getting the IP, UDP port and TCP port.
These methods performed separate checks for attributes set in the ENR.

With this PR, the accessor methods will now return cached information, and the endpoint is
determined when the node is created. The logic to determine the preferred endpoint is now
more correct, and considers how 'global' each address is when both IPv4 and IPv6 addresses
are present in the ENR.
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Sep 3, 2025
enode.Node has separate accessor functions for getting the IP, UDP port and TCP port.
These methods performed separate checks for attributes set in the ENR.

With this PR, the accessor methods will now return cached information, and the endpoint is
determined when the node is created. The logic to determine the preferred endpoint is now
more correct, and considers how 'global' each address is when both IPv4 and IPv6 addresses
are present in the ENR.
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Sep 4, 2025
enode.Node has separate accessor functions for getting the IP, UDP port and TCP port.
These methods performed separate checks for attributes set in the ENR.

With this PR, the accessor methods will now return cached information, and the endpoint is
determined when the node is created. The logic to determine the preferred endpoint is now
more correct, and considers how 'global' each address is when both IPv4 and IPv6 addresses
are present in the ENR.
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Sep 16, 2025
enode.Node has separate accessor functions for getting the IP, UDP port and TCP port.
These methods performed separate checks for attributes set in the ENR.

With this PR, the accessor methods will now return cached information, and the endpoint is
determined when the node is created. The logic to determine the preferred endpoint is now
more correct, and considers how 'global' each address is when both IPv4 and IPv6 addresses
are present in the ENR.
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