From d7d8bf82458d44a0e6d9cb89d06e4c1eb2c9a7dd Mon Sep 17 00:00:00 2001 From: Andrew Schran Date: Tue, 6 Dec 2022 16:59:16 -0800 Subject: [PATCH] Refactor node configs to remove local-only addresses from genesis This removes the notion of internal address from the narwhal side, instead configuring that externally. --- crates/sui-config/src/builder.rs | 117 +++-- crates/sui-config/src/genesis.rs | 38 +- crates/sui-config/src/genesis_config.rs | 18 +- crates/sui-config/src/node.rs | 66 ++- crates/sui-config/tests/snapshot_tests.rs | 8 +- ...ests__genesis_config_snapshot_matches.snap | 3 +- ...ests__network_config_snapshot_matches.snap | 36 +- ..._populated_genesis_snapshot_matches-4.snap | 448 +++++++++++++++++- ...s__populated_genesis_snapshot_matches.snap | 3 - crates/sui-core/src/authority_server.rs | 2 +- .../unit_tests/authority_aggregator_tests.rs | 2 - crates/sui-swarm/src/memory/swarm.rs | 4 +- crates/sui/src/genesis_ceremony.rs | 14 - crates/sui/src/sui_commands.rs | 2 +- doc/src/build/cli-client.md | 2 +- narwhal/config/src/lib.rs | 4 - .../snapshots/config_tests__worker_cache.snap | 48 +- narwhal/node/src/generate_format.rs | 3 - narwhal/node/tests/staged/narwhal.yaml | 3 - narwhal/primary/src/primary.rs | 18 +- narwhal/test-utils/src/lib.rs | 1 - 21 files changed, 630 insertions(+), 210 deletions(-) diff --git a/crates/sui-config/src/builder.rs b/crates/sui-config/src/builder.rs index ce669db7f468a..58629d191edea 100644 --- a/crates/sui-config/src/builder.rs +++ b/crates/sui-config/src/builder.rs @@ -3,12 +3,13 @@ use crate::{ genesis, - genesis_config::{GenesisConfig, ValidatorGenesisInfo}, + genesis_config::{GenesisConfig, ValidatorConfigInfo, ValidatorGenesisInfo}, p2p::P2pConfig, utils, ConsensusConfig, NetworkConfig, NodeConfig, ValidatorInfo, AUTHORITIES_DB_NAME, CONSENSUS_DB_NAME, }; use fastcrypto::encoding::{Encoding, Hex}; +use multiaddr::Multiaddr; use rand::rngs::OsRng; use std::{ num::NonZeroUsize, @@ -23,7 +24,7 @@ use sui_types::crypto::{ pub enum CommitteeConfig { Size(NonZeroUsize), - Validators(Vec), + Validators(Vec), } enum ValidatorIpSelection { @@ -82,7 +83,7 @@ impl ConfigBuilder { self } - pub fn with_validators(mut self, validators: Vec) -> Self { + pub fn with_validators(mut self, validators: Vec) -> Self { self.committee = Some(CommitteeConfig::Validators(validators)); self } @@ -155,14 +156,19 @@ impl ConfigBuilder { worker_key_pair: NetworkKeyPair, account_key_pair: SuiKeyPair, network_key_pair: NetworkKeyPair, - ) -> ValidatorGenesisInfo { + ) -> ValidatorConfigInfo { match self.validator_ip_sel { - ValidatorIpSelection::Localhost => ValidatorGenesisInfo::from_localhost_for_testing( - key_pair, - worker_key_pair, - account_key_pair, - network_key_pair, - ), + ValidatorIpSelection::Localhost => ValidatorConfigInfo { + genesis_info: ValidatorGenesisInfo::from_localhost_for_testing( + key_pair, + worker_key_pair, + account_key_pair, + network_key_pair, + ), + consensus_address: utils::new_tcp_network_address(), + consensus_internal_worker_address: None, + }, + ValidatorIpSelection::Simulator => { // we will probably never run this many validators in a sim let low_octet = index + 1; @@ -171,15 +177,22 @@ impl ConfigBuilder { } let ip = format!("10.10.0.{}", low_octet); + let make_tcp_addr = |port: u16| -> Multiaddr { + format!("/ip4/{}/tcp/{}/http", ip, port).parse().unwrap() + }; - ValidatorGenesisInfo::from_base_ip( - key_pair, - worker_key_pair, - account_key_pair, - network_key_pair, - ip, - index, - ) + ValidatorConfigInfo { + genesis_info: ValidatorGenesisInfo::from_base_ip( + key_pair, + worker_key_pair, + account_key_pair, + network_key_pair, + ip.clone(), + index, + ), + consensus_address: make_tcp_addr(4000 + index as u16), + consensus_internal_worker_address: None, + } } } } @@ -187,22 +200,25 @@ impl ConfigBuilder { fn build_with_validators( self, mut rng: R, - validators: Vec, + validators: Vec, ) -> NetworkConfig { let validator_set = validators .iter() .enumerate() .map(|(i, validator)| { let name = format!("validator-{i}"); - let protocol_key: AuthorityPublicKeyBytes = validator.key_pair.public().into(); - let account_key: PublicKey = validator.account_key_pair.public(); - let network_key: NetworkPublicKey = validator.network_key_pair.public().clone(); - let worker_key: NetworkPublicKey = validator.worker_key_pair.public().clone(); - let stake = validator.stake; - let network_address = validator.network_address.clone(); + let protocol_key: AuthorityPublicKeyBytes = + validator.genesis_info.key_pair.public().into(); + let account_key: PublicKey = validator.genesis_info.account_key_pair.public(); + let network_key: NetworkPublicKey = + validator.genesis_info.network_key_pair.public().clone(); + let worker_key: NetworkPublicKey = + validator.genesis_info.worker_key_pair.public().clone(); + let stake = validator.genesis_info.stake; + let network_address = validator.genesis_info.network_address.clone(); let pop = generate_proof_of_possession( - &validator.key_pair, - (&validator.account_key_pair.public()).into(), + &validator.genesis_info.key_pair, + (&validator.genesis_info.account_key_pair.public()).into(), ); ( @@ -214,16 +230,18 @@ impl ConfigBuilder { account_key, stake, delegation: 0, // no delegation yet at genesis - gas_price: validator.gas_price, - commission_rate: validator.commission_rate, + gas_price: validator.genesis_info.gas_price, + commission_rate: validator.genesis_info.commission_rate, network_address, - p2p_address: validator.p2p_address.clone(), - narwhal_primary_address: validator.narwhal_primary_address.clone(), - narwhal_worker_address: validator.narwhal_worker_address.clone(), - narwhal_internal_worker_address: validator - .narwhal_internal_worker_address + p2p_address: validator.genesis_info.p2p_address.clone(), + narwhal_primary_address: validator + .genesis_info + .narwhal_primary_address + .clone(), + narwhal_worker_address: validator + .genesis_info + .narwhal_worker_address .clone(), - narwhal_consensus_address: validator.narwhal_consensus_address.clone(), }, pop, ) @@ -250,36 +268,41 @@ impl ConfigBuilder { let validator_configs = validators .into_iter() .map(|validator| { - let public_key: AuthorityPublicKeyBytes = validator.key_pair.public().into(); + let public_key: AuthorityPublicKeyBytes = + validator.genesis_info.key_pair.public().into(); let db_path = self .config_directory .join(AUTHORITIES_DB_NAME) .join(Hex::encode(public_key)); - let network_address = validator.network_address; - let consensus_address = validator.narwhal_consensus_address; + let network_address = validator.genesis_info.network_address; + let consensus_address = validator.consensus_address; let consensus_db_path = self .config_directory .join(CONSENSUS_DB_NAME) .join(Hex::encode(public_key)); + let internal_worker_address = validator.consensus_internal_worker_address; let consensus_config = ConsensusConfig { - consensus_address, - consensus_db_path, + address: consensus_address, + db_path: consensus_db_path, + internal_worker_address, timeout_secs: Some(60), narwhal_config: Default::default(), }; let p2p_config = P2pConfig { - listen_address: utils::udp_multiaddr_to_listen_address(&validator.p2p_address) - .unwrap(), - external_address: Some(validator.p2p_address), + listen_address: utils::udp_multiaddr_to_listen_address( + &validator.genesis_info.p2p_address, + ) + .unwrap(), + external_address: Some(validator.genesis_info.p2p_address), ..Default::default() }; NodeConfig { - protocol_key_pair: Arc::new(validator.key_pair), - worker_key_pair: Arc::new(validator.worker_key_pair), - account_key_pair: Arc::new(validator.account_key_pair), - network_key_pair: Arc::new(validator.network_key_pair), + protocol_key_pair: Arc::new(validator.genesis_info.key_pair), + worker_key_pair: Arc::new(validator.genesis_info.worker_key_pair), + account_key_pair: Arc::new(validator.genesis_info.account_key_pair), + network_key_pair: Arc::new(validator.genesis_info.network_key_pair), db_path, network_address, metrics_address: utils::available_local_socket_address(), diff --git a/crates/sui-config/src/genesis.rs b/crates/sui-config/src/genesis.rs index d3aef237c6c0a..4c298e416e52e 100644 --- a/crates/sui-config/src/genesis.rs +++ b/crates/sui-config/src/genesis.rs @@ -10,7 +10,6 @@ use move_binary_format::CompiledModule; use move_core_types::ident_str; use move_core_types::language_storage::ModuleId; use move_vm_runtime::native_functions::NativeFunctionTable; -use narwhal_crypto::NetworkPublicKey; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_with::serde_as; use std::collections::BTreeMap; @@ -21,8 +20,7 @@ use sui_adapter::{adapter, execution_mode}; use sui_types::base_types::ObjectID; use sui_types::base_types::TransactionDigest; use sui_types::chain_id::ChainId; -use sui_types::crypto::{AuthorityPublicKey, ToFromBytes}; -use sui_types::crypto::{AuthorityPublicKeyBytes, AuthoritySignature}; +use sui_types::crypto::{AuthorityPublicKeyBytes, AuthoritySignature, ToFromBytes}; use sui_types::gas::SuiGasStatus; use sui_types::in_memory_storage::InMemoryStorage; use sui_types::messages::CallArg; @@ -101,38 +99,6 @@ impl Genesis { })) } - #[allow(clippy::mutable_key_type)] - pub fn narwhal_worker_cache(&self) -> narwhal_config::SharedWorkerCache { - let workers = self - .validator_set - .iter() - .map(|validator| { - let name = AuthorityPublicKey::from_bytes(validator.protocol_key().as_ref()) - .expect("Can't get protocol key"); - let workers = [( - 0, // worker_id - narwhal_config::WorkerInfo { - name: NetworkPublicKey::from_bytes(validator.worker_key().as_ref()) - .expect("Can't get worker key"), - transactions: validator.narwhal_consensus_address.clone(), - worker_address: validator.narwhal_worker_address.clone(), - internal_worker_address: validator.narwhal_internal_worker_address.clone(), - }, - )] - .into_iter() - .collect(); - let worker_index = narwhal_config::WorkerIndex(workers); - - (name, worker_index) - }) - .collect(); - narwhal_config::WorkerCache { - workers, - epoch: self.epoch() as narwhal_config::Epoch, - } - .into() - } - pub fn sui_system_object(&self) -> SuiSystemState { let sui_system_object = self .objects() @@ -689,8 +655,6 @@ mod test { p2p_address: utils::new_udp_network_address(), narwhal_primary_address: utils::new_udp_network_address(), narwhal_worker_address: utils::new_udp_network_address(), - narwhal_internal_worker_address: None, - narwhal_consensus_address: utils::new_tcp_network_address(), }; let pop = generate_proof_of_possession(&key, account_key.public().into()); let builder = Builder::new() diff --git a/crates/sui-config/src/genesis_config.rs b/crates/sui-config/src/genesis_config.rs index 228c30d092bd6..f13ea4bd396c7 100644 --- a/crates/sui-config/src/genesis_config.rs +++ b/crates/sui-config/src/genesis_config.rs @@ -22,9 +22,17 @@ use crate::node::DEFAULT_GRPC_CONCURRENCY_LIMIT; use crate::Config; use crate::{utils, DEFAULT_COMMISSION_RATE, DEFAULT_GAS_PRICE, DEFAULT_STAKE}; +// All information needed to build a NodeConfig for a validator. +#[derive(Serialize, Deserialize)] +pub struct ValidatorConfigInfo { + pub genesis_info: ValidatorGenesisInfo, + pub consensus_address: Multiaddr, + pub consensus_internal_worker_address: Option, +} + #[derive(Serialize, Deserialize)] pub struct GenesisConfig { - pub validator_genesis_info: Option>, + pub validator_config_info: Option>, pub parameters: GenesisChainParameters, pub committee_size: usize, pub grpc_load_shed: Option, @@ -108,8 +116,6 @@ pub struct ValidatorGenesisInfo { pub commission_rate: u64, pub narwhal_primary_address: Multiaddr, pub narwhal_worker_address: Multiaddr, - pub narwhal_internal_worker_address: Option, - pub narwhal_consensus_address: Multiaddr, } impl ValidatorGenesisInfo { @@ -131,8 +137,6 @@ impl ValidatorGenesisInfo { commission_rate: DEFAULT_COMMISSION_RATE, narwhal_primary_address: utils::new_udp_network_address(), narwhal_worker_address: utils::new_udp_network_address(), - narwhal_internal_worker_address: None, - narwhal_consensus_address: utils::new_tcp_network_address(), } } @@ -165,8 +169,6 @@ impl ValidatorGenesisInfo { commission_rate: DEFAULT_COMMISSION_RATE, narwhal_primary_address: make_udp_addr(2000 + port_offset), narwhal_worker_address: make_udp_addr(3000 + port_offset), - narwhal_internal_worker_address: None, - narwhal_consensus_address: make_tcp_addr(4000 + port_offset), } } } @@ -295,7 +297,7 @@ impl GenesisConfig { impl Default for GenesisConfig { fn default() -> Self { Self { - validator_genesis_info: None, + validator_config_info: None, parameters: Default::default(), committee_size: DEFAULT_NUMBER_OF_AUTHORITIES, grpc_load_shed: None, diff --git a/crates/sui-config/src/node.rs b/crates/sui-config/src/node.rs index a70dea3ebbe5a..1a58381322929 100644 --- a/crates/sui-config/src/node.rs +++ b/crates/sui-config/src/node.rs @@ -4,7 +4,9 @@ use crate::genesis; use crate::p2p::P2pConfig; use crate::Config; +use anyhow::anyhow; use anyhow::Result; +use fastcrypto::traits::ToFromBytes; use multiaddr::Multiaddr; use narwhal_config::Parameters as ConsensusParameters; use serde::{Deserialize, Serialize}; @@ -15,7 +17,6 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use sui_types::base_types::SuiAddress; use sui_types::committee::StakeUnit; -use sui_types::crypto::AccountKeyPair; use sui_types::crypto::AuthorityKeyPair; use sui_types::crypto::AuthorityPublicKeyBytes; use sui_types::crypto::KeypairTraits; @@ -23,6 +24,7 @@ use sui_types::crypto::NetworkKeyPair; use sui_types::crypto::NetworkPublicKey; use sui_types::crypto::PublicKey as AccountsPublicKey; use sui_types::crypto::SuiKeyPair; +use sui_types::crypto::{AccountKeyPair, AuthorityPublicKey}; use sui_types::sui_serde::KeyPairBase64; // Default max number of concurrent requests served @@ -163,13 +165,63 @@ impl NodeConfig { pub fn genesis(&self) -> Result<&genesis::Genesis> { self.genesis.genesis() } + + #[allow(clippy::mutable_key_type)] + pub fn narwhal_worker_cache(&self) -> Result { + let genesis = self.genesis()?; + let consensus_config = self + .consensus_config() + .ok_or_else(|| anyhow!("cannot generate worker cache without ConsensusConfig"))?; + let workers = genesis + .validator_set() + .iter() + .map(|validator| { + let name = AuthorityPublicKey::from_bytes(validator.protocol_key().as_ref()) + .expect("Can't get protocol key"); + let worker_address = if name != *self.protocol_key_pair().public() { + validator.narwhal_worker_address.clone() + } else { + // Use internal worker addresses for our own node if configured. + consensus_config + .internal_worker_address + .as_ref() + .unwrap_or(&validator.narwhal_worker_address) + .clone() + }; + let workers = [( + 0, // worker_id + narwhal_config::WorkerInfo { + name: NetworkPublicKey::from_bytes(validator.worker_key().as_ref()) + .expect("Can't get worker key"), + transactions: consensus_config.address.clone(), + worker_address, + }, + )] + .into_iter() + .collect(); + let worker_index = narwhal_config::WorkerIndex(workers); + + (name, worker_index) + }) + .collect(); + Ok(narwhal_config::WorkerCache { + workers, + epoch: genesis.epoch() as narwhal_config::Epoch, + } + .into()) + } } #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub struct ConsensusConfig { - pub consensus_address: Multiaddr, - pub consensus_db_path: PathBuf, + pub address: Multiaddr, + pub db_path: PathBuf, + + // Optional alternative address preferentially used by a primary to talk to its own worker. + // For example, this could be used to connect to co-located workers over a private LAN address. + pub internal_worker_address: Option, + // Timeout to retry sending transaction to consensus internally. // Default to 60s. pub timeout_secs: Option, @@ -179,11 +231,11 @@ pub struct ConsensusConfig { impl ConsensusConfig { pub fn address(&self) -> &Multiaddr { - &self.consensus_address + &self.address } pub fn db_path(&self) -> &Path { - &self.consensus_db_path + &self.db_path } pub fn narwhal_config(&self) -> &ConsensusParameters { @@ -209,11 +261,7 @@ pub struct ValidatorInfo { pub network_address: Multiaddr, pub p2p_address: Multiaddr, pub narwhal_primary_address: Multiaddr, - - //TODO remove all of these as they shouldn't be needed to be encoded in genesis pub narwhal_worker_address: Multiaddr, - pub narwhal_internal_worker_address: Option, - pub narwhal_consensus_address: Multiaddr, } impl ValidatorInfo { diff --git a/crates/sui-config/tests/snapshot_tests.rs b/crates/sui-config/tests/snapshot_tests.rs index 36167915c32d3..7716d52ec83de 100644 --- a/crates/sui-config/tests/snapshot_tests.rs +++ b/crates/sui-config/tests/snapshot_tests.rs @@ -81,8 +81,6 @@ fn populated_genesis_snapshot_matches() { p2p_address: Multiaddr::empty(), narwhal_primary_address: Multiaddr::empty(), narwhal_worker_address: Multiaddr::empty(), - narwhal_internal_worker_address: None, - narwhal_consensus_address: Multiaddr::empty(), }; let pop = generate_proof_of_possession(&key, account_key.public().into()); @@ -93,7 +91,6 @@ fn populated_genesis_snapshot_matches() { assert_yaml_snapshot!(genesis.validator_set()); assert_yaml_snapshot!(genesis.committee().unwrap()); assert_yaml_snapshot!(genesis.narwhal_committee()); - assert_yaml_snapshot!(genesis.narwhal_worker_cache()); assert_yaml_snapshot!(genesis.sui_system_object()); // Serialized `genesis` is not static and cannot be snapshot tested. } @@ -123,8 +120,9 @@ fn network_config_snapshot_matches() { let primary_network_admin_server_port = 5678; let worker_network_admin_server_base_port = 8765; if let Some(consensus_config) = validator_config.consensus_config.as_mut() { - consensus_config.consensus_address = Multiaddr::empty(); - consensus_config.consensus_db_path = PathBuf::from("/tmp/foo/"); + consensus_config.address = Multiaddr::empty(); + consensus_config.db_path = PathBuf::from("/tmp/foo/"); + consensus_config.internal_worker_address = Some(Multiaddr::empty()); consensus_config .narwhal_config .consensus_api_grpc diff --git a/crates/sui-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap b/crates/sui-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap index d997423b04bb8..7fae409e54959 100644 --- a/crates/sui-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap +++ b/crates/sui-config/tests/snapshots/snapshot_tests__genesis_config_snapshot_matches.snap @@ -2,7 +2,7 @@ source: crates/sui-config/tests/snapshot_tests.rs expression: genesis_config --- -validator_genesis_info: ~ +validator_config_info: ~ parameters: chain_id: 127 committee_size: 4 @@ -74,4 +74,3 @@ accounts: - object_id: "0x33d3e552666edc4f048c74e0d2776d0b18171e31" gas_value: 100000000000000 gas_object_ranges: [] - diff --git a/crates/sui-config/tests/snapshots/snapshot_tests__network_config_snapshot_matches.snap b/crates/sui-config/tests/snapshots/snapshot_tests__network_config_snapshot_matches.snap index 13486a555cb17..99a7cafbd5cff 100644 --- a/crates/sui-config/tests/snapshots/snapshot_tests__network_config_snapshot_matches.snap +++ b/crates/sui-config/tests/snapshots/snapshot_tests__network_config_snapshot_matches.snap @@ -13,8 +13,9 @@ validator_configs: metrics-address: "0.0.0.0:1" admin-interface-port: 8888 consensus-config: - consensus-address: "" - consensus-db-path: /tmp/foo/ + address: "" + db-path: /tmp/foo/ + internal-worker-address: "" timeout-secs: 60 narwhal-config: header_num_of_batches_threshold: 32 @@ -60,8 +61,9 @@ validator_configs: metrics-address: "0.0.0.0:1" admin-interface-port: 8888 consensus-config: - consensus-address: "" - consensus-db-path: /tmp/foo/ + address: "" + db-path: /tmp/foo/ + internal-worker-address: "" timeout-secs: 60 narwhal-config: header_num_of_batches_threshold: 32 @@ -107,8 +109,9 @@ validator_configs: metrics-address: "0.0.0.0:1" admin-interface-port: 8888 consensus-config: - consensus-address: "" - consensus-db-path: /tmp/foo/ + address: "" + db-path: /tmp/foo/ + internal-worker-address: "" timeout-secs: 60 narwhal-config: header_num_of_batches_threshold: 32 @@ -154,8 +157,9 @@ validator_configs: metrics-address: "0.0.0.0:1" admin-interface-port: 8888 consensus-config: - consensus-address: "" - consensus-db-path: /tmp/foo/ + address: "" + db-path: /tmp/foo/ + internal-worker-address: "" timeout-secs: 60 narwhal-config: header_num_of_batches_threshold: 32 @@ -201,8 +205,9 @@ validator_configs: metrics-address: "0.0.0.0:1" admin-interface-port: 8888 consensus-config: - consensus-address: "" - consensus-db-path: /tmp/foo/ + address: "" + db-path: /tmp/foo/ + internal-worker-address: "" timeout-secs: 60 narwhal-config: header_num_of_batches_threshold: 32 @@ -248,8 +253,9 @@ validator_configs: metrics-address: "0.0.0.0:1" admin-interface-port: 8888 consensus-config: - consensus-address: "" - consensus-db-path: /tmp/foo/ + address: "" + db-path: /tmp/foo/ + internal-worker-address: "" timeout-secs: 60 narwhal-config: header_num_of_batches_threshold: 32 @@ -295,8 +301,9 @@ validator_configs: metrics-address: "0.0.0.0:1" admin-interface-port: 8888 consensus-config: - consensus-address: "" - consensus-db-path: /tmp/foo/ + address: "" + db-path: /tmp/foo/ + internal-worker-address: "" timeout-secs: 60 narwhal-config: header_num_of_batches_threshold: 32 @@ -339,4 +346,3 @@ account_keys: - cHifntmjxd4QLaC71WRMoOeCpvicyDJMbTKRuo2v3R9UjI8DXP6RwO6c5B70OPjZEdiV0XB+RVfcjX6/JKfZeg== - mTzV/JVz4RdheOnQVFF3xuCPFF4AYAPyShHQCUizJX9pHbCeXB5wKAz9LCwtuoC4PCML0v4vko2/c16HlmPrbQ== genesis: "[fake genesis]" - diff --git a/crates/sui-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-4.snap b/crates/sui-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-4.snap index 3941a7be5c4c4..07d424aa60927 100644 --- a/crates/sui-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-4.snap +++ b/crates/sui-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-4.snap @@ -1,12 +1,444 @@ --- source: crates/sui-config/tests/snapshot_tests.rs -expression: genesis.narwhal_worker_cache() +expression: genesis.sui_system_object() --- -workers: - mfJe9h+AMrkUY2RgmCxcxvE07x3a52ZX8sv+wev8jQlzdAgN9vzw3Li8Sw2OCvXYDrv/K0xZn1T0LWMS38MUJ2B4wcw0fru+xRmL4lhRPzhrkw0CwnSagD4jMJVevRoQ: - 0: - name: DX2rNYyNrapO+gBJp1sHQ2VVsQo2ghm7aA9wVxNJ13U= - transactions: "" - worker_address: "" - internal_worker_address: ~ +info: + id: "0x0000000000000000000000000000000000000005" +chain_id: 127 epoch: 0 +validators: + validator_stake: 1 + delegation_stake: 0 + quorum_stake_threshold: 1 + active_validators: + - metadata: + sui_address: "0x21b60aa9a8cb189ccbe20461dbfad2202fdef55b" + pubkey_bytes: + - 153 + - 242 + - 94 + - 246 + - 31 + - 128 + - 50 + - 185 + - 20 + - 99 + - 100 + - 96 + - 152 + - 44 + - 92 + - 198 + - 241 + - 52 + - 239 + - 29 + - 218 + - 231 + - 102 + - 87 + - 242 + - 203 + - 254 + - 193 + - 235 + - 252 + - 141 + - 9 + - 115 + - 116 + - 8 + - 13 + - 246 + - 252 + - 240 + - 220 + - 184 + - 188 + - 75 + - 13 + - 142 + - 10 + - 245 + - 216 + - 14 + - 187 + - 255 + - 43 + - 76 + - 89 + - 159 + - 84 + - 244 + - 45 + - 99 + - 18 + - 223 + - 195 + - 20 + - 39 + - 96 + - 120 + - 193 + - 204 + - 52 + - 126 + - 187 + - 190 + - 197 + - 25 + - 139 + - 226 + - 88 + - 81 + - 63 + - 56 + - 107 + - 147 + - 13 + - 2 + - 194 + - 116 + - 154 + - 128 + - 62 + - 35 + - 48 + - 149 + - 94 + - 189 + - 26 + - 16 + network_pubkey_bytes: + - 68 + - 88 + - 50 + - 114 + - 78 + - 89 + - 121 + - 78 + - 114 + - 97 + - 112 + - 79 + - 43 + - 103 + - 66 + - 74 + - 112 + - 49 + - 115 + - 72 + - 81 + - 50 + - 86 + - 86 + - 115 + - 81 + - 111 + - 50 + - 103 + - 104 + - 109 + - 55 + - 97 + - 65 + - 57 + - 119 + - 86 + - 120 + - 78 + - 74 + - 49 + - 51 + - 85 + - 61 + proof_of_possession_bytes: + - 153 + - 27 + - 35 + - 60 + - 191 + - 127 + - 114 + - 42 + - 232 + - 130 + - 78 + - 8 + - 171 + - 176 + - 156 + - 1 + - 218 + - 41 + - 15 + - 12 + - 200 + - 251 + - 161 + - 118 + - 204 + - 12 + - 207 + - 20 + - 169 + - 155 + - 183 + - 78 + - 162 + - 200 + - 239 + - 217 + - 147 + - 103 + - 123 + - 109 + - 224 + - 32 + - 216 + - 58 + - 188 + - 101 + - 131 + - 137 + name: + - 48 + net_address: [] + next_epoch_stake: 1 + next_epoch_delegation: 0 + next_epoch_gas_price: 1 + next_epoch_commission_rate: 0 + stake_amount: 1 + pending_stake: 0 + pending_withdraw: 0 + gas_price: 1 + delegation_staking_pool: + validator_address: "0x21b60aa9a8cb189ccbe20461dbfad2202fdef55b" + starting_epoch: 1 + sui_balance: 0 + rewards_pool: + value: 0 + delegation_token_supply: + value: 0 + pending_delegations: [] + pending_withdraws: [] + commission_rate: 0 + pending_validators: [] + pending_removals: [] + next_epoch_validators: + - sui_address: "0x21b60aa9a8cb189ccbe20461dbfad2202fdef55b" + pubkey_bytes: + - 153 + - 242 + - 94 + - 246 + - 31 + - 128 + - 50 + - 185 + - 20 + - 99 + - 100 + - 96 + - 152 + - 44 + - 92 + - 198 + - 241 + - 52 + - 239 + - 29 + - 218 + - 231 + - 102 + - 87 + - 242 + - 203 + - 254 + - 193 + - 235 + - 252 + - 141 + - 9 + - 115 + - 116 + - 8 + - 13 + - 246 + - 252 + - 240 + - 220 + - 184 + - 188 + - 75 + - 13 + - 142 + - 10 + - 245 + - 216 + - 14 + - 187 + - 255 + - 43 + - 76 + - 89 + - 159 + - 84 + - 244 + - 45 + - 99 + - 18 + - 223 + - 195 + - 20 + - 39 + - 96 + - 120 + - 193 + - 204 + - 52 + - 126 + - 187 + - 190 + - 197 + - 25 + - 139 + - 226 + - 88 + - 81 + - 63 + - 56 + - 107 + - 147 + - 13 + - 2 + - 194 + - 116 + - 154 + - 128 + - 62 + - 35 + - 48 + - 149 + - 94 + - 189 + - 26 + - 16 + network_pubkey_bytes: + - 68 + - 88 + - 50 + - 114 + - 78 + - 89 + - 121 + - 78 + - 114 + - 97 + - 112 + - 79 + - 43 + - 103 + - 66 + - 74 + - 112 + - 49 + - 115 + - 72 + - 81 + - 50 + - 86 + - 86 + - 115 + - 81 + - 111 + - 50 + - 103 + - 104 + - 109 + - 55 + - 97 + - 65 + - 57 + - 119 + - 86 + - 120 + - 78 + - 74 + - 49 + - 51 + - 85 + - 61 + proof_of_possession_bytes: + - 153 + - 27 + - 35 + - 60 + - 191 + - 127 + - 114 + - 42 + - 232 + - 130 + - 78 + - 8 + - 171 + - 176 + - 156 + - 1 + - 218 + - 41 + - 15 + - 12 + - 200 + - 251 + - 161 + - 118 + - 204 + - 12 + - 207 + - 20 + - 169 + - 155 + - 183 + - 78 + - 162 + - 200 + - 239 + - 217 + - 147 + - 103 + - 123 + - 109 + - 224 + - 32 + - 216 + - 58 + - 188 + - 101 + - 131 + - 137 + name: + - 48 + net_address: [] + next_epoch_stake: 1 + next_epoch_delegation: 0 + next_epoch_gas_price: 1 + next_epoch_commission_rate: 0 + pending_delegation_switches: + contents: [] +treasury_cap: + value: 100000000000001 +storage_fund: + value: 100000000000000 +parameters: + min_validator_stake: 100000000000000 + max_validator_candidate_count: 100 + storage_gas_price: 1 +reference_gas_price: 0 +validator_report_records: + contents: [] + diff --git a/crates/sui-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches.snap b/crates/sui-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches.snap index acfa751a9f193..83c24bda52453 100644 --- a/crates/sui-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches.snap +++ b/crates/sui-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches.snap @@ -15,6 +15,3 @@ expression: genesis.validator_set() p2p-address: "" narwhal-primary-address: "" narwhal-worker-address: "" - narwhal-internal-worker-address: ~ - narwhal-consensus-address: "" - diff --git a/crates/sui-core/src/authority_server.rs b/crates/sui-core/src/authority_server.rs index 74ff60b8c2c97..fb779627a4cff 100644 --- a/crates/sui-core/src/authority_server.rs +++ b/crates/sui-core/src/authority_server.rs @@ -299,7 +299,7 @@ impl ValidatorService { let consensus_keypair = config.protocol_key_pair().copy(); let consensus_worker_keypair = config.worker_key_pair().copy(); let consensus_committee = config.genesis()?.narwhal_committee().load(); - let consensus_worker_cache = config.genesis()?.narwhal_worker_cache(); + let consensus_worker_cache = config.narwhal_worker_cache()?; let consensus_storage_base_path = consensus_config.db_path().to_path_buf(); let consensus_execution_state = ConsensusHandler::new(state.clone(), checkpoint_service); let consensus_execution_state = Arc::new(consensus_execution_state); diff --git a/crates/sui-core/src/unit_tests/authority_aggregator_tests.rs b/crates/sui-core/src/unit_tests/authority_aggregator_tests.rs index 48085c149ed5b..59ebf0817d2fe 100644 --- a/crates/sui-core/src/unit_tests/authority_aggregator_tests.rs +++ b/crates/sui-core/src/unit_tests/authority_aggregator_tests.rs @@ -114,8 +114,6 @@ pub async fn init_local_authorities( p2p_address: sui_config::utils::new_udp_network_address(), narwhal_primary_address: sui_config::utils::new_udp_network_address(), narwhal_worker_address: sui_config::utils::new_udp_network_address(), - narwhal_internal_worker_address: None, - narwhal_consensus_address: sui_config::utils::new_tcp_network_address(), }; let pop = generate_proof_of_possession(&key_pair, (&account_key_pair.public()).into()); builder = builder.add_validator(validator_info, pop); diff --git a/crates/sui-swarm/src/memory/swarm.rs b/crates/sui-swarm/src/memory/swarm.rs index a44a285b7eef2..26064322ff542 100644 --- a/crates/sui-swarm/src/memory/swarm.rs +++ b/crates/sui-swarm/src/memory/swarm.rs @@ -13,7 +13,7 @@ use std::{ path::{Path, PathBuf}, }; use sui_config::builder::{CommitteeConfig, ConfigBuilder}; -use sui_config::genesis_config::{GenesisConfig, ValidatorGenesisInfo}; +use sui_config::genesis_config::{GenesisConfig, ValidatorConfigInfo}; use sui_config::NetworkConfig; use sui_types::base_types::SuiAddress; use tempfile::TempDir; @@ -72,7 +72,7 @@ impl SwarmBuilder { self } - pub fn with_validators(mut self, validators: Vec) -> Self { + pub fn with_validators(mut self, validators: Vec) -> Self { self.committee = CommitteeConfig::Validators(validators); self } diff --git a/crates/sui/src/genesis_ceremony.rs b/crates/sui/src/genesis_ceremony.rs index a595e927d8651..1f0b3d6816b26 100644 --- a/crates/sui/src/genesis_ceremony.rs +++ b/crates/sui/src/genesis_ceremony.rs @@ -66,10 +66,6 @@ pub enum CeremonyCommand { narwhal_primary_address: Multiaddr, #[clap(long)] narwhal_worker_address: Multiaddr, - #[clap(long)] - narwhal_internal_worker_address: Option, - #[clap(long)] - narwhal_consensus_address: Multiaddr, }, AddGasObject { @@ -115,8 +111,6 @@ pub fn run(cmd: Ceremony) -> Result<()> { p2p_address, narwhal_primary_address, narwhal_worker_address, - narwhal_internal_worker_address, - narwhal_consensus_address, } => { let mut builder = Builder::load(&dir)?; let keypair: AuthorityKeyPair = read_authority_keypair_from_file(validator_key_file)?; @@ -139,8 +133,6 @@ pub fn run(cmd: Ceremony) -> Result<()> { p2p_address, narwhal_primary_address, narwhal_worker_address, - narwhal_internal_worker_address, - narwhal_consensus_address, }, pop, ); @@ -309,8 +301,6 @@ mod test { p2p_address: utils::new_udp_network_address(), narwhal_primary_address: utils::new_udp_network_address(), narwhal_worker_address: utils::new_udp_network_address(), - narwhal_internal_worker_address: None, - narwhal_consensus_address: utils::new_tcp_network_address(), }; let key_file = dir.path().join(format!("{}-0.key", info.name)); write_authority_keypair_to_file(&keypair, &key_file).unwrap(); @@ -369,10 +359,6 @@ mod test { p2p_address: validator.p2p_address().to_owned(), narwhal_primary_address: validator.narwhal_primary_address.clone(), narwhal_worker_address: validator.narwhal_worker_address.clone(), - narwhal_internal_worker_address: validator - .narwhal_internal_worker_address - .clone(), - narwhal_consensus_address: validator.narwhal_consensus_address.clone(), }, }; command.run()?; diff --git a/crates/sui/src/sui_commands.rs b/crates/sui/src/sui_commands.rs index a198d14d8e884..7160b7a5400c6 100644 --- a/crates/sui/src/sui_commands.rs +++ b/crates/sui/src/sui_commands.rs @@ -309,7 +309,7 @@ async fn genesis( return Ok(()); } - let validator_info = genesis_conf.validator_genesis_info.take(); + let validator_info = genesis_conf.validator_config_info.take(); let mut network_config = if let Some(validators) = validator_info { ConfigBuilder::new(sui_config_dir) .initial_accounts_config(genesis_conf) diff --git a/doc/src/build/cli-client.md b/doc/src/build/cli-client.md index 03b9513045bc4..d8985012b8396 100644 --- a/doc/src/build/cli-client.md +++ b/doc/src/build/cli-client.md @@ -618,7 +618,7 @@ Example `genesis.yaml`: ```yaml --- -validator_genesis_info: ~ +validator_config_info: ~ committee_size: 4 accounts: - gas_objects: diff --git a/narwhal/config/src/lib.rs b/narwhal/config/src/lib.rs index 3c138b7c69f1f..d8ccdde1ddf93 100644 --- a/narwhal/config/src/lib.rs +++ b/narwhal/config/src/lib.rs @@ -407,10 +407,6 @@ pub struct WorkerInfo { pub transactions: Multiaddr, /// Address to receive messages from other workers (WAN) and our primary. pub worker_address: Multiaddr, - /// Optional alternative address preferentially used by a primary to talk to its own workers. - /// For example, this could be used to connect to co-located workers over a private LAN - /// address. - pub internal_worker_address: Option, } pub type SharedWorkerCache = Arc>; diff --git a/narwhal/config/tests/snapshots/config_tests__worker_cache.snap b/narwhal/config/tests/snapshots/config_tests__worker_cache.snap index 2c137b8e46cd2..e25144f940482 100644 --- a/narwhal/config/tests/snapshots/config_tests__worker_cache.snap +++ b/narwhal/config/tests/snapshots/config_tests__worker_cache.snap @@ -8,104 +8,88 @@ expression: worker_cache "0": { "name": "+vUstEd3Zwmk1MRBNU6KMe93it1bV/ouTWPUDuDQHOQ=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "1": { "name": "tA1h9P/tjZVdIaW52V7TMpsYevOffi+wZ52uzvqizy8=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "2": { "name": "a+K1bOynGp8UECGdYL1AKu+VboCKFzkuas1YrJv9USs=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "3": { "name": "4kBB/sEnfuQrFVX4wKIWDruoWE0FdGQoAAxV3dH5Ruw=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" } }, "mfJe9h+AMrkUY2RgmCxcxvE07x3a52ZX8sv+wev8jQlzdAgN9vzw3Li8Sw2OCvXYDrv/K0xZn1T0LWMS38MUJ2B4wcw0fru+xRmL4lhRPzhrkw0CwnSagD4jMJVevRoQ": { "0": { "name": "Rl8pi3pQBvFS3qQ4Ge8XfGIWJ89Ig6gaG+hs27ITsoY=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "1": { "name": "LEP9AK0+iW5NcUyhZbcmNIb5RYHgH69slDisEtztjG0=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "2": { "name": "7e+czQHszqp2FRfx2nfFWAO0P62dYPZStGZrvhXxsrk=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "3": { "name": "E9/Bo/26Ipc5+PcH6FrVcSX/vQpmNQOdnsvrQHha22g=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" } }, "ofT8sYBvqkB+c/sjDYTwar96xgZbTdi/ncbet8ja9ePYhtSje59zyarNpF/ZxM1dAncK6uyr9Xv1lS7bJs+nSj2k0bMvbStf5RORLeuPwYz/yJrDOQQf4MxOnW0u8Gzo": { "0": { "name": "XfUKCTzkq/woZ4O5HhvOQYx2Mjmj53+b2Zvf47bUNAs=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "1": { "name": "ImcEJdnkJHGWWGfpkBU8v79yfxiBRd5dSk2fmgVot38=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "2": { "name": "wtCRbRtWxzwz1mf3mzcJZYlJSzmWIQriK6XTW558nX8=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "3": { "name": "6AXMr5ld8Tk2FSAG7nzpRNnxB9i/A2jvMHEo45HL1fU=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" } }, "q1ys+9ZU8B5aHgYbgyC5N0XQlGdq1B7xY9D8JOyT89upZpiuKRUDBsq3h/WbLtd4AvLNFNECBjlAG06r8heq7tEs6ol97VfaS2579e4b337eJAwd/y1bIt4F+LhEc3sV": { "0": { "name": "ZHHGcv0FFVsZHJGRHt9GyGNjuEVHfPRQtzzvr0muwdw=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "1": { "name": "8mDA/X8DSIDB1xgO2aWggBs6c1CHpwO/8yOObxDvDVg=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "2": { "name": "qk4EPcTqK1qa8nSDxvWLOc4eNK08K8jStJYuu4r19/I=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" }, "3": { "name": "8g85A29s6Un8b8sRwTLdQ626jFtHpDJOwtWEVy2t7MA=", "transactions": "/ip4/127.0.0.1/tcp/0/http", - "worker_address": "/ip4/127.0.0.1/udp/0", - "internal_worker_address": null + "worker_address": "/ip4/127.0.0.1/udp/0" } } }, diff --git a/narwhal/node/src/generate_format.rs b/narwhal/node/src/generate_format.rs index 3b1c3bd341855..4c991dabad83c 100644 --- a/narwhal/node/src/generate_format.rs +++ b/narwhal/node/src/generate_format.rs @@ -99,9 +99,6 @@ fn get_registry() -> Result { WorkerInfo { name: worker_pk, worker_address: "/ip4/127.0.0.1/udp/500".to_string().parse().unwrap(), - internal_worker_address: Some( - "/ip4/127.0.0.1/udp/500".to_string().parse().unwrap(), - ), transactions: "/ip4/127.0.0.1/tcp/400/http".to_string().parse().unwrap(), }, )] diff --git a/narwhal/node/tests/staged/narwhal.yaml b/narwhal/node/tests/staged/narwhal.yaml index 4302711491af9..6bf4a7e1d9c4e 100644 --- a/narwhal/node/tests/staged/narwhal.yaml +++ b/narwhal/node/tests/staged/narwhal.yaml @@ -88,8 +88,6 @@ WorkerInfo: - name: STR - transactions: BYTES - worker_address: BYTES - - internal_worker_address: - OPTION: BYTES WorkerOthersBatchMessage: STRUCT: - digest: @@ -112,4 +110,3 @@ WorkerSynchronizeMessage: SEQ: TYPENAME: BatchDigest - target: STR - diff --git a/narwhal/primary/src/primary.rs b/narwhal/primary/src/primary.rs index db250a6d37339..6e18179039dca 100644 --- a/narwhal/primary/src/primary.rs +++ b/narwhal/primary/src/primary.rs @@ -69,7 +69,7 @@ pub mod primary_tests; /// The default channel capacity for each channel of the primary. pub const CHANNEL_CAPACITY: usize = 1_000; -/// Maximum duration to fetch certficates from local storage. +/// Maximum duration to fetch certificates from local storage. const FETCH_CERTIFICATES_MAX_HANDLER_TIME: Duration = Duration::from_secs(10); /// The network model in which the primary operates. @@ -165,7 +165,7 @@ impl Primary { &primary_channel_metrics.tx_state_handler, &primary_channel_metrics.tx_state_handler_total, ); - let (tx_commited_own_headers, rx_commited_own_headers) = channel_with_total( + let (tx_committed_own_headers, rx_committed_own_headers) = channel_with_total( CHANNEL_CAPACITY, &primary_channel_metrics.tx_commited_own_headers, &primary_channel_metrics.tx_commited_own_headers_total, @@ -305,14 +305,8 @@ impl Primary { // Add my workers for worker in worker_cache.load().our_workers(&name).unwrap() { - let (peer_id, address) = Self::add_peer_in_network( - &network, - worker.name, - worker - .internal_worker_address - .as_ref() - .unwrap_or(&worker.worker_address), - ); + let (peer_id, address) = + Self::add_peer_in_network(&network, worker.name, &worker.worker_address); peer_types.insert(peer_id, "our_worker".to_string()); info!( "Adding our worker with peer id {} and address {}", @@ -455,7 +449,7 @@ impl Primary { rx_our_digests, tx_headers, tx_narwhal_round_updates, - rx_commited_own_headers, + rx_committed_own_headers, node_metrics, ); @@ -467,7 +461,7 @@ impl Primary { rx_committed_certificates, rx_state_handler, tx_reconfigure, - Some(tx_commited_own_headers), + Some(tx_committed_own_headers), network.clone(), ); diff --git a/narwhal/test-utils/src/lib.rs b/narwhal/test-utils/src/lib.rs index 40e2cf3434177..ec617a266d43a 100644 --- a/narwhal/test-utils/src/lib.rs +++ b/narwhal/test-utils/src/lib.rs @@ -946,7 +946,6 @@ impl WorkerFixture { info: WorkerInfo { name: worker_name, worker_address, - internal_worker_address: None, transactions, }, }