# Updating a validator
If you are a new validator you need follow the "Becoming a validator" procedure.
DO NOT USE THIS UPDATE PROCEDURES
This section describes the procedure that needs to be followed in order to update a validator node from one version to another.
Please note that each chain version has an update type associated to it. In order to know which one is associated to the chain version you are currently running, please do the following:
- Go to our chains repo
- Enter the folder of you current chain's version
- Open the
- Read the value associated to the
Once you know the update type, please follow the related procedure:
# Update type 1 - Hard fork
The procedure to follow in order to upgrade the chain using this update type is very similar to the installation procedure.
Due to this procedure being a hard fork, this means that any of the current chain data will be completely wiped and a new chain will start from scratch. However, if you want you can create a copy of the current chain state in order to use it for testing purposes.
# 1. Wipe the current chain state
To start the procedure we need to kill the service running the chain:
systemctl stop cnd pkill cnd
Now, we need to wipe the chain state. In order to do so, you have two options:
- Backup your data
cp -r ~/.cnd ~/.cnd.back
- Delete the data without a backup
rm -rf ~/.cnd
# 2. Start a new chain
Once you have properly cleaned up the previous chain state, you are ready to start the new chain version.
To do so, please refer to the full node installation guide but remember to apply the following changes to the procedure described there:
1. Inside the first step in order to update the OS so that you can work properly execute the following commands:
apt update && apt upgrade -y snap refresh --classic go
2. During the 4th step
you don't need to change the follow rows of your
export GOPATH="\$HOME/go" export PATH="\$GOPATH/bin:\$PATH"
You also need to clean up the files from the previous chain configurations
sed -i \ -e '/export NODENAME=.*/d' \ -e '/export CHAINID=.*/d' ~/.profile
and add the new chain ones
export NODENAME="<your-moniker>" export CHAINID=commercio-$(cat .data | grep -oP 'Name\s+\K\S+') cat <<EOF >> ~/.profile export NODENAME="$NODENAME" export CHAINID="$CHAINID" EOF
# Update type 2 - Soft fork
The second update type is the one known as soft fork.
In this case, the chain state will be preserved from its beginning to a certain point in time.
When signalling a required update that should follow this procedure, the following information will be let known to all validators:
- A specific block height
- The genesis file checksum
- The new chain software version
- A deadline expressed in UTC format
If you are a validator, please make sure that you know all those information before proceeding with the update.
Due to the nature of the update operations, there is some risk of double signature.
To avoid every sort of risks please verify the software version, the hash of the
genesis.json file and the specific
configuration present inside the
The deadline of the update must be respected: every validator that will not update just in time will be slashed.
Before starting the update it ss recommended to take a full data snapshot of the chain state at the export height.
To do so please run:
systemctl stop cnd cp -r ~/.cnd ~/.cnd.back cp -r ~/.cncli ~/.cncli.back cp -r /root/go/bin/cnd /root/go/bin/cnd.back cp -r /root/go/bin/cncli /root/go/bin/cncli.back
# Update procedure
# 1. Updating the software
In order to properly update your validator node, first of all you need to clone the
rm -rf commercio-chains mkdir commercio-chains && cd commercio-chains git clone https://github.com/commercionetwork/chains.git . cd commercio-<chain-version> # eg. cd commercio-testnet3000
Once downloaded, you need to compile the binaries:
git init . git remote add origin https://github.com/commercionetwork/commercionetwork.git git pull git checkout tags/$(cat .data | grep -oP 'Release\s+\K\S+') make install
After the compilation has finished successfully, please make sure you are running the correct software version:
cnd version # Should output the same version written inside the .data file
# 2. Export the chain state (WIP)
Once the software has properly been updated, we need to export the current chain state and later import it.
In order to do so, first of all you need to get the export height from the
export BLOCKHEIGHT=$(cat .data | grep -oP 'Height\s+\K\S+')
# Update type 3 - Binaries update
In order to update minor version of biniaries you need
# 1. Stop service
systemctl stop cnd
# 2. Chain selection
rm -rf commercio-chains mkdir commercio-chains && cd commercio-chains git clone https://github.com/commercionetwork/chains.git . cd commercio-<chain-version>
# 3. Install new binaries
pkill cncli git init . git remote add origin https://github.com/commercionetwork/commercionetwork.git git pull git checkout tags/$(cat .data | grep -oP 'Release\s+\K\S+') make install
# 4. Restart service
systemctl enable cnd systemctl start cnd
# 5. Control if chain works
Control if the sync was started. Use
Ctrl + C to interrupt the
tail -100f /var/log/syslog # OUTPUT SHOULD BE LIKE BELOW # # Aug 13 16:30:20 commerciotestnet-node4 cnd: I[2019-08-13|16:30:20.722] Executed block module=state height=1 validTxs=0 invalidTxs=0 # Aug 13 16:30:20 commerciotestnet-node4 cnd: I[2019-08-13|16:30:20.728] Committed state module=state height=1 txs=0 appHash=9815044185EB222CE9084AA467A156DFE6B4A0B1BAAC6751DE86BB31C83C4B08 # Aug 13 16:30:20 commerciotestnet-node4 cnd: I[2019-08-13|16:30:20.745] Executed block module=state height=2 validTxs=0 invalidTxs=0 # Aug 13 16:30:20 commerciotestnet-node4 cnd: I[2019-08-13|16:30:20.751] Committed state module=state height=2 txs=0 appHash=96BFD9C8714A79193A7913E5F091470691B195E1E6F028BC46D6B1423F7508A5 # Aug 13 16:30:20 commerciotestnet-node4 cnd: I[2019-08-13|16:30:20.771] Executed block module=state height=3 validTxs=0 invalidTxs=0
# 6. Restart the REST API if you need
cncli config chain-id $CHAINID cncli rest-server