Skip to content

Commit 7555688

Browse files
authored
Defaults for metrics_address during genesis (MystenLabs#9020)
## Description MystenLabs#8885 is breaking sui-operations deploys with the following error: ``` $ sui genesis --from-config /data/generate/target/genesis.yaml --working-dir generate/z -f validator_config_info[0].genesis_info: missing field `metrics_address` at line 23 column 21 ``` Rather than set `metrics_address` and `narwhal_metrics_address` on every validator's `genesis_info`, it should be reasonable to use a default. ## Test Plan Tested locally, `sui genesis` succeeds: ``` ./target/debug/sui genesis --from-config ../sui-operations/genesis.yaml --working-dir z -f [10:23:10] 2023-03-08T18:40:14.634219Z INFO sui_config::genesis_config: Creating accounts and gas objects... 2023-03-08T18:40:16.330088Z INFO sui::sui_commands: Network genesis completed. ``` ### Type of Change (Check all that apply) - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
1 parent d57bbc7 commit 7555688

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

crates/sui-config/src/genesis_config.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,27 @@ pub struct ValidatorGenesisInfo {
110110
pub network_address: Multiaddr,
111111
pub p2p_address: Multiaddr,
112112
pub p2p_listen_address: Option<SocketAddr>,
113+
#[serde(default = "default_socket_address")]
113114
pub metrics_address: SocketAddr,
115+
#[serde(default = "default_multiaddr_address")]
114116
pub narwhal_metrics_address: Multiaddr,
115117
pub gas_price: u64,
116118
pub commission_rate: u64,
117119
pub narwhal_primary_address: Multiaddr,
118120
pub narwhal_worker_address: Multiaddr,
119121
}
120122

123+
fn default_socket_address() -> SocketAddr {
124+
utils::available_local_socket_address()
125+
}
126+
127+
fn default_multiaddr_address() -> Multiaddr {
128+
let addr = utils::available_local_socket_address();
129+
format!("/ip4/{:?}/tcp/{}/http", addr.ip(), addr.port())
130+
.parse()
131+
.unwrap()
132+
}
133+
121134
impl ValidatorGenesisInfo {
122135
pub fn from_localhost_for_testing(
123136
key_pair: AuthorityKeyPair,

0 commit comments

Comments
 (0)