Actions

Cronos Validator Deployment: Difference between revisions

From Chainlink Community Wiki

No edit summary
No edit summary
Line 191: Line 191:
echo "The http rpc endpoint for this network is:  ${b}http://10.10.100.122:26657${reset}"
echo "The http rpc endpoint for this network is:  ${b}http://10.10.100.122:26657${reset}"
</pre>
</pre>
=== 0.6.0-testnet to 0.7.0-rc1-testnet ===
# Wait until block `1553700` is reached.
# Open the /etc/systemd/system/cronosd.service file
## Comment out the line containing the pat to the `0.6.0-testnet`binary
## Uncomment the line containing the path to the `0.7.0-rc1-testnet` binary.

Revision as of 20:30, 11 July 2022

Deploy Cronos Testnet Validator.

There are different binaries required to get the full node synced from genesis.

cronosd-v0.6.0-testnet

cronosd-v0.7.0-rc1-testnet

cronosd-v0.7.0-rc2-testnet

cronosd-v0.7.0-rc3-testnet

cronosd-v0.7.0-testnet


Initial Build

To make it easier to track, I suggest creating a directory structure to track all of the necessary binaries.

Within this directory, you can download all of the tarballs, and extract the binaries and rename them.


For example:

tree ~/binaries/

binaries/
├── cronosd-v0.6.0-testnet
├── cronosd-v0.7.0-rc1-testnet
├── cronosd-v0.7.0-rc2-testnet
├── cronosd-v0.7.0-rc3-testnet
├── cronosd-v0.7.0-testnet
└── tarballs
    ├── 0.6.0-testnet
    │   └── cronos_0.6.0-testnet_Linux_x86_64.tar.gz
    ├── 0.7.0-rc1-testnet
    │   ├── app.toml
    │   └── cronos_0.7.0-rc1-testnet_Linux_x86_64.tar.gz
    ├── 0.7.0-rc2-testnet
    │   └── cronos_0.7.0-rc2-testnet_Linux_x86_64.tar.gz
    └── 0.7.0-rc3-testnet
        └── cronos_0.7.0-rc3-testnet_Linux_x86_64.tar.gz

Once we’ve downloaded all of the necessary binaries, we can initialize our node. (assuming your deployment is identical)


Initialize Your Node

Be sure to update the below variable with your validator's moniker/name

./binaries/cronosd-v0.6.0-testnet init $VALIDATOR_NAME --chain-id cronostestnet_338-3


Prepare Your Binaries

After running the initialize function, you will now have a hidden .cronos directory in your home path. Within here, we can go ahead and make another directory to house our various binaries.

mkdir ~/.cronos/bin<c/ode>

Then we'll simply copy all of our binaries to that directory.

cp ~/binaries/cronosd-v0.* ~/.cronos/bin/

tree ~/.cronos/

/home/devtrace/.cronos/
├── bin
│   ├── cronosd-v0.6.0-testnet
│   ├── cronosd-v0.7.0-rc1-testnet
│   ├── cronosd-v0.7.0-rc2-testnet
│   ├── cronosd-v0.7.0-rc3-testnet
│   └── cronosd-v0.7.0-testnet
├── config
│   ├── app.toml
│   ├── client.toml
│   ├── config.toml
│   ├── genesis.json
│   ├── node_key.json
│   └── priv_validator_key.json
└── data
    └── priv_validator_state.json


Update Your Configuration Files

Once we have all of the binary versions copied into ~/.cronos/bin/, we’ll go ahead download and replace the necessary genesis.json.

curl https://raw.githubusercontent.com/crypto-org-chain/cronos-testnets/main/cronostestnet_338-3/genesis.json > ~/.cronos/config/genesis.json

With our genesis file downloaded, we can verify it’s correctness via checksum

if awk '{print $1}') = "7d898ad75b3e2e1fa182d928ca10a284c1dd252e12d17ad6dab76551b29d1a59" ; then echo "OK"; else echo "MISMATCHED"; fi;

If the checksums match, then the command output will be OK. If it does not match, then the command output will be MISMATCHED

And then we’ll need to make some adjustments to your app.toml file

sed -i.bak -E 's#^(minimum-gas-pricesspace:+=space:+).*$#\1"5000000000000basetcro"#' ~/.cronos/config/app.toml

As well as our config.toml

sed -i.bak -E 's#^(persistent_peersspace:+=space:+).*$#\1"8fcba3485c67a2a00a383b6f45660a4ac529c6ca@52.77.30.18:26656,e65199bc579ffd89d7c021c5611f9f1c97f7ff13@54.251.209.254:26656"#' ~/.cronos/config/config.toml

sed -i.bak -E 's#^(create_empty_blocks_intervalspace:+=space:+).*$#\1"5s"#' ~/.cronos/config/config.toml

sed -i.bak -E 's#^(timeout_commitspace:+=space:+).*$#\1"5s"#' ~/.cronos/config/config.toml


Lastly, we will create the cronosd service.

Create cronosd Service

sudo nano /etc/systemd/system/cronosd.service

[Unit]
Description=cronosd
After=network.target auditd.service
Wants=network.target

[Service]
Type=simple
User=$YOUR_USERNAME
WorkingDirectory=/home/$YOUR_USERNAME/.cronos
ExecStart=/home/$YOUR_USERNAME/.cronos/bin/cronosd-v0.6.0-testnet start --home /home/$YOUR_USERNAME/.cronos
#ExecStart=/home/$YOUR_USERNAME/.cronos/bin/cronosd-v0.7.0-rc1-testnet start --home /home/$YOUR_USERNAME/.cronos
#ExecStart=/home/de$YOUR_USERNAMEvtrace/.cronos/bin/cronosd-v0.7.0-rc2-testnet start --home /home/$YOUR_USERNAME/.cronos
#ExecStart=/home/$YOUR_USERNAME/.cronos/bin/cronosd-v0.7.0-rc3-testnet start --home /home/$YOUR_USERNAME/.cronos
#ExecStart=/home/$YOUR_USERNAME/.cronos/bin/cronosd-v0.7.0-testnet start --home /home/$YOUR_USERNAME/.cronos
Restart=on-failure
RestartSec=10
LimitNOFILE=50000

[Install]
WantedBy=multi-user.target

With the service file created, we can now start it.

sudo systemctl enable cronosd.service && sudo systemctl start cronosd.service

Performing Upgrades

With each new release of software, we need to stop, modify, and restart the cronosd service.

For the upgrade from `0.6.0-testnet` to the `0.7.0-rc1-testnet` release, we will need to stop the service once we reach block number `1553700`.

We can check the latest block with the simply bash script below:

#!/bin/bash

# bold
b=$(tput bold)

# blue foreground
blue_fg=$(tput setaf 6)

# yello foreground
yellow_fg=$(tput setaf 3)

# reset to default
reset=$(tput sgr0)


# SET VARS
BLOCK_HEIGHT=$(curl -s localhost:26657/block | jq -r .result.block.header.height)
CRONOS_EXPLORER_BLOCK_HEIGHT=$(curl -s -X GET "https://cronos.org/explorer/api?module=block&action=eth_block_number" -H "accept: application/json" | jq -r .result)
PEER_COUNT=$(curl -s -H "Content-Type: application/json" http://localhost:8545 -d '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}' | jq -r .result)
IS_SYNCING=$(curl -s localhost:26657/status | jq -r .result.sync_info.catching_up)

echo "----------------------"
echo "RPC Node block height:        ${blue_fg}$((BLOCK_HEIGHT))${reset}"
echo "Cronos Explorer block height: ${blue_fg}$((CRONOS_EXPLORER_BLOCK_HEIGHT))${reset}"

VAR1=$(curl -s -H "Content-Type: application/json" http://localhost:8545 -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_syncing"}' | jq .result)
VAR2="false"
if [ "$VAR1" = "$VAR2" ]; then
    echo "Sync Status:           ${blue_fg}Node is synced.${reset}"
else
    echo "${blue_fg}Node is ${yellow_fg}NOT${blue_fg} synced.${reset}"
fi
echo ""
COUNT=$((BLOCK_HEIGHT-CRONOS_EXPLORER_BLOCK_HEIGHT))
echo "Local endpoint is ${b}$COUNT${reset} blocks behind."
echo ""
echo "The websocket endpoint for this network is: ${b}  ws://10.10.100.122:26657/websocket${reset}"
echo "The http rpc endpoint for this network is:  ${b}http://10.10.100.122:26657${reset}"


0.6.0-testnet to 0.7.0-rc1-testnet

  1. Wait until block `1553700` is reached.
  2. Open the /etc/systemd/system/cronosd.service file
    1. Comment out the line containing the pat to the `0.6.0-testnet`binary
    2. Uncomment the line containing the path to the `0.7.0-rc1-testnet` binary.