feat(net): advertise --nat extip/extaddr IP in discv5 ENR#23863
Open
nktaushanov wants to merge 4 commits intoparadigmxyz:mainfrom
Open
feat(net): advertise --nat extip/extaddr IP in discv5 ENR#23863nktaushanov wants to merge 4 commits intoparadigmxyz:mainfrom
nktaushanov wants to merge 4 commits intoparadigmxyz:mainfrom
Conversation
Adds `advertised_ip: Option<IpAddr>` to `reth_discv5::Config`. When set, `build_local_enr` uses it for the ENR `ip4`/`ip6` field regardless of the UDP listen address, and `enr_update` is disabled so discv5's peer-observation does not overwrite the static value. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
When `--nat extip:<IP>` or `--nat extaddr:<DOMAIN>` is set, the resolved IP is now wired into the discv5 `advertised_ip` field so it appears in the ENR gossiped to peers. Only `ExternalIp`/`ExternalAddr` variants are resolved synchronously; other variants keep existing peer-observation behaviour. Fixes nodes behind load balancers that bound discv5 to 0.0.0.0 and gossiped an ENR with no ip4 field, breaking inbound gossip-based peer discovery. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Expand `if advertised_ip.is_some()` block with comment above - Use `nat.clone().and_then(|n| n.as_external_ip(0))` (idiomatic) - Fix `netif` doc: no argument accepted - Compact Config destructure in `build_local_enr` per nightly fmt - Assert `udp6` is present in dual-stack test (documented edge case) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.
Issue:
This change is required because when running reth nodes in Kubernetes
behind a load balancer, discv5 is not working. The local ENR was built from
the UDP listen address (the pod IP), so peers could never reach the node on
the LB's public IP. discv5's peer-observation ENR update doesn't help here
either — the LB rewrites source addresses, so observed IPs are noise.
Changes:
Adds an
advertised_ipoverride on the discv5 config and wires--nat(thestatic
extip:/extaddr:variants) into it, so the locally built ENR carriesthe user-provided external address instead of the UDP listen IP. Also disables
discv5's peer-observation ENR update when an override is set, so the
statically advertised address can't be flapped by observed source IPs.
Useful for nodes reachable on an address they don't bind locally (load
balancer, static NAT, 1:1 DNAT). Async resolvers (
upnp,publicip,any)are unaffected and still rely on discv5's observation-based update.