123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- use primitives::{Ed25519AuthorityId, ed25519};
- use joystream_node_runtime::{
- AccountId, GenesisConfig, ConsensusConfig, TimestampConfig, BalancesConfig,
- SudoConfig, IndicesConfig
- };
- use substrate_service;
- // Note this is the URL for the telemetry server
- //const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
- /// Specialised `ChainSpec`. This is a specialisation of the general Substrate ChainSpec type.
- pub type ChainSpec = substrate_service::ChainSpec<GenesisConfig>;
- /// The chain specification option. This is expected to come in from the CLI and
- /// is little more than one of a number of alternatives which can easily be converted
- /// from a string (`--chain=...`) into a `ChainSpec`.
- #[derive(Clone, Debug)]
- pub enum Alternative {
- /// Whatever the current runtime is, with just Alice as an auth.
- Development,
- /// Whatever the current runtime is, with simple Alice/Bob auths.
- LocalTestnet,
- }
- impl Alternative {
- /// Get an actual chain config from one of the alternatives.
- pub(crate) fn load(self) -> Result<ChainSpec, String> {
- Ok(match self {
- Alternative::Development => ChainSpec::from_genesis(
- "Development",
- "dev",
- || testnet_genesis(vec![
- ed25519::Pair::from_seed(b"Alice ").public().into(),
- ], vec![
- ed25519::Pair::from_seed(b"Alice ").public().0.into(),
- ],
- ed25519::Pair::from_seed(b"Alice ").public().0.into()
- ),
- vec![],
- None,
- None,
- None,
- None
- ),
- Alternative::LocalTestnet => ChainSpec::from_genesis(
- "Local Testnet",
- "local_testnet",
- || testnet_genesis(vec![
- ed25519::Pair::from_seed(b"Alice ").public().into(),
- ed25519::Pair::from_seed(b"Bob ").public().into(),
- ], vec![
- ed25519::Pair::from_seed(b"Alice ").public().0.into(),
- ed25519::Pair::from_seed(b"Bob ").public().0.into(),
- ed25519::Pair::from_seed(b"Charlie ").public().0.into(),
- ed25519::Pair::from_seed(b"Dave ").public().0.into(),
- ed25519::Pair::from_seed(b"Eve ").public().0.into(),
- ed25519::Pair::from_seed(b"Ferdie ").public().0.into(),
- ],
- ed25519::Pair::from_seed(b"Alice ").public().0.into()
- ),
- vec![],
- None,
- None,
- None,
- None
- ),
- })
- }
- pub(crate) fn from(s: &str) -> Option<Self> {
- match s {
- "dev" => Some(Alternative::Development),
- "local" => Some(Alternative::LocalTestnet),
- _ => None,
- }
- }
- }
- fn testnet_genesis(initial_authorities: Vec<Ed25519AuthorityId>, endowed_accounts: Vec<AccountId>, root_key: AccountId) -> GenesisConfig {
- GenesisConfig {
- consensus: Some(ConsensusConfig {
- code: include_bytes!("../runtime/wasm/target/wasm32-unknown-unknown/release/joystream_node_runtime.compact.wasm").to_vec(),
- authorities: initial_authorities.clone(),
- }),
- system: None,
- timestamp: Some(TimestampConfig {
- period: 5, // 5 second block time.
- }),
- indices: Some(IndicesConfig {
- ids: endowed_accounts.clone(),
- }),
- balances: Some(BalancesConfig {
- transaction_base_fee: 1,
- transaction_byte_fee: 0,
- existential_deposit: 500,
- transfer_fee: 0,
- creation_fee: 0,
- balances: endowed_accounts.iter().map(|&k|(k, (1 << 60))).collect(),
- }),
- sudo: Some(SudoConfig {
- key: root_key,
- }),
- }
- }
|