diff --git a/app/app.go b/app/app.go index 152b5f8e..cdb236fa 100644 --- a/app/app.go +++ b/app/app.go @@ -518,7 +518,7 @@ func NewApp( app.bankKeeper, app.accountKeeper, app.distrKeeper, - app.ModuleAccountAddrs(), + app.loadBlockedMaccAddrs(), ) app.transferKeeper = ibctransferkeeper.NewKeeper( diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 5df5ca12..24a1933e 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -375,7 +375,10 @@ - [Msg](#kava.issuance.v1beta1.Msg) - [kava/kavadist/v1beta1/params.proto](#kava/kavadist/v1beta1/params.proto) + - [CoreReward](#kava.kavadist.v1beta1.CoreReward) + - [InfrastructureParams](#kava.kavadist.v1beta1.InfrastructureParams) - [Params](#kava.kavadist.v1beta1.Params) + - [PartnerReward](#kava.kavadist.v1beta1.PartnerReward) - [Period](#kava.kavadist.v1beta1.Period) - [kava/kavadist/v1beta1/genesis.proto](#kava/kavadist/v1beta1/genesis.proto) @@ -5325,6 +5328,39 @@ Msg defines the issuance Msg service. + + +### CoreReward + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | | +| `weight` | [string](#string) | | | + + + + + + + + +### InfrastructureParams + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `infrastructure_periods` | [Period](#kava.kavadist.v1beta1.Period) | repeated | | +| `core_rewards` | [CoreReward](#kava.kavadist.v1beta1.CoreReward) | repeated | | +| `partner_rewards` | [PartnerReward](#kava.kavadist.v1beta1.PartnerReward) | repeated | | + + + + + + ### Params @@ -5335,6 +5371,23 @@ Params governance parameters for kavadist module | ----- | ---- | ----- | ----------- | | `active` | [bool](#bool) | | | | `periods` | [Period](#kava.kavadist.v1beta1.Period) | repeated | | +| `infrastructure_params` | [InfrastructureParams](#kava.kavadist.v1beta1.InfrastructureParams) | | | + + + + + + + + +### PartnerReward + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [bytes](#bytes) | | | +| `rewards_per_second` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | diff --git a/proto/kava/kavadist/v1beta1/params.proto b/proto/kava/kavadist/v1beta1/params.proto index 49857007..ddaa9af2 100644 --- a/proto/kava/kavadist/v1beta1/params.proto +++ b/proto/kava/kavadist/v1beta1/params.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package kava.kavadist.v1beta1; import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; import "google/protobuf/timestamp.proto"; option go_package = "github.com/kava-labs/kava/x/kavadist/types"; @@ -13,6 +15,36 @@ option (gogoproto.goproto_getters_all) = false; message Params { bool active = 1 [(gogoproto.moretags) = "yaml:\"active\""]; repeated Period periods = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"periods\""]; + InfrastructureParams infrastructure_params = 4 [(gogoproto.nullable) = false]; +} + +message InfrastructureParams { + repeated Period infrastructure_periods = 1 [(gogoproto.castrepeated) = "Periods", (gogoproto.nullable) = false]; + repeated CoreReward core_rewards = 2 [(gogoproto.castrepeated) = "CoreRewards", (gogoproto.nullable) = false]; + repeated PartnerReward partner_rewards = 3 [(gogoproto.castrepeated) = "PartnerRewards", (gogoproto.nullable) = false]; + option (gogoproto.goproto_stringer) = true; +} + +message CoreReward { + bytes address = 1 [ + (cosmos_proto.scalar) = "cosmos.AddressBytes", + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + string weight = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + option (gogoproto.goproto_stringer) = true; +} + +message PartnerReward { + bytes address = 1 [ + (cosmos_proto.scalar) = "cosmos.AddressBytes", + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" + ]; + cosmos.base.v1beta1.Coin rewards_per_second = 2[(gogoproto.nullable) = false]; + option (gogoproto.goproto_stringer) = true; } // Period stores the specified start and end dates, and the inflation, expressed as a decimal @@ -35,3 +67,4 @@ message Period { (gogoproto.moretags) = "yaml:\"inflation\"" ]; } + diff --git a/x/kavadist/keeper/infrastructure.go b/x/kavadist/keeper/infrastructure.go new file mode 100644 index 00000000..4aa065be --- /dev/null +++ b/x/kavadist/keeper/infrastructure.go @@ -0,0 +1,100 @@ +package keeper + +import ( + "fmt" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/kava-labs/kava/x/kavadist/types" +) + +func (k Keeper) mintInfrastructurePeriods(ctx sdk.Context, periods types.Periods, previousBlockTime time.Time) (sdk.Coin, sdk.Int, error) { + var err error + coinsMinted := sdk.NewCoin(types.GovDenom, sdk.ZeroInt()) + timeElapsed := sdk.ZeroInt() + for _, period := range periods { + switch { + // Case 1 - period is fully expired + case period.End.Before(previousBlockTime): + continue + + // Case 2 - period has ended since the previous block time + case period.End.After(previousBlockTime) && (period.End.Before(ctx.BlockTime()) || period.End.Equal(ctx.BlockTime())): + // calculate time elapsed relative to the periods end time + timeElapsed = sdk.NewInt(period.End.Unix() - previousBlockTime.Unix()) + coins, errI := k.mintInflationaryCoins(ctx, period.Inflation, timeElapsed, types.GovDenom) + err = errI + if !coins.IsZero() { + coinsMinted = coinsMinted.Add(coins) + } + // update the value of previousBlockTime so that the next period starts from the end of the last + // period and not the original value of previousBlockTime + previousBlockTime = period.End + + // Case 3 - period is ongoing + case (period.Start.Before(previousBlockTime) || period.Start.Equal(previousBlockTime)) && period.End.After(ctx.BlockTime()): + // calculate time elapsed relative to the current block time + timeElapsed = sdk.NewInt(ctx.BlockTime().Unix() - previousBlockTime.Unix()) + coins, errI := k.mintInflationaryCoins(ctx, period.Inflation, timeElapsed, types.GovDenom) + if !coins.IsZero() { + coinsMinted = coinsMinted.Add(coins) + } + err = errI + + // Case 4 - period hasn't started + case period.Start.After(ctx.BlockTime()) || period.Start.Equal(ctx.BlockTime()): + timeElapsed = sdk.NewInt(ctx.BlockTime().Unix() - previousBlockTime.Unix()) + continue + } + + if err != nil { + return sdk.Coin{}, sdk.Int{}, err + } + } + return coinsMinted, timeElapsed, nil +} + +func (k Keeper) distributeInfrastructureCoins(ctx sdk.Context, partnerRewards types.PartnerRewards, coreRewards types.CoreRewards, timeElapsed sdk.Int, coinsToDistribute sdk.Coin) error { + if timeElapsed.IsZero() { + return nil + } + if coinsToDistribute.IsZero() { + return nil + } + for _, pr := range partnerRewards { + coinsToSend := sdk.NewCoin(types.GovDenom, pr.RewardsPerSecond.Amount.Mul(timeElapsed)) + // TODO check balance, log if insufficient and return rather than error + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, pr.Address, sdk.NewCoins(coinsToSend)) + if err != nil { + return err + } + neg, updatedCoins := safeSub(coinsToDistribute, coinsToSend) + if neg { + return fmt.Errorf("negative coins") + } + coinsToDistribute = updatedCoins + } + for _, cr := range coreRewards { + coinsToSend := sdk.NewCoin(types.GovDenom, coinsToDistribute.Amount.ToDec().Mul(cr.Weight).RoundInt()) + // TODO check balance, log if insufficient and return rather than error + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, cr.Address, sdk.NewCoins(coinsToSend)) + if err != nil { + return err + } + neg, updatedCoins := safeSub(coinsToDistribute, coinsToSend) + if neg { + return fmt.Errorf("negative coins") + } + coinsToDistribute = updatedCoins + } + return nil +} + +func safeSub(a, b sdk.Coin) (bool, sdk.Coin) { + isNeg := a.IsLT(b) + if isNeg { + return true, sdk.Coin{} + } + return false, a.Sub(b) +} diff --git a/x/kavadist/keeper/mint.go b/x/kavadist/keeper/mint.go index 68bbf604..51838c51 100644 --- a/x/kavadist/keeper/mint.go +++ b/x/kavadist/keeper/mint.go @@ -1,6 +1,8 @@ package keeper import ( + "time" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/kava-labs/kava/x/kavadist/types" @@ -25,19 +27,37 @@ func (k Keeper) MintPeriodInflation(ctx sdk.Context) error { k.SetPreviousBlockTime(ctx, previousBlockTime) return nil } + err := k.mintIncentivePeriods(ctx, params.Periods, previousBlockTime) + if err != nil { + return err + } + coinsToDistribute, timeElapsed, err := k.mintInfrastructurePeriods(ctx, params.InfrastructureParams.InfrastructurePeriods, previousBlockTime) + if err != nil { + return err + } + + err = k.distributeInfrastructureCoins(ctx, params.InfrastructureParams.PartnerRewards, params.InfrastructureParams.CoreRewards, timeElapsed, coinsToDistribute) + if err != nil { + return err + } + k.SetPreviousBlockTime(ctx, ctx.BlockTime()) + return nil +} + +func (k Keeper) mintIncentivePeriods(ctx sdk.Context, periods types.Periods, previousBlockTime time.Time) error { var err error - for _, period := range params.Periods { + for _, period := range periods { switch { // Case 1 - period is fully expired case period.End.Before(previousBlockTime): continue // Case 2 - period has ended since the previous block time - case period.End.After(previousBlockTime) && period.End.Before(ctx.BlockTime()): + case period.End.After(previousBlockTime) && (period.End.Before(ctx.BlockTime()) || period.End.Equal(ctx.BlockTime())): // calculate time elapsed relative to the periods end time timeElapsed := sdk.NewInt(period.End.Unix() - previousBlockTime.Unix()) - err = k.mintInflationaryCoins(ctx, period.Inflation, timeElapsed, types.GovDenom) + _, err = k.mintInflationaryCoins(ctx, period.Inflation, timeElapsed, types.GovDenom) // update the value of previousBlockTime so that the next period starts from the end of the last // period and not the original value of previousBlockTime previousBlockTime = period.End @@ -46,7 +66,7 @@ func (k Keeper) MintPeriodInflation(ctx sdk.Context) error { case (period.Start.Before(previousBlockTime) || period.Start.Equal(previousBlockTime)) && period.End.After(ctx.BlockTime()): // calculate time elapsed relative to the current block time timeElapsed := sdk.NewInt(ctx.BlockTime().Unix() - previousBlockTime.Unix()) - err = k.mintInflationaryCoins(ctx, period.Inflation, timeElapsed, types.GovDenom) + _, err = k.mintInflationaryCoins(ctx, period.Inflation, timeElapsed, types.GovDenom) // Case 4 - period hasn't started case period.Start.After(ctx.BlockTime()) || period.Start.Equal(ctx.BlockTime()): @@ -57,11 +77,10 @@ func (k Keeper) MintPeriodInflation(ctx sdk.Context) error { return err } } - k.SetPreviousBlockTime(ctx, ctx.BlockTime()) return nil } -func (k Keeper) mintInflationaryCoins(ctx sdk.Context, inflationRate sdk.Dec, timePeriods sdk.Int, denom string) error { +func (k Keeper) mintInflationaryCoins(ctx sdk.Context, inflationRate sdk.Dec, timePeriods sdk.Int, denom string) (sdk.Coin, error) { totalSupply := k.bankKeeper.GetSupply(ctx, denom) // used to scale accumulator calculations by 10^18 scalar := sdk.NewInt(1000000000000000000) @@ -75,11 +94,11 @@ func (k Keeper) mintInflationaryCoins(ctx sdk.Context, inflationRate sdk.Dec, ti // calculate the number of coins to mint amountToMint := (sdk.NewDecFromInt(totalSupply.Amount).Mul(accumulator)).Sub(sdk.NewDecFromInt(totalSupply.Amount)).TruncateInt() if amountToMint.IsZero() { - return nil + return sdk.Coin{}, nil } err := k.bankKeeper.MintCoins(ctx, types.KavaDistMacc, sdk.NewCoins(sdk.NewCoin(denom, amountToMint))) if err != nil { - return err + return sdk.Coin{}, err } ctx.EventManager().EmitEvent( @@ -89,5 +108,5 @@ func (k Keeper) mintInflationaryCoins(ctx sdk.Context, inflationRate sdk.Dec, ti ), ) - return nil + return sdk.NewCoin(denom, amountToMint), nil } diff --git a/x/kavadist/keeper/mint_test.go b/x/kavadist/keeper/mint_test.go index a768e0ec..cc3b4288 100644 --- a/x/kavadist/keeper/mint_test.go +++ b/x/kavadist/keeper/mint_test.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/kava-labs/kava/app" "github.com/kava-labs/kava/x/kavadist/types" ) @@ -88,3 +89,290 @@ func (suite *keeperTestSuite) TestMintNotActive() { finalSupply := suite.BankKeeper.GetSupply(suite.Ctx, types.GovDenom) suite.Require().Equal(initialSupply, finalSupply) } + +func (suite *keeperTestSuite) TestInfraMinting() { + + type args struct { + startTime time.Time + endTime time.Time + infraPeriods types.Periods + expectedFinalSupply sdk.Coin + marginOfError sdk.Dec + } + + type errArgs struct { + expectPass bool + contains string + } + + type test struct { + name string + args args + errArgs errArgs + } + + testCases := []test{ + { + "5% apy one year", + args{ + startTime: time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), + endTime: time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), + infraPeriods: types.Periods{types.NewPeriod(time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), sdk.MustNewDecFromStr("1.000000001547125958"))}, + expectedFinalSupply: sdk.NewCoin(types.GovDenom, sdk.NewInt(1050000000000)), + marginOfError: sdk.MustNewDecFromStr("0.0001"), + }, + errArgs{ + expectPass: true, + contains: "", + }, + }, + { + "5% apy 10 seconds", + args{ + startTime: time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), + endTime: time.Date(2022, time.October, 1, 1, 0, 10, 0, time.UTC), + infraPeriods: types.Periods{types.NewPeriod(time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), sdk.MustNewDecFromStr("1.000000001547125958"))}, + expectedFinalSupply: sdk.NewCoin(types.GovDenom, sdk.NewInt(1000000015471)), + marginOfError: sdk.MustNewDecFromStr("0.0001"), + }, + errArgs{ + expectPass: true, + contains: "", + }, + }, + } + + for _, tc := range testCases { + suite.SetupTest() + params := types.NewParams(true, types.DefaultPeriods, types.NewInfraParams(tc.args.infraPeriods, types.DefaultInfraParams.PartnerRewards, types.DefaultInfraParams.CoreRewards)) + ctx := suite.Ctx.WithBlockTime(tc.args.startTime) + suite.Keeper.SetParams(ctx, params) + suite.Require().NotPanics(func() { + suite.Keeper.SetPreviousBlockTime(ctx, tc.args.startTime) + }) + ctx = suite.Ctx.WithBlockTime(tc.args.endTime) + err := suite.Keeper.MintPeriodInflation(ctx) + suite.Require().NoError(err) + finalSupply := suite.BankKeeper.GetSupply(ctx, types.GovDenom) + marginHigh := tc.args.expectedFinalSupply.Amount.ToDec().Mul(sdk.OneDec().Add(tc.args.marginOfError)) + marginLow := tc.args.expectedFinalSupply.Amount.ToDec().Mul(sdk.OneDec().Sub(tc.args.marginOfError)) + suite.Require().True(finalSupply.Amount.ToDec().LTE(marginHigh)) + suite.Require().True(finalSupply.Amount.ToDec().GTE(marginLow)) + + } + +} + +func (suite *keeperTestSuite) TestInfraPayoutCore() { + + type args struct { + startTime time.Time + endTime time.Time + infraPeriods types.Periods + expectedFinalSupply sdk.Coin + expectedBalanceIncrease sdk.Coin + marginOfError sdk.Dec + } + + type errArgs struct { + expectPass bool + contains string + } + + type test struct { + name string + args args + errArgs errArgs + } + + testCases := []test{ + { + "5% apy one year", + args{ + startTime: time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), + endTime: time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), + infraPeriods: types.Periods{types.NewPeriod(time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), sdk.MustNewDecFromStr("1.000000001547125958"))}, + expectedFinalSupply: sdk.NewCoin(types.GovDenom, sdk.NewInt(1050000000000)), + expectedBalanceIncrease: sdk.NewCoin(types.GovDenom, sdk.NewInt(50000000000)), + marginOfError: sdk.MustNewDecFromStr("0.0001"), + }, + errArgs{ + expectPass: true, + contains: "", + }, + }, + } + + for _, tc := range testCases { + suite.SetupTest() + coreReward := types.NewCoreReward(suite.Addrs[0], sdk.OneDec()) + params := types.NewParams(true, types.DefaultPeriods, types.NewInfraParams(tc.args.infraPeriods, types.DefaultInfraParams.PartnerRewards, types.CoreRewards{coreReward})) + ctx := suite.Ctx.WithBlockTime(tc.args.startTime) + suite.Keeper.SetParams(ctx, params) + suite.Require().NotPanics(func() { + suite.Keeper.SetPreviousBlockTime(ctx, tc.args.startTime) + }) + initialBalance := suite.BankKeeper.GetBalance(ctx, suite.Addrs[0], types.GovDenom) + ctx = suite.Ctx.WithBlockTime(tc.args.endTime) + err := suite.Keeper.MintPeriodInflation(ctx) + suite.Require().NoError(err) + finalSupply := suite.BankKeeper.GetSupply(ctx, types.GovDenom) + marginHigh := tc.args.expectedFinalSupply.Amount.ToDec().Mul(sdk.OneDec().Add(tc.args.marginOfError)) + marginLow := tc.args.expectedFinalSupply.Amount.ToDec().Mul(sdk.OneDec().Sub(tc.args.marginOfError)) + suite.Require().True(finalSupply.Amount.ToDec().LTE(marginHigh)) + suite.Require().True(finalSupply.Amount.ToDec().GTE(marginLow)) + + finalBalance := suite.BankKeeper.GetBalance(ctx, suite.Addrs[0], types.GovDenom) + suite.Require().Equal(tc.args.expectedBalanceIncrease, finalBalance.Sub(initialBalance)) + + } + +} + +func (suite *keeperTestSuite) TestInfraPayoutPartner() { + + type args struct { + startTime time.Time + endTime time.Time + infraPeriods types.Periods + expectedFinalSupply sdk.Coin + expectedBalanceIncrease sdk.Coin + marginOfError sdk.Dec + } + + type errArgs struct { + expectPass bool + contains string + } + + type test struct { + name string + args args + errArgs errArgs + } + + testCases := []test{ + { + "5% apy one year", + args{ + startTime: time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), + endTime: time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), + infraPeriods: types.Periods{types.NewPeriod(time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), sdk.MustNewDecFromStr("1.000000001547125958"))}, + expectedFinalSupply: sdk.NewCoin(types.GovDenom, sdk.NewInt(1050000000000)), + expectedBalanceIncrease: sdk.NewCoin(types.GovDenom, sdk.NewInt(63072000)), + marginOfError: sdk.MustNewDecFromStr("0.0001"), + }, + errArgs{ + expectPass: true, + contains: "", + }, + }, + } + + for _, tc := range testCases { + suite.SetupTest() + partnerReward := types.NewPartnerReward(suite.Addrs[0], sdk.NewCoin(types.GovDenom, sdk.NewInt(2))) + params := types.NewParams(true, types.DefaultPeriods, types.NewInfraParams(tc.args.infraPeriods, types.PartnerRewards{partnerReward}, types.DefaultInfraParams.CoreRewards)) + ctx := suite.Ctx.WithBlockTime(tc.args.startTime) + suite.Keeper.SetParams(ctx, params) + suite.Require().NotPanics(func() { + suite.Keeper.SetPreviousBlockTime(ctx, tc.args.startTime) + }) + initialBalance := suite.BankKeeper.GetBalance(ctx, suite.Addrs[0], types.GovDenom) + ctx = suite.Ctx.WithBlockTime(tc.args.endTime) + err := suite.Keeper.MintPeriodInflation(ctx) + suite.Require().NoError(err) + finalSupply := suite.BankKeeper.GetSupply(ctx, types.GovDenom) + marginHigh := tc.args.expectedFinalSupply.Amount.ToDec().Mul(sdk.OneDec().Add(tc.args.marginOfError)) + marginLow := tc.args.expectedFinalSupply.Amount.ToDec().Mul(sdk.OneDec().Sub(tc.args.marginOfError)) + suite.Require().True(finalSupply.Amount.ToDec().LTE(marginHigh)) + suite.Require().True(finalSupply.Amount.ToDec().GTE(marginLow)) + + finalBalance := suite.BankKeeper.GetBalance(ctx, suite.Addrs[0], types.GovDenom) + suite.Require().Equal(tc.args.expectedBalanceIncrease, finalBalance.Sub(initialBalance)) + + } + +} + +func (suite *keeperTestSuite) TestInfraPayoutE2E() { + + type balance struct { + address sdk.AccAddress + amount sdk.Coins + } + + type balances []balance + + type args struct { + periods types.Periods + startTime time.Time + endTime time.Time + infraPeriods types.Periods + coreRewards types.CoreRewards + partnerRewards types.PartnerRewards + expectedFinalSupply sdk.Coin + expectedBalances balances + marginOfError sdk.Dec + } + + type errArgs struct { + expectPass bool + contains string + } + + type test struct { + name string + args args + errArgs errArgs + } + + _, addrs := app.GeneratePrivKeyAddressPairs(3) + + testCases := []test{ + { + "5% apy one year", + args{ + periods: types.Periods{types.NewPeriod(time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), sdk.MustNewDecFromStr("1.000000001547125958"))}, + startTime: time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), + endTime: time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), + infraPeriods: types.Periods{types.NewPeriod(time.Date(2022, time.October, 1, 1, 0, 0, 0, time.UTC), time.Date(2023, time.October, 1, 1, 0, 0, 0, time.UTC), sdk.MustNewDecFromStr("1.000000001547125958"))}, + coreRewards: types.CoreRewards{types.NewCoreReward(addrs[1], sdk.OneDec())}, + partnerRewards: types.PartnerRewards{types.NewPartnerReward(addrs[2], sdk.NewCoin("ukava", sdk.NewInt(2)))}, + expectedFinalSupply: sdk.NewCoin(types.GovDenom, sdk.NewInt(1102500000000)), + expectedBalances: balances{ + balance{addrs[1], sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(52436928000)))}, + balance{addrs[2], sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(63072000)))}, + }, + marginOfError: sdk.MustNewDecFromStr("0.0001"), + }, + errArgs{ + expectPass: true, + contains: "", + }, + }, + } + + for _, tc := range testCases { + suite.SetupTest() + params := types.NewParams(true, tc.args.periods, types.NewInfraParams(tc.args.infraPeriods, tc.args.partnerRewards, tc.args.coreRewards)) + ctx := suite.Ctx.WithBlockTime(tc.args.startTime) + suite.Keeper.SetParams(ctx, params) + suite.Require().NotPanics(func() { + suite.Keeper.SetPreviousBlockTime(ctx, tc.args.startTime) + }) + ctx = suite.Ctx.WithBlockTime(tc.args.endTime) + err := suite.Keeper.MintPeriodInflation(ctx) + suite.Require().NoError(err) + finalSupply := suite.BankKeeper.GetSupply(ctx, types.GovDenom) + marginHigh := tc.args.expectedFinalSupply.Amount.ToDec().Mul(sdk.OneDec().Add(tc.args.marginOfError)) + marginLow := tc.args.expectedFinalSupply.Amount.ToDec().Mul(sdk.OneDec().Sub(tc.args.marginOfError)) + suite.Require().True(finalSupply.Amount.ToDec().LTE(marginHigh)) + suite.Require().True(finalSupply.Amount.ToDec().GTE(marginLow)) + + for _, bal := range tc.args.expectedBalances { + finalBalance := suite.BankKeeper.GetAllBalances(ctx, bal.address) + suite.Require().Equal(bal.amount, finalBalance) + } + } +} diff --git a/x/kavadist/legacy/v0_16/migrate_test.go b/x/kavadist/legacy/v0_16/migrate_test.go deleted file mode 100644 index 4c2c929f..00000000 --- a/x/kavadist/legacy/v0_16/migrate_test.go +++ /dev/null @@ -1,151 +0,0 @@ -package v0_16 - -import ( - "testing" - "time" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/suite" - tmtime "github.com/tendermint/tendermint/types/time" - - app "github.com/kava-labs/kava/app" - v015kavadist "github.com/kava-labs/kava/x/kavadist/legacy/v0_15" - v016kavadist "github.com/kava-labs/kava/x/kavadist/types" -) - -type migrateTestSuite struct { - suite.Suite - - addresses []sdk.AccAddress - v15genstate v015kavadist.GenesisState - cdc codec.Codec - legacyCdc *codec.LegacyAmino -} - -func (s *migrateTestSuite) SetupTest() { - app.SetSDKConfig() - - s.v15genstate = v015kavadist.GenesisState{ - Params: v015kavadist.Params{}, - PreviousBlockTime: tmtime.Canonical(time.Unix(1, 0)), - } - - config := app.MakeEncodingConfig() - s.cdc = config.Marshaler - - legacyCodec := codec.NewLegacyAmino() - s.legacyCdc = legacyCodec - - _, accAddresses := app.GeneratePrivKeyAddressPairs(10) - s.addresses = accAddresses -} - -func (s *migrateTestSuite) TestMigrate_JSON() { - // Migrate v15 kavadist to v16 - data := `{ - "params": { - "active": true, - "periods": [ - { - "end": "2021-06-01T14:00:00Z", - "inflation": "1.000000000000000000", - "start": "2020-06-01T14:00:00Z" - }, - { - "end": "2022-06-01T14:00:00Z", - "inflation": "1.000000002293273137", - "start": "2021-06-01T14:00:00Z" - }, - { - "end": "2023-06-01T14:00:00Z", - "inflation": "1.000000001167363430", - "start": "2022-06-01T14:00:00Z" - }, - { - "end": "2024-06-01T14:00:00Z", - "inflation": "1.000000000782997609", - "start": "2023-06-01T14:00:00Z" - } - ] - }, - "previous_block_time": "2021-11-05T21:13:12.85608847Z" - }` - err := s.legacyCdc.UnmarshalJSON([]byte(data), &s.v15genstate) - s.Require().NoError(err) - genstate := Migrate(s.v15genstate) - - // Compare expect v16 kavadist json with migrated json - actual := s.cdc.MustMarshalJSON(genstate) - expected := `{ - "params": { - "active": true, - "periods": [ - { - "start": "2020-06-01T14:00:00Z", - "end": "2021-06-01T14:00:00Z", - "inflation": "1.000000000000000000" - }, - { - "start": "2021-06-01T14:00:00Z", - "end": "2022-06-01T14:00:00Z", - "inflation": "1.000000002293273137" - }, - { - "start": "2022-06-01T14:00:00Z", - "end": "2023-06-01T14:00:00Z", - "inflation": "1.000000001167363430" - }, - { - "start": "2023-06-01T14:00:00Z", - "end": "2024-06-01T14:00:00Z", - "inflation": "1.000000000782997609" - } - ] - }, - "previous_block_time": "2021-11-05T21:13:12.856088470Z" - }` - s.Require().NoError(err) - s.Require().JSONEq(string(expected), string(actual)) -} - -func (s *migrateTestSuite) TestMigrate_Params() { - params := v015kavadist.Params{ - Active: true, - Periods: v015kavadist.Periods{ - { - Start: time.Date(2020, time.March, 1, 1, 0, 0, 0, time.UTC), - End: time.Date(2021, time.March, 1, 1, 0, 0, 0, time.UTC), - Inflation: sdk.MustNewDecFromStr("0.1"), - }, - { - Start: time.Date(2010, time.March, 1, 1, 0, 0, 0, time.UTC), - End: time.Date(2011, time.March, 2, 1, 0, 0, 0, time.UTC), - Inflation: sdk.MustNewDecFromStr("0.01"), - }, - }, - } - expected := v016kavadist.Params{ - Active: true, - Periods: []v016kavadist.Period{ - { - Start: time.Date(2020, time.March, 1, 1, 0, 0, 0, time.UTC), - End: time.Date(2021, time.March, 1, 1, 0, 0, 0, time.UTC), - Inflation: sdk.MustNewDecFromStr("0.1"), - }, - { - Start: time.Date(2010, time.March, 1, 1, 0, 0, 0, time.UTC), - End: time.Date(2011, time.March, 2, 1, 0, 0, 0, time.UTC), - Inflation: sdk.MustNewDecFromStr("0.01"), - }, - }, - } - - s.v15genstate.Params = params - genState := Migrate(s.v15genstate) - s.Require().Equal(expected, genState.Params) -} - -func TestMigrateTestSuite(t *testing.T) { - suite.Run(t, new(migrateTestSuite)) -} diff --git a/x/kavadist/simulation/genesis.go b/x/kavadist/simulation/genesis.go index bdeff95a..6ff289de 100644 --- a/x/kavadist/simulation/genesis.go +++ b/x/kavadist/simulation/genesis.go @@ -42,7 +42,7 @@ func RandomizedGenState(simState *module.SimulationState) { func genRandomParams(simState *module.SimulationState) types.Params { periods := genRandomPeriods(simState.Rand, simState.GenTimestamp) - params := types.NewParams(true, periods) + params := types.NewParams(true, periods, types.DefaultInfraParams) return params } diff --git a/x/kavadist/simulation/params.go b/x/kavadist/simulation/params.go index b8ff3760..ad7fb968 100644 --- a/x/kavadist/simulation/params.go +++ b/x/kavadist/simulation/params.go @@ -16,7 +16,7 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { // Hacky way to validate periods since validation is wrapped in params active := genRandomActive(r) periods := genRandomPeriods(r, simtypes.RandTimestamp(r)) - if err := types.NewParams(active, periods).Validate(); err != nil { + if err := types.NewParams(active, periods, types.DefaultInfraParams).Validate(); err != nil { panic(err) } diff --git a/x/kavadist/testutil/suite.go b/x/kavadist/testutil/suite.go index b6974a16..f999c3cc 100644 --- a/x/kavadist/testutil/suite.go +++ b/x/kavadist/testutil/suite.go @@ -52,7 +52,7 @@ func (suite *Suite) SetupTest() { Inflation: sdk.MustNewDecFromStr("1.000000003022265980"), }, } - params := types.NewParams(true, testPeriods) + params := types.NewParams(true, testPeriods, types.DefaultInfraParams) moduleGs := types.ModuleCdc.MustMarshalJSON(types.NewGenesisState(params, types.DefaultPreviousBlockTime)) gs := app.GenesisState{types.ModuleName: moduleGs} tApp.InitializeFromGenesisStates(authGS, gs) diff --git a/x/kavadist/types/expected_keepers.go b/x/kavadist/types/expected_keepers.go index 65511211..e78d3d9f 100644 --- a/x/kavadist/types/expected_keepers.go +++ b/x/kavadist/types/expected_keepers.go @@ -22,4 +22,5 @@ type BankKeeper interface { GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins MintCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error GetSupply(ctx sdk.Context, denom string) sdk.Coin + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error } diff --git a/x/kavadist/types/params.go b/x/kavadist/types/params.go index 77fe4d3e..3053a6dc 100644 --- a/x/kavadist/types/params.go +++ b/x/kavadist/types/params.go @@ -15,38 +15,24 @@ import ( var ( KeyActive = []byte("Active") KeyPeriods = []byte("Periods") + KeyInfra = []byte("InfrastructureParams") DefaultActive = false DefaultPeriods = []Period{} + DefaultInfraParams = InfrastructureParams{} DefaultPreviousBlockTime = tmtime.Canonical(time.Unix(1, 0)) GovDenom = "ukava" // TODO: replace with cdptypes.DefaultGovDenom ) -// NewPeriod returns a new instance of Period -func NewPeriod(start time.Time, end time.Time, inflation sdk.Dec) Period { - return Period{ - Start: start, - End: end, - Inflation: inflation, - } -} - -// String implements fmt.Stringer -func (pr Period) String() string { - return fmt.Sprintf(`Period: - Start: %s - End: %s - Inflation: %s`, pr.Start, pr.End, pr.Inflation) -} - -func NewParams(active bool, periods []Period) Params { +func NewParams(active bool, periods []Period, infraParams InfrastructureParams) Params { return Params{ - Active: active, - Periods: periods, + Active: active, + Periods: periods, + InfrastructureParams: infraParams, } } func DefaultParams() Params { - return NewParams(DefaultActive, DefaultPeriods) + return NewParams(DefaultActive, DefaultPeriods, DefaultInfraParams) } func (p Params) String() string { @@ -87,6 +73,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyActive, &p.Active, validateActiveParam), paramtypes.NewParamSetPair(KeyPeriods, &p.Periods, validatePeriodsParams), + paramtypes.NewParamSetPair(KeyInfra, &p.InfrastructureParams, validateInfraParams), } } @@ -99,6 +86,47 @@ func (p Params) Validate() error { return validatePeriodsParams(p.Periods) } +// NewPeriod returns a new instance of Period +func NewPeriod(start time.Time, end time.Time, inflation sdk.Dec) Period { + return Period{ + Start: start, + End: end, + Inflation: inflation, + } +} + +type Periods []Period + +// String implements fmt.Stringer +func (pr Period) String() string { + return fmt.Sprintf(`Period: + Start: %s + End: %s + Inflation: %s`, pr.Start, pr.End, pr.Inflation) +} + +func NewInfraParams(p Periods, pr PartnerRewards, cr CoreRewards) InfrastructureParams { + return InfrastructureParams{ + InfrastructurePeriods: p, + PartnerRewards: pr, + CoreRewards: cr, + } +} + +func NewPartnerReward(addr sdk.AccAddress, rps sdk.Coin) PartnerReward { + return PartnerReward{ + Address: addr, + RewardsPerSecond: rps, + } +} + +func NewCoreReward(addr sdk.AccAddress, w sdk.Dec) CoreReward { + return CoreReward{ + Address: addr, + Weight: w, + } +} + func validateActiveParam(i interface{}) error { _, ok := i.(bool) if !ok { @@ -134,3 +162,30 @@ func validatePeriodsParams(i interface{}) error { return nil } + +func validateInfraParams(i interface{}) error { + infraParams, ok := i.(InfrastructureParams) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + for _, pr := range infraParams.InfrastructurePeriods { + if pr.End.Before(pr.Start) { + return fmt.Errorf("end time for period is before start time: %s", pr) + } + prevEnd := tmtime.Canonical(time.Unix(0, 0)) + if pr.Start.Before(prevEnd) { + return fmt.Errorf("periods must be in chronological order: %s", infraParams.InfrastructurePeriods) + } + prevEnd = pr.End + + if pr.Start.Unix() <= 0 || pr.End.Unix() <= 0 { + return fmt.Errorf("start or end time cannot be zero: %s", pr) + } + + // TODO: validate period Inflation? + } + return nil +} + +type CoreRewards []CoreReward +type PartnerRewards []PartnerReward diff --git a/x/kavadist/types/params.pb.go b/x/kavadist/types/params.pb.go index b28e29cd..d0df10fd 100644 --- a/x/kavadist/types/params.pb.go +++ b/x/kavadist/types/params.pb.go @@ -5,7 +5,9 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" @@ -30,8 +32,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params governance parameters for kavadist module type Params struct { - Active bool `protobuf:"varint,1,opt,name=active,proto3" json:"active,omitempty" yaml:"active"` - Periods []Period `protobuf:"bytes,3,rep,name=periods,proto3" json:"periods" yaml:"periods"` + Active bool `protobuf:"varint,1,opt,name=active,proto3" json:"active,omitempty" yaml:"active"` + Periods []Period `protobuf:"bytes,3,rep,name=periods,proto3" json:"periods" yaml:"periods"` + InfrastructureParams InfrastructureParams `protobuf:"bytes,4,opt,name=infrastructure_params,json=infrastructureParams,proto3" json:"infrastructure_params"` } func (m *Params) Reset() { *m = Params{} } @@ -66,6 +69,121 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +type InfrastructureParams struct { + InfrastructurePeriods Periods `protobuf:"bytes,1,rep,name=infrastructure_periods,json=infrastructurePeriods,proto3,castrepeated=Periods" json:"infrastructure_periods"` + CoreRewards CoreRewards `protobuf:"bytes,2,rep,name=core_rewards,json=coreRewards,proto3,castrepeated=CoreRewards" json:"core_rewards"` + PartnerRewards PartnerRewards `protobuf:"bytes,3,rep,name=partner_rewards,json=partnerRewards,proto3,castrepeated=PartnerRewards" json:"partner_rewards"` +} + +func (m *InfrastructureParams) Reset() { *m = InfrastructureParams{} } +func (m *InfrastructureParams) String() string { return proto.CompactTextString(m) } +func (*InfrastructureParams) ProtoMessage() {} +func (*InfrastructureParams) Descriptor() ([]byte, []int) { + return fileDescriptor_2c7a7a4b0c884a4e, []int{1} +} +func (m *InfrastructureParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InfrastructureParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InfrastructureParams.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 *InfrastructureParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_InfrastructureParams.Merge(m, src) +} +func (m *InfrastructureParams) XXX_Size() int { + return m.Size() +} +func (m *InfrastructureParams) XXX_DiscardUnknown() { + xxx_messageInfo_InfrastructureParams.DiscardUnknown(m) +} + +var xxx_messageInfo_InfrastructureParams proto.InternalMessageInfo + +type CoreReward struct { + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty"` + Weight github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"weight"` +} + +func (m *CoreReward) Reset() { *m = CoreReward{} } +func (m *CoreReward) String() string { return proto.CompactTextString(m) } +func (*CoreReward) ProtoMessage() {} +func (*CoreReward) Descriptor() ([]byte, []int) { + return fileDescriptor_2c7a7a4b0c884a4e, []int{2} +} +func (m *CoreReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CoreReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CoreReward.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 *CoreReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_CoreReward.Merge(m, src) +} +func (m *CoreReward) XXX_Size() int { + return m.Size() +} +func (m *CoreReward) XXX_DiscardUnknown() { + xxx_messageInfo_CoreReward.DiscardUnknown(m) +} + +var xxx_messageInfo_CoreReward proto.InternalMessageInfo + +type PartnerReward struct { + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty"` + RewardsPerSecond types.Coin `protobuf:"bytes,2,opt,name=rewards_per_second,json=rewardsPerSecond,proto3" json:"rewards_per_second"` +} + +func (m *PartnerReward) Reset() { *m = PartnerReward{} } +func (m *PartnerReward) String() string { return proto.CompactTextString(m) } +func (*PartnerReward) ProtoMessage() {} +func (*PartnerReward) Descriptor() ([]byte, []int) { + return fileDescriptor_2c7a7a4b0c884a4e, []int{3} +} +func (m *PartnerReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PartnerReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PartnerReward.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 *PartnerReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_PartnerReward.Merge(m, src) +} +func (m *PartnerReward) XXX_Size() int { + return m.Size() +} +func (m *PartnerReward) XXX_DiscardUnknown() { + xxx_messageInfo_PartnerReward.DiscardUnknown(m) +} + +var xxx_messageInfo_PartnerReward proto.InternalMessageInfo + // Period stores the specified start and end dates, and the inflation, expressed as a decimal // representing the yearly APR of KAVA tokens that will be minted during that period type Period struct { @@ -80,7 +198,7 @@ type Period struct { func (m *Period) Reset() { *m = Period{} } func (*Period) ProtoMessage() {} func (*Period) Descriptor() ([]byte, []int) { - return fileDescriptor_2c7a7a4b0c884a4e, []int{1} + return fileDescriptor_2c7a7a4b0c884a4e, []int{4} } func (m *Period) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -111,6 +229,9 @@ var xxx_messageInfo_Period proto.InternalMessageInfo func init() { proto.RegisterType((*Params)(nil), "kava.kavadist.v1beta1.Params") + proto.RegisterType((*InfrastructureParams)(nil), "kava.kavadist.v1beta1.InfrastructureParams") + proto.RegisterType((*CoreReward)(nil), "kava.kavadist.v1beta1.CoreReward") + proto.RegisterType((*PartnerReward)(nil), "kava.kavadist.v1beta1.PartnerReward") proto.RegisterType((*Period)(nil), "kava.kavadist.v1beta1.Period") } @@ -119,32 +240,51 @@ func init() { } var fileDescriptor_2c7a7a4b0c884a4e = []byte{ - // 399 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xb1, 0x8e, 0xd3, 0x30, - 0x18, 0xc7, 0xe3, 0x0b, 0x04, 0xf0, 0x1d, 0x08, 0x22, 0x40, 0x51, 0x25, 0xec, 0xca, 0x03, 0x2a, - 0x48, 0x67, 0xeb, 0x8e, 0xed, 0xc6, 0xe8, 0x26, 0x84, 0xc4, 0x29, 0x62, 0x62, 0xc2, 0x49, 0x7c, - 0x21, 0xba, 0x24, 0x8e, 0x62, 0xb7, 0xa2, 0x2b, 0xe2, 0x01, 0xfa, 0x08, 0x3c, 0x4e, 0xc7, 0x8e, - 0x15, 0x43, 0xa0, 0xed, 0xc2, 0xdc, 0x27, 0x40, 0xb1, 0x13, 0xca, 0x80, 0x74, 0x4b, 0xf2, 0x25, - 0xf9, 0x7d, 0xbf, 0xef, 0xfb, 0x47, 0x86, 0xe4, 0x86, 0xcf, 0x38, 0xeb, 0x2e, 0x69, 0xae, 0x34, - 0x9b, 0x9d, 0xc5, 0x42, 0xf3, 0x33, 0x56, 0xf3, 0x86, 0x97, 0x8a, 0xd6, 0x8d, 0xd4, 0xd2, 0x7f, - 0xd6, 0x7d, 0xa6, 0x03, 0x43, 0x7b, 0x66, 0xf4, 0x34, 0x93, 0x99, 0x34, 0x04, 0xeb, 0x2a, 0x0b, - 0x8f, 0x70, 0x26, 0x65, 0x56, 0x08, 0x66, 0x9e, 0xe2, 0xe9, 0x35, 0xd3, 0x79, 0x29, 0x94, 0xe6, - 0x65, 0x6d, 0x01, 0xf2, 0x0d, 0x40, 0xef, 0xca, 0xe8, 0xfd, 0x57, 0xd0, 0xe3, 0x89, 0xce, 0x67, - 0x22, 0x00, 0x63, 0x30, 0xb9, 0x1f, 0x3e, 0xd9, 0xb7, 0xf8, 0xe1, 0x9c, 0x97, 0xc5, 0x05, 0xb1, - 0xef, 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59, 0xef, 0x90, 0xf3, 0xf1, 0xf5, 0x3f, 0xe3, 0xba, - 0x7f, 0x7d, 0x5a, 0xf0, 0x58, 0x99, 0x8a, 0x7d, 0x39, 0x1c, 0x1b, 0x33, 0x36, 0xf6, 0x4c, 0xcc, - 0x37, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x3b, 0xc2, 0x43, 0x54, 0x02, 0x00, 0x00, + // 696 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xbd, 0x6f, 0xd3, 0x40, + 0x14, 0xcf, 0x25, 0x21, 0xa5, 0x97, 0x7e, 0xe1, 0x7e, 0xc8, 0xad, 0x84, 0x1d, 0x2c, 0x84, 0x02, + 0x28, 0xb6, 0x1a, 0xb6, 0x8a, 0xa5, 0xa6, 0x03, 0x20, 0x10, 0x95, 0xe9, 0x02, 0x4b, 0x38, 0xdb, + 0x97, 0xd4, 0x6a, 0xe2, 0xb3, 0xee, 0x2e, 0x2d, 0x5d, 0xf9, 0x0b, 0x3a, 0x32, 0x76, 0x66, 0xee, + 0xbf, 0x80, 0x94, 0x81, 0xa1, 0xea, 0x54, 0x31, 0xa4, 0xb4, 0x5d, 0x18, 0x98, 0x3a, 0x32, 0x21, + 0xdf, 0x5d, 0x92, 0xa6, 0x6a, 0x50, 0x59, 0x58, 0x12, 0xbf, 0x8f, 0xdf, 0xef, 0xbd, 0xdf, 0xdd, + 0x7b, 0x07, 0xad, 0x2d, 0xb4, 0x8d, 0x9c, 0xf4, 0x27, 0x8c, 0x18, 0x77, 0xb6, 0x97, 0x7d, 0xcc, + 0xd1, 0xb2, 0x93, 0x20, 0x8a, 0x5a, 0xcc, 0x4e, 0x28, 0xe1, 0x44, 0x9b, 0x4f, 0xc3, 0x76, 0x2f, + 0xc7, 0x56, 0x39, 0x4b, 0x73, 0x0d, 0xd2, 0x20, 0x22, 0xc3, 0x49, 0x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ff, 0xff, + 0xb2, 0xbd, 0x98, 0xf3, 0xd9, 0x05, 0x00, 0x00, } func (this *Period) Equal(that interface{}) bool { @@ -197,6 +337,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.InfrastructureParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 if len(m.Periods) > 0 { for iNdEx := len(m.Periods) - 1; iNdEx >= 0; iNdEx-- { { @@ -224,6 +374,151 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *InfrastructureParams) 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 *InfrastructureParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InfrastructureParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PartnerRewards) > 0 { + for iNdEx := len(m.PartnerRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PartnerRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.CoreRewards) > 0 { + for iNdEx := len(m.CoreRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CoreRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.InfrastructurePeriods) > 0 { + for iNdEx := len(m.InfrastructurePeriods) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.InfrastructurePeriods[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CoreReward) 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 *CoreReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CoreReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Weight.Size() + i -= size + if _, err := m.Weight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintParams(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PartnerReward) 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 *PartnerReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PartnerReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RewardsPerSecond.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintParams(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Period) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -254,20 +549,20 @@ func (m *Period) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x1a - n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.End, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.End):]) - if err1 != nil { - return 0, err1 + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.End, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.End):]) + if err3 != nil { + return 0, err3 } - i -= n1 - i = encodeVarintParams(dAtA, i, uint64(n1)) + i -= n3 + i = encodeVarintParams(dAtA, i, uint64(n3)) i-- dAtA[i] = 0x12 - n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Start, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Start):]) - if err2 != nil { - return 0, err2 + n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Start, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Start):]) + if err4 != nil { + return 0, err4 } - i -= n2 - i = encodeVarintParams(dAtA, i, uint64(n2)) + i -= n4 + i = encodeVarintParams(dAtA, i, uint64(n4)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -299,6 +594,65 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) } } + l = m.InfrastructureParams.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *InfrastructureParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.InfrastructurePeriods) > 0 { + for _, e := range m.InfrastructurePeriods { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.CoreRewards) > 0 { + for _, e := range m.CoreRewards { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.PartnerRewards) > 0 { + for _, e := range m.PartnerRewards { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + return n +} + +func (m *CoreReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.Weight.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *PartnerReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.RewardsPerSecond.Size() + n += 1 + l + sovParams(uint64(l)) return n } @@ -406,6 +760,426 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InfrastructureParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InfrastructureParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *InfrastructureParams) 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 ErrIntOverflowParams + } + 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: InfrastructureParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InfrastructureParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InfrastructurePeriods", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InfrastructurePeriods = append(m.InfrastructurePeriods, Period{}) + if err := m.InfrastructurePeriods[len(m.InfrastructurePeriods)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CoreRewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CoreRewards = append(m.CoreRewards, CoreReward{}) + if err := m.CoreRewards[len(m.CoreRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PartnerRewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PartnerRewards = append(m.PartnerRewards, PartnerReward{}) + if err := m.PartnerRewards[len(m.PartnerRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CoreReward) 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 ErrIntOverflowParams + } + 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: CoreReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CoreReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Weight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PartnerReward) 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 ErrIntOverflowParams + } + 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: PartnerReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PartnerReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardsPerSecond", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardsPerSecond.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])