From f2a1d3e7c0ab5fca7f78ca143eb026f5f3af52d7 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Mon, 11 Nov 2024 17:22:16 -0500 Subject: [PATCH 1/8] Updated some compiled proto files --- api/poktroll/application/types.pulsar.go | 2 +- api/poktroll/service/tx.pulsar.go | 1 - api/poktroll/shared/service.pulsar.go | 2 +- x/application/types/types.pb.go | 2 +- x/service/types/tx.pb.go | 1 - x/shared/types/service.pb.go | 2 +- 6 files changed, 4 insertions(+), 6 deletions(-) diff --git a/api/poktroll/application/types.pulsar.go b/api/poktroll/application/types.pulsar.go index d1f8f492f..f482e77bb 100644 --- a/api/poktroll/application/types.pulsar.go +++ b/api/poktroll/application/types.pulsar.go @@ -2197,7 +2197,7 @@ type Application struct { // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 ServiceConfigs []*shared.ApplicationServiceConfig `protobuf:"bytes,3,rep,name=service_configs,json=serviceConfigs,proto3" json:"service_configs,omitempty"` // The list of services this appliccation is configured to request service for - // TODO_BETA: Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. + // TODO_BETA(@bryanchriswhite): Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. // Ensure to rename all relevant configs, comments, variables, function names, etc as well. DelegateeGatewayAddresses []string `protobuf:"bytes,4,rep,name=delegatee_gateway_addresses,json=delegateeGatewayAddresses,proto3" json:"delegatee_gateway_addresses,omitempty"` // The Bech32 encoded addresses for all delegatee Gateways, in a non-nullable slice // A map from sessionEndHeights to a list of Gateways. diff --git a/api/poktroll/service/tx.pulsar.go b/api/poktroll/service/tx.pulsar.go index 6a68413aa..ae03ea849 100644 --- a/api/poktroll/service/tx.pulsar.go +++ b/api/poktroll/service/tx.pulsar.go @@ -2968,7 +2968,6 @@ func (x *MsgUpdateParamResponse) GetParams() *Params { // MsgAddService defines a message for adding a new message to the network. // Services can be added by any actor in the network making them truly // permissionless. -// TODO_BETA: Add Champions / Sources once its fully defined. type MsgAddService struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/api/poktroll/shared/service.pulsar.go b/api/poktroll/shared/service.pulsar.go index 680123e30..60a1e6c85 100644 --- a/api/poktroll/shared/service.pulsar.go +++ b/api/poktroll/shared/service.pulsar.go @@ -3391,7 +3391,7 @@ type Service struct { // For example, what if we want to request a session for a certain service but with some additional configs that identify it? Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Unique identifier for the service - // TODO_BETA: Either remove this or rename it to alias. + // TODO_BETA(@bryanchriswhite): Either remove this or rename it to alias. Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // (Optional) Semantic human readable name for the service // The cost of a single relay for this service in terms of compute units. // Must be used alongside the global 'compute_units_to_tokens_multipler' to calculate the cost of a relay for this service. diff --git a/x/application/types/types.pb.go b/x/application/types/types.pb.go index 32bc0cc13..7d154dd9f 100644 --- a/x/application/types/types.pb.go +++ b/x/application/types/types.pb.go @@ -38,7 +38,7 @@ type Application struct { // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 ServiceConfigs []*types1.ApplicationServiceConfig `protobuf:"bytes,3,rep,name=service_configs,json=serviceConfigs,proto3" json:"service_configs,omitempty"` - // TODO_BETA: Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. + // TODO_BETA(@bryanchriswhite): Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`. // Ensure to rename all relevant configs, comments, variables, function names, etc as well. DelegateeGatewayAddresses []string `protobuf:"bytes,4,rep,name=delegatee_gateway_addresses,json=delegateeGatewayAddresses,proto3" json:"delegatee_gateway_addresses,omitempty"` // A map from sessionEndHeights to a list of Gateways. diff --git a/x/service/types/tx.pb.go b/x/service/types/tx.pb.go index cbfd2f131..098020211 100644 --- a/x/service/types/tx.pb.go +++ b/x/service/types/tx.pb.go @@ -252,7 +252,6 @@ func (m *MsgUpdateParamResponse) GetParams() *Params { // MsgAddService defines a message for adding a new message to the network. // Services can be added by any actor in the network making them truly // permissionless. -// TODO_BETA: Add Champions / Sources once its fully defined. type MsgAddService struct { OwnerAddress string `protobuf:"bytes,1,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` Service types1.Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service"` diff --git a/x/shared/types/service.pb.go b/x/shared/types/service.pb.go index 1a2538f90..d5998637f 100644 --- a/x/shared/types/service.pb.go +++ b/x/shared/types/service.pb.go @@ -94,7 +94,7 @@ func (ConfigOptions) EnumDescriptor() ([]byte, []int) { type Service struct { // For example, what if we want to request a session for a certain service but with some additional configs that identify it? Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // TODO_BETA: Either remove this or rename it to alias. + // TODO_BETA(@bryanchriswhite): Either remove this or rename it to alias. Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // The cost of a single relay for this service in terms of compute units. // Must be used alongside the global 'compute_units_to_tokens_multipler' to calculate the cost of a relay for this service. From 52441d3c841017a44a207265bb8186103b003001 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 12 Nov 2024 11:48:18 +0100 Subject: [PATCH 2/8] [Session Params] Add `MsgUpdateParam` to session module (#906) ## Summary Add `MsgUpdateParam` and handler to the session module to support individual parameter updates. **@reviewer, use the updated docs in #839 to validate these changes.** ## Issue - `TODO_BETA` ## Type of change Select one or more from athe following: - [x] New feature, functionality or library - [ ] Consensus breaking; add the `consensus-breaking` label if so. See #791 for details - [ ] Bug fix - [ ] Code health or cleanup - [ ] Documentation - [ ] Other (specify) ## Testing - [ ] **Documentation**: `make docusaurus_start`; only needed if you make doc changes - [x] **Unit Tests**: `make go_develop_and_test` - [ ] **LocalNet E2E Tests**: `make test_e2e` - [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR. ## Sanity Checklist - [x] I have tested my changes using the available tooling - [ ] I have commented my code - [x] I have performed a self-review of my own code; both comments & source code - [ ] I create and reference any new tickets, if applicable - [ ] I have left TODOs throughout the codebase, if applicable --- api/poktroll/session/tx.pulsar.go | 1193 ++++++++++++++++- api/poktroll/session/tx_grpc.pb.go | 38 + .../relay_mining_difficulty.pulsar.go | 777 ----------- proto/poktroll/session/tx.proto | 28 +- .../service/relay_mining_difficulty_test.go | 1 - .../authz/dao_genesis_authorizations.json | 9 + x/session/keeper/msg_server_update_param.go | 18 + x/session/module/autocli.go | 6 + x/session/module/simulation.go | 25 +- x/session/simulation/update_param.go | 30 + x/session/types/codec.go | 3 + x/session/types/message_update_param.go | 25 + x/session/types/message_update_param_test.go | 41 + x/session/types/tx.pb.go | 542 +++++++- x/supplier/module/abci.go | 1 + 15 files changed, 1925 insertions(+), 812 deletions(-) delete mode 100644 api/poktroll/tokenomics/relay_mining_difficulty.pulsar.go create mode 100644 x/session/keeper/msg_server_update_param.go create mode 100644 x/session/simulation/update_param.go create mode 100644 x/session/types/message_update_param.go create mode 100644 x/session/types/message_update_param_test.go diff --git a/api/poktroll/session/tx.pulsar.go b/api/poktroll/session/tx.pulsar.go index f524b7fe9..e11211ac9 100644 --- a/api/poktroll/session/tx.pulsar.go +++ b/api/poktroll/session/tx.pulsar.go @@ -871,6 +871,1003 @@ func (x *fastReflection_MsgUpdateParamsResponse) ProtoMethods() *protoiface.Meth } } +var ( + md_MsgUpdateParam protoreflect.MessageDescriptor + fd_MsgUpdateParam_authority protoreflect.FieldDescriptor + fd_MsgUpdateParam_name protoreflect.FieldDescriptor + fd_MsgUpdateParam_as_uint64 protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_session_tx_proto_init() + md_MsgUpdateParam = File_poktroll_session_tx_proto.Messages().ByName("MsgUpdateParam") + fd_MsgUpdateParam_authority = md_MsgUpdateParam.Fields().ByName("authority") + fd_MsgUpdateParam_name = md_MsgUpdateParam.Fields().ByName("name") + fd_MsgUpdateParam_as_uint64 = md_MsgUpdateParam.Fields().ByName("as_uint64") +} + +var _ protoreflect.Message = (*fastReflection_MsgUpdateParam)(nil) + +type fastReflection_MsgUpdateParam MsgUpdateParam + +func (x *MsgUpdateParam) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgUpdateParam)(x) +} + +func (x *MsgUpdateParam) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_session_tx_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgUpdateParam_messageType fastReflection_MsgUpdateParam_messageType +var _ protoreflect.MessageType = fastReflection_MsgUpdateParam_messageType{} + +type fastReflection_MsgUpdateParam_messageType struct{} + +func (x fastReflection_MsgUpdateParam_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgUpdateParam)(nil) +} +func (x fastReflection_MsgUpdateParam_messageType) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParam) +} +func (x fastReflection_MsgUpdateParam_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParam +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgUpdateParam) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParam +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgUpdateParam) Type() protoreflect.MessageType { + return _fastReflection_MsgUpdateParam_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgUpdateParam) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParam) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgUpdateParam) Interface() protoreflect.ProtoMessage { + return (*MsgUpdateParam)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgUpdateParam) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Authority != "" { + value := protoreflect.ValueOfString(x.Authority) + if !f(fd_MsgUpdateParam_authority, value) { + return + } + } + if x.Name != "" { + value := protoreflect.ValueOfString(x.Name) + if !f(fd_MsgUpdateParam_name, value) { + return + } + } + if x.AsType != nil { + switch o := x.AsType.(type) { + case *MsgUpdateParam_AsUint64: + v := o.AsUint64 + value := protoreflect.ValueOfUint64(v) + if !f(fd_MsgUpdateParam_as_uint64, value) { + return + } + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgUpdateParam) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.session.MsgUpdateParam.authority": + return x.Authority != "" + case "poktroll.session.MsgUpdateParam.name": + return x.Name != "" + case "poktroll.session.MsgUpdateParam.as_uint64": + if x.AsType == nil { + return false + } else if _, ok := x.AsType.(*MsgUpdateParam_AsUint64); ok { + return true + } else { + return false + } + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParam) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.session.MsgUpdateParam.authority": + x.Authority = "" + case "poktroll.session.MsgUpdateParam.name": + x.Name = "" + case "poktroll.session.MsgUpdateParam.as_uint64": + x.AsType = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgUpdateParam) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.session.MsgUpdateParam.authority": + value := x.Authority + return protoreflect.ValueOfString(value) + case "poktroll.session.MsgUpdateParam.name": + value := x.Name + return protoreflect.ValueOfString(value) + case "poktroll.session.MsgUpdateParam.as_uint64": + if x.AsType == nil { + return protoreflect.ValueOfUint64(uint64(0)) + } else if v, ok := x.AsType.(*MsgUpdateParam_AsUint64); ok { + return protoreflect.ValueOfUint64(v.AsUint64) + } else { + return protoreflect.ValueOfUint64(uint64(0)) + } + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParam does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParam) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.session.MsgUpdateParam.authority": + x.Authority = value.Interface().(string) + case "poktroll.session.MsgUpdateParam.name": + x.Name = value.Interface().(string) + case "poktroll.session.MsgUpdateParam.as_uint64": + cv := value.Uint() + x.AsType = &MsgUpdateParam_AsUint64{AsUint64: cv} + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// 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.session.MsgUpdateParam.authority": + panic(fmt.Errorf("field authority of message poktroll.session.MsgUpdateParam is not mutable")) + case "poktroll.session.MsgUpdateParam.name": + panic(fmt.Errorf("field name of message poktroll.session.MsgUpdateParam is not mutable")) + case "poktroll.session.MsgUpdateParam.as_uint64": + panic(fmt.Errorf("field as_uint64 of message poktroll.session.MsgUpdateParam is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgUpdateParam) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.session.MsgUpdateParam.authority": + return protoreflect.ValueOfString("") + case "poktroll.session.MsgUpdateParam.name": + return protoreflect.ValueOfString("") + case "poktroll.session.MsgUpdateParam.as_uint64": + return protoreflect.ValueOfUint64(uint64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// 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.session.MsgUpdateParam.as_type": + if x.AsType == nil { + return nil + } + switch x.AsType.(type) { + case *MsgUpdateParam_AsUint64: + return x.Descriptor().Fields().ByName("as_uint64") + } + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.session.MsgUpdateParam", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgUpdateParam) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParam) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgUpdateParam) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgUpdateParam) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Authority) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Name) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + switch x := x.AsType.(type) { + case *MsgUpdateParam_AsUint64: + if x == nil { + break + } + n += 1 + runtime.Sov(uint64(x.AsUint64)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParam) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + switch x := x.AsType.(type) { + case *MsgUpdateParam_AsUint64: + i = runtime.EncodeVarint(dAtA, i, uint64(x.AsUint64)) + i-- + dAtA[i] = 0x18 + } + if len(x.Name) > 0 { + i -= len(x.Name) + copy(dAtA[i:], x.Name) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name))) + i-- + dAtA[i] = 0x12 + } + if len(x.Authority) > 0 { + i -= len(x.Authority) + copy(dAtA[i:], x.Authority) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParam) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + 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++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParam: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParam: 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 Authority", wireType) + } + var stringLen uint64 + 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++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + 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++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsUint64", wireType) + } + var v uint64 + 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++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.AsType = &MsgUpdateParam_AsUint64{v} + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_MsgUpdateParamResponse protoreflect.MessageDescriptor + fd_MsgUpdateParamResponse_params protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_session_tx_proto_init() + md_MsgUpdateParamResponse = File_poktroll_session_tx_proto.Messages().ByName("MsgUpdateParamResponse") + fd_MsgUpdateParamResponse_params = md_MsgUpdateParamResponse.Fields().ByName("params") +} + +var _ protoreflect.Message = (*fastReflection_MsgUpdateParamResponse)(nil) + +type fastReflection_MsgUpdateParamResponse MsgUpdateParamResponse + +func (x *MsgUpdateParamResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgUpdateParamResponse)(x) +} + +func (x *MsgUpdateParamResponse) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_session_tx_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgUpdateParamResponse_messageType fastReflection_MsgUpdateParamResponse_messageType +var _ protoreflect.MessageType = fastReflection_MsgUpdateParamResponse_messageType{} + +type fastReflection_MsgUpdateParamResponse_messageType struct{} + +func (x fastReflection_MsgUpdateParamResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgUpdateParamResponse)(nil) +} +func (x fastReflection_MsgUpdateParamResponse_messageType) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParamResponse) +} +func (x fastReflection_MsgUpdateParamResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParamResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgUpdateParamResponse) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParamResponse +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgUpdateParamResponse) Type() protoreflect.MessageType { + return _fastReflection_MsgUpdateParamResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgUpdateParamResponse) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParamResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgUpdateParamResponse) Interface() protoreflect.ProtoMessage { + return (*MsgUpdateParamResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgUpdateParamResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Params != nil { + value := protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + if !f(fd_MsgUpdateParamResponse_params, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgUpdateParamResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.session.MsgUpdateParamResponse.params": + return x.Params != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.session.MsgUpdateParamResponse.params": + x.Params = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgUpdateParamResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.session.MsgUpdateParamResponse.params": + value := x.Params + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParamResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.session.MsgUpdateParamResponse.params": + x.Params = value.Message().Interface().(*Params) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.session.MsgUpdateParamResponse.params": + if x.Params == nil { + x.Params = new(Params) + } + return protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgUpdateParamResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.session.MsgUpdateParamResponse.params": + m := new(Params) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.session.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgUpdateParamResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.session.MsgUpdateParamResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgUpdateParamResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgUpdateParamResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgUpdateParamResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgUpdateParamResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Params != nil { + l = options.Size(x.Params) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParamResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Params != nil { + encoded, err := options.Marshal(x.Params) + 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 { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParamResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + 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++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParamResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParamResponse: 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 Params", 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.Params == nil { + x.Params = &Params{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Params); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -959,6 +1956,113 @@ func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { return file_poktroll_session_tx_proto_rawDescGZIP(), []int{1} } +type MsgUpdateParam struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 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"` + // Types that are assignable to AsType: + // + // *MsgUpdateParam_AsUint64 + AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` +} + +func (x *MsgUpdateParam) Reset() { + *x = MsgUpdateParam{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_session_tx_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgUpdateParam) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgUpdateParam) ProtoMessage() {} + +// Deprecated: Use MsgUpdateParam.ProtoReflect.Descriptor instead. +func (*MsgUpdateParam) Descriptor() ([]byte, []int) { + return file_poktroll_session_tx_proto_rawDescGZIP(), []int{2} +} + +func (x *MsgUpdateParam) GetAuthority() string { + if x != nil { + return x.Authority + } + return "" +} + +func (x *MsgUpdateParam) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *MsgUpdateParam) GetAsType() isMsgUpdateParam_AsType { + if x != nil { + return x.AsType + } + return nil +} + +func (x *MsgUpdateParam) GetAsUint64() uint64 { + if x, ok := x.GetAsType().(*MsgUpdateParam_AsUint64); ok { + return x.AsUint64 + } + return 0 +} + +type isMsgUpdateParam_AsType interface { + isMsgUpdateParam_AsType() +} + +type MsgUpdateParam_AsUint64 struct { + AsUint64 uint64 `protobuf:"varint,3,opt,name=as_uint64,json=asUint64,proto3,oneof"` +} + +func (*MsgUpdateParam_AsUint64) isMsgUpdateParam_AsType() {} + +type MsgUpdateParamResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (x *MsgUpdateParamResponse) Reset() { + *x = MsgUpdateParamResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_session_tx_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgUpdateParamResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgUpdateParamResponse) ProtoMessage() {} + +// Deprecated: Use MsgUpdateParamResponse.ProtoReflect.Descriptor instead. +func (*MsgUpdateParamResponse) Descriptor() ([]byte, []int) { + return file_poktroll_session_tx_proto_rawDescGZIP(), []int{3} +} + +func (x *MsgUpdateParamResponse) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + var File_poktroll_session_tx_proto protoreflect.FileDescriptor var file_poktroll_session_tx_proto_rawDesc = []byte{ @@ -986,13 +2090,34 @@ var file_poktroll_session_tx_proto_rawDesc = []byte{ 0x22, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x6a, - 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, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 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, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa5, + 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, 0x2c, 0x0a, + 0x09, 0x61, 0x73, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, + 0x42, 0x0d, 0xea, 0xde, 0x1f, 0x09, 0x61, 0x73, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x48, + 0x00, 0x52, 0x08, 0x61, 0x73, 0x55, 0x69, 0x6e, 0x74, 0x36, 0x34, 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, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x32, 0xc5, 0x01, 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, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 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, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 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, 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, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 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, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 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, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, @@ -1019,21 +2144,26 @@ func file_poktroll_session_tx_proto_rawDescGZIP() []byte { return file_poktroll_session_tx_proto_rawDescData } -var file_poktroll_session_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_poktroll_session_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_poktroll_session_tx_proto_goTypes = []interface{}{ (*MsgUpdateParams)(nil), // 0: poktroll.session.MsgUpdateParams (*MsgUpdateParamsResponse)(nil), // 1: poktroll.session.MsgUpdateParamsResponse - (*Params)(nil), // 2: poktroll.session.Params + (*MsgUpdateParam)(nil), // 2: poktroll.session.MsgUpdateParam + (*MsgUpdateParamResponse)(nil), // 3: poktroll.session.MsgUpdateParamResponse + (*Params)(nil), // 4: poktroll.session.Params } var file_poktroll_session_tx_proto_depIdxs = []int32{ - 2, // 0: poktroll.session.MsgUpdateParams.params:type_name -> poktroll.session.Params - 0, // 1: poktroll.session.Msg.UpdateParams:input_type -> poktroll.session.MsgUpdateParams - 1, // 2: poktroll.session.Msg.UpdateParams:output_type -> poktroll.session.MsgUpdateParamsResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] 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 + 4, // 0: poktroll.session.MsgUpdateParams.params:type_name -> poktroll.session.Params + 4, // 1: poktroll.session.MsgUpdateParamResponse.params:type_name -> poktroll.session.Params + 0, // 2: poktroll.session.Msg.UpdateParams:input_type -> poktroll.session.MsgUpdateParams + 2, // 3: poktroll.session.Msg.UpdateParam:input_type -> poktroll.session.MsgUpdateParam + 1, // 4: poktroll.session.Msg.UpdateParams:output_type -> poktroll.session.MsgUpdateParamsResponse + 3, // 5: poktroll.session.Msg.UpdateParam:output_type -> poktroll.session.MsgUpdateParamResponse + 4, // [4:6] is the sub-list for method output_type + 2, // [2:4] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_poktroll_session_tx_proto_init() } @@ -1067,6 +2197,33 @@ func file_poktroll_session_tx_proto_init() { return nil } } + file_poktroll_session_tx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgUpdateParam); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poktroll_session_tx_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgUpdateParamResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_poktroll_session_tx_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*MsgUpdateParam_AsUint64)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -1074,7 +2231,7 @@ func file_poktroll_session_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_poktroll_session_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/api/poktroll/session/tx_grpc.pb.go b/api/poktroll/session/tx_grpc.pb.go index 33cba3055..1a6c46c28 100644 --- a/api/poktroll/session/tx_grpc.pb.go +++ b/api/poktroll/session/tx_grpc.pb.go @@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion8 const ( Msg_UpdateParams_FullMethodName = "/poktroll.session.Msg/UpdateParams" + Msg_UpdateParam_FullMethodName = "/poktroll.session.Msg/UpdateParam" ) // MsgClient is the client API for Msg service. @@ -31,6 +32,7 @@ type MsgClient interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + UpdateParam(ctx context.Context, in *MsgUpdateParam, opts ...grpc.CallOption) (*MsgUpdateParamResponse, error) } type msgClient struct { @@ -51,6 +53,16 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) UpdateParam(ctx context.Context, in *MsgUpdateParam, opts ...grpc.CallOption) (*MsgUpdateParamResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(MsgUpdateParamResponse) + err := c.cc.Invoke(ctx, Msg_UpdateParam_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer // for forward compatibility @@ -60,6 +72,7 @@ type MsgServer interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + UpdateParam(context.Context, *MsgUpdateParam) (*MsgUpdateParamResponse, error) mustEmbedUnimplementedMsgServer() } @@ -70,6 +83,9 @@ type UnimplementedMsgServer struct { func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (UnimplementedMsgServer) UpdateParam(context.Context, *MsgUpdateParam) (*MsgUpdateParamResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParam not implemented") +} func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. @@ -101,6 +117,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParam_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParam) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParam(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Msg_UpdateParam_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParam(ctx, req.(*MsgUpdateParam)) + } + return interceptor(ctx, in, info, handler) +} + // Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -112,6 +146,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "UpdateParam", + Handler: _Msg_UpdateParam_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "poktroll/session/tx.proto", diff --git a/api/poktroll/tokenomics/relay_mining_difficulty.pulsar.go b/api/poktroll/tokenomics/relay_mining_difficulty.pulsar.go deleted file mode 100644 index 5e05f24d6..000000000 --- a/api/poktroll/tokenomics/relay_mining_difficulty.pulsar.go +++ /dev/null @@ -1,777 +0,0 @@ -// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. -package tokenomics - -import ( - fmt "fmt" - runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/gogoproto/gogoproto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoiface "google.golang.org/protobuf/runtime/protoiface" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" -) - -var ( - md_RelayMiningDifficulty protoreflect.MessageDescriptor - fd_RelayMiningDifficulty_service_id protoreflect.FieldDescriptor - fd_RelayMiningDifficulty_block_height protoreflect.FieldDescriptor - fd_RelayMiningDifficulty_num_relays_ema protoreflect.FieldDescriptor - fd_RelayMiningDifficulty_target_hash protoreflect.FieldDescriptor -) - -func init() { - file_poktroll_tokenomics_relay_mining_difficulty_proto_init() - md_RelayMiningDifficulty = File_poktroll_tokenomics_relay_mining_difficulty_proto.Messages().ByName("RelayMiningDifficulty") - fd_RelayMiningDifficulty_service_id = md_RelayMiningDifficulty.Fields().ByName("service_id") - fd_RelayMiningDifficulty_block_height = md_RelayMiningDifficulty.Fields().ByName("block_height") - fd_RelayMiningDifficulty_num_relays_ema = md_RelayMiningDifficulty.Fields().ByName("num_relays_ema") - fd_RelayMiningDifficulty_target_hash = md_RelayMiningDifficulty.Fields().ByName("target_hash") -} - -var _ protoreflect.Message = (*fastReflection_RelayMiningDifficulty)(nil) - -type fastReflection_RelayMiningDifficulty RelayMiningDifficulty - -func (x *RelayMiningDifficulty) ProtoReflect() protoreflect.Message { - return (*fastReflection_RelayMiningDifficulty)(x) -} - -func (x *RelayMiningDifficulty) slowProtoReflect() protoreflect.Message { - mi := &file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_RelayMiningDifficulty_messageType fastReflection_RelayMiningDifficulty_messageType -var _ protoreflect.MessageType = fastReflection_RelayMiningDifficulty_messageType{} - -type fastReflection_RelayMiningDifficulty_messageType struct{} - -func (x fastReflection_RelayMiningDifficulty_messageType) Zero() protoreflect.Message { - return (*fastReflection_RelayMiningDifficulty)(nil) -} -func (x fastReflection_RelayMiningDifficulty_messageType) New() protoreflect.Message { - return new(fastReflection_RelayMiningDifficulty) -} -func (x fastReflection_RelayMiningDifficulty_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_RelayMiningDifficulty -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_RelayMiningDifficulty) Descriptor() protoreflect.MessageDescriptor { - return md_RelayMiningDifficulty -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_RelayMiningDifficulty) Type() protoreflect.MessageType { - return _fastReflection_RelayMiningDifficulty_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_RelayMiningDifficulty) New() protoreflect.Message { - return new(fastReflection_RelayMiningDifficulty) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_RelayMiningDifficulty) Interface() protoreflect.ProtoMessage { - return (*RelayMiningDifficulty)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_RelayMiningDifficulty) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.ServiceId != "" { - value := protoreflect.ValueOfString(x.ServiceId) - if !f(fd_RelayMiningDifficulty_service_id, value) { - return - } - } - if x.BlockHeight != int64(0) { - value := protoreflect.ValueOfInt64(x.BlockHeight) - if !f(fd_RelayMiningDifficulty_block_height, value) { - return - } - } - if x.NumRelaysEma != uint64(0) { - value := protoreflect.ValueOfUint64(x.NumRelaysEma) - if !f(fd_RelayMiningDifficulty_num_relays_ema, value) { - return - } - } - if len(x.TargetHash) != 0 { - value := protoreflect.ValueOfBytes(x.TargetHash) - if !f(fd_RelayMiningDifficulty_target_hash, value) { - return - } - } -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_RelayMiningDifficulty) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "poktroll.tokenomics.RelayMiningDifficulty.service_id": - return x.ServiceId != "" - case "poktroll.tokenomics.RelayMiningDifficulty.block_height": - return x.BlockHeight != int64(0) - case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": - return x.NumRelaysEma != uint64(0) - case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": - return len(x.TargetHash) != 0 - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) - } - panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_RelayMiningDifficulty) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "poktroll.tokenomics.RelayMiningDifficulty.service_id": - x.ServiceId = "" - case "poktroll.tokenomics.RelayMiningDifficulty.block_height": - x.BlockHeight = int64(0) - case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": - x.NumRelaysEma = uint64(0) - case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": - x.TargetHash = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) - } - panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_RelayMiningDifficulty) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "poktroll.tokenomics.RelayMiningDifficulty.service_id": - value := x.ServiceId - return protoreflect.ValueOfString(value) - case "poktroll.tokenomics.RelayMiningDifficulty.block_height": - value := x.BlockHeight - return protoreflect.ValueOfInt64(value) - case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": - value := x.NumRelaysEma - return protoreflect.ValueOfUint64(value) - case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": - value := x.TargetHash - return protoreflect.ValueOfBytes(value) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) - } - panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_RelayMiningDifficulty) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "poktroll.tokenomics.RelayMiningDifficulty.service_id": - x.ServiceId = value.Interface().(string) - case "poktroll.tokenomics.RelayMiningDifficulty.block_height": - x.BlockHeight = value.Int() - case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": - x.NumRelaysEma = value.Uint() - case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": - x.TargetHash = value.Bytes() - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) - } - panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_RelayMiningDifficulty) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "poktroll.tokenomics.RelayMiningDifficulty.service_id": - panic(fmt.Errorf("field service_id of message poktroll.tokenomics.RelayMiningDifficulty is not mutable")) - case "poktroll.tokenomics.RelayMiningDifficulty.block_height": - panic(fmt.Errorf("field block_height of message poktroll.tokenomics.RelayMiningDifficulty is not mutable")) - case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": - panic(fmt.Errorf("field num_relays_ema of message poktroll.tokenomics.RelayMiningDifficulty is not mutable")) - case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": - panic(fmt.Errorf("field target_hash of message poktroll.tokenomics.RelayMiningDifficulty is not mutable")) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) - } - panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_RelayMiningDifficulty) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "poktroll.tokenomics.RelayMiningDifficulty.service_id": - return protoreflect.ValueOfString("") - case "poktroll.tokenomics.RelayMiningDifficulty.block_height": - return protoreflect.ValueOfInt64(int64(0)) - case "poktroll.tokenomics.RelayMiningDifficulty.num_relays_ema": - return protoreflect.ValueOfUint64(uint64(0)) - case "poktroll.tokenomics.RelayMiningDifficulty.target_hash": - return protoreflect.ValueOfBytes(nil) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.RelayMiningDifficulty")) - } - panic(fmt.Errorf("message poktroll.tokenomics.RelayMiningDifficulty does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_RelayMiningDifficulty) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in poktroll.tokenomics.RelayMiningDifficulty", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_RelayMiningDifficulty) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_RelayMiningDifficulty) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_RelayMiningDifficulty) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_RelayMiningDifficulty) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*RelayMiningDifficulty) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - l = len(x.ServiceId) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.BlockHeight != 0 { - n += 1 + runtime.Sov(uint64(x.BlockHeight)) - } - if x.NumRelaysEma != 0 { - n += 1 + runtime.Sov(uint64(x.NumRelaysEma)) - } - l = len(x.TargetHash) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*RelayMiningDifficulty) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if len(x.TargetHash) > 0 { - i -= len(x.TargetHash) - copy(dAtA[i:], x.TargetHash) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.TargetHash))) - i-- - dAtA[i] = 0x22 - } - if x.NumRelaysEma != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.NumRelaysEma)) - i-- - dAtA[i] = 0x18 - } - if x.BlockHeight != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.BlockHeight)) - i-- - dAtA[i] = 0x10 - } - if len(x.ServiceId) > 0 { - i -= len(x.ServiceId) - copy(dAtA[i:], x.ServiceId) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ServiceId))) - i-- - dAtA[i] = 0xa - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*RelayMiningDifficulty) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - 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++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: RelayMiningDifficulty: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: RelayMiningDifficulty: 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 ServiceId", wireType) - } - var stringLen uint64 - 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++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - 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.ServiceId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) - } - x.BlockHeight = 0 - 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++ - x.BlockHeight |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NumRelaysEma", wireType) - } - x.NumRelaysEma = 0 - 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++ - x.NumRelaysEma |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TargetHash", wireType) - } - var byteLen 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++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + byteLen - 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.TargetHash = append(x.TargetHash[:0], dAtA[iNdEx:postIndex]...) - if x.TargetHash == nil { - x.TargetHash = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.0 -// protoc (unknown) -// source: poktroll/tokenomics/relay_mining_difficulty.proto - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// RelayMiningDifficulty is a message used to store the on-chain Relay Mining -// difficulty associated with a specific service ID. -type RelayMiningDifficulty struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The service ID the relay mining difficulty is associated with. - ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` - // The block height at which this relay mining difficulty was computed. - // This is needed to determine how much time has passed since the last time - // the exponential moving average was computed. - BlockHeight int64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` - // The exponential moving average of the number of relays for this service. - NumRelaysEma uint64 `protobuf:"varint,3,opt,name=num_relays_ema,json=numRelaysEma,proto3" json:"num_relays_ema,omitempty"` - // The target hash determining the difficulty to mine relays for this service. - // For example, if we use sha256 to hash the (RelayRequest,ReqlayResponse) tuple, - // and the difficulty has 4 leading zero bits, then the target hash would be: - // 0b0000111... (until 32 bytes are filled up). - TargetHash []byte `protobuf:"bytes,4,opt,name=target_hash,json=targetHash,proto3" json:"target_hash,omitempty"` -} - -func (x *RelayMiningDifficulty) Reset() { - *x = RelayMiningDifficulty{} - if protoimpl.UnsafeEnabled { - mi := &file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RelayMiningDifficulty) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RelayMiningDifficulty) ProtoMessage() {} - -// Deprecated: Use RelayMiningDifficulty.ProtoReflect.Descriptor instead. -func (*RelayMiningDifficulty) Descriptor() ([]byte, []int) { - return file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescGZIP(), []int{0} -} - -func (x *RelayMiningDifficulty) GetServiceId() string { - if x != nil { - return x.ServiceId - } - return "" -} - -func (x *RelayMiningDifficulty) GetBlockHeight() int64 { - if x != nil { - return x.BlockHeight - } - return 0 -} - -func (x *RelayMiningDifficulty) GetNumRelaysEma() uint64 { - if x != nil { - return x.NumRelaysEma - } - return 0 -} - -func (x *RelayMiningDifficulty) GetTargetHash() []byte { - if x != nil { - return x.TargetHash - } - return nil -} - -var File_poktroll_tokenomics_relay_mining_difficulty_proto protoreflect.FileDescriptor - -var file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDesc = []byte{ - 0x0a, 0x31, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x69, 0x6e, 0x69, - 0x6e, 0x67, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa0, - 0x01, 0x0a, 0x15, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, - 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x6e, 0x75, - 0x6d, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x5f, 0x65, 0x6d, 0x61, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x0c, 0x6e, 0x75, 0x6d, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x45, 0x6d, 0x61, - 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x61, 0x73, - 0x68, 0x42, 0xcc, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, - 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, - 0x73, 0x42, 0x1a, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x44, 0x69, - 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x24, 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, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xa2, 0x02, 0x03, 0x50, 0x54, 0x58, 0xaa, 0x02, 0x13, 0x50, 0x6f, - 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, - 0x73, 0xca, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xe2, 0x02, 0x1f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x50, 0x6f, 0x6b, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescOnce sync.Once - file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescData = file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDesc -) - -func file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescGZIP() []byte { - file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescOnce.Do(func() { - file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescData) - }) - return file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDescData -} - -var file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_poktroll_tokenomics_relay_mining_difficulty_proto_goTypes = []interface{}{ - (*RelayMiningDifficulty)(nil), // 0: poktroll.tokenomics.RelayMiningDifficulty -} -var file_poktroll_tokenomics_relay_mining_difficulty_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 -} - -func init() { file_poktroll_tokenomics_relay_mining_difficulty_proto_init() } -func file_poktroll_tokenomics_relay_mining_difficulty_proto_init() { - if File_poktroll_tokenomics_relay_mining_difficulty_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RelayMiningDifficulty); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_poktroll_tokenomics_relay_mining_difficulty_proto_goTypes, - DependencyIndexes: file_poktroll_tokenomics_relay_mining_difficulty_proto_depIdxs, - MessageInfos: file_poktroll_tokenomics_relay_mining_difficulty_proto_msgTypes, - }.Build() - File_poktroll_tokenomics_relay_mining_difficulty_proto = out.File - file_poktroll_tokenomics_relay_mining_difficulty_proto_rawDesc = nil - file_poktroll_tokenomics_relay_mining_difficulty_proto_goTypes = nil - file_poktroll_tokenomics_relay_mining_difficulty_proto_depIdxs = nil -} diff --git a/proto/poktroll/session/tx.proto b/proto/poktroll/session/tx.proto index 6e72f8d5f..f84492834 100644 --- a/proto/poktroll/session/tx.proto +++ b/proto/poktroll/session/tx.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package poktroll.session; option go_package = "github.com/pokt-network/poktroll/x/session/types"; @@ -8,7 +9,6 @@ import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; - import "poktroll/session/params.proto"; // Msg defines the Msg service. @@ -17,13 +17,13 @@ service Msg { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. - rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc UpdateParam (MsgUpdateParam ) returns (MsgUpdateParamResponse ); } - // MsgUpdateParams is the Msg/UpdateParams request type. message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; - option (amino.name) = "poktroll/x/session/MsgUpdateParams"; + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "poktroll/x/session/MsgUpdateParams"; // authority is the address that controls the module (defaults to x/gov unless overwritten). string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; @@ -34,9 +34,25 @@ message MsgUpdateParams { // params defines the x/session parameters to update. // NOTE: All parameters must be supplied. - Params params = 2 [(gogoproto.jsontag) = "params",(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + Params params = 2 [(gogoproto.jsontag) = "params", (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. message MsgUpdateParamsResponse {} + +message MsgUpdateParam { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + string name = 2; + oneof as_type { + uint64 as_uint64 = 3 [(gogoproto.jsontag) = "as_uint64"]; + }} + +message MsgUpdateParamResponse { + Params params = 1; +} + diff --git a/tests/integration/service/relay_mining_difficulty_test.go b/tests/integration/service/relay_mining_difficulty_test.go index b907fa9fb..8e84787fb 100644 --- a/tests/integration/service/relay_mining_difficulty_test.go +++ b/tests/integration/service/relay_mining_difficulty_test.go @@ -60,7 +60,6 @@ func TestUpdateRelayMiningDifficulty_NewServiceSeenForTheFirstTime(t *testing.T) trie := prepareSMST(t, sdkCtx, integrationApp, session, expectedNumRelays) // Compute the number of blocks to wait between different events - // TODO_BETA(@bryanchriswhite): See this comment: https://github.com/pokt-network/poktroll/pull/610#discussion_r1645777322 sessionEndHeight := session.Header.SessionEndBlockHeight earliestSupplierClaimCommitHeight := sharedtypes.GetEarliestSupplierClaimCommitHeight( &sharedParams, diff --git a/tools/scripts/authz/dao_genesis_authorizations.json b/tools/scripts/authz/dao_genesis_authorizations.json index 1dd6992f5..b31c55ff5 100644 --- a/tools/scripts/authz/dao_genesis_authorizations.json +++ b/tools/scripts/authz/dao_genesis_authorizations.json @@ -170,6 +170,15 @@ }, "expiration": "2500-01-01T00:00:00Z" }, + { + "granter": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "grantee": "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw", + "authorization": { + "@type": "\/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "\/poktroll.session.MsgUpdateParam" + }, + "expiration": "2500-01-01T00:00:00Z" + }, { "granter": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "grantee": "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw", diff --git a/x/session/keeper/msg_server_update_param.go b/x/session/keeper/msg_server_update_param.go new file mode 100644 index 000000000..4cb9ec545 --- /dev/null +++ b/x/session/keeper/msg_server_update_param.go @@ -0,0 +1,18 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/pokt-network/poktroll/x/session/types" +) + +func (k msgServer) UpdateParam(goCtx context.Context, msg *types.MsgUpdateParam) (*types.MsgUpdateParamResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO: Handling the message + _ = ctx + + return &types.MsgUpdateParamResponse{}, nil +} diff --git a/x/session/module/autocli.go b/x/session/module/autocli.go index 75f59bd46..1b26497eb 100644 --- a/x/session/module/autocli.go +++ b/x/session/module/autocli.go @@ -42,6 +42,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { // Skip: true, // skipped because authority gated // }, + // { + // RpcMethod: "UpdateParam", + // Use: "update-param [name] [as-type]", + // Short: "Send a update-param tx", + // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "name"}, {ProtoField: "asType"}}, + // }, // this line is used by ignite scaffolding # autocli/tx }, }, diff --git a/x/session/module/simulation.go b/x/session/module/simulation.go index d060b5f91..99b402ece 100644 --- a/x/session/module/simulation.go +++ b/x/session/module/simulation.go @@ -23,7 +23,11 @@ var ( ) const ( -// this line is used by starport scaffolding # simapp/module/const + opWeightMsgUpdateParam = "op_weight_msg_update_param" + // TODO: Determine the simulation weight value + defaultWeightMsgUpdateParam int = 100 + + // this line is used by starport scaffolding # simapp/module/const ) // GenerateGenesisState creates a randomized GenState of the module. @@ -51,6 +55,17 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) + var weightMsgUpdateParam int + simState.AppParams.GetOrGenerate(opWeightMsgUpdateParam, &weightMsgUpdateParam, nil, + func(_ *rand.Rand) { + weightMsgUpdateParam = defaultWeightMsgUpdateParam + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgUpdateParam, + sessionsimulation.SimulateMsgUpdateParam(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations @@ -59,6 +74,14 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // ProposalMsgs returns msgs used for governance proposals for simulations. func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( + opWeightMsgUpdateParam, + defaultWeightMsgUpdateParam, + func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + sessionsimulation.SimulateMsgUpdateParam(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), // this line is used by starport scaffolding # simapp/module/OpMsg } } diff --git a/x/session/simulation/update_param.go b/x/session/simulation/update_param.go new file mode 100644 index 000000000..fec520abc --- /dev/null +++ b/x/session/simulation/update_param.go @@ -0,0 +1,30 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/session/types" +) + +func SimulateMsgUpdateParam( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgUpdateParam{ + Authority: simAccount.Address.String(), + } + + // TODO: Handling the UpdateParam simulation + + return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "UpdateParam simulation not implemented"), nil, nil + } +} diff --git a/x/session/types/codec.go b/x/session/types/codec.go index ac5526374..17b958d5c 100644 --- a/x/session/types/codec.go +++ b/x/session/types/codec.go @@ -8,6 +8,9 @@ import ( ) func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateParam{}, + ) // this line is used by starport scaffolding # 3 registry.RegisterImplementations((*sdk.Msg)(nil), diff --git a/x/session/types/message_update_param.go b/x/session/types/message_update_param.go new file mode 100644 index 000000000..38d848878 --- /dev/null +++ b/x/session/types/message_update_param.go @@ -0,0 +1,25 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ sdk.Msg = (*MsgUpdateParam)(nil) + +func NewMsgUpdateParam(authority string, name string, asType isMsgUpdateParam_AsType) *MsgUpdateParam { + return &MsgUpdateParam{ + Authority: authority, + Name: name, + AsType: asType, + } +} + +func (msg *MsgUpdateParam) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address (%s)", err) + } + return nil +} diff --git a/x/session/types/message_update_param_test.go b/x/session/types/message_update_param_test.go new file mode 100644 index 000000000..b72a6147b --- /dev/null +++ b/x/session/types/message_update_param_test.go @@ -0,0 +1,41 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "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: "invalid address", + msg: MsgUpdateParam{ + Authority: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgUpdateParam{ + Authority: sample.AccAddress(), + }, + }, + } + 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) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/session/types/tx.pb.go b/x/session/types/tx.pb.go index e60329741..e249c935a 100644 --- a/x/session/types/tx.pb.go +++ b/x/session/types/tx.pb.go @@ -117,15 +117,142 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +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"` + // Types that are valid to be assigned to AsType: + // *MsgUpdateParam_AsUint64 + AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` +} + +func (m *MsgUpdateParam) Reset() { *m = MsgUpdateParam{} } +func (m *MsgUpdateParam) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParam) ProtoMessage() {} +func (*MsgUpdateParam) Descriptor() ([]byte, []int) { + return fileDescriptor_0b53e8fbf6b46fb6, []int{2} +} +func (m *MsgUpdateParam) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParam) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *MsgUpdateParam) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParam.Merge(m, src) +} +func (m *MsgUpdateParam) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParam) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParam.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParam proto.InternalMessageInfo + +type isMsgUpdateParam_AsType interface { + isMsgUpdateParam_AsType() + MarshalTo([]byte) (int, error) + Size() int +} + +type MsgUpdateParam_AsUint64 struct { + AsUint64 uint64 `protobuf:"varint,3,opt,name=as_uint64,json=asUint64,proto3,oneof" json:"as_uint64"` +} + +func (*MsgUpdateParam_AsUint64) 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 + } + return "" +} + +func (m *MsgUpdateParam) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgUpdateParam) GetAsUint64() uint64 { + if x, ok := m.GetAsType().(*MsgUpdateParam_AsUint64); ok { + return x.AsUint64 + } + return 0 +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*MsgUpdateParam) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*MsgUpdateParam_AsUint64)(nil), + } +} + +type MsgUpdateParamResponse struct { + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (m *MsgUpdateParamResponse) Reset() { *m = MsgUpdateParamResponse{} } +func (m *MsgUpdateParamResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamResponse) ProtoMessage() {} +func (*MsgUpdateParamResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0b53e8fbf6b46fb6, []int{3} +} +func (m *MsgUpdateParamResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *MsgUpdateParamResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamResponse.Merge(m, src) +} +func (m *MsgUpdateParamResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamResponse proto.InternalMessageInfo + +func (m *MsgUpdateParamResponse) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + func init() { proto.RegisterType((*MsgUpdateParams)(nil), "poktroll.session.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "poktroll.session.MsgUpdateParamsResponse") + proto.RegisterType((*MsgUpdateParam)(nil), "poktroll.session.MsgUpdateParam") + proto.RegisterType((*MsgUpdateParamResponse)(nil), "poktroll.session.MsgUpdateParamResponse") } func init() { proto.RegisterFile("poktroll/session/tx.proto", fileDescriptor_0b53e8fbf6b46fb6) } var fileDescriptor_0b53e8fbf6b46fb6 = []byte{ - // 355 bytes of a gzipped FileDescriptorProto + // 462 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0xc8, 0xcf, 0x2e, 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0x4e, 0x2d, 0x2e, 0xce, 0xcc, 0xcf, 0xd3, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, 0x49, 0xe9, 0x41, 0xa5, 0xa4, 0x04, 0x13, 0x73, @@ -141,14 +268,20 @@ var fileDescriptor_0b53e8fbf6b46fb6 = []byte{ 0xe1, 0xd5, 0x3d, 0x79, 0xa8, 0xfa, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, 0x41, 0x39, 0x56, 0xa6, 0x4d, 0xcf, 0x37, 0x68, 0x21, 0x8c, 0xed, 0x7a, 0xbe, 0x41, 0x4b, 0x09, 0xee, 0x89, 0x0a, 0xb8, 0x37, 0xd0, 0x5c, 0xad, 0x24, 0xc9, 0x25, 0x8e, 0x26, 0x14, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, - 0x9c, 0x6a, 0x94, 0xc5, 0xc5, 0xec, 0x5b, 0x9c, 0x2e, 0x14, 0xc3, 0xc5, 0x83, 0xe2, 0x4f, 0x45, - 0x4c, 0xf7, 0xa1, 0x99, 0x20, 0xa5, 0x49, 0x50, 0x09, 0xcc, 0x12, 0x29, 0xd6, 0x06, 0x90, 0x2f, - 0x9c, 0xfc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc6, 0x23, 0x39, 0xc6, 0x07, - 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, - 0x28, 0x83, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x90, 0xc9, 0xba, - 0x79, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, 0xfa, 0x58, 0x3c, 0x58, 0x52, 0x59, 0x90, 0x5a, 0x9c, - 0xc4, 0x06, 0x8e, 0x27, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe9, 0xc2, 0x98, 0xb6, 0x52, - 0x02, 0x00, 0x00, + 0x9c, 0xaa, 0xb4, 0x94, 0x91, 0x8b, 0x0f, 0x55, 0x8e, 0x6c, 0x3f, 0x0a, 0x71, 0xb1, 0xe4, 0x25, + 0xe6, 0xa6, 0x82, 0x7d, 0xc8, 0x19, 0x04, 0x66, 0x0b, 0xe9, 0x70, 0x71, 0x26, 0x16, 0xc7, 0x97, + 0x66, 0xe6, 0x95, 0x98, 0x99, 0x48, 0x30, 0x2b, 0x30, 0x6a, 0xb0, 0x38, 0xf1, 0xbe, 0xba, 0x27, + 0x8f, 0x10, 0xf4, 0x60, 0x08, 0xe2, 0x48, 0x2c, 0x0e, 0x05, 0xb3, 0xad, 0xf8, 0x50, 0xbd, 0xe7, + 0xc4, 0xc9, 0xc5, 0x9e, 0x58, 0x1c, 0x5f, 0x52, 0x59, 0x90, 0xaa, 0xe4, 0xc5, 0x25, 0x86, 0xea, + 0x4c, 0x98, 0x0f, 0x84, 0x0c, 0xe0, 0x41, 0xcb, 0x88, 0x3f, 0x68, 0x61, 0xa1, 0x68, 0x74, 0x94, + 0x91, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x86, 0x8b, 0x07, 0x25, 0x72, 0x15, 0x31, 0x75, 0xa2, + 0x05, 0x9b, 0x94, 0x26, 0x41, 0x25, 0x70, 0x77, 0x45, 0x72, 0x71, 0x23, 0x87, 0xaa, 0x02, 0x21, + 0x9d, 0x52, 0x1a, 0x84, 0x54, 0xc0, 0x8c, 0x96, 0x62, 0x6d, 0x00, 0xa5, 0x0a, 0x27, 0xbf, 0x13, + 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0xbc, 0xf1, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, + 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x20, 0x3d, + 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x64, 0xb0, 0x6e, 0x5e, 0x6a, 0x49, + 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0x96, 0x04, 0x03, 0x0a, 0xe2, 0xe2, 0x24, 0x36, 0x70, 0xba, 0x37, + 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x34, 0x4c, 0x07, 0x59, 0xa2, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -166,6 +299,7 @@ type MsgClient interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + UpdateParam(ctx context.Context, in *MsgUpdateParam, opts ...grpc.CallOption) (*MsgUpdateParamResponse, error) } type msgClient struct { @@ -185,11 +319,21 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) UpdateParam(ctx context.Context, in *MsgUpdateParam, opts ...grpc.CallOption) (*MsgUpdateParamResponse, error) { + out := new(MsgUpdateParamResponse) + err := c.cc.Invoke(ctx, "/poktroll.session.Msg/UpdateParam", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + UpdateParam(context.Context, *MsgUpdateParam) (*MsgUpdateParamResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -199,6 +343,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (*UnimplementedMsgServer) UpdateParam(ctx context.Context, req *MsgUpdateParam) (*MsgUpdateParamResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParam not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -222,6 +369,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParam_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParam) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParam(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/poktroll.session.Msg/UpdateParam", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParam(ctx, req.(*MsgUpdateParam)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "poktroll.session.Msg", HandlerType: (*MsgServer)(nil), @@ -230,6 +395,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "UpdateParam", + Handler: _Msg_UpdateParam_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "poktroll/session/tx.proto", @@ -298,6 +467,99 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgUpdateParam) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParam) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParam) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + 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) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParam_AsUint64) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParam_AsUint64) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i = encodeVarintTx(dAtA, i, uint64(m.AsUint64)) + i-- + dAtA[i] = 0x18 + return len(dAtA) - i, nil +} +func (m *MsgUpdateParamResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -333,6 +595,48 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } +func (m *MsgUpdateParam) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.AsType != nil { + n += m.AsType.Size() + } + return n +} + +func (m *MsgUpdateParam_AsUint64) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovTx(uint64(m.AsUint64)) + return n +} +func (m *MsgUpdateParamResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -504,6 +808,226 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateParam) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParam: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParam: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AsUint64", wireType) + } + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.AsType = &MsgUpdateParam_AsUint64{v} + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &Params{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/supplier/module/abci.go b/x/supplier/module/abci.go index f448fd5f0..65416b0c1 100644 --- a/x/supplier/module/abci.go +++ b/x/supplier/module/abci.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" cosmostelemetry "github.com/cosmos/cosmos-sdk/telemetry" + "github.com/pokt-network/poktroll/x/supplier/keeper" "github.com/pokt-network/poktroll/x/supplier/types" ) From 9a4fcfe0a53b5a41c005b3af2a8b3da81f048390 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 12 Nov 2024 11:53:21 +0100 Subject: [PATCH 3/8] chore: review feedback improvements Co-authored-by: Redouane Lakrache --- x/session/keeper/params_test.go | 2 +- x/session/types/params.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/session/keeper/params_test.go b/x/session/keeper/params_test.go index 0114e731e..fadc53e6b 100644 --- a/x/session/keeper/params_test.go +++ b/x/session/keeper/params_test.go @@ -22,7 +22,7 @@ func TestGetParams(t *testing.T) { { desc: "invalid NumSuppliersPerSession (<1)", numSuppliersPerSession: uint64(0), - expectedErr: sessiontypes.ErrSessionParamInvalid.Wrapf("number of suppliers per session (%d) MUST be greater than 1", 0), + expectedErr: sessiontypes.ErrSessionParamInvalid.Wrapf("number of suppliers per session (%d) MUST be greater than or equal to 1", 0), }, { desc: "valid NumSuppliersPerSession", diff --git a/x/session/types/params.go b/x/session/types/params.go index ba87c7eda..0cbb4d211 100644 --- a/x/session/types/params.go +++ b/x/session/types/params.go @@ -55,7 +55,7 @@ func ValidateNumSuppliersPerSession(numSuppliersPerSessionAny any) error { } if numSuppliersPerSession < 1 { - return ErrSessionParamInvalid.Wrapf("number of suppliers per session (%d) MUST be greater than 1", numSuppliersPerSession) + return ErrSessionParamInvalid.Wrapf("number of suppliers per session (%d) MUST be greater than or equal to 1", numSuppliersPerSession) } return nil From f06276dfc9a8e22a13235a870a8bd9f833817ef4 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 12 Nov 2024 12:47:31 +0100 Subject: [PATCH 4/8] refactor: consolidate float params to float64 --- api/poktroll/proof/params.pulsar.go | 44 +++--- api/poktroll/proof/tx.pulsar.go | 42 +++--- api/poktroll/tokenomics/tx.pulsar.go | 133 +++++++++--------- pkg/client/interface.go | 2 +- pkg/crypto/rand/float.go | 15 +- pkg/crypto/rand/float_test.go | 9 +- proto/poktroll/proof/params.proto | 2 +- proto/poktroll/proof/tx.proto | 2 +- proto/poktroll/tokenomics/tx.proto | 2 +- testutil/integration/suites/param_configs.go | 7 +- testutil/integration/suites/update_params.go | 4 +- .../keeper/msg_server_update_param_test.go | 2 +- x/proof/keeper/params_test.go | 10 +- x/proof/keeper/proof_requirement_test.go | 4 +- x/proof/types/claim.go | 14 +- x/proof/types/params.go | 6 +- x/proof/types/params.pb.go | 76 +++++----- x/proof/types/tx.pb.go | 120 ++++++++-------- .../keeper/msg_server_update_param.go | 4 +- .../keeper/msg_server_update_param_test.go | 2 +- x/tokenomics/types/message_update_param.go | 12 +- .../types/message_update_param_test.go | 6 +- x/tokenomics/types/tx.pb.go | 58 ++++---- 23 files changed, 278 insertions(+), 298 deletions(-) diff --git a/api/poktroll/proof/params.pulsar.go b/api/poktroll/proof/params.pulsar.go index 36039d344..47fb7a9c7 100644 --- a/api/poktroll/proof/params.pulsar.go +++ b/api/poktroll/proof/params.pulsar.go @@ -99,8 +99,8 @@ 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.ProofRequestProbability != float32(0) || math.Signbit(float64(x.ProofRequestProbability)) { - value := protoreflect.ValueOfFloat32(x.ProofRequestProbability) + if x.ProofRequestProbability != float64(0) || math.Signbit(x.ProofRequestProbability) { + value := protoreflect.ValueOfFloat64(x.ProofRequestProbability) if !f(fd_Params_proof_request_probability, value) { return } @@ -139,7 +139,7 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { case "poktroll.proof.Params.proof_request_probability": - return x.ProofRequestProbability != float32(0) || math.Signbit(float64(x.ProofRequestProbability)) + return x.ProofRequestProbability != float64(0) || math.Signbit(x.ProofRequestProbability) case "poktroll.proof.Params.proof_requirement_threshold": return x.ProofRequirementThreshold != nil case "poktroll.proof.Params.proof_missing_penalty": @@ -163,7 +163,7 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "poktroll.proof.Params.proof_request_probability": - x.ProofRequestProbability = float32(0) + x.ProofRequestProbability = float64(0) case "poktroll.proof.Params.proof_requirement_threshold": x.ProofRequirementThreshold = nil case "poktroll.proof.Params.proof_missing_penalty": @@ -188,7 +188,7 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro switch descriptor.FullName() { case "poktroll.proof.Params.proof_request_probability": value := x.ProofRequestProbability - return protoreflect.ValueOfFloat32(value) + return protoreflect.ValueOfFloat64(value) case "poktroll.proof.Params.proof_requirement_threshold": value := x.ProofRequirementThreshold return protoreflect.ValueOfMessage(value.ProtoReflect()) @@ -219,7 +219,7 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { case "poktroll.proof.Params.proof_request_probability": - x.ProofRequestProbability = float32(value.Float()) + x.ProofRequestProbability = value.Float() case "poktroll.proof.Params.proof_requirement_threshold": x.ProofRequirementThreshold = value.Message().Interface().(*v1beta1.Coin) case "poktroll.proof.Params.proof_missing_penalty": @@ -277,7 +277,7 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { case "poktroll.proof.Params.proof_request_probability": - return protoreflect.ValueOfFloat32(float32(0)) + return protoreflect.ValueOfFloat64(float64(0)) case "poktroll.proof.Params.proof_requirement_threshold": m := new(v1beta1.Coin) return protoreflect.ValueOfMessage(m.ProtoReflect()) @@ -356,8 +356,8 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - if x.ProofRequestProbability != 0 || math.Signbit(float64(x.ProofRequestProbability)) { - n += 5 + if x.ProofRequestProbability != 0 || math.Signbit(x.ProofRequestProbability) { + n += 9 } if x.ProofRequirementThreshold != nil { l = options.Size(x.ProofRequirementThreshold) @@ -442,11 +442,11 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i-- dAtA[i] = 0x1a } - if x.ProofRequestProbability != 0 || math.Signbit(float64(x.ProofRequestProbability)) { - i -= 4 - binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(x.ProofRequestProbability)))) + if x.ProofRequestProbability != 0 || math.Signbit(x.ProofRequestProbability) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.ProofRequestProbability)))) i-- - dAtA[i] = 0x15 + dAtA[i] = 0x11 } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) @@ -498,16 +498,16 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { } switch fieldNum { case 2: - if wireType != 5 { + if wireType != 1 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ProofRequestProbability", wireType) } - var v uint32 - if (iNdEx + 4) > l { + var v uint64 + if (iNdEx + 8) > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - x.ProofRequestProbability = float32(math.Float32frombits(v)) + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.ProofRequestProbability = float64(math.Float64frombits(v)) case 3: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ProofRequirementThreshold", wireType) @@ -672,7 +672,7 @@ type Params struct { // proof_request_probability is the probability of a session requiring a proof // if it's cost (i.e. compute unit consumption) is below the ProofRequirementThreshold. - ProofRequestProbability float32 `protobuf:"fixed32,2,opt,name=proof_request_probability,json=proofRequestProbability,proto3" json:"proof_request_probability,omitempty"` + ProofRequestProbability float64 `protobuf:"fixed64,2,opt,name=proof_request_probability,json=proofRequestProbability,proto3" json:"proof_request_probability,omitempty"` // proof_requirement_threshold is the session cost (i.e. compute unit consumption) // threshold which asserts that a session MUST have a corresponding proof when its cost // is equal to or above the threshold. This is in contrast to the this requirement @@ -713,7 +713,7 @@ func (*Params) Descriptor() ([]byte, []int) { return file_poktroll_proof_params_proto_rawDescGZIP(), []int{0} } -func (x *Params) GetProofRequestProbability() float32 { +func (x *Params) GetProofRequestProbability() float64 { if x != nil { return x.ProofRequestProbability } @@ -754,7 +754,7 @@ var file_poktroll_proof_params_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd2, 0x03, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x59, 0x0a, 0x19, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x62, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x02, 0x42, 0x1d, 0xea, 0xde, 0x1f, 0x19, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, + 0x20, 0x01, 0x28, 0x01, 0x42, 0x1d, 0xea, 0xde, 0x1f, 0x19, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x62, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x17, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x62, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x7a, 0x0a, 0x1b, diff --git a/api/poktroll/proof/tx.pulsar.go b/api/poktroll/proof/tx.pulsar.go index 3be72003c..cc72dd116 100644 --- a/api/poktroll/proof/tx.pulsar.go +++ b/api/poktroll/proof/tx.pulsar.go @@ -5,13 +5,13 @@ import ( _ "cosmossdk.io/api/amino" v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" _ "cosmossdk.io/api/cosmos/msg/v1" - session "github.com/pokt-network/poktroll/api/poktroll/session" - _ "github.com/pokt-network/poktroll/api/poktroll/shared" binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" + session "github.com/pokt-network/poktroll/api/poktroll/session" + _ "github.com/pokt-network/poktroll/api/poktroll/shared" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -982,7 +982,7 @@ func (x *fastReflection_MsgUpdateParam) Range(f func(protoreflect.FieldDescripto } case *MsgUpdateParam_AsFloat: v := o.AsFloat - value := protoreflect.ValueOfFloat32(v) + value := protoreflect.ValueOfFloat64(v) if !f(fd_MsgUpdateParam_as_float, value) { return } @@ -1095,11 +1095,11 @@ func (x *fastReflection_MsgUpdateParam) Get(descriptor protoreflect.FieldDescrip } case "poktroll.proof.MsgUpdateParam.as_float": if x.AsType == nil { - return protoreflect.ValueOfFloat32(float32(0)) + return protoreflect.ValueOfFloat64(float64(0)) } else if v, ok := x.AsType.(*MsgUpdateParam_AsFloat); ok { - return protoreflect.ValueOfFloat32(v.AsFloat) + return protoreflect.ValueOfFloat64(v.AsFloat) } else { - return protoreflect.ValueOfFloat32(float32(0)) + return protoreflect.ValueOfFloat64(float64(0)) } case "poktroll.proof.MsgUpdateParam.as_coin": if x.AsType == nil { @@ -1137,7 +1137,7 @@ func (x *fastReflection_MsgUpdateParam) Set(fd protoreflect.FieldDescriptor, val cv := value.Bytes() x.AsType = &MsgUpdateParam_AsBytes{AsBytes: cv} case "poktroll.proof.MsgUpdateParam.as_float": - cv := float32(value.Float()) + cv := value.Float() x.AsType = &MsgUpdateParam_AsFloat{AsFloat: cv} case "poktroll.proof.MsgUpdateParam.as_coin": cv := value.Message().Interface().(*v1beta1.Coin) @@ -1206,7 +1206,7 @@ func (x *fastReflection_MsgUpdateParam) NewField(fd protoreflect.FieldDescriptor case "poktroll.proof.MsgUpdateParam.as_bytes": return protoreflect.ValueOfBytes(nil) case "poktroll.proof.MsgUpdateParam.as_float": - return protoreflect.ValueOfFloat32(float32(0)) + return protoreflect.ValueOfFloat64(float64(0)) case "poktroll.proof.MsgUpdateParam.as_coin": value := &v1beta1.Coin{} return protoreflect.ValueOfMessage(value.ProtoReflect()) @@ -1310,7 +1310,7 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { if x == nil { break } - n += 5 + n += 9 case *MsgUpdateParam_AsCoin: if x == nil { break @@ -1355,10 +1355,10 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { i-- dAtA[i] = 0x3a case *MsgUpdateParam_AsFloat: - i -= 4 - binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(x.AsFloat)))) + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.AsFloat)))) i-- - dAtA[i] = 0x45 + dAtA[i] = 0x41 case *MsgUpdateParam_AsCoin: encoded, err := options.Marshal(x.AsCoin) if err != nil { @@ -1534,16 +1534,16 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { x.AsType = &MsgUpdateParam_AsBytes{v} iNdEx = postIndex case 8: - if wireType != 5 { + if wireType != 1 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsFloat", wireType) } - var v uint32 - if (iNdEx + 4) > l { + var v uint64 + if (iNdEx + 8) > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - x.AsType = &MsgUpdateParam_AsFloat{float32(math.Float32frombits(v))} + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.AsType = &MsgUpdateParam_AsFloat{float64(math.Float64frombits(v))} case 9: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsCoin", wireType) @@ -4204,7 +4204,7 @@ func (x *MsgUpdateParam) GetAsBytes() []byte { return nil } -func (x *MsgUpdateParam) GetAsFloat() float32 { +func (x *MsgUpdateParam) GetAsFloat() float64 { if x, ok := x.GetAsType().(*MsgUpdateParam_AsFloat); ok { return x.AsFloat } @@ -4227,7 +4227,7 @@ type MsgUpdateParam_AsBytes struct { } type MsgUpdateParam_AsFloat struct { - AsFloat float32 `protobuf:"fixed32,8,opt,name=as_float,json=asFloat,proto3,oneof"` + AsFloat float64 `protobuf:"fixed64,8,opt,name=as_float,json=asFloat,proto3,oneof"` } type MsgUpdateParam_AsCoin struct { @@ -4494,7 +4494,7 @@ var file_poktroll_proof_tx_proto_rawDesc = []byte{ 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x08, 0x61, 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0c, 0xea, 0xde, 0x1f, 0x08, 0x61, 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x48, 0x00, 0x52, 0x07, 0x61, 0x73, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x29, 0x0a, - 0x08, 0x61, 0x73, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x02, 0x42, + 0x08, 0x61, 0x73, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x01, 0x42, 0x0c, 0xea, 0xde, 0x1f, 0x08, 0x61, 0x73, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x48, 0x00, 0x52, 0x07, 0x61, 0x73, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x41, 0x0a, 0x07, 0x61, 0x73, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, diff --git a/api/poktroll/tokenomics/tx.pulsar.go b/api/poktroll/tokenomics/tx.pulsar.go index c64b0ff16..9cf66c7d1 100644 --- a/api/poktroll/tokenomics/tx.pulsar.go +++ b/api/poktroll/tokenomics/tx.pulsar.go @@ -877,7 +877,7 @@ var ( md_MsgUpdateParam protoreflect.MessageDescriptor fd_MsgUpdateParam_authority protoreflect.FieldDescriptor fd_MsgUpdateParam_name protoreflect.FieldDescriptor - fd_MsgUpdateParam_as_double protoreflect.FieldDescriptor + fd_MsgUpdateParam_as_float protoreflect.FieldDescriptor ) func init() { @@ -885,7 +885,7 @@ func init() { md_MsgUpdateParam = File_poktroll_tokenomics_tx_proto.Messages().ByName("MsgUpdateParam") fd_MsgUpdateParam_authority = md_MsgUpdateParam.Fields().ByName("authority") fd_MsgUpdateParam_name = md_MsgUpdateParam.Fields().ByName("name") - fd_MsgUpdateParam_as_double = md_MsgUpdateParam.Fields().ByName("as_double") + fd_MsgUpdateParam_as_float = md_MsgUpdateParam.Fields().ByName("as_float") } var _ protoreflect.Message = (*fastReflection_MsgUpdateParam)(nil) @@ -967,10 +967,10 @@ func (x *fastReflection_MsgUpdateParam) Range(f func(protoreflect.FieldDescripto } if x.AsType != nil { switch o := x.AsType.(type) { - case *MsgUpdateParam_AsDouble: - v := o.AsDouble + case *MsgUpdateParam_AsFloat: + v := o.AsFloat value := protoreflect.ValueOfFloat64(v) - if !f(fd_MsgUpdateParam_as_double, value) { + if !f(fd_MsgUpdateParam_as_float, value) { return } } @@ -994,10 +994,10 @@ func (x *fastReflection_MsgUpdateParam) Has(fd protoreflect.FieldDescriptor) boo return x.Authority != "" case "poktroll.tokenomics.MsgUpdateParam.name": return x.Name != "" - case "poktroll.tokenomics.MsgUpdateParam.as_double": + case "poktroll.tokenomics.MsgUpdateParam.as_float": if x.AsType == nil { return false - } else if _, ok := x.AsType.(*MsgUpdateParam_AsDouble); ok { + } else if _, ok := x.AsType.(*MsgUpdateParam_AsFloat); ok { return true } else { return false @@ -1022,7 +1022,7 @@ func (x *fastReflection_MsgUpdateParam) Clear(fd protoreflect.FieldDescriptor) { x.Authority = "" case "poktroll.tokenomics.MsgUpdateParam.name": x.Name = "" - case "poktroll.tokenomics.MsgUpdateParam.as_double": + case "poktroll.tokenomics.MsgUpdateParam.as_float": x.AsType = nil default: if fd.IsExtension() { @@ -1046,11 +1046,11 @@ func (x *fastReflection_MsgUpdateParam) Get(descriptor protoreflect.FieldDescrip case "poktroll.tokenomics.MsgUpdateParam.name": value := x.Name return protoreflect.ValueOfString(value) - case "poktroll.tokenomics.MsgUpdateParam.as_double": + case "poktroll.tokenomics.MsgUpdateParam.as_float": if x.AsType == nil { return protoreflect.ValueOfFloat64(float64(0)) - } else if v, ok := x.AsType.(*MsgUpdateParam_AsDouble); ok { - return protoreflect.ValueOfFloat64(v.AsDouble) + } else if v, ok := x.AsType.(*MsgUpdateParam_AsFloat); ok { + return protoreflect.ValueOfFloat64(v.AsFloat) } else { return protoreflect.ValueOfFloat64(float64(0)) } @@ -1078,9 +1078,9 @@ func (x *fastReflection_MsgUpdateParam) Set(fd protoreflect.FieldDescriptor, val x.Authority = value.Interface().(string) case "poktroll.tokenomics.MsgUpdateParam.name": x.Name = value.Interface().(string) - case "poktroll.tokenomics.MsgUpdateParam.as_double": + case "poktroll.tokenomics.MsgUpdateParam.as_float": cv := value.Float() - x.AsType = &MsgUpdateParam_AsDouble{AsDouble: cv} + x.AsType = &MsgUpdateParam_AsFloat{AsFloat: cv} default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.MsgUpdateParam")) @@ -1105,8 +1105,8 @@ func (x *fastReflection_MsgUpdateParam) Mutable(fd protoreflect.FieldDescriptor) panic(fmt.Errorf("field authority of message poktroll.tokenomics.MsgUpdateParam is not mutable")) case "poktroll.tokenomics.MsgUpdateParam.name": panic(fmt.Errorf("field name of message poktroll.tokenomics.MsgUpdateParam is not mutable")) - case "poktroll.tokenomics.MsgUpdateParam.as_double": - panic(fmt.Errorf("field as_double of message poktroll.tokenomics.MsgUpdateParam is not mutable")) + case "poktroll.tokenomics.MsgUpdateParam.as_float": + panic(fmt.Errorf("field as_float of message poktroll.tokenomics.MsgUpdateParam is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.MsgUpdateParam")) @@ -1124,7 +1124,7 @@ func (x *fastReflection_MsgUpdateParam) NewField(fd protoreflect.FieldDescriptor return protoreflect.ValueOfString("") case "poktroll.tokenomics.MsgUpdateParam.name": return protoreflect.ValueOfString("") - case "poktroll.tokenomics.MsgUpdateParam.as_double": + case "poktroll.tokenomics.MsgUpdateParam.as_float": return protoreflect.ValueOfFloat64(float64(0)) default: if fd.IsExtension() { @@ -1144,8 +1144,8 @@ func (x *fastReflection_MsgUpdateParam) WhichOneof(d protoreflect.OneofDescripto return nil } switch x.AsType.(type) { - case *MsgUpdateParam_AsDouble: - return x.Descriptor().Fields().ByName("as_double") + case *MsgUpdateParam_AsFloat: + return x.Descriptor().Fields().ByName("as_float") } default: panic(fmt.Errorf("%s is not a oneof field in poktroll.tokenomics.MsgUpdateParam", d.FullName())) @@ -1212,7 +1212,7 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } switch x := x.AsType.(type) { - case *MsgUpdateParam_AsDouble: + case *MsgUpdateParam_AsFloat: if x == nil { break } @@ -1248,9 +1248,9 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], x.unknownFields) } switch x := x.AsType.(type) { - case *MsgUpdateParam_AsDouble: + case *MsgUpdateParam_AsFloat: i -= 8 - binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.AsDouble)))) + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.AsFloat)))) i-- dAtA[i] = 0x19 } @@ -1383,7 +1383,7 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 3: if wireType != 1 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsDouble", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsFloat", wireType) } var v uint64 if (iNdEx + 8) > l { @@ -1391,7 +1391,7 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { } v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 - x.AsType = &MsgUpdateParam_AsDouble{float64(math.Float64frombits(v))} + x.AsType = &MsgUpdateParam_AsFloat{float64(math.Float64frombits(v))} default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1963,7 +1963,7 @@ type MsgUpdateParam struct { Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Types that are assignable to AsType: // - // *MsgUpdateParam_AsDouble + // *MsgUpdateParam_AsFloat AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` } @@ -2008,9 +2008,9 @@ func (x *MsgUpdateParam) GetAsType() isMsgUpdateParam_AsType { return nil } -func (x *MsgUpdateParam) GetAsDouble() float64 { - if x, ok := x.GetAsType().(*MsgUpdateParam_AsDouble); ok { - return x.AsDouble +func (x *MsgUpdateParam) GetAsFloat() float64 { + if x, ok := x.GetAsType().(*MsgUpdateParam_AsFloat); ok { + return x.AsFloat } return 0 } @@ -2019,11 +2019,11 @@ type isMsgUpdateParam_AsType interface { isMsgUpdateParam_AsType() } -type MsgUpdateParam_AsDouble struct { - AsDouble float64 `protobuf:"fixed64,3,opt,name=as_double,json=asDouble,proto3,oneof"` +type MsgUpdateParam_AsFloat struct { + AsFloat float64 `protobuf:"fixed64,3,opt,name=as_float,json=asFloat,proto3,oneof"` } -func (*MsgUpdateParam_AsDouble) isMsgUpdateParam_AsType() {} +func (*MsgUpdateParam_AsFloat) isMsgUpdateParam_AsType() {} // MsgUpdateParamResponse defines the response structure for executing a // MsgUpdateParam message after a single param update. @@ -2090,48 +2090,47 @@ var file_poktroll_tokenomics_tx_proto_rawDesc = []byte{ 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0xa5, 0x01, 0x0a, 0x0e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x6e, 0x73, 0x65, 0x22, 0xa2, 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, 0x2c, 0x0a, 0x09, 0x61, 0x73, 0x5f, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x01, 0x42, 0x0d, 0xea, 0xde, 0x1f, 0x09, 0x61, 0x73, 0x5f, 0x64, 0x6f, - 0x75, 0x62, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x08, 0x61, 0x73, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, - 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, 0x4d, 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, 0x33, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0xd1, 0x01, 0x0a, 0x03, 0x4d, - 0x73, 0x67, 0x12, 0x62, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2c, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 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, 0x5f, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x23, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x08, 0x61, 0x73, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x01, 0x42, 0x0c, 0xea, 0xde, 0x1f, 0x08, 0x61, 0x73, 0x5f, 0x66, 0x6c, 0x6f, + 0x61, 0x74, 0x48, 0x00, 0x52, 0x07, 0x61, 0x73, 0x46, 0x6c, 0x6f, 0x61, 0x74, 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, 0x4d, 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, 0x33, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, + 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0xd1, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, + 0x62, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, + 0x24, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2c, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, - 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, 0xb9, - 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x42, 0x07, - 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 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, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xa2, - 0x02, 0x03, 0x50, 0x54, 0x58, 0xaa, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, - 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xca, 0x02, 0x13, 0x50, 0x6f, - 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, - 0x73, 0xe2, 0x02, 0x1f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x14, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x12, 0x23, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 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, 0xb9, 0x01, 0xd8, 0xe2, + 0x1e, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x42, 0x07, 0x54, 0x78, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 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, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xa2, 0x02, 0x03, 0x50, + 0x54, 0x58, 0xaa, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xca, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0xe2, 0x02, + 0x1f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, + 0x6d, 0x69, 0x63, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x14, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2225,7 +2224,7 @@ func file_poktroll_tokenomics_tx_proto_init() { } } file_poktroll_tokenomics_tx_proto_msgTypes[2].OneofWrappers = []interface{}{ - (*MsgUpdateParam_AsDouble)(nil), + (*MsgUpdateParam_AsFloat)(nil), } type x struct{} out := protoimpl.TypeBuilder{ diff --git a/pkg/client/interface.go b/pkg/client/interface.go index da564c1e2..0f8c8575a 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -330,7 +330,7 @@ type BlockQueryClient interface { // protobuf message. Since the generated go types don't include interface types, this // is necessary to prevent dependency cycles. type ProofParams interface { - GetProofRequestProbability() float32 + GetProofRequestProbability() float64 GetProofRequirementThreshold() *cosmostypes.Coin GetProofMissingPenalty() *cosmostypes.Coin GetProofSubmissionFee() *cosmostypes.Coin diff --git a/pkg/crypto/rand/float.go b/pkg/crypto/rand/float.go index 23524893f..c75efec5c 100644 --- a/pkg/crypto/rand/float.go +++ b/pkg/crypto/rand/float.go @@ -8,12 +8,12 @@ import ( "github.com/cometbft/cometbft/crypto" ) -// SeededFloat32 generates a deterministic float32 between 0 and 1 given a seed. +// SeededFloat64 generates a deterministic float64 between 0 and 1 given a seed. // // TODO_MAINNET: To support other language implementations of the protocol, the // pseudo-random number generator used here should be language-agnostic (i.e. not // golang specific). -func SeededFloat32(seedParts ...[]byte) (float32, error) { +func SeededFloat64(seedParts ...[]byte) float64 { seedHashInputBz := bytes.Join(append([][]byte{}, seedParts...), nil) seedHash := crypto.Sha256(seedHashInputBz) seed, _ := binary.Varint(seedHash) @@ -21,14 +21,5 @@ func SeededFloat32(seedParts ...[]byte) (float32, error) { // Construct a pseudo-random number generator with the seed. pseudoRand := rand.New(rand.NewSource(seed)) - // Generate a random uint32. - randUint32 := pseudoRand.Uint32() - - // Clamp the random float32 between [0,1]. This is achieved by dividing the random uint32 - // by the most significant digit of a float32, which is 2^32, guaranteeing an output between - // 0 and 1, inclusive. - oneMostSignificantDigitFloat32 := float32(1 << 32) - randClampedFloat32 := float32(randUint32) / oneMostSignificantDigitFloat32 - - return randClampedFloat32, nil + return pseudoRand.Float64() } diff --git a/pkg/crypto/rand/float_test.go b/pkg/crypto/rand/float_test.go index 5a7763c9a..df72c991a 100644 --- a/pkg/crypto/rand/float_test.go +++ b/pkg/crypto/rand/float_test.go @@ -13,7 +13,7 @@ import ( prooftypes "github.com/pokt-network/poktroll/x/proof/types" ) -func TestSeededFloat32(t *testing.T) { +func TestSeededFloat64(t *testing.T) { probability := prooftypes.DefaultProofRequestProbability tolerance := 0.01 confidence := 0.99 @@ -30,8 +30,7 @@ func TestSeededFloat32(t *testing.T) { go func(idx int64) { idxBz := make([]byte, binary.MaxVarintLen64) binary.PutVarint(idxBz, idx) - randFloat, err := poktrand.SeededFloat32(idxBz) - require.NoError(t, err) + randFloat := poktrand.SeededFloat64(idxBz) if randFloat < 0 || randFloat > 1 { errCh <- fmt.Errorf("secureRandFloat64() returned out of bounds value: %f", randFloat) @@ -54,8 +53,8 @@ func TestSeededFloat32(t *testing.T) { err := <-errCh require.NoError(t, err) - expectedNumTrueSamples := float32(sampleSize) * probability - expectedNumFalseSamples := float32(sampleSize) * (1 - probability) + expectedNumTrueSamples := float64(sampleSize) * probability + expectedNumFalseSamples := float64(sampleSize) * (1 - probability) toleranceSamples := tolerance * float64(sampleSize) // Check that the number of samples for each outcome is within the expected range. diff --git a/proto/poktroll/proof/params.proto b/proto/poktroll/proof/params.proto index 0af62cebf..d107e1b99 100644 --- a/proto/poktroll/proof/params.proto +++ b/proto/poktroll/proof/params.proto @@ -15,7 +15,7 @@ message Params { // proof_request_probability is the probability of a session requiring a proof // if it's cost (i.e. compute unit consumption) is below the ProofRequirementThreshold. - float proof_request_probability = 2 [(gogoproto.jsontag) = "proof_request_probability"]; + double proof_request_probability = 2 [(gogoproto.jsontag) = "proof_request_probability"]; // proof_requirement_threshold is the session cost (i.e. compute unit consumption) // threshold which asserts that a session MUST have a corresponding proof when its cost diff --git a/proto/poktroll/proof/tx.proto b/proto/poktroll/proof/tx.proto index 139e87042..988e2183a 100644 --- a/proto/poktroll/proof/tx.proto +++ b/proto/poktroll/proof/tx.proto @@ -60,7 +60,7 @@ message MsgUpdateParam { string name = 2; oneof as_type { bytes as_bytes = 7 [(gogoproto.jsontag) = "as_bytes"]; - float as_float = 8 [(gogoproto.jsontag) = "as_float"]; + double as_float = 8 [(gogoproto.jsontag) = "as_float"]; cosmos.base.v1beta1.Coin as_coin = 9 [(gogoproto.jsontag) = "as_coin"]; } } diff --git a/proto/poktroll/tokenomics/tx.proto b/proto/poktroll/tokenomics/tx.proto index 05ea18920..a9ebd766a 100644 --- a/proto/poktroll/tokenomics/tx.proto +++ b/proto/poktroll/tokenomics/tx.proto @@ -53,7 +53,7 @@ message MsgUpdateParam { // specified in the `Params` message in `proof/params.proto.` string name = 2; oneof as_type { - double as_double = 3 [(gogoproto.jsontag) = "as_double"]; + double as_float = 3 [(gogoproto.jsontag) = "as_float"]; } } diff --git a/testutil/integration/suites/param_configs.go b/testutil/integration/suites/param_configs.go index d3f4bfcce..15275e199 100644 --- a/testutil/integration/suites/param_configs.go +++ b/testutil/integration/suites/param_configs.go @@ -23,8 +23,7 @@ type ParamType = string const ( ParamTypeInt64 ParamType = "int64" ParamTypeUint64 ParamType = "uint64" - ParamTypeFloat32 ParamType = "float32" - ParamTypeDouble ParamType = "float64" + ParamTypeFloat64 ParamType = "float64" ParamTypeString ParamType = "string" ParamTypeBytes ParamType = "uint8" ParamTypeCoin ParamType = "Coin" @@ -215,7 +214,7 @@ var ( }, ParamTypes: map[ParamType]any{ ParamTypeBytes: prooftypes.MsgUpdateParam_AsBytes{}, - ParamTypeFloat32: prooftypes.MsgUpdateParam_AsFloat{}, + ParamTypeFloat64: prooftypes.MsgUpdateParam_AsFloat{}, ParamTypeCoin: prooftypes.MsgUpdateParam_AsCoin{}, }, DefaultParams: prooftypes.DefaultParams(), @@ -235,7 +234,7 @@ var ( MintAllocationDao: tokenomicstypes.DefaultMintAllocationDao, }, ParamTypes: map[ParamType]any{ - ParamTypeDouble: tokenomicstypes.MsgUpdateParam_AsDouble{}, + ParamTypeFloat64: tokenomicstypes.MsgUpdateParam_AsFloat{}, }, DefaultParams: tokenomicstypes.DefaultParams(), NewParamClientFn: tokenomicstypes.NewQueryClient, diff --git a/testutil/integration/suites/update_params.go b/testutil/integration/suites/update_params.go index ce7a0f080..af4bc1852 100644 --- a/testutil/integration/suites/update_params.go +++ b/testutil/integration/suites/update_params.go @@ -248,10 +248,8 @@ func (s *ParamsSuite) RunUpdateParamAsSigner( msgAsTypeValue.Elem().FieldByName("AsUint64").Set(paramReflectValue) case ParamTypeInt64: msgAsTypeValue.Elem().FieldByName("AsInt64").Set(paramReflectValue) - case ParamTypeFloat32: + case ParamTypeFloat64: msgAsTypeValue.Elem().FieldByName("AsFloat").Set(paramReflectValue) - case ParamTypeDouble: - msgAsTypeValue.Elem().FieldByName("AsDouble").Set(paramReflectValue) case ParamTypeString: msgAsTypeValue.Elem().FieldByName("AsString").Set(paramReflectValue) case ParamTypeBytes: diff --git a/x/proof/keeper/msg_server_update_param_test.go b/x/proof/keeper/msg_server_update_param_test.go index a53d688ec..11e12cdd8 100644 --- a/x/proof/keeper/msg_server_update_param_test.go +++ b/x/proof/keeper/msg_server_update_param_test.go @@ -16,7 +16,7 @@ import ( ) func TestMsgUpdateParam_UpdateProofRequestProbabilityOnly(t *testing.T) { - var expectedProofRequestProbability float32 = 0.1 + var expectedProofRequestProbability float64 = 0.1 // Set the parameters to their default values k, msgSrv, ctx := setupMsgServer(t) diff --git a/x/proof/keeper/params_test.go b/x/proof/keeper/params_test.go index 43e197d02..69fce0333 100644 --- a/x/proof/keeper/params_test.go +++ b/x/proof/keeper/params_test.go @@ -33,17 +33,17 @@ func TestParams_ValidateProofRequestProbability(t *testing.T) { }, { desc: "ProofRequestProbability less than zero", - proofRequestProbability: float32(-0.25), - expectedErr: prooftypes.ErrProofParamInvalid.Wrapf("invalid ProofRequestProbability: (%v)", float32(-0.25)), + proofRequestProbability: float64(-0.25), + expectedErr: prooftypes.ErrProofParamInvalid.Wrapf("invalid ProofRequestProbability: (%v)", float64(-0.25)), }, { desc: "ProofRequestProbability greater than one", - proofRequestProbability: float32(1.1), - expectedErr: prooftypes.ErrProofParamInvalid.Wrapf("invalid ProofRequestProbability: (%v)", float32(1.1)), + proofRequestProbability: float64(1.1), + expectedErr: prooftypes.ErrProofParamInvalid.Wrapf("invalid ProofRequestProbability: (%v)", float64(1.1)), }, { desc: "valid ProofRequestProbability", - proofRequestProbability: float32(0.25), + proofRequestProbability: float64(0.25), }, } diff --git a/x/proof/keeper/proof_requirement_test.go b/x/proof/keeper/proof_requirement_test.go index 054080c0e..9d58840c1 100644 --- a/x/proof/keeper/proof_requirement_test.go +++ b/x/proof/keeper/proof_requirement_test.go @@ -50,8 +50,8 @@ func TestKeeper_IsProofRequired(t *testing.T) { } } - expectedNumTrueSamples := float32(sampleSize) * probability - expectedNumFalseSamples := float32(sampleSize) * (1 - probability) + expectedNumTrueSamples := float64(sampleSize) * probability + expectedNumFalseSamples := float64(sampleSize) * (1 - probability) toleranceSamples := tolerance * float64(sampleSize) // Check that the number of samples for each outcome is within the expected range. numFalseSamples := sampleSize - numTrueSamples.Load() diff --git a/x/proof/types/claim.go b/x/proof/types/claim.go index 08b3dc406..4cc03af29 100644 --- a/x/proof/types/claim.go +++ b/x/proof/types/claim.go @@ -115,10 +115,9 @@ func (claim *Claim) GetHash() ([]byte, error) { // IMPORTANT: It is assumed that the caller has ensured the hash of the block seed func (claim *Claim) GetProofRequirementSampleValue( proofRequirementSeedBlockHash []byte, -) (proofRequirementSampleValue float32, err error) { +) (float64, error) { // Get the hash of the claim to seed the random number generator. - var claimHash []byte - claimHash, err = claim.GetHash() + claimHash, err := claim.GetHash() if err != nil { return 0, err } @@ -128,12 +127,7 @@ func (claim *Claim) GetProofRequirementSampleValue( // is unknown until the proofRequirementSeedBlockHash is observed. proofRequirementSeed := append(claimHash, proofRequirementSeedBlockHash...) - // Sample a pseudo-random value between 0 and 1 to determine if a proof is + // Sample a pseudo-random value between [0,1) to determine if a proof is // required probabilistically. - proofRequirementSampleValue, err = poktrand.SeededFloat32(proofRequirementSeed) - if err != nil { - return 0, err - } - - return proofRequirementSampleValue, nil + return poktrand.SeededFloat64(proofRequirementSeed), nil } diff --git a/x/proof/types/params.go b/x/proof/types/params.go index 16d77287f..9647651d1 100644 --- a/x/proof/types/params.go +++ b/x/proof/types/params.go @@ -18,7 +18,7 @@ var ( KeyProofRequestProbability = []byte("ProofRequestProbability") ParamProofRequestProbability = "proof_request_probability" - DefaultProofRequestProbability float32 = 0.25 // See: https://github.com/pokt-network/pocket-core/blob/staging/docs/proposals/probabilistic_proofs.md + DefaultProofRequestProbability float64 = 0.25 // See: https://github.com/pokt-network/pocket-core/blob/staging/docs/proposals/probabilistic_proofs.md // The probabilistic proofs paper specifies a threshold of 20 POKT. // TODO_MAINNET(@Olshansk, @RawthiL): Figure out what this value should be. @@ -46,7 +46,7 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams( - proofRequestProbability float32, + proofRequestProbability float64, proofRequirementThreshold *cosmostypes.Coin, proofMissingPenalty *cosmostypes.Coin, proofSubmissionFee *cosmostypes.Coin, @@ -119,7 +119,7 @@ func (params *Params) ValidateBasic() error { // ValidateProofRequestProbability validates the ProofRequestProbability param. // NB: The argument is an interface type to satisfy the ParamSetPair function signature. func ValidateProofRequestProbability(proofRequestProbabilityAny any) error { - proofRequestProbability, ok := proofRequestProbabilityAny.(float32) + proofRequestProbability, ok := proofRequestProbabilityAny.(float64) if !ok { return ErrProofParamInvalid.Wrapf("invalid parameter type: %T", proofRequestProbabilityAny) } diff --git a/x/proof/types/params.pb.go b/x/proof/types/params.pb.go index b84b9ab41..8427231fa 100644 --- a/x/proof/types/params.pb.go +++ b/x/proof/types/params.pb.go @@ -30,7 +30,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { // proof_request_probability is the probability of a session requiring a proof // if it's cost (i.e. compute unit consumption) is below the ProofRequirementThreshold. - ProofRequestProbability float32 `protobuf:"fixed32,2,opt,name=proof_request_probability,json=proofRequestProbability,proto3" json:"proof_request_probability"` + ProofRequestProbability float64 `protobuf:"fixed64,2,opt,name=proof_request_probability,json=proofRequestProbability,proto3" json:"proof_request_probability"` // proof_requirement_threshold is the session cost (i.e. compute unit consumption) // threshold which asserts that a session MUST have a corresponding proof when its cost // is equal to or above the threshold. This is in contrast to the this requirement @@ -80,7 +80,7 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetProofRequestProbability() float32 { +func (m *Params) GetProofRequestProbability() float64 { if m != nil { return m.ProofRequestProbability } @@ -115,32 +115,32 @@ func init() { func init() { proto.RegisterFile("poktroll/proof/params.proto", fileDescriptor_2ad689ad5bf3a2d7) } var fileDescriptor_2ad689ad5bf3a2d7 = []byte{ - // 390 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0xce, 0xd2, 0x40, - 0x14, 0x85, 0x29, 0x28, 0x8b, 0x9a, 0x98, 0x58, 0x31, 0xb4, 0x10, 0xa7, 0xc4, 0x15, 0x31, 0x71, - 0x26, 0xe8, 0xce, 0x25, 0x26, 0xae, 0x34, 0x21, 0xd5, 0x8d, 0x6e, 0x9a, 0x16, 0x87, 0x76, 0x42, - 0x3b, 0xb7, 0xce, 0x0c, 0x2a, 0x3e, 0x82, 0x2b, 0x1f, 0xc1, 0x47, 0xf0, 0x31, 0x5c, 0x12, 0x57, - 0xac, 0x1a, 0x53, 0x16, 0x9a, 0x3e, 0x85, 0x61, 0xa6, 0xc0, 0xe2, 0xe7, 0xff, 0xd9, 0x34, 0x93, - 0xf3, 0xdd, 0x73, 0xce, 0x4d, 0x7a, 0xed, 0x61, 0x01, 0x4b, 0x25, 0x20, 0xcb, 0x48, 0x21, 0x00, - 0x16, 0xa4, 0x88, 0x44, 0x94, 0x4b, 0x5c, 0x08, 0x50, 0xe0, 0xdc, 0x3d, 0x40, 0xac, 0xe1, 0xe0, - 0x5e, 0x94, 0x33, 0x0e, 0x44, 0x7f, 0xcd, 0xc8, 0xa0, 0x97, 0x40, 0x02, 0xfa, 0x49, 0xf6, 0xaf, - 0x46, 0x45, 0x73, 0x90, 0x39, 0x48, 0x12, 0x47, 0x92, 0x92, 0x4f, 0x93, 0x98, 0xaa, 0x68, 0x42, - 0xe6, 0xc0, 0xb8, 0xe1, 0x8f, 0x7e, 0x77, 0xec, 0xee, 0x4c, 0x37, 0x39, 0xef, 0x6c, 0x4f, 0x87, - 0x87, 0x82, 0x7e, 0x5c, 0x51, 0xa9, 0xc2, 0x42, 0x40, 0x1c, 0xc5, 0x2c, 0x63, 0x6a, 0xed, 0xb6, - 0x47, 0xd6, 0xb8, 0x3d, 0x7d, 0x58, 0x97, 0xfe, 0xf5, 0x43, 0x41, 0x5f, 0xa3, 0xc0, 0x90, 0xd9, - 0x09, 0x38, 0x5f, 0xed, 0xe1, 0xc9, 0xc5, 0x04, 0xcd, 0x29, 0x57, 0xa1, 0x4a, 0x05, 0x95, 0x29, - 0x64, 0x1f, 0xdc, 0xce, 0xc8, 0x1a, 0xdf, 0x79, 0xea, 0x61, 0xb3, 0x2b, 0xde, 0xef, 0x8a, 0x9b, - 0x5d, 0xf1, 0x0b, 0x60, 0x7c, 0xea, 0xd7, 0xa5, 0x7f, 0x53, 0x42, 0xe0, 0x1d, 0x9b, 0x1b, 0xf6, - 0xf6, 0x80, 0x9c, 0xd4, 0x7e, 0x60, 0x9c, 0x39, 0x93, 0x92, 0xf1, 0x24, 0x2c, 0x28, 0x8f, 0x32, - 0xb5, 0x76, 0x6f, 0x5d, 0x6a, 0xf5, 0xea, 0xd2, 0x3f, 0xef, 0x0d, 0xee, 0x6b, 0xf9, 0xb5, 0x51, - 0x67, 0x46, 0x74, 0xa8, 0xdd, 0x33, 0xd3, 0x72, 0x15, 0x6b, 0x03, 0xf0, 0x70, 0x41, 0xa9, 0x7b, - 0xfb, 0x52, 0x91, 0x5b, 0x97, 0xfe, 0x59, 0x6b, 0xe0, 0x68, 0xf5, 0xcd, 0x51, 0x7c, 0x49, 0xe9, - 0xf3, 0xd1, 0xbf, 0x1f, 0xbe, 0xf5, 0xed, 0xef, 0xcf, 0xc7, 0xfd, 0xe3, 0xc5, 0x7c, 0x69, 0x6e, - 0xc6, 0xfc, 0xc9, 0xe9, 0xab, 0x5f, 0x15, 0xb2, 0x36, 0x15, 0xb2, 0xb6, 0x15, 0xb2, 0xfe, 0x54, - 0xc8, 0xfa, 0xbe, 0x43, 0xad, 0xcd, 0x0e, 0xb5, 0xb6, 0x3b, 0xd4, 0x7a, 0x8f, 0x13, 0xa6, 0xd2, - 0x55, 0x8c, 0xe7, 0x90, 0x93, 0x7d, 0xc2, 0x13, 0x4e, 0xd5, 0x67, 0x10, 0x4b, 0x72, 0x25, 0x4e, - 0xad, 0x0b, 0x2a, 0xe3, 0xae, 0xbe, 0x94, 0x67, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x68, 0xf0, - 0x63, 0xa9, 0xa1, 0x02, 0x00, 0x00, + // 389 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0xca, 0xd3, 0x40, + 0x14, 0x85, 0x3b, 0xfe, 0xda, 0x45, 0x04, 0xc1, 0x58, 0x69, 0xd2, 0xe2, 0xa4, 0xb8, 0x2a, 0x82, + 0x33, 0x54, 0x77, 0x2e, 0x2b, 0xb8, 0x52, 0x28, 0xd1, 0x8d, 0x6e, 0x42, 0x52, 0xa7, 0xc9, 0xd0, + 0x64, 0x6e, 0x9c, 0x99, 0xaa, 0xf5, 0x11, 0x5c, 0xf9, 0x08, 0x3e, 0x82, 0x8f, 0xe1, 0xb2, 0xb8, + 0xea, 0x2a, 0x48, 0xba, 0x50, 0xf2, 0x14, 0xd2, 0x99, 0xb4, 0x5d, 0x58, 0xed, 0x26, 0x0c, 0xe7, + 0xbb, 0xe7, 0x9c, 0x0b, 0xb9, 0xce, 0xb0, 0x84, 0xa5, 0x96, 0x90, 0xe7, 0xb4, 0x94, 0x00, 0x0b, + 0x5a, 0xc6, 0x32, 0x2e, 0x14, 0x29, 0x25, 0x68, 0x70, 0x6f, 0x1d, 0x20, 0x31, 0x70, 0x70, 0x3b, + 0x2e, 0xb8, 0x00, 0x6a, 0xbe, 0x76, 0x64, 0xd0, 0x4b, 0x21, 0x05, 0xf3, 0xa4, 0xfb, 0x57, 0xab, + 0xe2, 0x39, 0xa8, 0x02, 0x14, 0x4d, 0x62, 0xc5, 0xe8, 0xfb, 0x49, 0xc2, 0x74, 0x3c, 0xa1, 0x73, + 0xe0, 0xc2, 0xf2, 0xfb, 0x3f, 0xae, 0x9c, 0xee, 0xcc, 0x34, 0xb9, 0xaf, 0x1d, 0xdf, 0x84, 0x47, + 0x92, 0xbd, 0x5b, 0x31, 0xa5, 0xa3, 0x52, 0x42, 0x12, 0x27, 0x3c, 0xe7, 0x7a, 0xed, 0x5d, 0x1b, + 0xa1, 0x31, 0x9a, 0xde, 0x6b, 0xaa, 0xe0, 0xdf, 0x43, 0x61, 0xdf, 0xa0, 0xd0, 0x92, 0xd9, 0x09, + 0xb8, 0x9f, 0x9c, 0xe1, 0xc9, 0xc5, 0x25, 0x2b, 0x98, 0xd0, 0x91, 0xce, 0x24, 0x53, 0x19, 0xe4, + 0x6f, 0xbd, 0xab, 0x11, 0x1a, 0xdf, 0x7c, 0xe4, 0x13, 0xbb, 0x2b, 0xd9, 0xef, 0x4a, 0xda, 0x5d, + 0xc9, 0x53, 0xe0, 0x62, 0x1a, 0x34, 0x55, 0xf0, 0xbf, 0x84, 0xd0, 0x3f, 0x36, 0xb7, 0xec, 0xd5, + 0x01, 0xb9, 0x99, 0x73, 0xd7, 0x3a, 0x0b, 0xae, 0x14, 0x17, 0x69, 0x54, 0x32, 0x11, 0xe7, 0x7a, + 0xed, 0x5d, 0xbf, 0xd4, 0xea, 0x37, 0x55, 0x70, 0xde, 0x1b, 0xde, 0x31, 0xf2, 0x0b, 0xab, 0xce, + 0xac, 0xe8, 0x32, 0xa7, 0x67, 0xa7, 0xd5, 0x2a, 0x31, 0x06, 0x10, 0xd1, 0x82, 0x31, 0xef, 0xc6, + 0xa5, 0x22, 0xaf, 0xa9, 0x82, 0xb3, 0xd6, 0xd0, 0x35, 0xea, 0xcb, 0xa3, 0xf8, 0x8c, 0xb1, 0x27, + 0xa3, 0xdf, 0x5f, 0x03, 0xf4, 0xf9, 0xd7, 0xb7, 0x07, 0xfd, 0xe3, 0xc5, 0x7c, 0x6c, 0x6f, 0xc6, + 0xfe, 0xc9, 0xe9, 0xf3, 0xef, 0x35, 0x46, 0x9b, 0x1a, 0xa3, 0x6d, 0x8d, 0xd1, 0xcf, 0x1a, 0xa3, + 0x2f, 0x3b, 0xdc, 0xd9, 0xec, 0x70, 0x67, 0xbb, 0xc3, 0x9d, 0x37, 0x24, 0xe5, 0x3a, 0x5b, 0x25, + 0x64, 0x0e, 0x05, 0xdd, 0x27, 0x3c, 0x14, 0x4c, 0x7f, 0x00, 0xb9, 0xa4, 0x7f, 0xc5, 0xe9, 0x75, + 0xc9, 0x54, 0xd2, 0x35, 0x97, 0xf2, 0xf8, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xde, 0xa6, 0xe4, + 0x39, 0xa1, 0x02, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -233,10 +233,10 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } if m.ProofRequestProbability != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.ProofRequestProbability)))) + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.ProofRequestProbability)))) i-- - dAtA[i] = 0x15 + dAtA[i] = 0x11 } return len(dAtA) - i, nil } @@ -259,7 +259,7 @@ func (m *Params) Size() (n int) { var l int _ = l if m.ProofRequestProbability != 0 { - n += 5 + n += 9 } if m.ProofRequirementThreshold != nil { l = m.ProofRequirementThreshold.Size() @@ -312,16 +312,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { case 2: - if wireType != 5 { + if wireType != 1 { return fmt.Errorf("proto: wrong wireType = %d for field ProofRequestProbability", wireType) } - var v uint32 - if (iNdEx + 4) > l { + var v uint64 + if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - m.ProofRequestProbability = float32(math.Float32frombits(v)) + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.ProofRequestProbability = float64(math.Float64frombits(v)) case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofRequirementThreshold", wireType) diff --git a/x/proof/types/tx.pb.go b/x/proof/types/tx.pb.go index 61d576174..c533c5dd9 100644 --- a/x/proof/types/tx.pb.go +++ b/x/proof/types/tx.pb.go @@ -174,7 +174,7 @@ type MsgUpdateParam_AsBytes struct { AsBytes []byte `protobuf:"bytes,7,opt,name=as_bytes,json=asBytes,proto3,oneof" json:"as_bytes"` } type MsgUpdateParam_AsFloat struct { - AsFloat float32 `protobuf:"fixed32,8,opt,name=as_float,json=asFloat,proto3,oneof" json:"as_float"` + AsFloat float64 `protobuf:"fixed64,8,opt,name=as_float,json=asFloat,proto3,oneof" json:"as_float"` } type MsgUpdateParam_AsCoin struct { AsCoin *types.Coin `protobuf:"bytes,9,opt,name=as_coin,json=asCoin,proto3,oneof" json:"as_coin"` @@ -212,7 +212,7 @@ func (m *MsgUpdateParam) GetAsBytes() []byte { return nil } -func (m *MsgUpdateParam) GetAsFloat() float32 { +func (m *MsgUpdateParam) GetAsFloat() float64 { if x, ok := m.GetAsType().(*MsgUpdateParam_AsFloat); ok { return x.AsFloat } @@ -485,54 +485,54 @@ func init() { func init() { proto.RegisterFile("poktroll/proof/tx.proto", fileDescriptor_345e95e87511f6a6) } var fileDescriptor_345e95e87511f6a6 = []byte{ - // 747 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x4d, 0x4f, 0xdb, 0x4c, - 0x10, 0x8e, 0xc3, 0xcb, 0x47, 0x36, 0xbc, 0x79, 0xf5, 0x5a, 0x94, 0x7c, 0xd0, 0x3a, 0x51, 0x0e, - 0x6d, 0x4a, 0x85, 0x2d, 0x40, 0xaa, 0x54, 0x6e, 0x04, 0x15, 0xe5, 0x50, 0x54, 0x64, 0x8a, 0x54, - 0xf5, 0x12, 0x6d, 0x92, 0x25, 0xb6, 0x88, 0xbd, 0xd6, 0xee, 0x86, 0xc2, 0xad, 0xea, 0xb1, 0x27, - 0x7e, 0x46, 0x8f, 0x1c, 0x7a, 0xe9, 0x3f, 0xe0, 0x88, 0x7a, 0xe2, 0x84, 0xaa, 0x50, 0x09, 0x09, - 0xfe, 0x44, 0xb5, 0x1f, 0x76, 0x1c, 0x37, 0x40, 0xd5, 0x53, 0x2f, 0xf1, 0xee, 0x3c, 0xcf, 0x4c, - 0x66, 0x9e, 0x19, 0x8f, 0x41, 0x3e, 0xc0, 0xfb, 0x8c, 0xe0, 0x5e, 0xcf, 0x0a, 0x08, 0xc6, 0x7b, - 0x16, 0x3b, 0x34, 0x03, 0x82, 0x19, 0xd6, 0x73, 0x21, 0x60, 0x0a, 0xa0, 0xf4, 0x3f, 0xf4, 0x5c, - 0x1f, 0x5b, 0xe2, 0x57, 0x52, 0x4a, 0x46, 0x1b, 0x53, 0x0f, 0x53, 0xab, 0x05, 0x29, 0xb2, 0x0e, - 0x96, 0x5b, 0x88, 0xc1, 0x65, 0xab, 0x8d, 0x5d, 0x5f, 0xe1, 0x79, 0x85, 0x7b, 0xb4, 0x6b, 0x1d, - 0x2c, 0xf3, 0x87, 0x02, 0x8a, 0x12, 0x68, 0x8a, 0x9b, 0x25, 0x2f, 0x0a, 0x9a, 0xeb, 0xe2, 0x2e, - 0x96, 0x76, 0x7e, 0x52, 0xd6, 0x85, 0x44, 0x96, 0x01, 0x24, 0xd0, 0x0b, 0x5d, 0x4a, 0xc9, 0x12, - 0x8e, 0x02, 0x14, 0x62, 0x0f, 0x23, 0x8c, 0x22, 0x4a, 0x5d, 0xec, 0x8f, 0xa0, 0x8f, 0x86, 0xa8, - 0x03, 0x09, 0xea, 0x58, 0x14, 0x91, 0x03, 0xb7, 0x8d, 0x24, 0x5c, 0xfd, 0xaa, 0x81, 0xff, 0xb6, - 0x68, 0x77, 0x37, 0xe8, 0x40, 0x86, 0xb6, 0xc5, 0x5f, 0xea, 0xcf, 0x41, 0x06, 0xf6, 0x99, 0x83, - 0x89, 0xcb, 0x8e, 0x0a, 0x5a, 0x45, 0xab, 0x65, 0xea, 0x85, 0x6f, 0x5f, 0x96, 0xe6, 0x54, 0x11, - 0xeb, 0x9d, 0x0e, 0x41, 0x94, 0xee, 0x30, 0xe2, 0xfa, 0x5d, 0x7b, 0x48, 0xd5, 0x5f, 0x80, 0x29, - 0x99, 0x74, 0x21, 0x5d, 0xd1, 0x6a, 0xd9, 0x95, 0x79, 0x73, 0x54, 0x5f, 0x53, 0xc6, 0xaf, 0x67, - 0x4e, 0x2f, 0xca, 0xa9, 0xcf, 0x57, 0x27, 0x8b, 0x9a, 0xad, 0x1c, 0xd6, 0x56, 0x3f, 0x5e, 0x9d, - 0x2c, 0x0e, 0x43, 0x7d, 0xba, 0x3a, 0x59, 0xac, 0x44, 0x89, 0x1f, 0xaa, 0xa2, 0x13, 0x79, 0x56, - 0x8b, 0x20, 0x9f, 0x30, 0xd9, 0x88, 0x06, 0xd8, 0xa7, 0xa8, 0x7a, 0x9c, 0x06, 0xb9, 0x51, 0xec, - 0x8f, 0xab, 0xd2, 0xc1, 0x3f, 0x3e, 0xf4, 0x90, 0xa8, 0x29, 0x63, 0x8b, 0xb3, 0xfe, 0x14, 0xcc, - 0x40, 0xda, 0x6c, 0x1d, 0x31, 0x44, 0x0b, 0xd3, 0x15, 0xad, 0x36, 0x5b, 0x9f, 0xbd, 0xbe, 0x28, - 0x47, 0xb6, 0x46, 0xca, 0x9e, 0x86, 0xb4, 0xce, 0x8f, 0x8a, 0xba, 0xd7, 0xc3, 0x90, 0x15, 0x66, - 0x2a, 0x5a, 0x2d, 0x1d, 0x51, 0x85, 0x4d, 0x52, 0x37, 0xf9, 0x51, 0x5f, 0x07, 0xd3, 0x90, 0x36, - 0xf9, 0x70, 0x15, 0x32, 0x42, 0xc0, 0xa2, 0xa9, 0x92, 0xe3, 0xd3, 0x67, 0xaa, 0xe9, 0x33, 0x37, - 0xb0, 0xeb, 0xd7, 0xb3, 0xd7, 0x17, 0xe5, 0x90, 0xdd, 0x48, 0xd9, 0x53, 0x90, 0x72, 0xf3, 0x5a, - 0x6e, 0x54, 0xc7, 0x7a, 0x46, 0x84, 0xe4, 0xf3, 0x50, 0x6d, 0x80, 0xf9, 0x51, 0x45, 0x42, 0xb1, - 0x74, 0x33, 0xea, 0x9b, 0x76, 0x57, 0xdf, 0xc2, 0x66, 0x55, 0x6f, 0x34, 0x21, 0xee, 0x06, 0x41, - 0x90, 0xa1, 0x8d, 0x1e, 0x74, 0x3d, 0xfd, 0x0d, 0x28, 0xd2, 0x7e, 0x10, 0xf4, 0x5c, 0x44, 0x9a, - 0x38, 0x40, 0x04, 0x32, 0x4c, 0x9a, 0x50, 0x4a, 0x7a, 0xaf, 0xd8, 0xf9, 0xd0, 0xf5, 0xb5, 0xf2, - 0x54, 0xb0, 0xbe, 0x09, 0x72, 0x6a, 0xa4, 0x9b, 0x0e, 0x82, 0x1d, 0x44, 0xd4, 0x60, 0x95, 0x87, - 0x09, 0x2a, 0xdc, 0xdc, 0x91, 0xcf, 0x86, 0xa0, 0xd9, 0xff, 0xd2, 0xf8, 0x55, 0x5f, 0x00, 0x19, - 0x82, 0x31, 0x6b, 0x3a, 0x90, 0x3a, 0x85, 0x09, 0xde, 0x2f, 0x7b, 0x86, 0x1b, 0x1a, 0x90, 0x3a, - 0x6b, 0x06, 0x97, 0xec, 0xf6, 0xec, 0xab, 0x2f, 0x85, 0x6e, 0xb1, 0x62, 0x23, 0xdd, 0x9e, 0x81, - 0xc9, 0x36, 0x37, 0x28, 0xd9, 0x1e, 0x24, 0x65, 0x93, 0x6c, 0xc9, 0xa9, 0xfe, 0x90, 0xa2, 0xed, - 0xf4, 0x5b, 0x9e, 0xcb, 0xb6, 0x39, 0xfe, 0x97, 0x8b, 0x36, 0x07, 0x26, 0x45, 0x19, 0x4a, 0x30, - 0x79, 0xf9, 0x4d, 0xb5, 0x62, 0x55, 0xc6, 0xd5, 0x92, 0xf1, 0x6e, 0x51, 0x4b, 0xb2, 0x25, 0x67, - 0xe5, 0x26, 0x0d, 0x26, 0xb6, 0x68, 0x57, 0x7f, 0x0b, 0x66, 0x47, 0x56, 0x53, 0x39, 0xe9, 0x95, - 0x58, 0x00, 0xa5, 0x27, 0xf7, 0x10, 0xa2, 0x74, 0x76, 0x41, 0x36, 0x3e, 0xc0, 0xc6, 0x18, 0xbf, - 0x18, 0x5e, 0x7a, 0x7c, 0x37, 0x1e, 0x0f, 0x1b, 0x6f, 0xf1, 0xb8, 0xb0, 0x31, 0x7c, 0x6c, 0xd8, - 0x71, 0xe2, 0xed, 0x82, 0x6c, 0x7c, 0x97, 0x19, 0x77, 0x57, 0x39, 0x36, 0xec, 0x98, 0x37, 0xbf, - 0x34, 0xf9, 0x81, 0x6f, 0xe1, 0xfa, 0xab, 0xd3, 0x81, 0xa1, 0x9d, 0x0d, 0x0c, 0xed, 0x7c, 0x60, - 0x68, 0xdf, 0x07, 0x86, 0x76, 0x7c, 0x69, 0xa4, 0xce, 0x2e, 0x8d, 0xd4, 0xf9, 0xa5, 0x91, 0x7a, - 0x67, 0x76, 0x5d, 0xe6, 0xf4, 0x5b, 0x66, 0x1b, 0x7b, 0x16, 0x0f, 0xbb, 0xe4, 0x23, 0xf6, 0x1e, - 0x93, 0x7d, 0xeb, 0x97, 0x05, 0x2d, 0xbe, 0x3b, 0xad, 0x29, 0xf1, 0x65, 0x59, 0xfd, 0x19, 0x00, - 0x00, 0xff, 0xff, 0x70, 0xd3, 0xcd, 0x4c, 0x77, 0x07, 0x00, 0x00, + // 745 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x4f, 0x4f, 0x13, 0x41, + 0x14, 0xef, 0x80, 0xfc, 0xe9, 0x14, 0x6b, 0xdc, 0x20, 0xfd, 0x83, 0x6e, 0x9b, 0x1e, 0xb4, 0x62, + 0xd8, 0x0d, 0x90, 0x98, 0xc8, 0x8d, 0x12, 0x49, 0x0f, 0x12, 0xc9, 0x22, 0x89, 0xf1, 0xd2, 0x4c, + 0xdb, 0xa1, 0xdd, 0xd0, 0xdd, 0xd9, 0xcc, 0x4c, 0x11, 0x6e, 0xc6, 0xa3, 0x27, 0x3e, 0x86, 0x47, + 0x0e, 0x5e, 0xfc, 0x06, 0x1c, 0x89, 0x27, 0x4e, 0xc4, 0x14, 0x13, 0x12, 0xf8, 0x12, 0x66, 0xfe, + 0x74, 0xbb, 0x5d, 0x0b, 0x18, 0x4f, 0x5e, 0xba, 0x33, 0xef, 0xf7, 0x7b, 0xaf, 0xef, 0xfd, 0xde, + 0xdb, 0xb7, 0x30, 0x13, 0x90, 0x3d, 0x4e, 0x49, 0xa7, 0x63, 0x07, 0x94, 0x90, 0x5d, 0x9b, 0x1f, + 0x58, 0x01, 0x25, 0x9c, 0x18, 0xe9, 0x3e, 0x60, 0x49, 0x20, 0xff, 0x10, 0x79, 0xae, 0x4f, 0x6c, + 0xf9, 0xab, 0x28, 0x79, 0xb3, 0x41, 0x98, 0x47, 0x98, 0x5d, 0x47, 0x0c, 0xdb, 0xfb, 0x4b, 0x75, + 0xcc, 0xd1, 0x92, 0xdd, 0x20, 0xae, 0xaf, 0xf1, 0x8c, 0xc6, 0x3d, 0xd6, 0xb2, 0xf7, 0x97, 0xc4, + 0x43, 0x03, 0x39, 0x05, 0xd4, 0xe4, 0xcd, 0x56, 0x17, 0x0d, 0xcd, 0xb6, 0x48, 0x8b, 0x28, 0xbb, + 0x38, 0x69, 0xeb, 0x7c, 0x2c, 0xcb, 0x00, 0x51, 0xe4, 0xf5, 0x5d, 0xf2, 0xf1, 0x12, 0x0e, 0x03, + 0xdc, 0xc7, 0x1e, 0x87, 0x18, 0xc3, 0x8c, 0xb9, 0xc4, 0x1f, 0x42, 0x9f, 0x0c, 0xd0, 0x36, 0xa2, + 0xb8, 0x69, 0x33, 0x4c, 0xf7, 0xdd, 0x06, 0x56, 0x70, 0xe9, 0x3b, 0x80, 0x0f, 0x36, 0x59, 0x6b, + 0x27, 0x68, 0x22, 0x8e, 0xb7, 0xe4, 0x5f, 0x1a, 0x2f, 0x61, 0x12, 0x75, 0x79, 0x9b, 0x50, 0x97, + 0x1f, 0x66, 0x41, 0x11, 0x94, 0x93, 0x95, 0xec, 0x8f, 0x6f, 0x8b, 0xb3, 0xba, 0x88, 0xb5, 0x66, + 0x93, 0x62, 0xc6, 0xb6, 0x39, 0x75, 0xfd, 0x96, 0x33, 0xa0, 0x1a, 0xaf, 0xe0, 0xa4, 0x4a, 0x3a, + 0x3b, 0x56, 0x04, 0xe5, 0xd4, 0xf2, 0x9c, 0x35, 0xac, 0xaf, 0xa5, 0xe2, 0x57, 0x92, 0x27, 0xe7, + 0x85, 0xc4, 0xd7, 0xcb, 0xe3, 0x05, 0xe0, 0x68, 0x87, 0xd5, 0x95, 0xcf, 0x97, 0xc7, 0x0b, 0x83, + 0x50, 0x5f, 0x2e, 0x8f, 0x17, 0x8a, 0x61, 0xe2, 0x07, 0xba, 0xe8, 0x58, 0x9e, 0xa5, 0x1c, 0xcc, + 0xc4, 0x4c, 0x0e, 0x66, 0x01, 0xf1, 0x19, 0x2e, 0x1d, 0x8d, 0xc1, 0xf4, 0x30, 0xf6, 0xcf, 0x55, + 0x19, 0xf0, 0x9e, 0x8f, 0x3c, 0x2c, 0x6b, 0x4a, 0x3a, 0xf2, 0x6c, 0x3c, 0x87, 0xd3, 0x88, 0xd5, + 0xea, 0x87, 0x1c, 0xb3, 0xec, 0x54, 0x11, 0x94, 0x67, 0x2a, 0x33, 0x57, 0xe7, 0x85, 0xd0, 0x56, + 0x4d, 0x38, 0x53, 0x88, 0x55, 0xc4, 0x51, 0x53, 0x77, 0x3b, 0x04, 0xf1, 0xec, 0x74, 0x11, 0x94, + 0x41, 0x48, 0x95, 0x36, 0x45, 0xdd, 0x10, 0x47, 0x63, 0x0d, 0x4e, 0x21, 0x56, 0x13, 0xc3, 0x95, + 0x4d, 0x4a, 0x01, 0x73, 0x96, 0x4e, 0x4e, 0x4c, 0x9f, 0xa5, 0xa7, 0xcf, 0x5a, 0x27, 0xae, 0x5f, + 0x49, 0x5d, 0x9d, 0x17, 0xfa, 0xec, 0x6a, 0xc2, 0x99, 0x44, 0x4c, 0x98, 0x57, 0xd3, 0xc3, 0x3a, + 0x56, 0x92, 0x32, 0xa4, 0x98, 0x87, 0x52, 0x15, 0xce, 0x0d, 0x2b, 0xd2, 0x17, 0xcb, 0xb0, 0xc2, + 0xbe, 0x81, 0xdb, 0xfa, 0xd6, 0x6f, 0x56, 0xe9, 0x1a, 0x48, 0x71, 0xd7, 0x29, 0x46, 0x1c, 0xaf, + 0x77, 0x90, 0xeb, 0x19, 0xef, 0x60, 0x8e, 0x75, 0x83, 0xa0, 0xe3, 0x62, 0x5a, 0x23, 0x01, 0xa6, + 0x88, 0x13, 0x5a, 0x43, 0x4a, 0xd2, 0x3b, 0xc5, 0xce, 0xf4, 0x5d, 0xdf, 0x6a, 0x4f, 0x0d, 0x1b, + 0x1b, 0x30, 0xad, 0x47, 0xba, 0xd6, 0xc6, 0xa8, 0x89, 0xa9, 0x1e, 0xac, 0xc2, 0x20, 0x41, 0x8d, + 0x5b, 0xdb, 0xea, 0x59, 0x95, 0x34, 0xe7, 0x3e, 0x8b, 0x5e, 0x8d, 0x79, 0x98, 0xa4, 0x84, 0xf0, + 0x5a, 0x1b, 0xb1, 0x76, 0x76, 0x5c, 0xf4, 0xcb, 0x99, 0x16, 0x86, 0x2a, 0x62, 0xed, 0x55, 0x53, + 0x48, 0x76, 0x73, 0xf6, 0xa5, 0xd7, 0x52, 0xb7, 0x48, 0xb1, 0xa1, 0x6e, 0x2f, 0xe0, 0x44, 0x43, + 0x18, 0xb4, 0x6c, 0x8f, 0xe2, 0xb2, 0x29, 0xb6, 0xe2, 0x94, 0x7e, 0x29, 0xd1, 0xb6, 0xbb, 0x75, + 0xcf, 0xe5, 0x5b, 0x02, 0xff, 0xcf, 0x45, 0x9b, 0x85, 0x13, 0xb2, 0x0c, 0x2d, 0x98, 0xba, 0xfc, + 0xa5, 0x5a, 0x91, 0x2a, 0xa3, 0x6a, 0xa9, 0x78, 0x37, 0xa8, 0xa5, 0xd8, 0x8a, 0xb3, 0x7c, 0x3d, + 0x06, 0xc7, 0x37, 0x59, 0xcb, 0x78, 0x0f, 0x67, 0x86, 0x56, 0x53, 0x21, 0xee, 0x15, 0x5b, 0x00, + 0xf9, 0x67, 0x77, 0x10, 0xc2, 0x74, 0x76, 0x60, 0x2a, 0x3a, 0xc0, 0xe6, 0x08, 0xbf, 0x08, 0x9e, + 0x7f, 0x7a, 0x3b, 0x1e, 0x0d, 0x1b, 0x6d, 0xf1, 0xa8, 0xb0, 0x11, 0x7c, 0x64, 0xd8, 0x51, 0xe2, + 0xed, 0xc0, 0x54, 0x74, 0x97, 0x99, 0xb7, 0x57, 0x39, 0x32, 0xec, 0x88, 0x37, 0x3f, 0x3f, 0xf1, + 0x49, 0x6c, 0xe1, 0xca, 0x9b, 0x93, 0x9e, 0x09, 0x4e, 0x7b, 0x26, 0x38, 0xeb, 0x99, 0xe0, 0x67, + 0xcf, 0x04, 0x47, 0x17, 0x66, 0xe2, 0xf4, 0xc2, 0x4c, 0x9c, 0x5d, 0x98, 0x89, 0x0f, 0x56, 0xcb, + 0xe5, 0xed, 0x6e, 0xdd, 0x6a, 0x10, 0xcf, 0x16, 0x61, 0x17, 0x7d, 0xcc, 0x3f, 0x12, 0xba, 0x67, + 0xff, 0xb1, 0xa0, 0xe5, 0x77, 0xa7, 0x3e, 0x29, 0xbf, 0x2c, 0x2b, 0xbf, 0x03, 0x00, 0x00, 0xff, + 0xff, 0x35, 0xfa, 0xd8, 0x87, 0x77, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -859,10 +859,10 @@ func (m *MsgUpdateParam_AsFloat) MarshalTo(dAtA []byte) (int, error) { func (m *MsgUpdateParam_AsFloat) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.AsFloat)))) + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.AsFloat)))) i-- - dAtA[i] = 0x45 + dAtA[i] = 0x41 return len(dAtA) - i, nil } func (m *MsgUpdateParam_AsCoin) MarshalTo(dAtA []byte) (int, error) { @@ -1162,7 +1162,7 @@ func (m *MsgUpdateParam_AsFloat) Size() (n int) { } var l int _ = l - n += 5 + n += 9 return n } func (m *MsgUpdateParam_AsCoin) Size() (n int) { @@ -1556,16 +1556,16 @@ func (m *MsgUpdateParam) Unmarshal(dAtA []byte) error { m.AsType = &MsgUpdateParam_AsBytes{v} iNdEx = postIndex case 8: - if wireType != 5 { + if wireType != 1 { return fmt.Errorf("proto: wrong wireType = %d for field AsFloat", wireType) } - var v uint32 - if (iNdEx + 4) > l { + var v uint64 + if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - m.AsType = &MsgUpdateParam_AsFloat{float32(math.Float32frombits(v))} + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.AsType = &MsgUpdateParam_AsFloat{float64(math.Float64frombits(v))} case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AsCoin", wireType) diff --git a/x/tokenomics/keeper/msg_server_update_param.go b/x/tokenomics/keeper/msg_server_update_param.go index 41887bd0e..c8dd118f0 100644 --- a/x/tokenomics/keeper/msg_server_update_param.go +++ b/x/tokenomics/keeper/msg_server_update_param.go @@ -33,8 +33,8 @@ func (k msgServer) UpdateParam( switch msg.Name { case tokenomicstypes.ParamMintAllocationDao: - logger = logger.With("param_value", msg.GetAsDouble()) - params.MintAllocationDao = msg.GetAsDouble() + logger = logger.With("param_value", msg.GetAsFloat()) + params.MintAllocationDao = msg.GetAsFloat() default: return nil, status.Error( codes.InvalidArgument, diff --git a/x/tokenomics/keeper/msg_server_update_param_test.go b/x/tokenomics/keeper/msg_server_update_param_test.go index 070c104d7..62fdc16c2 100644 --- a/x/tokenomics/keeper/msg_server_update_param_test.go +++ b/x/tokenomics/keeper/msg_server_update_param_test.go @@ -26,7 +26,7 @@ func TestMsgUpdateParam_UpdateMintAllocationDaoOnly(t *testing.T) { updateParamMsg := &tokenomicstypes.MsgUpdateParam{ Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), Name: tokenomicstypes.ParamMintAllocationDao, - AsType: &tokenomicstypes.MsgUpdateParam_AsDouble{AsDouble: expectedMintAllocationDao}, + AsType: &tokenomicstypes.MsgUpdateParam_AsFloat{AsFloat: expectedMintAllocationDao}, } res, err := msgSrv.UpdateParam(ctx, updateParamMsg) require.NoError(t, err) diff --git a/x/tokenomics/types/message_update_param.go b/x/tokenomics/types/message_update_param.go index 857416c00..24c4f4530 100644 --- a/x/tokenomics/types/message_update_param.go +++ b/x/tokenomics/types/message_update_param.go @@ -13,7 +13,7 @@ func NewMsgUpdateParam(authority string, name string, asTypeAny any) (*MsgUpdate switch asType := asTypeAny.(type) { case float64: - asTypeIface = &MsgUpdateParam_AsDouble{AsDouble: asType} + asTypeIface = &MsgUpdateParam_AsFloat{AsFloat: asType} default: return nil, fmt.Errorf("unexpected param value type: %T", asTypeAny) } @@ -42,20 +42,20 @@ func (msg *MsgUpdateParam) ValidateBasic() error { // Parameter name must be supported by this module. switch msg.Name { case ParamMintAllocationDao: - if err := msg.paramTypeIsDouble(); err != nil { + if err := msg.paramTypeIsFloat(); err != nil { return err } - return ValidateMintAllocationDao(msg.GetAsDouble()) + return ValidateMintAllocationDao(msg.GetAsFloat()) default: return ErrTokenomicsParamNameInvalid.Wrapf("unsupported param %q", msg.Name) } } -func (msg *MsgUpdateParam) paramTypeIsDouble() error { - if _, ok := msg.AsType.(*MsgUpdateParam_AsDouble); !ok { +func (msg *MsgUpdateParam) paramTypeIsFloat() error { + if _, ok := msg.AsType.(*MsgUpdateParam_AsFloat); !ok { return ErrTokenomicsParamInvalid.Wrapf( "invalid type for param %q; expected %T, got %T", - msg.Name, &MsgUpdateParam_AsDouble{}, msg.AsType, + msg.Name, &MsgUpdateParam_AsFloat{}, msg.AsType, ) } diff --git a/x/tokenomics/types/message_update_param_test.go b/x/tokenomics/types/message_update_param_test.go index 52adf3382..12a91c09f 100644 --- a/x/tokenomics/types/message_update_param_test.go +++ b/x/tokenomics/types/message_update_param_test.go @@ -20,7 +20,7 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { msg: MsgUpdateParam{ Authority: "invalid_address", Name: "", // Doesn't matter for this test - AsType: &MsgUpdateParam_AsDouble{AsDouble: 1}, + AsType: &MsgUpdateParam_AsFloat{AsFloat: 1}, }, expectedErr: ErrTokenomicsAddressInvalid, @@ -29,7 +29,7 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { msg: MsgUpdateParam{ Authority: sample.AccAddress(), Name: "invalid", - AsType: &MsgUpdateParam_AsDouble{AsDouble: 1}, + AsType: &MsgUpdateParam_AsFloat{AsFloat: 1}, }, expectedErr: ErrTokenomicsParamNameInvalid, }, @@ -38,7 +38,7 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { msg: MsgUpdateParam{ Authority: sample.AccAddress(), Name: ParamMintAllocationDao, - AsType: &MsgUpdateParam_AsDouble{AsDouble: DefaultMintAllocationDao}, + AsType: &MsgUpdateParam_AsFloat{AsFloat: DefaultMintAllocationDao}, }, }, } diff --git a/x/tokenomics/types/tx.pb.go b/x/tokenomics/types/tx.pb.go index 8393369df..d824fd4af 100644 --- a/x/tokenomics/types/tx.pb.go +++ b/x/tokenomics/types/tx.pb.go @@ -126,7 +126,7 @@ type MsgUpdateParam struct { // specified in the `Params` message in `proof/params.proto.` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Types that are valid to be assigned to AsType: - // *MsgUpdateParam_AsDouble + // *MsgUpdateParam_AsFloat AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` } @@ -165,11 +165,11 @@ type isMsgUpdateParam_AsType interface { Size() int } -type MsgUpdateParam_AsDouble struct { - AsDouble float64 `protobuf:"fixed64,3,opt,name=as_double,json=asDouble,proto3,oneof" json:"as_double"` +type MsgUpdateParam_AsFloat struct { + AsFloat float64 `protobuf:"fixed64,3,opt,name=as_float,json=asFloat,proto3,oneof" json:"as_float"` } -func (*MsgUpdateParam_AsDouble) isMsgUpdateParam_AsType() {} +func (*MsgUpdateParam_AsFloat) isMsgUpdateParam_AsType() {} func (m *MsgUpdateParam) GetAsType() isMsgUpdateParam_AsType { if m != nil { @@ -192,9 +192,9 @@ func (m *MsgUpdateParam) GetName() string { return "" } -func (m *MsgUpdateParam) GetAsDouble() float64 { - if x, ok := m.GetAsType().(*MsgUpdateParam_AsDouble); ok { - return x.AsDouble +func (m *MsgUpdateParam) GetAsFloat() float64 { + if x, ok := m.GetAsType().(*MsgUpdateParam_AsFloat); ok { + return x.AsFloat } return 0 } @@ -202,7 +202,7 @@ func (m *MsgUpdateParam) GetAsDouble() float64 { // XXX_OneofWrappers is for the internal use of the proto package. func (*MsgUpdateParam) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*MsgUpdateParam_AsDouble)(nil), + (*MsgUpdateParam_AsFloat)(nil), } } @@ -258,7 +258,7 @@ func init() { func init() { proto.RegisterFile("poktroll/tokenomics/tx.proto", fileDescriptor_aa0f2fdbd9b6d7eb) } var fileDescriptor_aa0f2fdbd9b6d7eb = []byte{ - // 461 bytes of a gzipped FileDescriptorProto + // 460 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0xc8, 0xcf, 0x2e, 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0xcb, 0xcf, 0xcd, 0x4c, 0x2e, 0xd6, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc9, 0xea, 0x21, 0x64, 0xa5, @@ -274,20 +274,20 @@ var fileDescriptor_aa0f2fdbd9b6d7eb = []byte{ 0xc4, 0x3d, 0x79, 0x86, 0x15, 0xcf, 0x37, 0x68, 0x31, 0x06, 0x41, 0x75, 0x59, 0x59, 0x34, 0x3d, 0xdf, 0xa0, 0x85, 0x30, 0xaf, 0xeb, 0xf9, 0x06, 0x2d, 0x55, 0xb8, 0x07, 0x2a, 0x90, 0xbd, 0x80, 0xe6, 0x62, 0x25, 0x49, 0x2e, 0x71, 0x34, 0xa1, 0xa0, 0xd4, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, - 0xa5, 0xa5, 0x8c, 0x5c, 0x7c, 0xa8, 0x72, 0x64, 0xfb, 0x4f, 0x88, 0x8b, 0x25, 0x2f, 0x31, 0x37, - 0x15, 0xec, 0x3b, 0xce, 0x20, 0x30, 0x5b, 0x48, 0x87, 0x8b, 0x33, 0xb1, 0x38, 0x3e, 0x25, 0xbf, - 0x34, 0x29, 0x27, 0x55, 0x82, 0x59, 0x81, 0x51, 0x83, 0xd1, 0x89, 0xf7, 0xd5, 0x3d, 0x79, 0x84, - 0xa0, 0x07, 0x43, 0x10, 0x47, 0x62, 0xb1, 0x0b, 0x98, 0x6d, 0xc5, 0x87, 0xea, 0x43, 0x27, 0x4e, - 0x2e, 0xf6, 0xc4, 0xe2, 0xf8, 0x92, 0xca, 0x82, 0x54, 0x25, 0x5f, 0x2e, 0x31, 0x54, 0x67, 0xc2, - 0x7c, 0x20, 0x64, 0x0c, 0x0f, 0x56, 0x46, 0x82, 0xc1, 0x0a, 0x0b, 0x4b, 0xa3, 0x8b, 0x8c, 0x5c, - 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0x49, 0x5c, 0x3c, 0x28, 0x71, 0xab, 0x82, 0x55, 0x33, 0x5a, 0xe0, - 0x49, 0xe9, 0x10, 0xa3, 0x0a, 0xee, 0xc0, 0x78, 0x2e, 0x6e, 0xe4, 0xe0, 0x55, 0x26, 0x42, 0xb3, - 0x94, 0x36, 0x11, 0x8a, 0x60, 0x16, 0x48, 0xb1, 0x36, 0x80, 0xd2, 0x89, 0x53, 0xe0, 0x89, 0x47, - 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0xde, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, - 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x9c, 0x9e, 0x59, - 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x32, 0x5b, 0x37, 0x2f, 0xb5, 0xa4, 0x3c, - 0xbf, 0x28, 0x5b, 0x1f, 0x7b, 0x12, 0x02, 0x05, 0x7a, 0x71, 0x12, 0x1b, 0x38, 0x17, 0x18, 0x03, - 0x02, 0x00, 0x00, 0xff, 0xff, 0x25, 0x85, 0x43, 0x68, 0xb9, 0x03, 0x00, 0x00, + 0xa5, 0x45, 0x8c, 0x5c, 0x7c, 0xa8, 0x72, 0x64, 0xfb, 0x4f, 0x88, 0x8b, 0x25, 0x2f, 0x31, 0x37, + 0x15, 0xec, 0x3b, 0xce, 0x20, 0x30, 0x5b, 0x48, 0x93, 0x8b, 0x23, 0xb1, 0x38, 0x3e, 0x2d, 0x27, + 0x3f, 0xb1, 0x44, 0x82, 0x59, 0x81, 0x51, 0x83, 0xd1, 0x89, 0xe7, 0xd5, 0x3d, 0x79, 0xb8, 0x98, + 0x07, 0x43, 0x10, 0x7b, 0x62, 0xb1, 0x1b, 0x88, 0x69, 0xc5, 0x87, 0xea, 0x3d, 0x27, 0x4e, 0x2e, + 0xf6, 0xc4, 0xe2, 0xf8, 0x92, 0xca, 0x82, 0x54, 0x25, 0x5f, 0x2e, 0x31, 0x54, 0x37, 0xc2, 0x9c, + 0x2f, 0x64, 0x0c, 0x0f, 0x53, 0x46, 0x82, 0x61, 0x0a, 0x0b, 0x48, 0xa3, 0x8b, 0x8c, 0x5c, 0xcc, + 0xbe, 0xc5, 0xe9, 0x42, 0x49, 0x5c, 0x3c, 0x28, 0x11, 0xab, 0x82, 0x55, 0x33, 0x5a, 0xc8, 0x49, + 0xe9, 0x10, 0xa3, 0x0a, 0xee, 0xc0, 0x78, 0x2e, 0x6e, 0xe4, 0xb0, 0x55, 0x26, 0x42, 0xb3, 0x94, + 0x36, 0x11, 0x8a, 0x60, 0x16, 0x48, 0xb1, 0x36, 0x80, 0x12, 0x89, 0x53, 0xe0, 0x89, 0x47, 0x72, + 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0xde, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, + 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x9c, 0x9e, 0x59, 0x92, + 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x32, 0x5b, 0x37, 0x2f, 0xb5, 0xa4, 0x3c, 0xbf, + 0x28, 0x5b, 0x1f, 0x7b, 0xfa, 0x01, 0x05, 0x7a, 0x71, 0x12, 0x1b, 0x38, 0x0b, 0x18, 0x03, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x2d, 0xb1, 0x59, 0xbc, 0xb6, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -519,15 +519,15 @@ func (m *MsgUpdateParam) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgUpdateParam_AsDouble) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateParam_AsFloat) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateParam_AsDouble) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateParam_AsFloat) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.AsDouble)))) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.AsFloat)))) i-- dAtA[i] = 0x19 return len(dAtA) - i, nil @@ -622,7 +622,7 @@ func (m *MsgUpdateParam) Size() (n int) { return n } -func (m *MsgUpdateParam_AsDouble) Size() (n int) { +func (m *MsgUpdateParam_AsFloat) Size() (n int) { if m == nil { return 0 } @@ -910,7 +910,7 @@ func (m *MsgUpdateParam) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field AsDouble", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AsFloat", wireType) } var v uint64 if (iNdEx + 8) > l { @@ -918,7 +918,7 @@ func (m *MsgUpdateParam) Unmarshal(dAtA []byte) error { } v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 - m.AsType = &MsgUpdateParam_AsDouble{float64(math.Float64frombits(v))} + m.AsType = &MsgUpdateParam_AsFloat{float64(math.Float64frombits(v))} default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 9c7919d86b9da12b2a06857af8ee0d23f7651ff5 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 12 Nov 2024 12:59:32 +0100 Subject: [PATCH 5/8] [Session Params] Add `num_suppliers_per_session` param to session module (#907) ## Summary Adds `num_suppliers_per_session` parameter to the session module. **@reviewer, use the updated docs in #839 to validate these changes.** ## Issue - `TODO_BETA` ## Type of change Select one or more from the following: - [x] New feature, functionality or library - [ ] Consensus breaking; add the `consensus-breaking` label if so. See #791 for details - [ ] Bug fix - [ ] Code health or cleanup - [ ] Documentation - [ ] Other (specify) ## Testing - [ ] **Documentation**: `make docusaurus_start`; only needed if you make doc changes - [x] **Unit Tests**: `make go_develop_and_test` - [ ] **LocalNet E2E Tests**: `make test_e2e` - [x] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR. ## Sanity Checklist - [x] I have tested my changes using the available tooling - [ ] I have commented my code - [x] I have performed a self-review of my own code; both comments & source code - [ ] I create and reference any new tickets, if applicable - [ ] I have left TODOs throughout the codebase, if applicable --------- Co-authored-by: Redouane Lakrache --- api/poktroll/session/params.pulsar.go | 99 ++++++++++++++++--- config.yml | 3 + docusaurus/docs/protocol/governance/params.md | 1 + makefiles/params.mk | 13 +++ proto/poktroll/session/params.proto | 4 + testutil/integration/suites/param_configs.go | 9 +- tools/scripts/params/session_all.json | 13 +++ .../session_num_suppliers_per_session.json | 12 +++ x/session/keeper/msg_server_update_param.go | 63 ++++++++++-- .../keeper/msg_server_update_param_test.go | 37 +++++++ x/session/keeper/msg_update_params_test.go | 26 +++-- x/session/keeper/params_test.go | 38 +++++-- x/session/module/genesis_test.go | 6 +- x/session/types/errors.go | 1 + x/session/types/message_update_param.go | 41 +++++++- x/session/types/message_update_param_test.go | 31 ++++-- x/session/types/params.go | 42 +++++++- x/session/types/params.pb.go | 62 ++++++++++-- 18 files changed, 434 insertions(+), 67 deletions(-) create mode 100644 tools/scripts/params/session_all.json create mode 100644 tools/scripts/params/session_num_suppliers_per_session.json create mode 100644 x/session/keeper/msg_server_update_param_test.go diff --git a/api/poktroll/session/params.pulsar.go b/api/poktroll/session/params.pulsar.go index b3959af5c..fda79e608 100644 --- a/api/poktroll/session/params.pulsar.go +++ b/api/poktroll/session/params.pulsar.go @@ -15,12 +15,14 @@ import ( ) var ( - md_Params protoreflect.MessageDescriptor + md_Params protoreflect.MessageDescriptor + fd_Params_num_suppliers_per_session protoreflect.FieldDescriptor ) func init() { file_poktroll_session_params_proto_init() md_Params = File_poktroll_session_params_proto.Messages().ByName("Params") + fd_Params_num_suppliers_per_session = md_Params.Fields().ByName("num_suppliers_per_session") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -88,6 +90,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.NumSuppliersPerSession != uint64(0) { + value := protoreflect.ValueOfUint64(x.NumSuppliersPerSession) + if !f(fd_Params_num_suppliers_per_session, value) { + return + } + } } // Has reports whether a field is populated. @@ -103,6 +111,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.session.Params.num_suppliers_per_session": + return x.NumSuppliersPerSession != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -119,6 +129,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.session.Params.num_suppliers_per_session": + x.NumSuppliersPerSession = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -135,6 +147,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.session.Params.num_suppliers_per_session": + value := x.NumSuppliersPerSession + return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -155,6 +170,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.session.Params.num_suppliers_per_session": + x.NumSuppliersPerSession = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -175,6 +192,8 @@ 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.session.Params.num_suppliers_per_session": + panic(fmt.Errorf("field num_suppliers_per_session of message poktroll.session.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -188,6 +207,8 @@ 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.session.Params.num_suppliers_per_session": + return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.session.Params")) @@ -257,6 +278,9 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + if x.NumSuppliersPerSession != 0 { + n += 1 + runtime.Sov(uint64(x.NumSuppliersPerSession)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -286,6 +310,11 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.NumSuppliersPerSession != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.NumSuppliersPerSession)) + i-- + dAtA[i] = 0x18 + } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -335,6 +364,25 @@ 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 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NumSuppliersPerSession", wireType) + } + x.NumSuppliersPerSession = 0 + 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++ + x.NumSuppliersPerSession |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -388,6 +436,10 @@ type Params struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // num_suppliers_per_session is the maximun number of suppliers per session + // (applicaiton:supplier pair for a given session number). + NumSuppliersPerSession uint64 `protobuf:"varint,3,opt,name=num_suppliers_per_session,json=numSuppliersPerSession,proto3" json:"num_suppliers_per_session,omitempty"` } func (x *Params) Reset() { @@ -410,6 +462,13 @@ func (*Params) Descriptor() ([]byte, []int) { return file_poktroll_session_params_proto_rawDescGZIP(), []int{0} } +func (x *Params) GetNumSuppliersPerSession() uint64 { + if x != nil { + return x.NumSuppliersPerSession + } + return 0 +} + var File_poktroll_session_params_proto protoreflect.FileDescriptor var file_poktroll_session_params_proto_rawDesc = []byte{ @@ -418,21 +477,29 @@ var file_poktroll_session_params_proto_rawDesc = []byte{ 0x10, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x11, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 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, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 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, 0x73, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 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, - 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, - 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0xca, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 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, 0x53, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xaa, 0x01, 0x0a, 0x06, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x7c, 0x0a, 0x19, 0x6e, 0x75, 0x6d, 0x5f, 0x73, 0x75, 0x70, + 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x41, 0xea, 0xde, 0x1f, 0x19, 0x6e, 0x75, + 0x6d, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, + 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xf2, 0xde, 0x1f, 0x20, 0x79, 0x61, 0x6d, 0x6c, 0x3a, + 0x22, 0x6e, 0x75, 0x6d, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x5f, 0x70, + 0x65, 0x72, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x52, 0x16, 0x6e, 0x75, 0x6d, + 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x3a, 0x22, 0xe8, 0xa0, 0x1f, 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x19, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 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, 0x73, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 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, 0x73, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x10, 0x50, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0xca, + 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0xe2, 0x02, 0x1c, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 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, 0x53, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/config.yml b/config.yml index d88a1dcca..79878d9c4 100644 --- a/config.yml +++ b/config.yml @@ -274,6 +274,9 @@ genesis: proof_submission_fee: amount: "1000000" denom: upokt + session: + params: + num_suppliers_per_session: 15 shared: params: num_blocks_per_session: 10 diff --git a/docusaurus/docs/protocol/governance/params.md b/docusaurus/docs/protocol/governance/params.md index 3bea1615d..5dea25f1d 100644 --- a/docusaurus/docs/protocol/governance/params.md +++ b/docusaurus/docs/protocol/governance/params.md @@ -46,6 +46,7 @@ Please follow the instructions in [this guide](../../develop/developer_guide/add | `proof` | `cosmos.base.v1beta1.Coin` | `proof_requirement_threshold` | proof_requirement_threshold is the session cost (i.e. compute unit consumption) threshold which asserts that a session MUST have a corresponding proof when its cost is equal to or above the threshold. This is in contrast to the this requirement being determined probabilistically via ProofRequestProbability. TODO_MAINNET: Consider renaming this to `proof_requirement_threshold_upokt`. | | `proof` | `cosmos.base.v1beta1.Coin` | `proof_submission_fee` | proof_submission_fee is the number of tokens (uPOKT) which should be paid by the supplier operator when submitting a proof. This is needed to account for the cost of storing proofs on-chain and prevent spamming (i.e. sybil bloat attacks) the network with non-required proofs. TODO_MAINNET: Consider renaming this to `proof_submission_fee_upokt`. | | `service` | `cosmos.base.v1beta1.Coin` | `add_service_fee` | The amount of uPOKT required to add a new service. This will be deducted from the signer's account balance, and transferred to the pocket network foundation. | +| `session` | `uint64` | `num_suppliers_per_session` | num_suppliers_per_session is the maximun number of suppliers per session (applicaiton:supplier pair for a given session number). | | `shared` | `uint64` | `application_unbonding_period_sessions` | application_unbonding_period_sessions is the number of sessions that an application must wait after unstaking before their staked assets are moved to their account balance. On-chain business logic requires, and ensures, that the corresponding block count of the application unbonding period will exceed the end of its corresponding proof window close height. | | `shared` | `uint64` | `claim_window_close_offset_blocks` | claim_window_close_offset_blocks is the number of blocks after the claim window open height, at which the claim window closes. | | `shared` | `uint64` | `claim_window_open_offset_blocks` | claim_window_open_offset_blocks is the number of blocks after the session grace period height, at which the claim window opens. | diff --git a/makefiles/params.mk b/makefiles/params.mk index 3e577ab52..29a4fe4c9 100644 --- a/makefiles/params.mk +++ b/makefiles/params.mk @@ -144,6 +144,19 @@ params_update_supplier_all: ## Update the supplier module params params_update_supplier_min_stake: ## Update the supplier module min_stake param poktrolld tx authz exec ./tools/scripts/params/supplier_min_stake.json $(PARAM_FLAGS) +### Session Module Params ### +.PHONY: params_get_session +params_get_session: ## Get the session module params + poktrolld query session params --node $(POCKET_NODE) + +.PHONY: params_update_session_all +params_update_session_all: ## Update the session module params + poktrolld tx authz exec ./tools/scripts/params/session_all.json $(PARAM_FLAGS) + +.PHONY: params_update_session_num_suppliers_per_session +params_update_session_num_suppliers_per_session: ## Update the session module num_suppliers_per_session param + poktrolld tx authz exec ./tools/scripts/params/session_num_suppliers_per_session.json $(PARAM_FLAGS) + .PHONY: params_query_all params_query_all: check_jq ## Query the params from all available modules @for module in $(MODULES); do \ diff --git a/proto/poktroll/session/params.proto b/proto/poktroll/session/params.proto index 342e64fce..d8d660ef4 100644 --- a/proto/poktroll/session/params.proto +++ b/proto/poktroll/session/params.proto @@ -11,4 +11,8 @@ import "gogoproto/gogo.proto"; message Params { option (amino.name) = "poktroll/x/session/Params"; option (gogoproto.equal) = true; + + // num_suppliers_per_session is the maximun number of suppliers per session + // (applicaiton:supplier pair for a given session number). + uint64 num_suppliers_per_session = 3 [(gogoproto.jsontag) = "num_suppliers_per_session", (gogoproto.moretags) = "yaml:\"num_suppliers_per_session\""]; } diff --git a/testutil/integration/suites/param_configs.go b/testutil/integration/suites/param_configs.go index 3f11ac943..1c40f1954 100644 --- a/testutil/integration/suites/param_configs.go +++ b/testutil/integration/suites/param_configs.go @@ -104,10 +104,17 @@ var ( ParamsMsgs: ModuleParamsMessages{ MsgUpdateParams: sessiontypes.MsgUpdateParams{}, MsgUpdateParamsResponse: sessiontypes.MsgUpdateParamsResponse{}, + MsgUpdateParam: sessiontypes.MsgUpdateParam{}, + MsgUpdateParamResponse: sessiontypes.MsgUpdateParamResponse{}, QueryParamsRequest: sessiontypes.QueryParamsRequest{}, QueryParamsResponse: sessiontypes.QueryParamsResponse{}, }, - ValidParams: sessiontypes.Params{}, + ValidParams: sessiontypes.Params{ + NumSuppliersPerSession: 420, + }, + ParamTypes: map[ParamType]any{ + ParamTypeUint64: sessiontypes.MsgUpdateParam_AsUint64{}, + }, DefaultParams: sessiontypes.DefaultParams(), NewParamClientFn: sessiontypes.NewQueryClient, } diff --git a/tools/scripts/params/session_all.json b/tools/scripts/params/session_all.json new file mode 100644 index 000000000..ca760015a --- /dev/null +++ b/tools/scripts/params/session_all.json @@ -0,0 +1,13 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.session.MsgUpdateParams", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "params": { + "num_suppliers_per_session": 15 + } + } + ] + } +} \ No newline at end of file diff --git a/tools/scripts/params/session_num_suppliers_per_session.json b/tools/scripts/params/session_num_suppliers_per_session.json new file mode 100644 index 000000000..642a5135a --- /dev/null +++ b/tools/scripts/params/session_num_suppliers_per_session.json @@ -0,0 +1,12 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.session.MsgUpdateParam", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "name": "num_suppliers_per_session", + "as_uint64": "15" + } + ] + } +} diff --git a/x/session/keeper/msg_server_update_param.go b/x/session/keeper/msg_server_update_param.go index 4cb9ec545..7804372d6 100644 --- a/x/session/keeper/msg_server_update_param.go +++ b/x/session/keeper/msg_server_update_param.go @@ -2,17 +2,66 @@ package keeper import ( "context" + "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/status" - "github.com/pokt-network/poktroll/x/session/types" + sessiontypes "github.com/pokt-network/poktroll/x/session/types" + suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" + + "google.golang.org/grpc/codes" ) -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 *sessiontypes.MsgUpdateParam) (*sessiontypes.MsgUpdateParamResponse, error) { + logger := k.logger.With( + "method", "UpdateParam", + "param_name", msg.Name, + ) + + if err := msg.ValidateBasic(); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if k.GetAuthority() != msg.Authority { + return nil, status.Error( + codes.InvalidArgument, + suppliertypes.ErrSupplierInvalidSigner.Wrapf( + "invalid authority; expected %s, got %s", + k.GetAuthority(), msg.Authority, + ).Error(), + ) + } + + params := k.GetParams(ctx) + + switch msg.Name { + case sessiontypes.ParamNumSuppliersPerSession: + logger = logger.With("param_value", msg.GetAsUint64()) + params.NumSuppliersPerSession = msg.GetAsUint64() + default: + return nil, status.Error( + codes.InvalidArgument, + suppliertypes.ErrSupplierParamInvalid.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.ValidateBasic(); 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()) + } - // TODO: Handling the message - _ = ctx + updatedParams := k.GetParams(ctx) - return &types.MsgUpdateParamResponse{}, nil + return &sessiontypes.MsgUpdateParamResponse{ + Params: &updatedParams, + }, nil } diff --git a/x/session/keeper/msg_server_update_param_test.go b/x/session/keeper/msg_server_update_param_test.go new file mode 100644 index 000000000..293f6f994 --- /dev/null +++ b/x/session/keeper/msg_server_update_param_test.go @@ -0,0 +1,37 @@ +package keeper_test + +import ( + "testing" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/require" + + testkeeper "github.com/pokt-network/poktroll/testutil/keeper" + sessiontypes "github.com/pokt-network/poktroll/x/session/types" +) + +func TestMsgUpdateParam_UpdateNumSuppliersPerSessionOnly(t *testing.T) { + var expectedNumSuppliersPerSession uint64 = 420 + + // Set the parameters to their default values + k, msgSrv, ctx := setupMsgServer(t) + defaultParams := sessiontypes.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, expectedNumSuppliersPerSession, defaultParams.NumSuppliersPerSession) + + // Update the new parameter + updateParamMsg := &sessiontypes.MsgUpdateParam{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Name: sessiontypes.ParamNumSuppliersPerSession, + AsType: &sessiontypes.MsgUpdateParam_AsUint64{AsUint64: expectedNumSuppliersPerSession}, + } + res, err := msgSrv.UpdateParam(ctx, updateParamMsg) + require.NoError(t, err) + require.Equal(t, expectedNumSuppliersPerSession, res.Params.NumSuppliersPerSession) + + // Ensure the other parameters are unchanged + testkeeper.AssertDefaultParamsEqualExceptFields(t, &defaultParams, res.Params, string(sessiontypes.KeyNumSuppliersPerSession)) +} diff --git a/x/session/keeper/msg_update_params_test.go b/x/session/keeper/msg_update_params_test.go index bf9df225b..4ad80338f 100644 --- a/x/session/keeper/msg_update_params_test.go +++ b/x/session/keeper/msg_update_params_test.go @@ -5,24 +5,24 @@ import ( "github.com/stretchr/testify/require" - "github.com/pokt-network/poktroll/x/session/types" + sessiontypes "github.com/pokt-network/poktroll/x/session/types" ) func TestMsgUpdateParams(t *testing.T) { k, ms, ctx := setupMsgServer(t) - params := types.DefaultParams() + params := sessiontypes.DefaultParams() require.NoError(t, k.SetParams(ctx, params)) // default params tests := []struct { desc string - params *types.MsgUpdateParams + params *sessiontypes.MsgUpdateParams shouldError bool expectedErrMsg string }{ { desc: "invalid: authority address invalid", - params: &types.MsgUpdateParams{ + params: &sessiontypes.MsgUpdateParams{ Authority: "invalid", Params: params, }, @@ -30,16 +30,26 @@ func TestMsgUpdateParams(t *testing.T) { expectedErrMsg: "invalid authority", }, { - desc: "send empty params", - params: &types.MsgUpdateParams{ + desc: "invalid: send empty params", + params: &sessiontypes.MsgUpdateParams{ Authority: k.GetAuthority(), - Params: types.Params{}, + Params: sessiontypes.Params{}, + }, + shouldError: true, + }, + { + desc: "valid: send minimal params", + params: &sessiontypes.MsgUpdateParams{ + Authority: k.GetAuthority(), + Params: sessiontypes.Params{ + NumSuppliersPerSession: 42, + }, }, shouldError: false, }, { desc: "valid: send default params", - params: &types.MsgUpdateParams{ + params: &sessiontypes.MsgUpdateParams{ Authority: k.GetAuthority(), Params: params, }, diff --git a/x/session/keeper/params_test.go b/x/session/keeper/params_test.go index 77e756c64..fadc53e6b 100644 --- a/x/session/keeper/params_test.go +++ b/x/session/keeper/params_test.go @@ -5,14 +5,40 @@ import ( "github.com/stretchr/testify/require" - testkeeper "github.com/pokt-network/poktroll/testutil/keeper" - "github.com/pokt-network/poktroll/x/session/types" + sessiontypes "github.com/pokt-network/poktroll/x/session/types" ) func TestGetParams(t *testing.T) { - k, ctx := testkeeper.SessionKeeper(t) - params := types.DefaultParams() + tests := []struct { + desc string + numSuppliersPerSession any + expectedErr error + }{ + { + desc: "invalid type", + numSuppliersPerSession: "420", + expectedErr: sessiontypes.ErrSessionParamInvalid.Wrapf("invalid parameter type: string"), + }, + { + desc: "invalid NumSuppliersPerSession (<1)", + numSuppliersPerSession: uint64(0), + expectedErr: sessiontypes.ErrSessionParamInvalid.Wrapf("number of suppliers per session (%d) MUST be greater than or equal to 1", 0), + }, + { + desc: "valid NumSuppliersPerSession", + numSuppliersPerSession: uint64(420), + }, + } - require.NoError(t, k.SetParams(ctx, params)) - require.EqualValues(t, params, k.GetParams(ctx)) + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := sessiontypes.ValidateNumSuppliersPerSession(test.numSuppliersPerSession) + if test.expectedErr != nil { + require.Error(t, err) + require.Contains(t, err.Error(), test.expectedErr.Error()) + } else { + require.NoError(t, err) + } + }) + } } diff --git a/x/session/module/genesis_test.go b/x/session/module/genesis_test.go index 91b8cc149..5c95ee0d5 100644 --- a/x/session/module/genesis_test.go +++ b/x/session/module/genesis_test.go @@ -9,6 +9,7 @@ import ( ) func TestGenesisState_Validate(t *testing.T) { + defaultParams := types.DefaultParams() tests := []struct { desc string genState *types.GenesisState @@ -20,8 +21,11 @@ func TestGenesisState_Validate(t *testing.T) { isValid: true, }, { - desc: "valid genesis state", + desc: "valid genesis state", genState: &types.GenesisState{ + Params: types.Params{ + NumSuppliersPerSession: defaultParams.NumSuppliersPerSession, + }, // this line is used by starport scaffolding # types/genesis/validField }, diff --git a/x/session/types/errors.go b/x/session/types/errors.go index 82b720b40..0d979b532 100644 --- a/x/session/types/errors.go +++ b/x/session/types/errors.go @@ -16,4 +16,5 @@ var ( ErrSessionInvalidBlockHeight = sdkerrors.Register(ModuleName, 1107, "invalid block height for session") ErrSessionInvalidSessionId = sdkerrors.Register(ModuleName, 1108, "invalid sessionId") ErrSessionAppNotActive = sdkerrors.Register(ModuleName, 1109, "application is not active") + ErrSessionParamInvalid = sdkerrors.Register(ModuleName, 1110, "the provided param is invalid") ) diff --git a/x/session/types/message_update_param.go b/x/session/types/message_update_param.go index 38d848878..ace4d5b71 100644 --- a/x/session/types/message_update_param.go +++ b/x/session/types/message_update_param.go @@ -8,18 +8,49 @@ import ( var _ sdk.Msg = (*MsgUpdateParam)(nil) -func NewMsgUpdateParam(authority string, name string, asType isMsgUpdateParam_AsType) *MsgUpdateParam { +func NewMsgUpdateParam(authority string, name string, asType any) (*MsgUpdateParam, error) { + var asTypeIface isMsgUpdateParam_AsType + + switch t := asType.(type) { + case uint64: + asTypeIface = &MsgUpdateParam_AsUint64{AsUint64: t} + default: + return nil, ErrSessionParamInvalid.Wrapf("unexpected param value type: %T", asType) + } + return &MsgUpdateParam{ Authority: authority, Name: name, - AsType: asType, - } + AsType: asTypeIface, + }, nil } +// ValidateBasic performs a basic validation of the MsgUpdateParam fields. It ensures: +// 1. The parameter name is supported. +// 2. The parameter type matches the expected type for a given parameter name. +// 3. The parameter value is valid (according to its respective validation function). func (msg *MsgUpdateParam) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address (%s)", err) } + + switch msg.Name { + case ParamNumSuppliersPerSession: + if err := msg.paramTypeIsUint64(); err != nil { + return err + } + return ValidateNumSuppliersPerSession(msg.GetAsUint64()) + default: + return ErrSessionParamInvalid.Wrapf("unsupported param %q", msg.Name) + } +} + +func (msg *MsgUpdateParam) paramTypeIsUint64() error { + if _, ok := msg.AsType.(*MsgUpdateParam_AsUint64); !ok { + return ErrSessionParamInvalid.Wrapf( + "invalid type for param %q expected %T, got %T", + msg.Name, &MsgUpdateParam_AsUint64{}, msg.AsType, + ) + } return nil } diff --git a/x/session/types/message_update_param_test.go b/x/session/types/message_update_param_test.go index b72a6147b..f1d101f90 100644 --- a/x/session/types/message_update_param_test.go +++ b/x/session/types/message_update_param_test.go @@ -11,28 +11,41 @@ import ( func TestMsgUpdateParam_ValidateBasic(t *testing.T) { tests := []struct { - name string - msg MsgUpdateParam - err error + desc string + msg MsgUpdateParam + expectedErr error }{ { - name: "invalid address", + desc: "invalid: authority address invalid", msg: MsgUpdateParam{ Authority: "invalid_address", + Name: "", // Doesn't matter for this test + AsType: &MsgUpdateParam_AsUint64{AsUint64: 0}, }, - err: sdkerrors.ErrInvalidAddress, + expectedErr: sdkerrors.ErrInvalidAddress, }, { - name: "valid address", + desc: "invalid: param name incorrect (non-existent)", msg: MsgUpdateParam{ Authority: sample.AccAddress(), + Name: "non_existent", + AsType: &MsgUpdateParam_AsUint64{AsUint64: DefaultNumSuppliersPerSession}, + }, + expectedErr: ErrSessionParamInvalid, + }, { + desc: "valid: correct address, param name, and type", + msg: MsgUpdateParam{ + Authority: sample.AccAddress(), + Name: ParamNumSuppliersPerSession, + AsType: &MsgUpdateParam_AsUint64{AsUint64: DefaultNumSuppliersPerSession}, }, }, } + for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { + t.Run(tt.desc, 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/session/types/params.go b/x/session/types/params.go index c894e0aa8..0cbb4d211 100644 --- a/x/session/types/params.go +++ b/x/session/types/params.go @@ -2,7 +2,13 @@ package types import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -var _ paramtypes.ParamSet = (*Params)(nil) +var ( + KeyNumSuppliersPerSession = []byte("NumSuppliersPerSession") + ParamNumSuppliersPerSession = "num_suppliers_per_session" + DefaultNumSuppliersPerSession uint64 = 15 + + _ paramtypes.ParamSet = (*Params)(nil) +) // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { @@ -10,21 +16,47 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new Params instance -func NewParams() Params { - return Params{} +func NewParams(numSuppliersPerSession uint64) Params { + return Params{ + NumSuppliersPerSession: numSuppliersPerSession, + } } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams() + return NewParams(DefaultNumSuppliersPerSession) } // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair( + KeyNumSuppliersPerSession, + &p.NumSuppliersPerSession, + ValidateNumSuppliersPerSession, + ), + } } // ValidateBasic does a sanity check on the provided params. func (p Params) ValidateBasic() error { + if err := ValidateNumSuppliersPerSession(p.NumSuppliersPerSession); err != nil { + return err + } + + return nil +} + +// ValidateNumSuppliersPerSession validates the NumSuppliersPerSession param. +func ValidateNumSuppliersPerSession(numSuppliersPerSessionAny any) error { + numSuppliersPerSession, ok := numSuppliersPerSessionAny.(uint64) + if !ok { + return ErrSessionParamInvalid.Wrapf("invalid parameter type: %T", numSuppliersPerSessionAny) + } + + if numSuppliersPerSession < 1 { + return ErrSessionParamInvalid.Wrapf("number of suppliers per session (%d) MUST be greater than or equal to 1", numSuppliersPerSession) + } + return nil } diff --git a/x/session/types/params.pb.go b/x/session/types/params.pb.go index ac12d5cc9..cdfc92480 100644 --- a/x/session/types/params.pb.go +++ b/x/session/types/params.pb.go @@ -26,6 +26,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { + // num_suppliers_per_session is the maximun number of suppliers per session + // (applicaiton:supplier pair for a given session number). + NumSuppliersPerSession uint64 `protobuf:"varint,3,opt,name=num_suppliers_per_session,json=numSuppliersPerSession,proto3" json:"num_suppliers_per_session" yaml:"num_suppliers_per_session"` } func (m *Params) Reset() { *m = Params{} } @@ -57,6 +60,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetNumSuppliersPerSession() uint64 { + if m != nil { + return m.NumSuppliersPerSession + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "poktroll.session.Params") } @@ -64,19 +74,23 @@ func init() { func init() { proto.RegisterFile("poktroll/session/params.proto", fileDescriptor_b9edf07916909b5b) } var fileDescriptor_b9edf07916909b5b = []byte{ - // 180 bytes of a gzipped FileDescriptorProto + // 247 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, 0x2f, 0x4e, 0x2d, 0x2e, 0xce, 0xcc, 0xcf, 0xd3, 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, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0x78, 0xe3, 0x91, 0x1c, - 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, - 0x1c, 0x43, 0x94, 0x41, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, - 0x0c, 0xdd, 0xbc, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x7d, 0x2c, 0x06, 0x96, 0x54, 0x16, 0xa4, - 0x16, 0x27, 0xb1, 0x81, 0x1d, 0x61, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x5a, 0x5e, 0xc7, 0xb4, - 0xe0, 0x00, 0x00, 0x00, + 0x7a, 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x44, 0x95, 0x56, 0x31, 0x72, 0xb1, 0x05, 0x80, 0xcd, + 0x12, 0xaa, 0xe1, 0x92, 0xcc, 0x2b, 0xcd, 0x8d, 0x2f, 0x2e, 0x2d, 0x28, 0xc8, 0xc9, 0x4c, 0x2d, + 0x2a, 0x8e, 0x2f, 0x48, 0x2d, 0x8a, 0x87, 0x1a, 0x28, 0xc1, 0xac, 0xc0, 0xa8, 0xc1, 0xe2, 0xe4, + 0xf8, 0xea, 0x9e, 0x3c, 0x6e, 0x45, 0x9f, 0xee, 0xc9, 0x2b, 0x54, 0x26, 0xe6, 0xe6, 0x58, 0x29, + 0xe1, 0x54, 0xa2, 0x14, 0x24, 0x96, 0x57, 0x9a, 0x1b, 0x0c, 0x93, 0x0a, 0x48, 0x2d, 0x0a, 0x86, + 0x48, 0x58, 0x29, 0xbd, 0x58, 0x20, 0xcf, 0xd8, 0xf5, 0x7c, 0x83, 0x96, 0x24, 0xdc, 0xaf, 0x15, + 0x70, 0xdf, 0x42, 0x5c, 0xe8, 0xe4, 0x77, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x37, + 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, + 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, + 0xea, 0x83, 0xcc, 0xd0, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0xc7, 0x62, 0x60, 0x49, + 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x0c, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4e, + 0x15, 0x44, 0x75, 0x5f, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -98,6 +112,9 @@ func (this *Params) Equal(that interface{}) bool { } else if this == nil { return false } + if this.NumSuppliersPerSession != that1.NumSuppliersPerSession { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -120,6 +137,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.NumSuppliersPerSession != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.NumSuppliersPerSession)) + i-- + dAtA[i] = 0x18 + } return len(dAtA) - i, nil } @@ -140,6 +162,9 @@ func (m *Params) Size() (n int) { } var l int _ = l + if m.NumSuppliersPerSession != 0 { + n += 1 + sovParams(uint64(m.NumSuppliersPerSession)) + } return n } @@ -178,6 +203,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumSuppliersPerSession", wireType) + } + m.NumSuppliersPerSession = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumSuppliersPerSession |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) From 39732c7ddc489fb05df954f6883e0bfc372cc06d Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 12 Nov 2024 13:14:35 +0100 Subject: [PATCH 6/8] fixup! HEAD --- e2e/tests/parse_params_test.go | 4 ++-- x/tokenomics/keeper/msg_server_update_param_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/tests/parse_params_test.go b/e2e/tests/parse_params_test.go index b54ae28bf..500312c1d 100644 --- a/e2e/tests/parse_params_test.go +++ b/e2e/tests/parse_params_test.go @@ -261,8 +261,8 @@ func (s *suite) newTokenomicsMsgUpdateParam(authority string, param paramAny) (m msg = proto.Message(&tokenomicstypes.MsgUpdateParam{ Authority: authority, Name: param.name, - AsType: &tokenomicstypes.MsgUpdateParam_AsDouble{ - AsDouble: param.value.(float64), + AsType: &tokenomicstypes.MsgUpdateParam_AsFloat{ + AsFloat: param.value.(float64), }, }) default: diff --git a/x/tokenomics/keeper/msg_server_update_param_test.go b/x/tokenomics/keeper/msg_server_update_param_test.go index dab36895e..370d4bb9b 100644 --- a/x/tokenomics/keeper/msg_server_update_param_test.go +++ b/x/tokenomics/keeper/msg_server_update_param_test.go @@ -51,7 +51,7 @@ func TestMsgUpdateParam_UpdateMintAllocationProposerOnly(t *testing.T) { updateParamMsg := &tokenomicstypes.MsgUpdateParam{ Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), Name: tokenomicstypes.ParamMintAllocationProposer, - AsType: &tokenomicstypes.MsgUpdateParam_AsDouble{AsDouble: expectedMintAllocationProposer}, + AsType: &tokenomicstypes.MsgUpdateParam_AsFloat{AsFloat: expectedMintAllocationProposer}, } res, err := msgSrv.UpdateParam(ctx, updateParamMsg) require.NoError(t, err) From 63b146efc1423f24183ca58adf0d3ab9f237f4be Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 12 Nov 2024 13:19:42 +0100 Subject: [PATCH 7/8] chore: review feedback improvements --- tools/scripts/params/tokenomics_mint_allocation_proposer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/scripts/params/tokenomics_mint_allocation_proposer.json b/tools/scripts/params/tokenomics_mint_allocation_proposer.json index e5396771b..f068abe2f 100644 --- a/tools/scripts/params/tokenomics_mint_allocation_proposer.json +++ b/tools/scripts/params/tokenomics_mint_allocation_proposer.json @@ -5,7 +5,7 @@ "@type": "/poktroll.tokenomics.MsgUpdateParam", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "name": "mint_allocation_proposer", - "as_double": 0.05 + "as_float": 0.05 } ] } From 5b9ae4554feca7b4b1e38dce78add6719d2211f0 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 12 Nov 2024 13:20:41 +0100 Subject: [PATCH 8/8] chore: review feedback improvements --- tools/scripts/params/tokenomics_mint_allocation_supplier.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/scripts/params/tokenomics_mint_allocation_supplier.json b/tools/scripts/params/tokenomics_mint_allocation_supplier.json index 5ece944ea..30d9c3dd9 100644 --- a/tools/scripts/params/tokenomics_mint_allocation_supplier.json +++ b/tools/scripts/params/tokenomics_mint_allocation_supplier.json @@ -5,7 +5,7 @@ "@type": "/poktroll.tokenomics.MsgUpdateParam", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "name": "mint_allocation_supplier", - "as_double": 0.7 + "as_float": 0.7 } ] }