[Validators] Polkadot & Kusama, Step by Step

note: This is work in progress

Tools and Learning Resources

Incentives & Grant Programs

Account Types Breakdown

Before starting your staking service you will need to create the following secret keys. For the sake of the tutorial, you can use polkadot.js.org to generate them (not recommended in production).

  • Controller Key - Schnorrkel (sr25519)
    • Used to start or stop validating or nominating
    • Should only store the minimum amount of funds (just enough for the tx fees)
  • Stash Key - Schnorrkel (sr25519)
    • Cold wallet (can hold a majority of your funds), used to bond funds to the particular controller
  • Session Key (Signing Key) - Edwards (ed25519)
    • Does not require to hold any funds
    • Used to sign the blocks (run the validator node)
    • You will need to install polkadot to use console and execute RPC author_rotateKeys command to generate this key (contained of the $HOME/.local/share/polkadot/chains/ksmcc3 directory)

Install All Tools

Ubuntu 18.04 LTS

Prerequisites

curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustup update
sudo apt install make clang pkg-config libssl-dev build-essential

Binaries

git clone https://github.com/paritytech/polkadot.git
cd polkadot
git checkout v0.7.20
./scripts/init.sh
cargo build --release
cargo install --force --git https://github.com/paritytech/substrate subkey

note: if the last command fails simply repeat it once or twice until it succeeds

Create polkadot service and start synchronizing the data so that you can run the RPC command and create the session key.

service_path=/lib/systemd/system/polkadot.service

cat > $service_path << EOL
[Unit]
Description=Polkadot Service
After=network.target

[Service]
Type=simple
EnvironmentFile=/etc/environment
ExecStart=$HOME/polkadot/target/release/polkadot --pruning=archive
Restart=always
RestartSec=5

[Install]
WantedBy=default.target
EOL

systemctl daemon-reload && \
 systemctl enable polkadot && \
 systemctl restart polkadot && \
 systemctl status polkadot

Optionally, if you do not want to create a service, you can run a nohup process

nohup $HOME/polkadot/target/release/polkadot --pruning=archive > ~/polkadot.log 2>&1
echo $! > ~/polkadot_pid.txt

# after you are done, kill the process with
kill -9 `cat ~/polkadot_pid.txt`

# to check latest log
tail -n 25 $HOME/polkadot.log

# to remove the db when it gets corrupted
$HOME/polkadot/target/release/polkadot purge-chain

If you already have existing session key then simply copy and save the content of the $HOME/.local/share/polkadot/chains/ksmcc3 otherwise, run the following command to rotate the key and display the extrinsic that you will need later on, so save the response.

systemctl stop polkadot
rm -rfv $HOME/.local/share/polkadot/chains/ksmcc3/keystore
systemctl start polkadot

# wait 30-60 seconds

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' http://localhost:9933

Finally, save the content of the $HOME/.local/share/polkadot/chains/ksmcc3/keystore directory (5 files) and output of the RPC command (hex string)

Initial Setup (Kusama)

  1. Create all keys as in the (Account Types Breakdown)
  2. Deposit 55 KSM to the Stash Key (No less than 50)
  3. Deposit 1 KSM to the Controller Key (Enough to pay for fees)
  4. Go to Kusama CC3 polkadot.js -> Staking -> Account actions -> (+) New stake and bond 1 KSM from your Stash Key to your Controller Key. As payment destination select Stash account (do not increase the amount at stake)
  5. Go to Kusama CC3 polkadot.js -> Staking -> Account actions -> Set session key, using your Controller Key and in the rotateKeys field provide hes string result of the author_rotateKeys RPC call