From 0c1129d5a98e4cf4511b1b2c09858238a4433386 Mon Sep 17 00:00:00 2001 From: Daniel Knopik Date: Tue, 8 Jul 2025 08:59:41 +0200 Subject: [PATCH 1/8] Set `allow_self_origin(true)` --- anchor/network/src/behaviour.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/anchor/network/src/behaviour.rs b/anchor/network/src/behaviour.rs index 9251e5acc..92f0020c9 100644 --- a/anchor/network/src/behaviour.rs +++ b/anchor/network/src/behaviour.rs @@ -78,6 +78,7 @@ impl AnchorBehaviour { .message_id_fn(gossip_message_id) .flood_publish(false) .validation_mode(ValidationMode::Permissive) + .allow_self_origin(true) .mesh_n(8) // D .mesh_n_low(6) // Dlo .mesh_n_high(12) // Dhi From 615c314da7b909a10eda95c9d3d80480ce061ac0 Mon Sep 17 00:00:00 2001 From: Daniel Knopik Date: Wed, 9 Jul 2025 10:05:52 +0200 Subject: [PATCH 2/8] Fix port selection - Use --port as --discovery-port if and only if explicitly given - Respect --port6 --- anchor/client/src/cli.rs | 9 ++++----- anchor/client/src/config.rs | 29 ++++++++++++++++++----------- anchor/network/src/lib.rs | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/anchor/client/src/cli.rs b/anchor/client/src/cli.rs index 8a11488b8..b2f52948e 100644 --- a/anchor/client/src/cli.rs +++ b/anchor/client/src/cli.rs @@ -259,11 +259,11 @@ pub struct Node { 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, \ + matching go-ssv's default values.", action = ArgAction::Set, )] - pub port: u16, + pub port: Option, #[clap( long, @@ -277,8 +277,7 @@ pub struct Node { #[clap( long, 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.", action = ArgAction::Set, )] pub discovery_port: Option, diff --git a/anchor/client/src/config.rs b/anchor/client/src/config.rs index 096e39383..fbd4a4292 100644 --- a/anchor/client/src/config.rs +++ b/anchor/client/src/config.rs @@ -4,7 +4,7 @@ use std::{fs, net::IpAddr, path::PathBuf}; use multiaddr::{Multiaddr, Protocol}; -use network::{ListenAddr, ListenAddress}; +use network::{DEFAULT_DISC_PORT, DEFAULT_TCP_PORT, ListenAddr, ListenAddress}; use sensitive_url::SensitiveUrl; use ssv_network_config::SsvNetworkConfig; use ssv_types::OperatorId; @@ -364,16 +364,18 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result Result Result Result; From fd91befa078a47077cc42c18a3a428341c3ad2cd Mon Sep 17 00:00:00 2001 From: Daniel Knopik Date: Wed, 9 Jul 2025 14:52:54 +0200 Subject: [PATCH 3/8] Adjust docs --- book/src/advanced_networking.md | 2 +- book/src/cli.md | 2 +- book/src/running_node.md | 16 +++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/book/src/advanced_networking.md b/book/src/advanced_networking.md index dfc8a3379..75e4455da 100644 --- a/book/src/advanced_networking.md +++ b/book/src/advanced_networking.md @@ -5,6 +5,6 @@ Anchor's networking stack is closely based on Lighthouse's. We refer to but want to outline several important differences: - Currently, Anchor does not support UPnP. -- Anchor uses ports 12001 (UDP), 13001 (TCP), and 9101 (UDP) by default. +- Anchor uses ports 12001 (UDP), 13001 (TCP), and 12002 (UDP) by default. - Anchor does not yet support ENR auto-update - we therefore recommend manually setting publicly reachable ports via the `--enr*-port` CLI parameters to advertise your node as reachable on the network. diff --git a/book/src/cli.md b/book/src/cli.md index 13c97b816..a7e82c864 100644 --- a/book/src/cli.md +++ b/book/src/cli.md @@ -73,7 +73,7 @@ anchor node [OPTIONS] | `--listen-address
` | Network address to listen for UDP & TCP connections | `0.0.0.0` | | `--port ` | Base port for all network connections | `13001` | | `--port6 ` | Base port for IPv6 network connections | Same as `--port` | -| `--discovery-port ` | UDP port for discovery | `12001` | +| `--discovery-port ` | UDP port for discovery | Same as ``--port` if specified, otherwise `12001` | | `--discovery-port6 ` | UDP port for IPv6 discovery | Same as `--discovery-port` | | `--quic-port ` | UDP port for QUIC protocol | `--port` + 1 | | `--quic-port6 ` | UDP port for IPv6 QUIC protocol | `--port6` + 1 | diff --git a/book/src/running_node.md b/book/src/running_node.md index af68923e4..15711f892 100644 --- a/book/src/running_node.md +++ b/book/src/running_node.md @@ -4,6 +4,8 @@ An SSV operator is a node that holds shares of validators' keys and participates in committees to perform Ethereum validation duties. The SSV network enables distributed validation where multiple operators collectively validate without any single operator having access to the complete validator key. +If you want to migrate an existing key from the Golang implementation of SSV, you can directly proceed to Step 3. + **Step 1: Generate RSA keys** Anchor includes a key generation tool to create the RSA keys needed for operator identity: @@ -30,12 +32,13 @@ To register an operator, follow the instructions for the official **Step 3: Configure and run your Anchor node** -Create a directory for Anchor-related data and move the generated private key into the directory. +Create a directory for Anchor-related data and move the generated private key into the directory. Per default, Anchor +uses `~/.anchor/`, where `` is `hoodi` or `holesky`. We use `hoodi` below: ```bash -mkdir -p ~/.anchor +mkdir -p ~/.anchor/hoodi -mv encrypted_private_key.json ~/.anchor +mv encrypted_private_key.json ~/.anchor/hoodi ``` Use the [CLI Reference](./cli.md) or `--help` to launch the node. If you use an encrypted key, you must specify the password via a password file or interactively input it when starting the node. @@ -43,10 +46,13 @@ Use the [CLI Reference](./cli.md) or `--help` to launch the node. If you use an ```bash anchor node \ --network hoodi \ - --datadir ~/.anchor \ + --datadir ~/.anchor/hoodi \ --beacon-nodes http://localhost:5052 \ --execution-rpc http://localhost:8545 \ --execution-ws ws://localhost:8546 \ - --metrics \ --password-file /path/to/file ``` + +All options used in this example (except for the `password-file`) are actually used with the default values and can therefore be omitted, or adjusted to your setup. + +The Anchor node will use the same ports as used by Go-SSV unless explicitly overridden. See [Advanced Networking](./advanced_networking.md) for more information From dde5d1c93be7ab9d7641252be800f27865419c5e Mon Sep 17 00:00:00 2001 From: Daniel Knopik Date: Wed, 9 Jul 2025 15:20:21 +0200 Subject: [PATCH 4/8] Golang is a word --- .github/wordlist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/wordlist.txt b/.github/wordlist.txt index e6e262def..139f662f8 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -89,3 +89,4 @@ onchain cli ENR UPnP +Golang From 41df1b52d2d4398a6fbd90b020569718e29ca3b2 Mon Sep 17 00:00:00 2001 From: Daniel Knopik Date: Thu, 10 Jul 2025 14:56:26 +0200 Subject: [PATCH 5/8] Improved wording on help text Co-authored-by: Zacholme7 --- anchor/client/src/cli.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/anchor/client/src/cli.rs b/anchor/client/src/cli.rs index b2f52948e..a23c8fc54 100644 --- a/anchor/client/src/cli.rs +++ b/anchor/client/src/cli.rs @@ -259,8 +259,7 @@ pub struct Node { 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. If this flag is not set, the default values will be 12001 for discovery and 13001 for TCP, \ - matching go-ssv's default values.", + 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.", action = ArgAction::Set, )] pub port: Option, @@ -277,7 +276,7 @@ pub struct Node { #[clap( long, value_name = "PORT", - help = "The UDP port that discovery will listen on. Defaults to --port if explicitly specified, and `12001` otherwise.", + help = "The UDP port that discovery will listen on. Defaults to --port if --port is explicitly specified, and `12001` otherwise.", action = ArgAction::Set, )] pub discovery_port: Option, From 7d61c49da5e4bb6c0fd196d30945bf4fd91d7f50 Mon Sep 17 00:00:00 2001 From: Daniel Knopik Date: Thu, 10 Jul 2025 15:00:24 +0200 Subject: [PATCH 6/8] Add comment --- anchor/network/src/behaviour.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/anchor/network/src/behaviour.rs b/anchor/network/src/behaviour.rs index 92f0020c9..4e30794a6 100644 --- a/anchor/network/src/behaviour.rs +++ b/anchor/network/src/behaviour.rs @@ -78,6 +78,8 @@ impl AnchorBehaviour { .message_id_fn(gossip_message_id) .flood_publish(false) .validation_mode(ValidationMode::Permissive) + // Do not punish identical messages generated by us and other nodes. This can happen for + // `Decided` messages. .allow_self_origin(true) .mesh_n(8) // D .mesh_n_low(6) // Dlo From 8c23373730a5448488a8084245de111b427a2593 Mon Sep 17 00:00:00 2001 From: Daniel Knopik Date: Thu, 10 Jul 2025 15:16:54 +0200 Subject: [PATCH 7/8] Fixes Co-authored-by: diegomrsantos --- anchor/client/src/cli.rs | 2 +- book/src/cli.md | 2 +- book/src/running_node.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/anchor/client/src/cli.rs b/anchor/client/src/cli.rs index a23c8fc54..130d0b9dc 100644 --- a/anchor/client/src/cli.rs +++ b/anchor/client/src/cli.rs @@ -257,7 +257,7 @@ pub struct Node { long, value_name = "PORT", 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 \ + The discovery UDP and TCP port will be set to this value. 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. If this flag is not set, the default values will be 12001 for discovery and 13001 for TCP.", action = ArgAction::Set, diff --git a/book/src/cli.md b/book/src/cli.md index a7e82c864..2b30e05bc 100644 --- a/book/src/cli.md +++ b/book/src/cli.md @@ -73,7 +73,7 @@ anchor node [OPTIONS] | `--listen-address
` | Network address to listen for UDP & TCP connections | `0.0.0.0` | | `--port ` | Base port for all network connections | `13001` | | `--port6 ` | Base port for IPv6 network connections | Same as `--port` | -| `--discovery-port ` | UDP port for discovery | Same as ``--port` if specified, otherwise `12001` | +| `--discovery-port ` | UDP port for discovery | Same as `--port` if specified, otherwise `12001` | | `--discovery-port6 ` | UDP port for IPv6 discovery | Same as `--discovery-port` | | `--quic-port ` | UDP port for QUIC protocol | `--port` + 1 | | `--quic-port6 ` | UDP port for IPv6 QUIC protocol | `--port6` + 1 | diff --git a/book/src/running_node.md b/book/src/running_node.md index 15711f892..ae1ec488a 100644 --- a/book/src/running_node.md +++ b/book/src/running_node.md @@ -32,7 +32,7 @@ To register an operator, follow the instructions for the official **Step 3: Configure and run your Anchor node** -Create a directory for Anchor-related data and move the generated private key into the directory. Per default, Anchor +Create a directory for Anchor-related data and move the generated private key into the directory. By default, Anchor uses `~/.anchor/`, where `` is `hoodi` or `holesky`. We use `hoodi` below: ```bash From 9ccc6c819420ca44e090801c7bf13da8476f35ac Mon Sep 17 00:00:00 2001 From: Daniel Knopik Date: Thu, 10 Jul 2025 15:23:24 +0200 Subject: [PATCH 8/8] Apply better comment pattern Co-authored-by: diegomrsantos --- anchor/client/src/config.rs | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/anchor/client/src/config.rs b/anchor/client/src/config.rs index fbd4a4292..5cbbc60e7 100644 --- a/anchor/client/src/config.rs +++ b/anchor/client/src/config.rs @@ -359,7 +359,10 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result Result Result Result { // A single ipv4 address was provided. Set the ports - // use zero ports if required. If not, use the given port. + // Select the TCP port in the following order of precedence: + // 1. If use_zero_ports is set, use an unused TCP4 port. + // 2. Else, if port is specified, use it. + // 3. If none of the above are set, use the default TCP port (DEFAULT_TCP_PORT). let tcp_port = cli_args .use_zero_ports .then(unused_port::unused_tcp4_port) .transpose()? .or(cli_args.port) .unwrap_or(DEFAULT_TCP_PORT); - // use zero ports if required. If not, use the specific udp port. If none given, use - // the specified tcp port. If not given, use the default disc port. + // Select the discovery port in the following order of precedence: + // 1. If use_zero_ports is set, use an unused UDP4 port. + // 2. Else, if discovery_port is specified in CLI args, use it. + // 3. Else, if port is specified, use it as the fallback. + // 4. If none of the above are set, use the default discovery port (DEFAULT_DISC_PORT). let disc_port = cli_args .use_zero_ports .then(unused_port::unused_udp4_port) @@ -410,8 +426,10 @@ pub fn parse_listening_addresses(cli_args: &Node) -> Result