Consensys / teku

Open-source Ethereum consensus client written in Java
https://consensys.io/teku
Apache License 2.0
679 stars 284 forks source link

IPv6 not automatically detected or included in ENR #8670

Closed one-three-three-seven closed 1 month ago

one-three-three-seven commented 1 month ago

Description

I'm testing the IPv6 implementations of all clients and noticed that Teku never updates the ENR with the IPv6 address. General test results for all clients can be found at https://ipv6eth.info

Steps to Reproduce (Bug)

My idea was to find as many IPv6 peers as possible by increasing the peer limit. In the end I had about 3000 peers, but the ENR still did not include the IPv6 address. The node had ~13 IPv6 peers.

Relevant parameters: teku --p2p-interface 0.0.0.0,:: --p2p-port 9000 --p2p-port-ipv6 9001 --p2p-peer-upper-bound 10000 ... Both ports 9000/9001 are open, UDP/TCP each. The system has a global IPv6 address.

I'm using the /eth/v1/node/identity endpoint to fetch the current ENR.

{
  "data": {
    "discovery_addresses": [
      "/ip4/REDACTED/udp/9000/p2p/REDACTED"
    ],
    "enr": "REDACTED_ENR_WITHOUT_IPV6_ADDRESS",
    "metadata": {
      "attnets": "0x0000060000000000",
      "seq_number": "1",
      "syncnets": "0x00"
    },
    "p2p_addresses": [
      "/ip4/10.10.10.2/tcp/9000/p2p/REDACTED", <--- FYI: This is a local IP, not relevant for the node
      "/ip6/::/tcp/9001/p2p/REDACTED"
    ],
    "peer_id": "REDACTED"
  }
}

discovery_addresses does not include the IPv6.

Expected behavior:

Teku should detect the IPv6 address and include it in the ENR.

Actual behavior:

The ENR never includes the IPv6 address. While it can be set manually, this approach is ineffective for dynamic IPv6 addresses.

Frequency: Always

Versions

StefanBratanov commented 1 month ago

Hi, can you please try also specifying --p2p-advertised-ip=127.0.0.1,::1 as per the docs. Probably should change the default to change if --p2p-interface has been configured with IPv4 and IPv6 address.

StefanBratanov commented 1 month ago

For reference: https://docs.teku.consensys.io/how-to/find-and-connect/configure-ipv6#advertise-both-ipv4-and-ipv6-addresses-dual-stack

one-three-three-seven commented 1 month ago

I've given it a try, but I don't think it's achieving what I want.

Now the endpoint /eth/v1/node/identity returns the following:

{
  "data": {
    "discovery_addresses": [
      "/ip4/127.0.0.1/udp/9000/p2p/REDACTED",
      "/ip6/::1/udp/9001/p2p/REDACTED"
    ],
    "enr": "REDACTED",
    "metadata": {
      "attnets": "0x0000060000000000",
      "seq_number": "1",
      "syncnets": "0x00"
    },
    "p2p_addresses": [
      "/ip4/127.0.0.1/tcp/9000/p2p/REDACTED",
      "/ip6/::1/tcp/9001/p2p/REDACTED"
    ],
    "peer_id": "REDACTED"
  }
}

What I want is for Teku to automatically detect the IP addresses and use them as follows:

{
  "data": {
    "discovery_addresses": [
      "/ip4/135.151.32.250/udp/9000/p2p/REDACTED",
      "/ip6/54b6:6e28:4636:3f40:c880:3f78:acaf:b0d4/udp/9001/p2p/REDACTED"
    ],
    "enr": "REDACTED",
    "metadata": {
      "attnets": "0x0000060000000000",
      "seq_number": "1",
      "syncnets": "0x00"
    },
    "p2p_addresses": [
      "/ip4/135.151.32.250/tcp/9000/p2p/REDACTED",
      "/ip6/54b6:6e28:4636:3f40:c880:3f78:acaf:b0d4/tcp/9001/p2p/REDACTED"
    ],
    "peer_id": "REDACTED"
  }
}

Teku is already able to do this automatically for IPv4 addresses, but not for IPv6 ones.

StefanBratanov commented 1 month ago

Hi @one-three-three-seven In Teku, for automatic detection we only use site local or unique local addresses found in the interfaces list. image

lucassaldanha commented 1 month ago

Closing this ticket for now. Feel free to reopen it with more info if needed.