owned this note
owned this note
Published
Linked with GitHub
# build gaia chain for ica test
```bash
#!/bin/bash
BINARY=gaiad
MNEMONIC_RELAYER="alley afraid soup fall idea toss can goose become valve initial strong forward bright dish figure check leopard decide warfare hub unusual join cart"
MNEMONIC_FAUCET="history early rice thank umbrella barely pulse issue primary obvious situate wild help fish okay door floor strong comfort rib gesture donate flock until"
CHAINID=test-1
# Stop if it is already running
if pgrep -x "$BINARY" >/dev/null; then
echo "Terminating $BINARY..."
killall gaiad
fi
echo "Removing previous data..."
rm -rf ~/.gaia &> /dev/null
# Add directories for both chains, exit if an error occurs
if ! mkdir -p ~/.gaia 2>/dev/null; then
echo "Failed to create gaiad folder. Aborting..."
exit 1
fi
echo "Initializing $CHAINID..."
gaiad init test --chain-id=$CHAINID
echo "Adding genesis accounts..."
$BINARY keys add val --keyring-backend=test
echo $MNEMONIC_FAUCET | $BINARY keys add faucet --recover --keyring-backend=test
echo $MNEMONIC_RELAYER | $BINARY keys add rly --recover --keyring-backend=test
$BINARY add-genesis-account $($BINARY keys show val --keyring-backend test -a) 100000000000stake
$BINARY add-genesis-account $($BINARY keys show faucet --keyring-backend test -a) 100000000000stake
$BINARY add-genesis-account $($BINARY keys show rly --keyring-backend test -a) 100000000000stake
echo "Creating and collecting gentx..."
$BINARY gentx val 7000000000stake --chain-id $CHAINID --keyring-backend test
$BINARY collect-gentxs
echo "Changing defaults and ports in app.toml and config.toml files..."
sed -i -e 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.gaia/config/config.toml
sed -i -e 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.gaia/config/config.toml
sed -i -e 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.gaia/config/config.toml
sed -i -e 's/index_all_keys = false/index_all_keys = true/g' ~/.gaia/config/config.toml
sed -i -e 's/enable = false/enable = true/g' ~/.gaia/config/app.toml
sed -i -e 's/swagger = false/swagger = true/g' ~/.gaia/config/app.toml
#disable rosetta
sed -i -e '/Enable defines if the Rosetta API server/,/Address defines the Rosetta API server/s/enable = true/enable = false/' ~/.gaia/config/app.toml
# Update host chain genesis to allow x/bank/MsgSend ICA tx execution
sed -i -e 's%\"allow_messages\":.*%\"allow_messages\": [\"\/cosmos.crypto.ed25519.PubKey\", \"/cosmos.crypto.secp256k1.PubKey\", \"/cosmos.crypto.multisig.LegacyAminoPubKey\", \"/cosmos.crypto.secp256r1.PubKey\", \"/cosmos.vesting.v1beta1.PeriodicVestingAccount\", \"/cosmos.vesting.v1beta1.PermanentLockedAccount\", \"/cosmos.auth.v1beta1.BaseAccount\", \"/cosmos.auth.v1beta1.ModuleAccount\", \"/cosmos.vesting.v1beta1.BaseVestingAccount\", \"/cosmos.vesting.v1beta1.DelayedVestingAccount\", \"/cosmos.vesting.v1beta1.ContinuousVestingAccount\", \"/cosmos.bank.v1beta1.SendAuthorization\", \"/cosmos.authz.v1beta1.GenericAuthorization\", \"/cosmos.staking.v1beta1.StakeAuthorization\", \"/ibc.lightclients.tendermint.v1.ClientState\", \"/ibc.lightclients.localhost.v1.ClientState\", \"/ibc.lightclients.solomachine.v2.ClientState\", \"/ibc.core.connection.v1.Version\", \"/ibc.core.channel.v1.Counterparty\", \"/ibc.core.channel.v1.Packet\", \"/ibc.core.commitment.v1.MerklePrefix\", \"/cosmos.feegrant.v1beta1.PeriodicAllowance\", \"/cosmos.feegrant.v1beta1.AllowedMsgAllowance\", \"/cosmos.feegrant.v1beta1.BasicAllowance\", \"/ibc.lightclients.solomachine.v2.ConsensusState\", \"/ibc.lightclients.tendermint.v1.ConsensusState\", \"/ibc.core.client.v1.Height\", \"/ibc.core.connection.v1.ConnectionEnd\", \"/ibc.core.commitment.v1.MerklePath\", \"/ibc.core.commitment.v1.MerkleProof\", \"/ibc.lightclients.solomachine.v2.Misbehaviour\", \"/ibc.lightclients.tendermint.v1.Misbehaviour\", \"/ibc.core.commitment.v1.MerkleRoot\", \"/ibc.core.connection.v1.MsgConnectionOpenAck\", \"/ibc.core.channel.v1.MsgTimeoutOnClose\", \"/cosmos.feegrant.v1beta1.MsgRevokeAllowance\", \"/ibc.applications.transfer.v1.MsgTransfer\", \"/cosmos.authz.v1beta1.MsgGrant\", \"/ibc.core.channel.v1.MsgChannelCloseInit\", \"/cosmos.crisis.v1beta1.MsgVerifyInvariant\", \"/cosmos.evidence.v1beta1.MsgSubmitEvidence\", \"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress\", \"/ibc.core.connection.v1.MsgConnectionOpenConfirm\", \"/ibc.core.channel.v1.MsgChannelOpenAck\", \"/ibc.core.channel.v1.MsgChannelCloseConfirm\", \"/ibc.core.channel.v1.MsgRecvPacket\", \"/cosmos.feegrant.v1beta1.MsgGrantAllowance\", \"/cosmos.gov.v1beta1.MsgSubmitProposal\", \"/cosmos.authz.v1beta1.MsgRevoke\", \"/cosmos.authz.v1beta1.MsgExec\", \"/ibc.core.connection.v1.MsgConnectionOpenTry\", \"/cosmos.staking.v1beta1.MsgEditValidator\", \"/tendermint.liquidity.v1beta1.MsgSwapWithinBatch\", \"/cosmos.bank.v1beta1.MsgSend\", \"/cosmos.vesting.v1beta1.MsgCreateVestingAccount\", \"/ibc.core.client.v1.MsgUpgradeClient\", \"/ibc.core.channel.v1.MsgChannelOpenInit\", \"/ibc.core.channel.v1.MsgAcknowledgement\", \"/cosmos.staking.v1beta1.MsgCreateValidator\", \"/tendermint.liquidity.v1beta1.MsgCreatePool\", \"/tendermint.liquidity.v1beta1.MsgDepositWithinBatch\", \"/cosmos.distribution.v1beta1.MsgFundCommunityPool\", \"/ibc.core.client.v1.MsgUpdateClient\", \"/ibc.core.connection.v1.MsgConnectionOpenInit\", \"/ibc.core.channel.v1.MsgChannelOpenTry\", \"/cosmos.staking.v1beta1.MsgBeginRedelegate\", \"/cosmos.bank.v1beta1.MsgMultiSend\", \"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission\", \"/cosmos.slashing.v1beta1.MsgUnjail\", \"/ibc.core.channel.v1.MsgTimeout\", \"/cosmos.gov.v1beta1.MsgVoteWeighted\", \"/cosmos.gov.v1beta1.MsgDeposit\", \"/ibc.core.client.v1.MsgCreateClient\", \"/ibc.core.client.v1.MsgSubmitMisbehaviour\", \"/ibc.core.channel.v1.MsgChannelOpenConfirm\", \"/cosmos.staking.v1beta1.MsgDelegate\", \"/cosmos.staking.v1beta1.MsgUndelegate\", \"/tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch\", \"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward\", \"/cosmos.gov.v1beta1.MsgVote\", \"/cosmos.vesting.v1beta1.BaseVestingAccount\", \"/cosmos.vesting.v1beta1.DelayedVestingAccount\", \"/cosmos.vesting.v1beta1.ContinuousVestingAccount\", \"/cosmos.vesting.v1beta1.PeriodicVestingAccount\", \"/cosmos.vesting.v1beta1.PermanentLockedAccount\", \"/cosmos.auth.v1beta1.BaseAccount\", \"/cosmos.auth.v1beta1.ModuleAccount\", \"/cosmos.vesting.v1beta1.ContinuousVestingAccount\", \"/cosmos.vesting.v1beta1.DelayedVestingAccount\", \"/cosmos.vesting.v1beta1.PeriodicVestingAccount\", \"/cosmos.vesting.v1beta1.PermanentLockedAccount\", \"/ibc.lightclients.solomachine.v2.Header\", \"/ibc.lightclients.tendermint.v1.Header\", \"/ibc.core.connection.v1.Counterparty\", \"/ibc.core.channel.v1.Channel\", \"/cosmos.tx.v1beta1.Tx\", \"/cosmos.evidence.v1beta1.Equivocation\", \"/cosmos.bank.v1beta1.Supply\", \"/cosmos.params.v1beta1.ParameterChangeProposal\", \"/ibc.core.client.v1.ClientUpdateProposal\", \"/ibc.core.client.v1.UpgradeProposal\", \"/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal\", \"/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal\", \"/cosmos.distribution.v1beta1.CommunityPoolSpendProposal\", \"/cosmos.gov.v1beta1.TextProposal\"]%g' ~/.gaia/config/genesis.json
#sed -i -e 's/\"allow_messages\":.*/\"allow_messages\": [\"\/cosmos.bank.v1beta1.MsgSend\", \"\/cosmos.staking.v1beta1.MsgDelegate\"]/g' ~/.gaia/config/genesis.json
# modify gov params to get ready for a fast proposal pass
# min deposition amount
sed -i -e 's%"amount": "64000000",%"amount": "1",%g' ~/.gaia/config/genesis.json
# min voting power that a proposal requires in order to be a valid proposal
sed -i -e 's%"quorum": "0.400000000000000000",%"quorum": "0.000000000000000001",%g' ~/.gaia/config/genesis.json
# the minimum proportion of "yes" votes requires for the proposal to pass
sed -i -e 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' ~/.gaia/config/genesis.json
# voting period
sed -i -e 's%"voting_period": "1209600s"%"voting_period": "60s"%g' ~/.gaia/config/genesis.json
echo "Starting $CHAINID in ~/.gaia ..."
echo "Creating log file at gaia.log"
$BINARY start --log_level trace --log_format json --pruning=nothing > gaia.log 2>&1 &
```
For the second chain, please change `CHAINID=test-2` before running the above script.