Skip to content

Commit

Permalink
docs: (x/distribution) Fix docs for v0.47 (#14022)
Browse files Browse the repository at this point in the history
  • Loading branch information
facundomedica authored Nov 25, 2022
1 parent d1e5a44 commit 16c772d
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 25 deletions.
2 changes: 1 addition & 1 deletion proto/cosmos/distribution/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ message GenesisState {
repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5
[(gogoproto.nullable) = false, (amino.dont_omitempty) = true];

// fee_pool defines the accumulated commisions of all validators at genesis.
// fee_pool defines the accumulated commissions of all validators at genesis.
repeated ValidatorAccumulatedCommissionRecord validator_accumulated_commissions = 6
[(gogoproto.nullable) = false, (amino.dont_omitempty) = true];

Expand Down
96 changes: 74 additions & 22 deletions x/distribution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ following rewards between validators and associated delegators:
* validator commission on all rewards earned by their delegators stake

Fees are pooled within a global pool. The mechanisms used allow for validators
and delegators to independently and lazily withdraw their rewards.
and delegators to independently and lazily withdraw their rewards.

## Shortcomings

Expand Down Expand Up @@ -190,7 +190,7 @@ type DelegationDistInfo struct {

### Params

The distribution module stores it's params in state with the prefix of `0x09`,
The distribution module stores it's params in state with the prefix of `0x09`,
it can be updated with governance or the address with authority.

* Params: `0x09 | ProtocolBuffer(Params)`
Expand Down Expand Up @@ -395,7 +395,7 @@ func (k Keeper) initializeDelegation(ctx sdk.Context, val sdk.ValAddress, del sd

### MsgUpdateParams

Distribution module params can be updated through `MsgUpdateParams`, which can be done using governance proposal and the signer will always be gov module account address.
Distribution module params can be updated through `MsgUpdateParams`, which can be done using governance proposal and the signer will always be gov module account address.

```protobuf reference
https://github.com/cosmos/cosmos-sdk/blob/8822ef2695a1eb8cb30b7432f58f631c73951f1d/proto/cosmos/distribution/v1beta1/tx.proto#L106-L119
Expand Down Expand Up @@ -454,7 +454,6 @@ Any remaining rewards are dust amounts.
### Validator is slashed

* triggered-by: `staking.Slash`

* The current validator period reference count is incremented.
The reference count is incremented because the slash event has created a reference to it.
* The validator period is incremented.
Expand Down Expand Up @@ -545,7 +544,7 @@ simd query distribution commission [address] [flags]
Example:

```shell
simd query distribution commission cosmosvaloper1..
simd query distribution commission cosmosvaloper1...
```

Example Output:
Expand Down Expand Up @@ -612,7 +611,7 @@ simd query distribution rewards [delegator-addr] [validator-addr] [flags]
Example:

```shell
simd query distribution rewards cosmos1..
simd query distribution rewards cosmos1...
```

Example Output:
Expand All @@ -639,7 +638,7 @@ simd query distribution slashes [validator] [start-height] [end-height] [flags]
Example:

```shell
simd query distribution slashes cosmosvaloper1.. 1 1000
simd query distribution slashes cosmosvaloper1... 1 1000
```

Example Output:
Expand All @@ -664,7 +663,7 @@ simd query distribution validator-outstanding-rewards [validator] [flags]
Example:

```shell
simd query distribution validator-outstanding-rewards cosmosvaloper1..
simd query distribution validator-outstanding-rewards cosmosvaloper1...
```

Example Output:
Expand All @@ -675,6 +674,26 @@ rewards:
denom: stake
```

##### validator-distribution-info

The `validator-distribution-info` command allows users to query validator commission and self-delegation rewards for validator.

````shell
simd query distribution validator-distribution-info cosmosvaloper1...
```

Example Output:

```yml
commission:
- amount: "100000.000000000000000000"
denom: stake
operator_address: cosmosvaloper1...
self_bond_rewards:
- amount: "100000.000000000000000000"
denom: stake
```
#### Transactions
The `tx` commands allow users to interact with the `distribution` module.
Expand All @@ -694,7 +713,7 @@ simd tx distribution fund-community-pool [amount] [flags]
Example:

```shell
simd tx distribution fund-community-pool 100stake --from cosmos1..
simd tx distribution fund-community-pool 100stake --from cosmos1...
```

##### set-withdraw-addr
Expand All @@ -708,7 +727,7 @@ simd tx distribution set-withdraw-addr [withdraw-addr] [flags]
Example:

```shell
simd tx distribution set-withdraw-addr cosmos1.. --from cosmos1..
simd tx distribution set-withdraw-addr cosmos1... --from cosmos1...
```

##### withdraw-all-rewards
Expand All @@ -722,13 +741,13 @@ simd tx distribution withdraw-all-rewards [flags]
Example:

```shell
simd tx distribution withdraw-all-rewards --from cosmos1..
simd tx distribution withdraw-all-rewards --from cosmos1...
```

##### withdraw-rewards

The `withdraw-rewards` command allows users to withdraw all rewards from a given delegation address,
and optionally withdraw validator commission if the delegation address given is a validator operator and the user proves the `--commision` flag.
and optionally withdraw validator commission if the delegation address given is a validator operator and the user proves the `--commission` flag.

```shell
simd tx distribution withdraw-rewards [validator-addr] [flags]
Expand All @@ -737,7 +756,7 @@ simd tx distribution withdraw-rewards [validator-addr] [flags]
Example:

```shell
simd tx distribution withdraw-rewards cosmosvaloper1.. --from cosmos1.. --commision
simd tx distribution withdraw-rewards cosmosvaloper1... --from cosmos1... --commission
```

### gRPC
Expand Down Expand Up @@ -769,6 +788,41 @@ Example Output:
}
```

#### ValidatorDistributionInfo

The `ValidatorDistributionInfo` queries validator commission and self-delegation rewards for validator.

Example:

```shell
grpcurl -plaintext \
-d '{"validator_address":"cosmosvalop1..."}' \
localhost:9090 \
cosmos.distribution.v1beta1.Query/ValidatorDistributionInfo
```

Example Output:

```json
{
"commission": {
"commission": [
{
"denom": "stake",
"amount": "1000000000000000"
}
]
},
"self_bond_rewards": [
{
"denom": "stake",
"amount": "1000000000000000"
}
],
"validator_address": "cosmosvalop1..."
}
```

#### ValidatorOutstandingRewards

The `ValidatorOutstandingRewards` endpoint allows users to query rewards of a validator address.
Expand Down Expand Up @@ -862,7 +916,7 @@ Example:

```shell
grpcurl -plaintext \
-d '{"delegator_address":"cosmos1..","validator_address":"cosmosvalop1.."}' \
-d '{"delegator_address":"cosmos1...","validator_address":"cosmosvalop1..."}' \
localhost:9090 \
cosmos.distribution.v1beta1.Query/DelegationRewards
```
Expand All @@ -888,7 +942,7 @@ Example:

```shell
grpcurl -plaintext \
-d '{"delegator_address":"cosmos1.."}' \
-d '{"delegator_address":"cosmos1..."}' \
localhost:9090 \
cosmos.distribution.v1beta1.Query/DelegationTotalRewards
```
Expand All @@ -899,7 +953,7 @@ Example Output:
{
"rewards": [
{
"validatorAddress": "cosmosvaloper1..",
"validatorAddress": "cosmosvaloper1...",
"reward": [
{
"denom": "stake",
Expand All @@ -925,7 +979,7 @@ Example:

```shell
grpcurl -plaintext \
-d '{"delegator_address":"cosmos1.."}' \
-d '{"delegator_address":"cosmos1..."}' \
localhost:9090 \
cosmos.distribution.v1beta1.Query/DelegatorValidators
```
Expand All @@ -934,9 +988,7 @@ Example Output:

```json
{
"validators": [
"cosmosvaloper1.."
]
"validators": ["cosmosvaloper1..."]
}
```

Expand All @@ -948,7 +1000,7 @@ Example:

```shell
grpcurl -plaintext \
-d '{"delegator_address":"cosmos1.."}' \
-d '{"delegator_address":"cosmos1..."}' \
localhost:9090 \
cosmos.distribution.v1beta1.Query/DelegatorWithdrawAddress
```
Expand All @@ -957,7 +1009,7 @@ Example Output:

```json
{
"withdrawAddress": "cosmos1.."
"withdrawAddress": "cosmos1..."
}
```

Expand Down
2 changes: 1 addition & 1 deletion x/distribution/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/staking/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestValidateParams(t *testing.T) {
// default params have no error
require.NoError(t, params.Validate())

// validate mincommision
// validate mincommission
params.MinCommissionRate = math.LegacyNewDec(-1)
require.Error(t, params.Validate())

Expand Down

0 comments on commit 16c772d

Please sign in to comment.