Merge PR #2040: Refactor Validator Account Types/Bech32 Prefixing

* Add new account bech32 prefixes with godocs

* Restructure spacing of existing account code

* Update account godocs

* More account godoc updates + new tm pub/addr helpers

* Update validator type to use new account types/bech32 prefixes

* Fix account documentation errors

* Update Bech32 prefix for consensus nodes

* Update Bech32 spec doc

* Fix account type tests

* Add missing account consensus functions, clear up godocs, and fix tests

* Add to TestRandBech32PubkeyConsistency check

* Update initialization of validator public keys

* Update query signing info command

* Implement new ConsAddress type with associated unit tests

* [WIP] Update stake and slashing parameters

* Update all calls to MustBech32ifyValPub

* [WIP] Validator operator API updates

* [WIP] Fix and update unit tests

* Fix gov logs (helping to debug failing tests)

* Fix gov tally

* Fix all broken x/ unit tests

* Update gaia app genesis address logic

* Fix linting errors

* Fix broken LCD tests

* Fix broken CLI tests

* Implement command to get validator address and pubkey from key name

* Add support for getting validator key information via REST endpoint

* Update PENDING log

* Update docs

* Revert GaiaGenTx.PubKey bech32 prefix

* Fix broken docs and cli tests

* Update genesis to use correct Bech32 (cons) prefix for pubkeys

* Update docs and unit tests to reflect new cosmos account bech32 prefix

* minor formatting
This commit is contained in:
Alexander Bezobchuk
2018-08-31 00:06:44 -04:00
committed by Rigel
parent dc0f13214d
commit 2d92803b9f
66 changed files with 1315 additions and 835 deletions
+43 -33
View File
@@ -18,17 +18,21 @@
There are three types of key representations that are used:
- `cosmosaccaddr`
- `cosmos`
- Derived from account keys generated by `gaiacli keys add`
- Used to receive funds
- e.g. `cosmosaccaddr15h6vd5f0wqps26zjlwrc6chah08ryu4hzzdwhc`
- `cosmosaccpub`
- e.g. `cosmos15h6vd5f0wqps26zjlwrc6chah08ryu4hzzdwhc`
* `cosmosval`
* Used to associate a validator to it's operator
* Used to invoke staking commands
* e.g. `cosmosval1carzvgq3e6y3z5kz5y6gxp3wpy3qdrv928vyah`
- `cosmospub`
- Derived from account keys generated by `gaiacli keys add`
- e.g. `cosmosaccpub1zcjduc3q7fu03jnlu2xpl75s2nkt7krm6grh4cc5aqth73v0zwmea25wj2hsqhlqzm`
- `cosmosvalpub`
- e.g. `cosmospub1zcjduc3q7fu03jnlu2xpl75s2nkt7krm6grh4cc5aqth73v0zwmea25wj2hsqhlqzm`
- `cosmosconspub`
- Generated when the node is created with `gaiad init`.
- Get this value with `gaiad tendermint show-validator`
- e.g. `cosmosvalpub1zcjduc3qcyj09qc03elte23zwshdx92jm6ce88fgc90rtqhjx8v0608qh5ssp0w94c`
- e.g. `cosmosconspub1zcjduepq0ms2738680y72v44tfyqm3c9ppduku8fs6sr73fx7m666sjztznqzp2emf`
#### Generate Keys
@@ -48,6 +52,12 @@ If you check your private keys, you'll now see `<account_name>`:
gaiacli keys show <account_name>
```
View the validator operator's address via:
```shell
gaiacli keys show <account_name> --bech=val
```
You can see all your available keys by typing:
```bash
@@ -68,18 +78,18 @@ We strongly recommend _NOT_ using the same passphrase for multiple keys. The Ten
#### Get Tokens
The best way to get tokens is from the [Cosmos Testnet Faucet](https://faucetcosmos.network). If the faucet is not working for you, try asking [#cosmos-validators](https://riot.im/app/#/room/#cosmos-validators:matrix.org). The faucet needs the `cosmosaccaddr` from the account you wish to use for staking.
The best way to get tokens is from the [Cosmos Testnet Faucet](https://faucetcosmos.network). If the faucet is not working for you, try asking [#cosmos-validators](https://riot.im/app/#/room/#cosmos-validators:matrix.org). The faucet needs the `cosmos` from the account you wish to use for staking.
#### Query Account balance
After receiving tokens to your address, you can view your account's balance by typing:
```bash
gaiacli account <account_cosmosaccaddr>
gaiacli account <account_cosmos>
```
::: warning Note
When you query an account balance with zero tokens, you will get this error: `No account with address <account_cosmosaccaddr> was found in the state.` This can also happen if you fund the account before your node has fully synced with the chain. These are both normal.
When you query an account balance with zero tokens, you will get this error: `No account with address <account_cosmos> was found in the state.` This can also happen if you fund the account before your node has fully synced with the chain. These are both normal.
:::
@@ -90,7 +100,7 @@ gaiacli send \
--amount=10faucetToken \
--chain-id=<chain_id> \
--name=<key_name> \
--to=<destination_cosmosaccaddr>
--to=<destination_cosmos>
```
::: warning Note
@@ -106,14 +116,14 @@ Gas estimate might be inaccurate as state changes could occur in between the end
Now, view the updated balances of the origin and destination accounts:
```bash
gaiacli account <account_cosmosaccaddr>
gaiacli account <destination_cosmosaccaddr>
gaiacli account <account_cosmos>
gaiacli account <destination_cosmos>
```
You can also check your balance at a given block by using the `--block` flag:
```bash
gaiacli account <account_cosmosaccaddr> --block=<block_height>
gaiacli account <account_cosmos> --block=<block_height>
```
### Staking
@@ -137,7 +147,7 @@ gaiacli stake validators
If you want to get the information of a single validator you can check it with:
```bash
gaiacli stake validator <account_cosmosaccaddr>
gaiacli stake validator <account_cosmosval>
```
#### Bond Tokens
@@ -164,14 +174,14 @@ Once submitted a delegation to a validator, you can see it's information by usin
```bash
gaiacli stake delegation \
--address-delegator=<account_cosmosaccaddr> \
--address-validator=$(gaiad tendermint show-validator)
--address-delegator=<account_cosmos> \
--validator=<account_cosmosval>
```
Or if you want to check all your current delegations with disctinct validators:
```bash
gaiacli stake delegations <account_cosmosaccaddr>
gaiacli stake delegations <account_cosmos>
```
You can also get previous delegation(s) status by adding the `--height` flag.
@@ -182,7 +192,7 @@ If for any reason the validator misbehaves, or you just want to unbond a certain
```bash
gaiacli stake unbond begin \
--address-validator=$(gaiad tendermint show-validator) \
--validator=<account_cosmosval> \
--shares-percent=100 \
--from=<key_name> \
--chain-id=<chain_id>
@@ -192,7 +202,7 @@ Later you must complete the unbonding process by using the `gaiacli stake unbond
```bash
gaiacli stake unbond complete \
--address-validator=$(gaiad tendermint show-validator) \
--validator=<account_cosmosval> \
--from=<key_name> \
--chain-id=<chain_id>
```
@@ -203,14 +213,14 @@ Once you begin an unbonding-delegation, you can see it's information by using th
```bash
gaiacli stake unbonding-delegation \
--address-delegator=<account_cosmosaccaddr> \
--address-validator=$(gaiad tendermint show-validator) \
--address-delegator=<account_cosmos> \
--validator=<account_cosmosval> \
```
Or if you want to check all your current unbonding-delegations with disctinct validators:
```bash
gaiacli stake unbonding-delegations <account_cosmosaccaddr>
gaiacli stake unbonding-delegations <account_cosmos>
```
You can also get previous unbonding-delegation(s) status by adding the `--height` flag.
@@ -221,8 +231,8 @@ A redelegation is a type delegation that allows you to bond illiquid tokens from
```bash
gaiacli stake redelegate begin \
--address-validator-source=$(gaiad tendermint show-validator) \
--address-validator-dest=<account_cosmosaccaddr> \
--address-validator-source=<account_cosmosval> \
--address-validator-dest=<account_cosmosval> \
--shares-percent=50 \
--from=<key_name> \
--chain-id=<chain_id>
@@ -234,7 +244,7 @@ Later you must complete the redelegation process by using the `gaiacli stake red
```bash
gaiacli stake unbond complete \
--address-validator=$(gaiad tendermint show-validator) \
--validator=<account_cosmosval> \
--from=<key_name> \
--chain-id=<chain_id>
```
@@ -245,15 +255,15 @@ Once you begin an redelegation, you can see it's information by using the follow
```bash
gaiacli stake redelegation \
--address-delegator=<account_cosmosaccaddr> \
--address-validator-source=$(gaiad tendermint show-validator) \
--address-validator-dest=<account_cosmosaccaddr> \
--address-delegator=<account_cosmos> \
--address-validator-source=<account_cosmosval> \
--address-validator-dest=<account_cosmosval> \
```
Or if you want to check all your current unbonding-delegations with disctinct validators:
```bash
gaiacli stake redelegations <account_cosmosaccaddr>
gaiacli stake redelegations <account_cosmos>
```
You can also get previous redelegation(s) status by adding the `--height` flag.
@@ -286,7 +296,7 @@ gaiacli gov submit-proposal \
--title=<title> \
--description=<description> \
--type=<Text/ParameterChange/SoftwareUpgrade> \
--proposer=<account_cosmosaccaddr> \
--proposer=<account_cosmos> \
--deposit=<40steak> \
--from=<name> \
--chain-id=<chain_id>
@@ -316,7 +326,7 @@ In order for a proposal to be broadcasted to the network, the amount deposited m
```bash
gaiacli gov deposit \
--proposal-id=<proposal_id> \
--depositer=<account_cosmosaccaddr> \
--depositer=<account_cosmos> \
--deposit=<200steak> \
--from=<name> \
--chain-id=<chain_id>
@@ -331,7 +341,7 @@ After a proposal's deposit reaches the `MinDeposit` value, the voting period ope
```bash
gaiacli gov vote \
--proposal-id=<proposal_id> \
--voter=<account_cosmosaccaddr> \
--voter=<account_cosmos> \
--option=<Yes/No/NoWithVeto/Abstain> \
--from=<name> \
--chain-id=<chain_id>
@@ -344,7 +354,7 @@ Check the vote with the option you just submitted:
```bash
gaiacli gov query-vote \
--proposal-id=<proposal_id> \
--voter=<account_cosmosaccaddr>
--voter=<account_cosmos>
```
#### Query Parameters