-
Notifications
You must be signed in to change notification settings - Fork 102
/
HAQQ
200 lines (162 loc) · 6.03 KB
/
HAQQ
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
#!/bin/bash
while true
do
# Logo
echo "=================================================="
echo -e "\e[0m"
echo " _ __ __ ___ __ __ ";
echo " / |/ /__ ___/ /__ ___ / _ )/ /__ ____/ /__ ___";
echo " / / _ \/ _ / -_|_-</ _ / / _ \/ __/ '_/(_-<";
echo "/_/|_/\___/\_,_/\__/___/____/_/\___/\__/_/\_\/___/";
echo " ";
echo -e "\e[0m"
echo "=================================================="
echo -e "\e[0m"
echo -e '\e[36mWebsite:\e[39m' https://nodesblocks.dev
echo -e '\e[36mTwitter:\e[39m' https://twitter.com/nodesblocks
echo -e '\e[36mGithub:\e[39m' https://github.com/NodesBlocks
echo -e "\e[0m"
# Menu
PS3='Select an action: '
options=(
"Install node"
"Check logs"
"Check balance"
"Sync via stateSync"
"Request tokens"
"Create validator"
"Exit")
select opt in "${options[@]}"
do
case $opt in
"Install node")
echo "============================================================"
echo "Your Node Name:"
echo "============================================================"
read NODENAME
echo "============================================================"
echo "Your Wallet Name:"
echo "============================================================"
read WALLETNAME
echo export NODENAME=${NODENAME} >> $HOME/.bash_profile
echo export WALLETNAME=${WALLETNAME} >> $HOME/.bash_profile
echo export CHAIN_ID="haqq_53211-1" >> $HOME/.bash_profile
source ~/.bash_profile
#UPDATE APT
sudo apt update && sudo apt upgrade -y
sudo apt install curl tar wget clang pkg-config libssl-dev jq build-essential bsdmainutils git make ncdu gcc git jq chrony liblz4-tool -y
#INSTALL GO
rm -r /usr/local/go
rm -r /usr/lib/go-1.13
wget https://golang.org/dl/go1.18.3.linux-amd64.tar.gz; \
rm -rv /usr/local/go; \
tar -C /usr/local -xzf go1.18.3.linux-amd64.tar.gz && \
rm -v go1.18.3.linux-amd64.tar.gz && \
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile && \
source ~/.bash_profile && \
go version
rm -rf $HOME/haqq $HOME/.haqqd
#INSTALL
cd $HOME && \
git clone -b v1.0.3 https://github.com/haqq-network/haqq && \
cd haqq && \
make install
haqqd init $NODENAME --chain-id $CHAIN_ID
echo "============================================================"
echo "Save your mnemonic !"
echo "============================================================"
#WALLET
haqqd keys add $WALLETNAME
haqqd tendermint unsafe-reset-all --home $HOME/.haqqd
rm $HOME/.haqqd/config/genesis.json
wget -O $HOME/.haqqd/config/genesis.json "https://storage.googleapis.com/haqq-testedge-snapshots/genesis.json"
wget -O $HOME/.haqqd/config/addrbook.json "https://raw.githubusercontent.com/NodesBlocks/Haqq-Network/main/addrbook.json"
SEEDS="[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656"
PEERS=""; \
sed -i.bak -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.haqqd/config/config.toml
# config pruning
indexer="null"
pruning="custom"
pruning_keep_recent="100"
pruning_keep_every="0"
pruning_interval="10"
sed -i -e "s/^indexer *=.*/indexer = \"$indexer\"/" $HOME/.haqqd/config/config.toml
sed -i -e "s/^pruning *=.*/pruning = \"$pruning\"/" $HOME/.haqqd/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" $HOME/.haqqd/config/app.toml
sed -i -e "s/^pruning-keep-every *=.*/pruning-keep-every = \"$pruning_keep_every\"/" $HOME/.haqqd/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" $HOME/.haqqd/config/app.toml
tee $HOME/haqqd.service > /dev/null <<EOF
[Unit]
Description=haqq
After=network.target
[Service]
Type=simple
User=$USER
ExecStart=$(which haqqd) start
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo mv $HOME/haqqd.service /etc/systemd/system/
# start service
sudo systemctl daemon-reload
sudo systemctl enable haqqd
sudo systemctl restart haqqd
break
;;
"Check logs")
journalctl -u haqqd -f -o cat
break
;;
"Check balance")
haqqd q bank balances $(haqqd keys show $WALLETNAME -a --bech acc)
break
;;
"Sync via stateSync")
SNAP_RPC="http://65.108.206.56:39658"
peers="[email protected]:41656"
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" $HOME/.haqqd/config/config.toml
LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \
BLOCK_HEIGHT=$((LATEST_HEIGHT - 500)); \
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH
sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"| ; \
s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" $HOME/.haqqd/config/config.toml
haqqd tendermint unsafe-reset-all --home $HOME/.haqqd
wget -O $HOME/.haqqd/config/addrbook.json "https://raw.githubusercontent.com/NodesBlocks/Haqq-Network/main/addrbook.json"
systemctl restart haqqd && journalctl -u haqqd -f -o cat
break
;;
"Create validator")
haqqd tx staking create-validator \
--amount 1000000000000000000aISLM \
--from $WALLETNAME \
--commission-max-change-rate "0.05" \
--commission-max-rate "0.20" \
--commission-rate "0.05" \
--min-self-delegation "1" \
--pubkey $(haqqd tendermint show-validator) \
--moniker $NODENAME \
--chain-id $CHAIN_ID \
--gas 300000 \
-y
break
;;
"Request tokens")
echo "========================================================================================================================"
echo "Use Haqq discord faucet or check Hass docs"
echo "========================================================================================================================"
break
;;
"Exit")
exit
;;
*) echo "invalid option $REPLY";;
esac
done
done