Skip to content

Commit

Permalink
Merge pull request #121 from White-Whale-Defi-Platform/hoang/state-sync
Browse files Browse the repository at this point in the history
Hoang/state sync
  • Loading branch information
faddat authored Mar 18, 2023
2 parents 5155c0d + 595676d commit b29b978
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 10 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/verify_state.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Verify Statesync

on: [push, pull_request]

jobs:
verify_statesync:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up shell
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Run verify.sh script
run: |
chmod +x scripts/statesync.bash
timeout 5m bash scripts/statesync.bash || true
- name: Check script with ShellCheck
run: |
shellcheck scripts/statesync.bash
30 changes: 20 additions & 10 deletions scripts/statesync.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,31 @@ go install ./...
# go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=badgerdb' -tags badgerdb ./...
# go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=boltdb' -tags boltdb ./...

# Initialize chain.
migalood init test

# get genesis
wget -O ~/.migalood/config/genesis.json https://github.com/White-Whale-Defi-Platform/migaloo-chain/raw/release/v2.0.x/networks/mainnet/genesis.json
# Check if genesis file exist, if not then download
GENESIS_FILE="$HOME/.migalood/config/genesis.json"
GENESIS_URL="https://github.com/White-Whale-Defi-Platform/migaloo-chain/raw/release/v2.0.x/networks/mainnet/genesis.json"

if [ ! -f "$GENESIS_FILE" ]; then
# Initialize chain.
migalood init test
mkdir -p "$(dirname "$GENESIS_FILE")"
# Download genesis
wget -O "$GENESIS_FILE" "$GENESIS_URL"

else
echo "File already exists!!!"
fi


# Set minimum gas price.
sed -i '' 's/minimum-gas-prices = ""/minimum-gas-prices = "0.0025uwhale"/' "$HOME/.migalood/config/app.toml"
# ADD SPACE IF RUN ON MAC
sed -i'' 's/minimum-gas-prices = ""/minimum-gas-prices = "0.0025uwhale"/' "$HOME/.migalood/config/app.toml"

# Get "trust_hash" and "trust_height".
INTERVAL=1000
LATEST_HEIGHT=$(curl -s https://rpc-whitewhale-h93nh9ykmqnzbrez-ie.internalendpoints.notional.ventures/block | jq -r .result.block.header.height)
LATEST_HEIGHT=$(curl -s https://whitewhale-rpc.lavenderfive.com/block | jq -r .result.block.header.height)
BLOCK_HEIGHT=$((LATEST_HEIGHT-INTERVAL))
TRUST_HASH=$(curl -s "https://rpc-whitewhale-h93nh9ykmqnzbrez-ie.internalendpoints.notional.ventures/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
TRUST_HASH=$(curl -s "https://whitewhale-rpc.lavenderfive.com/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)

# Print out block and transaction hash from which to sync state.
echo "trust_height: $BLOCK_HEIGHT"
Expand All @@ -39,8 +49,8 @@ echo "trust_hash: $TRUST_HASH"
# Export state sync variables.
export MIGALOOD_STATESYNC_ENABLE=true
export MIGALOOD_P2P_MAX_NUM_OUTBOUND_PEERS=200
# replace the url below with a working one
export MIGALOOD_STATESYNC_RPC_SERVERS="https://rpc-whitewhale-h93nh9ykmqnzbrez-ie.internalendpoints.notional.ventures:443,http://65.108.5.173:2481"
# replace the url below with a working one, get it from chain registry
export MIGALOOD_STATESYNC_RPC_SERVERS="https://whitewhale-mainnet-rpc.autostake.net:443,https://rpc-whitewhale.goldenratiostaking.net,https://whitewhale-rpc.lavenderfive.com,https://rpc-whitewhale.carbonzero.zone:443,https://rpc-whitewhale.whispernode.com:443,https://migaloo-rpc.kleomedes.network:443"
export MIGALOOD_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT
export MIGALOOD_STATESYNC_TRUST_HASH=$TRUST_HASH

Expand Down

0 comments on commit b29b978

Please sign in to comment.