diff --git a/Cargo.lock b/Cargo.lock index 55e321038a..a6d417c451 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -954,7 +954,7 @@ dependencies = [ [[package]] name = "chain-spec-builder" -version = "8.3.0" +version = "8.4.0" dependencies = [ "async-std", "clap 3.2.23", @@ -3314,7 +3314,7 @@ dependencies = [ [[package]] name = "joystream-node" -version = "8.4.0" +version = "8.5.0" dependencies = [ "assert_cmd", "async-std", diff --git a/bin/node/Cargo.toml b/bin/node/Cargo.toml index 5cc0f1f457..403fa10f24 100644 --- a/bin/node/Cargo.toml +++ b/bin/node/Cargo.toml @@ -3,7 +3,7 @@ authors = ['Joystream contributors'] build = 'build.rs' edition = '2018' name = 'joystream-node' -version = '8.4.0' +version = '8.5.0' default-run = "joystream-node" [[bin]] diff --git a/bin/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml index 0f1be65060..1371ee8ede 100644 --- a/bin/utils/chain-spec-builder/Cargo.toml +++ b/bin/utils/chain-spec-builder/Cargo.toml @@ -3,7 +3,7 @@ authors = ['Joystream contributors'] build = 'build.rs' edition = '2018' name = 'chain-spec-builder' -version = '8.3.0' +version = '8.4.0' [dependencies] enum-utils = "0.1.2" diff --git a/bin/utils/chain-spec-builder/src/main.rs b/bin/utils/chain-spec-builder/src/main.rs index fd9220593a..c2bf429ce0 100644 --- a/bin/utils/chain-spec-builder/src/main.rs +++ b/bin/utils/chain-spec-builder/src/main.rs @@ -43,10 +43,16 @@ const TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; #[allow(non_camel_case_types)] #[derive(Debug, Clone, PartialEq, enum_utils::FromStr)] enum ChainDeployment { + /// Single node chain with testing genesis config. + /// Private IP and local network discovery enabled. dev, + /// Two nodes (on same machine) chain with testing genesis config. + /// Private IP and local network discovery enabled local, - staging, - live, + /// Two or more public nodes chain with testing genesis config. + testnet, + /// Two or more public nodes chain with production genesis config. + mainnet, } #[allow(clippy::from_over_into)] @@ -55,8 +61,8 @@ impl Into for ChainDeployment { match self { ChainDeployment::dev => ChainType::Development, ChainDeployment::local => ChainType::Local, - ChainDeployment::staging => ChainType::Live, - ChainDeployment::live => ChainType::Live, + ChainDeployment::testnet => ChainType::Live, + ChainDeployment::mainnet => ChainType::Live, } } } @@ -93,8 +99,8 @@ enum ChainSpecBuilder { /// The path to an initial balances file #[structopt(long)] initial_balances_path: Option, - /// Deployment type: dev, local, staging, live - #[structopt(long, short, default_value = "live")] + /// Deployment type: dev, local, testnet, mainnet + #[structopt(long, short, default_value = "mainnet")] deployment: String, /// Endow authorities, and nominators. Initial balances /// overrides endowed amount. @@ -128,8 +134,8 @@ enum ChainSpecBuilder { /// The path to an initial balances file #[clap(long)] initial_balances_path: Option, - /// Deployment type: dev, local, staging, live - #[clap(long, short, default_value = "live")] + /// Deployment type: dev, local, testnet, mainnet + #[clap(long, short, default_value = "mainnet")] deployment: String, }, } @@ -184,6 +190,23 @@ impl ChainSpecBuilder { ChainSpecBuilder::Generate { .. } => true, } } + + fn valid_number_of_authorities(&self) -> bool { + match self { + ChainSpecBuilder::New { authorities, .. } => match self.chain_deployment() { + ChainDeployment::dev => authorities.len().eq(&1), + ChainDeployment::local => authorities.len().eq(&2), + ChainDeployment::testnet => authorities.len().gt(&1), + ChainDeployment::mainnet => authorities.len().gt(&1), + }, + ChainSpecBuilder::Generate { authorities, .. } => match self.chain_deployment() { + ChainDeployment::dev => authorities.eq(&1), + ChainDeployment::local => authorities.eq(&2), + ChainDeployment::testnet => authorities.gt(&1), + ChainDeployment::mainnet => authorities.gt(&1), + }, + } + } } fn authorities_from_seeds( @@ -230,17 +253,17 @@ fn genesis_constructor( .unwrap_or_else(Vec::new); let content_cfg = match deployment { - ChainDeployment::live => content_config::production_config(), + ChainDeployment::mainnet => content_config::production_config(), _ => content_config::testing_config(), }; let storage_cfg = match deployment { - ChainDeployment::live => storage_config::production_config(), + ChainDeployment::mainnet => storage_config::production_config(), _ => storage_config::testing_config(), }; let project_token_cfg = match deployment { - ChainDeployment::live => project_token_config::production_config(), + ChainDeployment::mainnet => project_token_config::production_config(), _ => project_token_config::testing_config(), }; @@ -309,10 +332,13 @@ fn generate_chain_spec( .map(parse_account) .collect::, String>>()?; - let telemetry_endpoints = Some( - TelemetryEndpoints::new(vec![(TELEMETRY_URL.to_string(), 0)]) - .expect("Staging telemetry url is valid; qed"), - ); + let telemetry_endpoints = match deployment { + ChainDeployment::mainnet => Some( + TelemetryEndpoints::new(vec![(TELEMETRY_URL.to_string(), 0)]) + .expect("Telemetry url is invalid; qed"), + ), + _ => None, + }; let chain_spec = chain_spec::ChainSpec::from_genesis( "Joystream Testnet", @@ -413,6 +439,10 @@ async fn main() -> Result<(), String> { let initial_balances_path = builder.initial_balances_path().clone(); let deployment = builder.chain_deployment(); let fund_accounts = builder.fund_accounts(); + if !builder.valid_number_of_authorities() { + println!("Incorrect number of authorities for the deployment type chosen."); + std::process::exit(1); + } let (authorities, nominator_accounts, endowed_accounts) = match builder { ChainSpecBuilder::Generate {