wget "https://golang.org/dl/go$VER.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "go$VER.linux-amd64.tar.gz"
rm "go$VER.linux-amd64.tar.gz"
[ ! -f ~/.bash_profile ] && touch ~/.bash_profile
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> ~/.bash_profile
source $HOME/.bash_profile
[ ! -d ~/go/bin ] && mkdir -p ~/go/bin
echo "export WALLET="wallet"" >> $HOME/.bash_profile
echo "export MONIKER="test"" >> $HOME/.bash_profile
echo "export ALLORA_CHAIN_ID="allora-testnet-1"" >> $HOME/.bash_profile
echo "export ALLORA_PORT="27"" >> $HOME/.bash_profile
source $HOME/.bash_profile
git clone https://github.com/allora-network/allora-chain
allorad config keyring-backend os
allorad config chain-id allora-testnet-1
allorad init $MONIKER --chain-id $ALLORA_CHAIN_ID
sed -i -e "s|^node *=.*|node = \"tcp://localhost:${ALLORA_PORT}657\"|" $HOME/.allorad/config/client.toml
# download genesis and addrbook
wget -O $HOME/.allorad/config/genesis.json https://server-3.itrocket.net/testnet/allora/genesis.json
wget -O $HOME/.allorad/config/addrbook.json https://server-3.itrocket.net/testnet/allora/addrbook.json
SEEDS="720d83b52611c64d119adfc4d08d2e85885d8c74@allora-testnet-seed.itrocket.net:27656"
PEERS="a8cde2de31410d896668e53446495a4a68c4c24f@allora-testnet-peer.itrocket.net:27656,6f98707b7cf8e03ceff83ed5343a0aec74b57aed@37.27.53.176:26756,8ba42dc9488a33ca1d709bc4fe8b8662854a695b@65.108.134.47:26756,debfed1b60f8639959a317939f56bd2a5ddae358@185.132.177.83:26656,18fbf5f16f73e216f93304d94e8b79bf5acd7578@15.204.101.152:26656,0f6b64fcd38872d18a78d89e090a5e6928883d52@8.209.116.116:26656,7d548f78f0c67d391279c36fa9e127c52ce8b14c@65.108.225.207:55656,2eb9f5f80d721be2d37ab72c10a7be6aaf7897a4@15.204.101.92:26656,1ec4d1954ce3631274d57a9b60f5ffb5f9e4d841@66.70.177.125:27656,d3c79122924ff477e941ec0ca1ed775cfb01ca20@66.35.84.140:26656,79af04335a0ac10073ef9342edba78e8fb08f9fc@89.58.0.245:37778"
sed -i -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*seeds *=.*/seeds = \"$SEEDS\"/}" \
-e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*persistent_peers *=.*/persistent_peers = \"$PEERS\"/}" $HOME/.allorad/config/config.toml
# set custom ports in app.toml
sed -i.bak -e "s%:1317%:${ALLORA_PORT}317%g;
s%:8080%:${ALLORA_PORT}080%g;
s%:9090%:${ALLORA_PORT}090%g;
s%:9091%:${ALLORA_PORT}091%g;
s%:8545%:${ALLORA_PORT}545%g;
s%:8546%:${ALLORA_PORT}546%g;
s%:6065%:${ALLORA_PORT}065%g" $HOME/.allorad/config/app.toml
# set custom ports in config.toml file
sed -i.bak -e "s%:26658%:${ALLORA_PORT}658%g;
s%:26657%:${ALLORA_PORT}657%g;
s%:6060%:${ALLORA_PORT}060%g;
s%:26656%:${ALLORA_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${ALLORA_PORT}656\"%;
s%:26660%:${ALLORA_PORT}660%g" $HOME/.allorad/config/config.toml
sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.allorad/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.allorad/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"50\"/" $HOME/.allorad/config/app.toml
# set minimum gas price, enable prometheus and disable indexing
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0uallo"|g' $HOME/.allorad/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.allorad/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.allorad/config/config.toml
sudo tee /etc/systemd/system/allorad.service > /dev/null <<EOF
After=network-online.target
WorkingDirectory=$HOME/.allorad
ExecStart=$(which allorad) start --home $HOME/.allorad
WantedBy=multi-user.target
# reset and download snapshot
allorad tendermint unsafe-reset-all --home $HOME/.allorad
curl https://server-3.itrocket.net/testnet/allora/allora_2024-09-02_966455_snap.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.allorad
# enable and start service
sudo systemctl daemon-reload
sudo systemctl enable allorad
sudo systemctl restart allorad && sudo journalctl -u allorad -f