These instructions explains the steps to create another consumer chain from a provider chain node.
0. Set required environment variables
Ensure that the following environment variables are set.
PROV_NODE_DIR=~/provider-coordinator
PROV_CHAIN_ID=provider
PROV_KEY=coordinator-key
MY_IP=$(host -4 myip.opendns.com resolver1.opendns.com | grep "address" | awk '{print $4}')
1. Create proposal Create the propsal file using a new consumer chain id.
NEW_CONS_CHAIN_ID=consumer2
tee ${PROV_NODE_DIR}/${NEW_CONS_CHAIN_ID}-proposal.json<<EOF
{
"title": "Create consumer chain",
"description": "Gonna be a great chain",
"chain_id": "${NEW_CONS_CHAIN_ID}",
"initial_height": {
"revision_height": 1
},
"genesis_hash": "Z2VuX2hhc2g=",
"binary_hash": "YmluX2hhc2g=",
"spawn_time": "2022-03-11T09:02:14.718477-08:00",
"deposit": "10000001stake"
}
EOF
2. submit proposal
Submit the consumer chain proposal to the provider chain.
interchain-security-pd tx gov submit-proposal \
create-consumer-chain ${PROV_NODE_DIR}/${NEW_CONS_CHAIN_ID}-proposal.json \
--keyring-backend test \
--chain-id $PROV_CHAIN_ID \
--from $PROV_KEY \
--home $PROV_NODE_DIR \
-b block -y
3. Vote to proposal
Submit the votes to proposal
interchain-security-pd tx gov vote 2 yes --from $PROV_KEY \
--keyring-backend test --chain-id $PROV_CHAIN_ID --home $PROV_NODE_DIR -b block -y
interchain-security-pd q gov proposal 2 --home $PROV_NODE_DIR
- Note that the governance proposal number might be higher than '2' if you have submitted other proposals previously.
Create and run the consumer chain node as explained in the previous sections.
NEW_CONS_NODE_DIR=~/consumer-coordinator-2
CONS_NODE_MONIKER=coordinator2
CONS_KEY=consumer-key
rm -rf $NEW_CONS_NODE_DIR
interchain-security-cd init $CONS_NODE_MONIKER --chain-id $NEW_CONS_CHAIN_ID --home $NEW_CONS_NODE_DIR
interchain-security-cd keys add $CONS_KEY --home $NEW_CONS_NODE_DIR \
--keyring-backend test --output json > ${NEW_CONS_NODE_DIR}/${CONS_KEY}.json 2>&1
CONS_ACCOUNT_ADDR=$(jq -r .address ${NEW_CONS_NODE_DIR}/${CONS_KEY}.json)
interchain-security-cd add-genesis-account $CONS_ACCOUNT_ADDR 1000000000stake \
--keyring-backend test --home $NEW_CONS_NODE_DIR
interchain-security-pd query provider consumer-genesis $NEW_CONS_CHAIN_ID \
--home $PROV_NODE_DIR -o json > ccvconsumer_genesis.json
jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' ${NEW_CONS_NODE_DIR}/config/genesis.json \
ccvconsumer_genesis.json > ${NEW_CONS_NODE_DIR}/edited_genesis.json
mv ${NEW_CONS_NODE_DIR}/edited_genesis.json ${NEW_CONS_NODE_DIR}/config/genesis.json && \
rm ccvconsumer_genesis.json
echo '{"height": "0","round": 0,"step": 0}' > ${NEW_CONS_NODE_DIR}/data/priv_validator_state.json
cp ${PROV_NODE_DIR}/config/priv_validator_key.json ${NEW_CONS_NODE_DIR}/config/priv_validator_key.json
cp ${PROV_NODE_DIR}/config/node_key.json ${NEW_CONS_NODE_DIR}/config/node_key.json
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${MY_IP}:26638\"/" ${NEW_CONS_NODE_DIR}/config/client.toml
interchain-security-cd start --home $NEW_CONS_NODE_DIR \
--rpc.laddr tcp://${MY_IP}:26638 \
--grpc.address ${MY_IP}:9071 \
--address tcp://${MY_IP}:26635 \
--p2p.laddr tcp://${MY_IP}:26636 \
--grpc-web.enable=false \
--fast_sync=false \
&> ${NEW_CONS_NODE_DIR}/logs &
Update the relayer config using the following commands:
1. Add new consumer chain to config file
cat <<EOT >> ~/.hermes/config.toml
[[chains]]
account_prefix = "cosmos"
clock_drift = "5s"
gas_multiplier = 1.1
grpc_addr = "tcp://${MY_IP}:9071"
id = "$NEW_CONS_CHAIN_ID"
key_name = "relayer"
max_gas = 2000000
rpc_addr = "http://${MY_IP}:26638"
rpc_timeout = "10s"
store_prefix = "ibc"
trusting_period = "14days"
websocket_addr = "ws://${MY_IP}:26638/websocket"
[chains.gas_price]
denom = "stake"
price = 0.00
[chains.trust_threshold]
denominator = "3"
numerator = "1"
EOT
2. Add new consumer account key to relayer
hermes keys delete --chain $NEW_CONS_CHAIN_ID --all
hermes keys add --key-file ${NEW_CONS_NODE_DIR}/${CONS_KEY}.json --chain $NEW_CONS_CHAIN_ID
3. Initiate client and channel
hermes create connection \
--a-chain $NEW_CONS_CHAIN_ID \
--a-client 07-tendermint-0 \
--b-client 07-tendermint-1
hermes create channel \
--a-chain $NEW_CONS_CHAIN_ID \
--a-port consumer \
--b-port provider \
--order ordered \
--channel-version 1 \
--a-connection connection-0
4. Restart relayer
pkill -f hermes
hermes --json start &> ~/.hermes/logs &