Filter by category:

Knowledge hub home

How to set up a validator node on CENNZnet

Setting up a validator node

Translations of this article can be found here:

🇯🇵 Japanese version

This guide will cover how to set up a Validator node on CENNZnet. Specifically how to set up a Validator node in a non-programmatic way which can be done with docker or system admin skills.

There are two ways to set up a validator node on CENNZnet:

  1. Using the CENNZnet API

  2. Using the CENNZnet portal (https://cennznet.io/)

The API method requires JavaScript programming skills. It allows you to automate the process, so you can set up multiple validators more easily. To set up a validator programmatically using CENNZnet’s API, please refer to our technical documentation found on the Wiki here.

The CENNZnet portal method can be done by anyone regardless of coding skill and is quicker to complete.

Requirements:

  • Familiar with using the command line

  • Docker or system admin experiences

 

Setting up a validator node using the CENNZnet.io portal

 

Step 1: Start a validator node

  1. Start a fresh node: this is a faster process, but you may need to wait a couple of days for it to finish synchronisation, depending on the network conditions.

  2. Start a node from a snapshot: this requires downloading a snapshot (a complete copy of the state of a node) which is currently around 50G. Once you have downloaded the snapshot, you can start a node that’s already synchronised.

Starting a fresh node

Run the following command in your terminal to start a node as a validator and join the CENNZnet Mainnet (Azalea).

				
					
# Edit this command before running it:
# 1. Replace “<VERSION>” with the latest version number, for example, “1.4.0”. The release number can be found here.
# 2. Replace “<MY_NODE>” with a name you’d like to call your node
# 3. Run it and inspect it from Docker dashboard

# Note: the -d option makes the docker container run in detached mode, which means it'll continue running even if you close terminal.
# You can use --it if you'd rather keep the terminal window open and see the output there.
# Please don't shut down the validator node without performing a "chill" action, to avoid penalties.

# Warning: The following command allows for setting session key. This exposes a security risk.
# The RPC methods should be constrained to use on localhost only
# Protect your PRC port with network security rules and the firewall

docker run -p 9944:9944 -p 9933:9933 -d --restart=always \
cennznet/cennznet:<VERSION> \
--chain=/cennznet/genesis/azalea.raw.json \
--validator \
--name=<MY_NODE> \
--telemetry-url 'ws://cennznet-telemetry.centrality.me:8000/submit 0' \
--rpc-methods=Unsafe \
--ws-external \
--rpc-external \
--rpc-cors=https://cennznet.io
				
			

This command won’t create blocks or participate in validating until you have completed all of the steps outlined in this document.

 

Starting a node from a snapshot

  1. Unzip the archive

  2. Edit the following command and run it

				
					
# Note: the -d option makes the docker container run in detached mode, which means it'll continue running even if you close terminal.
# You can use --it if you'd rather keep the terminal window open and see the output there.
# Please don't shut down the validator node without performing a "chill" action, to avoid penalties.

# Edit this command before running it:
# Replace “<VERSION>” with the latest version number, for example, “1.4.0”. The release number can be found here.
# Replace “<MY_NODE>” with a name you’d like to call your node
# Replace the “</path/to/dir/containing/the/unzipped/archive>” in the following command with the path to where you’ve unzipped the archive, and run the command in your terminal.

docker run -p 9944:9944 -p 9933:9933 -d --restart=always \
-v </path/to/dir/containing/the/unzipped/archive>:/mnt/cennznet \
cennznet/cennznet:<VERSION> --validator \
--chain=/cennznet/genesis/azalea.raw.json \
--base-path /mnt/cennznet --unsafe-ws-external \
--unsafe-rpc-external \
--rpc-external \
--rpc-cors=https://cennznet.io --rpc-methods=Unsafe \
--telemetry-url 'ws://cennznet-telemetry.centrality.me:8000/submit 0' \
--name <MY_NODE>
				
			

Step 2: Wait for the node to synchronise

				
					INFO ⚙️ Syncing 21.2 bps, target=#1140132 (1 peers), best: #532405 (0xfad8…07ea), finalized #531968 (0x1a24…d249), ⬇ 7.3kiB/s ⬆ 60 B/s
				
			

Step 3: Place funds at stake

During the bonding transaction, we can also set a controller account and specify the account where you wish to receive staking rewards.

  1. Go to CENNZnet.io

  2. Navigate to Advanced->Extrinsics

  3. In the first row, select the stash account: the account that holds the CENNZ you’d like to stake.

  4. In the second row, select “Staking” and “bond”

  5. In the “controller” field, select a controller account: the account that manages staking for your validator. The controller can be the same as the stash account, but it’s recommended to use a separate controller account as a security best practice.

  6. Set the amount of CENNZ to stake

  7. In the “pay” field, select the account where you would like to receive the staking reward. By default, the staking reward goes back to the stash account. You can choose to replace the default with a different account here.

For more information about stash vs controller account, please refer to our technical document on our Github Wiki here.

 

Step 4: Claim session keys

To claim your session keys you need to link your running validator node with a controller account which will act on behalf of the stash account. The controller account will make a transaction to claim some session keys on behalf of the stash.

Session keys may be rotated using this process at any time.

There are 2 steps in claiming session keys:

  1. Generate a new session key

  2. Set session keys

 

Step 4.1 Generate a new session key

				
					curl \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params": []}' localhost:9933
				
			
  • Copy the value of “result” to be used in the next step. This is your new session key. Please make sure you copy the entire session key. You may need to zoom out on the page to copy the whole string.
  1. Go to CENNZnet.io

  2. Navigate to Advanced->Extrinsics

  3. In the first row, select the controller account, which you selected in Step 3

  4. Select “session” and “setKeys”

  5. Set the keys to the value obtained from the last step

  6. Leave the “proof” as default

  7. Click Submit Transaction

 

Step 5: Signal intent to validate

Note: You cannot signal your intent to validate when the election window is closed. Normally the election window is closed in the last 10 minutes of an era. Please wait and try again in the next staking era if you see the error “staking.CallNotAllowed”.

When signalling your intent to validate, the controller account will send a transaction to join the validator candidate pool. This allows your validator to be nominated for the next staking era. To do this:

  1. Go to CENNZnet.io

  2. Navigate to Advanced->Extrinsics

  3. In the first row, select the controller account, which you selected in Step 3

  4. In the second row, select “Staking” and “validate”

  5. In the “commission” field, set the amount of commission, which is the amount of reward your validator will take. The rest of the rewards will be shared between your nominators. This amount is expressed as parts-per-billion and converted to a hexadecimal number.

You can calculate commission value in the Javascript page:

				
					const commission = 20; // Percent
const perbill = 1_000_000_000; // Base
const commissionPerBill = (commission/100)*perbill;
const commissionEncoded = api.registry.createType("Perbill", commissionPerBill);
console.log(`For ${commissionEncoded.toHuman()} commission`);
console.log(`Enter ${commissionEncoded.toHex()}`);
				
			

Congratulations! You did it 🎉 Now you have a working validator node on the CENNZnet.

 

How to stop validating

To call the chill method:

  1. Go to CENNZnet.io

  2. Navigate to Staking->My Stake

  3. Find the entry for your validator and click the cog wheel, this opens the Manage stake window

  4. In the Manage stake window, select the Chill action

Need help?

You can also learn more about being a validator on CENNZnet vai our validator FAQ here.