Validator Node
This document outlines the steps to deploy your own validator node.
Hardware Requirement
Server Timezone Configuration
Make sure your server timezone configuration is UTC. Check your current timezone by running timedatectl
Note: Having a different timezone configuration may cause a
LastResultHash
mismatch error and take down your node!
Install 0gchaind via CLI
Set Chain ID
Initialize Node
We need to initialize the node to create all the necessary validator and node configuration files:
Note: the validator name can only contain ASCII characters.
By default, the init
command creates config and data folder under ~/.0gchain
(i.e $HOME
). In the config directory, the most important files for configuration are app.toml
and config.toml
.
Note: you could specify
--home
to overwrite the default work directory.
Genesis & Seeds
Copy the Genesis File
Check the genesis.json
file and copy it over to the config directory $HOME/.0gchain/config/genesis.json
. This is a genesis file with the chain-id and genesis accounts balances.
Then verify the correctness of the genesis configuration file:
Add Seed Nodes
Your node needs to know how to find peers. You’ll need to add healthy seed nodes to $HOME/.0gchain/config/config.toml
.
The format of the config.toml
file is as follows:
We provide four seed nodes below.
Add Persistent Peers
You can set the persistent_peers
field in $HOME/.0gchain/config/config.toml
to specify peers that your node will maintain persistent connections with.
Start Testnet
Start the node and sync up to the latest block height. Note that the first time you start the sync up, it may take longer time to run.
Garbage Collection Optimization
To maximize sync speed for validators and other network providers that are running pruning nodes, the following settings are recommended:
Start 0gchaind process with environment variable and value
GOGC=900
; this instructs the golang garbage collector to wait until the heap has grown to 9x it's initial allocated size before running garbage collectionStart 0gchaind process with environment variable
GOMEMLIMIT
set to 66% of the total memory available to the 0gchaind process (e.g.GOMEMLIMIT=40GB
for a node with 64 GB of memory) to ensure garbage collection runs whenever 66% of the total memory is used
Make sure you've synced your node to the latest block height before running the following steps.
Create Validator
You could either create a new account or import from an existing key. To create a new account:
Here if you want to get the public address which starts with 0x
, you could first run the following command to get your key’s private key.
Then import the returned private key to a wallet (Metamask for example) to get the public address.
As a next step, you must acquire some testnet tokens either by wallet transfer or requesting on the faucet before submitting your validator account address.
Check that it is in the validator set:
Only top 125 staked validators will be selected as active validators.
By any chance your validator is put in jail, use this command to unjail it
Upgrade Your Node
These instructions are for full nodes that have ran on previous versions of and would like to upgrade to the latest testnet version.
Reset Data
Note: if the version you are upgrading to is not breaking from the previous one, you should not reset the data. If this is the case you can skip to Restart step.
First, remove the outdated files and reset the data.
Your node is now in a pristine state while keeping the original priv_validator.json
and config.toml
. If you had any sentry nodes or full nodes setup before, your node will still try to connect to them, but may fail if they haven’t also been upgraded.
Restart
Migrate Your Node
Important files
If you are migrating your node to a different server, first you need to recover your wallet account on your new server。 If you have stored your wallet mnemonic, you can restore your account by executing
and paste your mnemonic to recover the account.
However, if by any chance you did not store your mnemonic, you need to make sure to store and move the following files to the new server at the same place under your $HOME
.
$HOME/xx.address
$HOME/xx.info
$HOME/keyhash
Another important file to store is $HOME/config/priv_validator_key.json
. This file is generated at the init step and is the key file for your onchian signing.
Step
Follow the same setup process above to start syncing your node to the latest block height
Important: Delete
$HOME/config/addrbook.json
if you are using the same machine
Important: Make sure the genesis.json is updated
Important: Make sure the seeds are updated
Warning: Do not migrate the files before you finish syncing the blocks. This is to avoid double signing.
Warning: Do not stop your old server before you finish syncing the blocks. This is to avoid getting jailed for long downtime.
Once you finished syncing the blocks.
Stop your new server.
Copy and past the files mentioned in Important files to the
$HOME
on your new server.Stop your old server.
Restart your new server.
Last updated