diff --git a/.github/workflows/statesync.yml b/.github/workflows/statesync.yml new file mode 100644 index 00000000000..71642ab7c16 --- /dev/null +++ b/.github/workflows/statesync.yml @@ -0,0 +1,19 @@ +# This is a basic workflow that is manually triggered + +name: State Sync + +# Controls when the action will run. Workflow runs when manually triggered using the UI +# or API. +on: [workflow_dispatch] + +# This workflow makes x86_64 binaries for mac, windows, and linux. + +jobs: + build: + runs-on: ubuntu-latest + name: osmosis state sync + steps: + - uses: actions/checkout@v2 + + - name: state sync + run: bash scripts/statesync.sh diff --git a/scripts/statesync.sh b/scripts/statesync.sh new file mode 100644 index 00000000000..3c71cfd9393 --- /dev/null +++ b/scripts/statesync.sh @@ -0,0 +1,37 @@ + +#!/bin/bash +# microtick and bitcanna contributed significantly here. +set -e + +export GOPATH=~/go +export PATH=$PATH:~/go/bin +go install ./... + + +# MAKE HOME FOLDER AND GET GENESIS +osmosisd init test +wget -O ~/.osmosisd/config/genesis.json https://cloudflare-ipfs.com/ipfs/QmXRvBT3hgoXwwPqbK6a2sXUuArGM8wPyo1ybskyyUwUxs + +INTERVAL=1500 + +# GET TRUST HASH AND TRUST HEIGHT + +LATEST_HEIGHT=$(curl -s 162.55.132.230:2001/block | jq -r .result.block.header.height); +BLOCK_HEIGHT=$(($LATEST_HEIGHT-$INTERVAL)) +TRUST_HASH=$(curl -s "162.55.132.230:2001/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) + + +# TELL USER WHAT WE ARE DOING +echo "TRUST HEIGHT: $BLOCK_HEIGHT" +echo "TRUST HASH: $TRUST_HASH" + + +# export state sync vars +export OSMOSISD_STATESYNC_ENABLE=true +export OSMOSISD_STATESYNC_RPC_SERVERS="162.55.132.230:2001,162.55.132.230:2001" +export OSMOSISD_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT +export OSMOSISD_STATESYNC_TRUST_HASH=$TRUST_HASH +export OSMOSISD_P2P_PERSISTENT_PEERS="40aafcd9b6959d58dd1c567d9daf2a82a23311cf@162.55.132.230:2000" + +osmosisd unsafe-reset-all +osmosisd start