Upgrade Step-by-step
The Testnet upgrade aims to provide a platform for validators to have rehearsal on upgrading the chain from SheungWan to FoTan.
Archived on 2022/06/14. Information is out of date.
Overview
Preparation
Set up a Testnet chain running SheungWan software (to mimic the current state of SheungWan Mainnet).
Pre-upgrade
Make sure you have all keys
operator key in
.likeclifolder, or in mnemonic format,node key in
.liked/config/node_key.jsonconsensus key in
.liked/config/priv_validator_key.json
backed up properly, in case anything disastrous happens.
Pass the proposal, determining the date, time, software version and parameters of the upgrade
Change the node config, so it will automatically halt at the determined upgrade time
During upgrade
Run a web conference with other validators
Need to discuss export height and genesis time in realtime
Export keys and files
Export node key and consensus key by copying the key files
Export address book by copying the key files
Create new genesis
Determine export height
Determine new chain genesis time
Export old chain state
Migrate old chain state to new chain genesis
Verify new chain state
Setup new chain node
Initialize new chain node
Import new chain state
Import operator key
Import node key and consensus key
Import address book
Migrate operator key
Start the node and wait for what would happen at the new chain genesis time
Setup Testnet with SheungWan software
Requirements
Parameters
Chain ID:
likecoin-chain-public-testnet-2SHA256:
313f93afce5438655239f8f6915af02fd500a7485c6e0a2a0fb8ae8b6ed1decb
Seed node:
[email protected]:31801Software:
before upgrade: https://github.com/likecoin/likecoin-chain/tree/sheungwan-2
commit:
f81b7c728c0cdf22db4c324d8a12003c99b09703
after upgrade: https://github.com/likecoin/likecoin-chain/tree/fotan-1
commit:
32056fc4759d276a11180256474cc4ed5e3ed8d4
Denom (unit of token):
nanoekil(ekil is reverse of like)
Setup procedure
Install Git, Docker and Docker Compose
Clone the deployment repo with the corresponding branch:
git clone https://github.com/likecoin/likecoin-chain --branch sheungwan-2Go into the cloned repo:
cd likecoin-chainCopy the template
docker-compose.yml.templateand.env.templateasdocker-compose.ymland.envrespectively:cp docker-compose.yml.template docker-compose.yml cp .env.template .envEdit
.envfile to fill in the details, including chain parameters and custom parameters:LIKECOIN_DOCKER_IMAGE:"likecoin/likecoin-chain:sheungwan-2-testnet"LIKECOIN_CHAIN_ID:"likecoin-chain-public-testnet-2"LIKECOIN_UID: normally keep it as"1000"is fine, but if you are using root user under Linux (e.g. in some VPS) then you should change it to"0".LIKECOIN_MONIKER: any name you want to call your node. Will be displayed on validator list as the name of the validator.LIKECOIN_GENESIS_URL:"https://gist.githubusercontent.com/nnkken/a4eff0359b1acd816aa536bd664eb7ed/raw/207206a952078184b7dea1f152d4068612ef7bd6/genesis.json"LIKECOIN_SEED_NODES:"[email protected]:31801"
Initialize the node:
docker-compose run --rm initThis will create
.likedand.likeclifolders, setup the node config files and download genesis file according to the parameters in.env.Note that building the Docker image is not necessary, as the image is already on Docker Hub and Docker Compose will download the image automatically.
Setup the keystore and the operator key:
docker-compose run --rm likecli-command keys add validatorFollow the instruction to setup the keystore with passphrase. Eventually the command will output the address and a set of mnemonic words. Please write down the mnemonic words for backup.
Start the node
docker-compose up -dCheck the logs:
docker-compose logs --tail 100 -fYou should see the node synchronizing the blocks from the network. You may stop the display of the logs by
Ctrl+Cat anytime, it won't stop the node operation.Wait until the node is synchronized. This may take some time (hours), depending on the current block height of the chain.
You may check by going to http://localhost:26657/status and check
result.sync_info.catching_up. If the value isfalse, that means the node has caught up the latest block of the network.Run the following command to check the operator address:
docker-compose run --rm likecli-command keys show validator --addressGet some token from the faucet at https://likecoin-public-testnet-faucet.nnkken.dev. Fill in the operator address for receiving the token.
You may check the balance by:
docker-compose run --rm likecli-command \ query account \ --chain-id likecoin-chain-public-testnet-2 \ --node tcp://liked-service:26657 \ <OPERATOR_ADDRESS>Here modify
<OPERATOR_ADDRESS>to the operator address you get from the previous step.Sign and send a transaction for creating a validator:
docker-compose run --rm create-validator \ --amount <AMOUNT> \ --details <DETAILS> \ --commission-rate <COMMISSION_RATE>Modify the parameters:
<AMOUNT>: the amount to self-delegate on the validator at the beginning (e.g.90000000000000nanoekil).<DETAILS>: the detailed description of the validator. Remember to quote it using".:<COMMISSION_RATE>: the validator's commission rate, which could be seen as the "tax" received by the validator from delegators, e.g.0.5(50%).
Optionally, you may add the following additional parameters:
--identity <IDENTITY>: a string representing the identity of the validator, usually the GPG fingerprint. Some block explorers (e.g. Big Dipper) will query this field and search Keybase for the user profile.--website <WEBSITE>: the website of the validator.
You should be able to query the validator by:
docker-compose run --rm likecli-command \ query staking validators \ --chain-id likecoin-chain-public-testnet-2 \ --node tcp://liked-service:26657Note that the operator address referring the validator will start by
cosmosvaloper1instead ofcosmos1, and the last few letters (checksum characters) are also different.
Pre-upgrade: proposal & preparation
Pre-upgrade
Raise and pass a proposal on the upgrade.
To raise a proposal, one of the validators run the following command:
docker-compose run --rm likecli-command \ tx gov submit-proposal \ --chain-id likecoin-chain-public-testnet-2 \ --node tcp://liked-service:26657 \ --from validator \ --title "Upgrade software version to fotan-1" \ --type text \ --deposit 10000000000000nanoekil \ --description <DESCRIPTION>Modify the parameters:
<DESCRIPTION>: the content of the proposal, which should include some introduction to the upgrade, and also the following contents:the halt time (in both human-readable format with timezone, and also Unix timestamp)
the new chain parameters for the new ISCN module, namely:
ISCN registry name
ISCN fee per byte
the new software version (in Git commit hash)
and the new chain ID (e.g.
likecoin-chain-public-testnet-3)
After the creation of the proposal, one may query the content of the proposal by:
docker-compose run --rm likecli-command \ query gov proposals \ --chain-id likecoin-chain-public-testnet-2 \ --node tcp://liked-service:26657This will also show the proposal ID (should be
1for the first proposal).To pass the proposal, all validators vote for the proposal by running:
docker-compose run --rm vote 1 yesWhich means
vote "yes" in proposal ID 1.After the proposal is passed, setup chain halt time by modifying
.envfile and changingLIKECOIN_HALT_TIMEto the Unix timestamp of the halt time in the proposal.Restart the chain node by running:
docker-compose up -dJot down the content of the proposal, since chain explorers and APIs may not work during upgrade.
During upgrade
Right before the upgrade, validators should jot down the content of the proposal, since chain explorers and APIs may not work during the upgrade.
Validators should hold a meeting right before the upgrade time for discussing issues during the upgrade.
When the upgrade time comes, the chain node should be halt automatically.
Go into the node folder:
cd likecoin-chainTurn down the node:
docker-compose stopCheck the consensus public key:
docker-compose run --rm liked-command tendermint show-validatorRecord the output as consensus public key for later verification
Check the node ID:
docker-compose run --rm liked-command tendermint show-node-idRecord the output as node ID for later verification
Check the halting height of the node by:
docker-compose run --rm liked-command show-heightConfirm with other validators for the minimum height of exporting the state. The principle is to have consent and prevent state lost. For example, if the heights are
1234,1234,1234,1233,1233for different validators, then validators may use1233as the height for exporting state.Export chain state:
docker-compose run --rm liked-command \ export --for-zero-height \ --height <HEIGHT> \ > exported.jsonWhere the
<HEIGHT>is the height confirmed with other validators in the previous step.Copy
node_key.json(node key),priv_validator_key.json(consensus key) andaddrbook.json(address book) from.liked/configinto the fotan node folder:mkdir keys cp .liked/config/node_key.json \ .liked/config/priv_validator_key.json \ .liked/config/addrbook.json \ keysThis is to preserve the same keys and address book for the new fotan node.
Discuss with others the new genesis time, should have consensus according to the progress of the majority.
Fetch the newest software branch for the upgrade:
git fetchCheckout to the new software:
git checkout fotan-1Use new template of
docker-compose.ymlfrom the new software:cp docker-compose.yml docker-compose.yml.old cp docker-compose.yml.template docker-compose.ymlModify
.envfor the new chain:LIKECOIN_DOCKER_IMAGE:likecoin/likecoin-chain:fotan-1-testnetLIKECOIN_CHAIN_ID: the new chain ID specified in the proposal.LIKECOIN_HALT_TIME:"0"so that the new chain node can start up.LIKECOIN_GENESIS_URL:"genesis.json". The init script will detect that it is a local file and copy it from the migrated genesis file generated in the next step.
Migrate genesis state:
docker-compose run --rm liked-command \ migrate /host/exported.json \ --log_level "error" \ --chain-id <NEW_CHAIN_ID> \ --iscn-registry-name <ISCN_REGISTRY_NAME> \ --iscn-fee-per-byte <ISCN_FEE_PER_BYTE> \ --genesis-time <GENESIS_TIME> \ --output /host/genesis.jsonWhere
<NEW_CHAIN_ID>,<ISCN_REGISTRY_NAME>and<ISCN_FEE_PER_BYTE>should be modified to the values specified in the upgrade proposal, and<GENESIS_TIME>is determined in the previous step (format:YYYY-MM-DDThh:mm:ssZ, in UTC).Archive the old
.likedfolder:mv .liked .liked-oldCompute the checksum of genesis state with others:
sha256sum genesis.jsonFor Mac, use the following command instead:
shasum -a 256 genesis.jsonVerify the output checksum with other validators.
Re-initialize the node:
docker-compose run --rm initNote that this will create and write a new consensus public key at the end of
.envfile, which won't be used since we will use the original key instead. If you are already a validator, you will probably never use the field again so this is fine, but you are free to delete this line.(optional) Configure the new node (
config.toml&app.toml, both are in.liked/config)in
app.toml:setup
minimum-gas-pricesif needed, see the setting in your sheungwan node configunder
[api]section, if you need a local RESTful API server, then setenabletotrue, and also setup the corresponding port mapping indocker-compose.yml
in
config.toml:under
[p2p]section, if you don't want to use the--get-ipoption in the command parameter when starting the node for retrieving your externally accessible IP from third parties, then you need to enter your external address and port inexternal_address(e.g.123.123.123.123:26656)
Migrate the operator key:
docker-compose run liked-command keys migrate /host/.likecliFollow the instructions to migrate the keys in the old keystore.
For passphrases, the first one is for decrypting the old keystore, and the following 2 are for creating the new keystore.
Note that when it asks
Skip key migration? [y/N]:,Nactually meansnot skipping, which is what we need.Verify the operator key is properly imported:
docker-compose run --rm liked-command keys listCheck if the key with operator's address is listed and is the same address as before.
Re-import node key, consensus key and address book:
cp keys/node_key.json \ keys/priv_validator_key.json \ keys/addrbook.json \ .liked/configVerify the consensus key has been properly imported:
docker-compose run --rm liked-command \ tendermint show-validatorVerify that the output is the same as the previous recorded consensus public key.
Verify the node key has been properly imported:
docker-compose run --rm liked-command \ tendermint show-node-idVerify that the output is the same as the previous recorded node ID.
Restart the node:
docker-compose up -dMonitor the logs:
docker-compose logs -fWait for the new genesis time to see if anything goes wrong.
Properly process the
.liked-old,.likecliandkeysfolders, so the credentials are not leaked.
When Upgrade failed
If fatal issues happened during the upgrade (e.g. serious software bugs), then with the consent from the majority of the validators, validators may give up the upgrade and restart the SheungWan chain.
The procedure is simple:
Revert changes to
docker-compose.ymland.env.Set
halt-timeto"0"in.env.Revert
.likedfolder from.liked-bak.Start the node by
docker-compose up -d.Wait for enough validators to get online.
Last updated