Add AccrualTime type and state methods (#1379)

* Add methods for reward accrual time

* Add accrual time methods

* Add claim type to IterateAllRewardAccrualTimes callback method

* Use new AccrualTime proto type for state methods, add to genesis

* Add GetAllRewardAccrualTimes doc

* Add accrual times to genesis methods

* Remove DecodeKeyPrefix

* Update acrual time iterate method naming

* Update Iterate claims naming

* Use method for sourceID key conversion
This commit is contained in:
Derrick Lee 2022-11-04 16:21:05 -07:00 committed by GitHub
parent 4087941691
commit df1c2ffc34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 762 additions and 71 deletions

View File

@ -329,6 +329,7 @@
- [RewardPeriod](#kava.incentive.v1beta1.RewardPeriod) - [RewardPeriod](#kava.incentive.v1beta1.RewardPeriod)
- [kava/incentive/v1beta1/genesis.proto](#kava/incentive/v1beta1/genesis.proto) - [kava/incentive/v1beta1/genesis.proto](#kava/incentive/v1beta1/genesis.proto)
- [AccrualTime](#kava.incentive.v1beta1.AccrualTime)
- [AccumulationTime](#kava.incentive.v1beta1.AccumulationTime) - [AccumulationTime](#kava.incentive.v1beta1.AccumulationTime)
- [GenesisRewardState](#kava.incentive.v1beta1.GenesisRewardState) - [GenesisRewardState](#kava.incentive.v1beta1.GenesisRewardState)
- [GenesisState](#kava.incentive.v1beta1.GenesisState) - [GenesisState](#kava.incentive.v1beta1.GenesisState)
@ -4778,6 +4779,25 @@ RewardPeriod stores the state of an ongoing reward
<a name="kava.incentive.v1beta1.AccrualTime"></a>
### AccrualTime
AccrualTime stores the previous reward distribution time and its
corresponding collateral type and claim type. This is the new version of
AccumulationTime that is used for the new claim types.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `claim_type` | [ClaimType](#kava.incentive.v1beta1.ClaimType) | | |
| `collateral_type` | [string](#string) | | |
| `previous_accumulation_time` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
<a name="kava.incentive.v1beta1.AccumulationTime"></a> <a name="kava.incentive.v1beta1.AccumulationTime"></a>
### AccumulationTime ### AccumulationTime
@ -4833,6 +4853,7 @@ GenesisState is the state that must be provided at genesis.
| `earn_reward_state` | [GenesisRewardState](#kava.incentive.v1beta1.GenesisRewardState) | | | | `earn_reward_state` | [GenesisRewardState](#kava.incentive.v1beta1.GenesisRewardState) | | |
| `earn_claims` | [EarnClaim](#kava.incentive.v1beta1.EarnClaim) | repeated | | | `earn_claims` | [EarnClaim](#kava.incentive.v1beta1.EarnClaim) | repeated | |
| `claims` | [Claim](#kava.incentive.v1beta1.Claim) | repeated | | | `claims` | [Claim](#kava.incentive.v1beta1.Claim) | repeated | |
| `accrual_times` | [AccrualTime](#kava.incentive.v1beta1.AccrualTime) | repeated | |

View File

@ -15,11 +15,22 @@ option (gogoproto.goproto_getters_all) = false;
// AccumulationTime stores the previous reward distribution time and its corresponding collateral type // AccumulationTime stores the previous reward distribution time and its corresponding collateral type
message AccumulationTime { message AccumulationTime {
option deprecated = true;
string collateral_type = 1; string collateral_type = 1;
google.protobuf.Timestamp previous_accumulation_time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; google.protobuf.Timestamp previous_accumulation_time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
} }
// AccrualTime stores the previous reward distribution time and its
// corresponding collateral type and claim type. This is the new version of
// AccumulationTime that is used for the new claim types.
message AccrualTime {
ClaimType claim_type = 1;
string collateral_type = 2;
google.protobuf.Timestamp previous_accumulation_time = 3 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
// GenesisRewardState groups together the global state for a particular reward so it can be exported in genesis. // GenesisRewardState groups together the global state for a particular reward so it can be exported in genesis.
message GenesisRewardState { message GenesisRewardState {
repeated AccumulationTime accumulation_times = 1 repeated AccumulationTime accumulation_times = 1
@ -66,4 +77,6 @@ message GenesisState {
repeated EarnClaim earn_claims = 14 [(gogoproto.castrepeated) = "EarnClaims", (gogoproto.nullable) = false]; repeated EarnClaim earn_claims = 14 [(gogoproto.castrepeated) = "EarnClaims", (gogoproto.nullable) = false];
repeated Claim claims = 15 [(gogoproto.castrepeated) = "Claims", (gogoproto.nullable) = false]; repeated Claim claims = 15 [(gogoproto.castrepeated) = "Claims", (gogoproto.nullable) = false];
repeated AccrualTime accrual_times = 16 [(gogoproto.castrepeated) = "AccrualTimes", (gogoproto.nullable) = false];
} }

View File

@ -49,6 +49,18 @@ func InitGenesis(
k.SetClaim(ctx, claim) k.SetClaim(ctx, claim)
} }
// Set AccrualTimes of all types
for _, accrualTime := range gs.AccrualTimes {
k.SetRewardAccrualTime(
ctx,
accrualTime.ClaimType,
accrualTime.CollateralType,
accrualTime.PreviousAccumulationTime,
)
}
// Legacy claims and indexes below
// USDX Minting // USDX Minting
for _, claim := range gs.USDXMintingClaims { for _, claim := range gs.USDXMintingClaims {
k.SetUSDXMintingClaim(ctx, claim) k.SetUSDXMintingClaim(ctx, claim)
@ -152,6 +164,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
params := k.GetParams(ctx) params := k.GetParams(ctx)
claims := k.GetAllClaims(ctx) claims := k.GetAllClaims(ctx)
accrualTimes := k.GetAllRewardAccrualTimes(ctx)
usdxClaims := k.GetAllUSDXMintingClaims(ctx) usdxClaims := k.GetAllUSDXMintingClaims(ctx)
usdxRewardState := getUSDXMintingGenesisRewardState(ctx, k) usdxRewardState := getUSDXMintingGenesisRewardState(ctx, k)
@ -178,6 +191,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
usdxRewardState, hardSupplyRewardState, hardBorrowRewardState, delegatorRewardState, swapRewardState, savingsRewardState, earnRewardState, usdxRewardState, hardSupplyRewardState, hardBorrowRewardState, delegatorRewardState, swapRewardState, savingsRewardState, earnRewardState,
// Claims // Claims
claims, usdxClaims, hardClaims, delegatorClaims, swapClaims, savingsClaims, earnClaims, claims, usdxClaims, hardClaims, delegatorClaims, swapClaims, savingsClaims, earnClaims,
accrualTimes,
) )
} }

View File

@ -109,6 +109,7 @@ func (suite *GenesisTestSuite) SetupTest() {
types.DefaultSwapClaims, types.DefaultSwapClaims,
types.DefaultSavingsClaims, types.DefaultSavingsClaims,
types.DefaultEarnClaims, types.DefaultEarnClaims,
types.DefaultAccrualTimes,
) )
cdc := suite.app.AppCodec() cdc := suite.app.AppCodec()
@ -282,6 +283,9 @@ func (suite *GenesisTestSuite) TestExportedGenesisMatchesImported() {
types.MultiRewardIndexes{{CollateralType: "usdx", RewardIndexes: types.RewardIndexes{{CollateralType: "earn", RewardFactor: d("0.0")}}}}, types.MultiRewardIndexes{{CollateralType: "usdx", RewardIndexes: types.RewardIndexes{{CollateralType: "earn", RewardFactor: d("0.0")}}}},
), ),
}, },
types.AccrualTimes{
types.NewAccrualTime(types.CLAIM_TYPE_USDX_MINTING, "usdx", genesisTime.Add(-2*time.Hour)),
},
) )
tApp := app.NewTestApp() tApp := app.NewTestApp()

View File

@ -922,9 +922,9 @@ func (k Keeper) DeleteClaim(
store.Delete(owner) store.Delete(owner)
} }
// IterateClaims iterates over all claim objects in the store of a given // IterateClaimsByClaimType iterates over all claim objects in the store of a given
// claimType and preforms a callback function // claimType and preforms a callback function
func (k Keeper) IterateClaims( func (k Keeper) IterateClaimsByClaimType(
ctx sdk.Context, ctx sdk.Context,
claimType types.ClaimType, claimType types.ClaimType,
cb func(c types.Claim) (stop bool), cb func(c types.Claim) (stop bool),
@ -946,7 +946,7 @@ func (k Keeper) GetClaims(
claimType types.ClaimType, claimType types.ClaimType,
) types.Claims { ) types.Claims {
var cs types.Claims var cs types.Claims
k.IterateClaims(ctx, claimType, func(c types.Claim) (stop bool) { k.IterateClaimsByClaimType(ctx, claimType, func(c types.Claim) (stop bool) {
cs = append(cs, c) cs = append(cs, c)
return false return false
}) })
@ -954,9 +954,9 @@ func (k Keeper) GetClaims(
return cs return cs
} }
// IterateAllClaims iterates over all claim objects of any claimType in the // IterateClaims iterates over all claim objects of any claimType in the
// store and preforms a callback function // store and preforms a callback function
func (k Keeper) IterateAllClaims( func (k Keeper) IterateClaims(
ctx sdk.Context, ctx sdk.Context,
cb func(c types.Claim) (stop bool), cb func(c types.Claim) (stop bool),
) { ) {
@ -974,10 +974,96 @@ func (k Keeper) IterateAllClaims(
// GetAllClaims returns all Claim objects in the store of any claimType // GetAllClaims returns all Claim objects in the store of any claimType
func (k Keeper) GetAllClaims(ctx sdk.Context) types.Claims { func (k Keeper) GetAllClaims(ctx sdk.Context) types.Claims {
var cs types.Claims var cs types.Claims
k.IterateAllClaims(ctx, func(c types.Claim) (stop bool) { k.IterateClaims(ctx, func(c types.Claim) (stop bool) {
cs = append(cs, c) cs = append(cs, c)
return false return false
}) })
return cs return cs
} }
// GetRewardAccrualTime fetches the last time rewards were accrued for the
// specified ClaimType and sourceID.
func (k Keeper) GetRewardAccrualTime(
ctx sdk.Context,
claimType types.ClaimType,
sourceID string,
) (time.Time, bool) {
store := prefix.NewStore(ctx.KVStore(k.key), types.GetPreviousRewardAccrualTimeKeyPrefix(claimType))
b := store.Get(types.GetKeyFromSourceID(sourceID))
if b == nil {
return time.Time{}, false
}
var accrualTime types.AccrualTime
k.cdc.MustUnmarshal(b, &accrualTime)
return accrualTime.PreviousAccumulationTime, true
}
// SetRewardAccrualTime stores the last time rewards were accrued for the
// specified ClaimType and sourceID.
func (k Keeper) SetRewardAccrualTime(
ctx sdk.Context,
claimType types.ClaimType,
sourceID string,
blockTime time.Time,
) {
store := prefix.NewStore(ctx.KVStore(k.key), types.GetPreviousRewardAccrualTimeKeyPrefix(claimType))
at := types.NewAccrualTime(claimType, sourceID, blockTime)
bz := k.cdc.MustMarshal(&at)
store.Set(types.GetKeyFromSourceID(sourceID), bz)
}
// IterateRewardAccrualTimesByClaimType iterates over all reward accrual times of a given
// claimType and performs a callback function.
func (k Keeper) IterateRewardAccrualTimesByClaimType(
ctx sdk.Context,
claimType types.ClaimType,
cb func(string, time.Time) (stop bool),
) {
store := prefix.NewStore(ctx.KVStore(k.key), types.GetPreviousRewardAccrualTimeKeyPrefix(claimType))
iterator := sdk.KVStorePrefixIterator(store, []byte{})
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
var accrualTime types.AccrualTime
k.cdc.MustUnmarshal(iterator.Value(), &accrualTime)
if cb(accrualTime.CollateralType, accrualTime.PreviousAccumulationTime) {
break
}
}
}
// IterateRewardAccrualTimes iterates over all reward accrual times of any
// claimType and performs a callback function.
func (k Keeper) IterateRewardAccrualTimes(
ctx sdk.Context,
cb func(types.AccrualTime) (stop bool),
) {
store := prefix.NewStore(ctx.KVStore(k.key), types.PreviousRewardAccrualTimeKeyPrefix)
iterator := sdk.KVStorePrefixIterator(store, []byte{})
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
var accrualTime types.AccrualTime
k.cdc.MustUnmarshal(iterator.Value(), &accrualTime)
if cb(accrualTime) {
break
}
}
}
// GetAllRewardAccrualTimes returns all reward accrual times of any claimType.
func (k Keeper) GetAllRewardAccrualTimes(ctx sdk.Context) types.AccrualTimes {
var ats types.AccrualTimes
k.IterateRewardAccrualTimes(
ctx,
func(accrualTime types.AccrualTime) bool {
ats = append(ats, accrualTime)
return false
},
)
return ats
}

View File

@ -1,6 +1,8 @@
package keeper_test package keeper_test
import ( import (
"time"
"github.com/kava-labs/kava/x/incentive/types" "github.com/kava-labs/kava/x/incentive/types"
) )
@ -85,3 +87,112 @@ func (suite *KeeperTestSuite) TestIterateClaims() {
suite.Require().Len(allClaims, len(claims)) suite.Require().Len(allClaims, len(claims))
suite.Require().ElementsMatch(allClaims, claims, "GetAllClaims() should return claims of all types") suite.Require().ElementsMatch(allClaims, claims, "GetAllClaims() should return claims of all types")
} }
func (suite *KeeperTestSuite) TestGetSetRewardAccrualTimes() {
testCases := []struct {
name string
subKey string
accrualTime time.Time
panics bool
}{
{
name: "normal time can be written and read",
subKey: "btc/usdx",
accrualTime: time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC),
},
{
name: "zero time can be written and read",
subKey: "btc/usdx",
accrualTime: time.Time{},
},
}
for _, tc := range testCases {
suite.Run(tc.name, func() {
suite.SetupApp()
_, found := suite.keeper.GetRewardAccrualTime(suite.ctx, types.CLAIM_TYPE_USDX_MINTING, tc.subKey)
suite.False(found)
setFunc := func() {
suite.keeper.SetRewardAccrualTime(suite.ctx, types.CLAIM_TYPE_USDX_MINTING, tc.subKey, tc.accrualTime)
}
if tc.panics {
suite.Panics(setFunc)
return
} else {
suite.NotPanics(setFunc)
}
for _, claimTypeValue := range types.ClaimType_value {
claimType := types.ClaimType(claimTypeValue)
if claimType == types.CLAIM_TYPE_USDX_MINTING {
continue
}
_, found := suite.keeper.GetRewardAccrualTime(suite.ctx, claimType, tc.subKey)
suite.False(found, "reward accrual time for claim type %s should not exist", claimType)
}
storedTime, found := suite.keeper.GetRewardAccrualTime(suite.ctx, types.CLAIM_TYPE_USDX_MINTING, tc.subKey)
suite.True(found)
suite.Equal(tc.accrualTime, storedTime)
})
}
}
func (suite *KeeperTestSuite) TestIterateRewardAccrualTimes() {
suite.SetupApp()
expectedAccrualTimes := nonEmptyAccrualTimes
for _, at := range expectedAccrualTimes {
suite.keeper.SetRewardAccrualTime(suite.ctx, types.CLAIM_TYPE_USDX_MINTING, at.denom, at.time)
}
var actualAccrualTimes []accrualtime
suite.keeper.IterateRewardAccrualTimesByClaimType(suite.ctx, types.CLAIM_TYPE_USDX_MINTING, func(denom string, accrualTime time.Time) bool {
actualAccrualTimes = append(actualAccrualTimes, accrualtime{denom: denom, time: accrualTime})
return false
})
suite.ElementsMatch(expectedAccrualTimes, actualAccrualTimes)
}
func (suite *KeeperTestSuite) TestIterateAllRewardAccrualTimes() {
suite.SetupApp()
var expectedAccrualTimes types.AccrualTimes
for _, claimTypeValue := range types.ClaimType_value {
claimType := types.ClaimType(claimTypeValue)
// Skip invalid claim type
if claimType.Validate() != nil {
continue
}
for _, at := range nonEmptyAccrualTimes {
suite.keeper.SetRewardAccrualTime(suite.ctx, claimType, at.denom, at.time)
expectedAccrualTimes = append(expectedAccrualTimes, types.NewAccrualTime(
claimType,
at.denom,
at.time,
))
}
}
var actualAccrualTimes types.AccrualTimes
suite.keeper.IterateRewardAccrualTimes(
suite.ctx,
func(accrualTime types.AccrualTime) bool {
actualAccrualTimes = append(actualAccrualTimes, accrualTime)
return false
},
)
suite.ElementsMatch(expectedAccrualTimes, actualAccrualTimes)
}

View File

@ -6,7 +6,6 @@ import (
) )
var ( var (
DefaultClaims = Claims{}
DefaultUSDXClaims = USDXMintingClaims{} DefaultUSDXClaims = USDXMintingClaims{}
DefaultHardClaims = HardLiquidityProviderClaims{} DefaultHardClaims = HardLiquidityProviderClaims{}
DefaultDelegatorClaims = DelegatorClaims{} DefaultDelegatorClaims = DelegatorClaims{}
@ -17,6 +16,10 @@ var (
MultiRewardIndexes{}, MultiRewardIndexes{},
) )
DefaultEarnClaims = EarnClaims{} DefaultEarnClaims = EarnClaims{}
// New fields
DefaultClaims = Claims{}
DefaultAccrualTimes = AccrualTimes{}
) )
// NewGenesisState returns a new genesis state // NewGenesisState returns a new genesis state
@ -26,6 +29,7 @@ func NewGenesisState(
c Claims, c Claims,
uc USDXMintingClaims, hc HardLiquidityProviderClaims, dc DelegatorClaims, sc SwapClaims, savingsc SavingsClaims, uc USDXMintingClaims, hc HardLiquidityProviderClaims, dc DelegatorClaims, sc SwapClaims, savingsc SavingsClaims,
earnc EarnClaims, earnc EarnClaims,
accrualTimes AccrualTimes,
) GenesisState { ) GenesisState {
return GenesisState{ return GenesisState{
Params: params, Params: params,
@ -38,14 +42,17 @@ func NewGenesisState(
SavingsRewardState: savingsState, SavingsRewardState: savingsState,
EarnRewardState: earnState, EarnRewardState: earnState,
// Claims of all types
Claims: c,
USDXMintingClaims: uc, USDXMintingClaims: uc,
HardLiquidityProviderClaims: hc, HardLiquidityProviderClaims: hc,
DelegatorClaims: dc, DelegatorClaims: dc,
SwapClaims: sc, SwapClaims: sc,
SavingsClaims: savingsc, SavingsClaims: savingsc,
EarnClaims: earnc, EarnClaims: earnc,
// New fields
// Claims of all types
Claims: c,
AccrualTimes: accrualTimes,
} }
} }
@ -67,6 +74,7 @@ func DefaultGenesisState() GenesisState {
SwapClaims: DefaultSwapClaims, SwapClaims: DefaultSwapClaims,
SavingsClaims: DefaultSavingsClaims, SavingsClaims: DefaultSavingsClaims,
EarnClaims: DefaultEarnClaims, EarnClaims: DefaultEarnClaims,
AccrualTimes: DefaultAccrualTimes,
} }
} }
@ -99,10 +107,6 @@ func (gs GenesisState) Validate() error {
return err return err
} }
if err := gs.Claims.Validate(); err != nil {
return err
}
if err := gs.USDXMintingClaims.Validate(); err != nil { if err := gs.USDXMintingClaims.Validate(); err != nil {
return err return err
} }
@ -120,7 +124,16 @@ func (gs GenesisState) Validate() error {
return err return err
} }
return gs.EarnClaims.Validate() if err := gs.EarnClaims.Validate(); err != nil {
return err
}
// Refactored methods -- these will eventually replace the claim and state methods above
if err := gs.Claims.Validate(); err != nil {
return err
}
return gs.AccrualTimes.Validate()
} }
// NewGenesisRewardState returns a new GenesisRewardState // NewGenesisRewardState returns a new GenesisRewardState
@ -167,3 +180,38 @@ func (gats AccumulationTimes) Validate() error {
} }
return nil return nil
} }
// NewAccrualTime returns a new AccrualTime
func NewAccrualTime(claimType ClaimType, collateralType string, prevTime time.Time) AccrualTime {
return AccrualTime{
ClaimType: claimType,
CollateralType: collateralType,
PreviousAccumulationTime: prevTime,
}
}
// Validate performs validation of AccrualTime
func (at AccrualTime) Validate() error {
if err := at.ClaimType.Validate(); err != nil {
return err
}
if len(at.CollateralType) == 0 {
return fmt.Errorf("collateral type cannot be empty")
}
return nil
}
// AccrualTimes slice of AccrualTime
type AccrualTimes []AccrualTime
// Validate performs validation of AccrualTimes
func (gats AccrualTimes) Validate() error {
for _, gat := range gats {
if err := gat.Validate(); err != nil {
return err
}
}
return nil
}

View File

@ -28,6 +28,8 @@ var _ = time.Kitchen
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// AccumulationTime stores the previous reward distribution time and its corresponding collateral type // AccumulationTime stores the previous reward distribution time and its corresponding collateral type
//
// Deprecated: Do not use.
type AccumulationTime struct { type AccumulationTime struct {
CollateralType string `protobuf:"bytes,1,opt,name=collateral_type,json=collateralType,proto3" json:"collateral_type,omitempty"` CollateralType string `protobuf:"bytes,1,opt,name=collateral_type,json=collateralType,proto3" json:"collateral_type,omitempty"`
PreviousAccumulationTime time.Time `protobuf:"bytes,2,opt,name=previous_accumulation_time,json=previousAccumulationTime,proto3,stdtime" json:"previous_accumulation_time"` PreviousAccumulationTime time.Time `protobuf:"bytes,2,opt,name=previous_accumulation_time,json=previousAccumulationTime,proto3,stdtime" json:"previous_accumulation_time"`
@ -66,6 +68,48 @@ func (m *AccumulationTime) XXX_DiscardUnknown() {
var xxx_messageInfo_AccumulationTime proto.InternalMessageInfo var xxx_messageInfo_AccumulationTime proto.InternalMessageInfo
// AccrualTime stores the previous reward distribution time and its
// corresponding collateral type and claim type. This is the new version of
// AccumulationTime that is used for the new claim types.
type AccrualTime struct {
ClaimType ClaimType `protobuf:"varint,1,opt,name=claim_type,json=claimType,proto3,enum=kava.incentive.v1beta1.ClaimType" json:"claim_type,omitempty"`
CollateralType string `protobuf:"bytes,2,opt,name=collateral_type,json=collateralType,proto3" json:"collateral_type,omitempty"`
PreviousAccumulationTime time.Time `protobuf:"bytes,3,opt,name=previous_accumulation_time,json=previousAccumulationTime,proto3,stdtime" json:"previous_accumulation_time"`
}
func (m *AccrualTime) Reset() { *m = AccrualTime{} }
func (m *AccrualTime) String() string { return proto.CompactTextString(m) }
func (*AccrualTime) ProtoMessage() {}
func (*AccrualTime) Descriptor() ([]byte, []int) {
return fileDescriptor_8b76737885d05afd, []int{1}
}
func (m *AccrualTime) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *AccrualTime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_AccrualTime.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *AccrualTime) XXX_Merge(src proto.Message) {
xxx_messageInfo_AccrualTime.Merge(m, src)
}
func (m *AccrualTime) XXX_Size() int {
return m.Size()
}
func (m *AccrualTime) XXX_DiscardUnknown() {
xxx_messageInfo_AccrualTime.DiscardUnknown(m)
}
var xxx_messageInfo_AccrualTime proto.InternalMessageInfo
// GenesisRewardState groups together the global state for a particular reward so it can be exported in genesis. // GenesisRewardState groups together the global state for a particular reward so it can be exported in genesis.
type GenesisRewardState struct { type GenesisRewardState struct {
AccumulationTimes AccumulationTimes `protobuf:"bytes,1,rep,name=accumulation_times,json=accumulationTimes,proto3,castrepeated=AccumulationTimes" json:"accumulation_times"` AccumulationTimes AccumulationTimes `protobuf:"bytes,1,rep,name=accumulation_times,json=accumulationTimes,proto3,castrepeated=AccumulationTimes" json:"accumulation_times"`
@ -76,7 +120,7 @@ func (m *GenesisRewardState) Reset() { *m = GenesisRewardState{} }
func (m *GenesisRewardState) String() string { return proto.CompactTextString(m) } func (m *GenesisRewardState) String() string { return proto.CompactTextString(m) }
func (*GenesisRewardState) ProtoMessage() {} func (*GenesisRewardState) ProtoMessage() {}
func (*GenesisRewardState) Descriptor() ([]byte, []int) { func (*GenesisRewardState) Descriptor() ([]byte, []int) {
return fileDescriptor_8b76737885d05afd, []int{1} return fileDescriptor_8b76737885d05afd, []int{2}
} }
func (m *GenesisRewardState) XXX_Unmarshal(b []byte) error { func (m *GenesisRewardState) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -122,13 +166,14 @@ type GenesisState struct {
EarnRewardState GenesisRewardState `protobuf:"bytes,13,opt,name=earn_reward_state,json=earnRewardState,proto3" json:"earn_reward_state"` EarnRewardState GenesisRewardState `protobuf:"bytes,13,opt,name=earn_reward_state,json=earnRewardState,proto3" json:"earn_reward_state"`
EarnClaims EarnClaims `protobuf:"bytes,14,rep,name=earn_claims,json=earnClaims,proto3,castrepeated=EarnClaims" json:"earn_claims"` EarnClaims EarnClaims `protobuf:"bytes,14,rep,name=earn_claims,json=earnClaims,proto3,castrepeated=EarnClaims" json:"earn_claims"`
Claims Claims `protobuf:"bytes,15,rep,name=claims,proto3,castrepeated=Claims" json:"claims"` Claims Claims `protobuf:"bytes,15,rep,name=claims,proto3,castrepeated=Claims" json:"claims"`
AccrualTimes AccrualTimes `protobuf:"bytes,16,rep,name=accrual_times,json=accrualTimes,proto3,castrepeated=AccrualTimes" json:"accrual_times"`
} }
func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) Reset() { *m = GenesisState{} }
func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (m *GenesisState) String() string { return proto.CompactTextString(m) }
func (*GenesisState) ProtoMessage() {} func (*GenesisState) ProtoMessage() {}
func (*GenesisState) Descriptor() ([]byte, []int) { func (*GenesisState) Descriptor() ([]byte, []int) {
return fileDescriptor_8b76737885d05afd, []int{2} return fileDescriptor_8b76737885d05afd, []int{3}
} }
func (m *GenesisState) XXX_Unmarshal(b []byte) error { func (m *GenesisState) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -159,6 +204,7 @@ var xxx_messageInfo_GenesisState proto.InternalMessageInfo
func init() { func init() {
proto.RegisterType((*AccumulationTime)(nil), "kava.incentive.v1beta1.AccumulationTime") proto.RegisterType((*AccumulationTime)(nil), "kava.incentive.v1beta1.AccumulationTime")
proto.RegisterType((*AccrualTime)(nil), "kava.incentive.v1beta1.AccrualTime")
proto.RegisterType((*GenesisRewardState)(nil), "kava.incentive.v1beta1.GenesisRewardState") proto.RegisterType((*GenesisRewardState)(nil), "kava.incentive.v1beta1.GenesisRewardState")
proto.RegisterType((*GenesisState)(nil), "kava.incentive.v1beta1.GenesisState") proto.RegisterType((*GenesisState)(nil), "kava.incentive.v1beta1.GenesisState")
} }
@ -168,58 +214,63 @@ func init() {
} }
var fileDescriptor_8b76737885d05afd = []byte{ var fileDescriptor_8b76737885d05afd = []byte{
// 803 bytes of a gzipped FileDescriptorProto // 884 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x4f, 0x3b, 0x45, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x8f, 0xdb, 0x44,
0x18, 0xee, 0x02, 0x56, 0x98, 0x42, 0x4b, 0xc7, 0x02, 0xb5, 0xc4, 0x2d, 0x02, 0xd1, 0x46, 0xe3, 0x14, 0x8e, 0xb3, 0x25, 0x74, 0x27, 0xd9, 0x64, 0x33, 0xa4, 0xad, 0x49, 0x85, 0xb3, 0xec, 0x56,
0x6e, 0xa8, 0x57, 0x2f, 0xae, 0x10, 0x25, 0x91, 0x84, 0x6c, 0x91, 0x18, 0x63, 0xd2, 0xcc, 0x76, 0xb0, 0x02, 0x61, 0xab, 0xe1, 0x86, 0x38, 0x50, 0xd3, 0x0a, 0x2a, 0x51, 0xa9, 0xf2, 0x2e, 0x15,
0x87, 0x65, 0x74, 0xff, 0xb9, 0xb3, 0xdb, 0xd2, 0x9b, 0x47, 0x0f, 0x1e, 0xf8, 0x00, 0x26, 0xde, 0x42, 0x88, 0x68, 0x6c, 0x4f, 0xbd, 0x03, 0xfe, 0xc5, 0x8c, 0x9d, 0xdd, 0xdc, 0x38, 0x72, 0xec,
0xfd, 0x24, 0x1c, 0x39, 0x7a, 0x02, 0x2d, 0x5f, 0xc4, 0xcc, 0x9f, 0x2d, 0xbb, 0x2d, 0x8b, 0xf9, 0x1f, 0xc0, 0x8d, 0x1b, 0x7f, 0xc9, 0x1e, 0x7b, 0xe4, 0x80, 0xba, 0x90, 0xbd, 0xf2, 0x47, 0xa0,
0xf5, 0x77, 0x9b, 0x7d, 0xe7, 0x79, 0x9f, 0xe7, 0x79, 0xe7, 0x7d, 0xa7, 0x53, 0x70, 0xf8, 0x33, 0xf9, 0xe1, 0xac, 0x9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xe4, 0x32, 0xb1, 0xb2, 0xce, 0x4a, 0x7f, 0x5c, 0xfc, 0xaf, 0x81,
0xb9, 0x2d, 0x71, 0xe9, 0x7f, 0xf8, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0d, 0xa4, 0x09, 0x98,
0x09, 0x0a, 0x00, 0x00,
} }
func (m *AccumulationTime) Marshal() (dAtA []byte, err error) { func (m *AccumulationTime) Marshal() (dAtA []byte, err error) {
@ -260,6 +311,49 @@ func (m *AccumulationTime) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil return len(dAtA) - i, nil
} }
func (m *AccrualTime) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *AccrualTime) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *AccrualTime) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.PreviousAccumulationTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.PreviousAccumulationTime):])
if err2 != nil {
return 0, err2
}
i -= n2
i = encodeVarintGenesis(dAtA, i, uint64(n2))
i--
dAtA[i] = 0x1a
if len(m.CollateralType) > 0 {
i -= len(m.CollateralType)
copy(dAtA[i:], m.CollateralType)
i = encodeVarintGenesis(dAtA, i, uint64(len(m.CollateralType)))
i--
dAtA[i] = 0x12
}
if m.ClaimType != 0 {
i = encodeVarintGenesis(dAtA, i, uint64(m.ClaimType))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func (m *GenesisRewardState) Marshal() (dAtA []byte, err error) { func (m *GenesisRewardState) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
dAtA = make([]byte, size) dAtA = make([]byte, size)
@ -331,6 +425,22 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i _ = i
var l int var l int
_ = l _ = l
if len(m.AccrualTimes) > 0 {
for iNdEx := len(m.AccrualTimes) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.AccrualTimes[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1
i--
dAtA[i] = 0x82
}
}
if len(m.Claims) > 0 { if len(m.Claims) > 0 {
for iNdEx := len(m.Claims) - 1; iNdEx >= 0; iNdEx-- { for iNdEx := len(m.Claims) - 1; iNdEx >= 0; iNdEx-- {
{ {
@ -538,6 +648,24 @@ func (m *AccumulationTime) Size() (n int) {
return n return n
} }
func (m *AccrualTime) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.ClaimType != 0 {
n += 1 + sovGenesis(uint64(m.ClaimType))
}
l = len(m.CollateralType)
if l > 0 {
n += 1 + l + sovGenesis(uint64(l))
}
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.PreviousAccumulationTime)
n += 1 + l + sovGenesis(uint64(l))
return n
}
func (m *GenesisRewardState) Size() (n int) { func (m *GenesisRewardState) Size() (n int) {
if m == nil { if m == nil {
return 0 return 0
@ -623,6 +751,12 @@ func (m *GenesisState) Size() (n int) {
n += 1 + l + sovGenesis(uint64(l)) n += 1 + l + sovGenesis(uint64(l))
} }
} }
if len(m.AccrualTimes) > 0 {
for _, e := range m.AccrualTimes {
l = e.Size()
n += 2 + l + sovGenesis(uint64(l))
}
}
return n return n
} }
@ -747,6 +881,140 @@ func (m *AccumulationTime) Unmarshal(dAtA []byte) error {
} }
return nil return nil
} }
func (m *AccrualTime) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: AccrualTime: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: AccrualTime: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ClaimType", wireType)
}
m.ClaimType = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ClaimType |= ClaimType(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field CollateralType", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.CollateralType = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field PreviousAccumulationTime", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.PreviousAccumulationTime, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *GenesisRewardState) Unmarshal(dAtA []byte) error { func (m *GenesisRewardState) Unmarshal(dAtA []byte) error {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0
@ -1396,6 +1664,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
return err return err
} }
iNdEx = postIndex iNdEx = postIndex
case 16:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AccrualTimes", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.AccrualTimes = append(m.AccrualTimes, AccrualTime{})
if err := m.AccrualTimes[len(m.AccrualTimes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default: default:
iNdEx = preIndex iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:]) skippy, err := skipGenesis(dAtA[iNdEx:])

View File

@ -1,7 +1,6 @@
package types package types
import ( import (
"strings"
"testing" "testing"
"time" "time"
@ -135,6 +134,20 @@ func TestGenesisState_Validate(t *testing.T) {
contains: "claim owner cannot be empty", contains: "claim owner cannot be empty",
}, },
}, },
{
name: "invalid accrual time",
genesis: GenesisState{
Params: DefaultParams(),
Claims: DefaultClaims,
AccrualTimes: AccrualTimes{
NewAccrualTime(CLAIM_TYPE_USDX_MINTING, "", time.Date(2020, 10, 15, 14, 0, 0, 0, time.UTC)),
},
},
errArgs: errArgs{
expectPass: false,
contains: "collateral type cannot be empty",
},
},
} }
for _, tc := range testCases { for _, tc := range testCases {
@ -144,7 +157,7 @@ func TestGenesisState_Validate(t *testing.T) {
require.NoError(t, err, tc.name) require.NoError(t, err, tc.name)
} else { } else {
require.Error(t, err, tc.name) require.Error(t, err, tc.name)
require.True(t, strings.Contains(err.Error(), tc.errArgs.contains)) require.Contains(t, err.Error(), tc.errArgs.contains)
} }
}) })
} }
@ -189,4 +202,76 @@ func TestGenesisAccumulationTimes_Validate(t *testing.T) {
} }
} }
func TestAccrualTimes_Validate(t *testing.T) {
testCases := []struct {
name string
gats AccrualTimes
wantErr bool
}{
{
name: "normal",
gats: AccrualTimes{
{
ClaimType: CLAIM_TYPE_USDX_MINTING,
CollateralType: "btcb",
PreviousAccumulationTime: normalAccumulationtime,
},
{
ClaimType: CLAIM_TYPE_USDX_MINTING,
CollateralType: "bnb",
PreviousAccumulationTime: normalAccumulationtime,
},
},
wantErr: false,
},
{
name: "empty",
gats: nil,
wantErr: false,
},
{
name: "empty collateral type",
gats: AccrualTimes{
{
ClaimType: CLAIM_TYPE_USDX_MINTING,
PreviousAccumulationTime: normalAccumulationtime,
},
},
wantErr: true,
},
{
name: "invalid claim type",
gats: AccrualTimes{
{
ClaimType: 10000000,
CollateralType: "btcb",
PreviousAccumulationTime: normalAccumulationtime,
},
},
wantErr: true,
},
{
name: "unspecified claim type",
gats: AccrualTimes{
{
ClaimType: CLAIM_TYPE_UNSPECIFIED,
CollateralType: "btcb",
PreviousAccumulationTime: normalAccumulationtime,
},
},
wantErr: true,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := tc.gats.Validate()
if tc.wantErr {
require.NotNil(t, err)
} else {
require.Nil(t, err)
}
})
}
}
var normalAccumulationtime = time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC) var normalAccumulationtime = time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)

View File

@ -1,6 +1,8 @@
package types package types
import "encoding/binary" import (
"encoding/binary"
)
const ( const (
// ModuleName The name that will be used throughout the module // ModuleName The name that will be used throughout the module
@ -81,3 +83,8 @@ func GetRewardIndexesKeyPrefix(claimType ClaimType) []byte {
func GetPreviousRewardAccrualTimeKeyPrefix(claimType ClaimType) []byte { func GetPreviousRewardAccrualTimeKeyPrefix(claimType ClaimType) []byte {
return getKeyPrefix(PreviousRewardAccrualTimeKeyPrefix, claimType) return getKeyPrefix(PreviousRewardAccrualTimeKeyPrefix, claimType)
} }
// GetKeyFromSourceID returns the store key for the given source ID.
func GetKeyFromSourceID(sourceID string) []byte {
return []byte(sourceID)
}