|
#!/bin/bash |
|
# 1. Set up a one-validator chain |
|
|
|
echo "Stopping services..." |
|
systemctl disable $LSM_SERVICE_1 --now |
|
|
|
# Install Gaia binary |
|
echo "Installing Gaia..." |
|
git clone https://github.com/cosmos/gaia.git |
|
cd gaia |
|
git checkout main |
|
make build |
|
cp build/gaiad ~/go/bin/gaiad-lsm |
|
cd .. |
|
|
|
# Initialize home directories |
|
echo "Initializing node homes..." |
|
rm -rf $LSM_HOME_1 |
|
$LSM_BINARY config chain-id $LSM_CHAIN_ID --home $LSM_HOME_1 |
|
$LSM_BINARY config keyring-backend test --home $LSM_HOME_1 |
|
$LSM_BINARY config broadcast-mode block --home $LSM_HOME_1 |
|
$LSM_BINARY config node tcp://localhost:$LSM1_RPC_PORT --home $LSM_HOME_1 |
|
$LSM_BINARY init $MONIKER_1 --chain-id $LSM_CHAIN_ID --home $LSM_HOME_1 |
|
|
|
# Create self-delegation accounts |
|
echo $MNEMONIC_1 | $LSM_BINARY keys add $MONIKER_1 --keyring-backend test --home $LSM_HOME_1 --recover |
|
echo $MNEMONIC_2 | $LSM_BINARY keys add $MONIKER_2 --keyring-backend test --home $LSM_HOME_1 --recover |
|
|
|
# Update genesis file with right denom |
|
echo "Setting denom to $DENOM..." |
|
jq -r --arg denom "$DENOM" '.app_state.crisis.constant_fee.denom |= $denom' $LSM_HOME_1/config/genesis.json > temp/crisis.json |
|
jq -r --arg denom "$DENOM" '.app_state.gov.deposit_params.min_deposit[0].denom |= $denom' temp/crisis.json > temp/min_deposit.json |
|
jq -r --arg denom "$DENOM" '.app_state.mint.params.mint_denom |= $denom' temp/min_deposit.json > temp/mint.json |
|
jq -r --arg denom "$DENOM" '.app_state.staking.params.bond_denom |= $denom' temp/mint.json > temp/bond_denom.json |
|
cp temp/bond_denom.json $LSM_HOME_1/config/genesis.json |
|
# cat $HOME_1/config/genesis.json |
|
|
|
# Add funds to accounts |
|
$LSM_BINARY add-genesis-account $MONIKER_1 $VAL_FUNDS$DENOM --home $LSM_HOME_1 |
|
$LSM_BINARY add-genesis-account $MONIKER_2 $VAL_FUNDS$DENOM --home $LSM_HOME_1 |
|
|
|
echo "Creating and collecting gentxs..." |
|
mkdir -p $LSM_HOME_1/config/gentx |
|
LSM1_NODE_ID=$($LSM_BINARY tendermint show-node-id --home $LSM_HOME_1) |
|
$LSM_BINARY gentx $MONIKER_1 $VAL1_STAKE$DENOM --pubkey "$($LSM_BINARY tendermint show-validator --home $LSM_HOME_1)" --node-id $LSM1_NODE_ID --moniker $MONIKER_1 --chain-id $LSM_CHAIN_ID --home $LSM_HOME_1 --output-document $LSM_HOME_1/config/gentx/$MONIKER_1-gentx.json |
|
$LSM_BINARY collect-gentxs --home $LSM_HOME_1 |
|
|
|
echo "Patching genesis file for fast governance..." |
|
jq -r '.app_state.gov.voting_params.voting_period = "10s"' $LSM_HOME_1/config/genesis.json > temp/voting.json |
|
cp temp/voting.json $LSM_HOME_1/config/genesis.json |
|
|
|
echo "Patching config files..." |
|
# app.toml |
|
# minimum_gas_prices |
|
sed -i -e "/minimum-gas-prices =/ s^= .*^= \"0.0025$DENOM\"^" $LSM_HOME_1/config/app.toml |
|
|
|
# Enable API |
|
toml set --toml-path $LSM_HOME_1/config/app.toml api.enable true |
|
|
|
# Set different ports for api |
|
toml set --toml-path $LSM_HOME_1/config/app.toml api.address "tcp://0.0.0.0:$LSM1_API_PORT" |
|
|
|
# Set different ports for grpc |
|
toml set --toml-path $LSM_HOME_1/config/app.toml grpc.address "0.0.0.0:$LSM1_GRPC_PORT" |
|
|
|
# Turn off grpc web |
|
toml set --toml-path $LSM_HOME_1/config/app.toml grpc-web.enable false |
|
|
|
# config.toml |
|
echo "Setting ports for rpc..." |
|
toml set --toml-path $LSM_HOME_1/config/config.toml rpc.laddr "tcp://0.0.0.0:$LSM1_RPC_PORT" |
|
|
|
echo "Setting ports for rpc pprof..." |
|
toml set --toml-path $LSM_HOME_1/config/config.toml rpc.pprof_laddr "localhost:$LSM1_PPROF_PORT" |
|
|
|
echo "Setting ports for p2p..." |
|
toml set --toml-path $LSM_HOME_1/config/config.toml p2p.laddr "tcp://0.0.0.0:$LSM1_P2P_PORT" |
|
|
|
echo "Setting a short timeout commit..." |
|
toml set --toml-path $LSM_HOME_1/config/config.toml consensus.timeout_commit "1s" |
|
|
|
echo "Allow duplicate IP connections..." |
|
toml set --toml-path $LSM_HOME_1/config/config.toml p2p.allow_duplicate_ip true |
|
|
|
# Set fast_sync to false |
|
toml set --toml-path $LSM_HOME_1/config/config.toml fast_sync false |
|
|
|
echo "Setting up services..." |
|
|
|
rm /etc/systemd/system/$LSM_SERVICE_1 |
|
touch /etc/systemd/system/$LSM_SERVICE_1 |
|
echo "[Unit]" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 |
|
echo "Description=Gaia service" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "After=network-online.target" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "[Service]" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "User=$USER" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "ExecStart=$HOME/go/bin/$LSM_BINARY start --x-crisis-skip-assert-invariants --home $LSM_HOME_1" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "Restart=no" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "LimitNOFILE=4096" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "[Install]" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
echo "WantedBy=multi-user.target" | sudo tee /etc/systemd/system/$LSM_SERVICE_1 -a |
|
|
|
sudo systemctl daemon-reload |
|
sudo systemctl enable $LSM_SERVICE_1 --now |
|
|
|
echo "***********************" |
|
echo "To see the Gaia log enter:" |
|
echo "journalctl -fu $LSM_SERVICE_1" |
|
echo "***********************" |
|
|