Skip to content

Commit 9123b79

Browse files
author
Max Gravitt
committed
added hashed parachain spec
1 parent 07d504c commit 9123b79

File tree

8 files changed

+247
-32
lines changed

8 files changed

+247
-32
lines changed

collator/src/chain_spec/hashed.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use sc_service::ChainType;
2-
use sp_core::sr25519;
2+
// use sp_core::sr25519;
3+
use sp_core::{crypto::UncheckedInto};
4+
35
use hex_literal::hex;
46

57
use super::{
6-
get_account_id_from_seed, get_collator_keys_from_seed, session_keys, SAFE_XCM_VERSION, Extensions,
8+
/*get_account_id_from_seed, get_collator_keys_from_seed,*/ session_keys, SAFE_XCM_VERSION, Extensions,
79
};
810

911
use cumulus_primitives_core::ParaId;
@@ -20,6 +22,11 @@ pub fn get_chain_spec() -> HashedChainSpec {
2022
properties.insert("tokenSymbol".into(), "HASH".into());
2123
properties.insert("tokenDecimals".into(), 18.into());
2224
properties.insert("ss58Format".into(), 3000.into());
25+
properties.insert("prefix".into(), 3000.into());
26+
properties.insert("network".into(), "hashed".into());
27+
properties.insert("displayName".into(), "Hashed Network".into());
28+
properties.insert("standardAccount".into(),"*25519".into());
29+
properties.insert("website".into(), "https://hashed.network".into());
2330

2431
// REVIEW: this is where the Hashed genesis is customized, for now,
2532
// it is just a duplicate of the development configuration
@@ -32,30 +39,25 @@ pub fn get_chain_spec() -> HashedChainSpec {
3239
// initial collators.
3340
vec![
3441
(
35-
get_account_id_from_seed::<sr25519::Public>("Alice"),
36-
get_collator_keys_from_seed("Alice"),
42+
// LocalTestnet
43+
// 5DHun9L82cdeZfR5ufzsod4tBfcU2AoQT3XJoRpCoasYefQj
44+
hex!["364e8e853de71a91892b8ce50308b4229c0c21863a7ec788d5e4f2f5f957e224"].into(),
45+
hex!["364e8e853de71a91892b8ce50308b4229c0c21863a7ec788d5e4f2f5f957e224"].unchecked_into(),
3746
),
3847
(
39-
get_account_id_from_seed::<sr25519::Public>("Bob"),
40-
get_collator_keys_from_seed("Bob"),
48+
// Coll2
49+
// 5FcANChPbU6sNa4TxGiPMAKookH8u1XdUw9K2ruS3G2SYvHR
50+
hex!["9cb28bbb15e92ab4431f3ada24b5026c8a6c00ac236dd3ebf0196718c1d2f021"].into(),
51+
hex!["9cb28bbb15e92ab4431f3ada24b5026c8a6c00ac236dd3ebf0196718c1d2f021"].unchecked_into(),
4152
),
4253
],
4354
vec![
44-
get_account_id_from_seed::<sr25519::Public>("Alice"),
45-
get_account_id_from_seed::<sr25519::Public>("Bob"),
46-
get_account_id_from_seed::<sr25519::Public>("Charlie"),
47-
get_account_id_from_seed::<sr25519::Public>("Dave"),
48-
get_account_id_from_seed::<sr25519::Public>("Eve"),
49-
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
50-
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
51-
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
52-
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
53-
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
54-
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
55-
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
55+
// LocalTestnet
56+
// 5DHun9L82cdeZfR5ufzsod4tBfcU2AoQT3XJoRpCoasYefQj
57+
hex!["364e8e853de71a91892b8ce50308b4229c0c21863a7ec788d5e4f2f5f957e224"].into(),
5658
],
57-
hex!["f83a0218e100ce3ede12c5d403116ef034124c62b181fff6935403cea9396d2f"].into(),
58-
1000.into(),
59+
hex!["364e8e853de71a91892b8ce50308b4229c0c21863a7ec788d5e4f2f5f957e224"].into(),
60+
3000.into(),
5961
)
6062
},
6163
Vec::new(),
@@ -65,7 +67,7 @@ pub fn get_chain_spec() -> HashedChainSpec {
6567
Some(properties),
6668
Extensions {
6769
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
68-
para_id: 1000,
70+
para_id: 2000,
6971
},
7072
)
7173
}

collator/src/chain_spec/md5.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ pub fn get_chain_spec() -> Md5ChainSpec {
3030
// initial collators.
3131
vec![
3232
(
33-
// 5HgAxuAcEybo448w5BZdoceCuHMAbEW9AetBKsj9s5GEBZT3
33+
// Jonathan
34+
// 5DHun9L82cdeZfR5ufzsod4tBfcU2AoQT3XJoRpCoasYefQj
3435
hex!["f83a0218e100ce3ede12c5d403116ef034124c62b181fff6935403cea9396d2f"].into(),
3536
hex!["f83a0218e100ce3ede12c5d403116ef034124c62b181fff6935403cea9396d2f"].unchecked_into(),
3637
),
3738
(
39+
// Theresa
3840
// 5DkJvQp2gqHraWZU1BNCDxEKTQHezn2Qy7z5hLPksUdjtEG9
3941
hex!["4a70d789b0f0897e0880e8d3d532187ac77cbda04228cfadf8bededdd0b1005e"].into(),
4042
hex!["4a70d789b0f0897e0880e8d3d532187ac77cbda04228cfadf8bededdd0b1005e"].unchecked_into(),
@@ -76,7 +78,7 @@ pub fn get_chain_spec() -> Md5ChainSpec {
7678
),
7779
],
7880
vec![
79-
// 5HgAxuAcEybo448w5BZdoceCuHMAbEW9AetBKsj9s5GEBZT3
81+
// 5DHun9L82cdeZfR5ufzsod4tBfcU2AoQT3XJoRpCoasYefQj
8082
hex!["f83a0218e100ce3ede12c5d403116ef034124c62b181fff6935403cea9396d2f"].into(),
8183
// 5DkJvQp2gqHraWZU1BNCDxEKTQHezn2Qy7z5hLPksUdjtEG9
8284
hex!["4a70d789b0f0897e0880e8d3d532187ac77cbda04228cfadf8bededdd0b1005e"].into(),
@@ -98,7 +100,7 @@ pub fn get_chain_spec() -> Md5ChainSpec {
98100
// session keys at
99101
vec![
100102
(
101-
// 5HgAxuAcEybo448w5BZdoceCuHMAbEW9AetBKsj9s5GEBZT3
103+
// 5DHun9L82cdeZfR5ufzsod4tBfcU2AoQT3XJoRpCoasYefQj
102104
hex!["f83a0218e100ce3ede12c5d403116ef034124c62b181fff6935403cea9396d2f"].into(),
103105
hex!["f83a0218e100ce3ede12c5d403116ef034124c62b181fff6935403cea9396d2f"].unchecked_into(),
104106
),
@@ -143,7 +145,7 @@ pub fn get_chain_spec() -> Md5ChainSpec {
143145
hex!["1eed3cc6fde968d5fe9c64c12241a5178577e07c707065026f476e868df0264b"].unchecked_into(),
144146
)
145147
],
146-
// 5HgAxuAcEybo448w5BZdoceCuHMAbEW9AetBKsj9s5GEBZT3
148+
// 5DHun9L82cdeZfR5ufzsod4tBfcU2AoQT3XJoRpCoasYefQj
147149
hex!["f83a0218e100ce3ede12c5d403116ef034124c62b181fff6935403cea9396d2f"].into(),
148150
2089.into(),
149151
)

collator/src/command.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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 Systems Parachain Collator".into()
39+
"Hashed 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 Systems Parachain Collator\n\nThe command-line arguments provided first will be \
48+
"Hashed 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>",
@@ -76,7 +76,7 @@ impl SubstrateCli for Cli {
7676

7777
impl SubstrateCli for RelayChainCli {
7878
fn impl_name() -> String {
79-
"Hashed Systems Parachain Collator".into()
79+
"Hashed 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 Systems Parachain Collator\n\nThe command-line arguments provided first will be \
88+
"Hashed 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>",

docs/parachain/add-genesis-balance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ In the genesis configuration, there is a vector of addresses:
2626

2727
```rust
2828
vec![
29-
// 5HgAxuAcEybo448w5BZdoceCuHMAbEW9AetBKsj9s5GEBZT3
29+
// 5DHun9L82cdeZfR5ufzsod4tBfcU2AoQT3XJoRpCoasYefQj
3030
hex!["f83a0218e100ce3ede12c5d403116ef034124c62b181fff6935403cea9396d2f"].into(),
3131
// 5DkJvQp2gqHraWZU1BNCDxEKTQHezn2Qy7z5hLPksUdjtEG9
3232
hex!["4a70d789b0f0897e0880e8d3d532187ac77cbda04228cfadf8bededdd0b1005e"].into(),

docs/parachain/quick-start-hashed.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Quick Start
2+
This is a quick guide on connecting the parachain to a local testnet relay chain.
3+
4+
# Launch the Relay Chain
5+
```bash
6+
cd ~/github.com/paritytech
7+
8+
git clone https://github.com/paritytech/polkadot
9+
cd polkadot
10+
11+
cargo build --release
12+
13+
# Generate a raw chain spec
14+
./target/release/polkadot build-spec --chain rococo-local --disable-default-bootnode --raw > ~/github.com/paritytech/polkadot/rococo-custom-2-raw.json
15+
16+
# Alice
17+
./target/release/polkadot --alice --validator --base-path /tmp/relay/alice --chain ~/github.com/paritytech/polkadot/rococo-custom-2-raw.json --port 30333 --ws-port 9944
18+
19+
# Bob (In a separate terminal)
20+
./target/release/polkadot --bob --validator --base-path /tmp/relay/bob --chain ~/github.com/paritytech/polkadot/rococo-custom-2-raw.json --port 30334 --ws-port 9945
21+
```
22+
23+
# Reserve the Para ID
24+
Go to https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/parachains/parathreads
25+
26+
and Click `+ParaID`
27+
28+
# Launch the Parachain
29+
```bash
30+
31+
cd ~/github.com/hashed-io
32+
33+
git clone https://github.com/hashed-io/hashed-substrate
34+
cd hashed-substrate
35+
36+
cargo build --release
37+
38+
./target/release/hashed-parachain build-spec --chain hashed --disable-default-bootnode > hashed-local-parachain.json
39+
```
40+
41+
# Add the ParaID
42+
Update `md5-local-parachain.json` and change the parachain ID to 2000 in two places.
43+
44+
```json
45+
// --snip--
46+
"para_id": 2000,
47+
// --snip--
48+
"parachainInfo": {
49+
"parachainId": 2000
50+
},
51+
// --snip--
52+
```
53+
54+
# Build the Raw Spec File
55+
```bash
56+
# build raw spec
57+
./target/release/hashed-parachain build-spec --chain hashed-local-parachain.json --raw --disable-default-bootnode > hashed-local-parachain-raw.json
58+
```
59+
60+
# Building genesis state and wasm files
61+
```bash
62+
./target/release/hashed-parachain export-genesis-state --chain hashed-local-parachain-raw.json > hashed-genesis-head
63+
64+
./target/release/hashed-parachain export-genesis-wasm --chain hashed-local-parachain-raw.json > hashed-wasm
65+
```
66+
67+
# Start Collator
68+
```bash
69+
./target/release/hashed-parachain \
70+
--alice \
71+
--collator \
72+
--force-authoring \
73+
--chain hashed-local-parachain-raw.json \
74+
--base-path /tmp/parachain/alice \
75+
--port 40333 \
76+
--ws-port 8844 \
77+
-- \
78+
--execution wasm \
79+
--chain ~/github.com/paritytech/polkadot/rococo-custom-2-raw.json \
80+
--port 30343 \
81+
--ws-port 9977
82+
83+
```
84+
85+
## Sudo Register the parachain
86+
![image](https://user-images.githubusercontent.com/2915325/99548884-1be13580-2987-11eb-9a8b-20be658d34f9.png)
87+
88+
89+
### Purging the Chains
90+
```bash
91+
# Purge a chain
92+
./target/release/hashed-parachain \
93+
purge-chain \
94+
--base-path /tmp/parachain/alice \
95+
--chain ~/github.com/hashed-io/hashed-parachain/md5-local-parachain-raw.json
96+
97+
# Purge relay chain
98+
./target/release/polkadot purge-chain --base-path /tmp/relay/alice --chain ~/github.com/paritytech/polkadot/rococo-custom-2-raw.json
99+
100+
# Sometimes I use this:
101+
rm -rf /tmp/relay && rm -rf /tmp/parachain
102+
```

docs/parachain/quick-start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ and Click `+ParaID`
3030

3131
cd ~/github.com/hashed-io
3232

33-
git clone https://github.com/hashed-io/hashed-parachain
34-
cd hashed-parachain
33+
git clone https://github.com/hashed-io/hashed-substrate
34+
cd hashed-substrate
3535

3636
cargo build --release
3737

parachain-runtime/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ pallet-bounties = { git = "https://github.com/paritytech/substrate", branch = "p
6262
pallet-child-bounties = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
6363
pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.27", default-features = false }
6464
pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
65+
66+
# Contracts specific packages
67+
# pallet-contracts = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts", default-features = false, features = ["unstable-interface"], branch = "polkadot-v0.9.27" }
68+
# pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts-primitives", default-features = false, branch = "polkadot-v0.9.27" }
69+
# pallet-contracts-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts-rpc-runtime-api", default-features = false, branch = "polkadot-v0.9.27" }
70+
6571
pallet-conviction-voting = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
6672
pallet-democracy = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
6773
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false }
@@ -158,6 +164,9 @@ std = [
158164
"pallet-child-bounties/std",
159165
"pallet-collator-selection/std",
160166
"pallet-collective/std",
167+
# "pallet-contracts/std",
168+
# "pallet-contracts-primitives/std",
169+
# "pallet-contracts-rpc-runtime-api/std",
161170
"pallet-conviction-voting/std",
162171
"pallet-democracy/std",
163172
"pallet-elections-phragmen/std",
@@ -216,6 +225,7 @@ runtime-benchmarks = [
216225
"frame-system-benchmarking",
217226
"frame-system/runtime-benchmarks",
218227
"pallet-balances/runtime-benchmarks",
228+
# "pallet-contracts/runtime-benchmarks",
219229
"pallet-collator-selection/runtime-benchmarks",
220230
"pallet-timestamp/runtime-benchmarks",
221231
"pallet-xcm/runtime-benchmarks",

0 commit comments

Comments
 (0)