diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index bc3374f1..e2440f44 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -329,6 +329,7 @@ - [RewardPeriod](#kava.incentive.v1beta1.RewardPeriod) - [kava/incentive/v1beta1/genesis.proto](#kava/incentive/v1beta1/genesis.proto) + - [AccrualTime](#kava.incentive.v1beta1.AccrualTime) - [AccumulationTime](#kava.incentive.v1beta1.AccumulationTime) - [GenesisRewardState](#kava.incentive.v1beta1.GenesisRewardState) - [GenesisState](#kava.incentive.v1beta1.GenesisState) @@ -4778,6 +4779,25 @@ RewardPeriod stores the state of an ongoing reward + + +### 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) | | | + + + + + + ### AccumulationTime @@ -4833,6 +4853,7 @@ GenesisState is the state that must be provided at genesis. | `earn_reward_state` | [GenesisRewardState](#kava.incentive.v1beta1.GenesisRewardState) | | | | `earn_claims` | [EarnClaim](#kava.incentive.v1beta1.EarnClaim) | repeated | | | `claims` | [Claim](#kava.incentive.v1beta1.Claim) | repeated | | +| `accrual_times` | [AccrualTime](#kava.incentive.v1beta1.AccrualTime) | repeated | | diff --git a/proto/kava/incentive/v1beta1/genesis.proto b/proto/kava/incentive/v1beta1/genesis.proto index fabc5354..35200e96 100644 --- a/proto/kava/incentive/v1beta1/genesis.proto +++ b/proto/kava/incentive/v1beta1/genesis.proto @@ -15,11 +15,22 @@ option (gogoproto.goproto_getters_all) = false; // AccumulationTime stores the previous reward distribution time and its corresponding collateral type message AccumulationTime { + option deprecated = true; + string collateral_type = 1; 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. message GenesisRewardState { repeated AccumulationTime accumulation_times = 1 @@ -66,4 +77,6 @@ message GenesisState { repeated EarnClaim earn_claims = 14 [(gogoproto.castrepeated) = "EarnClaims", (gogoproto.nullable) = false]; repeated Claim claims = 15 [(gogoproto.castrepeated) = "Claims", (gogoproto.nullable) = false]; + + repeated AccrualTime accrual_times = 16 [(gogoproto.castrepeated) = "AccrualTimes", (gogoproto.nullable) = false]; } diff --git a/x/incentive/genesis.go b/x/incentive/genesis.go index 26949197..13bc7729 100644 --- a/x/incentive/genesis.go +++ b/x/incentive/genesis.go @@ -49,6 +49,18 @@ func InitGenesis( 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 for _, claim := range gs.USDXMintingClaims { k.SetUSDXMintingClaim(ctx, claim) @@ -152,6 +164,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState { params := k.GetParams(ctx) claims := k.GetAllClaims(ctx) + accrualTimes := k.GetAllRewardAccrualTimes(ctx) usdxClaims := k.GetAllUSDXMintingClaims(ctx) 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, // Claims claims, usdxClaims, hardClaims, delegatorClaims, swapClaims, savingsClaims, earnClaims, + accrualTimes, ) } diff --git a/x/incentive/genesis_test.go b/x/incentive/genesis_test.go index 92df67d7..ba097b40 100644 --- a/x/incentive/genesis_test.go +++ b/x/incentive/genesis_test.go @@ -109,6 +109,7 @@ func (suite *GenesisTestSuite) SetupTest() { types.DefaultSwapClaims, types.DefaultSavingsClaims, types.DefaultEarnClaims, + types.DefaultAccrualTimes, ) 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.AccrualTimes{ + types.NewAccrualTime(types.CLAIM_TYPE_USDX_MINTING, "usdx", genesisTime.Add(-2*time.Hour)), + }, ) tApp := app.NewTestApp() diff --git a/x/incentive/keeper/keeper.go b/x/incentive/keeper/keeper.go index a6d1c60d..ca98f50e 100644 --- a/x/incentive/keeper/keeper.go +++ b/x/incentive/keeper/keeper.go @@ -922,9 +922,9 @@ func (k Keeper) DeleteClaim( 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 -func (k Keeper) IterateClaims( +func (k Keeper) IterateClaimsByClaimType( ctx sdk.Context, claimType types.ClaimType, cb func(c types.Claim) (stop bool), @@ -946,7 +946,7 @@ func (k Keeper) GetClaims( claimType types.ClaimType, ) 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) return false }) @@ -954,9 +954,9 @@ func (k Keeper) GetClaims( 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 -func (k Keeper) IterateAllClaims( +func (k Keeper) IterateClaims( ctx sdk.Context, 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 func (k Keeper) GetAllClaims(ctx sdk.Context) 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) return false }) 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 +} diff --git a/x/incentive/keeper/keeper_state_test.go b/x/incentive/keeper/keeper_state_test.go index 4a92713a..9a2a6f93 100644 --- a/x/incentive/keeper/keeper_state_test.go +++ b/x/incentive/keeper/keeper_state_test.go @@ -1,6 +1,8 @@ package keeper_test import ( + "time" + "github.com/kava-labs/kava/x/incentive/types" ) @@ -85,3 +87,112 @@ func (suite *KeeperTestSuite) TestIterateClaims() { suite.Require().Len(allClaims, len(claims)) 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) +} diff --git a/x/incentive/types/genesis.go b/x/incentive/types/genesis.go index 699d5ea0..c977df11 100644 --- a/x/incentive/types/genesis.go +++ b/x/incentive/types/genesis.go @@ -6,7 +6,6 @@ import ( ) var ( - DefaultClaims = Claims{} DefaultUSDXClaims = USDXMintingClaims{} DefaultHardClaims = HardLiquidityProviderClaims{} DefaultDelegatorClaims = DelegatorClaims{} @@ -17,6 +16,10 @@ var ( MultiRewardIndexes{}, ) DefaultEarnClaims = EarnClaims{} + + // New fields + DefaultClaims = Claims{} + DefaultAccrualTimes = AccrualTimes{} ) // NewGenesisState returns a new genesis state @@ -26,6 +29,7 @@ func NewGenesisState( c Claims, uc USDXMintingClaims, hc HardLiquidityProviderClaims, dc DelegatorClaims, sc SwapClaims, savingsc SavingsClaims, earnc EarnClaims, + accrualTimes AccrualTimes, ) GenesisState { return GenesisState{ Params: params, @@ -38,14 +42,17 @@ func NewGenesisState( SavingsRewardState: savingsState, EarnRewardState: earnState, - // Claims of all types - Claims: c, USDXMintingClaims: uc, HardLiquidityProviderClaims: hc, DelegatorClaims: dc, SwapClaims: sc, SavingsClaims: savingsc, EarnClaims: earnc, + + // New fields + // Claims of all types + Claims: c, + AccrualTimes: accrualTimes, } } @@ -67,6 +74,7 @@ func DefaultGenesisState() GenesisState { SwapClaims: DefaultSwapClaims, SavingsClaims: DefaultSavingsClaims, EarnClaims: DefaultEarnClaims, + AccrualTimes: DefaultAccrualTimes, } } @@ -99,10 +107,6 @@ func (gs GenesisState) Validate() error { return err } - if err := gs.Claims.Validate(); err != nil { - return err - } - if err := gs.USDXMintingClaims.Validate(); err != nil { return err } @@ -120,7 +124,16 @@ func (gs GenesisState) Validate() error { 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 @@ -167,3 +180,38 @@ func (gats AccumulationTimes) Validate() error { } 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 +} diff --git a/x/incentive/types/genesis.pb.go b/x/incentive/types/genesis.pb.go index 2ffcd9f6..108d092d 100644 --- a/x/incentive/types/genesis.pb.go +++ b/x/incentive/types/genesis.pb.go @@ -28,6 +28,8 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // AccumulationTime stores the previous reward distribution time and its corresponding collateral type +// +// Deprecated: Do not use. type AccumulationTime struct { 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"` @@ -66,6 +68,48 @@ func (m *AccumulationTime) XXX_DiscardUnknown() { 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. type GenesisRewardState struct { 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 (*GenesisRewardState) ProtoMessage() {} func (*GenesisRewardState) Descriptor() ([]byte, []int) { - return fileDescriptor_8b76737885d05afd, []int{1} + return fileDescriptor_8b76737885d05afd, []int{2} } func (m *GenesisRewardState) XXX_Unmarshal(b []byte) error { 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"` 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"` + 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) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_8b76737885d05afd, []int{2} + return fileDescriptor_8b76737885d05afd, []int{3} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -159,6 +204,7 @@ var xxx_messageInfo_GenesisState proto.InternalMessageInfo func init() { 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((*GenesisState)(nil), "kava.incentive.v1beta1.GenesisState") } @@ -168,58 +214,63 @@ func init() { } var fileDescriptor_8b76737885d05afd = []byte{ - // 803 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x4f, 0x3b, 0x45, - 0x18, 0xee, 0x02, 0x56, 0x98, 0x42, 0x4b, 0xc7, 0x02, 0xb5, 0xc4, 0x2d, 0x02, 0xd1, 0x46, 0xe3, - 0x6e, 0xa8, 0x57, 0x2f, 0xae, 0x10, 0x25, 0x91, 0x84, 0x6c, 0x91, 0x18, 0x63, 0xd2, 0xcc, 0x76, - 0x87, 0x65, 0x74, 0xff, 0xb9, 0xb3, 0xdb, 0xd2, 0x9b, 0x47, 0x0f, 0x1e, 0xf8, 0x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00, 0x00, 0xff, 0xff, 0xc0, 0xab, 0xe5, 0xd0, 0xc6, - 0x08, 0x00, 0x00, + // 884 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x8f, 0xdb, 0x44, + 0x14, 0x8e, 0xb3, 0x25, 0x74, 0x27, 0xd9, 0x64, 0x33, 0xa4, 0xad, 0x49, 0x85, 0xb3, 0xec, 0x56, + 0xb0, 0x02, 0x61, 0xab, 0xe1, 0x86, 0x38, 0x50, 0xd3, 0x0a, 0x2a, 0x51, 0xa9, 0xf2, 0x2e, 0x15, + 0x42, 0x88, 0x68, 0x6c, 0x4f, 0xbd, 0x03, 0xfe, 0xc5, 0x8c, 0x9d, 0xdd, 0xdc, 0x38, 0x72, 0xec, + 0x1f, 0xc0, 0x8d, 0x1b, 0x7f, 0xc9, 0x1e, 0x7b, 0xe4, 0x80, 0xba, 0x90, 0xbd, 0xf2, 0x47, 0xa0, + 0xf9, 0xe1, 0xac, 0x9d, 0xac, 0x83, 0x08, 0xdc, 0xc6, 0x6f, 0xbe, 0xf7, 0x7d, 0xdf, 0x9b, 0xf7, + 0xec, 0x31, 0xb8, 0xf7, 0x3d, 0x9a, 0x22, 0x8b, 0xc4, 0x1e, 0x8e, 0x33, 0x32, 0xc5, 0xd6, 0xf4, + 0xbe, 0x8b, 0x33, 0x74, 0xdf, 0x0a, 0x70, 0x8c, 0x19, 0x61, 0x66, 0x4a, 0x93, 0x2c, 0x81, 0xb7, + 0x39, 0xca, 0x5c, 0xa0, 0x4c, 0x85, 0x1a, 0x0e, 0x82, 0x24, 0x48, 0x04, 0xc4, 0xe2, 0x2b, 0x89, + 0x1e, 0x1e, 0xd4, 0x70, 0x7a, 0x21, 0x22, 0x11, 0xfb, 0x07, 0x50, 0x8a, 0x28, 0x5a, 0x80, 0x46, + 0x41, 0x92, 0x04, 0x21, 0xb6, 0xc4, 0x93, 0x9b,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0xb8, 0xa5, 0x2a, 0xd8, + 0x29, 0x47, 0x99, 0xb3, 0xc3, 0xca, 0x8f, 0xfc, 0x9d, 0xc0, 0x88, 0xc6, 0xd5, 0x22, 0x76, 0x36, + 0x7d, 0x27, 0x38, 0x55, 0xb9, 0x82, 0x67, 0xa0, 0x2d, 0xd8, 0x95, 0xfd, 0xee, 0xfa, 0xd3, 0x7f, + 0x84, 0x68, 0xbc, 0x74, 0xfa, 0x8b, 0x10, 0x73, 0x00, 0x5e, 0xac, 0xe1, 0x23, 0xd0, 0x52, 0x94, + 0x3d, 0x41, 0xf9, 0xd6, 0xda, 0x5b, 0xd9, 0xee, 0x2a, 0xba, 0x96, 0xa2, 0x52, 0xc9, 0xf0, 0x5b, + 0xb0, 0x83, 0xe4, 0x7d, 0xaf, 0x6e, 0xbd, 0x5d, 0xc1, 0x76, 0xb0, 0xe6, 0xd6, 0x2b, 0x7e, 0x0e, + 0xec, 0x81, 0xe2, 0xec, 0x94, 0x82, 0xcc, 0xe9, 0xa0, 0xd2, 0x93, 0xfd, 0xf8, 0xfc, 0x4f, 0xa3, + 0x71, 0x3e, 0x37, 0xb4, 0x97, 0x73, 0x43, 0xfb, 0x63, 0x6e, 0x68, 0x2f, 0x2e, 0x8d, 0xc6, 0xcb, + 0x4b, 0xa3, 0xf1, 0xdb, 0xa5, 0xd1, 0xf8, 0xfa, 0xfd, 0x80, 0x64, 0x27, 0xb9, 0x6b, 0x7a, 0x49, + 0x64, 0x71, 0xc1, 0x0f, 0x42, 0xe4, 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) { @@ -260,6 +311,49 @@ func (m *AccumulationTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { 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) { size := m.Size() dAtA = make([]byte, size) @@ -331,6 +425,22 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = 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 { for iNdEx := len(m.Claims) - 1; iNdEx >= 0; iNdEx-- { { @@ -538,6 +648,24 @@ func (m *AccumulationTime) Size() (n int) { 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) { if m == nil { return 0 @@ -623,6 +751,12 @@ func (m *GenesisState) Size() (n int) { 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 } @@ -747,6 +881,140 @@ func (m *AccumulationTime) Unmarshal(dAtA []byte) error { } 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 { l := len(dAtA) iNdEx := 0 @@ -1396,6 +1664,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } 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: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/incentive/types/genesis_test.go b/x/incentive/types/genesis_test.go index 5aaa52f8..dbb6b793 100644 --- a/x/incentive/types/genesis_test.go +++ b/x/incentive/types/genesis_test.go @@ -1,7 +1,6 @@ package types import ( - "strings" "testing" "time" @@ -135,6 +134,20 @@ func TestGenesisState_Validate(t *testing.T) { 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 { @@ -144,7 +157,7 @@ func TestGenesisState_Validate(t *testing.T) { require.NoError(t, err, tc.name) } else { 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) diff --git a/x/incentive/types/keys.go b/x/incentive/types/keys.go index 380cf17e..49f21b3e 100644 --- a/x/incentive/types/keys.go +++ b/x/incentive/types/keys.go @@ -1,6 +1,8 @@ package types -import "encoding/binary" +import ( + "encoding/binary" +) const ( // ModuleName The name that will be used throughout the module @@ -81,3 +83,8 @@ func GetRewardIndexesKeyPrefix(claimType ClaimType) []byte { func GetPreviousRewardAccrualTimeKeyPrefix(claimType ClaimType) []byte { return getKeyPrefix(PreviousRewardAccrualTimeKeyPrefix, claimType) } + +// GetKeyFromSourceID returns the store key for the given source ID. +func GetKeyFromSourceID(sourceID string) []byte { + return []byte(sourceID) +}