Cronos Validator Deployment: Difference between revisions
From Chainlink Community Wiki
No edit summary |
No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 67: | Line 67: | ||
<code>tree ~/.cronos/</code> | <code>tree ~/.cronos/</code> | ||
<pre style="white-space:pre-wrap; width:100%; border:1px solid lightgrey; background:black; color:white;">/home/ | <pre style="white-space:pre-wrap; width:100%; border:1px solid lightgrey; background:black; color:white;">/home/$USERNAME/.cronos/ | ||
├── bin | ├── bin | ||
│ ├── cronosd-v0.6.0-testnet | │ ├── cronosd-v0.6.0-testnet | ||
Line 172: | Line 172: | ||
IP_ADDR=$(hostname -I | awk '{print $1}') | IP_ADDR=$(hostname -I | awk '{print $1}') | ||
BLOCK_HEIGHT=$(curl -s localhost:26657/block | jq -r .result.block.header.height) | BLOCK_HEIGHT=$(curl -s localhost:26657/block | jq -r .result.block.header.height) | ||
CRONOS_EXPLORER_BLOCK_HEIGHT=$(curl -s -X GET "https:// | CRONOS_EXPLORER_BLOCK_HEIGHT=$(curl -s -X GET "https://api-testnet.cronoscan.com/api?module=proxy&action=eth_blockNumber&apikey=$YOUR_API_KEY" -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) | 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) | IS_SYNCING=$(curl -s localhost:26657/status | jq -r .result.sync_info.catching_up) | ||
Line 183: | Line 183: | ||
VAR2="false" | VAR2="false" | ||
if [ "$VAR1" = "$VAR2" ]; then | if [ "$VAR1" = "$VAR2" ]; then | ||
printf '\U2705\n' | |||
echo "Sync Status: ${blue_fg}Node is synced.${reset}" | echo "Sync Status: ${blue_fg}Node is synced.${reset}" | ||
else | else | ||
printf '\U274C\n' | |||
echo "${blue_fg}Node is ${yellow_fg}NOT${blue_fg} synced.${reset}" | echo "${blue_fg}Node is ${yellow_fg}NOT${blue_fg} synced.${reset}" | ||
fi | fi | ||
echo "" | echo "" | ||
echo "----------------------" | echo "----------------------" | ||
if (( $BLOCK_HEIGHT < $CRONOS_EXPLORER_BLOCK_HEIGHT && $BLOCK_HEIGHT > 2483600)); then | if (( $BLOCK_HEIGHT <= $CRONOS_EXPLORER_BLOCK_HEIGHT && $BLOCK_HEIGHT >= 2483600)); then | ||
printf '\U1F44C\n' | |||
echo "${blue_fg}Running latest release.${reset}" | |||
COUNT=$((BLOCK_HEIGHT-CRONOS_EXPLORER_BLOCK_HEIGHT)) | COUNT=$((BLOCK_HEIGHT-CRONOS_EXPLORER_BLOCK_HEIGHT)) | ||
echo "Local endpoint is ${b}$COUNT${reset} blocks behind." | echo "Local endpoint is ${b}$COUNT${reset} blocks behind." | ||
elif (( $BLOCK_HEIGHT > | elif (( $BLOCK_HEIGHT >= 1869000 && $BLOCK_HEIGHT < 2483600 )); then | ||
printf '\U23F3\n' | |||
echo "${yellow_fg}Running 0.7.0-rc2-testnet.${reset}" | |||
BLOCKS_UNTIL_FORK=$(($BLOCK_HEIGHT-2483600)) | |||
echo "Blocks remaining until binary 0.7.0-rc3-testnet: ${yellow_fg}$BLOCKS_UNTIL_FORK${reset}" | |||
elif (( $BLOCK_HEIGHT >= 1553701 && $BLOCK_HEIGHT <= 1869000 )); then | |||
printf '\U23F3\n' | |||
echo "${yellow_fg}Running 0.7.0-rc1-testnet.${reset}" | |||
BLOCKS_UNTIL_FORK=$(($BLOCK_HEIGHT-1869000)) | BLOCKS_UNTIL_FORK=$(($BLOCK_HEIGHT-1869000)) | ||
echo "Blocks remaining until binary 0.7.0-rc2-testnet: ${yellow_fg}$BLOCKS_UNTIL_FORK${reset}" | echo "Blocks remaining until binary 0.7.0-rc2-testnet: ${yellow_fg}$BLOCKS_UNTIL_FORK${reset}" | ||
elif (( $BLOCK_HEIGHT < | elif (( $BLOCK_HEIGHT <= 1553700 )); then | ||
printf '\U23F3\n' | |||
echo "${yellow_fg}Running 0.6.0-testnet.${reset}" | |||
BLOCKS_UNTIL_FORK=$(($BLOCK_HEIGHT-1553701)) | BLOCKS_UNTIL_FORK=$(($BLOCK_HEIGHT-1553701)) | ||
echo "Blocks remaining until binary 0.7.0-rc1-testnet: ${yellow_fg}$BLOCKS_UNTIL_FORK${reset}" | echo "Blocks remaining until binary 0.7.0-rc1-testnet: ${yellow_fg}$BLOCKS_UNTIL_FORK${reset}" | ||
Line 205: | Line 216: | ||
echo "" | echo "" | ||
echo "----------------------" | echo "----------------------" | ||
echo "The websocket endpoint for this network is: ${b} ws://$IP_ADDR: | echo "The websocket endpoint for this network is: ${b} ws://$IP_ADDR:8546${reset}" | ||
echo "The http rpc endpoint for this network is: ${b}http://$IP_ADDR: | echo "The http rpc endpoint for this network is: ${b}http://$IP_ADDR:8545${reset}" | ||
</pre> | </pre> | ||
Latest revision as of 22:13, 14 July 2022
Deploy Cronos Testnet Validator.
There are different binaries required to get the full node synced from genesis.
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
Then we'll simply copy all of our binaries to that directory.
cp ~/binaries/cronosd-v0.* ~/.cronos/bin/
tree ~/.cronos/
/home/$USERNAME/.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/$YOUR_USERNAME/.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
sudo systemctl start cronosd.service
Performing Upgrades
With each new release of software, we need to stop, modify, and restart the cronosd service.
For each upgrade, we will need to stop the service once it has reached a specific block height, as it will not continue past that epoch.
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 IP_ADDR=$(hostname -I | awk '{print $1}') BLOCK_HEIGHT=$(curl -s localhost:26657/block | jq -r .result.block.header.height) CRONOS_EXPLORER_BLOCK_HEIGHT=$(curl -s -X GET "https://api-testnet.cronoscan.com/api?module=proxy&action=eth_blockNumber&apikey=$YOUR_API_KEY" -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 printf '\U2705\n' echo "Sync Status: ${blue_fg}Node is synced.${reset}" else printf '\U274C\n' echo "${blue_fg}Node is ${yellow_fg}NOT${blue_fg} synced.${reset}" fi echo "" echo "----------------------" if (( $BLOCK_HEIGHT <= $CRONOS_EXPLORER_BLOCK_HEIGHT && $BLOCK_HEIGHT >= 2483600)); then printf '\U1F44C\n' echo "${blue_fg}Running latest release.${reset}" COUNT=$((BLOCK_HEIGHT-CRONOS_EXPLORER_BLOCK_HEIGHT)) echo "Local endpoint is ${b}$COUNT${reset} blocks behind." elif (( $BLOCK_HEIGHT >= 1869000 && $BLOCK_HEIGHT < 2483600 )); then printf '\U23F3\n' echo "${yellow_fg}Running 0.7.0-rc2-testnet.${reset}" BLOCKS_UNTIL_FORK=$(($BLOCK_HEIGHT-2483600)) echo "Blocks remaining until binary 0.7.0-rc3-testnet: ${yellow_fg}$BLOCKS_UNTIL_FORK${reset}" elif (( $BLOCK_HEIGHT >= 1553701 && $BLOCK_HEIGHT <= 1869000 )); then printf '\U23F3\n' echo "${yellow_fg}Running 0.7.0-rc1-testnet.${reset}" BLOCKS_UNTIL_FORK=$(($BLOCK_HEIGHT-1869000)) echo "Blocks remaining until binary 0.7.0-rc2-testnet: ${yellow_fg}$BLOCKS_UNTIL_FORK${reset}" elif (( $BLOCK_HEIGHT <= 1553700 )); then printf '\U23F3\n' echo "${yellow_fg}Running 0.6.0-testnet.${reset}" BLOCKS_UNTIL_FORK=$(($BLOCK_HEIGHT-1553701)) echo "Blocks remaining until binary 0.7.0-rc1-testnet: ${yellow_fg}$BLOCKS_UNTIL_FORK${reset}" fi echo "" echo "----------------------" echo "The websocket endpoint for this network is: ${b} ws://$IP_ADDR:8546${reset}" echo "The http rpc endpoint for this network is: ${b}http://$IP_ADDR:8545${reset}"
0.6.0-testnet --> 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 path to the 0.6.0-testnet binary
- Uncomment the line containing the path to the 0.7.0-rc1-testnet binary.
- Example:
# 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/$YOUR_USERNAME/.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
- Replace/Update your app.toml
curl https://raw.githubusercontent.com/crypto-org-chain/cronos-testnets/main/cronostestnet_338-3/app.toml > ~/.cronos/config/app.toml
- Start the service again.
sudo systemctl daemon-reload && sudo systemctl start cronosd.service
0.7.0-rc1-testnet --> 0.7.0-rc2-testnet
- Wait until block 1869000 is reached.
- Open the /etc/systemd/system/cronosd.service file
- Comment out the line containing the path to the 0.7.0-rc1-testnet binary
- Uncomment the line containing the path to the 0.7.0-rc2-testnet binary.
- Example:
# 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/$YOUR_USERNAME/.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
- Start the service again.
sudo systemctl daemon-reload && sudo systemctl start cronosd.service
0.7.0-rc2-testnet --> 0.7.0-rc3-testnet
- Wait until block 2483600 is reached.
- Open the /etc/systemd/system/cronosd.service file
- Comment out the line containing the path to the 0.7.0-rc2-testnet binary
- Uncomment the line containing the path to the 0.7.0-rc3-testnet binary.
- Example:
# 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/$YOUR_USERNAME/.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
- Start the service again.
sudo systemctl daemon-reload && sudo systemctl start cronosd.service