From 810e87ba93f718b150a48eae1de80a20075de47a Mon Sep 17 00:00:00 2001 From: wicky Date: Mon, 2 Sep 2019 16:19:26 +0800 Subject: [PATCH] update docs/cmd --- docs/cmd.md | 166 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 158 insertions(+), 8 deletions(-) diff --git a/docs/cmd.md b/docs/cmd.md index a96e81c..d1d402e 100644 --- a/docs/cmd.md +++ b/docs/cmd.md @@ -1,7 +1,7 @@ # AnnChain Command Tool -This document is about AnnChain usage. It does not involve AnnChain installation, node deployment and start-up. -This note uses gtool to deploy and execute smart contracts, and Go/Java SDK to perform contract-related operations. +This document is about AnnChain's usage. It does not involve AnnChain installation, node deployment and start-up. +This note uses gtool to deploy and execute smart contracts, also can use the Go/Java SDK to perform contract-related operations. ## Create Account @@ -23,10 +23,9 @@ The default node has been started for the following actions ``` gtool --backend evm create --abif --callf --nonce +Privkey for user: //account's private key ``` -In addition to the above parameters, you need to input the private key of the validator node in the running chain when prompting "Privkey for user". - ##### Result ``` @@ -126,10 +125,9 @@ sample.json ``` gtool --backend evm call --abif --callf --nonce +Privkey for user: //account's private key ``` -In addition to the above parameters, you need to input the private key of the validator node in the running chain when prompting "Privkey for user". - ##### Result @@ -169,10 +167,9 @@ sample_execute.json ``` gtool --backend evm read --abif --callf +Privkey for user: //account's private key ``` -In addition to the above parameters, you need to input the private key of the validator node in the running chain when prompting "Privkey for user". - ##### Result ``` @@ -246,3 +243,156 @@ query result receipt ./build/gtool --backend "tcp://127.0.0.1:46657" query receipt --hash 0x2b41d9c05a7be5b85586c53b5a2d3cacc1ded323a18f1c62c51bc2aea0953b55 query result: {"root":null,"status":1,"cumulativeGasUsed":21656,"logsBloom":"0x00000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000020000000000000000000000000000000000000000000000000000000000000","logs":[{"address":"0xae119075bd77de2d8e32629bdb439d967a1ecfe6","topics":["0xb45ab3e8c50935ce2fa51d37817fd16e7358a3087fd93a9ac7fbddb22a926c35"],"data":"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000064","blockNumber":"0x64e","transactionHash":"0x2b41d9c05a7be5b85586c53b5a2d3cacc1ded323a18f1c62c51bc2aea0953b55","transactionIndex":"0x0","blockHash":"0x000000000000000000000000ec83a146ca731fdffe4bef69ad260d7389732e87","logIndex":"0x0","removed":false}],"transactionHash":"0x2b41d9c05a7be5b85586c53b5a2d3cacc1ded323a18f1c62c51bc2aea0953b55","contractAddress":"0x0000000000000000000000000000000000000000","gasUsed":21656} ``` + +## New Node Synchronous Chain's Data + +If a new node wants to join the chain, it needs to synchronize the chain data in the first. The details are as follows: + +#### Initialize a new node + +##### Command + +``` +./build/genesis init +``` + +##### Result + +``` +Log dir is: ./ +Initialized chain_id: genesis-SyaIbH genesis_file: /root/.genesis/genesis.json priv_validator: /root/.genesis/priv_validator.json +Check the files generated, make sure everything is OK. +``` + +The node's information can be found from `priv_validator.json` + +- The node's private key is `C25E861FC9083455FB1D47CDB1DCBC49597370C4A7E014C07D6D8E7BF9849F95FB192BF3F6D8B2DD2FA8CAE2F5E9B6B64597CD88BC7778820646B68A7E9D02F9` +- The node's public key is `FB192BF3F6D8B2DD2FA8CAE2F5E9B6B64597CD88BC7778820646B68A7E9D02F9` + +#### Update `config.toml` + +- `seeds` + + Filling in the `p2p_laddr` of the nodes which are validators in the chain in order to get the current state of the chain. + + ##### Demo + + ``` + seeds = "0.0.0.0:46000,0.0.0.0:46001,0.0.0.0:46002,0.0.0.0:46003" + ``` + +- `signbyca` + + If `auth_by_ca`is true, CA node's signature must be filled in `signbyca`. The details are as follows: + + ##### Command + + ``` + ./build/gtool sign --pub + Node Privkey for user://CA node's private key + ``` + + ##### Result + + ``` + : + ``` + + ##### Demo + + ``` + ./build/gtool sign --pub FB192BF3F6D8B2DD2FA8CAE2F5E9B6B64597CD88BC7778820646B68A7E9D02F9 + Node Privkey for user: + 2948184E586A8079538D6B033388CA094507D1339157AD397F687B17D327C237A05B3A182A3006024DD632823EA37F5B3742286AC759767DBD7B422C60175810 + FB192BF3F6D8B2DD2FA8CAE2F5E9B6B64597CD88BC7778820646B68A7E9D02F9 : ca4b244dbeadd0418434a42d8f4cc19570f0a5f091213460a2597601cd8f25d25daca5254dcd1b7599da3bacb3df9c73b91c34e3ac9ebd58fddf32fa18398805 + ``` + + ``` + signbyca = "ca4b244dbeadd0418434a42d8f4cc19570f0a5f091213460a2597601cd8f25d25daca5254dcd1b7599da3bacb3df9c73b91c34e3ac9ebd58fddf32fa18398805" + ``` + +#### Update `genesis.json` + +`genesis.json` should be replaced by CA nodes' `genesis.json` .Then run the node: + +``` +./build/genesis run +``` + +## Add Validator Node + +If the new node wants to vote, It must be a validator node. The details are as follows: + +##### Command + +``` +./build/gtool admin add_peer --nPrivs +Input Privkey of addnode for user: //new node's private key +Now fetch CA-Node;need n private keys; please input n' keys: //CA nodes' private keys,n is the number of CA nodes which needed to validate the behavior +``` + +##### Result + +``` +hash //tx hash +``` + +##### Demo + +``` +./build/gtool admin add_peer --nPrivs 1 +Input Privkey of addnode for user: +C25E861FC9083455FB1D47CDB1DCBC49597370C4A7E014C07D6D8E7BF9849F95FB192BF3F6D8B2DD2FA8CAE2F5E9B6B64597CD88BC7778820646B68A7E9D02F9 +Now fetch CA-Node;need 1 private keys; please input 1' keys: +2948184E586A8079538D6B033388CA094507D1339157AD397F687B17D327C237A05B3A182A3006024DD632823EA37F5B3742286AC759767DBD7B422C60175810 +hash= 0x288f30b4e5904b2cddf3d157bb7a4820229c947bf0ee00c51019f136071d8e19 +``` + +## Update Validator Node's Voting Power + +If the new node wants to update voting power, It must be a validator node in the first. The initial power is 0. + +##### Command + +``` +./build/gtool admin change_node --validator_pubkey --power --nPrivs +need n private keys; please input n' keys: //CA nodes' private keys,n is the number of CA nodes which needed to validate the behavior +``` + +##### Result + +``` +hash //tx hash +``` + +##### Demo + +``` +./build/gtool admin change_node --validator_pubkey FB192BF3F6D8B2DD2FA8CAE2F5E9B6B64597CD88BC7778820646B68A7E9D02F9 --power 20 --nPrivs 1 +need 1 private keys; please input 1' keys: +2948184E586A8079538D6B033388CA094507D1339157AD397F687B17D327C237A05B3A182A3006024DD632823EA37F5B3742286AC759767DBD7B422C60175810 +hash= 0x110ee98edba177ede906e5d8175d9f787bfed61f3bb841537327d6f8128c6dbe +``` + +## Remove Node + +``` +./build/gtool admin remove_node --validator_pubkey --nPrivs +need n private keys; please input n' keys //CA nodes' private keys,n is the number of CA nodes which needed to validate the behavior +``` + +##### Result + +``` +hash //tx hash +``` + +##### Demo + +``` +./build/gtool admin remove_node --validator_pubkey FB192BF3F6D8B2DD2FA8CAE2F5E9B6B64597CD88BC7778820646B68A7E9D02F9 --nPrivs 1 +need 1 private keys; please input 1' keys: +2948184E586A8079538D6B033388CA094507D1339157AD397F687B17D327C237A05B3A182A3006024DD632823EA37F5B3742286AC759767DBD7B422C60175810 +hash= 0x05248b13cda3b0feb40a9ec47d27e43c5a4648278e1473125c33089ad24d1d3d +``` +