diff --git a/proto/sentinel/node/v1/params.proto b/proto/sentinel/node/v1/params.proto index a10d8fa8..fc7ed86b 100644 --- a/proto/sentinel/node/v1/params.proto +++ b/proto/sentinel/node/v1/params.proto @@ -14,4 +14,12 @@ message Params { cosmos.base.v1beta1.Coin deposit = 1 [ (gogoproto.nullable) = false ]; google.protobuf.Duration inactive_duration = 2 [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + repeated cosmos.base.v1beta1.Coin max_price = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + repeated cosmos.base.v1beta1.Coin min_price = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; } diff --git a/x/node/abci.go b/x/node/abci.go index 54c7c58a..124c7e4e 100644 --- a/x/node/abci.go +++ b/x/node/abci.go @@ -15,6 +15,52 @@ func EndBlock(ctx sdk.Context, k keeper.Keeper) []abcitypes.ValidatorUpdate { inactiveDuration = k.InactiveDuration(ctx) ) + if k.IsMaxPriceModified(ctx) { + price := k.MaxPrice(ctx) + k.IterateNodes(ctx, func(_ int, item types.Node) (stop bool) { + if item.Price == nil { + return false + } + + for _, coin := range price { + amount := item.Price.AmountOf(coin.Denom) + if amount.GT(coin.Amount) { + item.Price = item.Price.Add( + sdk.NewCoin(coin.Denom, amount.Neg()), + ).Add(coin) + } + } + + k.SetNode(ctx, item) + return false + }) + + k.DeleteTransientKeyMaxPrice(ctx) + } + + if k.IsMinPriceModified(ctx) { + price := k.MinPrice(ctx) + k.IterateNodes(ctx, func(_ int, item types.Node) (stop bool) { + if item.Price == nil { + return false + } + + for _, coin := range price { + amount := item.Price.AmountOf(coin.Denom) + if amount.LT(coin.Amount) { + item.Price = item.Price.Add( + sdk.NewCoin(coin.Denom, amount.Neg()), + ).Add(coin) + } + } + + k.SetNode(ctx, item) + return false + }) + + k.DeleteTransientKeyMinPrice(ctx) + } + k.IterateInactiveNodesAt(ctx, ctx.BlockTime(), func(_ int, item types.Node) bool { log.Info("inactive node", "value", item) diff --git a/x/node/keeper/msg_server.go b/x/node/keeper/msg_server.go index 1dbfc988..7c620710 100644 --- a/x/node/keeper/msg_server.go +++ b/x/node/keeper/msg_server.go @@ -41,6 +41,9 @@ func (k *msgServer) MsgRegister(c context.Context, msg *types.MsgRegisterRequest return nil, types.ErrorProviderDoesNotExist } } + if msg.Price != nil && !k.IsValidPrice(ctx, msg.Price) { + return nil, types.ErrorInvalidPrice + } deposit := k.Deposit(ctx) if deposit.IsPositive() { @@ -137,6 +140,10 @@ func (k *msgServer) MsgUpdate(c context.Context, msg *types.MsgUpdateRequest) (* } } if msg.Price != nil { + if !k.IsValidPrice(ctx, msg.Price) { + return nil, types.ErrorInvalidPrice + } + node.Provider = "" node.Price = msg.Price } diff --git a/x/node/keeper/params.go b/x/node/keeper/params.go index 9e68d44e..c5267251 100644 --- a/x/node/keeper/params.go +++ b/x/node/keeper/params.go @@ -4,6 +4,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/sentinel-official/hub/x/node/types" ) @@ -18,6 +19,16 @@ func (k *Keeper) InactiveDuration(ctx sdk.Context) (duration time.Duration) { return } +func (k *Keeper) MaxPrice(ctx sdk.Context) (price sdk.Coins) { + k.params.Get(ctx, types.KeyMaxPrice, &price) + return +} + +func (k *Keeper) MinPrice(ctx sdk.Context) (price sdk.Coins) { + k.params.Get(ctx, types.KeyMinPrice, &price) + return +} + func (k *Keeper) SetParams(ctx sdk.Context, params types.Params) { k.params.SetParamSet(ctx, ¶ms) } @@ -26,5 +37,43 @@ func (k *Keeper) GetParams(ctx sdk.Context) types.Params { return types.NewParams( k.Deposit(ctx), k.InactiveDuration(ctx), + k.MaxPrice(ctx), + k.MinPrice(ctx), + ) +} + +func (k *Keeper) IsValidPrice(ctx sdk.Context, price sdk.Coins) bool { + var ( + maxPrice = k.MaxPrice(ctx) + minPrice = k.MinPrice(ctx) + ) + + return price.IsAllLTE(maxPrice) && + price.IsAllGTE(minPrice) +} + +func (k *Keeper) IsMaxPriceModified(ctx sdk.Context) bool { + return k.params.Modified(ctx, types.KeyMaxPrice) +} + +func (k *Keeper) IsMinPriceModified(ctx sdk.Context) bool { + return k.params.Modified(ctx, types.KeyMinPrice) +} + +func (k *Keeper) DeleteTransientKeyMaxPrice(ctx sdk.Context) { + var ( + tkey = sdk.NewTransientStoreKey(paramstypes.TStoreKey) + store = ctx.TransientStore(tkey) ) + + store.Delete(types.KeyMaxPrice) +} + +func (k *Keeper) DeleteTransientKeyMinPrice(ctx sdk.Context) { + var ( + tkey = sdk.NewTransientStoreKey(paramstypes.TStoreKey) + store = ctx.TransientStore(tkey) + ) + + store.Delete(types.KeyMinPrice) } diff --git a/x/node/simulation/genesis.go b/x/node/simulation/genesis.go index 1f8561bb..c74853d3 100644 --- a/x/node/simulation/genesis.go +++ b/x/node/simulation/genesis.go @@ -14,6 +14,8 @@ func RandomizedGenesisState(state *module.SimulationState) *types.GenesisState { var ( deposit sdk.Coin inactiveDuration time.Duration + maxPrice sdk.Coins + minPrice sdk.Coins ) state.AppParams.GetOrGenerate( @@ -24,7 +26,7 @@ func RandomizedGenesisState(state *module.SimulationState) *types.GenesisState { func(r *rand.Rand) { deposit = sdk.NewInt64Coin( sdk.DefaultBondDenom, - r.Int63n(MaxDepositAmount), + r.Int63n(MaxAmount), ) }, ) @@ -37,9 +39,37 @@ func RandomizedGenesisState(state *module.SimulationState) *types.GenesisState { inactiveDuration = time.Duration(r.Int63n(MaxInactiveDuration)) * time.Millisecond }, ) + state.AppParams.GetOrGenerate( + state.Cdc, + string(types.KeyMaxPrice), + &maxPrice, + state.Rand, + func(r *rand.Rand) { + maxPrice = sdk.NewCoins( + sdk.NewInt64Coin( + sdk.DefaultBondDenom, + r.Int63n(MaxAmount), + ), + ) + }, + ) + state.AppParams.GetOrGenerate( + state.Cdc, + string(types.KeyMinPrice), + &minPrice, + state.Rand, + func(r *rand.Rand) { + minPrice = sdk.NewCoins( + sdk.NewInt64Coin( + sdk.DefaultBondDenom, + r.Int63n(MaxAmount), + ), + ) + }, + ) return types.NewGenesisState( RandomNodes(state.Rand, state.Accounts), - types.NewParams(deposit, inactiveDuration), + types.NewParams(deposit, inactiveDuration, maxPrice, minPrice), ) } diff --git a/x/node/simulation/params.go b/x/node/simulation/params.go index b77c7eb1..47822e35 100644 --- a/x/node/simulation/params.go +++ b/x/node/simulation/params.go @@ -13,7 +13,7 @@ import ( ) const ( - MaxDepositAmount = 1 << 18 + MaxAmount = 1 << 18 MaxInactiveDuration = 1 << 18 ) @@ -25,7 +25,7 @@ func ParamChanges(_ *rand.Rand) []simulationtypes.ParamChange { func(r *rand.Rand) string { return sdk.NewInt64Coin( sdk.DefaultBondDenom, - r.Int63n(MaxDepositAmount), + r.Int63n(MaxAmount), ).String() }, ), diff --git a/x/node/types/params.go b/x/node/types/params.go index 70ac344b..f29e315e 100644 --- a/x/node/types/params.go +++ b/x/node/types/params.go @@ -13,12 +13,16 @@ const ( ) var ( - DefaultDeposit = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)) + DefaultDeposit = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)) + DefaultMaxPrice = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))) + DefaultMinPrice = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))) ) var ( KeyDeposit = []byte("Deposit") KeyInactiveDuration = []byte("InactiveDuration") + KeyMaxPrice = []byte("MaxPrice") + KeyMinPrice = []byte("MinPrice") ) var ( @@ -38,6 +42,16 @@ func (m *Params) Validate() error { if m.InactiveDuration == 0 { return fmt.Errorf("inactive_duration cannot be zero") } + if m.MaxPrice != nil { + if !m.MaxPrice.IsValid() { + return fmt.Errorf("max_price must be valid") + } + } + if m.MinPrice != nil { + if !m.MinPrice.IsValid() { + return fmt.Errorf("min_price must be valid") + } + } return nil } @@ -79,16 +93,54 @@ func (m *Params) ParamSetPairs() params.ParamSetPairs { return fmt.Errorf("inactive_duration cannot be zero") } + return nil + }, + }, + { + Key: KeyMaxPrice, + Value: &m.MaxPrice, + ValidatorFn: func(v interface{}) error { + value, ok := v.(sdk.Coins) + if !ok { + return fmt.Errorf("invalid parameter type %T", v) + } + + if value != nil { + if !value.IsValid() { + return fmt.Errorf("max_price must be valid") + } + } + + return nil + }, + }, + { + Key: KeyMinPrice, + Value: &m.MinPrice, + ValidatorFn: func(v interface{}) error { + value, ok := v.(sdk.Coins) + if !ok { + return fmt.Errorf("invalid parameter type %T", v) + } + + if value != nil { + if !value.IsValid() { + return fmt.Errorf("min_price must be valid") + } + } + return nil }, }, } } -func NewParams(deposit sdk.Coin, inactiveDuration time.Duration) Params { +func NewParams(deposit sdk.Coin, inactiveDuration time.Duration, maxPrice, minPrice sdk.Coins) Params { return Params{ Deposit: deposit, InactiveDuration: inactiveDuration, + MaxPrice: maxPrice, + MinPrice: minPrice, } } @@ -96,6 +148,8 @@ func DefaultParams() Params { return Params{ Deposit: DefaultDeposit, InactiveDuration: DefaultInactiveDuration, + MaxPrice: DefaultMaxPrice, + MinPrice: DefaultMinPrice, } } diff --git a/x/node/types/params.pb.go b/x/node/types/params.pb.go index 9f7b5213..f90a7ec0 100644 --- a/x/node/types/params.pb.go +++ b/x/node/types/params.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + 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" @@ -29,8 +30,10 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { - Deposit types.Coin `protobuf:"bytes,1,opt,name=deposit,proto3" json:"deposit"` - InactiveDuration time.Duration `protobuf:"bytes,2,opt,name=inactive_duration,json=inactiveDuration,proto3,stdduration" json:"inactive_duration"` + Deposit types.Coin `protobuf:"bytes,1,opt,name=deposit,proto3" json:"deposit"` + InactiveDuration time.Duration `protobuf:"bytes,2,opt,name=inactive_duration,json=inactiveDuration,proto3,stdduration" json:"inactive_duration"` + MaxPrice github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=max_price,json=maxPrice,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"max_price"` + MinPrice github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=min_price,json=minPrice,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"min_price"` } func (m *Params) Reset() { *m = Params{} } @@ -73,25 +76,29 @@ func init() { func init() { proto.RegisterFile("sentinel/node/v1/params.proto", fileDescriptor_56a408d0240644eb) } var fileDescriptor_56a408d0240644eb = []byte{ - // 286 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x90, 0xbd, 0x4e, 0xc3, 0x30, - 0x1c, 0xc4, 0x6d, 0x84, 0x0a, 0x0a, 0x4b, 0x89, 0x18, 0x4a, 0x25, 0x5c, 0xc4, 0xc4, 0x52, 0x5b, - 0x81, 0x89, 0xb5, 0xb0, 0x53, 0x75, 0x64, 0x41, 0x76, 0xe2, 0xa4, 0x96, 0x12, 0xff, 0xa3, 0xd8, - 0x89, 0xe0, 0x2d, 0x58, 0x90, 0x78, 0x04, 0x1e, 0x25, 0x63, 0x47, 0x26, 0x3e, 0x92, 0x17, 0x41, - 0xf9, 0x70, 0x37, 0x5b, 0xbf, 0xbb, 0xff, 0x9d, 0xce, 0xbb, 0x30, 0x52, 0x5b, 0xa5, 0x65, 0xca, - 0x34, 0x44, 0x92, 0x55, 0x01, 0xcb, 0x79, 0xc1, 0x33, 0x43, 0xf3, 0x02, 0x2c, 0xf8, 0x53, 0x87, - 0x69, 0x87, 0x69, 0x15, 0xcc, 0xcf, 0x12, 0x48, 0xa0, 0x87, 0xac, 0x7b, 0x0d, 0xba, 0x39, 0x49, - 0x00, 0x92, 0x54, 0xb2, 0xfe, 0x27, 0xca, 0x98, 0x45, 0x65, 0xc1, 0xad, 0x02, 0xed, 0x78, 0x08, - 0x26, 0x03, 0xc3, 0x04, 0x37, 0x5d, 0x88, 0x90, 0x96, 0x07, 0x2c, 0x04, 0x35, 0xf2, 0xab, 0x77, - 0xec, 0x4d, 0xd6, 0x7d, 0xb0, 0x7f, 0xe7, 0x1d, 0x45, 0x32, 0x07, 0xa3, 0xec, 0x0c, 0x5f, 0xe2, - 0xeb, 0x93, 0x9b, 0x73, 0x3a, 0x98, 0x69, 0x67, 0xa6, 0xa3, 0x99, 0xde, 0x83, 0xd2, 0xab, 0xc3, - 0xfa, 0x7b, 0x81, 0x36, 0x4e, 0xef, 0xaf, 0xbd, 0x53, 0xa5, 0x79, 0x68, 0x55, 0x25, 0x9f, 0x5d, - 0x81, 0xd9, 0xc1, 0x78, 0x64, 0x68, 0x48, 0x5d, 0x43, 0xfa, 0x30, 0x0a, 0x56, 0xc7, 0xdd, 0x91, - 0x8f, 0x9f, 0x05, 0xde, 0x4c, 0x9d, 0x7b, 0xcf, 0x1e, 0xeb, 0x3f, 0x82, 0x3e, 0x1b, 0x82, 0xea, - 0x86, 0xe0, 0x5d, 0x43, 0xf0, 0x6f, 0x43, 0xf0, 0x5b, 0x4b, 0xd0, 0xae, 0x25, 0xe8, 0xab, 0x25, - 0xe8, 0x69, 0x99, 0x28, 0xbb, 0x2d, 0x05, 0x0d, 0x21, 0x63, 0x6e, 0xac, 0x25, 0xc4, 0xb1, 0x0a, - 0x15, 0x4f, 0xd9, 0xb6, 0x14, 0xec, 0x65, 0x98, 0xd6, 0xbe, 0xe6, 0xd2, 0x88, 0x49, 0x9f, 0x7f, - 0xfb, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x73, 0x9b, 0x54, 0x60, 0x78, 0x01, 0x00, 0x00, + // 349 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x92, 0xb1, 0x4e, 0xf3, 0x30, + 0x14, 0x85, 0x93, 0xb6, 0xea, 0xdf, 0x3f, 0x2c, 0x25, 0x62, 0x28, 0x95, 0x70, 0x2b, 0xa6, 0x2e, + 0xb5, 0x29, 0x4c, 0xac, 0x85, 0x9d, 0xaa, 0x23, 0x4b, 0xe5, 0x24, 0x6e, 0x6a, 0xd1, 0xf8, 0x46, + 0xb1, 0x53, 0x95, 0xb7, 0x60, 0xe4, 0x11, 0x10, 0x4f, 0xd2, 0xb1, 0x23, 0x13, 0x85, 0x64, 0xe2, + 0x2d, 0x90, 0x9d, 0x58, 0x62, 0x62, 0x63, 0x4a, 0xac, 0x73, 0xcf, 0xf9, 0x8e, 0xad, 0xeb, 0x9d, + 0x49, 0x26, 0x14, 0x17, 0x6c, 0x4d, 0x04, 0x44, 0x8c, 0x6c, 0x26, 0x24, 0xa5, 0x19, 0x4d, 0x24, + 0x4e, 0x33, 0x50, 0xe0, 0x77, 0xad, 0x8c, 0xb5, 0x8c, 0x37, 0x93, 0xfe, 0x49, 0x0c, 0x31, 0x18, + 0x91, 0xe8, 0xbf, 0x6a, 0xae, 0x8f, 0x62, 0x80, 0x78, 0xcd, 0x88, 0x39, 0x05, 0xf9, 0x92, 0x44, + 0x79, 0x46, 0x15, 0x07, 0x61, 0xf5, 0x10, 0x64, 0x02, 0x92, 0x04, 0x54, 0x6a, 0x48, 0xc0, 0x14, + 0x9d, 0x90, 0x10, 0x78, 0xad, 0x9f, 0x7f, 0x35, 0xbc, 0xf6, 0xcc, 0x80, 0xfd, 0x6b, 0xef, 0x5f, + 0xc4, 0x52, 0x90, 0x5c, 0xf5, 0xdc, 0xa1, 0x3b, 0x3a, 0xba, 0x3c, 0xc5, 0x95, 0x19, 0x6b, 0x33, + 0xae, 0xcd, 0xf8, 0x06, 0xb8, 0x98, 0xb6, 0x76, 0xef, 0x03, 0x67, 0x6e, 0xe7, 0xfd, 0x99, 0x77, + 0xcc, 0x05, 0x0d, 0x15, 0xdf, 0xb0, 0x85, 0x2d, 0xd0, 0x6b, 0xd4, 0x21, 0x55, 0x43, 0x6c, 0x1b, + 0xe2, 0xdb, 0x7a, 0x60, 0xda, 0xd1, 0x21, 0xcf, 0x87, 0x81, 0x3b, 0xef, 0x5a, 0xb7, 0xd5, 0xfc, + 0x95, 0xf7, 0x3f, 0xa1, 0xdb, 0x45, 0x9a, 0xf1, 0x90, 0xf5, 0x9a, 0xc3, 0xe6, 0xef, 0x75, 0x2e, + 0x74, 0xd2, 0xeb, 0x61, 0x30, 0x8a, 0xb9, 0x5a, 0xe5, 0x01, 0x0e, 0x21, 0x21, 0xf5, 0xc5, 0xab, + 0xcf, 0x58, 0x46, 0x0f, 0x44, 0x3d, 0xa6, 0x4c, 0x1a, 0x83, 0x9c, 0x77, 0x12, 0xba, 0x9d, 0xe9, + 0x70, 0x43, 0xe2, 0xa2, 0x26, 0xb5, 0xfe, 0x82, 0xc4, 0x85, 0x21, 0x4d, 0xef, 0x76, 0x9f, 0xc8, + 0x79, 0x29, 0x90, 0xb3, 0x2b, 0x90, 0xbb, 0x2f, 0x90, 0xfb, 0x51, 0x20, 0xf7, 0xa9, 0x44, 0xce, + 0xbe, 0x44, 0xce, 0x5b, 0x89, 0x9c, 0xfb, 0xf1, 0x8f, 0x54, 0xbb, 0x00, 0x63, 0x58, 0x2e, 0x79, + 0xc8, 0xe9, 0x9a, 0xac, 0xf2, 0x80, 0x6c, 0xab, 0x75, 0x31, 0x80, 0xa0, 0x6d, 0xde, 0xf4, 0xea, + 0x3b, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x70, 0x93, 0x49, 0x4c, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -114,6 +121,34 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.MinPrice) > 0 { + for iNdEx := len(m.MinPrice) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.MinPrice[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.MaxPrice) > 0 { + for iNdEx := len(m.MaxPrice) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.MaxPrice[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.InactiveDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.InactiveDuration):]) if err1 != nil { return 0, err1 @@ -156,6 +191,18 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.InactiveDuration) n += 1 + l + sovParams(uint64(l)) + if len(m.MaxPrice) > 0 { + for _, e := range m.MaxPrice { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.MinPrice) > 0 { + for _, e := range m.MinPrice { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } return n } @@ -260,6 +307,74 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxPrice", 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.MaxPrice = append(m.MaxPrice, types.Coin{}) + if err := m.MaxPrice[len(m.MaxPrice)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinPrice", 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.MinPrice = append(m.MinPrice, types.Coin{}) + if err := m.MinPrice[len(m.MinPrice)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])