From ba7042f7e37a48cec6cb21180acb4181c5573e72 Mon Sep 17 00:00:00 2001 From: pinosu <95283998+pinosu@users.noreply.github.com> Date: Thu, 7 Jul 2022 14:34:14 +0200 Subject: [PATCH] Add statesync example script (#417) * Add statesync example script * Remove setup commands and add rpc endpoint * Remove semicolon Co-authored-by: Mauro Lacy Co-authored-by: Mauro Lacy --- scripts/statesync.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/statesync.sh diff --git a/scripts/statesync.sh b/scripts/statesync.sh new file mode 100644 index 00000000..f7e9ad09 --- /dev/null +++ b/scripts/statesync.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Print every command. +set -ux + +# Initialize chain. +tgrade init test --chain-id tgrade-mainnet-1 + +# Get "trust_hash" and "trust_height". +INTERVAL=2000 +SNAP_RPC="https://rpc.mainnet-1.tgrade.confio.run:443" +LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height) +BLOCK_HEIGHT=$(($LATEST_HEIGHT-$INTERVAL)) +TRUST_HASH=$(curl -s "$SNAP_RPC/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" +echo "TRUST HASH: $TRUST_HASH" + +# Export state sync variables. +export TGRADE_STATESYNC_ENABLE=true +export TGRADE_STATESYNC_RPC_SERVERS="$SNAP_RPC,https://tgrade-mainnet-rpc.allthatnode.com:26657" +export TGRADE_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT +export TGRADE_STATESYNC_TRUST_HASH=$TRUST_HASH + +# Start chain. +tgrade start \ No newline at end of file