cosmos-sdk/scripts/simapp-v2-init.sh
Hieu Vu 8ab643dc10
feat(server/v2): add config & start helper (#20505)
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
Co-authored-by: Marko <marko@baricevic.me>
Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com>
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
Co-authored-by: unknown unknown <unknown@unknown>
Co-authored-by: Julien Robert <julien@rbrt.fr>
2024-06-19 17:19:57 +00:00

51 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -x
ROOT=$PWD
SIMAPP_DIR="$ROOT/simapp/v2"
SIMD="$ROOT/build/simdv2"
CONFIG="${CONFIG:-$HOME/.simappv2/config}"
cd "$SIMAPP_DIR"
go build -o "$ROOT/build/simdv2" simdv2/main.go
if [ -d "$($SIMD config home)" ]; then rm -r $($SIMD config home); fi
$SIMD init simapp-v2-node --chain-id simapp-v2-chain
cd "$CONFIG"
# to change the voting_period
jq '.app_state.gov.voting_params.voting_period = "600s"' genesis.json > temp.json && mv temp.json genesis.json
# to change the inflation
jq '.app_state.mint.minter.inflation = "0.300000000000000000"' genesis.json > temp.json && mv temp.json genesis.json
# change the initial height to 2 to work around store/v2 and iavl limitations with a genesis block
jq '.initial_height = 2' genesis.json > temp.json && mv temp.json genesis.json
$SIMD keys add test_validator --indiscreet
VALIDATOR_ADDRESS=$($SIMD keys show test_validator -a --keyring-backend test)
$SIMD genesis add-genesis-account "$VALIDATOR_ADDRESS" 1000000000stake
$SIMD genesis gentx test_validator 1000000000stake --keyring-backend test
$SIMD genesis collect-gentxs
$SIMD start &
SIMD_PID=$!
cnt=0
while ! $SIMD query block --type=height 5; do
cnt=$((cnt + 1))
if [ $cnt -gt 30 ]; then
kill -9 "$SIMD_PID"
exit 1
fi
sleep 1
done
kill -9 "$SIMD_PID"