This guide contains the instructions for joining a Interchain-Security Testnet.
- Go 1.18+ (installation notes)
- Interchain Security binaries (installation notes)
- Rust 1.60+ (installation notes)
- Hermes v1.0.0-rc.0 (installation notes)
- jq (installation notes)
git clone https://github.com/cosmos/interchain-security.git
cd interchain-security
git checkout tags/v0.1.4
make install
This section will explain you how to setup and run an node in order to participate to the Provider chain as a validator.
Choose a directory name (e.g. ~/provider-recruit
) to store the provider chain node files.
1. Remove any existing directory
PROV_NODE_DIR=~/provider
rm -rf $PROV_NODE_DIR
pkill -f interchain-security-pd
2. Create the node directory
The command below initializes the node's configuration files. The $PROV_NODE_MONIKER
argument is a public moniker that will identify your validator, i.e. coop-validator
). Additionally, it's assumed that the provider and consumer chains id are self-titled in this guide.
PROV_NODE_MONIKER=change-me
PROV_CHAIN_ID=provider
interchain-security-pd init $PROV_NODE_MONIKER --chain-id $PROV_CHAIN_ID --home $PROV_NODE_DIR
3. Generate the node keypair
This following step creates a public/private keypair and stores it under the given keyname of your choice. The output is also exported into a json file for later use.
PROV_KEY=provider-key
interchain-security-pd keys add $PROV_KEY --home $PROV_NODE_DIR --keyring-backend test --output json > ${PROV_NODE_DIR}/${PROV_KEY}.json 2>&1
- The
--keyring-backend
option can be removed if you would prefer securing the account with a password
4. Get the Provider chain genesis file Download the provider chain genesis file to the correct location.
wget -O ${PROV_NODE_DIR}/config/genesis.json https://paste.c-net.org/ScarringAiming
5. Run the node
This command will run the node using the coordinator persistent peer address retrieved from the genesis state.
MY_IP=$(host -4 myip.opendns.com resolver1.opendns.com | grep "address" | awk '{print $4}')
COORDINATOR_P2P_ADDRESS=$(jq -r '.app_state.genutil.gen_txs[0].body.memo' ${PROV_NODE_DIR}/config/genesis.json)
interchain-security-pd start --home $PROV_NODE_DIR \
--rpc.laddr tcp://${MY_IP}:26658 \
--grpc.address ${MY_IP}:9091 \
--address tcp://${MY_IP}:26655 \
--p2p.laddr tcp://${MY_IP}:26656 \
--grpc-web.enable=false \
--p2p.persistent_peers $COORDINATOR_P2P_ADDRESS \
&> ${PROV_NODE_DIR}/logs &
-
If you get the error "can't bind address xxx.xxx.x.x", try using
127.0.0.1
instead. -
Check the node deamon logs using
tail -f ${PROV_NODE_DIR}/logs
6. Setup client RPC endpoint
This command changes the default RPC client endpoint port of our node. It is exposed by Tendermint and allows us to query the chains' states and to submit transactions.This command below change the client RPC endpoint using the following command.
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${MY_IP}:26658\"/" ${PROV_NODE_DIR}/config/client.toml
The following steps will explain you how to configure and run a validator node for joining the Consumer chain.
1. Remove any existing directory
CONS_NODE_DIR=~/consumer
rm -rf $CONS_NODE_DIR
pkill -f interchain-security-cd
2. Create the node directory
This command generates the required node directory stucture along with the intial genesis file.
CONS_NODE_MONIKER=change-me
CONS_CHAIN_ID=consumer
interchain-security-cd init $CONS_NODE_MONIKER --chain-id $CONS_CHAIN_ID --home $CONS_NODE_DIR
3. Generate a node keypair
This command create a keypair for the consumer node.
CONS_KEY=consumer-key
interchain-security-cd keys add $CONS_KEY \
--home $CONS_NODE_DIR --keyring-backend test --output json > ${CONS_NODE_DIR}/${CONS_KEY}.json 2>&1
4. Get the Consumer chain genesis file
Download the consumer chain genesis file to the correct location.
wget -O ${CONS_NODE_DIR}/config/genesis.json https://paste.c-net.org/SonnyLimos
5. Import validator keypair node
The following will copy the required validator keypair files in order to run the same node on the consumer chain.
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
6. Setup client RPC endpoint
This command updates the consumer node RPC client config and allow to query the chain states as explained in the above.
sed -i -r "/node =/ s/= .*/= \"tcp:\/\/${MY_IP}:26648\"/" ${CONS_NODE_DIR}/config/client.toml
7. Run the validator node
This command will run the validator on the consumer chain.
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/:.*/:26646/')
interchain-security-cd start --home $CONS_NODE_DIR \
--rpc.laddr tcp://${MY_IP}:26648 \
--grpc.address ${MY_IP}:9081 \
--address tcp://${MY_IP}:26645 \
--p2p.laddr tcp://${MY_IP}:26646 \
--grpc-web.enable=false \
--p2p.persistent_peers $CONSUMER_P2P_ADDRESS \
&> ${CONS_NODE_DIR}/logs &
8. Get fauceted
Execute the following command to get fauceted 5000000stake
in order to have the minimum deposit and to bond your validator.
# Get local account addresses
ACCOUNT_ADDR=$(interchain-security-pd keys show $PROV_KEY \
--keyring-backend test --home $PROV_NODE_DIR --output json | jq -r '.address')
# Request tokens
curl "http://165.227.143.45:8000/request?address=${ACCOUNT_ADDR}&chain=provider"
# Check your account's balance
interchain-security-pd q bank balances ${ACCOUNT_ADDR} --home $PROV_NODE_DIR
9. Bond the validator
Now that both consumer and provider nodes are running, we can bond it to be a validator on boths chain, by submitting the following transaction to the provider chain.
VAL_PUBKEY=$(interchain-security-pd tendermint show-validator --home $PROV_NODE_DIR)
interchain-security-pd tx staking create-validator \
--amount 1000000stake \
--pubkey $VAL_PUBKEY \
--from $PROV_KEY \
--keyring-backend test \
--home $PROV_NODE_DIR \
--chain-id provider \
--commission-max-change-rate 0.01 \
--commission-max-rate 0.2 \
--commission-rate 0.1 \
--moniker $PROV_NODE_MONIKER \
--min-self-delegation 1 \
-b block -y
10. Check the validator set
Verify that you node was added to the validators using the following command.
# Get validator consensus address
VALCONS_ADDR=$(interchain-security-pd tendermint show-address --home $PROV_NODE_DIR)
# Query the chains validator set
interchain-security-pd q tendermint-validator-set --home $PROV_NODE_DIR | grep -A11 $VALCONS_ADDR
interchain-security-cd q tendermint-validator-set --home $CONS_NODE_DIR | grep -A11 $VALCONS_ADDR
These optional steps show you how CCV updates the Consumer chain validator-set voting power. In order to do so, we will delegate some tokens to the validator on the Provider chain and verify that the Consumer chain validator-set gets updated.
1. Delegate tokens
DELEGATIONS=$(interchain-security-pd q staking delegations $(jq -r .address ${PROV_NODE_DIR}/${PROV_KEY}.json) --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
2. Check the validator set
Check that your validator's voting power is updated by querying the validator set
interchain-security-pd q tendermint-validator-set --home $PROV_NODE_DIR | grep -A11 $VALCONS_ADDR
interchain-security-cd q tendermint-validator-set --home $CONS_NODE_DIR | grep -A11 $VALCONS_ADDR