Skip to content

Commit 7ef9e04

Browse files
authored
Merge pull request #265 from hashed-io/feature/luhn-chain-spec
Feature/luhn chain spec
2 parents 9123b79 + c103811 commit 7ef9e04

File tree

16 files changed

+817
-270
lines changed

16 files changed

+817
-270
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# These are backup files generated by rustfmt
55
**/*.rs.bk
66

7+
**/node_modules
8+
79
.DS_Store
810

911
# The cache for docker container dependency
@@ -32,3 +34,4 @@ gcloud-md5-ingress.yml
3234
collator-data
3335
relay-data
3436
.vscode/settings.json
37+

Cargo.lock

Lines changed: 181 additions & 181 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

collator/src/chain_spec/hashed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn get_chain_spec() -> HashedChainSpec {
5757
hex!["364e8e853de71a91892b8ce50308b4229c0c21863a7ec788d5e4f2f5f957e224"].into(),
5858
],
5959
hex!["364e8e853de71a91892b8ce50308b4229c0c21863a7ec788d5e4f2f5f957e224"].into(),
60-
3000.into(),
60+
2000.into(),
6161
)
6262
},
6363
Vec::new(),
@@ -85,7 +85,7 @@ fn hashed_genesis(
8585
.to_vec(),
8686
},
8787
balances: hashed_parachain_runtime::BalancesConfig {
88-
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
88+
balances: endowed_accounts.iter().cloned().map(|k| (k, 1000000000000000000000000000)).collect(),
8989
},
9090
sudo: SudoConfig { key: Some(root_key) },
9191
council: Default::default(),

collator/src/chain_spec/luhn.rs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
use sc_service::ChainType;
2+
// use sp_core::sr25519;
3+
use sp_core::{crypto::UncheckedInto};
4+
5+
use hex_literal::hex;
6+
7+
use super::{
8+
/*get_account_id_from_seed, get_collator_keys_from_seed,*/ session_keys, SAFE_XCM_VERSION, Extensions,
9+
};
10+
11+
use cumulus_primitives_core::ParaId;
12+
use hashed_parachain_runtime::{AccountId, AuraId, SudoConfig, EXISTENTIAL_DEPOSIT};
13+
14+
/// Specialized `ChainSpec` for Hashed Network
15+
pub type HashedChainSpec =
16+
sc_service::GenericChainSpec<hashed_parachain_runtime::GenesisConfig, Extensions>;
17+
18+
/// Gen HASH chain specification
19+
pub fn get_chain_spec() -> HashedChainSpec {
20+
21+
let mut properties = sc_chain_spec::Properties::new();
22+
properties.insert("tokenSymbol".into(), "LUHN".into());
23+
properties.insert("tokenDecimals".into(), 18.into());
24+
properties.insert("ss58Format".into(), 11486.into());
25+
properties.insert("prefix".into(), 11486.into());
26+
properties.insert("network".into(), "luhn".into());
27+
properties.insert("displayName".into(), "Luhn Network".into());
28+
properties.insert("standardAccount".into(),"*25519".into());
29+
properties.insert("website".into(), "https://luhn.network".into());
30+
31+
HashedChainSpec::from_genesis(
32+
"Luhn Network",
33+
"luhn",
34+
ChainType::Live,
35+
move || {
36+
hashed_genesis(
37+
// initial collators.
38+
vec![
39+
(
40+
// Collator #1
41+
// uhsPQGuXYwjnLvoJWWttQ6FEVtztHSvsjE7UFzxS8mSfoSmts
42+
hex!["1cfc7e49e91696b84bf8e931c16375ea634c3997b36155657faf7dc4716e273e"].into(),
43+
hex!["1cfc7e49e91696b84bf8e931c16375ea634c3997b36155657faf7dc4716e273e"].unchecked_into(),
44+
),
45+
(
46+
// Collator #2
47+
// uhujXWvqSqGrY3K62qeamwCGQd7tTo1hm1s9ZYrgxAZFBLyLv
48+
hex!["84ce3f0bc9ae73d8497c6161927e9e04f39f4bc54579689532d048188c10a77c"].into(),
49+
hex!["84ce3f0bc9ae73d8497c6161927e9e04f39f4bc54579689532d048188c10a77c"].unchecked_into(),
50+
),
51+
],
52+
vec![
53+
// PH
54+
// uhtqJBJ9ZeKguyAG4GJ2S7cme5FvJ661P5NVdHTYKQgvDEQAR
55+
hex!["5cf8957922e4058a953281f82fdced2e4d389fe37c77f41a0fd2379df0caf877"].into(),
56+
],
57+
// uhtqJBJ9ZeKguyAG4GJ2S7cme5FvJ661P5NVdHTYKQgvDEQAR
58+
hex!["5cf8957922e4058a953281f82fdced2e4d389fe37c77f41a0fd2379df0caf877"].into(),
59+
2232.into(),
60+
)
61+
},
62+
Vec::new(),
63+
None,
64+
None,
65+
None,
66+
Some(properties),
67+
Extensions {
68+
relay_chain: "kusama".into(),
69+
para_id: 2232,
70+
},
71+
)
72+
}
73+
74+
fn hashed_genesis(
75+
invulnerables: Vec<(AccountId, AuraId)>,
76+
endowed_accounts: Vec<AccountId>,
77+
root_key: AccountId,
78+
id: ParaId,
79+
) -> hashed_parachain_runtime::GenesisConfig {
80+
hashed_parachain_runtime::GenesisConfig {
81+
system: hashed_parachain_runtime::SystemConfig {
82+
code: hashed_parachain_runtime::WASM_BINARY
83+
.expect("WASM binary was not build, please build it!")
84+
.to_vec(),
85+
},
86+
balances: hashed_parachain_runtime::BalancesConfig {
87+
balances: endowed_accounts.iter().cloned().map(|k| (k, 1000000000000000000000000000)).collect(),
88+
},
89+
sudo: SudoConfig { key: Some(root_key) },
90+
council: Default::default(),
91+
treasury: Default::default(),
92+
parachain_info: hashed_parachain_runtime::ParachainInfoConfig { parachain_id: id },
93+
collator_selection: hashed_parachain_runtime::CollatorSelectionConfig {
94+
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
95+
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
96+
..Default::default()
97+
},
98+
session: hashed_parachain_runtime::SessionConfig {
99+
keys: invulnerables
100+
.into_iter()
101+
.map(|(acc, aura)| {
102+
(
103+
acc.clone(), // account id
104+
acc, // validator id
105+
session_keys(aura), // session keys
106+
)
107+
})
108+
.collect(),
109+
},
110+
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
111+
// of this.
112+
aura: Default::default(),
113+
aura_ext: Default::default(),
114+
parachain_system: Default::default(),
115+
polkadot_xcm: hashed_parachain_runtime::PolkadotXcmConfig {
116+
safe_xcm_version: Some(SAFE_XCM_VERSION),
117+
},
118+
}
119+
}
120+

collator/src/chain_spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use sc_service::ChainType;
88
use sp_runtime::traits::{IdentifyAccount, Verify};
99

1010
pub mod hashed;
11+
pub mod luhn;
1112
pub mod md5;
1213

1314
/// Specialized `ChainSpec` for the normal parachain runtime.

collator/src/command.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
2727
Ok(match id {
2828
"dev" => Box::new(chain_spec::development_config()),
2929
"hashed" => Box::new(chain_spec::hashed::get_chain_spec()),
30-
// "luhn" => Box::new(chain_spec::luhn::get_chain_spec()),
30+
"luhn" => Box::new(chain_spec::luhn::get_chain_spec()),
3131
"md5" => Box::new(chain_spec::md5::get_chain_spec()),
3232
"" | "local" => Box::new(chain_spec::local_testnet_config()),
3333
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
@@ -36,7 +36,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
3636

3737
impl SubstrateCli for Cli {
3838
fn impl_name() -> String {
39-
"Hashed Network Parachain Collator".into()
39+
"Luhn Network Parachain Collator".into()
4040
}
4141

4242
fn impl_version() -> String {
@@ -45,7 +45,7 @@ impl SubstrateCli for Cli {
4545

4646
fn description() -> String {
4747
format!(
48-
"Hashed Network Parachain Collator\n\nThe command-line arguments provided first will be \
48+
"Luhn Network Parachain Collator\n\nThe command-line arguments provided first will be \
4949
passed to the parachain node, while the arguments provided after -- will be passed \
5050
to the relay chain node.\n\n\
5151
{} <parachain-args> -- <relay-chain-args>",
@@ -58,7 +58,7 @@ impl SubstrateCli for Cli {
5858
}
5959

6060
fn support_url() -> String {
61-
"https://github.com/hashed-io/hashed-parachain/issues/new".into()
61+
"https://github.com/hashed-io/hashed-substrate/issues/new".into()
6262
}
6363

6464
fn copyright_start_year() -> i32 {
@@ -76,7 +76,7 @@ impl SubstrateCli for Cli {
7676

7777
impl SubstrateCli for RelayChainCli {
7878
fn impl_name() -> String {
79-
"Hashed Network Parachain Collator".into()
79+
"Luhn Network Parachain Collator".into()
8080
}
8181

8282
fn impl_version() -> String {
@@ -85,7 +85,7 @@ impl SubstrateCli for RelayChainCli {
8585

8686
fn description() -> String {
8787
format!(
88-
"Hashed Network Parachain Collator\n\nThe command-line arguments provided first will be \
88+
"Luhn Network Parachain Collator\n\nThe command-line arguments provided first will be \
8989
passed to the parachain node, while the arguments provided after -- will be passed \
9090
to the relay chain node.\n\n\
9191
{} <parachain-args> -- <relay-chain-args>",
@@ -98,7 +98,7 @@ impl SubstrateCli for RelayChainCli {
9898
}
9999

100100
fn support_url() -> String {
101-
"https://github.com/hashed-io/hashed-parachain/issues/new".into()
101+
"https://github.com/hashed-io/hashed-substrate/issues/new".into()
102102
}
103103

104104
fn copyright_start_year() -> i32 {

docs/parachain/quick-start-hashed.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ cd hashed-substrate
3535

3636
cargo build --release
3737

38+
./target/release/hashed-parachain build-spec --chain hashed --disable-default-bootnode > hashed-local-parachain.json
39+
3840
./target/release/hashed-parachain build-spec --chain hashed --disable-default-bootnode > hashed-local-parachain.json
3941
```
4042

@@ -51,6 +53,12 @@ Update `md5-local-parachain.json` and change the parachain ID to 2000 in two pla
5153
// --snip--
5254
```
5355

56+
# Change amount for endowed account to
57+
58+
1000000000000000000000000000
59+
60+
1 billion with 18 decimal places
61+
5462
# Build the Raw Spec File
5563
```bash
5664
# build raw spec
@@ -61,17 +69,23 @@ Update `md5-local-parachain.json` and change the parachain ID to 2000 in two pla
6169
```bash
6270
./target/release/hashed-parachain export-genesis-state --chain hashed-local-parachain-raw.json > hashed-genesis-head
6371

64-
./target/release/hashed-parachain export-genesis-wasm --chain hashed-local-parachain-raw.json > hashed-wasm
72+
./target/release/hashed-parachain export-genesis-wasm --chain hashed-local-parachain-raw.json > hashed-wasm-upgrade
73+
```
74+
75+
# Building genesis state and wasm files
76+
```bash
77+
./target/release/hashed-parachain export-genesis-state --chain hashed > hashed-genesis-head
78+
79+
./target/release/hashed-parachain export-genesis-wasm --chain hashed > hashed-wasm
6580
```
6681

67-
# Start Collator
82+
# Start Collator #1
6883
```bash
6984
./target/release/hashed-parachain \
70-
--alice \
7185
--collator \
7286
--force-authoring \
73-
--chain hashed-local-parachain-raw.json \
74-
--base-path /tmp/parachain/alice \
87+
--chain hashed \
88+
--base-path /tmp/parachain/hashed-local \
7589
--port 40333 \
7690
--ws-port 8844 \
7791
-- \
@@ -86,6 +100,34 @@ Update `md5-local-parachain.json` and change the parachain ID to 2000 in two pla
86100
![image](https://user-images.githubusercontent.com/2915325/99548884-1be13580-2987-11eb-9a8b-20be658d34f9.png)
87101

88102

103+
# Generate new WASM
104+
```bash
105+
./target/release/hashed-parachain export-genesis-wasm --chain hashed > hashed-wasm-upgrade
106+
```
107+
108+
# Start Second Collator
109+
```bash
110+
./target/release/hashed-parachain \
111+
--bob \
112+
--collator \
113+
--force-authoring \
114+
--chain hashed \
115+
--base-path /tmp/parachain/bob \
116+
--port 40334 \
117+
--ws-port 8845 \
118+
-- \
119+
--execution wasm \
120+
--chain ~/github.com/paritytech/polkadot/rococo-custom-2-raw.json \
121+
--port 30344 \
122+
--ws-port 9978
123+
124+
```
125+
126+
## Insert second collator key
127+
```bash
128+
./target/release/hashed key insert --scheme sr25519 --keystore-path /tmp/parachain/hashed-local/chains/hashed/keystore --key-type aura --suri ""
129+
```
130+
89131
### Purging the Chains
90132
```bash
91133
# Purge a chain

0 commit comments

Comments
 (0)