Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
2 changes: 1 addition & 1 deletion bin/utils/chain-spec-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
60 changes: 45 additions & 15 deletions bin/utils/chain-spec-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -55,8 +61,8 @@ impl Into<ChainType> 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,
}
}
}
Expand Down Expand Up @@ -93,8 +99,8 @@ enum ChainSpecBuilder {
/// The path to an initial balances file
#[structopt(long)]
initial_balances_path: Option<PathBuf>,
/// 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.
Expand Down Expand Up @@ -128,8 +134,8 @@ enum ChainSpecBuilder {
/// The path to an initial balances file
#[clap(long)]
initial_balances_path: Option<PathBuf>,
/// 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,
},
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(),
};

Expand Down Expand Up @@ -309,10 +332,13 @@ fn generate_chain_spec(
.map(parse_account)
.collect::<Result<Vec<_>, 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",
Expand Down Expand Up @@ -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 {
Expand Down