-
Notifications
You must be signed in to change notification settings - Fork 4
157 lines (155 loc) · 7.41 KB
/
deploy-gaia-devnet-fresh-state.yml
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
---
name: Deploy gaia-devnet node
concurrency:
group: gaia-devnet-deploy
on:
workflow_dispatch:
push:
jobs:
gaia-devnet-deploy:
runs-on: gaia-devnet-node
environment: gaia-devnet-deploy
env:
SSH_PUB_KEYS: ${{ vars.SSH_PUB_KEYS }}
RPC_NODE: ${{ vars.RPC_NODE }}
# RUNNING_VERSION: ${{ vars.RUNNING_VERSION }}
DEVNET_BRANCH: main
steps:
# Get system info
- name: Install required packages
run: |
sudo apt update
sudo apt dist-upgrade -y
sudo apt -y install python-is-python3 python3-distutils screen curl jq wget python3-venv python3-pip build-essential git psmisc net-tools lz4 pigz
- run: lscpu
- run: df -h
- run: free -m
- run: uname -a
- run: lsb_release -a
- run: echo "GitHub branch is ${{ github.ref }}"
- name: Check out repository code
uses: actions/checkout@v3
- name: Init Python venv
run: python -m venv ~/env
- name: Install dependencies
run: |
source ~/env/bin/activate
python -m pip install --upgrade pip
python -m pip install toml-cli requests
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ vars.GO_VER }}
# Wipe chain
- name: Stop gaiad service
run: sudo systemctl disable --now gaiad
- name: Remove ~/.gaia
run: rm -rf /home/sysadmin/.gaia
- name: Remove repo ~/gaia
run: rm -rf /home/sysadmin/gaia
- name: Remove old artifacts
run: |
sudo rm -rf ~/artifact/
mkdir ~/artifact/
- name: Remove old archives on files.polypore.xyz
run: |
echo "[INFO]: Removing old archives from files.polypore.xyz"
ssh [email protected] rm /var/www/html/gaia-devnet/*.tar.gz || true
echo "<html><head><title>Gaia Devnet Rebuilding...</title></head><body><h1>gaia-devnet is currently rebuilding...</h1></body></html>" > /tmp/status-index.html
scp -6 /tmp/status-index.html [email protected]:/var/www/html/gaia-devnet/index.html
- name: Get current mainnet gaia version
run: |
RUNNING_VERSION=$(curl -s $RPC_NODE/abci_info | jq -r '.result.response.version')
echo "$RUNNING_VERSION"
echo "RUNNING_VERSION=$RUNNING_VERSION" >> $GITHUB_ENV
- name: Build gaiad from source
run: |
cd /home/sysadmin
git clone https://github.com/cosmos/gaia.git
cd gaia
git checkout ${{ env.DEVNET_BRANCH }}
make build
make install
- name: Initializing chain
env:
NODE_HOME: /home/sysadmin/.gaia
NODE_MONIKER: gaia-devnet-val1
SERVICE_NAME: gaia-devnet-val1
CHAIN_ID: gaia-devnet
CHAIN_BINARY: 'gaiad'
GAS_PRICES: "0.0025uatom"
run: |
echo "Initializing $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 config set client broadcast-mode sync --home $NODE_HOME
$CHAIN_BINARY init $NODE_MONIKER --chain-id $CHAIN_ID --home $NODE_HOME
sed -i -e "/minimum-gas-prices =/ s^= .*^= \"$GAS_PRICES\"^" $NODE_HOME/config/app.toml
sed -i -e "/^persistent_peers =/ s^= .*^= \"\"^" $NODE_HOME/config/config.toml
sed -i -e '/enable =/ s/= .*/= false/' $NODE_HOME/config/config.toml
sed -i -e "/trust_height =/ s/= .*/= 0/" $NODE_HOME/config/config.toml
sed -i -e "/trust_hash =/ s/= .*/= \"\"/" $NODE_HOME/config/config.toml
sed -i -e "/rpc_servers =/ s^= .*^= \"\"^" $NODE_HOME/config/config.toml
echo "${{ secrets.PRIV_VALIDATOR_KEY }}" | base64 --decode > $NODE_HOME/config/priv_validator_key.json
echo "${{ secrets.NODE_KEY }}" | base64 --decode > $NODE_HOME/config/node_key.json
pubkey=$(jq -r .pub_key.value $NODE_HOME/config/priv_validator_key.json)
privkey=$(jq -r .priv_key.value $NODE_HOME/config/priv_validator_key.json)
$CHAIN_BINARY genesis gentx validator 10000000000uatom --keyring-backend="test" --home $NODE_HOME --moniker $NODE_MONIKER --chain-id $CHAIN_ID
- name: Start Chain
env:
NODE_HOME: /home/sysadmin/.gaia
CHAIN_BINARY: 'gaiad'
run: sudo systemctl start gaiad
- name: Wait for gaiad to start and stabilize
run: tests/test_block_production.sh 127.0.0.1 26657 50 100000
- name: Stop gaiad
run: |
sudo systemctl stop gaiad
sleep 10
- name: Compress and upload files
run: |
echo "[INFO]: Creating archive ..."
cd /home/sysadmin/.gaia
mv data/priv_validator_state.json ./priv_validator_state.json
echo "${{ vars.PRIV_VALIDATOR_STATE }}" | base64 --decode > data/priv_validator_state.json
tar --use-compress-program="pigz --best --recursive" -cf gaia-devnet-${{ env.upgrade_height }}.tar.gz data wasm
archive_size=$(du -h "gaia-devnet-${{ env.upgrade_height }}.tar.gz" | cut -f1)
echo "[INFO]: Uploading archived state to files.polypore.xyz"
scp -6 gaia-devnet-${{ env.upgrade_height }}.tar.gz [email protected]:/var/www/html/gaia-devnet/
echo "[INFO]: Updating symlink"
ssh [email protected] ln -sf /var/www/html/gaia-devnet/gaia-devnet-${{ env.upgrade_height }}.tar.gz /var/www/html/gaia-devnet/latest.tar.gz
echo "[INFO]: Updating HTML page]"
echo "${{ vars.STATUS_HTML_PAGE }}" | base64 --decode > /tmp/status-index.html
sed -i -e "s/_BIN_VERSION_/${{ env.DEVNET_BRANCH }}/g" /tmp/status-index.html
sed -i -e "s/_ARCHIVE_TARBALL_/gaia-devnet-${{ env.upgrade_height }}.tar.gz/g" /tmp/status-index.html
tarball_size=$(du -h "gaia-devnet-${{ env.upgrade_height }}.tar.gz" | cut -f1)
sed -i -e "s/_TARBALL_SIZE_/$tarball_size/g" /tmp/status-index.html
echo "[INFO]: Uploading HTML page"
scp -6 /tmp/status-index.html [email protected]:/var/www/html/gaia-devnet/index.html
echo "[INFO]: Cleaning up..."
mv ./priv_validator_state.json data/
rm gaia-devnet-${{ env.upgrade_height }}.tar.gz
- name: Build gaiad
run: |
cd /home/sysadmin/gaia
git checkout ${{ env.DEVNET_BRANCH }}
make build
make install
- name: Configure gaiad
run: |
source ~/env/bin/activate
pip install toml-cli
/home/sysadmin/env/bin/toml set --toml-path /home/sysadmin/.gaia/config/app.toml api.enable true
/home/sysadmin/env/bin/toml set --toml-path /home/sysadmin/.gaia/config/app.toml api.swagger true
/home/sysadmin/env/bin/toml set --toml-path /home/sysadmin/.gaia/config/config.toml p2p.seed_mode true
rm /home/sysadmin/.gaia/config/addrbook.json
- name: Start gaiad
run: sudo systemctl enable --now gaiad
- name: Wait for gaiad to start
run: tests/test_block_production.sh 127.0.0.1 26657 20 100
- name: Send faucet tokens
run: |
gaiad tx bank send val ${{ vars.FAUCET_ADDRESS }} 100000000000uatom --from val --gas 20000000 --gas-prices 0.005uatom -y
tests/test_block_production.sh 127.0.0.1 26657 1 10
- name: Query faucet account
run: gaiad q bank balances ${{ vars.FAUCET_ADDRESS }}