diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index 617170fa..41f820b0 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -13,6 +13,7 @@ use stability_runtime::{opaque::SessionKeys, EnableManualSeal, Signature}; pub mod alphanet; pub mod betanet; pub mod dev; +pub mod testnet; // The URL for the telemetry server. // const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; @@ -164,7 +165,7 @@ pub fn base_genesis( storage: { let mut storage = BTreeMap::new(); let initial_default_token_balance = H256::from_str("0x00000000000000000000000000000000000000000000d3c21bcecceda1000000").expect("invalid hex storage value"); // 10M - storage.insert(H256::from_str("0x0000000000000000000000000000000000000000000000000000000000000002").expect("invalid hex storage key"), initial_default_token_balance); + storage.insert(H256::from_str("0x0000000000000000000000000000000000000000000000000000000000000002").expect("invalid hex storage key"), initial_default_token_balance); // Total Supply storage.insert(H256::from_str("0x0000000000000000000000000000000000000000000000000000000000000003").expect("invalid hex storage key"), H256::from_str("0x53746162696c6974792047617320546f6b656e00000000000000000000000026").expect("invalid hex storage value")); // Name storage.insert(H256::from_str("0x0000000000000000000000000000000000000000000000000000000000000004").expect("invalid hex storage key"), H256::from_str("0x5347540000000000000000000000000000000000000000000000000000000006").expect("invalid hex storage value")); // Symbol storage.insert(H256::from_str("0x0000000000000000000000000000000000000000000000000000000000000005").expect("invalid hex storage key"), H256::from_str("0x000000000000000000000000af537bd156c7e548d0bf2cd43168dabf7af2feb5").expect("invalid hex storage value")); // Owner diff --git a/node/src/chain_spec/testnet.rs b/node/src/chain_spec/testnet.rs new file mode 100644 index 00000000..297b9deb --- /dev/null +++ b/node/src/chain_spec/testnet.rs @@ -0,0 +1,70 @@ +use super::{base_genesis, get_authority_from_pubkeys, ChainSpec}; +use sc_service::ChainType; +use sp_application_crypto::Ss58Codec; +use sp_core::ecdsa; +use sp_runtime::traits::{IdentifyAccount, Verify}; +use stability_runtime::{AccountId, Signature, WASM_BINARY}; +use std::vec; + +type AccountPublic = ::Signer; + +fn get_account_id_from_public(pubkey: &str) -> AccountId { + AccountPublic::from(ecdsa::Public::from_string(pubkey).unwrap()).into_account() +} + +pub fn testnet_config() -> Result { + let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + Ok(ChainSpec::from_genesis( + // Name + "Testnet", + // ID + "testnet", + ChainType::Live, + move || { + base_genesis( + wasm_binary, + vec![ + get_authority_from_pubkeys( + "KWECfQF69Vr61qop6NVpesYrnw5WRS4M816286K7NUuVAn2zd", + "5FviP577ihFCP4n8jCnrd38dQDCn2VeM5DAoYNEHbPy7JtWz", + ), + get_authority_from_pubkeys( + "KW5B2djwfWnVUPjZALW9NjKPkYc5wA1LSXmYD7HB2QeNoyBX1", + "5FqDv66PJL7TtC49CitcfGNokKJjbL3nwDRmYnQ66BJttUrw", + ), + get_authority_from_pubkeys( + "KWAefjXz8rjkX23DYt1tdjUoz9E8PPPQaA5SDULYc1mPpyg6i", + "5GUVATr2DwH51tnqaUEuBtuHA4bLnoWBAkauDxDafMukpZAZ", + ), + get_authority_from_pubkeys( + "KWBJnoEoDMniHfxEC2iMv5xLQNwVHV7GdZPCD31eiiLi4niHt", + "5FiEnbnj7VV5CWAtbJXtZjCkiQTBBRqyb8MgXEkydW1SfLiJ", + ), + get_authority_from_pubkeys( + "KW7fmVoR3DnYBEX8DwBfPZR2QBLf4uTQvXNm7zweVRWvXqJyt", + "5GzRrcmG4kztd31FPWEcr51B3Jd2GZPh6ZjpxwzymopHuViN", + ), + get_authority_from_pubkeys( + "KWBJUVzDvXYKakKX1wuHKqxxH5qg751fHwtaG15KYpuPReU9x", + "5FqhzMYnwsDx4uZYiGVXxJWqvtGwTgMEgYvziEkihE6tfov7", + ), + ], + vec![get_account_id_from_public( + "KWECfQF69Vr61qop6NVpesYrnw5WRS4M816286K7NUuVAn2zd", + )], + 20180427, + ) + }, + // Bootnodes + vec![], + // Telemetry + None, + // Protocol ID + None, + None, + // Properties + None, + // Extensions + None, + )) +} diff --git a/node/src/command.rs b/node/src/command.rs index e48bf3f5..0beda64c 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -57,6 +57,7 @@ impl SubstrateCli for Cli { Ok(match id { "alphanet" => Box::new(chain_spec::alphanet::alphanet_config()?), "betanet" => Box::new(chain_spec::betanet::betanet_config()?), + "testnet" => Box::new(chain_spec::testnet::testnet_config()?), "" | "local" | "dev" => { let enable_manual_seal = self.sealing.map(|_| true); Box::new(chain_spec::dev::development_config(enable_manual_seal))