-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathjoin-provider.sh
More file actions
145 lines (128 loc) · 5.94 KB
/
join-provider.sh
File metadata and controls
145 lines (128 loc) · 5.94 KB
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
#!/bin/bash
# Set up a Gaia service to join the provider chain.
# Configuration
# You should only have to modify the values in this block
# * Keys
# The private validator key and node key operations are provided in case you have a pre-existing set of keys.
# If you want to generate these keys as part of the setup, comment out the "Replace keys" section.
# * Binary
# The binary for the amd64 architecture is set by default.
# If you are using a different architecture, visit the gaia releases page for an adequate link.
# If you want to build from source, uncomment the "or install from source" section
# ***
PRIV_VALIDATOR_KEY_FILE=~/priv_validator_key.json
NODE_KEY_FILE=~/node_key.json
NODE_HOME=~/.gaia
NODE_MONIKER=provider
SERVICE_NAME=provider
GAIA_VERSION=v27.1.0-rc0
CHAIN_BINARY_URL=https://github.com/cosmos/gaia/releases/download/$GAIA_VERSION/gaiad-$GAIA_VERSION-linux-amd64
STATE_SYNC=true
GAS_PRICE=0.005uatom
# ***
CHAIN_BINARY='gaiad'
CHAIN_ID=provider
GENESIS_URL=https://raw.githubusercontent.com/cosmos/testnets/refs/heads/master/provider/provider-genesis.json
SEEDS="08ec17e86dac67b9da70deb20177655495a55407@provider-seed-01.hub-testnet.polypore.xyz:26656,4ea6e56300a2f37b90e58de5ee27d1c9065cf871@provider-seed-02.hub-testnet.polypore.xyz:26656"
SYNC_RPC_1=https://rpc.provider-state-sync-01.hub-testnet.polypore.xyz:443
SYNC_RPC_2=https://rpc.provider-state-sync-02.hub-testnet.polypore.xyz:443
SYNC_RPC_SERVERS="$SYNC_RPC_1,$SYNC_RPC_2"
SNAPSHOT_URL=https://snapshots.polypore.xyz/hub-testnet/provider/latest.tar.gz
SNAPSHOT=false
for i in "$@"; do
case $i in
-s|--snapshot)
SNAPSHOT=true
STATE_SYNC=false
;;
esac
done
# Install wget and jq
sudo apt-get install curl jq wget -y
mkdir -p $HOME/go/bin
export PATH=$PATH:$HOME/go/bin
# Install Gaia binary
echo "Installing Gaia..."
# Build from source,
## Install go 1.24.3
echo "Installing go..."
rm go*linux-amd64.tar.gz
wget https://go.dev/dl/go1.25.7.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
echo "Installing build-essential..."
sudo apt install build-essential -y
echo "Installing Gaia..."
cd $HOME
rm -rf gaia
git clone https://github.com/cosmos/gaia.git
cd gaia
git checkout $GAIA_VERSION
make install
# or download Linux amd64 (unsupported)
# wget $CHAIN_BINARY_URL -O $HOME/go/bin/$CHAIN_BINARY
# chmod +x $HOME/go/bin/$CHAIN_BINARY
# Initialize home directory
echo "Initializing $NODE_HOME..."
rm -rf $NODE_HOME
$CHAIN_BINARY config set client chain-id $CHAIN_ID --home $NODE_HOME
$CHAIN_BINARY config set client keyring-backend test --home $NODE_HOME
$CHAIN_BINARY init $NODE_MONIKER --chain-id $CHAIN_ID --home $NODE_HOME
sed -i -e "/minimum-gas-prices =/ s^= .*^= \"$GAS_PRICE\"^" $NODE_HOME/config/app.toml
sed -i -e "/seeds =/ s^= .*^= \"$SEEDS\"^" $NODE_HOME/config/config.toml
# Replace keys
echo "Replacing keys and genesis file..."
cp $PRIV_VALIDATOR_KEY_FILE $NODE_HOME/config/priv_validator_key.json
cp $NODE_KEY_FILE $NODE_HOME/config/node_key.json
if [ $STATE_SYNC == "true" ]; then
echo "Configuring state sync..."
CURRENT_BLOCK=$(curl -s $SYNC_RPC_1/block | jq -r '.result.block.header.height')
TRUST_HEIGHT=$[$CURRENT_BLOCK-1000]
TRUST_BLOCK=$(curl -s $SYNC_RPC_1/block\?height\=$TRUST_HEIGHT)
TRUST_HASH=$(echo $TRUST_BLOCK | jq -r '.result.block_id.hash')
sed -i -e '/enable =/ s/= .*/= true/' $NODE_HOME/config/config.toml
sed -i -e '/trust_period =/ s/= .*/= "8h0m0s"/' $NODE_HOME/config/config.toml
sed -i -e "/trust_height =/ s/= .*/= $TRUST_HEIGHT/" $NODE_HOME/config/config.toml
sed -i -e "/trust_hash =/ s/= .*/= \"$TRUST_HASH\"/" $NODE_HOME/config/config.toml
sed -i -e "/rpc_servers =/ s^= .*^= \"$SYNC_RPC_SERVERS\"^" $NODE_HOME/config/config.toml
else
echo "Skipping state sync..."
fi
if [ $SNAPSHOT == "true" ]; then
echo "Downloading snapshot..."
rm -rf $NODE_HOME/wasm $NODE_HOME/data
curl $SNAPSHOT_URL
curl -o - -L $SNAPSHOT_URL | tar vxz -C $NODE_HOME
else
echo "Skipping download snapshot..."
fi
# Replace genesis file
wget $GENESIS_URL -O genesis.json
mv genesis.json $NODE_HOME/config/genesis.json
sudo rm /etc/systemd/system/$SERVICE_NAME.service
sudo touch /etc/systemd/system/$SERVICE_NAME.service
echo "[Unit]" | sudo tee /etc/systemd/system/$SERVICE_NAME.service
echo "Description=Gaia service" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "After=network-online.target" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "[Service]" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "User=$USER" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "ExecStart=$HOME/go/bin/$CHAIN_BINARY start --home $NODE_HOME" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "Restart=no" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "LimitNOFILE=4096" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "[Install]" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
echo "WantedBy=multi-user.target" | sudo tee /etc/systemd/system/$SERVICE_NAME.service -a
# Start service
echo "Starting $SERVICE_NAME.service..."
sudo systemctl daemon-reload
sudo systemctl enable $SERVICE_NAME.service
sudo systemctl start $SERVICE_NAME.service
sudo systemctl restart systemd-journald
# Add go and gaiad to the path
echo "Setting up paths for go and cosmovisor current bin..."
echo "export PATH=$PATH:/usr/local/go/bin" >> .profile
echo "***********************"
echo "To see the Gaia log enter:"
echo "journalctl -fu $SERVICE_NAME.service"
echo "***********************"