Skip to content

Remove --ip-version CLI flag, always use dual-stack#52

Merged
grumbach merged 2 commits intoWithAutonomi:mainfrom
grumbach:claude/remove-ip-version-flag-SFH7m
Mar 31, 2026
Merged

Remove --ip-version CLI flag, always use dual-stack#52
grumbach merged 2 commits intoWithAutonomi:mainfrom
grumbach:claude/remove-ip-version-flag-SFH7m

Conversation

@grumbach
Copy link
Copy Markdown
Collaborator

The --ip-version flag allowed users to restrict the node to IPv4-only or IPv6-only mode. This was flagged for removal as it enables misconfiguration ("we cannot go back to tweakers"). The node now always runs in dual-stack mode (both IPv4 and IPv6), which was already the default.

Changes:

  • Remove --ip-version CLI arg and ANT_IP_VERSION env var
  • Remove IpVersion enum from config
  • Remove ip_version field from NodeConfig
  • Remove CliIpVersion enum and From impl
  • Hardcode ipv6=true in core config builder (dual-stack)
  • Update production.toml, testnet scripts, and README

https://claude.ai/code/session_01ApfhBFUhWMnYoZj7P1VkvU

The --ip-version flag allowed users to restrict the node to IPv4-only
or IPv6-only mode. This was flagged for removal as it enables
misconfiguration ("we cannot go back to tweakers"). The node now always
runs in dual-stack mode (both IPv4 and IPv6), which was already the
default.

Changes:
- Remove --ip-version CLI arg and ANT_IP_VERSION env var
- Remove IpVersion enum from config
- Remove ip_version field from NodeConfig
- Remove CliIpVersion enum and From impl
- Hardcode ipv6=true in core config builder (dual-stack)
- Update production.toml, testnet scripts, and README

https://claude.ai/code/session_01ApfhBFUhWMnYoZj7P1VkvU
Copilot AI review requested due to automatic review settings March 31, 2026 04:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the ability to force IPv4-only or IPv6-only operation via configuration/CLI, and makes the node always run in dual-stack mode (the prior default).

Changes:

  • Removed --ip-version CLI flag and related config/env plumbing (IpVersion, ip_version fields, CLI enum + conversion).
  • Forced dual-stack behavior by hardcoding IPv6 enabled in the core config builder.
  • Updated deployment/testnet scripts and sample config/docs to drop ip_version usage.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/node.rs Hardcodes core networking config to always enable IPv6 (dual-stack behavior).
src/config.rs Removes IpVersion and ip_version from NodeConfig and its defaults.
src/bin/ant-node/cli.rs Removes --ip-version CLI flag, CLI enum, and config mapping.
scripts/testnet/start-genesis.sh Drops --ip-version ipv4 from systemd unit templates.
scripts/testnet/spawn-nodes.sh Drops --ip-version ipv4 when spawning testnet nodes.
README.md Removes --ip-version from CLI/config examples and option list.
config/production.toml Removes ip_version from production config template.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1008 to 1012
### Configuration File

`~/.ant-node/config.toml`:

```toml
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

README still documents ANT_IP_VERSION under the Environment Variables section, but this PR removes the --ip-version flag and ANT_IP_VERSION env var support. Please update that section to remove (or replace) the ANT_IP_VERSION example so docs match the new behavior.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@mickvandijke mickvandijke left a comment

Choose a reason for hiding this comment

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

Deep Review: Address Reachability Risk

What the PR does

Clean removal — IpVersion enum, CliIpVersion, --ip-version CLI arg, ANT_IP_VERSION env var, ip_version config field all gone. ipv6 is now hardcoded to true (dual-stack) in build_core_config. The code change itself is correct and well-scoped.

Problem: two failure modes on hosts without working IPv6

The old --ip-version flag existed for a reason. With it removed and dual-stack hardcoded, there are two scenarios where this breaks:

1. IPv4-only kernel (no IPv6 support at all)

saorsa-core's DualStackNetworkNode::new_with_options() tries to bind [::]:<port>. On an IPv4-only kernel this fails with EAFNOSUPPORT or EADDRNOTAVAIL. The error propagates via ? with no fallback — the node crashes on startup.

2. IPv6-capable kernel but no routable IPv6 address (the worse case)

The bind to [::] succeeds (kernel supports it), but the machine has no global IPv6 address — only link-local fe80:: or nothing routable. The node starts fine but:

  • Advertises an unreachable IPv6 address to the DHT
  • saorsa-core does not validate routability before advertising — it only filters unspecified (::, 0.0.0.0), multicast, and loopback addresses. There's no is_global() check, no STUN/AutoNAT probe.
  • Peers accept the address into their routing tables (it passes all filters)
  • Peers waste time trying to dial it — hole-punching/relay fallback chain is 5s → 15s → 30s before giving up
  • This silently degrades network health with no obvious error on the node itself

Why this matters

  • The testnet scripts (spawn-nodes.sh, start-genesis.sh) previously hardcoded --ip-version ipv4 — likely because those VPS nodes have unreliable or absent IPv6 routing
  • Many cloud instances (older providers, some DigitalOcean/Hetzner configs) and corporate networks are IPv4-only or have non-routable IPv6
  • There's now no workaround for operators who know their network is IPv4-only

Existing config file compatibility

No issue here — NodeConfig doesn't use deny_unknown_fields, so old TOML files with ip_version = "dual" are silently ignored. Good.

Missed cleanup

README.md:1002 still lists export ANT_IP_VERSION=dual in the environment variables section.

Suggestion

The goal of preventing misconfiguration ("we cannot go back to tweakers") is valid, but removing the escape hatch entirely is unsafe without routability detection in saorsa-core. Options:

  1. Keep dual-stack as default, add --ipv4-only opt-out — simpler than the old 3-way enum, still prevents casual tweaking (it's an explicit opt-out rather than a menu), and gives operators the escape hatch they need
  2. Add a fallback in build_core_config — try dual-stack, if bind fails retry with ipv6=false. Only catches failure mode #1, not #2.
  3. Fix in saorsa-core — add routability detection before advertising addresses. The right long-term fix but a larger scope change.

I'd recommend option 1 as the pragmatic fix for this PR, with option 3 tracked as follow-up work.

…SION

Instead of removing IP version control entirely, add a simple --ipv4-only
boolean flag as an opt-out for hosts without working IPv6. This addresses
the reachability risk on IPv4-only kernels and hosts with non-routable
IPv6 addresses, while keeping dual-stack as the default.

- Add ipv4_only field to NodeConfig
- Add --ipv4-only CLI flag (ANT_IPV4_ONLY env var)
- Use ipv4_only in build_core_config to conditionally set ipv6
- Add --ipv4-only to testnet scripts (VPS nodes need it)
- Remove stale ANT_IP_VERSION=dual from README env vars section
- Document --ipv4-only in README CLI options
- Add tests for ipv4_only and dual-stack default behavior
@grumbach grumbach merged commit f113f4b into WithAutonomi:main Mar 31, 2026
11 checks passed
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.

4 participants