-
Notifications
You must be signed in to change notification settings - Fork 7
/
createvalidatorsystemd.sh
336 lines (272 loc) · 12 KB
/
createvalidatorsystemd.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
read -p "Do you need to create your validator, answer yes or no: " createvalidator
while [[ "$createvalidator" != @(yes|no) ]]; do
read wishtocreate
done
if [[ "$createvalidator" == "yes" ]]; then
echo "Checking if node is on latest block"
catchingup=$(jq -r '.result.sync_info.catching_up' <<<$(curl -s "http://localhost:26657/status"))
while [[ $catchingup == "true" ]]; do
echo "Your node is NOT fully synced yet"
echo "we'll wait 30s and retry"
echo "check blockheigt on explorer and on node, if it differs to much ctrl-c and wait patiently"
echo "check blockheight on node with curl -s "http://localhost:26657/status" | jq -r '.result.sync_info' "
echo
sleep 30
catchingup=$(jq -r '.result.sync_info.catching_up' <<<$(curl -s "http://localhost:26657/status"))
done
echo "Node is on latest block"
echo
if [ -z $MONIKER ]; then
echo "Please enter Moniker name below"
read -p "Enter Moniker name :" MONIKER
fi
if [ -z "$NETWORK" ];then
read -p "Enter network, testnet or mainnet :" NETWORK
fi
read -p "Enter your KEYRING PASSWORD : " KEYRING
denom=uaxl
broadcaster=$(tail $HOME/broadcaster.txt | grep address | cut -f2 -d ":")
validator=$(tail $HOME/validator.txt | grep address | cut -f2 -d ":")
# Determining Axelar versions
echo "Determining Axelar version"
CORE_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep axelar-core | cut -d \` -f 4)
echo ${CORE_VERSION}
echo "Determining Vald version"
VALD_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep vald | cut -d \` -f 4)
echo ${VALD_VERSION}
echo "Determining Tofnd version"
TOFND_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep tofnd | cut -d \` -f 4)
echo ${TOFND_VERSION}
echo
if [ "$NETWORK" == testnet ]; then
echo "Setup node for axelar testnet"
echo "Determining testnet chain"
CHAIN_ID=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelarate-community/main/scripts/node.sh | grep chain_id=axelar-t | cut -f2 -d "=")
NETWORKPATH=".axelar_testnet"
else
echo "Setup node for axelar mainnet"
echo "Determining mainnet chain"
CHAIN_ID=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelarate-community/main/scripts/node.sh | grep chain_id=axelar-d | cut -f2 -d "=")
NETWORKPATH=".axelar"
fi
echo "Setup validator tools"
echo
echo "-->setup TOFND service"
sudo bash -c "cat > /etc/systemd/system/tofnd.service << EOF
[Unit]
Description=tofnd
After=network-online.target
[Service]
User=$USER
ExecStart=/bin/sh -c 'echo $KEYRING | tofnd -m existing -d $HOME/$NETWORKPATH/.tofnd'
Restart=always
RestartSec=3
LimitNOFILE=16384
MemoryMax=4G
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
EOF"
echo
echo "--> enable and start tofnd service"
sudo systemctl enable tofnd.service
sudo systemctl start tofnd.service
echo "--> setup vald service"
(cat $HOME/broadcaster.txt | tail -1 ; echo $KEYRING ; echo $KEYRING) | axelard keys add broadcaster --recover --home $HOME/$NETWORKPATH/.vald
cp $HOME/$NETWORKPATH/.core/config/config.toml $HOME/$NETWORKPATH/.vald/config/config.toml
cp $HOME/$NETWORKPATH/.core/config/app.toml $HOME/$NETWORKPATH/.vald/config/app.toml
cp $HOME/$NETWORKPATH/.core/config/genesis.json $HOME/$NETWORKPATH/.vald/config/genesis.json
valoper=$(echo $KEYRING | axelard keys show validator --home $HOME/$NETWORKPATH/.core --bech val -a)
sudo bash -c "cat > /etc/systemd/system/axelard-val.service << EOF
[Unit]
Description=axelard-val
After=network-online.target
[Service]
User=$USER
ExecStart=/bin/sh -c 'echo $KEYRING | vald vald-start --tofnd-host localhost --node http://localhost:26657 --home $HOME/$NETWORKPATH/.vald --validator-addr $valoper --log_level debug --chain-id $CHAIN_ID --from broadcaster'
Restart=always
RestartSec=3
LimitNOFILE=16384
MemoryMax=4G
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
EOF"
echo
echo "--> enable and start vald services"
sudo systemctl enable axelard-val.service
sudo systemctl start axelard-val.service
echo "done"
echo
echo "Register proxy for validator"
echo $KEYRING | axelard tx snapshot register-proxy $broadcaster --from validator --home $HOME/$NETWORKPATH/.core --chain-id $CHAIN_ID -y
echo "creating a validator"
balance=$(echo $KEYRING | axelard q bank balances $validator | grep amount | cut -d '"' -f 2)
echo "Current validator balance is: $balance"
echo "Leave some balance to pay for fees"
read -p "Amount of selfstake axltest example: 1000000 (without ${denom}) : " uaxl
read -p "Enter validator details : " details
axelarvalconspub=$(echo $KEYRING | axelard tendermint show-validator --home $HOME/$NETWORKPATH/.core)
echo $KEYRING | axelard tx staking create-validator --yes --amount "${uaxl}${denom}" --moniker "$MONIKER" --commission-rate="0.10" --commission-max-rate="0.20" --commission-max-change-rate="0.01" --min-self-delegation="1" --pubkey=$axelarvalconspub --home $HOME/$NETWORKPATH/.core --chain-id $CHAIN_ID --details "$details" --from validator -b block
echo "done"
echo
echo "Adding chainmaintainers"
echo
echo "Notice: every chain requires an own entry"
echo "If a wrong address is send in, your node won't come up"
echo
read -p "Do you want to add ethereum as a chain-maintainer, answer yes or no: " ethereum
while [[ "$ethereum" != @(yes|no) ]]; do
read wishtocreate
done
if [[ "$ethereum" == "yes" ]]; then
# setting up eth rpc
sed -i '/^name = "Ethereum"/{n;N;d}' $HOME/$NETWORKPATH/.core/config/config.toml
read -p "Type in your ETH Ropsten node address: " eth
sed -i "/^name = \"Ethereum\"/a rpc_addr = \"$eth\"\nstart-with-bridge = true" $HOME/$NETWORKPATH/.core/config/config.toml
echo
echo "eth bridge enabled"
echo
ethereum=ethereum
fi
read -p "Do you want to add Avalanche as a chain-maintainer, answer yes or no: " avalanche
while [[ "$avalanche" != @(yes|no) ]]; do
read wishtocreate
done
if [[ "$avalanche" == "yes" ]]; then
# setting up Avalanche rpc
sed -i '/^name = "Avalanche"/{n;N;d}' $HOME/$NETWORKPATH/.core/config/config.toml
read -p "Type in your Avalanche node address: " avax
sed -i "/^name = \"Avalanche\"/a rpc_addr = \"$avax\"\nstart-with-bridge = true" $HOME/$NETWORKPATH/.core/config/config.toml
echo
echo "Avalanche bridge enabled"
echo
avalanche=avalanche
fi
read -p "Do you want to add Fantom as a chain-maintainer, answer yes or no: " fantom
while [[ "$fantom" != @(yes|no) ]]; do
read wishtocreate
done
if [[ "$fantom" == "yes" ]]; then
# setting up Fantom rpc
sed -i '/^name = "Fantom"/{n;N;d}' $HOME/$NETWORKPATH/.core/config/config.toml
read -p "Type in your Fantom node address: " fantom
sed -i "/^name = \"Fantom\"/a rpc_addr = \"$fantom\"\nstart-with-bridge = true" $HOME/$NETWORKPATH/.core/config/config.toml
echo
echo "Fantom bridge enabled"
echo
fantom=fantom
fi
read -p "Do you want to add Moonbeam as a chain-maintainer, answer yes or no: " moonbeam
while [[ "$moonbeam" != @(yes|no) ]]; do
read wishtocreate
done
if [[ "$moonbeam" == "yes" ]]; then
# setting up Moonbeam rpc
sed -i '/^name = "Moonbeam"/{n;N;d}' $HOME/$NETWORKPATH/.core/config/config.toml
read -p "Type in your Moonbeam node address: " moonbeam
sed -i "/^name = \"Moonbeam\"/a rpc_addr = \"$moonbeam\"\nstart-with-bridge = true" $HOME/$NETWORKPATH/.core/config/config.toml
echo
echo "Moonbeam bridge enabled"
echo
moonbeam=moonbeam
fi
read -p "Do you want to add Polygon as a chain-maintainer, answer yes or no: " polygon
while [[ "$polygon" != @(yes|no) ]]; do
read wishtocreate
done
if [[ "$polygon" == "yes" ]]; then
# setting up Polygon rpc
sed -i '/^name = "Polygon"/{n;N;d}' $HOME/$NETWORKPATH/.core/config/config.toml
read -p "Type in your Polygon node address: " polygon
sed -i "/^name = \"Polygon\"/a rpc_addr = \"$polygon\"\nstart-with-bridge = true" $HOME/$NETWORKPATH/.core/config/config.toml
echo
echo "Polygon bridge enabled"
echo
polygon=polygon
fi
read -p "Do you want to add binance as a chain-maintainer, answer yes or no: " binance
while [[ "$binance" != @(yes|no) ]]; do
read wishtocreate
done
if [[ "$binance" == "yes" ]]; then
# setting up binance rpc
sed -i '/^name = "binance"/{n;N;d}' $HOME/$NETWORKPATH/.core/config/config.toml
read -p "Type in your binance node address: " binance
sed -i "/^name = \"binance\"/a rpc_addr = \"$binance\"\nstart-with-bridge = true" $HOME/$NETWORKPATH/.core/config/config.toml
echo
echo "binance bridge enabled"
echo
binance=binance
fi
read -p "Do you want to add aurora as a chain-maintainer, answer yes or no: " aurora
while [[ "$aurora" != @(yes|no) ]]; do
read wishtocreate
done
if [[ "$aurora" == "yes" ]]; then
# setting up aurora rpc
sed -i '/^name = "aurora"/{n;N;d}' $HOME/$NETWORKPATH/.core/config/config.toml
read -p "Type in your aurora node address: " aurora
sed -i "/^name = \"aurora\"/a rpc_addr = \"$aurora\"\nstart-with-bridge = true" $HOME/$NETWORKPATH/.core/config/config.toml
echo
echo "aurora bridge enabled"
echo
aurora=aurora
fi
echo "copy config to vald dir"
cp $HOME/$NETWORKPATH/.core/config/config.toml $HOME/$NETWORKPATH/.vald/config/config.toml
echo "restarting vald and tofnd"
sudo systemctl restart axelard-val.service
sudo systemctl restart tofnd.service
echo "chain maintainers startup"
if [[ "$ethereum" == "ethereum" ]]; then
echo "active"
echo $KEYRING | vald tx nexus register-chain-maintainer ethereum --from broadcaster --node http://localhost:26657 --gas auto --gas-adjustment 1.2 --chain-id $CHAIN_ID --home $HOME/$NETWORKPATH/.vald
else
echo "ethereum not maintained"
fi
if [[ "$avalanche" == "avalanche" ]]; then
echo "active"
echo $KEYRING | vald tx nexus register-chain-maintainer avalanche --from broadcaster --node http://localhost:26657 --gas auto --gas-adjustment 1.2 --chain-id $CHAIN_ID --home $HOME/$NETWORKPATH/.vald
else
echo "avalanche not maintained"
fi
if [[ "$fantom" == "fantom" ]]; then
echo "active"
echo $KEYRING | vald tx nexus register-chain-maintainer fantom --from broadcaster --node http://localhost:26657 --gas auto --gas-adjustment 1.2 --chain-id $CHAIN_ID --home $HOME/$NETWORKPATH/.vald
else
echo "fantom not maintained"
fi
if [[ "$moonbeam" == "moonbeam" ]]; then
echo "active"
echo $KEYRING | vald tx nexus register-chain-maintainer moonbeam --from broadcaster --node http://localhost:26657 --gas auto --gas-adjustment 1.2 --chain-id $CHAIN_ID --home $HOME/$NETWORKPATH/.vald
else
echo "moonbeam not maintained"
fi
if [[ "$polygon" == "polygon" ]]; then
echo "active"
echo $KEYRING | vald tx nexus register-chain-maintainer polygon --from broadcaster --node http://localhost:26657 --gas auto --gas-adjustment 1.2 --chain-id $CHAIN_ID --home $HOME/$NETWORKPATH/.vald
else
echo "polygon not maintained"
fi
if [[ "$binance" == "binance" ]]; then
echo "active"
echo $KEYRING | vald tx nexus register-chain-maintainer binance --from broadcaster --node http://localhost:26657 --gas auto --gas-adjustment 1.2 --chain-id $CHAIN_ID --home $HOME/$NETWORKPATH/.vald
else
echo "binance not maintained"
fi
if [[ "$aurora" == "aurora" ]]; then
echo "active"
echo $KEYRING | vald tx nexus register-chain-maintainer aurora --from broadcaster --node http://localhost:26657 --gas auto --gas-adjustment 1.2 --chain-id $CHAIN_ID --home $HOME/$NETWORKPATH/.vald
else
echo "aurora not maintained"
fi
echo "chain maintainers enabled"
echo "Validator completely enabled"
echo "please check explorer or do health check to determine host status"
echo "done"
else
echo "Default node setup completed"
echo "done"
exit 1
fi