Note: This manual assumes familiarity with Unix command line and blockchain validator nodes. Prior experience with Cosmos SDK and Ethereum transactions will be helpful.
- Prepare machine and install dependencies
- Setup binary, config and accounts
- Run validator with systemd
- Claim validator status
- Setup gateway
- Withdraw stakes / Unbond validator
- Withdraw rewards
- Other operations
If you only want to run a standby unbonded node to sync the blocks and query sidechain information, stop after run validator with systemd.
-
Prepare a Linux machine with a minimum of 16GB RAM, at least 2 cores and at least 100GB of disk space. We assume Ubuntu in this manual but most Linux distros should work.
-
Install go (version 1.14+), gcc, make, git and libleveldb-dev.
-
Set $GOBIN and add $GOBIN to $PATH. Edit
$HOME/.profile
and add:
export GOBIN=$HOME/go/bin; export GOPATH=$HOME/go; export PATH=$PATH:$GOBIN
to the end, then:
source $HOME/.profile
- From the
/home/ubuntu
directory, clone thesgn
repository, then install thesgnd
,sgncli
andsgnops
binaries:
git clone /~https://github.com/celer-network/sgn
cd sgn
git checkout master # Use master for latest stable version
WITH_CLEVELDB=yes make install-all
cd ..
- From the
/home/ubuntu
directory, clone thesgn-networks
repository:
git clone /~https://github.com/celer-network/sgn-networks
cd sgn-networks
git checkout master
cd <chain-id>
- Copy the config files and initialize the validator node:
mkdir -p $HOME/.sgncli/config
cp sgn.toml $HOME/.sgncli/config
sgnd init <validator-name> --chain-id <chain-id>
cp genesis.json config.toml $HOME/.sgnd/config
- Initialize common Cosmos SDK CLI configs, which will be saved to
$HOME/.sgncli/config/config.toml
:
sgncli config trust-node true; sgncli config indent true; sgncli config output json
-
Fill out the
moniker
field in$HOME/.sgnd/config/config.toml
with the name of the validator. Fill out theexternal_address
field with<public-ip:26656>
. -
Get the validator public key:
sgnd tendermint show-validator
Make a note of the output.
- Add an SGN validator account key:
sgncli keys add <key-name> --keyring-backend=file
Repeat to create multiple transactors for the gateway. You can use <validator_name>_operator
to
name your validator account and <validator_name_transactor0>
, <validator_name_transactor1>
, etc.
to name your transactor accounts. Use the same passphrase as the validator account for all accounts.
To get the list of accounts, run:
sgncli keys list --keyring-backend=file
-
Prepare an Ethereum gateway URL. You can use services like Infura, Alchemy or run your own node.
-
Prepare an Ethereum keystore JSON file for the validator, eg.:
geth account new --lightkdf --keystore <path-to-keystore-folder>
Save it as $HOME/.sgncli/eth_ks.json
.
- For testnet, obtain some Ropsten ETH from places like the MetaMask faucet. Buy Ropsten mock CELR tokens on the Ropsten Uniswap. If there is not enough CELR in the Uniswap pool, join our Discord server and ping us.
For mainnet, currently we have not opened validator spots. Please stay tuned for more information.
-
Send ETH and CELR to the validator ETH address. Make sure it has enough CELR for self-staking and a few ETH for gas.
-
Fill in the placeholders in
$HOME/.sgncli/config/sgn.toml
.Field Description ETHEREUM_GATEWAY_URL The Ethereum gateway URL obtained from step 8 KEYSTORE_PATH The path to the keystore file in step 9 KEYSTORE_PASSPHRASE The passphrase to the keystore VALIDATOR_ACCOUNT_ADDRESS The sgn-prefixed address obtained in step 7 TRANSACTOR_PASSPHRASE The passphrase you typed in step 7 VALIDATOR_PUBKEY The validator public key obtained in step 6 TRANSACTOR_ADDRESS If planning to run gateway, fill in one or multiple transactor accounts obtained in step 7. Otherwise, leave it as an empty array
We recommend using systemd to run your validator. Feel free to experiment with other setups on your own.
- Prepare the sgnd system service:
sudo mkdir -p /var/log/sgnd
sudo touch /var/log/sgnd/tendermint.log
sudo touch /var/log/sgnd/app.log
sudo touch /etc/systemd/system/sgnd.service
Add the following to /etc/systemd/system/sgnd.service
:
[Unit]
Description=SGN daemon
After=network-online.target
[Service]
ExecStart=/home/ubuntu/go/bin/sgnd start \
--home /home/ubuntu/.sgnd/ \
--cli-home /home/ubuntu/.sgncli \
--config /home/ubuntu/.sgncli/config/sgn.toml
StandardOutput=append:/var/log/sgnd/tendermint.log
StandardError=append:/var/log/sgnd/app.log
Restart=always
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
tendermint.log
contains Tendermint logs (i.e. block height, peer info, etc.) while sgnd.log
contains SGN-specific logs.
- (Optional) For log rotation, create a
/etc/logrotate.d/sgn
file and add the following:
/var/log/sgnd/*.log {
compress
copytruncate
maxsize 50M
rotate 5
}
- Enable and start the sgnd service:
sudo systemctl enable sgnd.service
sudo systemctl start sgnd.service
- Monitor
tendermint.log
and wait for the node to sync:
tail -f /var/log/sgnd/tendermint.log
You can tell the node is synced when new blocks show up about every 5 seconds.
- Initialize the validator candidate:
sgnops init-candidate --commission-rate <commission-rate> --min-self-stake <min-self-stake> --rate-lock-period <rate-lock-period>
Wait for the transaction to be confirmed. Refer to the CLI doc and design doc for more details. Note that rateLockPeriod + currentBlockNum = rateLockEndTime
- Delegate CELR to the candidate:
sgnops delegate --candidate <candidate-eth-address> --amount <delegate-amount>
Wait for the transaction to be confirmed. Refer to the CLI doc and design doc for more details.
- Note that it will take some time for the existing SGN validators to sync your new validator from the mainchain. Afterwards, verify your validator status:
sgncli query validator candidate <candidate-eth-address>
You should be able to see that your candidate has a delegatedStake
matching your delegated amount
denominated in wei.
- Verify validator is in the SGN validator set:
sgncli query validator validator <validator-account-address>
<validator-account-address>
is the sgn-prefixed address you created. You should see your validator
and its identity
should equal to your <candidate-eth-address>
. Make a note of the
consensus_pubkey
- the address prefixed with sgnvalconspub
.
If your validator doesn't appear in the query, check the candidate status on mainchain through
sgnops get-candidate-info --candidate <candidate-eth-address>
If Status = 0
(unbonded), try claiming the status manually:
sgnops claim-validator
If Status = 1
(bonded), try triggering the sidechain info sync manually:
sgnops sync sync-validator --candidate <candidate-eth-address>
Then wait for a while and retry the query again.
- Verify validator is in the Tendermint validator set:
sgncli query tendermint-validator-set
You should see an entry with pub_key
matching the consensus_pubkey
obtained in step 4.
-
Go to the SGN mainnet explorer to view your validator.
-
Update validator public contact info:
sgncli tx validator edit-candidate-description --contact [email address] --website [entity website]
Optionally, you can start a gateway service alongside the validator to serve HTTP requests.
- Prepare the SGN gateway service:
sudo mkdir -p /var/log/sgn-gateway
sudo touch /var/log/sgn-gateway/gateway.log
sudo touch /var/log/sgn-gateway/gateway_error.log
sudo touch /etc/systemd/system/sgn-gateway.service
Add the following to /etc/systemd/system/sgn-gateway.service
:
[Unit]
Description=SGN gateway
After=network-online.target
[Service]
ExecStart=/home/ubuntu/go/bin/sgncli gateway \
--laddr tcp://0.0.0.0:1317 \
--home /home/ubuntu/.sgncli \
--config /home/ubuntu/.sgncli/config/sgn.toml
StandardOutput=append:/var/log/sgn-gateway/gateway.log
StandardError=append:/var/log/sgn-gateway/gateway_error.log
Restart=always
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
- (Optional) Add the log folder to
/etc/logrotate.d/sgn
:
/var/log/sgnd/*.log
/var/log/sgn-gateway/*.log {
...
- Enable and start the service:
sudo systemctl enable sgn-gateway.service
sudo systemctl start sgn-gateway.service
Please refer to the design doc for better understanding of the stake withdrawal process.
- Initialize a withdrawal of your self-delegated stake:
sgnops withdraw intend --candidate <candidate-eth-address> --amount <delegate-amount>
If the self-delegated stake after the withdrawal is below your min-self-stake
amout, the validator will transit to unbonding
status.
- After the slash timeout, confirm the withdrawal of your stake:
sgnops withdraw confirm --candidate <candidate-eth-address>
If your validator is in unbonding status, also confirm it to become unbonded.
sgnops confirm-unbonded-candidate --candidate <candidate-eth-address>
Please refer to the design doc for better understanding of the reward withdrawal process.
- Initialize withdrawal of rewards at sidechain:
sgncli tx validator withdraw-reward <self-eth-address>
- Wait for the validators to co-sign the reward message, and query the reward message at sidechain:
sgncli query validator reward <self-eth-address>
- After new reward message is signed with signer stakes greater than quorum stakes, submit the message to mainchain:
sgnops withdraw reward
Please refer to the CLI docs of sgnops and sgncli, or try sgnops --help
and sgncli --help
to learn more about other operations.
In case the local state of your validator is corrupted, you can try resetting the state by running:
sgnd unsafe-reset-all
Normally this shouldn't be necessary. Please contact us on Discord before doing so.