Addressed basic comments
This commit is contained in:
parent
89494ef73e
commit
41130f8742
|
@ -4,9 +4,9 @@
|
|||
|
||||
This paper specifies changes to the auth and bank modules to implement vested accounts for the Cosmos Hub.
|
||||
The requirements for this vested account is that it should be capable of being initialized during genesis with
|
||||
a starting balance X coins and a vesting blocknumber N. The owner of this account should be able to delegate to validators and vote,
|
||||
a starting balance X coins and a vesting blocktime T. The owner of this account should be able to delegate to validators and vote,
|
||||
however they cannot send their coins to other accounts until the account has fully vested. Thus, the bank module's `MsgSend` handler
|
||||
should error if a vested account is trying to send an amount before block N.
|
||||
should error if a vested account is trying to send an amount before time T.
|
||||
|
||||
### Implementation
|
||||
|
||||
|
@ -36,9 +36,10 @@ type Account interface {
|
|||
SetCoins(sdk.Coins) error
|
||||
|
||||
// Getter and setter methods for account params
|
||||
// Parameters can be understood to be a map[string]interface{} with encoded keys and vals in store
|
||||
// It is upto handler to use these appropriately
|
||||
GetParams() map[string]interface{}
|
||||
SetParams(map[string]interface{}) error
|
||||
GetParams([]byte) []byte
|
||||
SetParams([]byte, []byte) error
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -47,7 +48,7 @@ handler can then call `GetParams` to handle the specific account type using the
|
|||
exist in the parameter map.
|
||||
|
||||
The `VestedAccount` will be an implementation of `Account` interface that wraps `BaseAccount` with
|
||||
`Type() => "vested` and params, `GetParams() => {"BlockLock": blockN (int64)}`.
|
||||
`Type() => "vested` and params, `GetParams() => {"TimeLock": N (int64)}`.
|
||||
`SetParams` will be disabled as we do not want to update params after vested account initialization.
|
||||
|
||||
|
||||
|
@ -62,7 +63,7 @@ handled at the `bank.Keeper` level. Specifically in methods that are explicitly
|
|||
`sendCoins` and `inputOutputCoins`. These methods must check an account's `Type` method; if it is a vested
|
||||
account (i.e. `acc.Type() == "vested"`):
|
||||
|
||||
1. Check if `ctx.BlockHeight() < acc.GetParams()["BlockLock"]`
|
||||
1. Check if `ctx.BlockHeader().Time < acc.GetParams()["BlockLock"]`
|
||||
2. If `true`, the account is still vesting, return sdk.Error. Else, allow transaction to be processed as normal.
|
||||
|
||||
### Initializing at Genesis
|
||||
|
@ -71,16 +72,16 @@ To initialize both vested accounts and base accounts, the `GenesisAccount` struc
|
|||
|
||||
```go
|
||||
type GenesisAccount struct {
|
||||
Address sdk.AccAddress `json:"address"`
|
||||
Coins sdk.Coins `json:"coins"`
|
||||
Type string `json:"type"`
|
||||
BlockLock int64 `json:"lock"`
|
||||
Address sdk.AccAddress `json:"address"`
|
||||
Coins sdk.Coins `json:"coins"`
|
||||
Type string `json:"type"`
|
||||
TimeLock int64 `json:"lock"`
|
||||
}
|
||||
```
|
||||
|
||||
During `InitChain`, the GenesisAccount's are decoded. If they have `Type == "vested`, a vested account with parameters =>
|
||||
`{"BlockLock": BlockLock}` gets created and put in initial state. Otherwise if `Type == "base"` a base account is created
|
||||
and the `BlockLock` attribute of corresponding `GenesisAccount` is ignored. `InitChain` will panic on any other account types.
|
||||
`{"TimeLock": N}` gets created and put in initial state. Otherwise if `Type == "base"` a base account is created
|
||||
and the `TimeLock` attribute of corresponding `GenesisAccount` is ignored. `InitChain` will panic on any other account types.
|
||||
|
||||
### Pros and Cons
|
||||
|
||||
|
|
Loading…
Reference in New Issue