-
Setting up two chains
# change HOME1 & HOME2 for proper value KEY1="key1" KEY2="key2" CHAINID="canto_7700-1" MONIKER1="canto1" MONIKER2="canto2" KEYRING="test" KEYALGO="eth_secp256k1" HOME1="$HOME/workspace/canto1" HOME2="$HOME/workspace/canto2" rm -rf $HOME1 rm -rf $HOME2 # initialize two chains cantod init $MONIKER1 --chain-id $CHAINID --home $HOME1 cantod init $MONIKER2 --chain-id $CHAINID --home $HOME2 # Setting up keys cantod keys add $KEY1 --keyring-backend $KEYRING --algo $KEYALGO --home $HOME1 cantod keys add $KEY2 --keyring-backend $KEYRING --algo $KEYALGO --home $HOME2 # Change parameter token denominations to acanto cat $HOME1/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="acanto"' > $HOME1/config/tmp_genesis.json && mv $HOME1/config/tmp_genesis.json $HOME1/config/genesis.json cat $HOME1/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="acanto"' > $HOME1/config/tmp_genesis.json && mv $HOME1/config/tmp_genesis.json $HOME1/config/genesis.json cat $HOME1/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="acanto"' > $HOME1/config/tmp_genesis.json && mv $HOME1/config/tmp_genesis.json $HOME1/config/genesis.json cat $HOME1/config/genesis.json | jq '.app_state["evm"]["params"]["evm_denom"]="acanto"' > $HOME1/config/tmp_genesis.json && mv $HOME1/config/tmp_genesis.json $HOME1/config/genesis.json cat $HOME1/config/genesis.json | jq '.app_state["inflation"]["params"]["mint_denom"]="acanto"' > $HOME1/config/tmp_genesis.json && mv $HOME1/config/tmp_genesis.json $HOME1/config/genesis.json # Change voting params so that submitted proposals pass immediately for testing cat $HOME1/config/genesis.json| jq '.app_state.gov.voting_params.voting_period="30s"' > $HOME1/config/tmp_genesis.json && mv $HOME1/config/tmp_genesis.json $HOME1/config/genesis.json # disable produce empty block if [[ "$OSTYPE" == "darwin"* ]]; then sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME1/config/config.toml else sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME1/config/config.toml fi if [[ $1 == "pending" ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then sed -i '' 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME1/config/config.toml sed -i '' 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME1/config/config.toml sed -i '' 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME1/config/config.toml sed -i '' 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME1/config/config.toml sed -i '' 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME1/config/config.toml sed -i '' 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME1/config/config.toml sed -i '' 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME1/config/config.toml sed -i '' 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME1/config/config.toml sed -i '' 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME1/config/config.toml else sed -i 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME1/config/config.toml sed -i 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME1/config/config.toml sed -i 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME1/config/config.toml sed -i 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME1/config/config.toml sed -i 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME1/config/config.toml sed -i 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME1/config/config.toml sed -i 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME1/config/config.toml sed -i 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME1/config/config.toml sed -i 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME1/config/config.toml fi fi # Allocate genesis accounts (cosmos formatted addresses) cantod add-genesis-account $KEY1 1000000000000000000000000000000000acanto --keyring-backend $KEYRING --home $HOME1 # Update total supply with claim values #validators_supply=$(cat $HOME1/config/genesis.json | jq -r '.app_state["bank"]["supply"][0]["amount"]') # Bc is required to add this big numbers # total_supply=$(bc <<< "$amount_to_claim+$validators_supply") total_supply=1000000000000000000000000000000000 cat $HOME1/config/genesis.json | jq -r --arg total_supply "$total_supply" '.app_state["bank"]["supply"][0]["amount"]=$total_supply' > $HOME1/config/tmp_genesis.json && mv $HOME1/config/tmp_genesis.json $HOME1/config/genesis.json echo $KEYRING echo $KEY1 # Sign genesis transaction mkdir $HOME1/config/gentx cantod gentx $KEY1 900000000000000000000000acanto --keyring-backend $KEYRING --chain-id $CHAINID --output-document $HOME1/config/gentx/gentx-1.json --home $HOME1 # Collect genesis tx cantod collect-gentxs --home $HOME1 # Run this to ensure everything worked and that the genesis file is setup correctly cantod validate-genesis --home $HOME1
-
Copy genesis file from chain 1 to chain 2
cp $HOME1/config/genesis.json $HOME2/config/genesis.json
-
Change configs for chain 2 (changing ports) (path: $HOME2/config/)
#app.toml address = "tcp://0.0.0.0:1317" --> address = "tcp://0.0.0.0:11317" address = ":8080" --> address = ":9080" address = "0.0.0.0:9090" --> address = "0.0.0.0:19090" address = "0.0.0.0:9091" --> address = "0.0.0.0:19091" address = "0.0.0.0:8545" --> address = "0.0.0.0:18545" ws-address = "0.0.0.0:8546" --> ws-address = "0.0.0.0:18546" #client.toml node = "tcp://localhost:26657" --> node = "tcp://localhost:36657" # config.toml proxy_app = "tcp://127.0.0.1:26658" --> proxy_app = "tcp://127.0.0.1:36658" laddr = "tcp://127.0.0.1:26657" --> laddr = "tcp://127.0.0.1:36657" pprof_laddr = "localhost:6060" --> pprof_laddr = "localhost:16060" laddr = "tcp://0.0.0.0:26656" --> laddr = "tcp://0.0.0.0:36656" prometheus_listen_addr = ":26660" --> prometheus_listen_addr = ":36660"
-
Setup persistent peer (for chain 2)
echo $(cantod tendermint show-node-id --home $HOME1)'@0.0.0.0:26656' 25839f2ef44109c5d7de0d0cf6267d9679949e72@0.0.0.0:26656 # copy printed value to persistent-peer value in config.toml persistent_peers = "25839f2ef44109c5d7de0d0cf6267d9679949e72@0.0.0.0:26656"
-
Start chains in new terminals
cantod start --home $HOME/workspace/canto1 cantod start --home $HOME/workspace/canto2
-
Send tokens to key2 account (2nd validator)
DST=$(cantod keys show $KEY2 --home $HOME2 --keyring-backend $KEYRING -a) cantod tx bank send $KEY1 $DST 100000000000000000000000000000000acanto --from $KEY1 --home $HOME1 --keyring-backend $KEYRING --chain-id $CHAINID
-
Create a new validator
cantod tx staking create-validator \ --amount=10000000000000000000000000000000acanto \ --pubkey=$(cantod tendermint show-validator --home $HOME2) \ --chain-id=$CHAINID \ --commission-rate="0.10" \ --commission-max-rate="0.20" \ --commission-max-change-rate="0.01" \ --min-self-delegation="1000000" \ --gas="100000000" \ --gas-prices="200000000000acanto" \ --from=$KEY2 \ --home=$HOME2 \ --keyring-backend=$KEYRING --broadcast-mode block
-
Query validators
cantod q staking validators --home $HOME1 pagination: next_key: null total: "0" validators: - commission: commission_rates: max_change_rate: "0.010000000000000000" max_rate: "0.200000000000000000" rate: "0.100000000000000000" update_time: "2023-07-21T12:24:46.454249Z" consensus_pubkey: '@type': /cosmos.crypto.ed25519.PubKey key: 5JD+a4XJQcvgRHO35LPlet5dSjG26vso4hFVADmTmGQ= delegator_shares: "900000000000000000000000.000000000000000000" description: details: "" identity: "" moniker: canto1 security_contact: "" website: "" jailed: false min_self_delegation: "1" operator_address: cantovaloper106sydspjcewhlxzy207lpguecdmlqg2z6zlf4e status: BOND_STATUS_BONDED tokens: "900000000000000000000000" unbonding_height: "0" unbonding_time: "1970-01-01T00:00:00Z" - commission: commission_rates: max_change_rate: "0.010000000000000000" max_rate: "0.200000000000000000" rate: "0.100000000000000000" update_time: "2023-07-21T12:51:08.800150Z" consensus_pubkey: '@type': /cosmos.crypto.ed25519.PubKey key: ULuR/W5wjhSRuPTfvzM0rxkQ33F0MiuEOlefS0o0P5w= delegator_shares: "10000000000000000000000000000000.000000000000000000" description: details: "" identity: "" moniker: canto2 security_contact: "" website: "" jailed: false min_self_delegation: "10000000000" operator_address: cantovaloper16l6l04lf0lm4azkm2jxgs86zlgvk97sul0h5c2 status: BOND_STATUS_BONDED tokens: "10000000000000000000000000000000" unbonding_height: "0" unbonding_time: "1970-01-01T00:00:00Z"
Created
December 8, 2023 02:13
-
-
Save zsystm/dd186c0dfa8c4782809b5c0fe56c4ad0 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment