Becoming a Validator
Links
- Mars contributor @larry0x's workshop: https://github.com/larry0x/workshops/tree/main/how-to-run-a-validator
Server Requirements
A production-ready server typically requires:
- 8-core x86 CPU. Cosmos apps do compile on ARM chips (e.g. Apple's M1 processor) but the reliability is not battle-tested. Notably, chains that incorporate the CosmWasm module won't even compile on ARM servers.
- 64 GB RAM. Cosmos apps typically use less than 32 GB under normal conditions, but during events such as chain upgrades, up to 64 GB is usually needed.
- 4 TB NVME SSD. Hard drive I/O speed is crucial! Nodes that run on HDD or SATA SSD often find themselves missing blocks. Requirements on disk space depends on the chain and your pruning settings but generally at least 2 TB is recommended.
- Linux operating system.
Spin up a Node
Generate Operator Key
Each node needs three private keys: operator key
, consensus key
and node key
. Let's first generate the operator key
.
Run these commands to create a new private key named demo-user
:
# to generate a new seed phrasemarsd keys add demo-user --coin-type 118# to use an existing seed phrasemarsd keys add demo-user --recover --coin-type 118mards keys show demo-user
--coin-type
is a parameter used when generating private keys from seed phrases, as defined in SLIP-0044. Most Cosmos chains use 118
. For the sake of a better interchain UX, we recommend everyone use 118
.
It is important that you keep the mnemonic phrase secure, as there is no way to recover it.
Create your validator operator key:
marsd keys add validator
Add your operator key to the genesis state:
marsd genesis add-account validator 1000000umars
Note that the chain id is mars-1 and set the self-bond amount to 1000000umars:
marsd genesis gentx validator 1000000umars \ --pubkey "$(marsd tendermint show-validator)" \ --chain-id mars-1 \ --commission-rate "..." \ --commission-max-rate "..." \ --commission-max-change-rate "..." \ --moniker "..." \ --identity "..." \ --details "..." \ --website "..." \ --security-contact "..."
The gentx can be found in ~/.mars/config/gentx/gentx-<hash>.json
. Add the file to this repository under the mars-1/gentxs
folder by making a PR.
Register your Node as a Validator
Once synced up, register your node as a validator:
marsd tx staking create-validator \ --pubkey $(marsd tendermint show-validator) \ --moniker "the moniker for your validator" \ --details "a description of your validator" \ --identity "your keybase.io PGP key (block explorers will use your keybase pfp)" \ --website "http://homepage.validator.com" \ --security-contact "contact@your.email" \ --min-self-delegation 1 \ --commission-rate "0.05" \ --commission-max-rate "0.20" \ --commission-max-change-rate "0.01" \ --amount 1000000stake \ --from validator \ --chain-id hub-1 \ --gas auto \ --gas-adjustment 1.4 \ --gas-prices 0umars
A few notable flags:
pubkey
: By using the command marsdtendermint
show-validator, we provide the private key in.marsd/config/priv_validator_key.json
as your validator's signing key. Therefore, again, make sure to backup this file!moniker
: This is the moniker of your validator that will show up in wallet apps and block explorersidentity
: This is your Keybase PGP key. It should be a 16-digit hex string; for example,28DC4101DA38C22C
. Most wallet apps and block explorers will use your Keybase profile picture as the your validator's pfp. The only exception is MintScan, for which you need to add your pfp to this repo via a pull request (PR)min-self-delegation
: The minimum amount of self delegation for your validator to be active. If you withdraw your self delegation to below this threshold, your validator will be immediately removed from the active set. Your validator will not be slashed, but will stop earning staking rewards. This is considered the proper way for a validator to voluntarily to cease operation. NOTE: If you intend to shut down, make sure to communicate with your delegators at least 21 days before withdrawing your self delegation, so that they have sufficient time to redelegate and not missing out on staking rewards.commission-max-rate
: The maximum commission rate your validator is allowed to change. This number can not be changed. If you wish to go above this limit, you will have to create a new validator. This limit increases trust between you and your delegators, as they can be sure you will not rug them by ramping up your commission rate.commission-max-change-rate
: Similar to the previous one, this parameter limits how quickly you can increase or decrease your commission rate.chain-id
: Make sure you are using the appropriatechain-id
for either mainnet (mars-1
) or testnet(ares-1
).gas auto gas-adjustment
1.4 andgas-prices
0umars
are the default recommended gas parameters.
Once the tx
is confirmed, run the following query:
marsd query staking validator $(marsd keys show validator --bech val --address) --output json | jq
The output should look like:
{ "operator_address": "cosmosvaloper1...", "jailed": false, "status": "BOND_STATUS_BONDED", "tokens": "...", // ...}
Your status should be "bonded"; if not ("unbonding" or "unbonded") the most likely reason is you do not have enough delegation to enter to active set.
If you're bonded, restart your node by:
sudo systemctl restart marsd
You should see a log message that looks like:
INF This node is a validator addr=[...] module=consensus pubKey=[...]
This means your validator is now successfully registered and active!
Let's check whether your node is properly signing blocks:
marsd query block | jq
This will display the latest block in JSON format. Scroll down to the block.signatures
section, you should see an array of items in this format:
{ "block": { "signature": [ { "block_id_flag": ..., "validator_address": "...", "timestamp": "...", "signature": "..." } ] }}
validator_address
is the validator's hex address. Your hex address can be found by running marsd status | jq
.
If your validator's signature shows up in the list, congrats your validator has been successfully registered & is operating!