diff --git a/app/app.go b/app/app.go index b03e726129..fd56ebc8e9 100644 --- a/app/app.go +++ b/app/app.go @@ -180,18 +180,7 @@ func NewApp( homePath string, appOpts servertypes.AppOptions, options ...func(*bam.BaseApp), ) *AkashApp { // find out the genesis time, to be used later in inflation calculation - if v := appOpts.Get("GenesisTime"); v != nil { - // in tests, GenesisTime is supplied using appOpts - genTime, ok := v.(time.Time) - if !ok { - panic("expected GenesisTime to be a Time value") - } - inflationtypes.GenesisTime = genTime - } else if genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join(homePath, "config/genesis.json")); err != nil { - panic(err) - } else { - inflationtypes.GenesisTime = genDoc.GenesisTime - } + genesisTime := getGenesisTime(appOpts, homePath) // TODO: Remove cdc in favor of appCodec once all modules are migrated. encodingConfig := MakeEncodingConfig() @@ -353,7 +342,6 @@ func NewApp( app.keeper.evidence = *evidenceKeeper app.setAkashKeepers() - inflationtypes.InflationParamSubspace = app.GetSubspace(inflation.ModuleName) // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. @@ -369,7 +357,7 @@ func NewApp( capability.NewAppModule(appCodec, *app.keeper.cap), crisis.NewAppModule(&app.keeper.crisis, skipGenesisInvariants), gov.NewAppModule(appCodec, app.keeper.gov, app.keeper.acct, app.keeper.bank), - mint.NewAppModule(appCodec, app.keeper.mint, app.keeper.acct, inflationtypes.InflationCalculator), + mint.NewAppModule(appCodec, app.keeper.mint, app.keeper.acct, inflationtypes.GetInflationCalculator(genesisTime, app.GetSubspace(inflation.ModuleName))), slashing.NewAppModule(appCodec, app.keeper.slashing, app.keeper.acct, app.keeper.bank, app.keeper.staking), distr.NewAppModule(appCodec, app.keeper.distr, app.keeper.acct, app.keeper.bank, app.keeper.staking), staking.NewAppModule(appCodec, app.keeper.staking, app.keeper.acct, app.keeper.bank), @@ -436,7 +424,7 @@ func NewApp( bank.NewAppModule(appCodec, app.keeper.bank, app.keeper.acct), capability.NewAppModule(appCodec, *app.keeper.cap), gov.NewAppModule(appCodec, app.keeper.gov, app.keeper.acct, app.keeper.bank), - mint.NewAppModule(appCodec, app.keeper.mint, app.keeper.acct, inflationtypes.InflationCalculator), + mint.NewAppModule(appCodec, app.keeper.mint, app.keeper.acct, inflationtypes.GetInflationCalculator(genesisTime, app.GetSubspace(inflation.ModuleName))), staking.NewAppModule(appCodec, app.keeper.staking, app.keeper.acct, app.keeper.bank), distr.NewAppModule(appCodec, app.keeper.distr, app.keeper.acct, app.keeper.bank, app.keeper.staking), slashing.NewAppModule(appCodec, app.keeper.slashing, app.keeper.acct, app.keeper.bank, app.keeper.staking), @@ -538,6 +526,24 @@ func (app *AkashApp) registerUpgradeHandlers() { } } +func getGenesisTime(appOpts servertypes.AppOptions, homePath string) time.Time { + if v := appOpts.Get("GenesisTime"); v != nil { + // in tests, GenesisTime is supplied using appOpts + genTime, ok := v.(time.Time) + if !ok { + panic("expected GenesisTime to be a Time value") + } + return genTime + } + + genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join(homePath, "config/genesis.json")) + if err != nil { + panic(err) + } + + return genDoc.GenesisTime +} + // MakeCodecs constructs the *std.Codec and *codec.LegacyAmino instances used by // simapp. It is useful for tests and clients who do not want to construct the // full simapp diff --git a/proto/akash/inflation/v1beta2/genesis.proto b/proto/akash/inflation/v1beta2/genesis.proto index 825d59767b..53def74370 100644 --- a/proto/akash/inflation/v1beta2/genesis.proto +++ b/proto/akash/inflation/v1beta2/genesis.proto @@ -8,7 +8,7 @@ option go_package = "github.com/ovrclk/akash/x/inflation/types/v1beta2"; // GenesisState stores slice of genesis deployment instance message GenesisState { - Params params = 2 [ + Params params = 1 [ (gogoproto.nullable) = false, (gogoproto.jsontag) = "params", (gogoproto.moretags) = "yaml:\"params\"" diff --git a/proto/akash/inflation/v1beta2/params.proto b/proto/akash/inflation/v1beta2/params.proto index 62d475916f..4bf04c32de 100644 --- a/proto/akash/inflation/v1beta2/params.proto +++ b/proto/akash/inflation/v1beta2/params.proto @@ -14,18 +14,20 @@ message Params { ]; // InitialInflation is the rate at which inflation starts at genesis. - // It is a float value. Maximum: 100.0 - // Amino has issues marshalling float, so type is marked string. + // It is a decimal value in the range [0.0, 100.0]. string initial_inflation = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, (gogoproto.customname) = "InitialInflation", (gogoproto.jsontag) = "initial_inflation", (gogoproto.moretags) = "yaml:\"initial_inflation\"" ]; // Variance defines the fraction by which inflation can vary from its previous value in a block. - // It is a float value in the range [0.0, 1.0]. - // Amino has issues marshalling float, so type is marked string. + // It is a decimal value in the range [0.0, 1.0]. string variance = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, (gogoproto.customname) = "Variance", (gogoproto.jsontag) = "variance", (gogoproto.moretags) = "yaml:\"variance\"" diff --git a/x/inflation/simulation/genesis.go b/x/inflation/simulation/genesis.go index 7d21999382..76cb613df2 100644 --- a/x/inflation/simulation/genesis.go +++ b/x/inflation/simulation/genesis.go @@ -1,6 +1,7 @@ package simulation import ( + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" types "github.com/ovrclk/akash/x/inflation/types/v1beta2" ) @@ -10,8 +11,8 @@ func RandomizedGenState(simState *module.SimulationState) { deploymentGenesis := &types.GenesisState{ Params: types.Params{ InflationDecayFactor: 2, - InitialInflation: "100.0", - Variance: "0.05", + InitialInflation: sdk.NewDec(100), + Variance: sdk.MustNewDecFromStr("0.05"), }, } diff --git a/x/inflation/types/v1beta2/genesis.pb.go b/x/inflation/types/v1beta2/genesis.pb.go index e106ee14dc..ee102ff68a 100644 --- a/x/inflation/types/v1beta2/genesis.pb.go +++ b/x/inflation/types/v1beta2/genesis.pb.go @@ -25,7 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState stores slice of genesis deployment instance type GenesisState struct { - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params" yaml:"params"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params" yaml:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -84,14 +84,14 @@ var fileDescriptor_912221706d9e5bb6 = []byte{ 0xc9, 0x17, 0x12, 0x07, 0x2b, 0xd3, 0x83, 0x2b, 0xd3, 0x83, 0x2a, 0x93, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0xa5, 0x54, 0x70, 0x99, 0x5a, 0x90, 0x58, 0x94, 0x98, 0x0b, 0x35, 0x54, 0x29, 0x83, 0x8b, 0xc7, 0x1d, 0x62, 0x4b, 0x70, 0x49, 0x62, 0x49, 0xaa, - 0x50, 0x04, 0x17, 0x1b, 0x44, 0x5e, 0x82, 0x49, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x5e, 0x0f, 0x87, + 0x50, 0x04, 0x17, 0x1b, 0x44, 0x5e, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x5e, 0x0f, 0x87, 0xad, 0x7a, 0x01, 0x60, 0x65, 0x4e, 0xf2, 0x27, 0xee, 0xc9, 0x33, 0xbc, 0xba, 0x27, 0x0f, 0xd5, 0xf6, 0xe9, 0x9e, 0x3c, 0x6f, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x84, 0xaf, 0x14, 0x04, 0x95, 0x70, 0xf2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xc3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xfc, 0xb2, 0xa2, 0xe4, 0x9c, 0x6c, 0x7d, 0x88, 0xdb, 0x2b, 0x90, 0x5c, 0x5f, 0x52, 0x59, 0x90, 0x5a, 0x0c, 0xf3, 0x43, 0x12, 0x1b, 0xd8, - 0xf5, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, 0x5e, 0x65, 0x12, 0x3b, 0x01, 0x00, 0x00, + 0xf5, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1c, 0xff, 0xda, 0x38, 0x3b, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -123,7 +123,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -184,7 +184,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 2: + case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } diff --git a/x/inflation/types/v1beta2/inflation_calculator.go b/x/inflation/types/v1beta2/inflation_calculator.go index 5631d9dd96..5cc5399580 100644 --- a/x/inflation/types/v1beta2/inflation_calculator.go +++ b/x/inflation/types/v1beta2/inflation_calculator.go @@ -10,59 +10,51 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -var ( - // these are set during NewApp and used in InflationCalculator - - GenesisTime time.Time - InflationParamSubspace paramstypes.Subspace -) - -func InflationCalculator(ctx sdk.Context, minter minttypes.Minter, params minttypes.Params, bondedRatio sdk.Dec) sdk.Dec { - var inflationParams Params - InflationParamSubspace.GetParamSet(ctx, &inflationParams) - tHalf := float64(inflationParams.InflationDecayFactor) - initialInflation, err := strconv.ParseFloat(inflationParams.InitialInflation, 32) - if err != nil { - panic(err) +func GetInflationCalculator( + genesisTime time.Time, + inflationParamSubspace paramstypes.Subspace, +) minttypes.InflationCalculationFn { + return func(ctx sdk.Context, minter minttypes.Minter, params minttypes.Params, bondedRatio sdk.Dec) sdk.Dec { + var inflationParams Params + inflationParamSubspace.GetParamSet(ctx, &inflationParams) + tHalf := float64(inflationParams.InflationDecayFactor) + + // Number of hours in an year = 8766 (averaging the leap year hours) + // Number of minutes in an hour = 60 + // Number of seconds in a minute = 60 + // => Number of seconds per year = 60 * 60 * 8766 = 31557600 + t := ctx.BlockTime().Sub(genesisTime).Seconds() / 31557600 // years passed (can be a fraction, eg: 0.5) + idealInflation := inflationParams.InitialInflation.Mul(sdk.MustNewDecFromStr( + strconv.FormatFloat(math.Pow(2, -t/tHalf), 'f', -1, 64), + )) + + // (1 - bondedRatio/GoalBonded) * InflationRateChange + inflationRateChangePerYear := sdk.OneDec(). + Sub(bondedRatio.Quo(params.GoalBonded)). + Mul(params.InflationRateChange) + inflationRateChange := inflationRateChangePerYear.Quo(sdk.NewDec(int64(params.BlocksPerYear))) + + // note inflationRateChange may be negative + currentInflation := minter.Inflation.Add(inflationRateChange) + + // min, max currentInflation based on a defined range parameter 'r' + // currentInflation range = [I(t) - I(t) * R, I(t) + I(t) * R] + r := inflationParams.Variance + minInflation := idealInflation.Sub(idealInflation.Mul(r)) + maxInflation := idealInflation.Add(idealInflation.Mul(r)) + + // minInflation >= minimumMinInflation + minimumMinInflation := sdk.ZeroDec() // 0 for now + if minInflation.LT(minimumMinInflation) { + minInflation = minimumMinInflation + } + + if currentInflation.LT(minInflation) { + currentInflation = minInflation + } else if currentInflation.GT(maxInflation) { + currentInflation = maxInflation + } + + return currentInflation } - - // Number of hours in an year = 8766 (averaging the leap year hours) - // Number of minutes in an hour = 60 - // Number of seconds in a minute = 60 - // => 60 * 60 * 8766 = Number of seconds per year - t := ctx.BlockTime().Sub(GenesisTime).Seconds() / (60 * 60 * 8766) // years passed - i := initialInflation * math.Pow(2, -t/tHalf) - idealInflation := sdk.NewDec(int64(i)) - - // (1 - bondedRatio/GoalBonded) * InflationRateChange - inflationRateChangePerYear := sdk.OneDec(). - Sub(bondedRatio.Quo(params.GoalBonded)). - Mul(params.InflationRateChange) - inflationRateChange := inflationRateChangePerYear.Quo(sdk.NewDec(int64(params.BlocksPerYear))) - - // note inflationRateChange may be negative - currentInflation := minter.Inflation.Add(inflationRateChange) - - // min, max currentInflation based on a defined range parameter 'r' - // currentInflation range = [I(t) - I(t) * R, I(t) + I(t) * R] - r, err := sdk.NewDecFromStr(inflationParams.Variance) - if err != nil { - panic(err) - } - minInflation := idealInflation.Sub(idealInflation.Mul(r)) - maxInflation := idealInflation.Add(idealInflation.Mul(r)) - - // minInflation >= minimumMinInflation - minimumMinInflation := sdk.ZeroDec() // 0 for now - if minInflation.LT(minimumMinInflation) { - minInflation = minimumMinInflation - } - - if currentInflation.LT(minInflation) { - currentInflation = minInflation - } else if currentInflation.GT(maxInflation) { - currentInflation = maxInflation - } - - return currentInflation } diff --git a/x/inflation/types/v1beta2/params.go b/x/inflation/types/v1beta2/params.go index ceb76f17dd..43a2dfcdc9 100644 --- a/x/inflation/types/v1beta2/params.go +++ b/x/inflation/types/v1beta2/params.go @@ -1,7 +1,7 @@ package v1beta2 import ( - "strconv" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/pkg/errors" @@ -11,14 +11,23 @@ var _ paramtypes.ParamSet = (*Params)(nil) const ( DefaultInflationDecayFactor uint32 = 2 // years - DefaultInitialInflation string = "100.0" - DefaultVarince string = "0.05" keyInflationDecayFactor = "InflationDecayFactor" keyInitialInflation = "InitialInflation" keyVariance = "Variance" ) +var ( + DefaultInitialInflation = sdk.NewDec(100) + DefaultVarince = sdk.MustNewDecFromStr("0.05") + + MaxInitialInflation = sdk.NewDec(100) + MinInitialInflation = sdk.ZeroDec() + + MaxVariance = sdk.NewDec(1) + MinVariance = sdk.ZeroDec() +) + func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } @@ -63,32 +72,24 @@ func validateInflationDecayFactor(i interface{}) error { } func validateInitialInflation(i interface{}) error { - v, ok := i.(string) + v, ok := i.(sdk.Dec) if !ok { return errors.Wrapf(ErrInvalidParam, "%T", i) } - initialInflation, err := strconv.ParseFloat(v, 32) - if err != nil { - return err - } - if initialInflation > 100.0 { - return errors.Wrapf(ErrInvalidInitialInflation, "%v", initialInflation) + if v.GT(MaxInitialInflation) || v.LT(MinInitialInflation) { + return errors.Wrapf(ErrInvalidInitialInflation, "%v", v) } return nil } func validateVariance(i interface{}) error { - v, ok := i.(string) + v, ok := i.(sdk.Dec) if !ok { return errors.Wrapf(ErrInvalidParam, "%T", i) } - variance, err := strconv.ParseFloat(v, 32) - if err != nil { - return err - } - if variance < 0.0 || variance > 1.0 { - return errors.Wrapf(ErrInvalidVariance, "%v", variance) + if v.GT(MaxVariance) || v.LT(MinVariance) { + return errors.Wrapf(ErrInvalidVariance, "%v", v) } return nil diff --git a/x/inflation/types/v1beta2/params.pb.go b/x/inflation/types/v1beta2/params.pb.go index 41c5999313..7c2678c34f 100644 --- a/x/inflation/types/v1beta2/params.pb.go +++ b/x/inflation/types/v1beta2/params.pb.go @@ -5,6 +5,7 @@ package v1beta2 import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -28,13 +29,11 @@ type Params struct { // InflationDecayFactor is the number of years it takes inflation to halve. InflationDecayFactor uint32 `protobuf:"varint,1,opt,name=inflation_decay_factor,json=inflationDecayFactor,proto3" json:"inflation_decay_factor" yaml:"inflation_decay_factor"` // InitialInflation is the rate at which inflation starts at genesis. - // It is a float value. Maximum: 100.0 - // Amino has issues marshalling float, so type is marked string. - InitialInflation string `protobuf:"bytes,2,opt,name=initial_inflation,json=initialInflation,proto3" json:"initial_inflation" yaml:"initial_inflation"` + // It is a decimal value in the range [0.0, 100.0]. + InitialInflation github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=initial_inflation,json=initialInflation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"initial_inflation" yaml:"initial_inflation"` // Variance defines the fraction by which inflation can vary from its previous value in a block. - // It is a float value in the range [0.0, 1.0]. - // Amino has issues marshalling float, so type is marked string. - Variance string `protobuf:"bytes,3,opt,name=variance,proto3" json:"variance" yaml:"variance"` + // It is a decimal value in the range [0.0, 1.0]. + Variance github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=variance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"variance" yaml:"variance"` } func (m *Params) Reset() { *m = Params{} } @@ -77,20 +76,6 @@ func (m *Params) GetInflationDecayFactor() uint32 { return 0 } -func (m *Params) GetInitialInflation() string { - if m != nil { - return m.InitialInflation - } - return "" -} - -func (m *Params) GetVariance() string { - if m != nil { - return m.Variance - } - return "" -} - func init() { proto.RegisterType((*Params)(nil), "akash.inflation.v1beta2.Params") } @@ -100,27 +85,29 @@ func init() { } var fileDescriptor_fea313162cb1e23f = []byte{ - // 317 bytes of a gzipped FileDescriptorProto + // 349 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xcc, 0x4e, 0x2c, 0xce, 0xd0, 0xcf, 0xcc, 0x4b, 0xcb, 0x49, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd2, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x07, 0xab, 0xd2, 0x83, 0xab, 0xd2, 0x83, 0xaa, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0x95, 0x2e, 0x32, 0x71, 0xb1, 0x05, 0x80, 0xf5, 0x0b, + 0x07, 0xab, 0xd1, 0x07, 0xb1, 0x20, 0xca, 0x95, 0xd6, 0x31, 0x73, 0xb1, 0x05, 0x80, 0xf5, 0x0b, 0x75, 0x32, 0x72, 0x89, 0xc1, 0xb5, 0xc5, 0xa7, 0xa4, 0x26, 0x27, 0x56, 0xc6, 0xa7, 0x25, 0x26, 0x97, 0xe4, 0x17, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x3a, 0x05, 0x3f, 0xba, 0x27, 0x2f, 0xe2, 0x09, 0x53, 0xe1, 0x02, 0x52, 0xe0, 0x06, 0x96, 0x7f, 0x75, 0x4f, 0x1e, 0x87, 0xce, 0x4f, 0xf7, 0xe4, 0x65, 0x2b, 0x13, 0x73, 0x73, 0xac, 0x94, 0xb0, 0xcb, 0x2b, 0x05, 0x89, 0x64, 0x62, 0x31, - 0x50, 0xa8, 0x88, 0x4b, 0x30, 0x33, 0x2f, 0xb3, 0x24, 0x33, 0x31, 0x27, 0x1e, 0x2e, 0x2f, 0xc1, - 0xa4, 0xc0, 0xa8, 0xc1, 0xe9, 0xe4, 0xfa, 0xe8, 0x9e, 0xbc, 0x80, 0x27, 0x44, 0x12, 0xee, 0x98, - 0x57, 0xf7, 0xe4, 0x31, 0x35, 0x7c, 0xba, 0x27, 0x2f, 0x01, 0xb3, 0x1c, 0x4d, 0x4a, 0x29, 0x48, - 0x20, 0x13, 0xcd, 0x08, 0x21, 0x77, 0x2e, 0x8e, 0xb2, 0xc4, 0xa2, 0xcc, 0xc4, 0xbc, 0xe4, 0x54, - 0x09, 0x66, 0xb0, 0x55, 0xda, 0x8f, 0xee, 0xc9, 0x73, 0x84, 0x41, 0xc5, 0x5e, 0xdd, 0x93, 0x87, - 0xcb, 0x7f, 0xba, 0x27, 0xcf, 0x0f, 0x31, 0x19, 0x26, 0xa2, 0x14, 0x04, 0x97, 0x74, 0xf2, 0x3e, - 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, - 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xc3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, - 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xfc, 0xb2, 0xa2, 0xe4, 0x9c, 0x6c, 0x7d, 0x48, 0xa4, 0x56, - 0x20, 0x45, 0x6b, 0x49, 0x65, 0x41, 0x6a, 0x31, 0x2c, 0x72, 0x93, 0xd8, 0xc0, 0xf1, 0x64, 0x0c, - 0x08, 0x00, 0x00, 0xff, 0xff, 0x74, 0xeb, 0x02, 0xbf, 0xfe, 0x01, 0x00, 0x00, + 0x50, 0x68, 0x01, 0x23, 0x97, 0x60, 0x66, 0x5e, 0x66, 0x49, 0x66, 0x62, 0x4e, 0x3c, 0x5c, 0x81, + 0x04, 0x93, 0x02, 0xa3, 0x06, 0xa7, 0x53, 0xf1, 0x89, 0x7b, 0xf2, 0x0c, 0xb7, 0xee, 0xc9, 0xab, + 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0xe7, 0x17, 0xe7, 0xe6, + 0x17, 0x43, 0x29, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, 0xd4, 0x62, 0x3d, 0x97, 0xd4, + 0xe4, 0x47, 0xf7, 0xe4, 0x05, 0x3c, 0x21, 0x46, 0xc1, 0xdd, 0xfe, 0xea, 0x9e, 0x3c, 0xa6, 0xf1, + 0x9f, 0xee, 0xc9, 0x4b, 0xc0, 0xdc, 0x8a, 0x26, 0xa5, 0x14, 0x24, 0x90, 0x89, 0x66, 0x84, 0x50, + 0x29, 0x17, 0x47, 0x59, 0x62, 0x51, 0x66, 0x62, 0x5e, 0x72, 0xaa, 0x04, 0x33, 0xd8, 0x61, 0x91, + 0x24, 0x3b, 0x8c, 0x23, 0x0c, 0x6a, 0xc2, 0xab, 0x7b, 0xf2, 0x70, 0xd3, 0x3e, 0xdd, 0x93, 0xe7, + 0x87, 0xb8, 0x03, 0x26, 0xa2, 0x14, 0x04, 0x97, 0x74, 0xf2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, + 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, + 0xc6, 0x63, 0x39, 0x86, 0x28, 0x43, 0x24, 0x6b, 0xf3, 0xcb, 0x8a, 0x92, 0x73, 0xb2, 0xf5, 0x21, + 0x29, 0xa6, 0x02, 0x29, 0xcd, 0x80, 0x6d, 0x87, 0xa5, 0x9c, 0x24, 0x36, 0x70, 0x22, 0x30, 0x06, + 0x04, 0x00, 0x00, 0xff, 0xff, 0x24, 0x5e, 0xdd, 0xdf, 0x5b, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -143,20 +130,26 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Variance) > 0 { - i -= len(m.Variance) - copy(dAtA[i:], m.Variance) - i = encodeVarintParams(dAtA, i, uint64(len(m.Variance))) - i-- - dAtA[i] = 0x1a + { + size := m.Variance.Size() + i -= size + if _, err := m.Variance.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) } - if len(m.InitialInflation) > 0 { - i -= len(m.InitialInflation) - copy(dAtA[i:], m.InitialInflation) - i = encodeVarintParams(dAtA, i, uint64(len(m.InitialInflation))) - i-- - dAtA[i] = 0x12 + i-- + dAtA[i] = 0x1a + { + size := m.InitialInflation.Size() + i -= size + if _, err := m.InitialInflation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if m.InflationDecayFactor != 0 { i = encodeVarintParams(dAtA, i, uint64(m.InflationDecayFactor)) i-- @@ -185,14 +178,10 @@ func (m *Params) Size() (n int) { if m.InflationDecayFactor != 0 { n += 1 + sovParams(uint64(m.InflationDecayFactor)) } - l = len(m.InitialInflation) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = len(m.Variance) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } + l = m.InitialInflation.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.Variance.Size() + n += 1 + l + sovParams(uint64(l)) return n } @@ -280,7 +269,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.InitialInflation = string(dAtA[iNdEx:postIndex]) + if err := m.InitialInflation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 3: if wireType != 2 { @@ -312,7 +303,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Variance = string(dAtA[iNdEx:postIndex]) + if err := m.Variance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex