forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_seedling_spec.sh
executable file
·56 lines (45 loc) · 1.85 KB
/
create_seedling_spec.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
usage() {
echo Usage:
echo "$0 <srtool compressed runtime path> <name> <id> <chain type> <bootnodes> <relay chain> <parachain id> <sudo key>"
exit 1
}
set -e
runtime_path=$1
name=$2
id="seedling-$3"
chain_type=$4
bootnodes=$5
relay_chain=$6
para_id=$7
sudo=$8
[ -z "$runtime_path" ] && usage
[ -z "$name" ] && usage
[ -z "$id" ] && usage
[ -z "$chain_type" ] && usage
[ -z "$bootnodes" ] && usage
[ -z "$relay_chain" ] && usage
[ -z "$para_$id" ] && usage
[ -z "$sudo" ] && usage
binary="./target/release/polkadot-parachain"
# build the chain spec we'll manipulate
$binary build-spec --disable-default-bootnode --chain seedling > seedling-spec-plain.json
# convert runtime to hex
cat $runtime_path | od -A n -v -t x1 | tr -d ' \n' > seedling-hex.txt
# replace the runtime in the spec with the given runtime and set some values to production
cat seedling-spec-plain.json | jq --rawfile code seedling-hex.txt '.genesis.runtime.system.code = ("0x" + $code)' \
| jq --arg name $name '.name = $name' \
| jq --arg id $id '.id = $id' \
| jq --arg chain_type $chain_type '.chainType = $chain_type' \
| jq --argjson bootnodes $bootnodes '.bootNodes = $bootnodes' \
| jq --arg relay_chain $relay_chain '.relay_chain = $relay_chain' \
| jq --argjson para_id $para_id '.para_id = $para_id' \
| jq --arg sudo $sudo '.genesis.runtime.sudo.key = $sudo' \
| jq --argjson para_id $para_id '.genesis.runtime.parachainInfo.parachainId = $para_id' \
> edited-seedling-plain.json
# build a raw spec
$binary build-spec --disable-default-bootnode --chain edited-seedling-plain.json --raw > seedling-spec-raw.json
# build genesis data
$binary export-genesis-state --parachain-id=$para_id --chain seedling-spec-raw.json > seedling-head-data
# build genesis wasm
$binary export-genesis-wasm --chain seedling-spec-raw.json > seedling-wasm