forked from zigbee-alliance/distributed-compliance-ledger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genlocalnetconfig.sh
executable file
·137 lines (95 loc) · 4.94 KB
/
genlocalnetconfig.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# Copyright 2020 DSR Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
rm -rf ~/.dclcli
rm -rf ~/.dcld
rm -rf localnet
mkdir localnet localnet/client localnet/node0 localnet/node1 localnet/node2 localnet/node3
# client
dclcli config chain-id dclchain
dclcli config output json
dclcli config indent true
dclcli config trust-node false
echo 'test1234' | dclcli keys add jack
echo 'test1234' | dclcli keys add alice
echo 'test1234' | dclcli keys add bob
echo 'test1234' | dclcli keys add anna
cp -r ~/.dclcli/* localnet/client
# node 0
dcld init node0 --chain-id dclchain
jack_address=$(dclcli keys show jack -a)
jack_pubkey=$(dclcli keys show jack -p)
alice_address=$(dclcli keys show alice -a)
alice_pubkey=$(dclcli keys show alice -p)
bob_address=$(dclcli keys show bob -a)
bob_pubkey=$(dclcli keys show bob -p)
anna_address=$(dclcli keys show anna -a)
anna_pubkey=$(dclcli keys show anna -p)
dcld add-genesis-account --address=$jack_address --pubkey=$jack_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$alice_address --pubkey=$alice_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$bob_address --pubkey=$bob_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$anna_address --pubkey=$anna_pubkey --roles="NodeAdmin"
echo 'test1234' | dcld gentx --from jack
mv ~/.dcld/* localnet/node0
# node 1
dcld init node1 --chain-id dclchain
dcld add-genesis-account --address=$jack_address --pubkey=$jack_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$alice_address --pubkey=$alice_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$bob_address --pubkey=$bob_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$anna_address --pubkey=$anna_pubkey --roles="NodeAdmin"
echo 'test1234' | dcld gentx --from alice
mv ~/.dcld/* localnet/node1
# node 2
dcld init node2 --chain-id dclchain
dcld add-genesis-account --address=$jack_address --pubkey=$jack_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$alice_address --pubkey=$alice_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$bob_address --pubkey=$bob_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$anna_address --pubkey=$anna_pubkey --roles="NodeAdmin"
echo 'test1234' | dcld gentx --from bob
mv ~/.dcld/* localnet/node2
# node 3
dcld init node3 --chain-id dclchain
dcld add-genesis-account --address=$jack_address --pubkey=$jack_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$alice_address --pubkey=$alice_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$bob_address --pubkey=$bob_pubkey --roles="Trustee,NodeAdmin"
dcld add-genesis-account --address=$anna_address --pubkey=$anna_pubkey --roles="NodeAdmin"
echo 'test1234' | dcld gentx --from anna
cp -r ~/.dcld/* localnet/node3
# Collect all validator creation transactions
cp localnet/node0/config/gentx/* ~/.dcld/config/gentx
cp localnet/node1/config/gentx/* ~/.dcld/config/gentx
cp localnet/node2/config/gentx/* ~/.dcld/config/gentx
cp localnet/node3/config/gentx/* ~/.dcld/config/gentx
# Embed them into genesis
dcld collect-gentxs
dcld validate-genesis
# Update genesis for all nodes
cp ~/.dcld/config/genesis.json localnet/node0/config/
cp ~/.dcld/config/genesis.json localnet/node1/config/
cp ~/.dcld/config/genesis.json localnet/node2/config/
cp ~/.dcld/config/genesis.json localnet/node3/config/
# Find out node ids
id0=$(ls localnet/node0/config/gentx | sed 's/gentx-\(.*\).json/\1/')
id1=$(ls localnet/node1/config/gentx | sed 's/gentx-\(.*\).json/\1/')
id2=$(ls localnet/node2/config/gentx | sed 's/gentx-\(.*\).json/\1/')
id3=$(ls localnet/node3/config/gentx | sed 's/gentx-\(.*\).json/\1/')
# Update address book of the first node
peers="[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656"
sed -i "s/persistent_peers = \"\"/persistent_peers = \"$peers\"/g" localnet/node0/config/config.toml
# Make RPC enpoint available externally
sed -i 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' localnet/node0/config/config.toml
sed -i 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' localnet/node1/config/config.toml
sed -i 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' localnet/node2/config/config.toml
sed -i 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' localnet/node3/config/config.toml