-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulti-node.sh
executable file
·120 lines (94 loc) · 6.67 KB
/
multi-node.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
#!/bin/bash
set -e
killall injectived &>/dev/null || true
rm -rf ~/.injectived
CHAINID="testing-1"
mkdir $HOME/.injectived
mkdir $HOME/.injectived/validator1
mkdir $HOME/.injectived/validator2
mkdir $HOME/.injectived/validator3
mkdir $HOME/.injectived/validator4
# init all three validators
injectived init validator1 --chain-id $CHAINID --home=$HOME/.injectived/validator1
injectived init validator2 --chain-id $CHAINID --home=$HOME/.injectived/validator2
injectived init validator3 --chain-id $CHAINID --home=$HOME/.injectived/validator3
injectived init validator4 --chain-id $CHAINID --home=$HOME/.injectived/validator4
# injectived config chain-id $CHAINID --home=$HOME/.injectived/validator1
# # create keys for all three validators
injectived keys add validator1 --keyring-backend=test --home=$HOME/.injectived/validator1
injectived keys add validator2 --keyring-backend=test --home=$HOME/.injectived/validator2
injectived keys add validator3 --keyring-backend=test --home=$HOME/.injectived/validator3
injectived keys add validator4 --keyring-backend=test --home=$HOME/.injectived/validator4
# create validator node with tokens to transfer to the three other nodes
injectived add-genesis-account $(injectived keys show validator1 -a --keyring-backend=test --home=$HOME/.injectived/validator1) 10000000000000000000000000000000stake --home=$HOME/.injectived/validator1 --chain-id $CHAINID
injectived gentx validator1 1000000000000000000000stake --keyring-backend=test --home=$HOME/.injectived/validator1 --chain-id $CHAINID
injectived collect-gentxs --home=$HOME/.injectived/validator1
# change app.toml values
VALIDATOR1_APP_TOML=$HOME/.injectived/validator1/config/app.toml
VALIDATOR2_APP_TOML=$HOME/.injectived/validator2/config/app.toml
VALIDATOR3_APP_TOML=$HOME/.injectived/validator3/config/app.toml
VALIDATOR4_APP_TOML=$HOME/.injectived/validator4/config/app.toml
# validator1
sed -i -E 's|0.0.0.0:9090|0.0.0.0:9050|g' $VALIDATOR1_APP_TOML
# validator2
sed -i -E 's|tcp://0.0.0.0:1317|tcp://0.0.0.0:1316|g' $VALIDATOR2_APP_TOML
sed -i -E 's|0.0.0.0:9090|0.0.0.0:9088|g' $VALIDATOR2_APP_TOML
sed -i -E 's|0.0.0.0:9091|0.0.0.0:9089|g' $VALIDATOR2_APP_TOML
sed -i -E 's|tcp://0.0.0.0:10337|tcp://0.0.0.0:10347|g' $VALIDATOR2_APP_TOML
# "tcp://0.0.0.0:10337"
# # validator3
sed -i -E 's|tcp://0.0.0.0:1317|tcp://0.0.0.0:1315|g' $VALIDATOR3_APP_TOML
sed -i -E 's|0.0.0.0:9090|0.0.0.0:9086|g' $VALIDATOR3_APP_TOML
sed -i -E 's|0.0.0.0:9091|0.0.0.0:9087|g' $VALIDATOR3_APP_TOML
sed -i -E 's|adaptive-fee-enabled = "false"|adaptive-fee-enabled = "true"|g' $VALIDATOR3_APP_TOML
sed -i -E 's|tcp://0.0.0.0:10337|tcp://0.0.0.0:10357|g' $VALIDATOR3_APP_TOML
# # validator4
sed -i -E 's|tcp://0.0.0.0:1317|tcp://0.0.0.0:1314|g' $VALIDATOR4_APP_TOML
sed -i -E 's|0.0.0.0:9090|0.0.0.0:9084|g' $VALIDATOR4_APP_TOML
sed -i -E 's|0.0.0.0:9091|0.0.0.0:9085|g' $VALIDATOR4_APP_TOML
sed -i -E 's|adaptive-fee-enabled = "false"|adaptive-fee-enabled = "true"|g' $VALIDATOR4_APP_TOML
sed -i -E 's|tcp://0.0.0.0:10337|tcp://0.0.0.0:10367|g' $VALIDATOR4_APP_TOML
# change config.toml values
VALIDATOR1_CONFIG=$HOME/.injectived/validator1/config/config.toml
VALIDATOR2_CONFIG=$HOME/.injectived/validator2/config/config.toml
VALIDATOR3_CONFIG=$HOME/.injectived/validator3/config/config.toml
VALIDATOR4_CONFIG=$HOME/.injectived/validator4/config/config.toml
# validator1
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR1_CONFIG
# sed -i -E 's|version = "v0"|version = "v1"|g' $VALIDATOR1_CONFIG
sed -i -E 's|prometheus = false|prometheus = true|g' $VALIDATOR1_CONFIG
# # validator2
sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26655|g' $VALIDATOR2_CONFIG
sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26654|g' $VALIDATOR2_CONFIG
sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26653|g' $VALIDATOR2_CONFIG
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR2_CONFIG
sed -i -E 's|prometheus = false|prometheus = true|g' $VALIDATOR2_CONFIG
sed -i -E 's|prometheus_listen_addr = ":26660"|prometheus_listen_addr = ":26630"|g' $VALIDATOR2_CONFIG
# # validator3
sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26652|g' $VALIDATOR3_CONFIG
sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26651|g' $VALIDATOR3_CONFIG
sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26650|g' $VALIDATOR3_CONFIG
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR3_CONFIG
sed -i -E 's|prometheus = false|prometheus = true|g' $VALIDATOR3_CONFIG
sed -i -E 's|prometheus_listen_addr = ":26660"|prometheus_listen_addr = ":26620"|g' $VALIDATOR3_CONFIG
# # validator4
sed -i -E 's|tcp://127.0.0.1:26658|tcp://127.0.0.1:26649|g' $VALIDATOR4_CONFIG
sed -i -E 's|tcp://127.0.0.1:26657|tcp://127.0.0.1:26648|g' $VALIDATOR4_CONFIG
sed -i -E 's|tcp://0.0.0.0:26656|tcp://0.0.0.0:26647|g' $VALIDATOR4_CONFIG
sed -i -E 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $VALIDATOR4_CONFIG
sed -i -E 's|prometheus = false|prometheus = true|g' $VALIDATOR4_CONFIG
sed -i -E 's|prometheus_listen_addr = ":26660"|prometheus_listen_addr = ":26610"|g' $VALIDATOR4_CONFIG
# copy validator1 genesis file to validator2-4
cp $HOME/.injectived/validator1/config/genesis.json $HOME/.injectived/validator2/config/genesis.json
cp $HOME/.injectived/validator1/config/genesis.json $HOME/.injectived/validator3/config/genesis.json
cp $HOME/.injectived/validator1/config/genesis.json $HOME/.injectived/validator4/config/genesis.json
# copy tendermint node id of validator1 to persistent peers of validator2-4
sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$(injectived tendermint show-node-id --home=$HOME/.injectived/validator1)@localhost:26656\"|g" $HOME/.injectived/validator2/config/config.toml
sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$(injectived tendermint show-node-id --home=$HOME/.injectived/validator1)@localhost:26656\"|g" $HOME/.injectived/validator3/config/config.toml
sed -i -E "s|persistent_peers = \"\"|persistent_peers = \"$(injectived tendermint show-node-id --home=$HOME/.injectived/validator1)@localhost:26656\"|g" $HOME/.injectived/validator4/config/config.toml
# # start all three validators
tmux new -s validator1 -d injectived start --home=$HOME/.injectived/validator1
tmux new -s validator2 -d injectived start --home=$HOME/.injectived/validator2
tmux new -s validator3 -d injectived start --home=$HOME/.injectived/validator3
tmux new -s validator4 -d injectived start --home=$HOME/.injectived/validator4
# injectived tx bank send validator1 $(injectived keys show validator2 -a --keyring-backend=test --home=$HOME/.injectived/validator2) 50000000000stake --keyring-backend=test --home=$HOME/.injectived/validator1 --chain-id=testing-1 --broadcast-mode block --node http://localhost:26657 --yes --fees 1000000stake