From 81131a977c87e02cbaed5bceabc1aefda505d08c Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Fri, 9 Jun 2023 02:51:10 +0800 Subject: [PATCH 1/2] add state sync script --- statesync.bash | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 statesync.bash diff --git a/statesync.bash b/statesync.bash new file mode 100644 index 00000000..ad3e44c8 --- /dev/null +++ b/statesync.bash @@ -0,0 +1,61 @@ +#!/bin/bash +# microtick and bitcanna contributed significantly here. +# Pebbledb state sync script. +# invoke like: bash scripts/ss.bash + + + +## USAGE RUNDOWN +# Not for use on live nodes +# For use when testing. +# Assumes that ~/.evmosd doesn't exist +# can be modified to suit your purposes if ~/.evmosd does already exist + + +set -uxe + +# Set Golang environment variables. +export GOPATH=~/go +export PATH=$PATH:~/go/bin + +# Install with pebbledb +go mod edit -replace github.com/tendermint/tm-db=github.com/baabeetaa/tm-db@pebble +go mod tidy +go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb -X github.com/tendermint/tm-db.ForceSync=1' -tags pebbledb ./... + +# 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. +kujirad init test + +# Get Genesis +wget -O ~/.kujira/config/genesis.json https://github.com/Team-Kujira/networks/raw/master/mainnet/kaiyo-1.json + + +# Get "trust_hash" and "trust_height". +INTERVAL=1000 +LATEST_HEIGHT=$(curl -s https://kujira-rpc.polkachu.com/block | jq -r .result.block.header.height) +BLOCK_HEIGHT=$(($LATEST_HEIGHT-$INTERVAL)) +TRUST_HASH=$(curl -s "https://kujira-rpc.polkachu.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" +echo "trust_hash: $TRUST_HASH" + +# Export state sync variables. +export KUJIRAD_STATESYNC_ENABLE=true +export KUJIRAD_P2P_MAX_NUM_OUTBOUND_PEERS=200 +export KUJIRAD_STATESYNC_RPC_SERVERS="https://kujira-rpc.polkachu.com:443,https://kujira-rpc.polkachu.com:443" +export KUJIRAD_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT +export KUJIRAD_STATESYNC_TRUST_HASH=$TRUST_HASH + +# Fetch and set list of seeds from chain registry. +export KUJIRAD_P2P_SEEDS=$(curl -s https://raw.githubusercontent.com/cosmos/chain-registry/master/kujira/chain.json | jq -r '[foreach .peers.seeds[] as $item (""; "\($item.id)@\($item.address)")] | join(",")') + +# Start chain. +kujirad start --x-crisis-skip-assert-invariants --db_backend pebbledb From 97fd897327ccffecab0416e298befad49acbaef5 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Fri, 9 Jun 2023 03:19:30 +0800 Subject: [PATCH 2/2] update state sync script --- statesync.bash | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/statesync.bash b/statesync.bash index ad3e44c8..d64db4d3 100644 --- a/statesync.bash +++ b/statesync.bash @@ -19,11 +19,12 @@ export GOPATH=~/go export PATH=$PATH:~/go/bin # Install with pebbledb -go mod edit -replace github.com/tendermint/tm-db=github.com/baabeetaa/tm-db@pebble -go mod tidy -go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb -X github.com/tendermint/tm-db.ForceSync=1' -tags pebbledb ./... +#go mod edit -replace github.com/tendermint/tm-db=github.com/baabeetaa/tm-db@pebble +#go mod tidy +#go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb -X github.com/tendermint/tm-db.ForceSync=1' -tags pebbledb ./... -# go install ./... +# install with defaults +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 ./... @@ -49,7 +50,7 @@ echo "trust_hash: $TRUST_HASH" # Export state sync variables. export KUJIRAD_STATESYNC_ENABLE=true -export KUJIRAD_P2P_MAX_NUM_OUTBOUND_PEERS=200 +export KUJIRAD_P2P_MAX_NUM_OUTBOUND_PEERS=500 export KUJIRAD_STATESYNC_RPC_SERVERS="https://kujira-rpc.polkachu.com:443,https://kujira-rpc.polkachu.com:443" export KUJIRAD_STATESYNC_TRUST_HEIGHT=$BLOCK_HEIGHT export KUJIRAD_STATESYNC_TRUST_HASH=$TRUST_HASH @@ -58,4 +59,4 @@ export KUJIRAD_STATESYNC_TRUST_HASH=$TRUST_HASH export KUJIRAD_P2P_SEEDS=$(curl -s https://raw.githubusercontent.com/cosmos/chain-registry/master/kujira/chain.json | jq -r '[foreach .peers.seeds[] as $item (""; "\($item.id)@\($item.address)")] | join(",")') # Start chain. -kujirad start --x-crisis-skip-assert-invariants --db_backend pebbledb +kujirad start --x-crisis-skip-assert-invariants