Skip to content

Comments

Fix port selection#423

Merged
mergify[bot] merged 6 commits intosigp:unstablefrom
dknopik:port-fixes
Jul 10, 2025
Merged

Fix port selection#423
mergify[bot] merged 6 commits intosigp:unstablefrom
dknopik:port-fixes

Conversation

@dknopik
Copy link
Member

@dknopik dknopik commented Jul 9, 2025

Issue Addressed

My previous PR introduced a regression, as --port was only respected for the TCP port, but not the discovery port.

Also I noticed that --port6 was not correctly set at all.

Proposed Changes

Ensure that:

  • ports are set as in Go-SSV when --port is not specified.
  • if only --port is specified, that is used for both TCP and discovery UDP.
  • if --discovery-port is specified, that value is used for discovery UDP regardless of whether --port is specified.
  • --port6 is respected

- Use --port as --discovery-port if and only if explicitly given
- Respect --port6
@dknopik dknopik requested a review from Zacholme7 July 9, 2025 12:40
@dknopik dknopik added bug Something isn't working network cli v0.2.0 Second testnet release labels Jul 9, 2025
@dknopik
Copy link
Member Author

dknopik commented Jul 9, 2025

Added some docs to highlight the default ports and sneaked in some more details 👀

@diegomrsantos diegomrsantos requested a review from Copilot July 10, 2025 12:45
Copy link
Contributor

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 fixes the port selection logic so that TCP, discovery UDP, and IPv6 ports all respect the appropriate flags and default to Go-SSV values, and updates documentation to match.

  • Export default port constants and use them when no CLI flag is provided
  • Ensure --port applies to both TCP and discovery UDP, --discovery-port overrides only discovery, and --port6 is respected
  • Update docs to reflect new defaults and directory layout

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
book/src/running_node.md Added Golang migration note, updated default data directory and port docs
book/src/cli.md Clarified default behavior of --discovery-port
book/src/advanced_networking.md Updated default UDP/TCP port list to match new defaults
anchor/network/src/lib.rs Export DEFAULT_DISC_PORT, DEFAULT_QUIC_PORT, and DEFAULT_TCP_PORT constants
anchor/client/src/config.rs Revised port-parsing logic to use Option<u16> flags and default constants
anchor/client/src/cli.rs Made --port and --discovery-port optional and updated help text
.github/wordlist.txt Added “Golang” to the wordlist
Comments suppressed due to low confidence (4)

anchor/client/src/config.rs:461

  • For the IPv6 discovery port fallback, this uses cli_args.port instead of cli_args.port6. It should .or(cli_args.port6) before falling back to the default.
                .use_zero_ports

book/src/running_node.md:35

  • [nitpick] Consider changing “Per default” to “By default” for idiomatic English.
Create a directory for Anchor-related data and move the generated private key into the directory. Per default, Anchor

book/src/cli.md:76

  • The backtick formatting is mismatched (--port`). It should be --port `` for correct Markdown rendering.
| `--discovery-port <PORT>` | UDP port for discovery | Same as ``--port` if specified, otherwise `12001` |

anchor/client/src/cli.rs:263

  • [nitpick] Use consistent branding: elsewhere it’s referred to as “Go-SSV”, so consider capitalizing here to “Go-SSV”.
                      matching go-ssv's default values.",

Zacholme7
Zacholme7 previously approved these changes Jul 10, 2025
Copy link
Member

@Zacholme7 Zacholme7 left a comment

Choose a reason for hiding this comment

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

tiny wording. lgtm

will apply to the IPv4 address and --port6 to the IPv6 address.",
default_value = "13001",
will apply to the IPv4 address and --port6 to the IPv6 address. If this flag is not set, the default values will be 12001 for discovery and 13001 for TCP, \
matching go-ssv's default values.",
Copy link
Member

Choose a reason for hiding this comment

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

IMO, I wouldnt mention this is matching go-ssv.

value_name = "PORT",
help = "The UDP port that discovery will listen on. Defaults to `12001`",
default_value = "12001",
help = "The UDP port that discovery will listen on. Defaults to --port if explicitly specified, and `12001` otherwise.",
Copy link
Member

Choose a reason for hiding this comment

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

I think this description is a little confusing. I would just add in "--port if --port is explicitly specified". Otherwise it makes it sound like this will default to --port if --discovery-port is specified.

Copy link
Member

Choose a reason for hiding this comment

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

or maybe "It has the value passed in --port, if --port is explicitly specified"

Co-authored-by: Zacholme7 <zacholme@gmail.com>
Comment on lines 259 to 262
help = "The TCP/UDP ports to listen on. There are two UDP ports. \
The discovery UDP port will be set to this value and the Quic UDP port will be set to this value + 1. The discovery port can be modified by the \
--discovery-port flag and the quic port can be modified by the --quic-port flag. If listening over both IPv4 and IPv6 the --port flag \
will apply to the IPv4 address and --port6 to the IPv6 address.",
default_value = "13001",
will apply to the IPv4 address and --port6 to the IPv6 address. If this flag is not set, the default values will be 12001 for discovery and 13001 for TCP.",
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit confusing We mention TCP two times, but the text is mostly about discovery UDP and Quic UDP.

Copy link
Member Author

Choose a reason for hiding this comment

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

changed it a bit, wdyt?

Co-authored-by: diegomrsantos <diego@sigmaprime.io>
@diegomrsantos
Copy link
Member

Small nits, otherwise looks great.

Co-authored-by: diegomrsantos <diego@sigmaprime.io>
Copy link
Member

@diegomrsantos diegomrsantos left a comment

Choose a reason for hiding this comment

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

Thank you

mergify bot added a commit that referenced this pull request Jul 10, 2025
@mergify mergify bot merged commit 7a91e3e into sigp:unstable Jul 10, 2025
17 checks passed
mergify bot pushed a commit that referenced this pull request Jul 10, 2025
My previous PR introduced a regression, as `--port` was only respected for the TCP port, but not the discovery port.

Also I noticed that `--port6` was not correctly set at all.


  Ensure that:

- ports are set as in Go-SSV when `--port` is not specified.
- if only `--port` is specified, that is used for both TCP and discovery UDP.
- if `--discovery-port` is specified, that value is used for discovery UDP regardless of whether `--port` is specified.
- `--port6` is respected
@dknopik dknopik deleted the port-fixes branch July 18, 2025 08:57
diegomrsantos pushed a commit to diegomrsantos/anchor that referenced this pull request Sep 17, 2025
My previous PR introduced a regression, as `--port` was only respected for the TCP port, but not the discovery port.

Also I noticed that `--port6` was not correctly set at all.


  Ensure that:

- ports are set as in Go-SSV when `--port` is not specified.
- if only `--port` is specified, that is used for both TCP and discovery UDP.
- if `--discovery-port` is specified, that value is used for discovery UDP regardless of whether `--port` is specified.
- `--port6` is respected
jking-aus pushed a commit to jking-aus/anchor that referenced this pull request Oct 8, 2025
My previous PR introduced a regression, as `--port` was only respected for the TCP port, but not the discovery port.

Also I noticed that `--port6` was not correctly set at all.


  Ensure that:

- ports are set as in Go-SSV when `--port` is not specified.
- if only `--port` is specified, that is used for both TCP and discovery UDP.
- if `--discovery-port` is specified, that value is used for discovery UDP regardless of whether `--port` is specified.
- `--port6` is respected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cli network ready-for-merge v0.2.0 Second testnet release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants