Skip to content

Commit

Permalink
cli/net_params: Warn on empty public-addr when starting a validator n…
Browse files Browse the repository at this point in the history
…ode (paritytech#5240)

This PR shows a warning when the `--public-addr` is not provided for
validators.

In the future, we'll transform this warning into a hard failure.
Validators are encouraged to provide this parameter for better
availability over the network.

cc @paritytech/networking

---------

Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv authored Aug 7, 2024
1 parent dd48544 commit 7a6e91c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
12 changes: 12 additions & 0 deletions prdoc/pr_5240.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
title: Warn on empty public-addr when starting a validator node

doc:
- audience: Node Operator
description: |
This PR shows a warning when the `--public-addr` CLI parameter is missing for validators.
In the future, we'll transform this warning into a hard failure.
Validators are encouraged to provide this parameter for better availability over the network.

crates:
- name: sc-cli
bump: patch
18 changes: 16 additions & 2 deletions substrate/client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
node_key: NodeKeyConfig,
default_listen_port: u16,
) -> Result<NetworkConfiguration> {
Ok(if let Some(network_params) = self.network_params() {
let network_config = if let Some(network_params) = self.network_params() {
network_params.network_config(
chain_spec,
is_dev,
Expand All @@ -185,7 +185,13 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
)
} else {
NetworkConfiguration::new(node_name, client_id, node_key, Some(net_config_dir))
})
};

// TODO: Return error here in the next release:
// https://github.com/paritytech/polkadot-sdk/issues/5266
// if is_validator && network_config.public_addresses.is_empty() {}

Ok(network_config)
}

/// Get the keystore configuration.
Expand Down Expand Up @@ -638,6 +644,14 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {

logger.init()?;

if config.role.is_authority() && config.network.public_addresses.is_empty() {
warn!(
"WARNING: No public address specified, validator node may not be reachable.
Consider setting `--public-addr` to the public IP address of this node.
This will become a hard requirement in future versions."
);
}

match fdlimit::raise_fd_limit() {
Ok(fdlimit::Outcome::LimitRaised { to, .. }) =>
if to < RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT {
Expand Down

0 comments on commit 7a6e91c

Please sign in to comment.