Created
September 16, 2024 12:38
-
-
Save toschdev/36b65f509ef5a9f2503be86beff25b37 to your computer and use it in GitHub Desktop.
Interchain Security Setup, Create and Start the Procedure Bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Enable strict mode: exit on error, print commands, and treat unset variables as errors. | |
set -eux | |
# Setup Variables | |
# Define total and staked coin amounts for validators | |
TOTAL_COINS=100000000000stake | |
STAKE_COINS=100000000stake | |
# Define paths, binary, and other configuration parameters | |
PROVIDER_BINARY=interchain-security-pd | |
PROVIDER_HOME="$HOME/.provider" | |
PROVIDER_CHAIN_ID=provider | |
PROVIDER_MONIKER=provider | |
VALIDATOR=validator | |
NODE_IP="localhost" | |
PROVIDER_RPC_LADDR="$NODE_IP:26658" | |
PROVIDER_GRPC_ADDR="$NODE_IP:9091" | |
PROVIDER_DELEGATOR=delegator | |
# Terminate any running instances of the blockchain binary | |
killall $PROVIDER_BINARY &> /dev/null || true | |
####### VALIDATOR 1 SETUP ####### | |
rm -rf $PROVIDER_HOME # Clean previous data if any | |
# Initialize the blockchain with a moniker and chain ID | |
$PROVIDER_BINARY init $PROVIDER_MONIKER --home $PROVIDER_HOME --chain-id $PROVIDER_CHAIN_ID | |
# Update genesis parameters for testing | |
jq ".app_state.gov.voting_params.voting_period = \"3s\" | \ | |
.app_state.staking.params.unbonding_time = \"600s\" | \ | |
.app_state.provider.params.template_client.trusting_period = \"300s\"" \ | |
$PROVIDER_HOME/config/genesis.json > \ | |
$PROVIDER_HOME/edited_genesis.json && mv $PROVIDER_HOME/edited_genesis.json $PROVIDER_HOME/config/genesis.json | |
sleep 1 | |
# Create key pairs for the validator and delegator | |
$PROVIDER_BINARY keys add $VALIDATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair.json 2>&1 | |
sleep 1 | |
$PROVIDER_BINARY keys add $PROVIDER_DELEGATOR --home $PROVIDER_HOME --keyring-backend test --output json > $PROVIDER_HOME/keypair_delegator.json 2>&1 | |
sleep 1 | |
# Add total coins to the validator and delegator accounts | |
$PROVIDER_BINARY genesis add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test | |
sleep 1 | |
$PROVIDER_BINARY genesis add-genesis-account $(jq -r .address $PROVIDER_HOME/keypair_delegator.json) $TOTAL_COINS --home $PROVIDER_HOME --keyring-backend test | |
sleep 1 | |
# Generate genesis transaction for staking 1/1000 coins | |
$PROVIDER_BINARY genesis gentx $VALIDATOR $STAKE_COINS --chain-id $PROVIDER_CHAIN_ID --home $PROVIDER_HOME --keyring-backend test --moniker $VALIDATOR | |
sleep 1 | |
$PROVIDER_BINARY genesis collect-gentxs --home $PROVIDER_HOME | |
# Start node | |
$PROVIDER_BINARY start \ | |
--home $PROVIDER_HOME \ | |
--rpc.laddr tcp://$PROVIDER_RPC_LADDR \ | |
--grpc.address $PROVIDER_GRPC_ADDR \ | |
--address tcp://${NODE_IP}:26655 \ | |
--p2p.laddr tcp://${NODE_IP}:26656 \ | |
--grpc-web.enable=false \ | |
--trace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment