Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
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
18 changes: 9 additions & 9 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ impl SubstrateCli for Cli {
.unwrap_or("polkadot")
} else { id };
Ok(match id {
"polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()),
"polkadot-local" => Box::new(service::chain_spec::polkadot_local_testnet_config()),
"polkadot-staging" => Box::new(service::chain_spec::polkadot_staging_testnet_config()),
"kusama-dev" => Box::new(service::chain_spec::kusama_development_config()),
"kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()),
"kusama-staging" => Box::new(service::chain_spec::kusama_staging_testnet_config()),
"polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()?),
"polkadot-local" => Box::new(service::chain_spec::polkadot_local_testnet_config()?),
"polkadot-staging" => Box::new(service::chain_spec::polkadot_staging_testnet_config()?),
"kusama-dev" => Box::new(service::chain_spec::kusama_development_config()?),
"kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()?),
"kusama-staging" => Box::new(service::chain_spec::kusama_staging_testnet_config()?),
"polkadot" => Box::new(service::chain_spec::polkadot_config()?),
"westend" => Box::new(service::chain_spec::westend_config()?),
"kusama" => Box::new(service::chain_spec::kusama_config()?),
"westend-dev" => Box::new(service::chain_spec::westend_development_config()),
"westend-local" => Box::new(service::chain_spec::westend_local_testnet_config()),
"westend-staging" => Box::new(service::chain_spec::westend_staging_testnet_config()),
"westend-dev" => Box::new(service::chain_spec::westend_development_config()?),
"westend-local" => Box::new(service::chain_spec::westend_local_testnet_config()?),
"westend-staging" => Box::new(service::chain_spec::westend_staging_testnet_config()?),
path if self.run.force_kusama => {
Box::new(service::KusamaChainSpec::from_json_file(std::path::PathBuf::from(path))?)
},
Expand Down
129 changes: 78 additions & 51 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn westend_session_keys(
westend::SessionKeys { babe, grandpa, im_online, parachain_validator, authority_discovery }
}

fn polkadot_staging_testnet_config_genesis() -> polkadot::GenesisConfig {
fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
// subkey inspect "$SECRET"
let endowed_accounts = vec![];

Expand All @@ -132,7 +132,7 @@ fn polkadot_staging_testnet_config_genesis() -> polkadot::GenesisConfig {

polkadot::GenesisConfig {
system: Some(polkadot::SystemConfig {
code: polkadot::WASM_BINARY.to_vec(),
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}),
balances: Some(polkadot::BalancesConfig {
Expand Down Expand Up @@ -197,7 +197,7 @@ fn polkadot_staging_testnet_config_genesis() -> polkadot::GenesisConfig {
}
}

fn westend_staging_testnet_config_genesis() -> westend::GenesisConfig {
fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
// subkey inspect "$SECRET"
let endowed_accounts = vec![
// 5ENpP27BrVdJTdUfY6djmcw3d3xEJ6NzSUU52CCPmGpMrdEY
Expand Down Expand Up @@ -284,7 +284,7 @@ fn westend_staging_testnet_config_genesis() -> westend::GenesisConfig {

westend::GenesisConfig {
system: Some(westend::SystemConfig {
code: westend::WASM_BINARY.to_vec(),
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}),
balances: Some(westend::BalancesConfig {
Expand Down Expand Up @@ -337,7 +337,7 @@ fn westend_staging_testnet_config_genesis() -> westend::GenesisConfig {
}
}

fn kusama_staging_testnet_config_genesis() -> kusama::GenesisConfig {
fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
// subkey inspect "$SECRET"
let endowed_accounts = vec![
// 5CVFESwfkk7NmhQ6FwHCM9roBvr9BGa4vJHFYU8DnGQxrXvz
Expand Down Expand Up @@ -424,7 +424,7 @@ fn kusama_staging_testnet_config_genesis() -> kusama::GenesisConfig {

kusama::GenesisConfig {
system: Some(kusama::SystemConfig {
code: kusama::WASM_BINARY.to_vec(),
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}),
balances: Some(kusama::BalancesConfig {
Expand Down Expand Up @@ -490,54 +490,60 @@ fn kusama_staging_testnet_config_genesis() -> kusama::GenesisConfig {
}

/// Polkadot staging testnet config.
pub fn polkadot_staging_testnet_config() -> PolkadotChainSpec {
pub fn polkadot_staging_testnet_config() -> Result<PolkadotChainSpec, String> {
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
let boot_nodes = vec![];
PolkadotChainSpec::from_genesis(

Ok(PolkadotChainSpec::from_genesis(
"Polkadot Staging Testnet",
"polkadot_staging_testnet",
ChainType::Live,
polkadot_staging_testnet_config_genesis,
move || polkadot_staging_testnet_config_genesis(wasm_binary),
boot_nodes,
Some(TelemetryEndpoints::new(vec![(POLKADOT_STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Polkadot Staging telemetry url is valid; qed")),
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
)
))
}

/// Staging testnet config.
pub fn kusama_staging_testnet_config() -> KusamaChainSpec {
pub fn kusama_staging_testnet_config() -> Result<KusamaChainSpec, String> {
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
let boot_nodes = vec![];
KusamaChainSpec::from_genesis(

Ok(KusamaChainSpec::from_genesis(
"Kusama Staging Testnet",
"kusama_staging_testnet",
ChainType::Live,
kusama_staging_testnet_config_genesis,
move || kusama_staging_testnet_config_genesis(wasm_binary),
boot_nodes,
Some(TelemetryEndpoints::new(vec![(KUSAMA_STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Kusama Staging telemetry url is valid; qed")),
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
)
))
}

/// Westend staging testnet config.
pub fn westend_staging_testnet_config() -> WestendChainSpec {
pub fn westend_staging_testnet_config() -> Result<WestendChainSpec, String> {
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
let boot_nodes = vec![];
WestendChainSpec::from_genesis(

Ok(WestendChainSpec::from_genesis(
"Westend Staging Testnet",
"westend_staging_testnet",
ChainType::Live,
westend_staging_testnet_config_genesis,
move || westend_staging_testnet_config_genesis(wasm_binary),
boot_nodes,
Some(TelemetryEndpoints::new(vec![(WESTEND_STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Westend Staging telemetry url is valid; qed")),
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
)
))
}

/// Helper function to generate a crypto pair from seed
Expand Down Expand Up @@ -595,6 +601,7 @@ fn testnet_accounts() -> Vec<AccountId> {

/// Helper function to create polkadot GenesisConfig for testing
pub fn polkadot_testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
_root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
Expand All @@ -606,7 +613,7 @@ pub fn polkadot_testnet_genesis(

polkadot::GenesisConfig {
system: Some(polkadot::SystemConfig {
code: polkadot::WASM_BINARY.to_vec(),
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}),
indices: Some(polkadot::IndicesConfig {
Expand Down Expand Up @@ -669,6 +676,7 @@ pub fn polkadot_testnet_genesis(

/// Helper function to create kusama GenesisConfig for testing
pub fn kusama_testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
_root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
Expand All @@ -680,7 +688,7 @@ pub fn kusama_testnet_genesis(

kusama::GenesisConfig {
system: Some(kusama::SystemConfig {
code: kusama::WASM_BINARY.to_vec(),
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}),
indices: Some(kusama::IndicesConfig {
Expand Down Expand Up @@ -743,6 +751,7 @@ pub fn kusama_testnet_genesis(

/// Helper function to create polkadot GenesisConfig for testing
pub fn westend_testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
Expand All @@ -754,7 +763,7 @@ pub fn westend_testnet_genesis(

westend::GenesisConfig {
system: Some(westend::SystemConfig {
code: westend::WASM_BINARY.to_vec(),
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}),
indices: Some(westend::IndicesConfig {
Expand Down Expand Up @@ -803,8 +812,9 @@ pub fn westend_testnet_genesis(
}
}

fn polkadot_development_config_genesis() -> polkadot::GenesisConfig {
fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
polkadot_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
],
Expand All @@ -813,8 +823,9 @@ fn polkadot_development_config_genesis() -> polkadot::GenesisConfig {
)
}

fn kusama_development_config_genesis() -> kusama::GenesisConfig {
fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
kusama_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
],
Expand All @@ -823,8 +834,9 @@ fn kusama_development_config_genesis() -> kusama::GenesisConfig {
)
}

fn westend_development_config_genesis() -> westend::GenesisConfig {
fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
westend_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
],
Expand All @@ -834,52 +846,59 @@ fn westend_development_config_genesis() -> westend::GenesisConfig {
}

/// Polkadot development config (single validator Alice)
pub fn polkadot_development_config() -> PolkadotChainSpec {
PolkadotChainSpec::from_genesis(
pub fn polkadot_development_config() -> Result<PolkadotChainSpec, String> {
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;

Ok(PolkadotChainSpec::from_genesis(
"Development",
"dev",
ChainType::Development,
polkadot_development_config_genesis,
move || polkadot_development_config_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
)
))
}

/// Kusama development config (single validator Alice)
pub fn kusama_development_config() -> KusamaChainSpec {
KusamaChainSpec::from_genesis(
pub fn kusama_development_config() -> Result<KusamaChainSpec, String> {
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;

Ok(KusamaChainSpec::from_genesis(
"Development",
"kusama_dev",
ChainType::Development,
kusama_development_config_genesis,
move || kusama_development_config_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
)
))
}

/// Westend development config (single validator Alice)
pub fn westend_development_config() -> WestendChainSpec {
WestendChainSpec::from_genesis(
pub fn westend_development_config() -> Result<WestendChainSpec, String> {
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;

Ok(WestendChainSpec::from_genesis(
"Development",
"westend_dev",
ChainType::Development,
westend_development_config_genesis,
move || westend_development_config_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
)
))
}

fn polkadot_local_testnet_genesis() -> polkadot::GenesisConfig {
fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
polkadot_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
Expand All @@ -890,22 +909,25 @@ fn polkadot_local_testnet_genesis() -> polkadot::GenesisConfig {
}

/// Polkadot local testnet config (multivalidator Alice + Bob)
pub fn polkadot_local_testnet_config() -> PolkadotChainSpec {
PolkadotChainSpec::from_genesis(
pub fn polkadot_local_testnet_config() -> Result<PolkadotChainSpec, String> {
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;

Ok(PolkadotChainSpec::from_genesis(
"Local Testnet",
"local_testnet",
ChainType::Local,
polkadot_local_testnet_genesis,
move || polkadot_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
)
))
}

fn kusama_local_testnet_genesis() -> kusama::GenesisConfig {
fn kusama_local_testnet_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
kusama_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
Expand All @@ -916,22 +938,25 @@ fn kusama_local_testnet_genesis() -> kusama::GenesisConfig {
}

/// Kusama local testnet config (multivalidator Alice + Bob)
pub fn kusama_local_testnet_config() -> KusamaChainSpec {
KusamaChainSpec::from_genesis(
pub fn kusama_local_testnet_config() -> Result<KusamaChainSpec, String> {
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;

Ok(KusamaChainSpec::from_genesis(
"Kusama Local Testnet",
"kusama_local_testnet",
ChainType::Local,
kusama_local_testnet_genesis,
move || kusama_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
)
))
}

fn westend_local_testnet_genesis() -> westend::GenesisConfig {
fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
westend_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
Expand All @@ -942,16 +967,18 @@ fn westend_local_testnet_genesis() -> westend::GenesisConfig {
}

/// Westend local testnet config (multivalidator Alice + Bob)
pub fn westend_local_testnet_config() -> WestendChainSpec {
WestendChainSpec::from_genesis(
pub fn westend_local_testnet_config() -> Result<WestendChainSpec, String> {
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;

Ok(WestendChainSpec::from_genesis(
"Westend Local Testnet",
"westend_local_testnet",
ChainType::Local,
westend_local_testnet_genesis,
move || westend_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
)
))
}
Loading