Skip to content

fix(net): disable Discv5 ENR auto-update when NAT disabled or explicit addr set#23075

Merged
mattsse merged 2 commits into
paradigmxyz:mainfrom
aayushbaluni:fix/20008-discv5-enr-update-nat
Mar 18, 2026
Merged

fix(net): disable Discv5 ENR auto-update when NAT disabled or explicit addr set#23075
mattsse merged 2 commits into
paradigmxyz:mainfrom
aayushbaluni:fix/20008-discv5-enr-update-nat

Conversation

@aayushbaluni

Copy link
Copy Markdown
Contributor

Summary

Disables Discv5 ENR auto-update when --disable-nat is set or when explicit --discovery.v5.addr / --discovery.v5.addr.ipv6 are configured.

Problem

When running a node with fixed public IP + port (e.g. in Kubernetes), manually set addresses get overwritten by the ENR auto-update. The UDP port gets replaced with a different value from PONG responses.

Example: --discovery.v5.port=30303 and --discovery.v5.addr=34.159.243.134 with --disable-nat still results in ENR advertising UDP port 45056 instead of 30303.

Solution

Call disable_enr_update() on the discv5 ConfigBuilder when:

  • discv5_addr is explicitly set (user specified discovery.v5.addr)
  • discv5_addr_ipv6 is explicitly set (user specified discovery.v5.addr.ipv6)
  • disable_nat is set (user does not want NAT discovery)

This matches the upstream discv5 behavior: when the user has explicitly configured their address or disabled NAT, the ENR should not be auto-updated from peer responses.

Testing

  • Manual verification with the reported params
  • Existing discovery tests remain unchanged

Fixes #20008

Made with Cursor

…t addr set

When --disable-nat is set or explicit discovery.v5.addr / discovery.v5.addr.ipv6
are configured, the ENR should not auto-update from PONG responses. Otherwise
the manually set UDP port gets overwritten by the discovery service.

Fixes #20008

@mattsse mattsse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Correct fix — disables ENR auto-update when the user has explicitly configured addresses or disabled NAT, preventing discv5 from overwriting fixed IP/port from peer PONG responses.

@github-project-automation github-project-automation Bot moved this from Backlog to In Progress in Reth Tracker Mar 18, 2026
@mattsse mattsse enabled auto-merge March 18, 2026 11:58
auto-merge was automatically disabled March 18, 2026 14:33

Head branch was pushed to by a user without write access

@mattsse mattsse enabled auto-merge March 18, 2026 21:24
@mattsse mattsse added this pull request to the merge queue Mar 18, 2026
Merged via the queue into paradigmxyz:main with commit a14db7f Mar 18, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Reth Tracker Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Discv5 ENR auto update should be disabled when NAT is disabled or explicit addresses are set

2 participants