Skip to content

Commit

Permalink
Merge pull request #104 from web3labs/snow-testnet
Browse files Browse the repository at this point in the history
Snow testnet spec
  • Loading branch information
mohamedelshami authored Jul 13, 2022
2 parents b42334e + a8672e2 commit fe6455c
Show file tree
Hide file tree
Showing 12 changed files with 569 additions and 199 deletions.
4 changes: 2 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ homepage = 'https://substrate.dev'
license = 'Apache-2.0'
name = 'ice-node'
repository = 'https://github.com/web3labs/ice-substrate'
version = '0.4.48'
version = '0.4.49'
publish = false

[package.metadata.docs.rs]
Expand All @@ -25,7 +25,7 @@ futures = "0.3"
log = "0.4.8"
serde_json = "1.0"
hex-literal = "0.3.4"

tracing-core = "=0.1.28"

# primitives
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" }
Expand Down
127 changes: 101 additions & 26 deletions node/src/chain_spec/snow.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
use cumulus_primitives_core::ParaId;
use hex_literal::hex;
use sc_chain_spec::Properties;
use sc_service::ChainType;
use snow_runtime::currency::ICY;
use snow_runtime::{
wasm_binary_unwrap, AccountId, AirdropConfig, AuraConfig, AuraId, BalancesConfig,
wasm_binary_unwrap, AccountId, Balance, AirdropConfig, AuraConfig, AuraId, BalancesConfig,
CollatorSelectionConfig, CouncilConfig, CouncilMembershipConfig, DemocracyConfig, EVMConfig,
GenesisConfig, IndicesConfig, ParachainInfoConfig, SS58Prefix, SessionConfig, SessionKeys,
Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, TechnicalMembershipConfig,
VestingConfig,
VestingConfig, TreasuryPalletId,
};
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
use snow_runtime::currency::ICY;
use cumulus_primitives_core::ParaId;
use hex_literal::hex;
use sc_chain_spec::Properties;
use sc_service::ChainType;
use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
use sp_runtime::traits::{AccountIdConversion, IdentifyAccount, Verify};
use std::collections::BTreeMap;

use super::{get_from_seed, Extensions};

/// Publicly expose SnowChainSpec for sc service
pub type SnowChainSpec = sc_service::GenericChainSpec<GenesisConfig, Extensions>;

const AIRDROP_MERKLE_ROOT: [u8; 32] =
hex!("990e01e3959627d2ddd94927e1c605a422b62dc3b8c8b98d713ae6833c3ef122");

const PARA_ID: u32 = 2000;

//const TOTAL_SUPPLY: Balance = ICY * 1800000000;
//const TOTAL_AIR_DROP: Balance = 1 * ICY;

const AIRDROP_MERKLE_ROOT: [u8; 32] =
hex!("b654eac2f99abbe8e847a2079a2018bcf09989c00a3e0dd0114a335c4d97ef32");

fn snow_properties() -> Properties {
let mut properties = Properties::new();

Expand Down Expand Up @@ -55,8 +58,12 @@ pub fn get_dev_chain_spec() -> SnowChainSpec {
];

let endowed_accounts = vec![
(get_account_id_from_seed::<sr25519::Public>("Alice")),
(get_account_id_from_seed::<sr25519::Public>("Bob")),
(
(get_account_id_from_seed::<sr25519::Public>("Alice"), ICY * 300_000_000)
),
(
(get_account_id_from_seed::<sr25519::Public>("Bob"), ICY * 300_000_000)
),
];

let council_members = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
Expand Down Expand Up @@ -84,7 +91,78 @@ pub fn get_dev_chain_spec() -> SnowChainSpec {
},
vec![],
None,
"snow".into(),
None,
Some(snow_properties()),
Extensions {
bad_blocks: Default::default(),
relay_chain: "rococo-local".into(),
para_id: PARA_ID,
},
)
}

pub fn testnet_spec() -> SnowChainSpec {

let root_key: AccountId =
hex!["6f38cb15a6ec17a68f2aec60d2cd8cd15e58b4e33ee7f705d1cbcde07009d33f"].into();

let invulnerables = vec![
(
hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(),
hex!["62687296bffd79f12178c4278b9439d5eeb8ed7cc0b1f2ae29307e806a019659"]
.unchecked_into(),
),
];
let authorities = vec![
(
hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(),
hex!["62687296bffd79f12178c4278b9439d5eeb8ed7cc0b1f2ae29307e806a019659"]
.unchecked_into(),
),
];

let airdrop_creditor_account: AccountId =
hex!["1d94604ab70381bc1ea9e14854b939f4c651d2259aa0f7eb193971d526f64a45"].into();

let endowed_accounts = vec![
(hex!["10b3ae7ebb7d722c8e8d0d6bf421f6d5dbde8d329f7c905a201539c635d61872"].into(), ICY * 630000000),
(TreasuryPalletId::get().into_account_truncating(), ICY * 1170000000),
(hex!["6f38cb15a6ec17a68f2aec60d2cd8cd15e58b4e33ee7f705d1cbcde07009d33f"].into(), ICY * 2000),
(hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(), ICY * 5100),
(hex!["62687296bffd79f12178c4278b9439d5eeb8ed7cc0b1f2ae29307e806a019659"].into(), ICY * 2000),
(hex!["328d54003810edf7cef62d1374032333ade2fdb2756138fc43f6b4c1918bef7c"].into(), ICY * 2000),
(hex!["f057f9fbec27bb5b92c5f30e89cae9826f5b86cae8380aa383c079939b3e0a55"].into(), ICY * 2000),
(hex!["6adaa753d9c17d9280d2469acdac1aa9b7f01be3d4149f667b9be7c7fbad1319"].into(), ICY * 2000),
];

let council_members = vec![];

let technical_committee = vec![
hex!["f28ae952b7518dbc35543b894facca7db5ab982ec6aa9afbba4e8c015ce4b74a"].into(),
hex!["f057f9fbec27bb5b92c5f30e89cae9826f5b86cae8380aa383c079939b3e0a55"].into(),
hex!["70d8131ab823528226296bbfbb5827a5ae84beda0edf73f0cbc95057ef43be6a"].into(),
];

SnowChainSpec::from_genesis(
"Snow Local Tesnet",
"snow-testnet",
ChainType::Local,
move || {
make_genesis(
root_key.clone(),
authorities.clone(),
invulnerables.clone(),
endowed_accounts.clone(),
council_members.clone(),
technical_committee.clone(),
airdrop_creditor_account.clone(),
PARA_ID.into(),
)
},
vec![],
None,
"snow".into(),
None,
Some(snow_properties()),
Extensions {
Expand All @@ -93,14 +171,15 @@ pub fn get_dev_chain_spec() -> SnowChainSpec {
para_id: PARA_ID,
},
)

}

/// Helper function to create Arctic GenesisConfig.
/// Helper function to create GenesisConfig.
fn make_genesis(
root_key: AccountId,
authorities: Vec<(AccountId, AuraId)>,
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
endowed_accounts: Vec<(AccountId, Balance)>,
council_members: Vec<AccountId>,
technical_committee: Vec<AccountId>,
airdrop_creditor_account: AccountId,
Expand All @@ -115,11 +194,7 @@ fn make_genesis(
},
parachain_info: ParachainInfoConfig { parachain_id },
balances: BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, ICY * 300_000_000))
.collect(),
balances: endowed_accounts,
},
vesting: VestingConfig { vesting: vec![] },
aura: AuraConfig {
Expand All @@ -128,7 +203,7 @@ fn make_genesis(
aura_ext: Default::default(),
collator_selection: CollatorSelectionConfig {
desired_candidates: 200,
candidacy_bond: 32_000 * ICY,
candidacy_bond: 5000 * ICY,
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
},
session: SessionConfig {
Expand Down Expand Up @@ -187,10 +262,10 @@ where

/// Generate an Aura authority key
pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AuraId) {
(
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<AuraId>(seed),
)
(
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<AuraId>(seed),
)
}

/// Helper for session keys to map aura id
Expand Down
1 change: 1 addition & 0 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, St
"arctic-dev" => Box::new(chain_spec::arctic::get_dev_chain_spec()),
"arctic" => Box::new(chain_spec::arctic::get_chain_spec()),
"snow-dev" => Box::new(chain_spec::snow::get_dev_chain_spec()),
"snow-testnet" => Box::new(chain_spec::snow::testnet_spec()),

path => {
let chain_spec = chain_spec::snow::SnowChainSpec::from_json_file(path.into())?;
Expand Down
99 changes: 0 additions & 99 deletions resources/frost_testnet.json

This file was deleted.

70 changes: 0 additions & 70 deletions resources/frost_testnetRaw.json

This file was deleted.

4 changes: 2 additions & 2 deletions resources/snow-laucnh.json → resources/snow-launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"parachains": [
{
"bin": "../target/release/ice-node",
"chain": "snow-dev",
"chain": "snow-testnet",
"balance": 100000000000000000,
"nodes": [
{
Expand All @@ -41,7 +41,7 @@
"--unsafe-rpc-external",
"--rpc-cors=all",
"--rpc-methods=Unsafe",
"--log=cumulus-collator=trace",

"--",
"--execution=wasm"
]
Expand Down
187 changes: 187 additions & 0 deletions resources/snow-plain.json

Large diffs are not rendered by default.

122 changes: 122 additions & 0 deletions resources/snow-raw.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions scripts/launch/alice.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Start Relay `Alice` node
../polkadot/target/release/polkadot \
--alice \
--validator \
--base-path /tmp/relay/alice \
--chain rococo-local.json \
--port 30333 \
--ws-port 9955
8 changes: 8 additions & 0 deletions scripts/launch/bob.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
../polkadot/target/release/polkadot \
--bob \
--validator \
--base-path /tmp/relay/bob \
--chain rococo-local.json \
--port 30334 \
--ws-port 9945
15 changes: 15 additions & 0 deletions scripts/launch/collator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

./target/release/ice-node \
--collator \
--force-authoring \
--chain snow-raw.json \
--base-path /tmp/snow \
--port 40333 \
--ws-port 9944 \
--rpc-cors all \
-- \
--execution wasm \
--chain rococo-local.json \
--port 30343 \
--ws-port 9977
122 changes: 122 additions & 0 deletions snow-raw.json

Large diffs are not rendered by default.

0 comments on commit fe6455c

Please sign in to comment.