Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add start script and state sync script #219

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
58 changes: 58 additions & 0 deletions statesync.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
# microtick and bitcanna contributed significantly here.
# Pebbledb state sync script.
# invoke like: bash statesync.bash

## USAGE RUNDOWN
# Not for use on live nodes
# For use when testing.
# Assumes that ~/.evmosd doesn't exist
faddat marked this conversation as resolved.
Show resolved Hide resolved
# can be modified to suit your purposes if ~/.evmosd does already exist
faddat marked this conversation as resolved.
Show resolved Hide resolved

set -uxe

# Set Golang environment variables.
export GOPATH=~/go
export PATH=$PATH:~/go/bin
faddat marked this conversation as resolved.
Show resolved Hide resolved

# Install with pebbledb
go mod edit -replace github.com/tendermint/tm-db=github.com/baabeetaa/tm-db@pebble
go mod tidy
make build

# Install with goleveldb
# go install ./...

# NOTE: ABOVE YOU CAN USE ALTERNATIVE DATABASES, HERE ARE THE EXACT COMMANDS
# go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb' -tags rocksdb ./...
# 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.
babylond init test
faddat marked this conversation as resolved.
Show resolved Hide resolved

# Get Genesis
curl http://node.mainnet.babylonchain.io:26657/genesis | jq .result.genesis >~/.babylond/config/genesis.json
faddat marked this conversation as resolved.
Show resolved Hide resolved

# Get "trust_hash" and "trust_height".
INTERVAL=100
LATEST_HEIGHT=$(curl -s http://node.mainnet.babylonchain.io:26657/block | jq -r .result.block.header.height)
BLOCK_HEIGHT=$(($LATEST_HEIGHT - $INTERVAL))
faddat marked this conversation as resolved.
Show resolved Hide resolved
TRUST_HASH=$(curl -s "http://node.mainnet.babylonchain.io:26657/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 BABYLOND_STATESYNC_ENABLE=true
export BABYLOND_P2P_MAX_NUM_OUTBOUND_PEERS=200
export BABYLOND_STATESYNC_RPC_SERVERS="http://node.mainnet.babylonchain.io:26657,http://node.mainnet.babylonchain.io:26657"
faddat marked this conversation as resolved.
Show resolved Hide resolved
export BABYLOND_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT
export BABYLOND_STATESYNC_TRUST_HASH=$TRUST_HASH

# Fetch and set list of seeds from chain registry.
export BABYLOND_P2P_PERSISTENT_PEERS=c12226489ac3f6ce1d7903d37cd204bc8f269018@node.mainnet.babylonchain.io:26656
faddat marked this conversation as resolved.
Show resolved Hide resolved

# Start chain.
babylond start --x-crisis-skip-assert-invariants