Skip to content

Commit

Permalink
snapshot sync
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanchez committed Jan 3, 2025
1 parent fd58697 commit 12496ab
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 10 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/upgrade-gaia-v22-serviceless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,6 @@
# echo "$HOME_1/cosmovisor/current/bin" >> $GITHUB_PATH
- name: Start chain
run: |
# source scripts/vars.sh
# echo "CHAIN_VERSION=$START_VERSION" >> $GITHUB_ENV
# echo "CHAIN_BINARY_URL=https://github.com/cosmos/gaia/releases/download/$START_VERSION/gaiad-$START_VERSION-linux-amd64" >> $GITHUB_ENV
echo "Start version: $START_VERSION"
echo "Binary URL: $CHAIN_BINARY_URL"
scripts/setup.sh
Expand All @@ -318,11 +315,9 @@
tail -n 100 log_001
- name: Confirm chain is online
run: |
# source scripts/vars.sh
scripts/wait_for_block.sh 3
- name: Confirm all validators are signing
run: |
# source scripts/vars.sh
scripts/check_signatures.sh
- name: Load state
Expand All @@ -337,14 +332,12 @@
env:
DOWNLOAD_URL: https://github.com/cosmos/gaia/releases/download/${{ matrix.upgrade_version }}/gaiad-${{ matrix.upgrade_version }}-linux-amd64
run: |
# source scripts/vars.sh
echo "UPGRADE_VERSION=${{ matrix.upgrade_version }}" >> $GITHUB_ENV
echo "UPGRADE_BINARY_URL=https://github.com/cosmos/gaia/releases/download/$UPGRADE_VERSION/gaiad-$UPGRADE_VERSION-linux-amd64" >> $GITHUB_ENV
scripts/upgrade.sh
- name: Test software upgrade for main branch
if: ${{ matrix.upgrade_version == 'main' }}
run: |
# source scripts/vars.sh
echo "UPGRADE_VERSION=${{ matrix.upgrade_version }}" >> $GITHUB_ENV
# echo "UPGRADE_BINARY_URL=https://github.com/cosmos/gaia/releases/download/$UPGRADE_VERSION/gaiad-$UPGRADE_VERSION-linux-amd64" >> $GITHUB_ENV
# echo "UPGRADE_BINARY_SOURCE=BUILD" >> $GITHUB_ENV
Expand All @@ -353,18 +346,19 @@
- name: Confirm chain is online
run: |
# source scripts/vars.sh
height=$(curl -s http://localhost:${rpc_prefix}001/block | jq -r .result.block.header.height)
target_height=$(($height+5))
scripts/wait_for_block.sh $target_height
- name: Confirm all validators are signing
run: |
# source scripts/vars.sh
scripts/check_signatures.sh
- name: Test snapshot sync
run: |
tests/test_snapshot_sync.sh
- name: Test state sync
run: |
# source scripts/vars.sh
scripts/setup_state_sync_node.sh
tests/test_state_sync.sh
Expand Down
89 changes: 89 additions & 0 deletions tests/test_snapshot_sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
echo "> Creating arrays"

monikers=()
homes=()
api_ports=()
rpc_ports=()
p2p_ports=()
grpc_ports=()
pprof_ports=()
logs=()
for i in $(seq -w 001 $validator_count)
do
moniker=$moniker_prefix$i
monikers+=($moniker)
home=$home_prefix$i
homes+=($home)
api_port=$api_prefix$i
api_ports+=($api_port)
rpc_port=$rpc_prefix$i
rpc_ports+=($rpc_port)
p2p_port=$p2p_prefix$i
p2p_ports+=($p2p_port)
grpc_port=$grpc_prefix$i
grpc_ports+=($grpc_port)
pprof_port=$pprof_prefix$i
pprof_ports+=($pprof_port)
log=$log_prefix$i
logs+=($log)
done

home=.nodesync
rpc_port=${rpc_prefix}999
api_port=${api_prefix}999
p2p_port=${p2p_prefix}999
grpc_port=${grpc_prefix}999
pprof_port=${pprof_prefix}999
log=${log_prefix}999

rm -rf $home
echo "> Creating home"
$CHAIN_BINARY config set client chain-id $CHAIN_ID --home $home
$CHAIN_BINARY config set client keyring-backend test --home $home
$CHAIN_BINARY config set client broadcast-mode sync --home $home
$CHAIN_BINARY config set client node tcp://localhost:$rpc_port --home $home
$CHAIN_BINARY init nodesync --chain-id $CHAIN_ID --home $home &> /dev/null

echo "> Copying genesis"
cp ${homes[0]}/config/genesis.json $home/config/genesis.json

toml set --toml-path $home/config/app.toml minimum-gas-prices "$GAS_PRICE"
toml set --toml-path $home/config/app.toml api.enable true
toml set --toml-path $home/config/app.toml api.enabled-unsafe-cors true
toml set --toml-path $home/config/app.toml api.address "tcp://0.0.0.0:$api_port"
toml set --toml-path $home/config/app.toml grpc.address "0.0.0.0:$grpc_port"
toml set --toml-path $home/config/app.toml grpc-web.enable false

echo "> Configuring config.toml"
node_id=$($CHAIN_BINARY tendermint show-node-id --home ${homes[-1]})
peer="$node_id@127.0.0.1:${p2p_ports[-1]}"
toml set --toml-path $home/config/config.toml rpc.laddr "tcp://0.0.0.0:$rpc_port"
toml set --toml-path $home/config/config.toml rpc.pprof_laddr "0.0.0.0:$pprof_port"
toml set --toml-path $home/config/config.toml p2p.laddr "tcp://0.0.0.0:$p2p_port"
sed -i -e '/addr_book_strict =/ s/= .*/= false/' $home/config/config.toml
sed -i -e '/allow_duplicate_ip =/ s/= .*/= true/' $home/config/config.toml
toml set --toml-path $home/config/config.toml block_sync false
toml set --toml-path $home/config/config.toml consensus.timeout_commit "${TIMEOUT_COMMIT}s"
toml set --toml-path $home/config/config.toml p2p.persistent_peers "$peer"

echo "> Copying data folder"
./stop.sh
cp $home/data/priv_validator_state.json ./
cp -r ${homes[-1]}/data $home/data
cp ./priv_validator_state.json $home/data/
./start.sh

echo "> Starting snapshot sync node"
tmux new-session -d -s snapshot "$CHAIN_BINARY start --home $home 2>&1 | tee $log"

sleep 120
catching_up=$(curl -s http://localhost:$rpc_port/status | jq -r .result.sync_info.catching_up)
echo "> Catching up: $catching_up"

tmux send-keys -t snapshot C-c

if [ $catching_up != "false" ]; then
echo "Node did not sync."
exit 1
fi
2 changes: 2 additions & 0 deletions tests/test_state_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ p2p_port=${p2p_prefix}999
grpc_port=${grpc_prefix}999
pprof_port=${pprof_prefix}999
log=${log_prefix}999

rm -rf $home
echo "> Creating home"
$CHAIN_BINARY config set client chain-id $CHAIN_ID --home $home
$CHAIN_BINARY config set client keyring-backend test --home $home
Expand Down

0 comments on commit 12496ab

Please sign in to comment.