How to Run a Polkadot Validator ?

Setup An EC-2 instance on AWS

  • Ubuntu Server 20.04 LTS (HVM), SSD Volume Type - ami-0fb653ca2d3203ac1 (64-bit x86)

  • m5.xlarge

  • Volume = 500 GB mainnet, 200 -250 GB testnet

  • Allow ports 33033, 9943, 9944, 9615, 3000 in security groups

Install DOCKER

curl -sSL https://get.docker.com/ | sh
sudo systemctl start docker
sudo usermod -aG docker $USER
exit

Setup Node with Docker

  • Once you are done experimenting and picking the best node name :) you can start Polkadot as daemon, exposes the Polkadot ports and mount a volume that will keep your blockchain data locally. Make sure that you set the ownership of your local directory to the Polkadot user that is used by the container. Set user id 1000 and group id 1000, by running chown 1000.1000 /my/local/folder -R if you use a bind mount.

  • To start a Polkadot node on default rpc port 9933 and default p2p port 30333 use the following command. If you want to connect to rpc port 9933, then must add Polkadot startup parameter: --rpc-external.

  • Additionally if you want to have custom node name you can add the --name "YourName" at the end.

  • If you also want to expose the webservice port 9944 use the following command:

  • If you also want to expose the webservice port 9944 use the following command:

Testnet(westend)

docker run -d --network host -p 9615:9615 -p 30333:30333 -p 9933:9933 -p 9944:9944 -v /home/ubuntu/volume:/polkadot parity/polkadot:latest --chain westend --ws-external --rpc-external --rpc-cors all --name "Coindelta-Testnet-2-AWS" --rpc-methods=Unsafe

Mainnet(polkadot)

docker run -d --network host -p 9615:9615 -p 30333:30333 -p 9933:9933 -p 9944:9944 -v /home/ubuntu/volume:/polkadot parity/polkadot:latest --chain polkadot --ws-external --rpc-external --rpc-cors all --name "Ivan-Stake" --rpc-methods=Unsafe

Bond DOT

  • Connect Your Node to the Polkadot.js UI in Development Section add your node ip and 9944 port . Then perform All the operations.

  • It is highly recommended that you make your controller and stash accounts be two separate accounts. For this, you will create two accounts and make sure each of them have at least enough funds to pay the fees for making transactions. Keep most of your funds in the stash account since it is meant to be the custodian of your staking funds.

  • Make sure not to bond all your DOT balance since you will be unable to pay transaction fees from your bonded balance.

  • It is now time to set up our validator. We will do the following:

  • Bond the DOT of the Stash account. These DOT will be put at stake for the security of the network and can be slashed.

  • Select the Controller. This is the account that will decide when to start or stop validating.

First, go to the Staking section. Click on "Account Actions", and then the "+ Stash" button.

  • Stash account - Select your Stash account. In this example, we will bond 1 DOT, where the minimum bonding amount is 1. Make sure that your Stash account contains at least this much. You can, of course, stake more than this.

  • Controller account - Select the Controller account created earlier. This account will also need a small amount of DOT in order to start and stop validating.

  • Value bonded - How much DOT from the Stash account you want to bond/stake. Note that you do not need to bond all of the DOT in that account. Also note that you can always bond more DOT later. However, withdrawing any bonded amount requires the duration of the unbonding period. On Kusama, the unbonding period is 7 days. On Polkadot, the planned unbonding period is 28 days.

  • Payment destination - The account where the rewards from validating are sent. More info here. Starting with runtime version v23 natively included in client version 0.9.3, payouts can go to any custom address. If you'd like to redirect payments to an account that is neither the controller nor the stash account, set one up. Note that it is extremely unsafe to set an exchange address as the recipient of the staking rewards.

Once everything is filled in properly, click Bond and sign the transaction with your Stash account.

After a few seconds, you should see an ExtrinsicSuccessmessage.

Your bonded account will available under Stashes. You should now see a new card with all your accounts (note: you may need to refresh the screen). The bonded amount on the right corresponds to the funds bonded by the Stash account.

Set Session Keys

If you are not sure if your node has the current session keys that you made the setKeys transaction then you can use one of the two available RPC methods to query your node: hasKey to check for a specific key or hasSessionKeys to check the full session key public key string.

Once your node is fully synced, stop the process by pressing Ctrl-C. At your terminal prompt, you will now start running the node.

./target/release/polkadot --validator --name "name on telemetry"

Similarly:

2021-06-17 03:12:08 Parity Polkadot
2021-06-17 03:12:08 ✌ī¸  version 0.9.5-95f6aa201-x86_64-linux-gnu
2021-06-17 03:12:08 ❤ī¸  by Parity Technologies <admin@parity.io>, 2017-2021
2021-06-17 03:12:08 📋 Chain specification: Polkadot
2021-06-17 03:12:08 🏷 Node name: nateched-test
2021-06-17 03:12:08 👤 Role: AUTHORITY
2021-06-17 03:12:08 💾 Database: RocksDb at /root/.local/share/polkadot/chains/polkadot/db
2021-06-17 03:12:08 ⛓  Native runtime: polkadot-9050 (parity-polkadot-0.tx7.au0)
2021-06-17 03:12:12 🏷 Local node identity is: 12D3KooWLtXFWf1oGrnxMGmPKPW54xWCHAXHbFh4Eap6KXmxoi9u
2021-06-17 03:12:12 đŸ“Ļ Highest known block at #64673
2021-06-17 03:12:12 ã€Ŋī¸ Prometheus server started at 127.0.0.1:9615
2021-06-17 03:12:12 Listening for new connections on 127.0.0.1:9944.
2021-06-17 03:12:12 đŸ‘ļ Starting BABE Authorship worker
2021-06-17 03:12:16 🔍 Discovered new external address for our node: /ip4/10.26.11.1/tcp/30333/p2p/12D3KooWLtXFWf1oGrnxMGmPKPW54xWCHAXHbFh4Eap6KXmxoi9u
2021-06-17 03:12:17 ⚙ī¸  Syncing, target=#5553810 (14 peers), best: #65068 (0x6da5â€Ļ0662), finalized #65024 (0x4e84â€Ļd170), âŦ‡ 352.2kiB/s âŦ† 75.6kiB/s

You can give your validator any name that you like, but note that others will be able to see it, and it will be included in the list of all servers using the same telemetry server. Since numerous people are using telemetry, it is recommended that you choose something likely to be unique.

Generating the Session Keys

You need to tell the chain your Session keys by signing and submitting an extrinsic. This is what associates your validator node with your Controller account on Polkadot.

Option 1: PolkadotJS-APPS

You can generate your Session keys in the client via the apps RPC. If you are doing this, make sure that you have the PolkadotJS-Apps explorer attached to your validator node. You can configure the apps dashboard to connect to the endpoint of your validator in the Settings tab. If you are connected to a default endpoint hosted by Parity of Web3 Foundation, you will not be able to use this method since making RPC requests to this node would effect the local keystore hosted on a public node and you want to make sure you are interacting with the keystore for your node.

Once ensuring that you have connected to your node, the easiest way to set session keys for your node is by calling the author_rotateKeys RPC request to create new keys in your validator's keystore. Navigate to Toolbox tab and select RPC Calls then select the author > rotateKeys() option and remember to save the output that you get back for a later step.

Option 2: CLI

If you are on a remote server, it is easier to run this command on the same machine (while the node is running with the default WS RPC port configured):

echo '{"id":1,"jsonrpc":"2.0","method":"author_rotateKeys","params":[]}' | websocat -n1 -B 99999999 ws://127.0.0.1:9944

The output will have a hex-encoded "result" field. The result is the concatenation of the four public keys. Save this result for a later step.

You can restart your node at this point.

Submitting the setKeys Transaction

You need to tell the chain your Session keys by signing and submitting an extrinsic. This is what associates your validator with your Controller account.

Go to Staking > Account Actions, and click "Set Session Key" on the bonding account you generated earlier. Enter the output from author_rotateKeys in the field and click "Set Session Key".

Submit this extrinsic and you are now ready to start validating.

Validate

To verify that your node is live and synchronized, head to Telemetry and find your node. Note that this will show all nodes on the Polkadot network, which is why it is important to select a unique name!

In this example, we used the name techedtest and have successfully located it upon searching:

Setup via Validator Tab

Here you will need to input the Keys from rotateKeys, which is the Hex output from author_rotateKeys. The keys will show as pending until applied at the start of a new session.

The "reward commission percentage" is the commission percentage that you can declare against your validator's rewards. This is the rate that your validator will be commissioned with.

  • Payment preferences - You can specify the percentage of the rewards that will get paid to you. The remaining will be split among your nominators.

Setting a commission rate of 100% suggests that you do not want your validator to receive

nominations

You can also determine if you would like to receive nominations with the "allows new nominations" option.

Click "Bond & Validate".

If you go to the "Staking" tab, you will see a list of active validators currently running on the network. At the top of the page, it shows the number of validator slots that are available as well as the number of nodes that have signaled their intention to be a validator. You can go to the "Waiting" tab to double check to see whether your node is listed there.

The validator set is refreshed every era. In the next era, if there is a slot available and your node is selected to join the validator set, your node will become an active validator. Until then, it will remain in the waiting queue. If your validator is not selected to become part of the validator set, it will remain in the waiting queue until it is. There is no need to re-start if you are not selected for the validator set in a particular era. However, it may be necessary to increase the number of DOT staked or seek out nominators for your validator in order to join the validator set.

Congratulations! If you have followed all of these steps, and been selected to be a part of the validator set, you are now running a Polkadot validator! If you need help, reach out on the Polkadot Validator chat.

Last updated