Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Add wococo-local chain spec (#3509)
Browse files Browse the repository at this point in the history
  • Loading branch information
adoerr committed Jul 21, 2021
1 parent e9fee36 commit a1224d2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cli/src/command.rs
Expand Up @@ -111,6 +111,8 @@ impl SubstrateCli for Cli {
"wococo" => Box::new(service::chain_spec::wococo_config()?),
#[cfg(feature = "rococo-native")]
"wococo-dev" => Box::new(service::chain_spec::wococo_development_config()?),
#[cfg(feature = "rococo-native")]
"wococo-local" => Box::new(service::chain_spec::wococo_local_testnet_config()?),
#[cfg(not(feature = "rococo-native"))]
name if name.starts_with("wococo-") =>
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?,
Expand Down
36 changes: 36 additions & 0 deletions node/service/src/chain_spec.rs
Expand Up @@ -1805,3 +1805,39 @@ pub fn rococo_local_testnet_config() -> Result<RococoChainSpec, String> {
Default::default(),
))
}

/// Wococo is a temporary testnet that uses the same runtime as rococo.
#[cfg(feature = "rococo-native")]
fn wococo_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisConfig {
rococo_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}

/// Wococo local testnet config (multivalidator Alice + Bob)
#[cfg(feature = "rococo-native")]
pub fn wococo_local_testnet_config() -> Result<RococoChainSpec, String> {
let wasm_binary = rococo::WASM_BINARY.ok_or("Wococo development wasm not available")?;

Ok(RococoChainSpec::from_genesis(
"Wococo Local Testnet",
"wococo_local_testnet",
ChainType::Local,
move || RococoGenesisExt {
runtime_genesis_config: wococo_local_testnet_genesis(wasm_binary),
// Use 1 minute session length.
session_length_in_blocks: Some(10),
},
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
))
}

0 comments on commit a1224d2

Please sign in to comment.