diff --git a/api/poktroll/gateway/params.pulsar.go b/api/poktroll/gateway/params.pulsar.go index 47b892b49..354bf132c 100644 --- a/api/poktroll/gateway/params.pulsar.go +++ b/api/poktroll/gateway/params.pulsar.go @@ -3,6 +3,7 @@ package gateway import ( _ "cosmossdk.io/api/amino" + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" @@ -15,12 +16,14 @@ import ( ) var ( - md_Params protoreflect.MessageDescriptor + md_Params protoreflect.MessageDescriptor + fd_Params_min_stake protoreflect.FieldDescriptor ) func init() { file_poktroll_gateway_params_proto_init() md_Params = File_poktroll_gateway_params_proto.Messages().ByName("Params") + fd_Params_min_stake = md_Params.Fields().ByName("min_stake") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -88,6 +91,12 @@ func (x *fastReflection_Params) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.MinStake != nil { + value := protoreflect.ValueOfMessage(x.MinStake.ProtoReflect()) + if !f(fd_Params_min_stake, value) { + return + } + } } // Has reports whether a field is populated. @@ -103,6 +112,8 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto // a repeated field is populated if it is non-empty. func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "poktroll.gateway.Params.min_stake": + return x.MinStake != nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.Params")) @@ -119,6 +130,8 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "poktroll.gateway.Params.min_stake": + x.MinStake = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.Params")) @@ -135,6 +148,9 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "poktroll.gateway.Params.min_stake": + value := x.MinStake + return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.Params")) @@ -155,6 +171,8 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "poktroll.gateway.Params.min_stake": + x.MinStake = value.Message().Interface().(*v1beta1.Coin) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.Params")) @@ -175,6 +193,11 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.gateway.Params.min_stake": + if x.MinStake == nil { + x.MinStake = new(v1beta1.Coin) + } + return protoreflect.ValueOfMessage(x.MinStake.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.Params")) @@ -188,6 +211,9 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.gateway.Params.min_stake": + m := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.Params")) @@ -257,6 +283,10 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + if x.MinStake != nil { + l = options.Size(x.MinStake) + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -286,6 +316,20 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.MinStake != nil { + encoded, err := options.Marshal(x.MinStake) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -335,6 +379,42 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.MinStake == nil { + x.MinStake = &v1beta1.Coin{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.MinStake); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -388,6 +468,9 @@ type Params struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // min_stake is the minimum amount of uPOKT that a gateway must stake. + MinStake *v1beta1.Coin `protobuf:"bytes,1,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` } func (x *Params) Reset() { @@ -410,6 +493,13 @@ func (*Params) Descriptor() ([]byte, []int) { return file_poktroll_gateway_params_proto_rawDescGZIP(), []int{0} } +func (x *Params) GetMinStake() *v1beta1.Coin { + if x != nil { + return x.MinStake + } + return nil +} + var File_poktroll_gateway_params_proto protoreflect.FileDescriptor var file_poktroll_gateway_params_proto_rawDesc = []byte{ @@ -417,22 +507,29 @@ var file_poktroll_gateway_params_proto_rawDesc = []byte{ 0x61, 0x79, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x1a, 0x11, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, + 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2c, 0x0a, 0x06, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x3a, 0x22, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x19, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, - 0x79, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xab, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, - 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, - 0x74, 0x65, 0x77, 0x61, 0x79, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, - 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, - 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xa2, 0x02, 0x03, 0x50, 0x47, 0x58, 0xaa, 0x02, 0x10, - 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, - 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x47, 0x61, 0x74, 0x65, - 0x77, 0x61, 0x79, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x47, - 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x47, - 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x73, 0x0a, 0x06, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x12, 0x45, 0x0a, 0x09, 0x6d, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6b, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, + 0x69, 0x6e, 0x42, 0x0d, 0xea, 0xde, 0x1f, 0x09, 0x6d, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6b, + 0x65, 0x52, 0x08, 0x6d, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x3a, 0x22, 0xe8, 0xa0, 0x1f, + 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x19, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, + 0x2f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, + 0xab, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x42, 0x0b, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xa2, 0x02, + 0x03, 0x50, 0x47, 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x5c, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -449,14 +546,16 @@ func file_poktroll_gateway_params_proto_rawDescGZIP() []byte { var file_poktroll_gateway_params_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_poktroll_gateway_params_proto_goTypes = []interface{}{ - (*Params)(nil), // 0: poktroll.gateway.Params + (*Params)(nil), // 0: poktroll.gateway.Params + (*v1beta1.Coin)(nil), // 1: cosmos.base.v1beta1.Coin } var file_poktroll_gateway_params_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: poktroll.gateway.Params.min_stake:type_name -> cosmos.base.v1beta1.Coin + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_poktroll_gateway_params_proto_init() } diff --git a/api/poktroll/gateway/tx.pulsar.go b/api/poktroll/gateway/tx.pulsar.go index b1e7190da..ab91c6084 100644 --- a/api/poktroll/gateway/tx.pulsar.go +++ b/api/poktroll/gateway/tx.pulsar.go @@ -2586,7 +2586,7 @@ var ( md_MsgUpdateParam protoreflect.MessageDescriptor fd_MsgUpdateParam_authority protoreflect.FieldDescriptor fd_MsgUpdateParam_name protoreflect.FieldDescriptor - fd_MsgUpdateParam_as_type protoreflect.FieldDescriptor + fd_MsgUpdateParam_as_coin protoreflect.FieldDescriptor ) func init() { @@ -2594,7 +2594,7 @@ func init() { md_MsgUpdateParam = File_poktroll_gateway_tx_proto.Messages().ByName("MsgUpdateParam") fd_MsgUpdateParam_authority = md_MsgUpdateParam.Fields().ByName("authority") fd_MsgUpdateParam_name = md_MsgUpdateParam.Fields().ByName("name") - fd_MsgUpdateParam_as_type = md_MsgUpdateParam.Fields().ByName("as_type") + fd_MsgUpdateParam_as_coin = md_MsgUpdateParam.Fields().ByName("as_coin") } var _ protoreflect.Message = (*fastReflection_MsgUpdateParam)(nil) @@ -2674,10 +2674,14 @@ func (x *fastReflection_MsgUpdateParam) Range(f func(protoreflect.FieldDescripto return } } - if x.AsType != "" { - value := protoreflect.ValueOfString(x.AsType) - if !f(fd_MsgUpdateParam_as_type, value) { - return + if x.AsType != nil { + switch o := x.AsType.(type) { + case *MsgUpdateParam_AsCoin: + v := o.AsCoin + value := protoreflect.ValueOfMessage(v.ProtoReflect()) + if !f(fd_MsgUpdateParam_as_coin, value) { + return + } } } } @@ -2699,8 +2703,14 @@ func (x *fastReflection_MsgUpdateParam) Has(fd protoreflect.FieldDescriptor) boo return x.Authority != "" case "poktroll.gateway.MsgUpdateParam.name": return x.Name != "" - case "poktroll.gateway.MsgUpdateParam.as_type": - return x.AsType != "" + case "poktroll.gateway.MsgUpdateParam.as_coin": + if x.AsType == nil { + return false + } else if _, ok := x.AsType.(*MsgUpdateParam_AsCoin); ok { + return true + } else { + return false + } default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.MsgUpdateParam")) @@ -2721,8 +2731,8 @@ func (x *fastReflection_MsgUpdateParam) Clear(fd protoreflect.FieldDescriptor) { x.Authority = "" case "poktroll.gateway.MsgUpdateParam.name": x.Name = "" - case "poktroll.gateway.MsgUpdateParam.as_type": - x.AsType = "" + case "poktroll.gateway.MsgUpdateParam.as_coin": + x.AsType = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.MsgUpdateParam")) @@ -2745,9 +2755,14 @@ func (x *fastReflection_MsgUpdateParam) Get(descriptor protoreflect.FieldDescrip case "poktroll.gateway.MsgUpdateParam.name": value := x.Name return protoreflect.ValueOfString(value) - case "poktroll.gateway.MsgUpdateParam.as_type": - value := x.AsType - return protoreflect.ValueOfString(value) + case "poktroll.gateway.MsgUpdateParam.as_coin": + if x.AsType == nil { + return protoreflect.ValueOfMessage((*v1beta1.Coin)(nil).ProtoReflect()) + } else if v, ok := x.AsType.(*MsgUpdateParam_AsCoin); ok { + return protoreflect.ValueOfMessage(v.AsCoin.ProtoReflect()) + } else { + return protoreflect.ValueOfMessage((*v1beta1.Coin)(nil).ProtoReflect()) + } default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.MsgUpdateParam")) @@ -2772,8 +2787,9 @@ func (x *fastReflection_MsgUpdateParam) Set(fd protoreflect.FieldDescriptor, val x.Authority = value.Interface().(string) case "poktroll.gateway.MsgUpdateParam.name": x.Name = value.Interface().(string) - case "poktroll.gateway.MsgUpdateParam.as_type": - x.AsType = value.Interface().(string) + case "poktroll.gateway.MsgUpdateParam.as_coin": + cv := value.Message().Interface().(*v1beta1.Coin) + x.AsType = &MsgUpdateParam_AsCoin{AsCoin: cv} default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.MsgUpdateParam")) @@ -2794,12 +2810,26 @@ func (x *fastReflection_MsgUpdateParam) Set(fd protoreflect.FieldDescriptor, val // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgUpdateParam) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "poktroll.gateway.MsgUpdateParam.as_coin": + if x.AsType == nil { + value := &v1beta1.Coin{} + oneofValue := &MsgUpdateParam_AsCoin{AsCoin: value} + x.AsType = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } + switch m := x.AsType.(type) { + case *MsgUpdateParam_AsCoin: + return protoreflect.ValueOfMessage(m.AsCoin.ProtoReflect()) + default: + value := &v1beta1.Coin{} + oneofValue := &MsgUpdateParam_AsCoin{AsCoin: value} + x.AsType = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } case "poktroll.gateway.MsgUpdateParam.authority": panic(fmt.Errorf("field authority of message poktroll.gateway.MsgUpdateParam is not mutable")) case "poktroll.gateway.MsgUpdateParam.name": panic(fmt.Errorf("field name of message poktroll.gateway.MsgUpdateParam is not mutable")) - case "poktroll.gateway.MsgUpdateParam.as_type": - panic(fmt.Errorf("field as_type of message poktroll.gateway.MsgUpdateParam is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.MsgUpdateParam")) @@ -2817,8 +2847,9 @@ func (x *fastReflection_MsgUpdateParam) NewField(fd protoreflect.FieldDescriptor return protoreflect.ValueOfString("") case "poktroll.gateway.MsgUpdateParam.name": return protoreflect.ValueOfString("") - case "poktroll.gateway.MsgUpdateParam.as_type": - return protoreflect.ValueOfString("") + case "poktroll.gateway.MsgUpdateParam.as_coin": + value := &v1beta1.Coin{} + return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.gateway.MsgUpdateParam")) @@ -2832,6 +2863,14 @@ func (x *fastReflection_MsgUpdateParam) NewField(fd protoreflect.FieldDescriptor // It panics if the oneof descriptor does not belong to this message. func (x *fastReflection_MsgUpdateParam) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { + case "poktroll.gateway.MsgUpdateParam.as_type": + if x.AsType == nil { + return nil + } + switch x.AsType.(type) { + case *MsgUpdateParam_AsCoin: + return x.Descriptor().Fields().ByName("as_coin") + } default: panic(fmt.Errorf("%s is not a oneof field in poktroll.gateway.MsgUpdateParam", d.FullName())) } @@ -2896,8 +2935,12 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.AsType) - if l > 0 { + switch x := x.AsType.(type) { + case *MsgUpdateParam_AsCoin: + if x == nil { + break + } + l = options.Size(x.AsCoin) n += 1 + l + runtime.Sov(uint64(l)) } if x.unknownFields != nil { @@ -2929,10 +2972,18 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.AsType) > 0 { - i -= len(x.AsType) - copy(dAtA[i:], x.AsType) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AsType))) + switch x := x.AsType.(type) { + case *MsgUpdateParam_AsCoin: + encoded, err := options.Marshal(x.AsCoin) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) i-- dAtA[i] = 0x1a } @@ -3065,9 +3116,9 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 3: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsType", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsCoin", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -3077,23 +3128,26 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.AsType = string(dAtA[iNdEx:postIndex]) + v := &v1beta1.Coin{} + if err := options.Unmarshal(dAtA[iNdEx:postIndex], v); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + x.AsType = &MsgUpdateParam_AsCoin{v} iNdEx = postIndex default: iNdEx = preIndex @@ -3801,7 +3855,10 @@ type MsgUpdateParam struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - AsType string `protobuf:"bytes,3,opt,name=as_type,json=asType,proto3" json:"as_type,omitempty"` + // Types that are assignable to AsType: + // + // *MsgUpdateParam_AsCoin + AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` } func (x *MsgUpdateParam) Reset() { @@ -3838,13 +3895,30 @@ func (x *MsgUpdateParam) GetName() string { return "" } -func (x *MsgUpdateParam) GetAsType() string { +func (x *MsgUpdateParam) GetAsType() isMsgUpdateParam_AsType { if x != nil { return x.AsType } - return "" + return nil +} + +func (x *MsgUpdateParam) GetAsCoin() *v1beta1.Coin { + if x, ok := x.GetAsType().(*MsgUpdateParam_AsCoin); ok { + return x.AsCoin + } + return nil +} + +type isMsgUpdateParam_AsType interface { + isMsgUpdateParam_AsType() } +type MsgUpdateParam_AsCoin struct { + AsCoin *v1beta1.Coin `protobuf:"bytes,3,opt,name=as_coin,json=asCoin,proto3,oneof"` +} + +func (*MsgUpdateParam_AsCoin) isMsgUpdateParam_AsType() {} + type MsgUpdateParamResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -3931,56 +4005,60 @@ var file_poktroll_gateway_tx_proto_rawDesc = []byte{ 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x0c, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x1b, 0x0a, 0x19, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x47, 0x61, - 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x85, 0x01, + 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xba, 0x01, 0x0a, 0x0e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, - 0x61, 0x73, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, - 0x73, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x0e, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x4a, 0x0a, 0x16, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x30, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, - 0x61, 0x79, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x32, 0x87, 0x03, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5c, 0x0a, 0x0c, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x21, 0x2e, 0x70, 0x6f, 0x6b, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x4d, 0x73, 0x67, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x29, 0x2e, 0x70, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x41, 0x0a, 0x07, + 0x61, 0x73, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x0b, 0xea, 0xde, 0x1f, 0x07, 0x61, 0x73, + 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x48, 0x00, 0x52, 0x06, 0x61, 0x73, 0x43, 0x6f, 0x69, 0x6e, 0x3a, + 0x0e, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x42, + 0x09, 0x0a, 0x07, 0x61, 0x73, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0x4a, 0x0a, 0x16, 0x4d, 0x73, + 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, + 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x06, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0x87, 0x03, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5c, + 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x21, + 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, + 0x79, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x1a, 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, + 0x65, 0x77, 0x61, 0x79, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x0c, + 0x53, 0x74, 0x61, 0x6b, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x21, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, - 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x6b, 0x65, - 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x21, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x74, - 0x61, 0x6b, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x1a, 0x29, 0x2e, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x4d, 0x73, - 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x0e, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, - 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x23, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x6e, - 0x73, 0x74, 0x61, 0x6b, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x1a, 0x2b, 0x2e, 0x70, + 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x1a, + 0x29, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, + 0x61, 0x79, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, + 0x61, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x0e, 0x55, 0x6e, + 0x73, 0x74, 0x61, 0x6b, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x23, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, - 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x0b, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x20, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x4d, 0x73, 0x67, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x1a, 0x28, 0x2e, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x4d, 0x73, - 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xa7, 0x01, 0xd8, 0xe2, - 0x1e, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, - 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x67, - 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xa2, 0x02, 0x03, 0x50, 0x47, 0x58, 0xaa, 0x02, 0x10, 0x50, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xca, - 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x47, 0x61, 0x74, 0x65, 0x77, - 0x61, 0x79, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x47, 0x61, - 0x74, 0x65, 0x77, 0x61, 0x79, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x47, 0x61, - 0x74, 0x65, 0x77, 0x61, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x79, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, + 0x65, 0x77, 0x61, 0x79, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x47, + 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, + 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x20, 0x2e, + 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, + 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x1a, + 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, + 0x61, 0x79, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, + 0x42, 0xa7, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x42, 0x07, 0x54, + 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xa2, 0x02, 0x03, 0x50, 0x47, + 0x58, 0xaa, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x47, 0x61, 0x74, + 0x65, 0x77, 0x61, 0x79, 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, + 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x5c, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, + 0x6c, 0x3a, 0x3a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -4013,20 +4091,21 @@ var file_poktroll_gateway_tx_proto_depIdxs = []int32{ 8, // 0: poktroll.gateway.MsgUpdateParams.params:type_name -> poktroll.gateway.Params 9, // 1: poktroll.gateway.MsgStakeGateway.stake:type_name -> cosmos.base.v1beta1.Coin 10, // 2: poktroll.gateway.MsgStakeGatewayResponse.gateway:type_name -> poktroll.gateway.Gateway - 8, // 3: poktroll.gateway.MsgUpdateParamResponse.params:type_name -> poktroll.gateway.Params - 0, // 4: poktroll.gateway.Msg.UpdateParams:input_type -> poktroll.gateway.MsgUpdateParams - 2, // 5: poktroll.gateway.Msg.StakeGateway:input_type -> poktroll.gateway.MsgStakeGateway - 4, // 6: poktroll.gateway.Msg.UnstakeGateway:input_type -> poktroll.gateway.MsgUnstakeGateway - 6, // 7: poktroll.gateway.Msg.UpdateParam:input_type -> poktroll.gateway.MsgUpdateParam - 1, // 8: poktroll.gateway.Msg.UpdateParams:output_type -> poktroll.gateway.MsgUpdateParamsResponse - 3, // 9: poktroll.gateway.Msg.StakeGateway:output_type -> poktroll.gateway.MsgStakeGatewayResponse - 5, // 10: poktroll.gateway.Msg.UnstakeGateway:output_type -> poktroll.gateway.MsgUnstakeGatewayResponse - 7, // 11: poktroll.gateway.Msg.UpdateParam:output_type -> poktroll.gateway.MsgUpdateParamResponse - 8, // [8:12] is the sub-list for method output_type - 4, // [4:8] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 9, // 3: poktroll.gateway.MsgUpdateParam.as_coin:type_name -> cosmos.base.v1beta1.Coin + 8, // 4: poktroll.gateway.MsgUpdateParamResponse.params:type_name -> poktroll.gateway.Params + 0, // 5: poktroll.gateway.Msg.UpdateParams:input_type -> poktroll.gateway.MsgUpdateParams + 2, // 6: poktroll.gateway.Msg.StakeGateway:input_type -> poktroll.gateway.MsgStakeGateway + 4, // 7: poktroll.gateway.Msg.UnstakeGateway:input_type -> poktroll.gateway.MsgUnstakeGateway + 6, // 8: poktroll.gateway.Msg.UpdateParam:input_type -> poktroll.gateway.MsgUpdateParam + 1, // 9: poktroll.gateway.Msg.UpdateParams:output_type -> poktroll.gateway.MsgUpdateParamsResponse + 3, // 10: poktroll.gateway.Msg.StakeGateway:output_type -> poktroll.gateway.MsgStakeGatewayResponse + 5, // 11: poktroll.gateway.Msg.UnstakeGateway:output_type -> poktroll.gateway.MsgUnstakeGatewayResponse + 7, // 12: poktroll.gateway.Msg.UpdateParam:output_type -> poktroll.gateway.MsgUpdateParamResponse + 9, // [9:13] is the sub-list for method output_type + 5, // [5:9] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_poktroll_gateway_tx_proto_init() } @@ -4134,6 +4213,9 @@ func file_poktroll_gateway_tx_proto_init() { } } } + file_poktroll_gateway_tx_proto_msgTypes[6].OneofWrappers = []interface{}{ + (*MsgUpdateParam_AsCoin)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/config.yml b/config.yml index 4c5215779..4ec9a33e0 100644 --- a/config.yml +++ b/config.yml @@ -223,6 +223,11 @@ genesis: amount: "1000068" denom: upokt gateway: + params: + # TODO_MAINNET: Determine realistic amount for minimum gateway stake amount. + min_stake: + amount: "1000000" # 1 POKT + denom: upokt gatewayList: - address: pokt15vzxjqklzjtlz7lahe8z2dfe9nm5vxwwmscne4 stake: diff --git a/e2e/tests/parse_params_test.go b/e2e/tests/parse_params_test.go index 43e9fef2b..98ba813d6 100644 --- a/e2e/tests/parse_params_test.go +++ b/e2e/tests/parse_params_test.go @@ -16,6 +16,7 @@ import ( "github.com/pokt-network/poktroll/app/volatile" apptypes "github.com/pokt-network/poktroll/x/application/types" + gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" servicetypes "github.com/pokt-network/poktroll/x/service/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" @@ -94,7 +95,7 @@ func (s *suite) paramsMapToMsgUpdateParams(moduleName string, paramsMap paramsAn msgUpdateParams = s.newAppMsgUpdateParams(paramsMap) case servicetypes.ModuleName: msgUpdateParams = s.newServiceMsgUpdateParams(paramsMap) - // NB: gateway & supplier modules currently have no parameters + // NB: supplier module currently has no parameters default: err := fmt.Errorf("ERROR: unexpected module name %q", moduleName) s.Fatal(err) @@ -388,3 +389,20 @@ func (s *suite) newServiceMsgUpdateParam(authority string, param paramAny) (msg return msg } + +func (s *suite) newGatewayMsgUpdateParam(authority string, param paramAny) (msg proto.Message) { + switch param.typeStr { + case "coin": + msg = proto.Message(&gatewaytypes.MsgUpdateParam{ + Authority: authority, + Name: param.name, + AsType: &gatewaytypes.MsgUpdateParam_AsCoin{ + AsCoin: param.value.(*cosmostypes.Coin), + }, + }) + default: + s.Fatalf("unexpected param type %q for %s module", param.typeStr, tokenomicstypes.ModuleName) + } + + return msg +} diff --git a/makefiles/params.mk b/makefiles/params.mk index 559e0ae4d..03d237e13 100644 --- a/makefiles/params.mk +++ b/makefiles/params.mk @@ -105,6 +105,18 @@ params_update_shared_application_unbonding_period_sessions: ## Update the shared params_update_shared_compute_units_to_tokens_multiplier: ## Update the shared module compute_units_to_tokens_multiplier param poktrolld tx authz exec ./tools/scripts/params/shared_compute_units_to_tokens_multiplier.json $(PARAM_FLAGS) +### Gateway Module Params ### +.PHONY: params_get_gateway +params_get_gateway: ## Get the gateway module params + poktrolld query gateway params --node $(POCKET_NODE) + +.PHONY: params_update_gateway_all +params_update_gateway_all: ## Update the session module params + poktrolld tx authz exec ./tools/scripts/params/gateway_all.json $(PARAM_FLAGS) + +.PHONY: params_update_gateway_min_stake +params_update_gateway_min_stake: ## Update the gateway module min_stake param + poktrolld tx authz exec ./tools/scripts/params/gateway_min_stake.json $(PARAM_FLAGS) .PHONY: params_query_all params_query_all: check_jq ## Query the params from all available modules diff --git a/proto/poktroll/gateway/params.proto b/proto/poktroll/gateway/params.proto index 4b1671aad..2a8290d4c 100644 --- a/proto/poktroll/gateway/params.proto +++ b/proto/poktroll/gateway/params.proto @@ -5,10 +5,14 @@ option go_package = "github.com/pokt-network/poktroll/x/gateway/types"; option (gogoproto.stable_marshaler_all) = true; import "amino/amino.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; // Params defines the parameters for the module. message Params { option (amino.name) = "poktroll/x/gateway/Params"; option (gogoproto.equal) = true; + + // min_stake is the minimum amount of uPOKT that a gateway must stake. + cosmos.base.v1beta1.Coin min_stake = 1 [(gogoproto.jsontag) = "min_stake"]; } diff --git a/proto/poktroll/gateway/tx.proto b/proto/poktroll/gateway/tx.proto index 5f494c1f3..e8a37c698 100644 --- a/proto/poktroll/gateway/tx.proto +++ b/proto/poktroll/gateway/tx.proto @@ -70,7 +70,9 @@ message MsgUpdateParam { string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; string name = 2; - string as_type = 3; + oneof as_type { + cosmos.base.v1beta1.Coin as_coin = 3 [(gogoproto.jsontag) = "as_coin"]; + } } message MsgUpdateParamResponse { diff --git a/testutil/integration/suites/param_configs.go b/testutil/integration/suites/param_configs.go index 2e95a7c41..5141554d2 100644 --- a/testutil/integration/suites/param_configs.go +++ b/testutil/integration/suites/param_configs.go @@ -16,12 +16,60 @@ import ( tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) +// ParamType is a type alias for a module parameter type. It is the string that +// is returned when calling reflect.Value#Type()#Name() on a module parameter. +type ParamType = string + +const ( + ParamTypeInt64 ParamType = "int64" + ParamTypeUint64 ParamType = "uint64" + ParamTypeFloat32 ParamType = "float32" + ParamTypeString ParamType = "string" + ParamTypeBytes ParamType = "uint8" + ParamTypeCoin ParamType = "Coin" +) + +// ModuleParamConfig holds type information about a module's parameters update +// message(s) along with default and valid non-default values and a query constructor +// function for the module. It is used by ParamsSuite to construct and send +// parameter update messages and assert on their results. +type ModuleParamConfig struct { + ParamsMsgs ModuleParamsMessages + // ParamTypes is a map of parameter types to their respective MsgUpdateParam_As* + // types which satisfy the oneof for the MsgUpdateParam#AsType field. Each AsType + // type which the module supports should be included in this map. + ParamTypes map[ParamType]any + // ValidParams is a set of parameters which are expected to be valid when used + // together AND when used individually, where the renaming parameters are set + // to their default values. + ValidParams any + DefaultParams any + NewParamClientFn any +} + +// ModuleParamsMessages holds a reference to each of the params-related message +// types for a given module. The values are only used for their type information +// which is obtained via reflection. The values are not used for their actual +// message contents and MAY be the zero value. +// If MsgUpdateParam is omitted (i.e. nil), ParamsSuite will assume that +// this module does not support individual parameter updates (i.e. MsgUpdateParam). +// In this case, MsgUpdateParamResponse SHOULD also be omitted. +type ModuleParamsMessages struct { + MsgUpdateParams any + MsgUpdateParamsResponse any + MsgUpdateParam any + MsgUpdateParamResponse any + QueryParamsRequest any + QueryParamsResponse any +} + var ( ValidAddServiceFeeCoin = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 1000000001) ValidProofMissingPenaltyCoin = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 500) ValidProofSubmissionFeeCoin = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 5000000) ValidProofRequirementThresholdCoin = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 100) ValidRelayDifficultyTargetHash, _ = hex.DecodeString("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff") + ValidActorMinStake = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 100) SharedModuleParamConfig = ModuleParamConfig{ ParamsMsgs: ModuleParamsMessages{ @@ -102,10 +150,17 @@ var ( ParamsMsgs: ModuleParamsMessages{ MsgUpdateParams: gatewaytypes.MsgUpdateParams{}, MsgUpdateParamsResponse: gatewaytypes.MsgUpdateParamsResponse{}, + MsgUpdateParam: gatewaytypes.MsgUpdateParam{}, + MsgUpdateParamResponse: gatewaytypes.MsgUpdateParamResponse{}, QueryParamsRequest: gatewaytypes.QueryParamsRequest{}, QueryParamsResponse: gatewaytypes.QueryParamsResponse{}, }, - ValidParams: gatewaytypes.Params{}, + ValidParams: gatewaytypes.Params{ + MinStake: &ValidActorMinStake, + }, + ParamTypes: map[ParamType]any{ + ParamTypeCoin: gatewaytypes.MsgUpdateParam_AsCoin{}, + }, DefaultParams: gatewaytypes.DefaultParams(), NewParamClientFn: gatewaytypes.NewQueryClient, } diff --git a/testutil/integration/suites/update_params.go b/testutil/integration/suites/update_params.go index 8841a7e6f..f7db56aeb 100644 --- a/testutil/integration/suites/update_params.go +++ b/testutil/integration/suites/update_params.go @@ -1,7 +1,10 @@ package suites import ( + "os" + "path/filepath" "reflect" + "strings" "testing" cosmostypes "github.com/cosmos/cosmos-sdk/types" @@ -19,58 +22,11 @@ import ( tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) -// ParamType is a type alias for a module parameter type. It is the string that -// is returned when calling reflect.Value#Type()#Name() on a module parameter. -type ParamType = string - -const ( - ParamTypeInt64 ParamType = "int64" - ParamTypeUint64 ParamType = "uint64" - ParamTypeFloat32 ParamType = "float32" - ParamTypeString ParamType = "string" - ParamTypeBytes ParamType = "uint8" - ParamTypeCoin ParamType = "Coin" -) - const ( MsgUpdateParamsName = "MsgUpdateParams" MsgUpdateParamName = "MsgUpdateParam" ) -// ModuleParamConfig holds type information about a module's parameters update -// message(s) along with default and valid non-default values and a query constructor -// function for the module. It is used by ParamsSuite to construct and send -// parameter update messages and assert on their results. -type ModuleParamConfig struct { - ParamsMsgs ModuleParamsMessages - // ParamTypes is a map of parameter types to their respective MsgUpdateParam_As* - // types which satisfy the oneof for the MsgUpdateParam#AsType field. Each AsType - // type which the module supports should be included in this map. - ParamTypes map[ParamType]any - // ValidParams is a set of parameters which are expected to be valid when used - // together AND when used individually, where the reamining parameters are set - // to their default values. - ValidParams any - DefaultParams any - NewParamClientFn any -} - -// ModuleParamsMessages holds a reference to each of the params-related message -// types for a given module. The values are only used for their type information -// which is obtained via reflection. The values are not used for their actual -// message contents and MAY be the zero value. -// If MsgUpdateParam is omitted (i.e. nil), ParamsSuite will assume that -// this module does not support individual parameter updates (i.e. MsgUpdateParam). -// In this case, MsgUpdateParamResponse SHOULD also be omitted. -type ModuleParamsMessages struct { - MsgUpdateParams any - MsgUpdateParamsResponse any - MsgUpdateParam any - MsgUpdateParamResponse any - QueryParamsRequest any - QueryParamsResponse any -} - var ( // MsgUpdateParamEnabledModuleNames is a list of module names which support // individual parameter updates (i.e. MsgUpdateParam). It is initialized in @@ -91,15 +47,28 @@ var ( tokenomicstypes.ModuleName: TokenomicsModuleParamConfig, } - _ IntegrationSuite = (*ParamsSuite)(nil) + // paramConfigsPath is the path, relative to the project root, to the go file + // containing the ModuleParamConfig declaration. It is set in init() and is + // interpolated into error messages when a module's ModuleParamConfig seems + // misconfigured (e.g. missing expected values). + paramConfigsPath string ) +var _ IntegrationSuite = (*ParamsSuite)(nil) + func init() { for moduleName, moduleParamCfg := range ModuleParamConfigMap { if moduleParamCfg.ParamsMsgs.MsgUpdateParam != nil { MsgUpdateParamEnabledModuleNames = append(MsgUpdateParamEnabledModuleNames, moduleName) } } + + // Take the package path of the ModuleParamConfig type and drop the github.com// prefix. + paramConfigsPkgPath := reflect.TypeOf(ModuleParamConfig{}).PkgPath() + paramConfigsPathParts := strings.Split(paramConfigsPkgPath, string(os.PathSeparator)) + paramConfigsDir := filepath.Join(paramConfigsPathParts[3:]...) + // NB: The file name is not included in the package path and must be updated here if it changes. + paramConfigsPath = filepath.Join(paramConfigsDir, "param_configs.go") } // ParamsSuite is an integration test suite that provides helper functions for @@ -266,7 +235,11 @@ func (s *ParamsSuite) RunUpdateParamAsSigner( msgUpdateParamValue.Elem().FieldByName("Name").SetString(cases.ToSnakeCase(paramName)) - msgAsTypeStruct := moduleCfg.ParamTypes[paramType] + msgAsTypeStruct, hasParamType := moduleCfg.ParamTypes[paramType] + require.Truef(t, hasParamType, + "module %q does not include param type %q in its ModuleParamConfig#ParamTypes; consider updating %s", + moduleName, paramType, paramConfigsPath, + ) msgAsTypeType := reflect.TypeOf(msgAsTypeStruct) msgAsTypeValue := reflect.New(msgAsTypeType) switch paramType { diff --git a/tools/scripts/authz/dao_genesis_authorizations.json b/tools/scripts/authz/dao_genesis_authorizations.json index 9bc539937..3eead39e5 100644 --- a/tools/scripts/authz/dao_genesis_authorizations.json +++ b/tools/scripts/authz/dao_genesis_authorizations.json @@ -143,6 +143,15 @@ }, "expiration": "2500-01-01T00:00:00Z" }, + { + "granter": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "grantee": "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw", + "authorization": { + "@type": "\/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "\/poktroll.gateway.MsgUpdateParam" + }, + "expiration": "2500-01-01T00:00:00Z" + }, { "granter": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "grantee": "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw", diff --git a/tools/scripts/params/tokenomics_all.json b/tools/scripts/params/gateway_all.json similarity index 50% rename from tools/scripts/params/tokenomics_all.json rename to tools/scripts/params/gateway_all.json index 4194f89d0..83ae4f2dd 100644 --- a/tools/scripts/params/tokenomics_all.json +++ b/tools/scripts/params/gateway_all.json @@ -2,10 +2,13 @@ "body": { "messages": [ { - "@type": "/poktroll.tokenomics.MsgUpdateParams", + "@type": "/poktroll.gateway.MsgUpdateParams", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "params": { - "compute_units_to_tokens_multiplier": "42" + "min_stake": { + "amount": "1000000", + "denom": "upokt" + } } } ] diff --git a/tools/scripts/params/gateway_min_stake.json b/tools/scripts/params/gateway_min_stake.json new file mode 100644 index 000000000..0d6d10347 --- /dev/null +++ b/tools/scripts/params/gateway_min_stake.json @@ -0,0 +1,15 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.gateway.MsgUpdateParam", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "name": "min_stake", + "as_coin": { + "amount": "1000000", + "denom": "upokt" + } + } + ] + } +} diff --git a/tools/scripts/params/tokenomics_compute_units_to_tokens_multiplier.json b/tools/scripts/params/tokenomics_compute_units_to_tokens_multiplier.json deleted file mode 100644 index 363bb1350..000000000 --- a/tools/scripts/params/tokenomics_compute_units_to_tokens_multiplier.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/poktroll.tokenomics.MsgUpdateParam", - "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", - "name": "compute_units_to_tokens_multiplier", - "as_int64": "42" - } - ] - } -} diff --git a/x/gateway/keeper/msg_server_update_param.go b/x/gateway/keeper/msg_server_update_param.go index 3315a0804..f1cf6fbe7 100644 --- a/x/gateway/keeper/msg_server_update_param.go +++ b/x/gateway/keeper/msg_server_update_param.go @@ -2,17 +2,64 @@ package keeper import ( "context" + "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/pokt-network/poktroll/x/gateway/types" ) -func (k msgServer) UpdateParam(goCtx context.Context, msg *types.MsgUpdateParam) (*types.MsgUpdateParamResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) +// UpdateParam updates a single parameter in the proof module and returns +// all active parameters. +func (k msgServer) UpdateParam(ctx context.Context, msg *types.MsgUpdateParam) (*types.MsgUpdateParamResponse, error) { + logger := k.logger.With( + "method", "UpdateParam", + "param_name", msg.Name, + ) - // TODO: Handling the message - _ = ctx + if err := msg.ValidateBasic(); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } - return &types.MsgUpdateParamResponse{}, nil + if k.GetAuthority() != msg.Authority { + return nil, status.Error( + codes.InvalidArgument, + types.ErrGatewayInvalidSigner.Wrapf( + "invalid authority; expected %s, got %s", + k.GetAuthority(), msg.Authority, + ).Error(), + ) + } + + params := k.GetParams(ctx) + + switch msg.Name { + case types.ParamMinStake: + logger = logger.With("param_value", msg.GetAsCoin()) + params.MinStake = msg.GetAsCoin() + default: + return nil, status.Error( + codes.InvalidArgument, + types.ErrGatewayParamInvalid.Wrapf("unsupported param %q", msg.Name).Error(), + ) + } + + // Perform a global validation on all params, which includes the updated param. + // This is needed to ensure that the updated param is valid in the context of all other params. + if err := params.Validate(); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if err := k.SetParams(ctx, params); err != nil { + err = fmt.Errorf("unable to set params: %w", err) + logger.Error(err.Error()) + return nil, status.Error(codes.Internal, err.Error()) + } + + updatedParams := k.GetParams(ctx) + + return &types.MsgUpdateParamResponse{ + Params: &updatedParams, + }, nil } diff --git a/x/gateway/keeper/msg_server_update_param_test.go b/x/gateway/keeper/msg_server_update_param_test.go new file mode 100644 index 000000000..84f61086c --- /dev/null +++ b/x/gateway/keeper/msg_server_update_param_test.go @@ -0,0 +1,41 @@ +package keeper_test + +import ( + "testing" + + cosmostypes "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/app/volatile" + testkeeper "github.com/pokt-network/poktroll/testutil/keeper" + gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" +) + +func TestMsgUpdateParam_UpdateMinStakeOnly(t *testing.T) { + expectedMinStake := cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 420) + + // Set the parameters to their default values + k, msgSrv, ctx := setupMsgServer(t) + defaultParams := gatewaytypes.DefaultParams() + require.NoError(t, k.SetParams(ctx, defaultParams)) + + // Ensure the default values are different from the new values we want to set + require.NotEqual(t, expectedMinStake, defaultParams.MinStake) + + // Update the min relay difficulty bits + updateParamMsg := &gatewaytypes.MsgUpdateParam{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Name: gatewaytypes.ParamMinStake, + AsType: &gatewaytypes.MsgUpdateParam_AsCoin{AsCoin: &expectedMinStake}, + } + res, err := msgSrv.UpdateParam(ctx, updateParamMsg) + require.NoError(t, err) + + require.NotEqual(t, defaultParams.MinStake, res.Params.MinStake) + require.Equal(t, expectedMinStake.Amount, res.Params.MinStake.Amount) + + // Ensure the other parameters are unchanged + testkeeper.AssertDefaultParamsEqualExceptFields(t, &defaultParams, res.Params, string(gatewaytypes.KeyMinStake)) +} diff --git a/x/gateway/keeper/msg_update_params_test.go b/x/gateway/keeper/msg_update_params_test.go index 7fb8ab31e..400aeb7c0 100644 --- a/x/gateway/keeper/msg_update_params_test.go +++ b/x/gateway/keeper/msg_update_params_test.go @@ -5,24 +5,24 @@ import ( "github.com/stretchr/testify/require" - "github.com/pokt-network/poktroll/x/gateway/types" + gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" ) func TestMsgUpdateParams(t *testing.T) { k, ms, ctx := setupMsgServer(t) - params := types.DefaultParams() + params := gatewaytypes.DefaultParams() require.NoError(t, k.SetParams(ctx, params)) // default params tests := []struct { desc string - input *types.MsgUpdateParams + input *gatewaytypes.MsgUpdateParams shouldError bool expectedErrMsg string }{ { desc: "invalid: authority address invalid", - input: &types.MsgUpdateParams{ + input: &gatewaytypes.MsgUpdateParams{ Authority: "invalid", Params: params, }, @@ -30,16 +30,26 @@ func TestMsgUpdateParams(t *testing.T) { expectedErrMsg: "invalid authority", }, { - desc: "send empty params", - input: &types.MsgUpdateParams{ + desc: "invalid: send empty params", + input: &gatewaytypes.MsgUpdateParams{ Authority: k.GetAuthority(), - Params: types.Params{}, + Params: gatewaytypes.Params{}, + }, + shouldError: true, + }, + { + desc: "valid: send minimal params", + input: &gatewaytypes.MsgUpdateParams{ + Authority: k.GetAuthority(), + Params: gatewaytypes.Params{ + MinStake: &gatewaytypes.DefaultMinStake, + }, }, shouldError: false, }, { desc: "valid: send default params", - input: &types.MsgUpdateParams{ + input: &gatewaytypes.MsgUpdateParams{ Authority: k.GetAuthority(), Params: params, }, diff --git a/x/gateway/keeper/params_test.go b/x/gateway/keeper/params_test.go index 27bf9d53d..fce11d4e1 100644 --- a/x/gateway/keeper/params_test.go +++ b/x/gateway/keeper/params_test.go @@ -3,10 +3,14 @@ package keeper_test import ( "testing" + "cosmossdk.io/math" + cosmostypes "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/pokt-network/poktroll/app/volatile" testkeeper "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/x/gateway/types" + gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" ) func TestGetParams(t *testing.T) { @@ -16,3 +20,41 @@ func TestGetParams(t *testing.T) { require.NoError(t, k.SetParams(ctx, params)) require.EqualValues(t, params, k.GetParams(ctx)) } + +func TestParams_ValidateMinStake(t *testing.T) { + tests := []struct { + desc string + minStake any + expectedErr error + }{ + { + desc: "invalid type", + minStake: int64(-1), + expectedErr: gatewaytypes.ErrGatewayParamInvalid.Wrapf("invalid type for %s: int64; expected *cosmostypes.Coin", gatewaytypes.ParamMinStake), + }, + { + desc: "MinStake less than zero", + minStake: &cosmostypes.Coin{ + Denom: volatile.DenomuPOKT, + Amount: math.NewInt(-1), + }, + expectedErr: gatewaytypes.ErrGatewayParamInvalid.Wrapf("min stake amount must be greater than zero: -1%s", volatile.DenomuPOKT), + }, + { + desc: "valid MinStake", + minStake: &gatewaytypes.DefaultMinStake, + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + err := gatewaytypes.ValidateMinStake(tt.minStake) + if tt.expectedErr != nil { + require.Error(t, err) + require.Contains(t, err.Error(), tt.expectedErr.Error()) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/gateway/types/errors.go b/x/gateway/types/errors.go index 54bf3f388..6dc182445 100644 --- a/x/gateway/types/errors.go +++ b/x/gateway/types/errors.go @@ -11,4 +11,5 @@ var ( ErrGatewayInvalidStake = sdkerrors.Register(ModuleName, 1102, "invalid gateway stake") ErrGatewayUnauthorized = sdkerrors.Register(ModuleName, 1103, "unauthorized signer") ErrGatewayNotFound = sdkerrors.Register(ModuleName, 1104, "gateway not found") + ErrGatewayParamInvalid = sdkerrors.Register(ModuleName, 1105, "the provided param is invalid") ) diff --git a/x/gateway/types/genesis_test.go b/x/gateway/types/genesis_test.go index 357176de1..d7dbf5b60 100644 --- a/x/gateway/types/genesis_test.go +++ b/x/gateway/types/genesis_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/testutil/sample" - "github.com/pokt-network/poktroll/x/gateway/types" + gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" ) func TestGenesisState_Validate(t *testing.T) { @@ -20,18 +20,19 @@ func TestGenesisState_Validate(t *testing.T) { tests := []struct { desc string - genState *types.GenesisState + genState *gatewaytypes.GenesisState valid bool }{ { desc: "default is valid", - genState: types.DefaultGenesis(), + genState: gatewaytypes.DefaultGenesis(), valid: true, }, { desc: "valid genesis state", - genState: &types.GenesisState{ - GatewayList: []types.Gateway{ + genState: &gatewaytypes.GenesisState{ + Params: gatewaytypes.DefaultParams(), + GatewayList: []gatewaytypes.Gateway{ { Address: addr1, Stake: &stake1, @@ -41,14 +42,14 @@ func TestGenesisState_Validate(t *testing.T) { Stake: &stake2, }, }, - // this line is used by starport scaffolding # types/genesis/validField + // this line is used by starport scaffolding # gatewaytypes/genesis/validField }, valid: true, }, { desc: "invalid - duplicated gateway address", - genState: &types.GenesisState{ - GatewayList: []types.Gateway{ + genState: &gatewaytypes.GenesisState{ + GatewayList: []gatewaytypes.Gateway{ { Address: addr1, Stake: &stake1, @@ -63,8 +64,8 @@ func TestGenesisState_Validate(t *testing.T) { }, { desc: "invalid - nil gateway stake", - genState: &types.GenesisState{ - GatewayList: []types.Gateway{ + genState: &gatewaytypes.GenesisState{ + GatewayList: []gatewaytypes.Gateway{ { Address: addr1, Stake: &stake1, @@ -79,8 +80,8 @@ func TestGenesisState_Validate(t *testing.T) { }, { desc: "invalid - missing gateway stake", - genState: &types.GenesisState{ - GatewayList: []types.Gateway{ + genState: &gatewaytypes.GenesisState{ + GatewayList: []gatewaytypes.Gateway{ { Address: addr1, Stake: &stake1, @@ -95,8 +96,8 @@ func TestGenesisState_Validate(t *testing.T) { }, { desc: "invalid - zero gateway stake", - genState: &types.GenesisState{ - GatewayList: []types.Gateway{ + genState: &gatewaytypes.GenesisState{ + GatewayList: []gatewaytypes.Gateway{ { Address: addr1, Stake: &stake1, @@ -111,8 +112,8 @@ func TestGenesisState_Validate(t *testing.T) { }, { desc: "invalid - negative gateway stake", - genState: &types.GenesisState{ - GatewayList: []types.Gateway{ + genState: &gatewaytypes.GenesisState{ + GatewayList: []gatewaytypes.Gateway{ { Address: addr1, Stake: &stake1, @@ -127,8 +128,8 @@ func TestGenesisState_Validate(t *testing.T) { }, { desc: "invalid - wrong stake denom", - genState: &types.GenesisState{ - GatewayList: []types.Gateway{ + genState: &gatewaytypes.GenesisState{ + GatewayList: []gatewaytypes.Gateway{ { Address: addr1, Stake: &stake1, @@ -143,8 +144,8 @@ func TestGenesisState_Validate(t *testing.T) { }, { desc: "invalid - missing denom", - genState: &types.GenesisState{ - GatewayList: []types.Gateway{ + genState: &gatewaytypes.GenesisState{ + GatewayList: []gatewaytypes.Gateway{ { Address: addr1, Stake: &stake1, @@ -157,7 +158,7 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, - // this line is used by starport scaffolding # types/genesis/testcase + // this line is used by starport scaffolding # gatewaytypes/genesis/testcase } for _, test := range tests { t.Run(test.desc, func(t *testing.T) { diff --git a/x/gateway/types/message_update_param.go b/x/gateway/types/message_update_param.go index d5e798ef8..9e7ff407e 100644 --- a/x/gateway/types/message_update_param.go +++ b/x/gateway/types/message_update_param.go @@ -1,6 +1,8 @@ package types import ( + "fmt" + errorsmod "cosmossdk.io/errors" cosmostypes "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -8,11 +10,20 @@ import ( var _ cosmostypes.Msg = (*MsgUpdateParam)(nil) -func NewMsgUpdateParam(authority string, name string, asType string) *MsgUpdateParam { +func NewMsgUpdateParam(authority string, name string, asType any) *MsgUpdateParam { + var asTypeIface isMsgUpdateParam_AsType + + switch t := asType.(type) { + case *cosmostypes.Coin: + asTypeIface = &MsgUpdateParam_AsCoin{AsCoin: t} + default: + panic(fmt.Sprintf("unexpected param value type: %T", asType)) + } + return &MsgUpdateParam{ Authority: authority, Name: name, - AsType: asType, + AsType: asTypeIface, } } @@ -21,5 +32,32 @@ func (msg *MsgUpdateParam) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address (%s)", err) } + + // Parameter value cannot be nil. + if msg.AsType == nil { + return ErrGatewayParamInvalid.Wrap("missing param AsType") + } + + // Parameter name must be supported by this module. + switch msg.Name { + case ParamMinStake: + if err := msg.paramTypeIsCoin(); err != nil { + return err + } + return ValidateMinStake(msg.GetAsCoin()) + default: + return ErrGatewayParamInvalid.Wrapf("unsupported param %q", msg.Name) + } +} + +func (msg *MsgUpdateParam) paramTypeIsCoin() error { + _, ok := msg.AsType.(*MsgUpdateParam_AsCoin) + if !ok { + return ErrGatewayParamInvalid.Wrapf( + "invalid type for param %q expected %T type: %T", + msg.Name, &MsgUpdateParam_AsCoin{}, msg.AsType, + ) + } + return nil } diff --git a/x/gateway/types/message_update_param_test.go b/x/gateway/types/message_update_param_test.go index 892ec6878..84530f9e8 100644 --- a/x/gateway/types/message_update_param_test.go +++ b/x/gateway/types/message_update_param_test.go @@ -4,34 +4,48 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/pokt-network/poktroll/testutil/sample" "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/testutil/sample" ) func TestMsgUpdateParam_ValidateBasic(t *testing.T) { tests := []struct { - name string - msg MsgUpdateParam - err error + name string + msg MsgUpdateParam + expectedErr error }{ { - name: "invalid address", + name: "invalid: authority address invalid", msg: MsgUpdateParam{ Authority: "invalid_address", + Name: "", // Doesn't matter for this test + AsType: &MsgUpdateParam_AsCoin{AsCoin: &DefaultMinStake}, + }, + expectedErr: sdkerrors.ErrInvalidAddress, + }, { + name: "invalid: param name incorrect (non-existent)", + msg: MsgUpdateParam{ + Authority: sample.AccAddress(), + Name: "WRONG_relay_difficulty_target_hash", + AsType: &MsgUpdateParam_AsCoin{AsCoin: nil}, }, - err: sdkerrors.ErrInvalidAddress, + + expectedErr: ErrGatewayParamInvalid, }, { - name: "valid address", + name: "valid: correct authority, param name, and type", msg: MsgUpdateParam{ Authority: sample.AccAddress(), + Name: ParamMinStake, + AsType: &MsgUpdateParam_AsCoin{AsCoin: &DefaultMinStake}, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) + if tt.expectedErr != nil { + require.ErrorIs(t, err, tt.expectedErr) return } require.NoError(t, err) diff --git a/x/gateway/types/params.go b/x/gateway/types/params.go index 95b0cf8a2..60e7c43dc 100644 --- a/x/gateway/types/params.go +++ b/x/gateway/types/params.go @@ -1,8 +1,20 @@ package types -import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +import ( + cosmostypes "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -var _ paramtypes.ParamSet = (*Params)(nil) + "github.com/pokt-network/poktroll/app/volatile" +) + +var ( + _ paramtypes.ParamSet = (*Params)(nil) + + // TODO_MAINNET: Determine a sensible default value for the min stake amount. + KeyMinStake = []byte("MinStake") + ParamMinStake = "min_stake" + DefaultMinStake = cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 100) +) // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { @@ -10,21 +22,55 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new Params instance -func NewParams() Params { - return Params{} +func NewParams(minStake *cosmostypes.Coin) Params { + return Params{ + MinStake: minStake, + } } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams() + return NewParams(&DefaultMinStake) } // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair( + KeyMinStake, + &p.MinStake, + ValidateMinStake, + ), + } } // Validate validates the set of params func (p Params) Validate() error { + if err := ValidateMinStake(p.MinStake); err != nil { + return err + } + return nil +} + +func ValidateMinStake(minStakeAny any) error { + minStakeCoin, ok := minStakeAny.(*cosmostypes.Coin) + if !ok { + return ErrGatewayParamInvalid.Wrapf("invalid type for %s: %T; expected *cosmostypes.Coin", ParamMinStake, minStakeAny) + } + + if minStakeCoin == nil { + return ErrGatewayParamInvalid.Wrap("missing min_stake") + } + + if minStakeCoin.Denom != volatile.DenomuPOKT { + return ErrGatewayParamInvalid.Wrapf( + "invalid min_stake denom %q; expected %q", + minStakeCoin.Denom, volatile.DenomuPOKT, + ) + } + if minStakeCoin.IsZero() || minStakeCoin.IsNegative() { + return ErrGatewayParamInvalid.Wrapf("invalid min stake amount must be greater than zero: %s", minStakeCoin) + } + return nil } diff --git a/x/gateway/types/params.pb.go b/x/gateway/types/params.pb.go index ceb9f5ead..c930a8322 100644 --- a/x/gateway/types/params.pb.go +++ b/x/gateway/types/params.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -26,6 +27,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { + // min_stake is the minimum amount of uPOKT that a gateway must stake. + MinStake *types.Coin `protobuf:"bytes,1,opt,name=min_stake,json=minStake,proto3" json:"min_stake"` } func (m *Params) Reset() { *m = Params{} } @@ -57,6 +60,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetMinStake() *types.Coin { + if m != nil { + return m.MinStake + } + return nil +} + func init() { proto.RegisterType((*Params)(nil), "poktroll.gateway.Params") } @@ -64,19 +74,24 @@ func init() { func init() { proto.RegisterFile("poktroll/gateway/params.proto", fileDescriptor_23ed52a392489486) } var fileDescriptor_23ed52a392489486 = []byte{ - // 180 bytes of a gzipped FileDescriptorProto + // 258 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0xc8, 0xcf, 0x2e, 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x4f, 0x4f, 0x2c, 0x49, 0x2d, 0x4f, 0xac, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0x49, 0xeb, 0x41, 0xa5, - 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x91, 0x94, 0x48, 0x7a, 0x7e, - 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x44, 0x95, 0x74, 0xb8, 0xd8, 0x02, 0xc0, 0x46, 0x59, - 0x29, 0xbd, 0x58, 0x20, 0xcf, 0xd8, 0xf5, 0x7c, 0x83, 0x96, 0x24, 0xdc, 0xb2, 0x0a, 0xb8, 0x75, - 0x10, 0x35, 0x4e, 0x7e, 0x27, 0x1e, 0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, 0x30, 0x88, 0x65, 0xa5, 0xf4, 0x62, + 0x81, 0x3c, 0x63, 0xd7, 0xf3, 0x0d, 0x5a, 0x92, 0x70, 0x3f, 0x55, 0xc0, 0x7d, 0x05, 0xb1, 0xca, + 0xc9, 0xef, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x6f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, + 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, + 0x32, 0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x07, 0x99, 0xa1, 0x9b, + 0x97, 0x5a, 0x52, 0x9e, 0x5f, 0x94, 0xad, 0x8f, 0xc5, 0xc0, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, + 0x36, 0xb0, 0x5f, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbc, 0xcb, 0xc3, 0x2b, 0x47, 0x01, + 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -98,6 +113,9 @@ func (this *Params) Equal(that interface{}) bool { } else if this == nil { return false } + if !this.MinStake.Equal(that1.MinStake) { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -120,6 +138,18 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MinStake != nil { + { + size, err := m.MinStake.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 } @@ -140,6 +170,10 @@ func (m *Params) Size() (n int) { } var l int _ = l + if m.MinStake != nil { + l = m.MinStake.Size() + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -178,6 +212,42 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinStake", 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 m.MinStake == nil { + m.MinStake = &types.Coin{} + } + if err := m.MinStake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/gateway/types/tx.pb.go b/x/gateway/types/tx.pb.go index 63c23783d..1de507649 100644 --- a/x/gateway/types/tx.pb.go +++ b/x/gateway/types/tx.pb.go @@ -283,7 +283,10 @@ type MsgUpdateParam struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - AsType string `protobuf:"bytes,3,opt,name=as_type,json=asType,proto3" json:"as_type,omitempty"` + // Types that are valid to be assigned to AsType: + // + // *MsgUpdateParam_AsCoin + AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` } func (m *MsgUpdateParam) Reset() { *m = MsgUpdateParam{} } @@ -315,6 +318,25 @@ func (m *MsgUpdateParam) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParam proto.InternalMessageInfo +type isMsgUpdateParam_AsType interface { + isMsgUpdateParam_AsType() + MarshalTo([]byte) (int, error) + Size() int +} + +type MsgUpdateParam_AsCoin struct { + AsCoin *types.Coin `protobuf:"bytes,3,opt,name=as_coin,json=asCoin,proto3,oneof" json:"as_coin"` +} + +func (*MsgUpdateParam_AsCoin) isMsgUpdateParam_AsType() {} + +func (m *MsgUpdateParam) GetAsType() isMsgUpdateParam_AsType { + if m != nil { + return m.AsType + } + return nil +} + func (m *MsgUpdateParam) GetAuthority() string { if m != nil { return m.Authority @@ -329,11 +351,18 @@ func (m *MsgUpdateParam) GetName() string { return "" } -func (m *MsgUpdateParam) GetAsType() string { - if m != nil { - return m.AsType +func (m *MsgUpdateParam) GetAsCoin() *types.Coin { + if x, ok := m.GetAsType().(*MsgUpdateParam_AsCoin); ok { + return x.AsCoin + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*MsgUpdateParam) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*MsgUpdateParam_AsCoin)(nil), } - return "" } type MsgUpdateParamResponse struct { @@ -390,44 +419,45 @@ func init() { func init() { proto.RegisterFile("poktroll/gateway/tx.proto", fileDescriptor_7ad4b0c5e3b59f23) } var fileDescriptor_7ad4b0c5e3b59f23 = []byte{ - // 589 bytes of a gzipped FileDescriptorProto + // 606 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xbf, 0x6f, 0xd3, 0x4e, - 0x1c, 0xcd, 0x7d, 0xf3, 0x6d, 0xa2, 0x5c, 0xa3, 0x40, 0xad, 0x8a, 0x24, 0x06, 0x4c, 0x30, 0x4b, - 0x08, 0xaa, 0xaf, 0x49, 0x05, 0x43, 0x98, 0x08, 0x03, 0x12, 0x52, 0x2b, 0x94, 0xd2, 0x01, 0x54, - 0xa9, 0xba, 0x24, 0x27, 0xd7, 0x4a, 0xed, 0xb3, 0x7c, 0xd7, 0x1f, 0xd9, 0x10, 0x02, 0x21, 0x31, - 0xf1, 0x67, 0x30, 0x66, 0x60, 0x65, 0xef, 0x58, 0x31, 0x75, 0x42, 0x28, 0x19, 0xf2, 0x6f, 0x20, - 0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0xff, 0xff, 0x05, 0x4a, 0x88, 0xc9, 0xf8, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -835,12 +865,14 @@ func (m *MsgUpdateParam) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.AsType) > 0 { - i -= len(m.AsType) - copy(dAtA[i:], m.AsType) - i = encodeVarintTx(dAtA, i, uint64(len(m.AsType))) - i-- - dAtA[i] = 0x1a + if m.AsType != nil { + { + size := m.AsType.Size() + i -= size + if _, err := m.AsType.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } } if len(m.Name) > 0 { i -= len(m.Name) @@ -859,6 +891,27 @@ func (m *MsgUpdateParam) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUpdateParam_AsCoin) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParam_AsCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.AsCoin != nil { + { + size, err := m.AsCoin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} func (m *MsgUpdateParamResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -995,13 +1048,24 @@ func (m *MsgUpdateParam) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.AsType) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.AsType != nil { + n += m.AsType.Size() } return n } +func (m *MsgUpdateParam_AsCoin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AsCoin != nil { + l = m.AsCoin.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} func (m *MsgUpdateParamResponse) Size() (n int) { if m == nil { return 0 @@ -1617,9 +1681,9 @@ func (m *MsgUpdateParam) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AsType", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AsCoin", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1629,23 +1693,26 @@ func (m *MsgUpdateParam) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.AsType = string(dAtA[iNdEx:postIndex]) + v := &types.Coin{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.AsType = &MsgUpdateParam_AsCoin{v} iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/proof/keeper/msg_server_update_param.go b/x/proof/keeper/msg_server_update_param.go index 03828492a..df698a38b 100644 --- a/x/proof/keeper/msg_server_update_param.go +++ b/x/proof/keeper/msg_server_update_param.go @@ -28,65 +28,44 @@ func (k msgServer) UpdateParam( if !ok { return nil, types.ErrProofParamInvalid.Wrapf("unsupported value type for %s param: %T", msg.Name, msg.AsType) } - relayDifficultyTargetHash := value.AsBytes - if err := types.ValidateRelayDifficultyTargetHash(relayDifficultyTargetHash); err != nil { - return nil, err - } - - params.RelayDifficultyTargetHash = relayDifficultyTargetHash + params.RelayDifficultyTargetHash = value.AsBytes case types.ParamProofRequestProbability: value, ok := msg.AsType.(*types.MsgUpdateParam_AsFloat) if !ok { return nil, types.ErrProofParamInvalid.Wrapf("unsupported value type for %s param: %T", msg.Name, msg.AsType) } - proofRequestProbability := value.AsFloat - - if err := types.ValidateProofRequestProbability(proofRequestProbability); err != nil { - return nil, err - } - params.ProofRequestProbability = proofRequestProbability + params.ProofRequestProbability = value.AsFloat case types.ParamProofRequirementThreshold: value, ok := msg.AsType.(*types.MsgUpdateParam_AsCoin) if !ok { return nil, types.ErrProofParamInvalid.Wrapf("unsupported value type for %s param: %T", msg.Name, msg.AsType) } - proofRequirementThreshold := value.AsCoin - if err := types.ValidateProofRequirementThreshold(proofRequirementThreshold); err != nil { - return nil, err - } - - params.ProofRequirementThreshold = proofRequirementThreshold + params.ProofRequirementThreshold = value.AsCoin case types.ParamProofMissingPenalty: value, ok := msg.AsType.(*types.MsgUpdateParam_AsCoin) if !ok { return nil, types.ErrProofParamInvalid.Wrapf("unsupported value type for %s param: %T", msg.Name, msg.AsType) } - proofMissingPenalty := value.AsCoin - if err := types.ValidateProofMissingPenalty(proofMissingPenalty); err != nil { - return nil, err - } - - params.ProofMissingPenalty = proofMissingPenalty + params.ProofMissingPenalty = value.AsCoin case types.ParamProofSubmissionFee: value, ok := msg.AsType.(*types.MsgUpdateParam_AsCoin) if !ok { return nil, types.ErrProofParamInvalid.Wrapf("unsupported value type for %s param: %T", msg.Name, msg.AsType) } - proofSubmissionFee := value.AsCoin - - if err := types.ValidateProofSubmissionFee(proofSubmissionFee); err != nil { - return nil, err - } - params.ProofSubmissionFee = proofSubmissionFee + params.ProofSubmissionFee = value.AsCoin default: return nil, types.ErrProofParamInvalid.Wrapf("unsupported param %q", msg.Name) } + if err := params.ValidateBasic(); err != nil { + return nil, err + } + if err := k.SetParams(ctx, params); err != nil { return nil, err } diff --git a/x/proof/keeper/msg_server_update_param_test.go b/x/proof/keeper/msg_server_update_param_test.go index 3b6ba5c58..52078f52a 100644 --- a/x/proof/keeper/msg_server_update_param_test.go +++ b/x/proof/keeper/msg_server_update_param_test.go @@ -27,7 +27,7 @@ func TestMsgUpdateParam_UpdateMinRelayDifficultyBitsOnly(t *testing.T) { // Ensure the default values are different from the new values we want to set require.NotEqual(t, expectedRelayDifficultyTargetHash, defaultParams.RelayDifficultyTargetHash) - // Update the min relay difficulty bits + // Update the min stake. updateParamMsg := &prooftypes.MsgUpdateParam{ Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), Name: prooftypes.ParamRelayDifficultyTargetHash,