Skip to content

Commit

Permalink
UX Network Fixes (#6796)
Browse files Browse the repository at this point in the history
There were two things I came across during some recent testing, that this PR addresses.

1 - The default port for IPv6 was set to 9090, which is confusing. I've set this to match its ipv4 counterpart (i.e 9000 and 9001). This makes more sense and is easier to firewall, for those firewalls that support both versions for a single rule.

2 - Watching the NAT status of lighthouse, I notice we only set the field to 1 once the NAT is passed. We don't give it a default 0 (false). So we only see results when its successful. On peer disconnects, i've piggy-backed a loop of the connected peers to also watch and check for NAT status updates.
  • Loading branch information
AgeManning authored Feb 4, 2025
1 parent df131b2 commit d1061dc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
3 changes: 1 addition & 2 deletions beacon_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ pub fn cli_app() -> Command {
.long("port6")
.value_name("PORT")
.help("The TCP/UDP ports to listen on over IPv6 when listening over both IPv4 and \
IPv6. Defaults to 9090 when required. The Quic UDP port will be set to this value + 1.")
.default_value("9090")
IPv6. Defaults to --port. The Quic UDP port will be set to this value + 1.")
.action(ArgAction::Set)
.display_order(0)
)
Expand Down
14 changes: 10 additions & 4 deletions beacon_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,12 +936,11 @@ pub fn parse_listening_addresses(
.expect("--port has a default value")
.parse::<u16>()
.map_err(|parse_error| format!("Failed to parse --port as an integer: {parse_error}"))?;
let port6 = cli_args
let maybe_port6 = cli_args
.get_one::<String>("port6")
.map(|s| str::parse::<u16>(s))
.transpose()
.map_err(|parse_error| format!("Failed to parse --port6 as an integer: {parse_error}"))?
.unwrap_or(9090);
.map_err(|parse_error| format!("Failed to parse --port6 as an integer: {parse_error}"))?;

// parse the possible discovery ports.
let maybe_disc_port = cli_args
Expand Down Expand Up @@ -989,6 +988,10 @@ pub fn parse_listening_addresses(
warn!(log, "When listening only over IPv6, use the --port flag. The value of --port6 will be ignored.");
}

// If we are only listening on ipv6 and the user has specified --port6, lets just use
// that.
let port = maybe_port6.unwrap_or(port);

// use zero ports if required. If not, use the given port.
let tcp_port = use_zero_ports
.then(unused_port::unused_tcp6_port)
Expand Down Expand Up @@ -1055,6 +1058,9 @@ pub fn parse_listening_addresses(
})
}
(Some(ipv4), Some(ipv6)) => {
// If --port6 is not set, we use --port
let port6 = maybe_port6.unwrap_or(port);

let ipv4_tcp_port = use_zero_ports
.then(unused_port::unused_tcp4_port)
.transpose()?
Expand All @@ -1074,7 +1080,7 @@ pub fn parse_listening_addresses(
ipv4_tcp_port + 1
});

// Defaults to 9090 when required
// Defaults to 9000 when required
let ipv6_tcp_port = use_zero_ports
.then(unused_port::unused_tcp6_port)
.transpose()?
Expand Down
8 changes: 4 additions & 4 deletions book/src/advanced_networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ To listen over both IPv4 and IPv6:
>
> **IPv6**:
>
> It listens on the default value of --port6 (`9090`) for both UDP and TCP.
> QUIC will use port `9091` for UDP, which is the default `--port6` value (`9090`) + 1.
> It listens on the default value of --port6 (`9000`) for both UDP and TCP.
> QUIC will use port `9001` for UDP, which is the default `--port6` value (`9000`) + 1.
> When using `--listen-address :: --listen-address --port 9909 --discovery-port6 9999`, listening will be set up as follows:
>
Expand All @@ -174,8 +174,8 @@ To listen over both IPv4 and IPv6:
>
> **IPv6**:
>
> It listens on the default value of `--port6` (`9090`) for TCP, and port `9999` for UDP.
> QUIC will use port `9091` for UDP, which is the default `--port6` value (`9090`) + 1.
> It listens on the default value of `--port6` (`9000`) for TCP, and port `9999` for UDP.
> QUIC will use port `9001` for UDP, which is the default `--port6` value (`9000`) + 1.
### Configuring Lighthouse to advertise IPv6 reachable addresses

Expand Down
4 changes: 2 additions & 2 deletions book/src/help_bn.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ Options:
[default: 9000]
--port6 <PORT>
The TCP/UDP ports to listen on over IPv6 when listening over both IPv4
and IPv6. Defaults to 9090 when required. The Quic UDP port will be
set to this value + 1. [default: 9090]
and IPv6. Defaults to --port. The Quic UDP port will be set to this
value + 1.
--prepare-payload-lookahead <MILLISECONDS>
The time before the start of a proposal slot at which payload
attributes should be sent. Low values are useful for execution nodes
Expand Down

0 comments on commit d1061dc

Please sign in to comment.