0g-chain/x/validator-vesting/spec/02_state.md

32 lines
2.1 KiB
Markdown
Raw Normal View History

<!--
order: 2
-->
2019-09-23 19:12:18 +00:00
# State
## Validator Vesting Account type
2020-05-07 21:52:07 +00:00
Validator Vesting Accounts implement the `cosmos-sdk` vesting account interfaces and extends the `PeriodicVestingAccountType`:
2019-09-23 19:12:18 +00:00
```go
type ValidatorVestingAccount struct {
*vesting.PeriodicVestingAccount
2020-05-07 21:52:07 +00:00
2019-09-23 19:12:18 +00:00
ValidatorAddress sdk.ConsAddress // The validator address which will be used to check if blocks were signed
ReturnAddress sdk.AccAddress `json:"return_address" yaml:"return_address"` // The account where coins will be returned in the event of a failed vesting period
SigningThreshold int64 `json:"signing_threshold" yaml:"signing_threshold"` // The percentage of blocks, as an integer between 0 and 100, that must be signed each period for coins to successfully vest.
MissingSignCount []int64 `json:"missing_sign_count" yaml:"missing_sign_count"` // An array of two integers which track the number of blocks that were not signed during the current period and the total number of blocks which have passed during the current period, respectively.
2020-05-07 21:52:07 +00:00
VestingPeriodProgress [][]int `json:"vesting_period_progress" yaml:"vesting_period_progress"` //An 2d array with length equal to the number of vesting periods. After each period, the value at the first index of that period is updated with 1 to represent that the period is over. The value at the second index is updated to 0 for unsuccessful vesting and 1 for successful vesting.
DebtAfterFailedVesting sdk.Coins `json:"debt_after_failed_vesting" yaml:"debt_after_failed_vesting"` // The debt currently owed by the account. Debt accumulates in the event of unsuccessful vesting periods.
}
2019-09-23 19:12:18 +00:00
```
## Stores
There is one `KVStore` in `validator-vesting` which stores
2020-05-07 21:52:07 +00:00
2019-09-23 19:12:18 +00:00
* A mapping from each ValidatorVestingAccount `address` to `[]Byte{0}`
* A mapping from `previous_block_time_prefix` to `time.Time`
2020-05-07 21:52:07 +00:00
The use of `[]Byte{0}` value for each `address` key reflects that this module only accesses the store to get or iterate over keys, and does not require storing an value. The storage of the actual account state is done by the cosmos-sdk `x/auth` `AccountKeeper`.