2018-08-08 03:10:21 -07:00
|
|
|
## State
|
|
|
|
|
2018-09-05 16:15:15 -07:00
|
|
|
### FeePool
|
2018-08-08 03:10:21 -07:00
|
|
|
|
|
|
|
All globally tracked parameters for distribution are stored within
|
2018-09-05 16:15:15 -07:00
|
|
|
`FeePool`. Rewards are collected and added to the reward pool and
|
2018-08-08 03:10:21 -07:00
|
|
|
distributed to validators/delegators from here.
|
|
|
|
|
|
|
|
Note that the reward pool holds decimal coins (`DecCoins`) to allow
|
|
|
|
for fractions of coins to be received from operations like inflation.
|
|
|
|
When coins are distributed from the pool they are truncated back to
|
|
|
|
`sdk.Coins` which are non-decimal.
|
|
|
|
|
2018-09-05 16:15:15 -07:00
|
|
|
- FeePool: `0x00 -> amino(FeePool)`
|
2018-08-08 03:10:21 -07:00
|
|
|
|
|
|
|
```golang
|
|
|
|
// coins with decimal
|
|
|
|
type DecCoins []DecCoin
|
|
|
|
|
|
|
|
type DecCoin struct {
|
|
|
|
Amount sdk.Dec
|
|
|
|
Denom string
|
|
|
|
}
|
|
|
|
|
2018-09-05 16:15:15 -07:00
|
|
|
type FeePool struct {
|
2018-08-08 20:43:40 -07:00
|
|
|
TotalValAccumUpdateHeight int64 // last height which the total validator accum was updated
|
|
|
|
TotalValAccum sdk.Dec // total valdator accum held by validators
|
|
|
|
Pool DecCoins // funds for all validators which have yet to be withdrawn
|
|
|
|
CommunityPool DecCoins // pool for community funds yet to be spent
|
2018-08-08 03:10:21 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Validator Distribution
|
|
|
|
|
|
|
|
Validator distribution information for the relevant validator is updated each time:
|
2018-08-20 08:50:13 -07:00
|
|
|
1. delegation amount to a validator is updated,
|
2018-08-08 03:10:21 -07:00
|
|
|
2. a validator successfully proposes a block and receives a reward,
|
|
|
|
3. any delegator withdraws from a validator, or
|
|
|
|
4. the validator withdraws it's commission.
|
|
|
|
|
2018-08-16 13:41:32 -07:00
|
|
|
- ValidatorDistInfo: `0x02 | ValOperatorAddr -> amino(validatorDistribution)`
|
2018-08-08 03:10:21 -07:00
|
|
|
|
|
|
|
```golang
|
2018-08-16 13:41:32 -07:00
|
|
|
type ValidatorDistInfo struct {
|
2018-09-05 16:15:15 -07:00
|
|
|
FewPoolWithdrawalHeight int64 // last height this validator withdrew from the global fee pool
|
2018-08-23 00:19:21 -07:00
|
|
|
Pool DecCoins // rewards owed to delegators, commission has already been charged (includes proposer reward)
|
|
|
|
PoolCommission DecCoins // commission collected by this validator (pending withdrawal)
|
2018-08-08 20:43:40 -07:00
|
|
|
|
|
|
|
TotalDelAccumUpdateHeight int64 // last height which the total delegator accum was updated
|
|
|
|
TotalDelAccum sdk.Dec // total proposer pool accumulation factor held by delegators
|
2018-08-08 03:10:21 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Delegation Distribution
|
|
|
|
|
2018-08-08 20:43:40 -07:00
|
|
|
Each delegation distribution only needs to record the height at which it last
|
|
|
|
withdrew fees. Because a delegation must withdraw fees each time it's
|
|
|
|
properties change (aka bonded tokens etc.) its properties will remain constant
|
|
|
|
and the delegator's _accumulation_ factor can be calculated passively knowing
|
|
|
|
only the height of the last withdrawal and its current properties.
|
2018-08-08 03:10:21 -07:00
|
|
|
|
2018-10-05 17:32:06 -07:00
|
|
|
- DelegationDistInfo: ` 0x02 | DelegatorAddr | ValOperatorAddr -> amino(delegatorDist)`
|
2018-08-08 03:10:21 -07:00
|
|
|
|
|
|
|
```golang
|
2018-10-05 17:32:06 -07:00
|
|
|
type DelegationDistInfo struct {
|
2018-08-08 11:24:38 -07:00
|
|
|
WithdrawalHeight int64 // last time this delegation withdrew rewards
|
2018-08-08 03:10:21 -07:00
|
|
|
}
|
|
|
|
```
|