Skip to content

fix(p2p): add p2p.announce_addresses to override advertised addresses - #3510

Merged
auricom merged 2 commits into
mainfrom
recur/p2p-announce-addresses
Nov 25, 2026
Merged

auricom merged 2 commits into
mainfrom
recur/p2p-announce-addresses

Conversation

@auricom

@auricom auricom commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Overview

ev-node gives operators no way to choose the P2P addresses it advertises. celestia-node has AnnounceAddresses and ev-reth has --nat extip:<IP>. A containerized ev-node that doesn't use host networking advertises only its loopback and Docker bridge addresses, so other peers can't connect to it. Right now, 6 of the 10 nodes announcing the eden-mainnet namespace advertise only loopback, Docker bridge or CGNAT addresses, and so do 3 of the 6 testnet nodes.

This PR adds p2p.announce_addresses (flag --evnode.p2p.announce_addresses), a comma-separated list of multiaddrs. When it's set, listen() installs a libp2p AddrsFactory that replaces the addresses detected from the network interfaces with the configured ones. libp2p uses that list everywhere it reports the node's addresses (identify, the DHT, namespace discovery) and so does GetNetworkInfo (/net_info, p2p info).

  • The configured addresses replace the detected ones rather than being added to them, so internal addresses stop being advertised.
  • An invalid entry makes the node fail at startup instead of being silently ignored.
  • The value is not passed through TranslateAddresses, so values must be multiaddrs. Both /ip4/... and /dns4/... work.
  • Empty (the default) keeps the current behavior.

Docker example: publish the port with -p 7676:7676 and set --evnode.p2p.announce_addresses /ip4/<public-ip>/tcp/7676.

Not included

  • A no_announce_addresses filter like celestia-node's.
  • Automatic filtering of private IPs, which would break local devnets.
  • UPnP/NAT port mapping.

Testing

  • New TestAnnounceAddresses covers the replacement, GetNetworkInfo output and an invalid value. The config flag test is updated (expected flag count 91 → 92).
  • go test ./pkg/config/... ./pkg/cmd/... ./pkg/p2p/... passes. TestDiscovery failed once in a combined run but passed 10/10 on both this branch and the base commit, so it looks flaky.
  • golangci-lint crashed locally inside the tool itself, so the lint result is up to CI.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a setting to specify which network addresses a node advertises to peers. This can help nodes behind NAT or in containers advertise reachable addresses instead of automatically detected local addresses.
    • When the setting is empty, the node continues to advertise its listen addresses.
  • Documentation
    • Added configuration examples for YAML, command-line, and container deployments.

Nodes running in containers without host networking (or behind NAT)
advertised only their loopback/Docker bridge addresses, so remote peers
could not dial them. The new option installs a libp2p AddrsFactory that
replaces the auto-detected addresses with the configured multiaddrs for
identify, the DHT and namespace discovery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The P2P configuration adds p2p.announce_addresses. When set, the P2P client parses the configured multiaddresses and uses them for peer advertisement instead of auto-detected addresses.

Changes: P2P Announce Addresses

Layer / File(s) Summary
Configure announce addresses
pkg/config/config.go, pkg/config/config_test.go, pkg/p2p/README.md, docs/learn/config.md, docs/reference/configuration/ev-node-config.md, CHANGELOG.md
The P2P configuration and flag expose announce_addresses. The documentation and changelog describe the setting, its empty default, and configuration examples. The flag test checks its default.
Parse and advertise configured addresses
pkg/p2p/client.go, pkg/p2p/client_test.go
Client.listen parses configured multiaddresses and uses them instead of auto-detected addresses. Tests check the advertised addresses and errors for invalid or empty input.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client.listen
  participant parseMultiaddrs
  participant libp2pHost
  Client.listen->>parseMultiaddrs: Parse comma-separated announce addresses
  parseMultiaddrs-->>Client.listen: Return parsed addresses or an error
  Client.listen->>libp2pHost: Configure advertised-address factory
  libp2pHost-->>Client.listen: Return host with configured advertised addresses
Loading

Suggested reviewers: tac0turtle, julienrbrt

Merge Risk: Minimal · up to 302da

This adds an optional setting for the addresses a node advertises to peers. Leaving it empty keeps current behavior, and invalid values fail at startup. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description check Passed The description follows the template: it has an Overview section that gives context (no way for operators to choose advertised P2P addresses, containerized nodes advertising only loopback/Docker bridg…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title names the new p2p.announce_addresses setting, which is the main change in the changeset. It states that the setting overrides advertised addresses, which matches the client.go logic and the …
Full details: Description check

Explanation

The description follows the template: it has an Overview section that gives context (no way for operators to choose advertised P2P addresses, containerized nodes advertising only loopback/Docker bridge addresses), the goal, the flag and behavior, Docker usage, exclusions, and testing notes. The template's optional issue link (Closes #) is absent, but the description links the context and the related PR number is in the objectives. This is a minor gap and does not affect completeness.

Full details: Title check

Explanation

The title names the new p2p.announce_addresses setting, which is the main change in the changeset. It states that the setting overrides advertised addresses, which matches the client.go logic and the config flag. The fix(p2p) prefix is a minor mismatch because the PR adds a feature, but the title still describes the primary change accurately and specifically.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 22b337d2-aac2-4eb8-ab47-aaf0de383758
Commits

Reviewing files that changed from the base of the PR and between 28d2714 and 302da06.

Files selected for processing: 8

  • CHANGELOG.md
  • docs/learn/config.md
  • docs/reference/configuration/ev-node-config.md
  • pkg/config/config.go
  • pkg/config/config_test.go
  • pkg/p2p/README.md
  • pkg/p2p/client.go
  • pkg/p2p/client_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The latest Buf updates on your PR. Results from workflow CI / buf-check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed⏩ skippedNov 25, 2026, 8:41 AM

A value made only of separators (e.g. ",") passed the empty-string guard
and installed an AddrsFactory returning no addresses, so the node
advertised nothing. Also make the test order-independent (libp2p sorts
the factory output), align the p2p README table and link the PR in the
changelog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.37%. Comparing base (28d2714) to head (302da06).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3510      +/-   ##
==========================================
+ Coverage   69.35%   69.37%   +0.02%     
==========================================
  Files         122      122              
  Lines       12219    12237      +18     
==========================================
+ Hits         8474     8489      +15     
- Misses       3745     3748       +3     
Flag Coverage Δ
combined 69.37% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@damiannolan damiannolan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

@damiannolan
damiannolan marked this pull request as ready for review November 25, 2026 13:18
@auricom auricom changed the title feat(p2p): add p2p.announce_addresses to override advertised addresses fix(p2p): add p2p.announce_addresses to override advertised addresses Nov 25, 2026
@auricom
auricom added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 010ab7b Nov 25, 2026
36 of 37 checks passed
@auricom
auricom deleted the recur/p2p-announce-addresses branch November 25, 2026 13:51
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-25 13:52 UTC

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.

2 participants