fix(net): disable Discv5 ENR auto-update when NAT disabled or explicit addr set#23075
Merged
mattsse merged 2 commits intoMar 18, 2026
Merged
Conversation
…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
approved these changes
Mar 18, 2026
mattsse
left a comment
Collaborator
There was a problem hiding this comment.
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.
auto-merge was automatically disabled
March 18, 2026 14:33
Head branch was pushed to by a user without write access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Disables Discv5 ENR auto-update when
--disable-natis set or when explicit--discovery.v5.addr/--discovery.v5.addr.ipv6are 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=30303and--discovery.v5.addr=34.159.243.134with--disable-natstill results in ENR advertising UDP port 45056 instead of 30303.Solution
Call
disable_enr_update()on the discv5 ConfigBuilder when:discv5_addris explicitly set (user specified discovery.v5.addr)discv5_addr_ipv6is explicitly set (user specified discovery.v5.addr.ipv6)disable_natis 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
Fixes #20008
Made with Cursor