Skip to content

Commit 64f1dee

Browse files
lexnvdharjeezy
authored andcommitted
cli/net_params: Warn on empty public-addr when starting a validator node (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]>
1 parent 15b63ab commit 64f1dee

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

prdoc/pr_5240.prdoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
title: Warn on empty public-addr when starting a validator node
2+
3+
doc:
4+
- audience: Node Operator
5+
description: |
6+
This PR shows a warning when the `--public-addr` CLI parameter is missing for validators.
7+
In the future, we'll transform this warning into a hard failure.
8+
Validators are encouraged to provide this parameter for better availability over the network.
9+
10+
crates:
11+
- name: sc-cli
12+
bump: patch

substrate/client/cli/src/config.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
172172
node_key: NodeKeyConfig,
173173
default_listen_port: u16,
174174
) -> Result<NetworkConfiguration> {
175-
Ok(if let Some(network_params) = self.network_params() {
175+
let network_config = if let Some(network_params) = self.network_params() {
176176
network_params.network_config(
177177
chain_spec,
178178
is_dev,
@@ -185,7 +185,13 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
185185
)
186186
} else {
187187
NetworkConfiguration::new(node_name, client_id, node_key, Some(net_config_dir))
188-
})
188+
};
189+
190+
// TODO: Return error here in the next release:
191+
// https://github.com/paritytech/polkadot-sdk/issues/5266
192+
// if is_validator && network_config.public_addresses.is_empty() {}
193+
194+
Ok(network_config)
189195
}
190196

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

639645
logger.init()?;
640646

647+
if config.role.is_authority() && config.network.public_addresses.is_empty() {
648+
warn!(
649+
"WARNING: No public address specified, validator node may not be reachable.
650+
Consider setting `--public-addr` to the public IP address of this node.
651+
This will become a hard requirement in future versions."
652+
);
653+
}
654+
641655
match fdlimit::raise_fd_limit() {
642656
Ok(fdlimit::Outcome::LimitRaised { to, .. }) =>
643657
if to < RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT {

0 commit comments

Comments
 (0)