Skip to content

Instantly share code, notes, and snippets.

@sainoe
Last active October 17, 2022 15:59
Show Gist options
  • Save sainoe/90ae6f8cba8755046328a05d2478fd93 to your computer and use it in GitHub Desktop.
Save sainoe/90ae6f8cba8755046328a05d2478fd93 to your computer and use it in GitHub Desktop.
testnet-scripts
#!/bin/bash
set -eux
```
tee ${PROV_NODE_DIR}/change-voting-period.json<<EOF
{
"title": "Change voting period",
"description": "Voting period",
"changes": [
{
"subspace": "gov",
"key": "votingparams",
"value": {"voting_period": "259200000000000"}
}
],
"deposit": "10000001stake"
}
EOF
```
#Submit and vote proposal
```
interchain-security-pd tx gov submit-proposal \
param-change \
~/provider-coordinator/change-voting-period.json \
--keyring-backend test \
--chain-id $PROV_CHAIN_ID \
--from $PROV_KEY \
--home $PROV_NODE_DIR \
-b block -y
interchain-security-pd tx gov vote 3 yes \
--from $PROV_KEY \
--keyring-backend test \
--chain-id $PROV_CHAIN_ID \
--home $PROV_NODE_DIR -b block -y
```

Create another consumer chain

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.

Run consumer chain

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 relayer

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 &
#!/bin/bash
set -eux
PROV_KEY=coordinator-key
PROV_NODE_MONIKER=coordinator
PROV_CHAIN_ID=provider
PROV_NODE_DIR=~/provider-coordinator
PROV_ACCOUNT_ADDR=$(jq -r .address ${PROV_NODE_DIR}/${PROV_KEY}.json)
DELEGATIONS=$(interchain-security-pd q staking delegations $PROV_ACCOUNT_ADDR --home ${PROV_NODE_DIR} -o json)
OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r '.delegation_responses[0].delegation.validator_address')
interchain-security-pd tx staking delegate $OPERATOR_ADDR 1000000stake \
--from $PROV_KEY \
--keyring-backend test \
--home $PROV_NODE_DIR \
--chain-id $PROV_CHAIN_ID \
-y -b block
#!/bin/bash
set -eux
# User balance of stake tokens
USER_COINS="100000000000stake"
# Amount of stake tokens staked
STAKE="100000000stake"
# Node IP address
NODE_IP="165.227.143.45"
# Home directory
HOME_DIR="/root"
# Validator moniker
MONIKER="coordinator"
# Validator directory
PROV_NODE_DIR=${HOME_DIR}/provider-${MONIKER}
CONS_NODE_DIR=${HOME_DIR}/consumer-${MONIKER}
# Clean start
pkill -f interchain-security-pd &> /dev/null || true
rm -rf ${PROV_NODE_DIR}
# Build genesis file and node directory structure
interchain-security-pd init $MONIKER --chain-id provider --home ${PROV_NODE_DIR}
jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"345600s\"" \
${PROV_NODE_DIR}/config/genesis.json > \
${PROV_NODE_DIR}/edited_genesis.json && mv ${PROV_NODE_DIR}/edited_genesis.json ${PROV_NODE_DIR}/config/genesis.json
sleep 1
# Create account keypair
interchain-security-pd keys add $MONIKER --home ${PROV_NODE_DIR} --keyring-backend test --output json > ${PROV_NODE_DIR}/${MONIKER}_keypair.json 2>&1
sleep 1
# Add stake to user
PROV_ACCOUNT_ADDR=$(jq -r '.address' ${PROV_NODE_DIR}/${MONIKER}_keypair.json)
interchain-security-pd add-genesis-account $PROV_ACCOUNT_ADDR $USER_COINS --home ${PROV_NODE_DIR} --keyring-backend test
sleep 1
# Stake 1/1000 user's coins
interchain-security-pd gentx $MONIKER $STAKE --chain-id provider --home ${PROV_NODE_DIR} --keyring-backend test --moniker $MONIKER
sleep 1
interchain-security-pd collect-gentxs --home ${PROV_NODE_DIR} --gentx-dir ${PROV_NODE_DIR}/config/gentx/
sleep 1
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26658\"/" ${PROV_NODE_DIR}/config/client.toml
sed -i -r 's/timeout_commit = "5s"/timeout_commit = "3s"/g' ${PROV_NODE_DIR}/config/config.toml
sed -i -r 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ${PROV_NODE_DIR}/config/config.toml
# Start gaia
interchain-security-pd start \
--home ${PROV_NODE_DIR} \
--rpc.laddr tcp://${NODE_IP}:26658 \
--grpc.address ${NODE_IP}:9091 \
--address tcp://${NODE_IP}:26655 \
--p2p.laddr tcp://${NODE_IP}:26656 \
--grpc-web.enable=false &> ${PROV_NODE_DIR}/logs &
sleep 5
# Build consumer chain proposal file
tee ${PROV_NODE_DIR}/consumer-proposal.json<<EOF
{
"title": "Create a chain",
"description": "Gonna be a great chain",
"chain_id": "consumer",
"initial_height": {
"revision_height": 1
},
"genesis_hash": "Z2VuX2hhc2g=",
"binary_hash": "YmluX2hhc2g=",
"spawn_time": "2022-03-11T09:02:14.718477-08:00",
"deposit": "10000001stake"
}
EOF
interchain-security-pd keys show $MONIKER --keyring-backend test --home ${PROV_NODE_DIR}
# Submit consumer chain proposal
interchain-security-pd tx gov submit-proposal consumer-addition ${PROV_NODE_DIR}/consumer-proposal.json --chain-id provider --from $MONIKER --home ${PROV_NODE_DIR} --node tcp://${NODE_IP}:26658 --keyring-backend test -b block -y
sleep 1
# Vote yes to proposal
interchain-security-pd tx gov vote 1 yes --from $MONIKER --chain-id provider --home ${PROV_NODE_DIR} -b block -y --keyring-backend test
# sleep 3
# ## CONSUMER CHAIN ##
# Clean start
pkill -f interchain-security-cd &> /dev/null || true
rm -rf ${CONS_NODE_DIR}
# Build genesis file and node directory structure
interchain-security-cd init $MONIKER --chain-id consumer --home ${CONS_NODE_DIR}
sleep 1
# Create user account keypair
interchain-security-cd keys add $MONIKER --home ${CONS_NODE_DIR} --keyring-backend test --output json > ${CONS_NODE_DIR}/${MONIKER}_keypair.json 2>&1
# Add stake to user account
CONS_ACCOUNT_ADDR=$(jq -r '.address' ${CONS_NODE_DIR}/${MONIKER}_keypair.json)
interchain-security-cd add-genesis-account $CONS_ACCOUNT_ADDR 1000000000stake --home ${CONS_NODE_DIR}
# Add consumer genesis states to genesis file
interchain-security-pd query provider consumer-genesis consumer --home ${PROV_NODE_DIR} -o json > consumer_gen.json
jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' ${CONS_NODE_DIR}/config/genesis.json consumer_gen.json > ${CONS_NODE_DIR}/edited_genesis.json \
&& mv ${CONS_NODE_DIR}/edited_genesis.json ${CONS_NODE_DIR}/config/genesis.json
rm consumer_gen.json
# Reduce the signed blocks window parameter
# jq ".app_state.slashing.params.signed_blocks_window = \"30\"" ${CONS_NODE_DIR}/config/genesis.json > \
# ${CONS_NODE_DIR}/edited_genesis.json && mv ${CONS_NODE_DIR}/edited_genesis.json ${PROV_NODE_DIR}/config/genesis.json
# Create validator states
echo '{"height": "0","round": 0,"step": 0}' > ${CONS_NODE_DIR}/data/priv_validator_state.json
# Copy validator key files
cp ${PROV_NODE_DIR}/config/priv_validator_key.json ${CONS_NODE_DIR}/config/priv_validator_key.json
cp ${PROV_NODE_DIR}/config/node_key.json ${CONS_NODE_DIR}/config/node_key.json
# Set default client port
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26648\"/" ${CONS_NODE_DIR}/config/client.toml
# Start giaia
interchain-security-cd start --home ${CONS_NODE_DIR} \
--rpc.laddr tcp://${NODE_IP}:26648 \
--grpc.address ${NODE_IP}:9081 \
--address tcp://${NODE_IP}:26645 \
--p2p.laddr tcp://${NODE_IP}:26646 \
--grpc-web.enable=false \
&> ${CONS_NODE_DIR}/logs &
sleep 3
# # Setup Hermes in packet relayer mode
pkill -f hermes 2> /dev/null || true
tee ~/.hermes/config.toml<<EOF
[global]
log_level = "info"
[mode]
[mode.clients]
enabled = true
refresh = true
misbehaviour = true
[mode.connections]
enabled = false
[mode.channels]
enabled = false
[mode.packets]
enabled = true
[[chains]]
account_prefix = "cosmos"
clock_drift = "5s"
gas_multiplier = 1.1
grpc_addr = "tcp://${NODE_IP}:9081"
id = "consumer"
key_name = "relayer"
max_gas = 2000000
rpc_addr = "http://${NODE_IP}:26648"
rpc_timeout = "10s"
store_prefix = "ibc"
trusting_period = "2days"
websocket_addr = "ws://${NODE_IP}:26648/websocket"
[chains.gas_price]
denom = "stake"
price = 0.00
[chains.trust_threshold]
denominator = "3"
numerator = "1"
[[chains]]
account_prefix = "cosmos"
clock_drift = "5s"
gas_multiplier = 1.1
grpc_addr = "tcp://${NODE_IP}:9091"
id = "provider"
key_name = "relayer"
max_gas = 2000000
rpc_addr = "http://${NODE_IP}:26658"
rpc_timeout = "10s"
store_prefix = "ibc"
trusting_period = "2days"
websocket_addr = "ws://${NODE_IP}:26658/websocket"
[chains.gas_price]
denom = "stake"
price = 0.00
[chains.trust_threshold]
denominator = "3"
numerator = "1"
EOF
# Delete all previous keys in relayer
hermes keys delete --chain consumer --all
hermes keys delete --chain provider --all
# Restore keys to hermes relayer
hermes keys add --key-file ${CONS_NODE_DIR}/${MONIKER}_keypair.json --chain consumer
hermes keys add --key-file ${PROV_NODE_DIR}/${MONIKER}_keypair.json --chain provider
sleep 5
hermes create connection \
--a-chain consumer \
--a-client 07-tendermint-0 \
--b-client 07-tendermint-0
hermes create channel \
--a-chain consumer \
--a-port consumer \
--b-port provider \
--order ordered \
--channel-version 1 \
--a-connection connection-0
sleep 5
# clear packet manually
hermes --json start &> ~/.hermes/logs &
# create new account
# Home directory
# Validator moniker
DOWNTIME_MONIKER="downtime"
# Validator directory
DOWNTIME_NODE_DIR=${HOME_DIR}/provider-${DOWNTIME_MONIKER}
rm -rf $DOWNTIME_NODE_DIR
interchain-security-pd init $DOWNTIME_MONIKER --chain-id provider --home $DOWNTIME_NODE_DIR
interchain-security-pd keys add $DOWNTIME_MONIKER --home $DOWNTIME_NODE_DIR --keyring-backend test --output json > ${DOWNTIME_NODE_DIR}/${DOWNTIME_MONIKER}_keypair.json 2>&1
cp ${PROV_NODE_DIR}/config/genesis.json ${DOWNTIME_NODE_DIR}/config/genesis.json
COORDINATOR_P2P_ADDRESS=$(jq -r '.app_state.genutil.gen_txs[0].body.memo' ${PROV_NODE_DIR}/config/genesis.json)
interchain-security-pd start --home $DOWNTIME_NODE_DIR \
--rpc.laddr tcp://${NODE_IP}:26628 \
--grpc.address ${NODE_IP}:9021 \
--address tcp://${NODE_IP}:26625 \
--p2p.laddr tcp://${NODE_IP}:26626 \
--grpc-web.enable=false \
--p2p.persistent_peers $COORDINATOR_P2P_ADDRESS &> ${DOWNTIME_NODE_DIR}/logs &
sleep 2
DOWNTIME_ACCOUNT_ADDR=$(jq -r '.address' ${DOWNTIME_NODE_DIR}/${DOWNTIME_MONIKER}_keypair.json)
# faucet new validator
sleep 1
interchain-security-pd tx bank send \
$PROV_ACCOUNT_ADDR $DOWNTIME_ACCOUNT_ADDR \
1000000000stake \
--chain-id provider \
--keyring-backend test \
--home ~/provider-coordinator \
-b block -y
# create validator
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26628\"/" ${DOWNTIME_NODE_DIR}/config/client.toml
VAL_PUBKEY=$(interchain-security-pd tendermint show-validator --home $DOWNTIME_NODE_DIR)
sleep 3
interchain-security-pd tx staking create-validator \
--amount 1000000stake \
--pubkey $VAL_PUBKEY \
--from $DOWNTIME_MONIKER \
--keyring-backend test \
--home $DOWNTIME_NODE_DIR \
--chain-id provider \
--commission-max-change-rate 0.01 \
--commission-max-rate 0.2 \
--commission-rate 0.1 \
--moniker $DOWNTIME_MONIKER \
--min-self-delegation 1 \
-b block -y
sleep 8
# kill hermes to clear packet manually
pkill -f hermes &> /dev/null || true
# check the missed blocks of new validators on the consumer chain
interchain-security-pd q slashing signing-infos --home $CONS_NODE_DIR
#!/bin/bash
set -eux
# User balance of stake tokens
USER_COINS="100000000000stake"
# Amount of stake tokens staked
STAKE="100000000stake"
# Node IP address
NODE_IP="167.172.190.207"
# Home directory
HOME_DIR=""
# Validator moniker
MONIKER="coordinator"
# Validator directory
PROV_NODE_DIR=${HOME_DIR}/provider-${MONIKER}
CONS_NODE_DIR=${HOME_DIR}/consumer-${MONIKER}
# Clean start
pkill -f interchain-security-pd &> /dev/null || true
rm -rf ${PROV_NODE_DIR}
# Build genesis file and node directory structure
interchain-security-pd init $MONIKER --chain-id provider --home ${PROV_NODE_DIR}
jq ".app_state.gov.voting_params.voting_period = \"3s\" | .app_state.staking.params.unbonding_time = \"345600s\"" \
${PROV_NODE_DIR}/config/genesis.json > \
${PROV_NODE_DIR}/edited_genesis.json && mv ${PROV_NODE_DIR}/edited_genesis.json ${PROV_NODE_DIR}/config/genesis.json
sleep 1
# Create account keypair
interchain-security-pd keys add $MONIKER --home ${PROV_NODE_DIR} --keyring-backend test --output json > ${PROV_NODE_DIR}/${MONIKER}_keypair.json 2>&1
sleep 1
# Add stake to user
PROV_ACCOUNT_ADDR=$(jq -r '.address' ${PROV_NODE_DIR}/${MONIKER}_keypair.json)
interchain-security-pd add-genesis-account $PROV_ACCOUNT_ADDR $USER_COINS --home ${PROV_NODE_DIR} --keyring-backend test
sleep 1
# Stake 1/1000 user's coins
interchain-security-pd gentx $MONIKER $STAKE --chain-id provider --home ${PROV_NODE_DIR} --keyring-backend test --moniker $MONIKER
sleep 1
interchain-security-pd collect-gentxs --home ${PROV_NODE_DIR} --gentx-dir ${PROV_NODE_DIR}/config/gentx/
sleep 1
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26658\"/" ${PROV_NODE_DIR}/config/client.toml
sed -i -r 's/timeout_commit = "5s"/timeout_commit = "3s"/g' ${PROV_NODE_DIR}/config/config.toml
sed -i -r 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ${PROV_NODE_DIR}/config/config.toml
# Start gaia
interchain-security-pd start \
--home ${PROV_NODE_DIR} \
--rpc.laddr tcp://${NODE_IP}:26658 \
--grpc.address ${NODE_IP}:9091 \
--address tcp://${NODE_IP}:26655 \
--p2p.laddr tcp://${NODE_IP}:26656 \
--grpc-web.enable=false &> ${PROV_NODE_DIR}/logs &
sleep 5
# Build consumer chain proposal file
tee ${PROV_NODE_DIR}/consumer-proposal.json<<EOF
{
"title": "Create a chain",
"description": "Gonna be a great chain",
"chain_id": "consumer",
"initial_height": {
"revision_height": 1
},
"genesis_hash": "Z2VuX2hhc2g=",
"binary_hash": "YmluX2hhc2g=",
"spawn_time": "2022-03-11T09:02:14.718477-08:00",
"deposit": "10000001stake"
}
EOF
interchain-security-pd keys show $MONIKER --keyring-backend test --home ${PROV_NODE_DIR}
# Submit consumer chain proposal
interchain-security-pd tx gov submit-proposal create-consumer-chain ${PROV_NODE_DIR}/consumer-proposal.json --chain-id provider --from $MONIKER --home ${PROV_NODE_DIR} --node tcp://${NODE_IP}:26658 --keyring-backend test -b block -y
sleep 1
# Vote yes to proposal
interchain-security-pd tx gov vote 1 yes --from $MONIKER --chain-id provider --home ${PROV_NODE_DIR} -b block -y --keyring-backend test
sleep 3
## CONSUMER CHAIN ##
# Clean start
pkill -f interchain-security-cd &> /dev/null || true
rm -rf ${CONS_NODE_DIR}
# Build genesis file and node directory structure
interchain-security-cd init $MONIKER --chain-id consumer --home ${CONS_NODE_DIR}
sleep 1
# Create user account keypair
interchain-security-cd keys add $MONIKER --home ${CONS_NODE_DIR} --keyring-backend test --output json > ${CONS_NODE_DIR}/${MONIKER}_keypair.json 2>&1
# Add stake to user account
CONS_ACCOUNT_ADDR=$(jq -r '.address' ${CONS_NODE_DIR}/${MONIKER}_keypair.json)
interchain-security-cd add-genesis-account $CONS_ACCOUNT_ADDR 1000000000stake --home ${CONS_NODE_DIR}
# Add consumer genesis states to genesis file
interchain-security-pd query provider consumer-genesis consumer --home ${PROV_NODE_DIR} -o json > consumer_gen.json
jq -s '.[0].app_state.ccvconsumer = .[1] | .[0]' ${CONS_NODE_DIR}/config/genesis.json consumer_gen.json > ${CONS_NODE_DIR}/edited_genesis.json \
&& mv ${CONS_NODE_DIR}/edited_genesis.json ${CONS_NODE_DIR}/config/genesis.json
rm consumer_gen.json
# Create validator states
echo '{"height": "0","round": 0,"step": 0}' > ${CONS_NODE_DIR}/data/priv_validator_state.json
# Copy validator key files
cp ${PROV_NODE_DIR}/config/priv_validator_key.json ${CONS_NODE_DIR}/config/priv_validator_key.json
cp ${PROV_NODE_DIR}/config/node_key.json ${CONS_NODE_DIR}/config/node_key.json
# Set default client port
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${NODE_IP}:26648\"/" ${CONS_NODE_DIR}/config/client.toml
# Start giaia
interchain-security-cd start --home ${CONS_NODE_DIR} \
--rpc.laddr tcp://${NODE_IP}:26648 \
--grpc.address ${NODE_IP}:9081 \
--address tcp://${NODE_IP}:26645 \
--p2p.laddr tcp://${NODE_IP}:26646 \
--grpc-web.enable=false \
&> ${CONS_NODE_DIR}/logs &
sleep 3
# Setup Hermes in packet relayer mode
pkill -f hermes 2> /dev/null || true
tee ~/.hermes/config.toml<<EOF
[global]
log_level = "info"
[mode]
[mode.clients]
enabled = true
refresh = true
misbehaviour = true
[mode.connections]
enabled = false
[mode.channels]
enabled = false
[mode.packets]
enabled = true
[[chains]]
account_prefix = "cosmos"
clock_drift = "5s"
gas_multiplier = 1.1
grpc_addr = "tcp://${NODE_IP}:9081"
id = "consumer"
key_name = "relayer"
max_gas = 2000000
rpc_addr = "http://${NODE_IP}:26648"
rpc_timeout = "10s"
store_prefix = "ibc"
trusting_period = "2days"
websocket_addr = "ws://${NODE_IP}:26648/websocket"
[chains.gas_price]
denom = "stake"
price = 0.00
[chains.trust_threshold]
denominator = "3"
numerator = "1"
[[chains]]
account_prefix = "cosmos"
clock_drift = "5s"
gas_multiplier = 1.1
grpc_addr = "tcp://${NODE_IP}:9091"
id = "provider"
key_name = "relayer"
max_gas = 2000000
rpc_addr = "http://${NODE_IP}:26658"
rpc_timeout = "10s"
store_prefix = "ibc"
trusting_period = "2days"
websocket_addr = "ws://${NODE_IP}:26658/websocket"
[chains.gas_price]
denom = "stake"
price = 0.00
[chains.trust_threshold]
denominator = "3"
numerator = "1"
EOF
# Delete all previous keys in relayer
hermes keys delete --chain consumer --all
hermes keys delete --chain provider --all
# Restore keys to hermes relayer
hermes keys add --key-file ${CONS_NODE_DIR}/${MONIKER}_keypair.json --chain consumer
hermes keys add --key-file ${PROV_NODE_DIR}/${MONIKER}_keypair.json --chain provider
sleep 5
hermes create connection \
--a-chain consumer \
--a-client 07-tendermint-0 \
--b-client 07-tendermint-0
hermes create channel \
--a-chain consumer \
--a-port consumer \
--b-port provider \
--order ordered \
--channel-version 1 \
--a-connection connection-0
sleep 5
hermes --json start &> ~/.hermes/logs &
interchain-security-pd q tendermint-validator-set --home ${PROV_NODE_DIR}
interchain-security-cd q tendermint-validator-set --home ${CONS_NODE_DIR}
DELEGATIONS=$(interchain-security-pd q staking delegations $PROV_ACCOUNT_ADDR --home ${PROV_NODE_DIR} -o json)
OPERATOR_ADDR=$(echo $DELEGATIONS | jq -r '.delegation_responses[0].delegation.validator_address')
interchain-security-pd tx staking delegate $OPERATOR_ADDR 1000000stake \
--from $MONIKER \
--keyring-backend test \
--home ${PROV_NODE_DIR} \
--chain-id provider \
-y -b block
sleep 13
interchain-security-pd q tendermint-validator-set --home ${PROV_NODE_DIR}
interchain-security-cd q tendermint-validator-set --home ${CONS_NODE_DIR}
#!/bin/bash
set -eux
# Clone faucet repo
cd $HOME
git clone https://github.com/sainoe/cosmos-rest-faucet.git
# Install python
apt update
apt install software-properties-common -y
add-apt-repository ppa:deadsnakes/ppa -y
apt update -y
apt install python3.8 -y
apt install python3-pip -y
apt install python3.8-venv -y
cd cosmos-rest-faucet/
python -m venv .env
source .env/bin/activate
pip install -r requirements.txt
hypercorn cosmos_rest_faucet:app -b 0.0.0.0:8000

Join a consumer chain

This guide explains you the steps to join a consumer chain assuming that a provider chain validator node is already set on your local machine.


Setup consumer chain

The following commands show how to create a consumer chain node configuration files

1. Create account_

CONS_CHAIN_ID=consumer2
CONS_NODE_DIR=~/consumer2
CONS_NODE_MONIKER=provider
rm -rf $CONS_NODE_DIR

interchain-security-cd init $CONS_NODE_MONIKER --chain-id $CONS_CHAIN_ID --home $CONS_NODE_DIR

2. Get consuer chain genesis Download the consumer chain genesis using the following command:

wget -O ${CONS_NODE_DIR}/config/genesis.json https://paste.c-net.org/https://paste.c-net.org/DentistsSuper

3. Copy provider chain validator keys
In order to run the consumer chain node you need a provider validator node private key. Here we are assuming that these keys are stored in the same local machine.

PROV_NODE_DIR=~/provider

echo '{"height": "0","round": 0,"step": 0}' > ${CONS_NODE_DIR}/data/priv_validator_state.json
cp ${PROV_NODE_DIR}/config/node_key.json ${CONS_NODE_DIR}/config/node_key.json
cp ${PROV_NODE_DIR}/config/priv_validator_key.json ${CONS_NODE_DIR}/config/priv_validator_key.json

4. Run the validator

sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${MY_IP}:26638\"/" ${CONS_NODE_DIR}/config/client.toml
COORDINATOR_P2P_ADDRESS=$(jq -r '.app_state.genutil.gen_txs[0].body.memo' ${PROV_NODE_DIR}/config/genesis.json)
CONSUMER_P2P_ADDRESS=$(echo $COORDINATOR_P2P_ADDRESS | sed 's/:.*/:26636/')

interchain-security-cd start --home $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 \
        --p2p.persistent_peers $CONSUMER_P2P_ADDRESS \
        &> ${CONS_NODE_DIR}/logs &
# START FAUCET WITHOUT INSTALL ##
#!/bin/bash
set -eux
cd ~/cosmos-rest-faucet
source .env/bin/activate
hypercorn cosmos_rest_faucet:app -b 0.0.0.0:8000
#!/bin/bash
set -eux
PROV_KEY=coordinator-key
PROV_CHAIN_ID=provider
PROV_NODE_DIR=~/provider-coordinator
CONS_NODE_DIR=~/consumer-coordinator
CONS_CHAIN_ID=consumer
tee ${PROV_NODE_DIR}/stop-${CONS_CHAIN_ID}-proposal.json<<EOF
{
"title": "Stop the consumer",
"description": "It was a great chain",
"chain_id": "${CONS_CHAIN_ID}",
"stop_time": "2022-01-27T15:59:50.121607-08:00",
"deposit": "100000001stake"
}
EOF
PROP_ID=3
interchain-security-pd tx gov submit-proposal stop-consumer-chain \
${PROV_NODE_DIR}/stop-${CONS_CHAIN_ID}-proposal.json \
--chain-id provider \
--from $PROV_KEY \
--home ${PROV_NODE_DIR} \
--keyring-backend test -b block -y
interchain-security-pd tx gov vote $PROP_ID yes \
--chain-id provider \
--from $PROV_KEY \
--home ${PROV_NODE_DIR} \
--keyring-backend test -b block -y
#!/bin/bash
set -eux
PROV_KEY=provider-key
interchain-security-pd tx slashing unjail --from $PROV_KEY \
--home ~/provider \
--keyring-backend test \
-y -b block \
--chain-id provider
#!/bin/bash
set -eux
curl --upload-file '/root/provider-coordinator/config/genesis.json' 'https://paste.c-net.org/';
curl --upload-file '/root/consumer-coordinator/config/genesis.json' 'https://paste.c-net.org/';
#!/bin/bash
set -eux
echo "Provider chain valset:"
interchain-security-cd q tendermint-validator-set --home ~/provider-coordinator
echo "Consumer chain valset:"
interchain-security-cd q tendermint-validator-set --home ~/consumer-coordinator
echo "Consumer2 chain valset:"
interchain-security-cd q tendermint-validator-set --home ~/consumer-coordinator-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment