Skip to content

Commit

Permalink
preset alice & bob
Browse files Browse the repository at this point in the history
  • Loading branch information
yanganto committed Jan 13, 2020
1 parent 00ad56a commit 5995135
Show file tree
Hide file tree
Showing 3 changed files with 326 additions and 11 deletions.
250 changes: 250 additions & 0 deletions boot-conf/icefrog/icefrog.json

Large diffs are not rendered by default.

83 changes: 72 additions & 11 deletions node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use sr_primitives::{
traits::{IdentifyAccount, Verify},
Perbill,
};
use std::env;
use substrate_service::Properties;
use substrate_telemetry::TelemetryEndpoints;

Expand All @@ -58,6 +59,65 @@ pub fn icefrog_testnet_config() -> Result<ChainSpec, String> {
ChainSpec::from_json_bytes(&include_bytes!("../res/icefrog.json")[..])
}

/// IceFrog testnet config generator
pub fn gen_icefrog_testnet_config() -> ChainSpec {
fn icefrog_config_genesis() -> GenesisConfig {
darwinia_genesis(
vec![
(
hex!["be3fd892bf0e2b33dbfcf298c99a9f71e631a57af6c017dc5ac078c5d5b3494b"].into(), //stash
hex!["70bf51d123581d6e51af70b342cac75ae0a0fc71d1a8d388719139af9c042b18"].into(),
get_from_seed::<GrandpaId>(&env::var("ALICE_SECRET").expect("Alice secret key missing")),
get_from_seed::<BabeId>("Alice"),
get_from_seed::<ImOnlineId>("Alice"),
),
(
hex!["e2f560c01a2d8e98d313d6799185c28a39e10896332b56304ff46392f585024c"].into(), //stash
hex!["94c51178449c09eec77918ea951fa3244f7b841eea1dd1489d2b5f2a53f8840f"].into(),
get_from_seed::<GrandpaId>(&env::var("BOB_SECRET").expect("Bob secret key missing")),
get_from_seed::<BabeId>("Bob"),
get_from_seed::<ImOnlineId>("Bob"),
),
],
hex!["a60837b2782f7ffd23e95cd26d1aa8d493b8badc6636234ccd44db03c41fcc6c"].into(),
Some(vec![
hex!["a60837b2782f7ffd23e95cd26d1aa8d493b8badc6636234ccd44db03c41fcc6c"].into(),
hex!["f29311a581558ded67b8bfd097e614ce8135f777e29777d07ec501adb0ddab08"].into(),
hex!["1098e3bf7b351d6210c61b05edefb3a2b88c9611db26fbed2c7136b6d8f9c90f"].into(),
hex!["f252bc67e45acc9b3852a0ef84ddfce6c9cef25193617ef1421c460ecc2c746f"].into(),
hex!["90ce56f84328b180fc55146709aa7038c18efd58f1f247410be0b1ddc612df27"].into(),
hex!["4ca516c4b95488d0e6e9810a429a010b5716168d777c6b1399d3ed61cce1715c"].into(),
hex!["e28573bb4d9233c799defe8f85fa80a66b43d47f4c1aef64bb8fffde1ecf8606"].into(),
hex!["20e2455350cbe36631e82ce9b12152f98a3738cb763e46e65d1a253806a26d1a"].into(),
hex!["9eccaca8a35f0659aed4df45455a855bcb3e7bff7bfc9d672b676bbb78988f0d"].into(),
hex!["98dba2d3252825f4cd1141ca4f41ea201a22b4e129a6c7253cea546dbb20e442"].into(),
]),
true,
)
}

ChainSpec::from_genesis(
"Darwinia IceFrog Testnet",
"icefrog_testnet",
icefrog_config_genesis,
vec![],
Some(TelemetryEndpoints::new(vec![(STAGING_TELEMETRY_URL.to_string(), 0)])),
Some("DAR"),
{
let mut properties = Properties::new();

properties.insert("ss58Format".into(), 42.into());
properties.insert("tokenDecimals".into(), 9.into());
properties.insert("tokenSymbol".into(), "IRING".into());
properties.insert("ktonTokenDecimals".into(), 9.into());
properties.insert("ktonTokenSymbol".into(), "IKTON".into());

Some(properties)
},
Default::default(),
)
}

fn session_keys(grandpa: GrandpaId, babe: BabeId, im_online: ImOnlineId) -> SessionKeys {
SessionKeys {
grandpa,
Expand Down Expand Up @@ -152,9 +212,12 @@ pub fn staging_testnet_config() -> ChainSpec {
}
/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
let pair = if seed.starts_with("0x") {
TPublic::Pair::from_string(seed, None)
} else {
TPublic::Pair::from_string(&format!("//{}", seed), None)
};
pair.expect("static values are valid; qed").public()
}

/// Helper function to generate an account ID from seed
Expand Down Expand Up @@ -185,25 +248,23 @@ pub fn darwinia_genesis(
) -> GenesisConfig {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
initial_authorities[0].clone().1,
initial_authorities[1].clone().1,
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
initial_authorities[0].clone().0,
initial_authorities[1].clone().0,
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
]
});

let eth_relay_authorities: Vec<AccountId> = vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
];
let eth_relay_authorities: Vec<AccountId> =
vec![initial_authorities[0].clone().1, initial_authorities[1].clone().1];

const RING_ENDOWMENT: Balance = 20_000_000 * COIN;
const KTON_ENDOWMENT: Balance = 10 * COIN;
Expand Down
4 changes: 4 additions & 0 deletions node/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub enum ChainSpec {
LocalTestnet,
/// The IceFrog testnet.
IceFrogTestnet,
/// Generate Iceforg testnet config.
GenIceFrogTestnet,
/// Whatever the current runtime is with the "global testnet" defaults.
StagingTestnet,
}
Expand All @@ -56,6 +58,7 @@ impl ChainSpec {
ChainSpec::LocalTestnet => chain_spec::local_testnet_config(),
ChainSpec::StagingTestnet => chain_spec::staging_testnet_config(),
ChainSpec::IceFrogTestnet => chain_spec::icefrog_testnet_config()?,
ChainSpec::GenIceFrogTestnet => chain_spec::gen_icefrog_testnet_config(),
})
}

Expand All @@ -65,6 +68,7 @@ impl ChainSpec {
"local" => Some(ChainSpec::LocalTestnet),
"staging" => Some(ChainSpec::StagingTestnet),
"" => Some(ChainSpec::IceFrogTestnet),
"gen" => Some(ChainSpec::GenIceFrogTestnet),
_ => None,
}
}
Expand Down

0 comments on commit 5995135

Please sign in to comment.