owned this note
owned this note
Published
Linked with GitHub
# Kratos Validator Handbook
- Kratos [source code](https://github.com/KuChainNetwork/Kratos)
- Release version number v0.5.3 [Release Kratos v0.5.3-RC Release](https://github.com/KuChainNetwork/Kratos/releases/tag/v0.5.3)
- Block explorer: [KuChain Explorer](https://explorer.kuchain.network/)
- Recommended hardware configuration:
- Linux Ubuntu 18.04 lts
- 4 cores 16G memory
- CPU frequency 3.1 or higher
- Bandwidth 5M
- 500GB hard drive
## Deployment Script
Follow this script to build a Kratos synchronization node quickly.
## Operation Steps
1. Install related tools, download kratos source code to local and compile it.
2. Download the genesis file, update the configuration, then start up the node.
3. Generate a wallet and create a user name on the chain (user name must conform to the format: 12 characters).
4. Transfer money to the user name and register as a validator.
5. Stake for your node (validator account).
## 1. Install related tools, download kratos source code to local and compile it
```
#!/usr/bin/env bash
# Install related tools
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install git -y
sudo apt-get install build-essential -y
sudo apt-get install curl -y
curl -O https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz
sudo tar -xvf go1.14.4.linux-amd64.tar.gz -C /opt/
rm go1.14.4.linux-amd64.tar.gz
# Configure `$PATH` environment variable
sudo mkdir /opt/gopath
sudo chmod 0777 /opt/gopath
echo "export GOROOT=/opt/go" >> ~/.profile
echo "export GOPATH=/opt/gopath" >> ~/.profile
echo "export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin" >> ~/.profile
source ~/.profile
# Download kratos source code from Github to local
git clone https://github.com/KuChainNetwork/kratos.git
# Locate to the kratos folder
cd kratos
git pull
# Switch to the current kratos release branch
git checkout v0.5.3
# Compile source code
make all -e CORE_SYMBOL=kts -e MAIN_SYMBOL=kratos
```
## 2. Download the genesis file, update the configuration, then start up the node
```
# Initialize the node information - moniker is the node name
kucd init --chain-id=kratos <moniker>
# Download the genesis file and overwrite the default genesis configuration
curl -O https://gist.githubusercontent.com/cain42/962c3f265cc258bc4f39aa594b517f1f/raw/a62c539f4ced3c70cef58b5d3afae37afb766935/genesis.json
mv genesis.json ~/.kucd/config/
# Update the seed configuration information in config file
sed -i "s/seeds = \"\"/seeds = \"3192fada5783c4094c5f1e34998d22c28ae17b3c@54.250.252.137:26656,035ec954c47f0b40c02491fc9abd4ce398bfec70@39.99.233.130:26656,31fc3d7e406c4869af4d008746a2f72180e92c7b@39.99.154.141:26656,0f4d7149fbe35d7114630a17d545d584915ec856@147.139.31.48:26656,5434d9687037f732720cb3e607c8ab4eab192ae4@47.254.66.202:26656,72861902a218d37407891e2aaff75ce79ed8d1bd@47.252.75.40:26656\"/g" "${HOME}/.kucd/config/config.toml"
#Start up your node
kucd start
# or start with nohup
nohup kucd start &
```
You could check the node record by the log file after the node started.
```
tail -f ./log/node.log
```
> Note: The script will initialize the node's private key at ~/.kucd/config/priv_validator_key.json, please backup your private key.
### Validator Handbook
##### Note for validators
Kratos restructured the asset and account modules, and the dividend receiving module has also been restructured accordingly. The validator node needs to understand some basic operating commands to complete the regular operations such as account registration, node mortgage, dividend receiving, and asset confirmation.
##### Account and Address
In Kratos, the account is the basic unit of authority management, and its ownership is confirmed through Auth. Once you generate the private key, you will get a unique address. At this time, to become a validator, you need to register a username(an account which is parallel to the address accounting) on the blockchain. That is to say, the account information of the username is isolated from the balance of the Auth-bound address.
If there are 10 KTSt under the address kratosxxx, the account name accountnamexxxx bound to this address(kratosxxx) doesn't own the 10 KTSt. Similarly, as the payee, the assets received by the account accountnamexxxx will not exist under kratosxxx, but will under the account book.
##### The format of username
- 12 bits
- The letters a-z (only lower case)
- Numbers 0-9
- Support symbols `@` and `.`, `@` is the account separator so it can only appear one time
In `Kratos`, `@` is regarded as the account separator. The account name with `@` can be separated into the first identification name and the following organization name. If the organization name is the account with the chain master symbol, it is reserved for the system which is used as a system mechanism. Accounts including system accounts or root accounts cannot actively create system accounts.
## 3. Generate a wallet and create a user name on the chain
```
# localkey is a locally managed private key alias, remember to back up your address and mnemonic after running
kucli keys add localkey --chain-id Kratos --keyring-backend test
# Create the username <address of localkey> localkey address / testvalidaor is the username / The second <address of localkey> is the address bound by Auth
kucli tx account create <address of localkey> testvalidaor <address of localkey> --fee-payer <address of localkey> --from localkey --chain-id kratos --keyring-backend test
```
## 4. Transfer money to the user name and register as a validator
#### Transfer money to the validator account
```
# <address of localkey> is the address of localkey,testvalidaor is the account name,the second <address of localkey>is the address bound by Auth
./kucli tx asset transfer <address of localkey> testvalidaor 1000000000Kratos/kts --fee-payer <address of localkey> --from localkey --chain-id Kratos --keyring-backend test
```
#### Query account
```
# Query account information
kucli query account get testvalidaor
# Query the account which is bound to Auth
kucli query account auth <address of localkey>
# Query the account balance, the user name here can also be replaced with the address, but the account information you got is different
kucli query asset coins testvalidaor
```
> The account authority (Auth) points to an address, multiple accounts can have the same address authority, but these accounts are logically unrelated and the assets are independent.
#### Register as a validator
In Kratos network, if you want to be a validator, firstly you need a node to synchronize the block information. This node can also provide the public key which could verify whether the signature of a certain block belongs to the node. Secondly, you need to have an account registered on Kratos as the operator of the node. Then there are two conventional parameters you need to have: moniker and commission-rate, moniker is the name of the node, commission-rate is the commission ratio. You could modify the two parameters after creating the node.
```
kucli tx kustaking create-validator testvalidaor\
--pubkey=$(./kucd tendermint show-validator) \
--moniker="secode test" \
--from=localkey \ # Alias of local wallet
--commission-rate="0.10" # 10%
--chain-id Kratos
--keyring-backend test
```
- pubkey is the public key of the node, which could be obtained by the command: `./kucd tendermint show-validator`
- testvalidaor is the on-chain account we registered before
- moniker is the name of the node which cannot exceed 70 characters
- commission-rate is the commission ratio which should be between 0 to 1
- from is the parameter used by kucli to call the wallet to sign, here we use the private key of the localkey in the wallet to sign
- The default parameter is fee-payer, here the localkey account is used for payment by default
##### Query validator
```
kucli query kustaking validator testvalidaor
{
"operator_account": "testvalidaor",
"consensus_pubkey": "Kratosvalconspubxxxxxx",
"status": 1,
"tokens": "0",
"delegator_shares": "0.000000000000000000",
"description": {
"moniker": "secode test"
},
"unbonding_time": "1970-01-01T00:00:00Z",
"commission": {
"commission_rates": {
"rate": "0.100000000000000000",
"max_rate": "1.000000000000000000",
"max_change_rate": "1.000000000000000000"
},
"update_time": "2020-09-15T03:23:07.823072717Z"
},
"min_self_delegation": "1"
}
```
The meaning of the `status` field is as follows:
- 1 represents the unbonding state which refers to the state of a candidate node. Generally, when the mortgage on a node is not enough to make it a validator, the node will be in the unbonding state.
- 2 represents the unbonded state. The bonded state of a validator will be set to the unbonded when it is punished by the chain for some reason.
- 3 represents the bonded state, which is the state of the validator
In addition to the `status` field, another important status field for validator is`Jailed`. This is a bool type field, true means being punished, false means not being punished.
- The validator being punished will not become a valid validator regardless of the amount of mortgage
- Validators not being punished can run for valid validators based on their mortgage amount
## 5. Stake for your node (validator account).
```
kucli tx kustaking delegate delegator testvalidaor 98760540321Kratos/kts --from localkey
```
- delegator is the user name mortgaged on the chain
- testvalidaor is the account of the validator
- amount is the mortgage amount. The value here needs to be accompanied by precision information. The precision in Kratos is 18 digits. ** 1 token on Kratos is 100000000000000000kratos/kts**
- -from is used to determine which local private key will be used to sign
##### Redeem mortgage
```
kucli tx kustaking unbond delegator testvalidaor 100Kratos/kts --from localkey
```
- delegator is the name of the on-chain validator
- testvalidaor is the operation account of validators
- amount is the amount which need to be redeemed. If it is greater than the amount of the mortgage, txmsg will report an error
- -from is used to determine which local private key will be used to sign
##### The punishment of validators
Kratos will punish validators when the following situations occur:
- When the validator is double-signed.
- When the validator misses more than 50 blocks in 100 consecutive blocks.
##### The punishment situation
- When a validator is double-signed, Kratos will set the validator's `Jailed` status to true, then remove it from the valid validator queue, and deduct 5% of the total mortgage amount on the validator. The validator can set the status of `Jailed` to False through the `unjail` operation after 14 days, then continue to compete for valid validators.
- When the validator misses more than 50 blocks in 100 consecutive blocks, Kratos will set the validator's `Jailed` status to true, kick it from the valid validator queue, and deduct 0.01% of the total mortgage amount of the validator. The validator can set the `Jailed` status to False through the `unjail` operation after 10 minutes, then continue to compete for valid validators.
The block generation and punishment situation of a validator can be queried through the kuslashing module
```
kucli query kuslashing signing-info [validator-conspub] [flags]
{
"address": "Kratosvalconsxxxxx",
"start_height": "7192",
"index_offset": "2",
"jailed_until": "2020-09-15T08:32:16.653850079Z",
"missed_blocks_counter": "2"
}
```
- validator-conspub is the public key of the validator
- flags is a common parameter
Here is the query result after the testvalidaor missing more than 50 blocks. The `jailed_until` parameter above is a time node which shows the time that nodes can be removed from punishment through the unjail operation. The following are the relevant parameters of the unjail command.
##### Restore penalized node
```
kucli tx kuslashing unjail testvalidaor --from localkey --keyring-backend test --chain-id Kratos
```
- testvalidaor refers to the account of the penalized validator's operator
- -from is used to determine which local private key will be used to sign
##### Receive Node Revenue
[Kratos Incentive System](https://hackmd.io/@KuChain/distribution)
##### Coinpower
In order to support programmable assets, Kratos defines Coinpower, which can be converted into assets, but assets cannot be actively converted into Coinpower.
When users have Coinpower, they can obtain coins through `exercise` confirmation:
Firstly confirm the Coinpower:
```
./build/kucli query asset coinpowers validator1
- denom: kratos/kts
amount: "8123569779369697717424050"
```
Claim Coinpower
```
./kucli tx asset exercise testvalidator Kratos/kts --from localkey --chain-id Kratos --keyring-backend test --fee-payer testvalidator
```
Now users can obtain coins.