diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index d11cbba2b..5d6119728 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -22,7 +22,25 @@ jobs: reporter: github-pr-review level: error fail_on_error: true - pattern: TODO_IN_THIS_ + pattern: TODO_IN_THIS_|TODO_THIS_ + + # Makes sure that comments like TODO_UPNEXT prevent merging if there is + # no associated username right after. + # Example failure: TODO_UPNEXT: + # Example non-failure: TODO_UPNEXT(@olshansk): + # See https://github.com/pokt-network/action-fail-on-found + check_todo_upnext: + name: Check TODO_UPNEXT + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pokt-network/action-fail-on-found@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: error + fail_on_error: true + pattern: "TODO_UPNEXT:" # Prevent the use of `sed` in helper scripts. This ensures compatibility across # Darwin and Linux systems. diff --git a/api/poktroll/application/types.pulsar.go b/api/poktroll/application/types.pulsar.go index b5735ed3c..ca032ba67 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/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..9b5ab2fb2 100644 --- a/api/poktroll/proof/tx.pulsar.go +++ b/api/poktroll/proof/tx.pulsar.go @@ -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/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/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/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/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/api/poktroll/tokenomics/params.pulsar.go b/api/poktroll/tokenomics/params.pulsar.go index cec03c7ba..d9578f45f 100644 --- a/api/poktroll/tokenomics/params.pulsar.go +++ b/api/poktroll/tokenomics/params.pulsar.go @@ -3,6 +3,7 @@ package tokenomics import ( _ "cosmossdk.io/api/amino" + binary "encoding/binary" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" @@ -10,17 +11,28 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" io "io" + math "math" reflect "reflect" sync "sync" ) var ( - md_Params protoreflect.MessageDescriptor + md_Params protoreflect.MessageDescriptor + fd_Params_mint_allocation_dao protoreflect.FieldDescriptor + fd_Params_mint_allocation_proposer protoreflect.FieldDescriptor + fd_Params_mint_allocation_supplier protoreflect.FieldDescriptor + fd_Params_mint_allocation_source_owner protoreflect.FieldDescriptor + fd_Params_mint_allocation_application protoreflect.FieldDescriptor ) func init() { file_poktroll_tokenomics_params_proto_init() md_Params = File_poktroll_tokenomics_params_proto.Messages().ByName("Params") + fd_Params_mint_allocation_dao = md_Params.Fields().ByName("mint_allocation_dao") + fd_Params_mint_allocation_proposer = md_Params.Fields().ByName("mint_allocation_proposer") + fd_Params_mint_allocation_supplier = md_Params.Fields().ByName("mint_allocation_supplier") + fd_Params_mint_allocation_source_owner = md_Params.Fields().ByName("mint_allocation_source_owner") + fd_Params_mint_allocation_application = md_Params.Fields().ByName("mint_allocation_application") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -88,6 +100,36 @@ 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.MintAllocationDao != float64(0) || math.Signbit(x.MintAllocationDao) { + value := protoreflect.ValueOfFloat64(x.MintAllocationDao) + if !f(fd_Params_mint_allocation_dao, value) { + return + } + } + if x.MintAllocationProposer != float64(0) || math.Signbit(x.MintAllocationProposer) { + value := protoreflect.ValueOfFloat64(x.MintAllocationProposer) + if !f(fd_Params_mint_allocation_proposer, value) { + return + } + } + if x.MintAllocationSupplier != float64(0) || math.Signbit(x.MintAllocationSupplier) { + value := protoreflect.ValueOfFloat64(x.MintAllocationSupplier) + if !f(fd_Params_mint_allocation_supplier, value) { + return + } + } + if x.MintAllocationSourceOwner != float64(0) || math.Signbit(x.MintAllocationSourceOwner) { + value := protoreflect.ValueOfFloat64(x.MintAllocationSourceOwner) + if !f(fd_Params_mint_allocation_source_owner, value) { + return + } + } + if x.MintAllocationApplication != float64(0) || math.Signbit(x.MintAllocationApplication) { + value := protoreflect.ValueOfFloat64(x.MintAllocationApplication) + if !f(fd_Params_mint_allocation_application, value) { + return + } + } } // Has reports whether a field is populated. @@ -103,6 +145,16 @@ 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.tokenomics.Params.mint_allocation_dao": + return x.MintAllocationDao != float64(0) || math.Signbit(x.MintAllocationDao) + case "poktroll.tokenomics.Params.mint_allocation_proposer": + return x.MintAllocationProposer != float64(0) || math.Signbit(x.MintAllocationProposer) + case "poktroll.tokenomics.Params.mint_allocation_supplier": + return x.MintAllocationSupplier != float64(0) || math.Signbit(x.MintAllocationSupplier) + case "poktroll.tokenomics.Params.mint_allocation_source_owner": + return x.MintAllocationSourceOwner != float64(0) || math.Signbit(x.MintAllocationSourceOwner) + case "poktroll.tokenomics.Params.mint_allocation_application": + return x.MintAllocationApplication != float64(0) || math.Signbit(x.MintAllocationApplication) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.Params")) @@ -119,6 +171,16 @@ 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.tokenomics.Params.mint_allocation_dao": + x.MintAllocationDao = float64(0) + case "poktroll.tokenomics.Params.mint_allocation_proposer": + x.MintAllocationProposer = float64(0) + case "poktroll.tokenomics.Params.mint_allocation_supplier": + x.MintAllocationSupplier = float64(0) + case "poktroll.tokenomics.Params.mint_allocation_source_owner": + x.MintAllocationSourceOwner = float64(0) + case "poktroll.tokenomics.Params.mint_allocation_application": + x.MintAllocationApplication = float64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.Params")) @@ -135,6 +197,21 @@ 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.tokenomics.Params.mint_allocation_dao": + value := x.MintAllocationDao + return protoreflect.ValueOfFloat64(value) + case "poktroll.tokenomics.Params.mint_allocation_proposer": + value := x.MintAllocationProposer + return protoreflect.ValueOfFloat64(value) + case "poktroll.tokenomics.Params.mint_allocation_supplier": + value := x.MintAllocationSupplier + return protoreflect.ValueOfFloat64(value) + case "poktroll.tokenomics.Params.mint_allocation_source_owner": + value := x.MintAllocationSourceOwner + return protoreflect.ValueOfFloat64(value) + case "poktroll.tokenomics.Params.mint_allocation_application": + value := x.MintAllocationApplication + return protoreflect.ValueOfFloat64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.Params")) @@ -155,6 +232,16 @@ 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.tokenomics.Params.mint_allocation_dao": + x.MintAllocationDao = value.Float() + case "poktroll.tokenomics.Params.mint_allocation_proposer": + x.MintAllocationProposer = value.Float() + case "poktroll.tokenomics.Params.mint_allocation_supplier": + x.MintAllocationSupplier = value.Float() + case "poktroll.tokenomics.Params.mint_allocation_source_owner": + x.MintAllocationSourceOwner = value.Float() + case "poktroll.tokenomics.Params.mint_allocation_application": + x.MintAllocationApplication = value.Float() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.Params")) @@ -175,6 +262,16 @@ 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.tokenomics.Params.mint_allocation_dao": + panic(fmt.Errorf("field mint_allocation_dao of message poktroll.tokenomics.Params is not mutable")) + case "poktroll.tokenomics.Params.mint_allocation_proposer": + panic(fmt.Errorf("field mint_allocation_proposer of message poktroll.tokenomics.Params is not mutable")) + case "poktroll.tokenomics.Params.mint_allocation_supplier": + panic(fmt.Errorf("field mint_allocation_supplier of message poktroll.tokenomics.Params is not mutable")) + case "poktroll.tokenomics.Params.mint_allocation_source_owner": + panic(fmt.Errorf("field mint_allocation_source_owner of message poktroll.tokenomics.Params is not mutable")) + case "poktroll.tokenomics.Params.mint_allocation_application": + panic(fmt.Errorf("field mint_allocation_application of message poktroll.tokenomics.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.Params")) @@ -188,6 +285,16 @@ 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.tokenomics.Params.mint_allocation_dao": + return protoreflect.ValueOfFloat64(float64(0)) + case "poktroll.tokenomics.Params.mint_allocation_proposer": + return protoreflect.ValueOfFloat64(float64(0)) + case "poktroll.tokenomics.Params.mint_allocation_supplier": + return protoreflect.ValueOfFloat64(float64(0)) + case "poktroll.tokenomics.Params.mint_allocation_source_owner": + return protoreflect.ValueOfFloat64(float64(0)) + case "poktroll.tokenomics.Params.mint_allocation_application": + return protoreflect.ValueOfFloat64(float64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.Params")) @@ -257,6 +364,21 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + if x.MintAllocationDao != 0 || math.Signbit(x.MintAllocationDao) { + n += 9 + } + if x.MintAllocationProposer != 0 || math.Signbit(x.MintAllocationProposer) { + n += 9 + } + if x.MintAllocationSupplier != 0 || math.Signbit(x.MintAllocationSupplier) { + n += 9 + } + if x.MintAllocationSourceOwner != 0 || math.Signbit(x.MintAllocationSourceOwner) { + n += 9 + } + if x.MintAllocationApplication != 0 || math.Signbit(x.MintAllocationApplication) { + n += 9 + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -286,6 +408,36 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.MintAllocationApplication != 0 || math.Signbit(x.MintAllocationApplication) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.MintAllocationApplication)))) + i-- + dAtA[i] = 0x29 + } + if x.MintAllocationSourceOwner != 0 || math.Signbit(x.MintAllocationSourceOwner) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.MintAllocationSourceOwner)))) + i-- + dAtA[i] = 0x21 + } + if x.MintAllocationSupplier != 0 || math.Signbit(x.MintAllocationSupplier) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.MintAllocationSupplier)))) + i-- + dAtA[i] = 0x19 + } + if x.MintAllocationProposer != 0 || math.Signbit(x.MintAllocationProposer) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.MintAllocationProposer)))) + i-- + dAtA[i] = 0x11 + } + if x.MintAllocationDao != 0 || math.Signbit(x.MintAllocationDao) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.MintAllocationDao)))) + i-- + dAtA[i] = 0x9 + } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -335,6 +487,61 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MintAllocationDao", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.MintAllocationDao = float64(math.Float64frombits(v)) + case 2: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MintAllocationProposer", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.MintAllocationProposer = float64(math.Float64frombits(v)) + case 3: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MintAllocationSupplier", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.MintAllocationSupplier = float64(math.Float64frombits(v)) + case 4: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MintAllocationSourceOwner", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.MintAllocationSourceOwner = float64(math.Float64frombits(v)) + case 5: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MintAllocationApplication", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.MintAllocationApplication = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -388,6 +595,22 @@ type Params struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // mint_allocation_dao is the percentage of the minted tokens which are sent + // to the DAO reward address during claim settlement. + MintAllocationDao float64 `protobuf:"fixed64,1,opt,name=mint_allocation_dao,json=mintAllocationDao,proto3" json:"mint_allocation_dao,omitempty"` + // mint_allocation_proposer is the percentage of the minted tokens which are sent + // to the block proposer account address during claim settlement. + MintAllocationProposer float64 `protobuf:"fixed64,2,opt,name=mint_allocation_proposer,json=mintAllocationProposer,proto3" json:"mint_allocation_proposer,omitempty"` + // mint_allocation_supplier is the percentage of the minted tokens which are sent + // to the block supplier account address during claim settlement. + MintAllocationSupplier float64 `protobuf:"fixed64,3,opt,name=mint_allocation_supplier,json=mintAllocationSupplier,proto3" json:"mint_allocation_supplier,omitempty"` + // mint_allocation_source_owner is the percentage of the minted tokens which are sent + // to the service source owner account address during claim settlement. + MintAllocationSourceOwner float64 `protobuf:"fixed64,4,opt,name=mint_allocation_source_owner,json=mintAllocationSourceOwner,proto3" json:"mint_allocation_source_owner,omitempty"` + // mint_allocation_application is the percentage of the minted tokens which are sent + // to the application account address during claim settlement. + MintAllocationApplication float64 `protobuf:"fixed64,5,opt,name=mint_allocation_application,json=mintAllocationApplication,proto3" json:"mint_allocation_application,omitempty"` } func (x *Params) Reset() { @@ -410,6 +633,41 @@ func (*Params) Descriptor() ([]byte, []int) { return file_poktroll_tokenomics_params_proto_rawDescGZIP(), []int{0} } +func (x *Params) GetMintAllocationDao() float64 { + if x != nil { + return x.MintAllocationDao + } + return 0 +} + +func (x *Params) GetMintAllocationProposer() float64 { + if x != nil { + return x.MintAllocationProposer + } + return 0 +} + +func (x *Params) GetMintAllocationSupplier() float64 { + if x != nil { + return x.MintAllocationSupplier + } + return 0 +} + +func (x *Params) GetMintAllocationSourceOwner() float64 { + if x != nil { + return x.MintAllocationSourceOwner + } + return 0 +} + +func (x *Params) GetMintAllocationApplication() float64 { + if x != nil { + return x.MintAllocationApplication + } + return 0 +} + var File_poktroll_tokenomics_params_proto protoreflect.FileDescriptor var file_poktroll_tokenomics_params_proto_rawDesc = []byte{ @@ -419,22 +677,61 @@ var file_poktroll_tokenomics_params_proto_rawDesc = []byte{ 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 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, 0x2f, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x3a, 0x25, 0xe8, 0xa0, 0x1f, 0x01, - 0x8a, 0xe7, 0xb0, 0x2a, 0x1c, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x42, 0xbd, 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, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 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, + 0x22, 0x9f, 0x05, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x65, 0x0a, 0x13, 0x6d, + 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, + 0x61, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x42, 0x35, 0xea, 0xde, 0x1f, 0x13, 0x6d, 0x69, + 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61, + 0x6f, 0xf2, 0xde, 0x1f, 0x1a, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x69, 0x6e, 0x74, 0x5f, + 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x6f, 0x22, 0x52, + 0x11, 0x6d, 0x69, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, + 0x61, 0x6f, 0x12, 0x79, 0x0a, 0x18, 0x6d, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x01, 0x42, 0x3f, 0xea, 0xde, 0x1f, 0x18, 0x6d, 0x69, 0x6e, 0x74, 0x5f, 0x61, + 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, + 0x65, 0x72, 0xf2, 0xde, 0x1f, 0x1f, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x69, 0x6e, 0x74, + 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x70, + 0x6f, 0x73, 0x65, 0x72, 0x22, 0x52, 0x16, 0x6d, 0x69, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x6f, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x12, 0x79, 0x0a, + 0x18, 0x6d, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x42, + 0x3f, 0xea, 0xde, 0x1f, 0x18, 0x6d, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0xf2, 0xde, 0x1f, + 0x1f, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x22, + 0x52, 0x16, 0x6d, 0x69, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x88, 0x01, 0x0a, 0x1c, 0x6d, 0x69, 0x6e, + 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x42, + 0x47, 0xea, 0xde, 0x1f, 0x1c, 0x6d, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, + 0x72, 0xf2, 0xde, 0x1f, 0x23, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x69, 0x6e, 0x74, 0x5f, + 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x22, 0x52, 0x19, 0x6d, 0x69, 0x6e, 0x74, 0x41, 0x6c, + 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4f, 0x77, + 0x6e, 0x65, 0x72, 0x12, 0x85, 0x01, 0x0a, 0x1b, 0x6d, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, + 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x42, 0x45, 0xea, 0xde, 0x1f, 0x1b, 0x6d, + 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, + 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xf2, 0xde, 0x1f, 0x22, 0x79, 0x61, + 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x69, 0x6e, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, + 0x52, 0x19, 0x6d, 0x69, 0x6e, 0x74, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x25, 0xe8, 0xa0, 0x1f, + 0x01, 0x8a, 0xe7, 0xb0, 0x2a, 0x1c, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, + 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x42, 0xbd, 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, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 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 ( 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/api/poktroll/tokenomics/tx.pulsar.go b/api/poktroll/tokenomics/tx.pulsar.go index 6182cb0ef..9cf66c7d1 100644 --- a/api/poktroll/tokenomics/tx.pulsar.go +++ b/api/poktroll/tokenomics/tx.pulsar.go @@ -4,6 +4,7 @@ package tokenomics import ( _ "cosmossdk.io/api/amino" _ "cosmossdk.io/api/cosmos/msg/v1" + binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -12,6 +13,7 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" io "io" + math "math" reflect "reflect" sync "sync" ) @@ -875,9 +877,7 @@ var ( md_MsgUpdateParam protoreflect.MessageDescriptor fd_MsgUpdateParam_authority protoreflect.FieldDescriptor fd_MsgUpdateParam_name protoreflect.FieldDescriptor - fd_MsgUpdateParam_as_string protoreflect.FieldDescriptor - fd_MsgUpdateParam_as_int64 protoreflect.FieldDescriptor - fd_MsgUpdateParam_as_bytes protoreflect.FieldDescriptor + fd_MsgUpdateParam_as_float protoreflect.FieldDescriptor ) func init() { @@ -885,9 +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_string = md_MsgUpdateParam.Fields().ByName("as_string") - fd_MsgUpdateParam_as_int64 = md_MsgUpdateParam.Fields().ByName("as_int64") - fd_MsgUpdateParam_as_bytes = md_MsgUpdateParam.Fields().ByName("as_bytes") + fd_MsgUpdateParam_as_float = md_MsgUpdateParam.Fields().ByName("as_float") } var _ protoreflect.Message = (*fastReflection_MsgUpdateParam)(nil) @@ -969,22 +967,10 @@ func (x *fastReflection_MsgUpdateParam) Range(f func(protoreflect.FieldDescripto } if x.AsType != nil { switch o := x.AsType.(type) { - case *MsgUpdateParam_AsString: - v := o.AsString - value := protoreflect.ValueOfString(v) - if !f(fd_MsgUpdateParam_as_string, value) { - return - } - case *MsgUpdateParam_AsInt64: - v := o.AsInt64 - value := protoreflect.ValueOfInt64(v) - if !f(fd_MsgUpdateParam_as_int64, value) { - return - } - case *MsgUpdateParam_AsBytes: - v := o.AsBytes - value := protoreflect.ValueOfBytes(v) - if !f(fd_MsgUpdateParam_as_bytes, value) { + case *MsgUpdateParam_AsFloat: + v := o.AsFloat + value := protoreflect.ValueOfFloat64(v) + if !f(fd_MsgUpdateParam_as_float, value) { return } } @@ -1008,26 +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_string": + case "poktroll.tokenomics.MsgUpdateParam.as_float": if x.AsType == nil { return false - } else if _, ok := x.AsType.(*MsgUpdateParam_AsString); ok { - return true - } else { - return false - } - case "poktroll.tokenomics.MsgUpdateParam.as_int64": - if x.AsType == nil { - return false - } else if _, ok := x.AsType.(*MsgUpdateParam_AsInt64); ok { - return true - } else { - return false - } - case "poktroll.tokenomics.MsgUpdateParam.as_bytes": - if x.AsType == nil { - return false - } else if _, ok := x.AsType.(*MsgUpdateParam_AsBytes); ok { + } else if _, ok := x.AsType.(*MsgUpdateParam_AsFloat); ok { return true } else { return false @@ -1052,11 +1022,7 @@ func (x *fastReflection_MsgUpdateParam) Clear(fd protoreflect.FieldDescriptor) { x.Authority = "" case "poktroll.tokenomics.MsgUpdateParam.name": x.Name = "" - case "poktroll.tokenomics.MsgUpdateParam.as_string": - x.AsType = nil - case "poktroll.tokenomics.MsgUpdateParam.as_int64": - x.AsType = nil - case "poktroll.tokenomics.MsgUpdateParam.as_bytes": + case "poktroll.tokenomics.MsgUpdateParam.as_float": x.AsType = nil default: if fd.IsExtension() { @@ -1080,29 +1046,13 @@ 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_string": - if x.AsType == nil { - return protoreflect.ValueOfString("") - } else if v, ok := x.AsType.(*MsgUpdateParam_AsString); ok { - return protoreflect.ValueOfString(v.AsString) - } else { - return protoreflect.ValueOfString("") - } - case "poktroll.tokenomics.MsgUpdateParam.as_int64": - if x.AsType == nil { - return protoreflect.ValueOfInt64(int64(0)) - } else if v, ok := x.AsType.(*MsgUpdateParam_AsInt64); ok { - return protoreflect.ValueOfInt64(v.AsInt64) - } else { - return protoreflect.ValueOfInt64(int64(0)) - } - case "poktroll.tokenomics.MsgUpdateParam.as_bytes": + case "poktroll.tokenomics.MsgUpdateParam.as_float": if x.AsType == nil { - return protoreflect.ValueOfBytes(nil) - } else if v, ok := x.AsType.(*MsgUpdateParam_AsBytes); ok { - return protoreflect.ValueOfBytes(v.AsBytes) + return protoreflect.ValueOfFloat64(float64(0)) + } else if v, ok := x.AsType.(*MsgUpdateParam_AsFloat); ok { + return protoreflect.ValueOfFloat64(v.AsFloat) } else { - return protoreflect.ValueOfBytes(nil) + return protoreflect.ValueOfFloat64(float64(0)) } default: if descriptor.IsExtension() { @@ -1128,15 +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_string": - cv := value.Interface().(string) - x.AsType = &MsgUpdateParam_AsString{AsString: cv} - case "poktroll.tokenomics.MsgUpdateParam.as_int64": - cv := value.Int() - x.AsType = &MsgUpdateParam_AsInt64{AsInt64: cv} - case "poktroll.tokenomics.MsgUpdateParam.as_bytes": - cv := value.Bytes() - x.AsType = &MsgUpdateParam_AsBytes{AsBytes: cv} + case "poktroll.tokenomics.MsgUpdateParam.as_float": + cv := value.Float() + x.AsType = &MsgUpdateParam_AsFloat{AsFloat: cv} default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.MsgUpdateParam")) @@ -1161,12 +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_string": - panic(fmt.Errorf("field as_string of message poktroll.tokenomics.MsgUpdateParam is not mutable")) - case "poktroll.tokenomics.MsgUpdateParam.as_int64": - panic(fmt.Errorf("field as_int64 of message poktroll.tokenomics.MsgUpdateParam is not mutable")) - case "poktroll.tokenomics.MsgUpdateParam.as_bytes": - panic(fmt.Errorf("field as_bytes 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")) @@ -1184,12 +1124,8 @@ func (x *fastReflection_MsgUpdateParam) NewField(fd protoreflect.FieldDescriptor return protoreflect.ValueOfString("") case "poktroll.tokenomics.MsgUpdateParam.name": return protoreflect.ValueOfString("") - case "poktroll.tokenomics.MsgUpdateParam.as_string": - return protoreflect.ValueOfString("") - case "poktroll.tokenomics.MsgUpdateParam.as_int64": - return protoreflect.ValueOfInt64(int64(0)) - case "poktroll.tokenomics.MsgUpdateParam.as_bytes": - return protoreflect.ValueOfBytes(nil) + case "poktroll.tokenomics.MsgUpdateParam.as_float": + return protoreflect.ValueOfFloat64(float64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.MsgUpdateParam")) @@ -1208,12 +1144,8 @@ func (x *fastReflection_MsgUpdateParam) WhichOneof(d protoreflect.OneofDescripto return nil } switch x.AsType.(type) { - case *MsgUpdateParam_AsString: - return x.Descriptor().Fields().ByName("as_string") - case *MsgUpdateParam_AsInt64: - return x.Descriptor().Fields().ByName("as_int64") - case *MsgUpdateParam_AsBytes: - return x.Descriptor().Fields().ByName("as_bytes") + 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())) @@ -1280,23 +1212,11 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } switch x := x.AsType.(type) { - case *MsgUpdateParam_AsString: - if x == nil { - break - } - l = len(x.AsString) - n += 1 + l + runtime.Sov(uint64(l)) - case *MsgUpdateParam_AsInt64: + case *MsgUpdateParam_AsFloat: if x == nil { break } - n += 1 + runtime.Sov(uint64(x.AsInt64)) - case *MsgUpdateParam_AsBytes: - if x == nil { - break - } - l = len(x.AsBytes) - n += 1 + l + runtime.Sov(uint64(l)) + n += 9 } if x.unknownFields != nil { n += len(x.unknownFields) @@ -1328,22 +1248,11 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], x.unknownFields) } switch x := x.AsType.(type) { - case *MsgUpdateParam_AsString: - i -= len(x.AsString) - copy(dAtA[i:], x.AsString) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AsString))) + case *MsgUpdateParam_AsFloat: + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.AsFloat)))) i-- - dAtA[i] = 0x1a - case *MsgUpdateParam_AsInt64: - i = runtime.EncodeVarint(dAtA, i, uint64(x.AsInt64)) - i-- - dAtA[i] = 0x30 - case *MsgUpdateParam_AsBytes: - i -= len(x.AsBytes) - copy(dAtA[i:], x.AsBytes) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AsBytes))) - i-- - dAtA[i] = 0x3a + dAtA[i] = 0x19 } if len(x.Name) > 0 { i -= len(x.Name) @@ -1473,90 +1382,16 @@ func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { x.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsString", 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.AsType = &MsgUpdateParam_AsString{string(dAtA[iNdEx:postIndex])} - iNdEx = postIndex - case 6: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsInt64", wireType) - } - var v int64 - 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 |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - x.AsType = &MsgUpdateParam_AsInt64{v} - case 7: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsBytes", 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 + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsFloat", wireType) } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { + var v uint64 + if (iNdEx + 8) > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - x.AsType = &MsgUpdateParam_AsBytes{v} - iNdEx = postIndex + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.AsType = &MsgUpdateParam_AsFloat{float64(math.Float64frombits(v))} default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -2128,9 +1963,7 @@ type MsgUpdateParam struct { Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Types that are assignable to AsType: // - // *MsgUpdateParam_AsString - // *MsgUpdateParam_AsInt64 - // *MsgUpdateParam_AsBytes + // *MsgUpdateParam_AsFloat AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` } @@ -2175,48 +2008,22 @@ func (x *MsgUpdateParam) GetAsType() isMsgUpdateParam_AsType { return nil } -func (x *MsgUpdateParam) GetAsString() string { - if x, ok := x.GetAsType().(*MsgUpdateParam_AsString); ok { - return x.AsString - } - return "" -} - -func (x *MsgUpdateParam) GetAsInt64() int64 { - if x, ok := x.GetAsType().(*MsgUpdateParam_AsInt64); ok { - return x.AsInt64 +func (x *MsgUpdateParam) GetAsFloat() float64 { + if x, ok := x.GetAsType().(*MsgUpdateParam_AsFloat); ok { + return x.AsFloat } return 0 } -func (x *MsgUpdateParam) GetAsBytes() []byte { - if x, ok := x.GetAsType().(*MsgUpdateParam_AsBytes); ok { - return x.AsBytes - } - return nil -} - type isMsgUpdateParam_AsType interface { isMsgUpdateParam_AsType() } -type MsgUpdateParam_AsString struct { - AsString string `protobuf:"bytes,3,opt,name=as_string,json=asString,proto3,oneof"` -} - -type MsgUpdateParam_AsInt64 struct { - AsInt64 int64 `protobuf:"varint,6,opt,name=as_int64,json=asInt64,proto3,oneof"` +type MsgUpdateParam_AsFloat struct { + AsFloat float64 `protobuf:"fixed64,3,opt,name=as_float,json=asFloat,proto3,oneof"` } -type MsgUpdateParam_AsBytes struct { - AsBytes []byte `protobuf:"bytes,7,opt,name=as_bytes,json=asBytes,proto3,oneof"` -} - -func (*MsgUpdateParam_AsString) isMsgUpdateParam_AsType() {} - -func (*MsgUpdateParam_AsInt64) isMsgUpdateParam_AsType() {} - -func (*MsgUpdateParam_AsBytes) isMsgUpdateParam_AsType() {} +func (*MsgUpdateParam_AsFloat) isMsgUpdateParam_AsType() {} // MsgUpdateParamResponse defines the response structure for executing a // MsgUpdateParam message after a single param update. @@ -2283,53 +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, 0xfb, 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, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0d, 0xea, 0xde, 0x1f, 0x09, 0x61, 0x73, 0x5f, 0x73, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x08, 0x61, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x12, 0x29, 0x0a, 0x08, 0x61, 0x73, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x03, 0x42, 0x0c, 0xea, 0xde, 0x1f, 0x08, 0x61, 0x73, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, - 0x48, 0x00, 0x52, 0x07, 0x61, 0x73, 0x49, 0x6e, 0x74, 0x36, 0x34, 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, 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, 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, + 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, 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 ( @@ -2423,9 +2224,7 @@ func file_poktroll_tokenomics_tx_proto_init() { } } file_poktroll_tokenomics_tx_proto_msgTypes[2].OneofWrappers = []interface{}{ - (*MsgUpdateParam_AsString)(nil), - (*MsgUpdateParam_AsInt64)(nil), - (*MsgUpdateParam_AsBytes)(nil), + (*MsgUpdateParam_AsFloat)(nil), } type x struct{} out := protoimpl.TypeBuilder{ diff --git a/cmd/poktrolld/cmd/config.go b/cmd/poktrolld/cmd/config.go index 61a441fa7..ae9520a41 100644 --- a/cmd/poktrolld/cmd/config.go +++ b/cmd/poktrolld/cmd/config.go @@ -156,21 +156,21 @@ func customPoktrollAppConfigTemplate() string { ############################################################################### ### Poktroll ### ############################################################################### - + # Poktroll-specific app configuration for Full Nodes and Validators. [poktroll] # Telemetry configuration in addition to the [telemetry] settings. [poktroll.telemetry] - + # Cardinality level for telemetry metrics collection # This controls the level of detail (number of unique labels) in metrics. # Options: - # - "low": Collects basic metrics with low cardinality. + # - "low": Collects basic metrics with low cardinality. # Suitable for production environments with tight performance constraints. # - "medium": Collects a moderate number of labels, balancing detail and performance. # Suitable for moderate workloads or staging environments. - # - "high": WARNING: WILL CAUSE STRESS TO YOUR MONITORING ENVIRONMENT! Collects detailed metrics with high + # - "high": WARNING: WILL CAUSE STRESS TO YOUR MONITORING ENVIRONMENT! Collects detailed metrics with high # cardinality, including labels with many unique values (e.g., application_id, session_id). # Recommended for debugging or testing environments. cardinality-level = "{{ .Poktroll.Telemetry.CardinalityLevel }}" diff --git a/cmd/poktrolld/cmd/root.go b/cmd/poktrolld/cmd/root.go index a0cb39688..86fd01f81 100644 --- a/cmd/poktrolld/cmd/root.go +++ b/cmd/poktrolld/cmd/root.go @@ -30,7 +30,7 @@ import ( relayercmd "github.com/pokt-network/poktroll/pkg/relayer/cmd" ) -// TODO_MAINNET: adjust chain ID for the mainnet if it's going to change +// TODO_MAINNET: adjust chain ID to `pocket`, `pokt` or `shannon` const DefaultChainID = "poktroll" // NewRootCmd creates a new root command for poktrolld. It is called once in the main function. diff --git a/config.yml b/config.yml index 3449dfc4d..ae62cb029 100644 --- a/config.yml +++ b/config.yml @@ -94,7 +94,7 @@ validators: app: # DEV_NOTE: Ignite does not carry over all defaults, so we are going to match `minimum-gas-prices` with `cmd/config.go`. # See the enhancement request here: https://github.com/ignite/cli/issues/4340 - # TODO_MAINNET(#794): turn on `minimum-gas-prices` back + # TODO_BETA(@okdas, #794): turn on `minimum-gas-prices` back # minimum-gas-prices: 0.000000001upokt telemetry: enabled: true @@ -135,9 +135,7 @@ genesis: staking: params: bond_denom: upokt - # TODO_MAINNET: Figure out what this should be on Shannon - # re-genesis. We're setting it to 1 for Alpha TestNet #1 so Grove - # maintains the only validator until Alpha TestNet #2. + # TODO_BETA(@okdas): Update this to 10 for Beta TestNet. max_validators: 1 crisis: constant_fee: @@ -150,13 +148,15 @@ genesis: denom: upokt bank: supply: - - amount: "1102000204" + - amount: "1202000272" denom: upokt balances: # Application module - address: pokt1rl3gjgzexmplmds3tq3r3yk84zlwdl6djzgsvm coins: - - amount: "100000068" # MUST BE equal to the total of all app stakes below + # TODO_MAINNET(@olshansk): Pass config.yml into ChatGPT to build a script + # that ensures the amounts line up + - amount: "200000136" # MUST BE equal to the total of all app stakes below denom: upokt # Supplier module - address: pokt1j40dzzmn6cn9kxku7a5tjnud6hv37vesr5ccaa @@ -177,7 +177,7 @@ genesis: params: max_delegated_gateways: "7" min_stake: - # TODO_MAINNET: Determine realistic amount for minimum application stake amount. + # TODO_BETA(@bryanchriswhite): Determine realistic amount for minimum application stake amount. amount: "100000000" # 100 POKT denom: upokt applicationList: @@ -203,7 +203,7 @@ genesis: denom: upokt supplier: params: - # TODO_MAINNET: Determine realistic amount for minimum gateway stake amount. + # TODO_BETA(@bryanchriswhite): Determine realistic amount for minimum gateway stake amount. min_stake: amount: "1000000" # 1 POKT denom: upokt @@ -242,7 +242,7 @@ genesis: denom: upokt gateway: params: - # TODO_MAINNET: Determine realistic amount for minimum gateway stake amount. + # TODO_BETA(@bryanchriswhite): Determine realistic amount for minimum gateway stake amount. min_stake: amount: "1000000" # 1 POKT denom: upokt @@ -283,6 +283,16 @@ genesis: proof_submission_fee: amount: "1000000" denom: upokt + session: + params: + num_suppliers_per_session: 15 + tokenomics: + params: + mint_allocation_dao: 0.1 + mint_allocation_proposer: 0.05 + mint_allocation_supplier: 0.7 + mint_allocation_source_owner: 0.15 + mint_allocation_application: 0.0 shared: params: num_blocks_per_session: 10 diff --git a/docusaurus/docs/operate/run_a_node/full_node_cosmovisor.md b/docusaurus/docs/operate/run_a_node/full_node_cosmovisor.md index e9a1c8704..629408040 100644 --- a/docusaurus/docs/operate/run_a_node/full_node_cosmovisor.md +++ b/docusaurus/docs/operate/run_a_node/full_node_cosmovisor.md @@ -62,7 +62,7 @@ To install and set up a Poktroll Full Node using Cosmovisor, we provide a compre 4. Follow the prompts to provide the necessary information: - Desired username to run poktrolld (`default: poktroll`) - Node moniker (`default: hostname`) - - Seeds (`default: fetched` [from the official source](https://github.com/pokt-network/pocket-network-genesis/tree/master/poktrolld)) + - Seeds (`default: fetched` [from the official source](https://github.com/pokt-network/pocket-network-genesis/tree/master/shannon/alpha)) - Chain ID (`default: poktroll-testnet`) The script will then proceed with the installation and setup process. 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/e2e/tests/parse_params_test.go b/e2e/tests/parse_params_test.go index f8a213eaa..9e329ad3e 100644 --- a/e2e/tests/parse_params_test.go +++ b/e2e/tests/parse_params_test.go @@ -59,10 +59,10 @@ func (s *suite) parseParam(table gocuke.DataTable, rowIdx int) paramAny { case "bytes": paramValue = []byte(table.Cell(rowIdx, paramValueColIdx).String()) case "float": - floatValue, err := strconv.ParseFloat(table.Cell(rowIdx, paramValueColIdx).String(), 32) + floatValue, err := strconv.ParseFloat(table.Cell(rowIdx, paramValueColIdx).String(), 64) require.NoError(s, err) - paramValue = float32(floatValue) + paramValue = floatValue case "coin": coinAmount := table.Cell(rowIdx, paramValueColIdx).Int64() coinValue := cosmostypes.NewCoin(volatile.DenomuPOKT, math.NewInt(coinAmount)) @@ -132,7 +132,7 @@ func (s *suite) newProofMsgUpdateParams(params paramsAnyMap) cosmostypes.Msg { for paramName, paramValue := range params { switch paramName { case prooftypes.ParamProofRequestProbability: - msgUpdateParams.Params.ProofRequestProbability = paramValue.value.(float32) + msgUpdateParams.Params.ProofRequestProbability = paramValue.value.(float64) case prooftypes.ParamProofRequirementThreshold: msgUpdateParams.Params.ProofRequirementThreshold = paramValue.value.(*cosmostypes.Coin) case prooftypes.ParamProofMissingPenalty: @@ -257,28 +257,12 @@ func (s *suite) newMsgUpdateParam( func (s *suite) newTokenomicsMsgUpdateParam(authority string, param paramAny) (msg proto.Message) { switch param.typeStr { - case "string": - msg = proto.Message(&tokenomicstypes.MsgUpdateParam{ - Authority: authority, - Name: param.name, - AsType: &tokenomicstypes.MsgUpdateParam_AsString{ - AsString: param.value.(string), - }, - }) - case "int64": + case "float64": msg = proto.Message(&tokenomicstypes.MsgUpdateParam{ Authority: authority, Name: param.name, - AsType: &tokenomicstypes.MsgUpdateParam_AsInt64{ - AsInt64: param.value.(int64), - }, - }) - case "bytes": - msg = proto.Message(&tokenomicstypes.MsgUpdateParam{ - Authority: authority, - Name: param.name, - AsType: &tokenomicstypes.MsgUpdateParam_AsBytes{ - AsBytes: param.value.([]byte), + AsType: &tokenomicstypes.MsgUpdateParam_AsFloat{ + AsFloat: param.value.(float64), }, }) default: @@ -303,7 +287,7 @@ func (s *suite) newProofMsgUpdateParam(authority string, param paramAny) (msg pr Authority: authority, Name: param.name, AsType: &prooftypes.MsgUpdateParam_AsFloat{ - AsFloat: param.value.(float32), + AsFloat: param.value.(float64), }, }) case "coin": diff --git a/e2e/tests/update_params_test.go b/e2e/tests/update_params_test.go index 8dbaee5dc..27c0be4d0 100644 --- a/e2e/tests/update_params_test.go +++ b/e2e/tests/update_params_test.go @@ -364,7 +364,7 @@ func (s *suite) assertExpectedModuleParamsUpdated(moduleName string) { proofRequestProbability, ok := paramsMap[prooftypes.ParamProofRequestProbability] if ok { - params.ProofRequestProbability = proofRequestProbability.value.(float32) + params.ProofRequestProbability = proofRequestProbability.value.(float64) } proofRequirementThreshold, ok := paramsMap[prooftypes.ParamProofRequirementThreshold] diff --git a/makefiles/params.mk b/makefiles/params.mk index 3e577ab52..d81528fa6 100644 --- a/makefiles/params.mk +++ b/makefiles/params.mk @@ -14,9 +14,21 @@ params_get_tokenomics: ## Get the tokenomics module params params_update_tokenomics_all: ## Update the tokenomics module params poktrolld tx authz exec ./tools/scripts/params/tokenomics_all.json $(PARAM_FLAGS) -.PHONY: params_update_tokenomics_compute_units_to_tokens_multiplier -params_update_tokenomics_compute_units_to_tokens_multiplier: ## Update the tokenomics module compute_units_to_tokens_multiplier param - poktrolld tx authz exec ./tools/scripts/params/tokenomics_compute_units_to_tokens_multiplier.json $(PARAM_FLAGS) +.PHONY: params_update_tokenomics_mint_allocation_dao +params_update_tokenomics_mint_allocation_dao: ## Update the tokenomics module mint_allocation_dao param + poktrolld tx authz exec ./tools/scripts/params/tokenomics_mint_allocation_dao.json $(PARAM_FLAGS) + +.PHONY: params_update_tokenomics_mint_allocation_proposer +params_update_tokenomics_mint_allocation_proposer: ## Update the tokenomics module mint_allocation_proposer param + poktrolld tx authz exec ./tools/scripts/params/tokenomics_mint_allocation_proposer.json $(PARAM_FLAGS) + +.PHONY: params_update_tokenomics_mint_allocation_supplier +params_update_tokenomics_mint_allocation_supplier: ## Update the tokenomics module mint_allocation_supplier param + poktrolld tx authz exec ./tools/scripts/params/tokenomics_mint_allocation_supplier.json $(PARAM_FLAGS) + +.PHONY: params_update_tokenomics_mint_allocation_source_owner +params_update_tokenomics_mint_allocation_source_owner: ## Update the tokenomics module mint_allocation_source_owner param + poktrolld tx authz exec ./tools/scripts/params/tokenomics_mint_allocation_source_owner.json $(PARAM_FLAGS) ### Service Module Params ### .PHONY: params_get_service @@ -144,6 +156,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/makefiles/todos.mk b/makefiles/todos.mk index d4f20517b..ce77ea664 100644 --- a/makefiles/todos.mk +++ b/makefiles/todos.mk @@ -1,45 +1,47 @@ ############# ### TODOS ### ############# - -# How do I use TODOs? -# 1. : ; +## Inspired by @goldinguy_ in this post: https://goldin.io/blog/stop-using-todo ### +# +## How do I use TODOs? +# +# 1. TODO_: # e.g. TODO_HACK: This is a hack, we need to fix it later -# 2. If there's a specific issue, or specific person, add that in paranthesiss +# +# 2. If there's a specific issue and/or person, include it in paranthesiss +# # e.g. TODO(@Olshansk): Automatically link to the Github user https://github.com/olshansk # e.g. TODO_INVESTIGATE(#420): Automatically link this to github issue https://github.com/pokt-network/poktroll/issues/420 # e.g. TODO_DISCUSS(@Olshansk, #420): Specific individual should tend to the action item in the specific ticket -# e.g. TODO_CLEANUP(core): This is not tied to an issue, or a person, but should only be done by the core team. # e.g. TODO_CLEANUP: This is not tied to an issue, or a person, and can be done by the core team or external contributors. +# # 3. Feel free to add additional keywords to the list above. - -# Inspired by @goldinguy_ in this post: https://goldin.io/blog/stop-using-todo ### -# TODO - General Purpose catch-all. +# +## TODO LIST +# TODO - General Purpose catch-all. Try to keep the usage of this to a minimum. # TODO_COMMUNITY - A TODO that may be a candidate for outsourcing to the community. # TODO_DECIDE - A TODO indicating we need to make a decision and document it using an ADR in the future; https://github.com/pokt-network/pocket-network-protocol/tree/main/ADRs -# TODO_TECHDEBT - Not a great implementation, but we need to fix it later. -# TODO_BLOCKER - BEFORE MAINNET. Similar to TECHDEBT, but of higher priority, urgency & risk prior to the next release -# TODO_QOL - AFTER MAINNET. Similar to TECHDEBT, but of lower priority. Doesn't deserve a GitHub Issue but will improve everyone's life. -# TODO_IMPROVE - A nice to have, but not a priority. It's okay if we never get to this. -# TODO_OPTIMIZE - An opportunity for performance improvement if/when it's necessary -# TODO_DISCUSS - Probably requires a lengthy offline discussion to understand next steps. -# TODO_INCOMPLETE - A change which was out of scope of a specific PR but needed to be documented. -# TODO_INVESTIGATE - TBD what was going on, but needed to continue moving and not get distracted. -# TODO_CLEANUP - Like TECHDEBT, but not as bad. It's okay if we never get to this. -# TODO_HACK - Like TECHDEBT, but much worse. This needs to be prioritized -# TODO_REFACTOR - Similar to TECHDEBT, but will require a substantial rewrite and change across the codebase -# TODO_CONSIDERATION - A comment that involves extra work but was thoughts / considered as part of some implementation -# TODO_CONSOLIDATE - We likely have similar implementations/types of the same thing, and we should consolidate them. -# TODO_ADDTEST / TODO_TEST - Add more tests for a specific code section -# TODO_FLAKY - Signals that the test is flaky and we are aware of it. Provide an explanation if you know why. -# TODO_DEPRECATE - Code that should be removed in the future -# TODO_RESEARCH - A non-trivial action item that requires deep research and investigation being next steps can be taken -# TODO_DOCUMENT - A comment that involves the creation of a README or other documentation -# TODO_BUG - There is a known existing bug in this code -# TODO_NB - An important note to reference later -# TODO_DISCUSS_IN_THIS_COMMIT - SHOULD NEVER BE COMMITTED TO MASTER. It is a way for the reviewer of a PR to start / reply to a discussion. -# TODO_IN_THIS_COMMIT - SHOULD NEVER BE COMMITTED TO MASTER. It is a way to start the review process while non-critical changes are still in progress - +# TODO_TECHDEBT - Code that works but isn’t ideal; needs a fix to improve maintainability and avoid accumulating technical debt. +# TODO_QOL - AFTER MAINNET. Low-priority improvements that enhance the code quality or developer experience. +# TODO_IMPROVE - A nice-to-have but not a priority; it’s okay if we never get to this. +# TODO_OPTIMIZE - Performance improvements that can be pursued if performance demands increase. +# TODO_DISCUSS - Marks code that requires a larger discussion with the team to clarify next steps or make decisions. +# TODO_INCOMPLETE - Notes unfinished work or partial implementation that should be completed later. +# TODO_INVESTIGATE - Requires more investigation to clarify issues or validate behavior; avoid premature optimizations without research. +# TODO_CLEANUP - Lower-priority cleanup or refactoring tasks; it’s acceptable if this is never prioritized. +# TODO_HACK - Code is functional but particularly bad; prioritization needed to fix due to the hacky implementation. +# TODO_REFACTOR - Indicates a need for a significant rewrite or architectural change across the codebase. +# TODO_CONSIDERATION - Marks optional considerations or ideas related to the code that could be explored later. +# TODO_CONSOLIDATE - Similar implementations or data structures are likely scattered; consolidate to reduce duplication. +# TODO_TEST / TODO_ADDTEST - Signals that additional test coverage is needed in this code section. +# TODO_FLAKY - Known flaky test; provides an explanation if there’s an understanding of the root cause. +# TODO_DEPRECATE - Marks code slated for eventual removal or replacement. +# TODO_RESEARCH - Requires substantial research or exploration before proceeding with next steps or optimization. +# TODO_DOCUMENT - Involves creating or updating documentation, such as READMEs, inline comments, or other resources. +# TODO_BUG - Known bug exists; this should be prioritized based on severity. +# TODO_NB - Important note that may not require immediate action but should be referenced later. +# TODO_IN_THIS_??? - Indicates ongoing non-critical changes before final review. THIS SHOULD NEVER BE COMMITTED TO MASTER and has workflows to prevent it. +# TODO_UPNEXT(@???) - Indicates this should be done shortly after an existing PR. THIS MUST HAVE A USER ASSIGNED TO IT and has workflows to prevent it. # Define shared variable for the exclude parameters EXCLUDE_GREP = --exclude-dir={.git,vendor,./docusaurus,.vscode,.idea} --exclude={Makefile,reviewdog.yml,*.pb.go,*.pulsar.go} @@ -50,8 +52,4 @@ todo_list: ## List all the TODOs in the project (excludes vendor and prototype d .PHONY: todo_count todo_count: ## Print a count of all the TODOs in the project - grep -r $(EXCLUDE_GREP) TODO . | grep -v 'TODO()' | wc -l - -.PHONY: todo_this_commit -todo_this_commit: ## List all the TODOs needed to be done in this commit - grep -r $(EXCLUDE_GREP) TODO_IN_THIS .| grep -v 'TODO()' + grep -r $(EXCLUDE_GREP) TODO . | grep -v 'TODO()' | wc -l \ No newline at end of file diff --git a/pkg/appgateserver/config/appgate_configs_reader.go b/pkg/appgateserver/config/appgate_configs_reader.go index 29c8c8f20..18c38a745 100644 --- a/pkg/appgateserver/config/appgate_configs_reader.go +++ b/pkg/appgateserver/config/appgate_configs_reader.go @@ -7,7 +7,7 @@ import ( ) // YAMLAppGateServerConfig is the structure used to unmarshal the AppGateServer config file -// TODO_BETA(@red-0ne): Rename self_signing parameter to `sovereign` in code, configs +// TODO_MAINNET(@red-0ne): Rename self_signing parameter to `sovereign` in code, configs // and documentation type YAMLAppGateServerConfig struct { ListeningEndpoint string `yaml:"listening_endpoint"` diff --git a/pkg/client/interface.go b/pkg/client/interface.go index da564c1e2..365c24b74 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -291,6 +291,9 @@ type SessionQueryClient interface { serviceId string, blockHeight int64, ) (*sessiontypes.Session, error) + + // GetParams queries the chain for the session module parameters. + GetParams(ctx context.Context) (*sessiontypes.Params, error) } // SharedQueryClient defines an interface that enables the querying of the @@ -330,7 +333,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/client/query/sessionquerier.go b/pkg/client/query/sessionquerier.go index 7dba6e87c..8553e3313 100644 --- a/pkg/client/query/sessionquerier.go +++ b/pkg/client/query/sessionquerier.go @@ -62,3 +62,13 @@ func (sessq *sessionQuerier) GetSession( } return res.Session, nil } + +// GetParams queries & returns the session module on-chain parameters. +func (sessq *sessionQuerier) GetParams(ctx context.Context) (*sessiontypes.Params, error) { + req := &sessiontypes.QueryParamsRequest{} + res, err := sessq.sessionQuerier.Params(ctx, req) + if err != nil { + return nil, ErrQuerySessionParams.Wrapf("[%v]", err) + } + return &res.Params, nil +} 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/pkg/relayer/cmd/cmd.go b/pkg/relayer/cmd/cmd.go index 98df7e375..18cd07d42 100644 --- a/pkg/relayer/cmd/cmd.go +++ b/pkg/relayer/cmd/cmd.go @@ -198,12 +198,13 @@ func setupRelayerDependencies( config.NewSupplyDelegationClientFn(), // leaf config.NewSupplySharedQueryClientFn(), // leaf config.NewSupplyServiceQueryClientFn(), + config.NewSupplyApplicationQuerierFn(), + config.NewSupplySessionQuerierFn(), + supplyRelayMeter, supplyMiner, config.NewSupplyAccountQuerierFn(), config.NewSupplyBankQuerierFn(), - config.NewSupplyApplicationQuerierFn(), config.NewSupplySupplierQuerierFn(), - config.NewSupplySessionQuerierFn(), config.NewSupplyProofQueryClientFn(), config.NewSupplyRingCacheFn(), supplyTxFactory, @@ -231,6 +232,21 @@ func supplyMiner( return depinject.Configs(deps, depinject.Supply(mnr)), nil } +// supplyRelayMeter constructs a RelayMeter instance and returns a new +// depinject.Config which is supplied with the given deps and the new RelayMeter. +func supplyRelayMeter( + _ context.Context, + deps depinject.Config, + _ *cobra.Command, +) (depinject.Config, error) { + rm, err := proxy.NewRelayMeter(deps) + if err != nil { + return nil, err + } + + return depinject.Configs(deps, depinject.Supply(rm)), nil +} + // supplyTxFactory constructs a cosmostx.Factory instance and returns a new // depinject.Config which is supplied with the given deps and the new // cosmostx.Factory. diff --git a/pkg/relayer/interface.go b/pkg/relayer/interface.go index 1f231e7f1..766dcb5ce 100644 --- a/pkg/relayer/interface.go +++ b/pkg/relayer/interface.go @@ -1,6 +1,7 @@ //go:generate mockgen -destination=../../testutil/mockrelayer/relayer_proxy_mock.go -package=mockrelayer . RelayerProxy //go:generate mockgen -destination=../../testutil/mockrelayer/miner_mock.go -package=mockrelayer . Miner //go:generate mockgen -destination=../../testutil/mockrelayer/relayer_sessions_manager_mock.go -package=mockrelayer . RelayerSessionsManager +//go:generate mockgen -destination=../../testutil/mockrelayer/relay_meter_mock.go -package=mockrelayer . RelayMeter package relayer @@ -162,3 +163,29 @@ type SessionTree interface { // GetTrieSpec returns the trie spec of the SMST. GetTrieSpec() smt.TrieSpec } + +// RelayMeter is an interface that keeps track of the amount of stake consumed between +// a single onchain Application and a single onchain Supplier over the course of a single session. +// It enables the RelayMiner to rate limit the number of requests handled offchain as a function +// of the optimistic onchain rate limits. +type RelayMeter interface { + // Start starts the relay meter. + Start(ctx context.Context) error + + // AccumulateRelayReward adds the relay reward from the incoming request to session's accumulator. + // The relay cost is added optimistically, assuming that the relay WILL be volume / reward applicable. + // + // The reason why optimistic AccumulateRelayReward + SetNonApplicableRelayReward is used instead of + // a simpler AccumulateVolumeApplicableRelayReward is that when the relay is first seen + // we don't know if it will be volume / reward applicable until it is served. + // + // To rate limit or not the current relay, we need to always optimistically account all relays as being + // volume / reward applicable. + AccumulateRelayReward(ctx context.Context, relayRequestMeta servicetypes.RelayRequestMetadata) error + + // SetNonApplicableRelayReward updates the relay meter for the given relay request as + // non-applicable between a single Application and a single Supplier for a single session. + // The volume / reward applicability of the relay is unknown to the relay miner + // until the relay is served and the relay response signed. + SetNonApplicableRelayReward(ctx context.Context, relayRequestMeta servicetypes.RelayRequestMetadata) error +} diff --git a/pkg/relayer/miner/miner.go b/pkg/relayer/miner/miner.go index b6ed55e0e..83cd4a8a8 100644 --- a/pkg/relayer/miner/miner.go +++ b/pkg/relayer/miner/miner.go @@ -27,6 +27,7 @@ type miner struct { // serviceQueryClient is used to query for the relay difficulty target hash of a service. // relay_difficulty is the target hash which a relay hash must be less than to be volume/reward applicable. serviceQueryClient client.ServiceQueryClient + relayMeter relayer.RelayMeter } // NewMiner creates a new miner from the given dependencies and options. It @@ -43,7 +44,7 @@ func NewMiner( ) (*miner, error) { mnr := &miner{} - if err := depinject.Inject(deps, &mnr.serviceQueryClient); err != nil { + if err := depinject.Inject(deps, &mnr.serviceQueryClient, &mnr.relayMeter); err != nil { return nil, err } @@ -88,6 +89,9 @@ func (mnr *miner) mapMineRelay( ) (_ either.Either[*relayer.MinedRelay], skip bool) { relayBz, err := relay.Marshal() if err != nil { + if relayMeteringResult := mnr.unclaimRelayUPOKT(ctx, *relay); relayMeteringResult.IsError() { + return relayMeteringResult, false + } return either.Error[*relayer.MinedRelay](err), false } relayHashArr := protocol.GetRelayHashFromBytes(relayBz) @@ -95,11 +99,17 @@ func (mnr *miner) mapMineRelay( relayDifficultyTargetHash, err := mnr.getServiceRelayDifficultyTargetHash(ctx, relay.Req) if err != nil { - return either.Error[*relayer.MinedRelay](err), false + if relayMeteringResult := mnr.unclaimRelayUPOKT(ctx, *relay); relayMeteringResult.IsError() { + return relayMeteringResult, true + } + return either.Error[*relayer.MinedRelay](err), true } // The relay IS NOT volume / reward applicable if !protocol.IsRelayVolumeApplicable(relayHash, relayDifficultyTargetHash) { + if eitherMeteringResult := mnr.unclaimRelayUPOKT(ctx, *relay); eitherMeteringResult.IsError() { + return eitherMeteringResult, true + } return either.Success[*relayer.MinedRelay](nil), true } @@ -135,3 +145,13 @@ func (mnr *miner) getServiceRelayDifficultyTargetHash(ctx context.Context, req * return serviceRelayDifficulty.GetTargetHash(), nil } + +// unclaimRelayUPOKT unclaims the relay UPOKT reward for the relay. +// It returns an either.Error if the relay UPOKT reward could not be unclaimed. +func (mnr *miner) unclaimRelayUPOKT(ctx context.Context, relay servicetypes.Relay) either.Either[*relayer.MinedRelay] { + if err := mnr.relayMeter.SetNonApplicableRelayReward(ctx, relay.GetReq().GetMeta()); err != nil { + return either.Error[*relayer.MinedRelay](err) + } + + return either.Success[*relayer.MinedRelay](nil) +} diff --git a/pkg/relayer/miner/miner_test.go b/pkg/relayer/miner/miner_test.go index 7afbf69d2..1aaf6d318 100644 --- a/pkg/relayer/miner/miner_test.go +++ b/pkg/relayer/miner/miner_test.go @@ -13,12 +13,14 @@ import ( "time" "cosmossdk.io/depinject" + gomock "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/pkg/crypto/protocol" "github.com/pokt-network/poktroll/pkg/observable/channel" "github.com/pokt-network/poktroll/pkg/relayer" "github.com/pokt-network/poktroll/pkg/relayer/miner" + "github.com/pokt-network/poktroll/testutil/mockrelayer" "github.com/pokt-network/poktroll/testutil/testclient/testqueryclients" servicetypes "github.com/pokt-network/poktroll/x/service/types" ) @@ -48,8 +50,9 @@ func TestMiner_MinedRelays(t *testing.T) { testqueryclients.SetServiceRelayDifficultyTargetHash(t, testSvcId, testRelayMiningTargetHash) serviceQueryClientMock := testqueryclients.NewTestServiceQueryClient(t) + relayMeterMock := newMockRelayMeter(t) - deps := depinject.Supply(serviceQueryClientMock) + deps := depinject.Supply(serviceQueryClientMock, relayMeterMock) mnr, err := miner.NewMiner(deps) require.NoError(t, err) @@ -154,3 +157,17 @@ func unmarshalHexMinedRelay( Hash: relayHash, } } + +// newMockRelayMeter returns a mock RelayMeter that is used by the relay miner to claim and unclaim relays. +func newMockRelayMeter(t *testing.T) relayer.RelayMeter { + t.Helper() + + ctrl := gomock.NewController(t) + relayMeter := mockrelayer.NewMockRelayMeter(ctrl) + + relayMeter.EXPECT().Start(gomock.Any()).Return(nil).AnyTimes() + relayMeter.EXPECT().AccumulateRelayReward(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + relayMeter.EXPECT().SetNonApplicableRelayReward(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + + return relayMeter +} diff --git a/pkg/relayer/proxy/errors.go b/pkg/relayer/proxy/errors.go index be2dbd95c..ff2fc285f 100644 --- a/pkg/relayer/proxy/errors.go +++ b/pkg/relayer/proxy/errors.go @@ -17,4 +17,7 @@ var ( ErrRelayerProxyUnsupportedTransportType = sdkerrors.Register(codespace, 9, "unsupported proxy transport type") ErrRelayerProxyInternalError = sdkerrors.Register(codespace, 10, "internal error") ErrRelayerProxyMissingSupplierOperatorAddress = sdkerrors.Register(codespace, 11, "supplier operator address is missing") + ErrRelayerProxyUnknownSession = sdkerrors.Register(codespace, 12, "relayer proxy encountered unknown session") + ErrRelayerProxyRateLimited = sdkerrors.Register(codespace, 13, "offchain rate limit hit by relayer proxy") + ErrRelayerProxyUnclaimRelayPrice = sdkerrors.Register(codespace, 14, "failed to unclaim relay price") ) diff --git a/pkg/relayer/proxy/proxy.go b/pkg/relayer/proxy/proxy.go index 0db1016f9..ad69a587b 100644 --- a/pkg/relayer/proxy/proxy.go +++ b/pkg/relayer/proxy/proxy.go @@ -78,6 +78,11 @@ type relayerProxy struct { // 1. Relay verification to check if the incoming relay matches the supplier hosted by the relay miner; // 2. Relay signing to resolve which keyring key name to use for signing; OperatorAddressToSigningKeyNameMap map[string]string + + // relayMeter keeps track of the total amount of stake an onchhain Application + // will owe an onchain Supplier (backed by this RelayMiner) once the session settles. + // It also configures application over-servicing allowance. + relayMeter relayer.RelayMeter } // NewRelayerProxy creates a new relayer proxy with the given dependencies or returns @@ -86,9 +91,15 @@ type relayerProxy struct { // Required dependencies: // - cosmosclient.Context // - client.BlockClient +// - crypto.RingCache +// - client.SupplierQueryClient // - client.SessionQueryClient // - client.SharedQueryClient -// - client.SupplierQueryClient +// - keyring.Keyring +// - client.SharedQueryClient +// - client.ApplicationQueryClient +// - client.ServiceQueryClient +// - client.EventsQueryClient // // Available options: // - WithSigningKeyNames @@ -108,6 +119,7 @@ func NewRelayerProxy( &rp.sessionQuerier, &rp.sharedQuerier, &rp.keyring, + &rp.relayMeter, ); err != nil { return nil, err } @@ -143,6 +155,13 @@ func (rp *relayerProxy) Start(ctx context.Context) error { // Start the ring cache. rp.ringCache.Start(ctx) + // Start the relay meter by subscribing to the on-chain events. + // This function is non-blocking and the subscription cancellation is handled + // by the context passed to the Start method. + if err := rp.relayMeter.Start(ctx); err != nil { + return err + } + startGroup, ctx := errgroup.WithContext(ctx) for _, relayServer := range rp.servers { diff --git a/pkg/relayer/proxy/relay_meter.go b/pkg/relayer/proxy/relay_meter.go new file mode 100644 index 000000000..e60f058db --- /dev/null +++ b/pkg/relayer/proxy/relay_meter.go @@ -0,0 +1,460 @@ +package proxy + +import ( + "context" + "math/big" + "strings" + "sync" + + "cosmossdk.io/depinject" + "cosmossdk.io/math" + cosmostypes "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/gogoproto/proto" + + "github.com/pokt-network/poktroll/app/volatile" + "github.com/pokt-network/poktroll/pkg/client" + "github.com/pokt-network/poktroll/pkg/client/tx" + "github.com/pokt-network/poktroll/pkg/crypto/protocol" + "github.com/pokt-network/poktroll/pkg/either" + "github.com/pokt-network/poktroll/pkg/observable" + "github.com/pokt-network/poktroll/pkg/observable/channel" + "github.com/pokt-network/poktroll/pkg/polylog" + "github.com/pokt-network/poktroll/pkg/relayer" + apptypes "github.com/pokt-network/poktroll/x/application/types" + servicetypes "github.com/pokt-network/poktroll/x/service/types" + sessiontypes "github.com/pokt-network/poktroll/x/session/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +const defaultOverServicingAllowanceCoins = 1000000 + +var _ relayer.RelayMeter = (*ProxyRelayMeter)(nil) + +// sessionRelayMeter is the relay meter's internal representation of an onchain +// Application's max and consumed stake. +type sessionRelayMeter struct { + // The onchain application the relay meter is for. + app apptypes.Application + // The maximum uPOKT an application can pay this relayer for a given session. + // This is a fraction of the Application's overall stake in proportion. + maxCoin cosmostypes.Coin + // The amount of uPOKT a specific application has consumed from this relayer in the given session. + consumedCoin cosmostypes.Coin + // The header for the session the Application and Supplier (backed by the relayer) + // are exchanging services in. + sessionHeader *sessiontypes.SessionHeader + // numOverServicedRelays is the number of relays that have been over-serviced + // by the relayer for the application. + numOverServicedRelays uint64 + // numOverservicedComputeUnits is the number of compute units that have been + // over-serviced by the relayer for the application. + numOverServicedComputeUnits uint64 + + // sharedParams, service and serviceRelayDifficulty are used to calculate the relay cost + // that increments the consumedAmount. + // They are cached at each session to avoid querying the blockchain for each relay. + // TODO_TECHDEBT(#543): Remove once the query clients start handling caching and invalidation. + sharedParams *sharedtypes.Params + service *sharedtypes.Service + serviceRelayDifficulty servicetypes.RelayMiningDifficulty + numSuppliersPerSession uint64 +} + +// ProxyRelayMeter is the offchain Supplier's rate limiter. +// It ensures that no Application is over-serviced by the Supplier per session. +// This is done by maintaining the max amount of stake the supplier can consume +// per session and the amount of stake consumed by mined relays. +// TODO_POST_MAINNET(@red-0ne): Consider making the relay meter a light client, +// since it's already receiving all committed blocks and events. +type ProxyRelayMeter struct { + // sessionToRelayMeterMap is a map of session IDs to their corresponding session relay meter. + // Only known applications (i.e. have sent at least one relay) have their stakes metered. + // This map gets reset every new session in order to meter new applications. + sessionToRelayMeterMap map[string]*sessionRelayMeter + // overServicingAllowanceCoins allows Suppliers to overservice applications. + // This entails providing a free service (i.e. mine for relays), that they will not be paid for onchain. + // This is common by some suppliers to build goodwill and receive a higher offchain quality-of-service rating. + // If negative, allow infinite overservicing. + // TODO_MAINNET(@red-0ne): Expose overServicingAllowanceCoins as a configuration parameter. + overServicingAllowanceCoins cosmostypes.Coin + + // relayMeterMu ensures that relay meter operations are thread-safe. + relayMeterMu sync.Mutex + + // Clients to query onchain data. + applicationQuerier client.ApplicationQueryClient + serviceQuerier client.ServiceQueryClient + sharedQuerier client.SharedQueryClient + sessionQuerier client.SessionQueryClient + eventsQueryClient client.EventsQueryClient + blockQuerier client.BlockClient + + logger polylog.Logger +} + +func NewRelayMeter(deps depinject.Config) (relayer.RelayMeter, error) { + overservicingAllowanceCoins := cosmostypes.NewInt64Coin(volatile.DenomuPOKT, defaultOverServicingAllowanceCoins) + rm := &ProxyRelayMeter{ + sessionToRelayMeterMap: make(map[string]*sessionRelayMeter), + overServicingAllowanceCoins: overservicingAllowanceCoins, + } + + if err := depinject.Inject( + deps, + &rm.sharedQuerier, + &rm.applicationQuerier, + &rm.serviceQuerier, + &rm.blockQuerier, + &rm.eventsQueryClient, + &rm.sessionQuerier, + &rm.logger, + ); err != nil { + return nil, err + } + + return rm, nil +} + +// Start starts the relay meter by observing application staked events and new sessions. +func (rmtr *ProxyRelayMeter) Start(ctx context.Context) error { + // Listen to transaction events to filter application staked events. + // TODO_BETA(@red-0ne): refactor this listener to be shared across all query clients + // and remove the need to listen to events in the relay meter. + eventsObs, err := rmtr.eventsQueryClient.EventsBytes(ctx, "tm.event = 'Tx'") + if err != nil { + return err + } + + // Listen for application staked events and update known application stakes. + // + // Since an applications might upstake (never downstake) during a session, this + // stake increase is guaranteed to be available at settlement. + // Stake updates take effect immediately. + // + // This enables applications to adjust their stake mid-session and increase + // their rate limits without needing to wait for the next session to start. + appStakedEvents := filterTypedEvents[*apptypes.EventApplicationStaked](ctx, eventsObs, nil) + channel.ForEach(ctx, appStakedEvents, rmtr.forEachEventApplicationStakedFn) + + // Listen to new blocks and reset the relay meter application stakes every new session. + committedBlocksSequence := rmtr.blockQuerier.CommittedBlocksSequence(ctx) + channel.ForEach(ctx, committedBlocksSequence, rmtr.forEachNewBlockFn) + + return nil +} + +// AccumulateRelayReward accumulates the relay reward for the given relay request. +// The relay reward is added optimistically, assuming that the relay will be volume / reward +// applicable and the relay meter would remain up to date. +func (rmtr *ProxyRelayMeter) AccumulateRelayReward(ctx context.Context, reqMeta servicetypes.RelayRequestMetadata) error { + // TODO_MAINNET(@adshmh): Locking the relay serving flow to ensure that the relay meter is updated + // might be a bottleneck since ensureRequestAppMetrics is performing multiple + // sequential queries to the Pocket Network node. + // Re-evaluate when caching and invalidation is implemented. + rmtr.relayMeterMu.Lock() + defer rmtr.relayMeterMu.Unlock() + + // Ensure that the served application has a relay meter and update the consumed + // stake amount. + appRelayMeter, err := rmtr.ensureRequestSessionRelayMeter(ctx, reqMeta) + if err != nil { + return err + } + + // Get the cost of the relay based on the service and shared parameters. + relayCostCoin, err := getSingleMinedRelayCostCoin( + appRelayMeter.sharedParams, + appRelayMeter.service, + appRelayMeter.serviceRelayDifficulty, + ) + if err != nil { + return err + } + + // Increase the consumed stake amount by relay cost. + newConsumedCoin := appRelayMeter.consumedCoin.Add(relayCostCoin) + + isAppOverServiced := appRelayMeter.maxCoin.IsLT(newConsumedCoin) + if !isAppOverServiced { + appRelayMeter.consumedCoin = newConsumedCoin + return nil + } + + // Check if the supplier is allowing unlimited over-servicing (i.e. negative value) + allowUnlimitedOverServicing := rmtr.overServicingAllowanceCoins.IsNegative() + + // The application is over-servicing, if unlimited over-servicing is not allowed + // and the newConsumedCoin is greater than the maxCoin + overServicingAllowanceCoins, + // then return a rate limit error. + overServicingCoin := newConsumedCoin.Sub(appRelayMeter.maxCoin) + + // In case Allowance is positive, add it to maxCoin to allow no or limited over-servicing. + if !allowUnlimitedOverServicing { + maxAllowedOverServicing := appRelayMeter.maxCoin.Add(rmtr.overServicingAllowanceCoins) + if maxAllowedOverServicing.IsLT(newConsumedCoin) { + return ErrRelayerProxyRateLimited.Wrapf( + "application has been rate limited, stake needed: %s, has: %s", + newConsumedCoin.String(), + appRelayMeter.maxCoin.String(), + ) + } + } + + appRelayMeter.numOverServicedRelays++ + appRelayMeter.numOverServicedComputeUnits += appRelayMeter.service.ComputeUnitsPerRelay + + // Exponential backoff, only log over-servicing when numOverServicedRelays is a power of 2 + if shouldLogOverServicing(appRelayMeter.numOverServicedRelays) { + rmtr.logger.Warn().Msgf( + "overservicing enabled, application %q over-serviced %s", + appRelayMeter.app.GetAddress(), + overServicingCoin, + ) + } + + return nil +} + +// SetNonApplicableRelayReward updates the relay meter to make the relay reward for +// the given relay request as non-applicable. +// This is used when the relay is not volume / reward applicable but was optimistically +// accounted for in the relay meter. +func (rmtr *ProxyRelayMeter) SetNonApplicableRelayReward(ctx context.Context, reqMeta servicetypes.RelayRequestMetadata) error { + rmtr.relayMeterMu.Lock() + defer rmtr.relayMeterMu.Unlock() + + sessionRelayMeter, ok := rmtr.sessionToRelayMeterMap[reqMeta.GetSessionHeader().GetSessionId()] + if !ok { + return ErrRelayerProxyUnknownSession.Wrap("session relay meter not found") + } + + // Get the cost of the relay based on the service and shared parameters. + relayCost, err := getSingleMinedRelayCostCoin( + sessionRelayMeter.sharedParams, + sessionRelayMeter.service, + sessionRelayMeter.serviceRelayDifficulty, + ) + if err != nil { + return ErrRelayerProxyUnclaimRelayPrice.Wrapf("%s", err) + } + + // Decrease the consumed stake amount by relay cost. + newConsumedAmount := sessionRelayMeter.consumedCoin.Sub(relayCost) + + sessionRelayMeter.consumedCoin = newConsumedAmount + return nil +} + +// forEachNewBlockFn is a callback function that is called every time a new block is committed. +// It resets the relay meter's application stakes every new session so that new +// application stakes can be metered. +func (rmtr *ProxyRelayMeter) forEachNewBlockFn(ctx context.Context, block client.Block) { + rmtr.relayMeterMu.Lock() + defer rmtr.relayMeterMu.Unlock() + + sharedParams, err := rmtr.sharedQuerier.GetParams(ctx) + if err != nil { + return + } + + // Delete the relay meters that correspond to settled sessions. + for _, sessionRelayMeter := range rmtr.sessionToRelayMeterMap { + sessionEndHeight := sessionRelayMeter.sessionHeader.GetSessionEndBlockHeight() + sessionClaimOpenHeight := sessionEndHeight + int64(sharedParams.GetClaimWindowOpenOffsetBlocks()) + + if block.Height() >= sessionClaimOpenHeight { + // The session started its claim phase and the corresponding session relay meter + // is no longer needed. + delete(rmtr.sessionToRelayMeterMap, sessionRelayMeter.sessionHeader.GetSessionId()) + } + } +} + +// forEachEventApplicationStakedFn is a callback function that is called every time +// an application staked event is observed. It updates the relay meter known applications. +func (rmtr *ProxyRelayMeter) forEachEventApplicationStakedFn(ctx context.Context, event *apptypes.EventApplicationStaked) { + rmtr.relayMeterMu.Lock() + defer rmtr.relayMeterMu.Unlock() + + app := event.GetApplication() + + // Since lean clients are supported, multiple suppliers might share the same RelayMiner. + // Loop over all the suppliers that have metered the application and update their + // max amount of stake they can consume. + for _, sessionRelayMeter := range rmtr.sessionToRelayMeterMap { + if sessionRelayMeter.app.Address != app.Address { + continue + } + sessionRelayMeter.app.Stake = app.GetStake() + appStakeShare := getAppStakePortionPayableToSessionSupplier( + app.GetStake(), + sessionRelayMeter.sharedParams, + sessionRelayMeter.numSuppliersPerSession, + ) + sessionRelayMeter.maxCoin = appStakeShare + } +} + +// ensureRequestSessionRelayMeter ensures that the relay miner has a relay meter +// ready for monitoring the requests's application's consumption. +func (rmtr *ProxyRelayMeter) ensureRequestSessionRelayMeter(ctx context.Context, reqMeta servicetypes.RelayRequestMetadata) (*sessionRelayMeter, error) { + appAddress := reqMeta.GetSessionHeader().GetApplicationAddress() + sessionId := reqMeta.GetSessionHeader().GetSessionId() + + relayMeter, ok := rmtr.sessionToRelayMeterMap[sessionId] + // If the application is seen for the first time in this session, calculate the + // max amount of stake the application can consume. + if !ok { + var app apptypes.Application + app, err := rmtr.applicationQuerier.GetApplication(ctx, appAddress) + if err != nil { + return nil, err + } + + // In order to prevent over-servicing, the protocol must split the application's stake + // among all the suppliers that are serving it. + if len(app.ServiceConfigs) != 1 { + return nil, ErrRelayerProxyInvalidSession.Wrapf( + "application %q has %d service configs, expected 1", + appAddress, + len(app.ServiceConfigs), + ) + } + + sharedParams, err := rmtr.sharedQuerier.GetParams(ctx) + if err != nil { + return nil, err + } + + service, err := rmtr.serviceQuerier.GetService(ctx, reqMeta.SessionHeader.ServiceId) + if err != nil { + return nil, err + } + + serviceRelayDifficulty, err := rmtr.serviceQuerier.GetServiceRelayDifficulty(ctx, service.Id) + if err != nil { + return nil, err + } + + sessionParams, err := rmtr.sessionQuerier.GetParams(ctx) + if err != nil { + return nil, err + } + + // calculate the max amount of stake the application can consume in the current session. + supplierAppStake := getAppStakePortionPayableToSessionSupplier( + app.GetStake(), + sharedParams, + sessionParams.GetNumSuppliersPerSession(), + ) + relayMeter = &sessionRelayMeter{ + app: app, + consumedCoin: cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 0), + maxCoin: supplierAppStake, + sessionHeader: reqMeta.SessionHeader, + sharedParams: sharedParams, + service: &service, + serviceRelayDifficulty: serviceRelayDifficulty, + numSuppliersPerSession: sessionParams.GetNumSuppliersPerSession(), + } + + rmtr.sessionToRelayMeterMap[sessionId] = relayMeter + } + + return relayMeter, nil +} + +// filterTypedEvents filters the provided events bytes for the typed event T. +// T is then filtered by the provided filter function. +func filterTypedEvents[T proto.Message]( + ctx context.Context, + eventBzObs client.EventsBytesObservable, + filterFn func(T) bool, +) observable.Observable[T] { + eventObs, eventCh := channel.NewObservable[T]() + channel.ForEach(ctx, eventBzObs, func(ctx context.Context, maybeTxBz either.Bytes) { + if maybeTxBz.IsError() { + return + } + txBz, _ := maybeTxBz.ValueOrError() + + // Try to deserialize the provided bytes into an abci.TxResult. + txResult, err := tx.UnmarshalTxResult(txBz) + if err != nil { + return + } + + for _, event := range txResult.Result.Events { + eventApplicationStakedType := cosmostypes.MsgTypeURL(*new(T)) + if strings.Trim(event.GetType(), "/") != strings.Trim(eventApplicationStakedType, "/") { + continue + } + + typedEvent, err := cosmostypes.ParseTypedEvent(event) + if err != nil { + return + } + + castedEvent, ok := typedEvent.(T) + if !ok { + return + } + + // Apply the filter function to the typed event. + if filterFn == nil || filterFn(castedEvent) { + eventCh <- castedEvent + return + } + } + }) + + return eventObs +} + +// getSingleMinedRelayCostCoin returns the cost of a relay based on the shared parameters and the service. +// relayCost = Compute Units Per Relay (CUPR) * Compute Units To Token Multiplier (CUTTM) * relayDifficultyMultiplier +func getSingleMinedRelayCostCoin( + sharedParams *sharedtypes.Params, + service *sharedtypes.Service, + relayMiningDifficulty servicetypes.RelayMiningDifficulty, +) (cosmostypes.Coin, error) { + // Get the difficulty multiplier based on the relay mining difficulty. + difficultyTargetHash := relayMiningDifficulty.GetTargetHash() + difficultyMultiplier := protocol.GetRelayDifficultyMultiplier(difficultyTargetHash) + + // Get the estimated cost of the relay if it gets mined. + relayCostAmt := service.ComputeUnitsPerRelay * sharedParams.GetComputeUnitsToTokensMultiplier() + relayCostRat := big.NewRat(int64(relayCostAmt), 1) + estimatedRelayCostRat := big.NewRat(0, 1).Mul(relayCostRat, difficultyMultiplier) + estimatedRelayCost := big.NewInt(0).Quo(estimatedRelayCostRat.Num(), estimatedRelayCostRat.Denom()) + + estimatedRelayCostCoin := cosmostypes.NewCoin(volatile.DenomuPOKT, math.NewIntFromBigInt(estimatedRelayCost)) + + return estimatedRelayCostCoin, nil +} + +// getAppStakePortionPayableToSessionSupplier returns the portion of the application +// stake that can be consumed per supplier per session. +func getAppStakePortionPayableToSessionSupplier( + stake *cosmostypes.Coin, + sharedParams *sharedtypes.Params, + numSuppliersPerSession uint64, +) cosmostypes.Coin { + appStakePerSupplier := stake.Amount.Quo(math.NewInt(int64(numSuppliersPerSession))) + + // Calculate the number of pending sessions that might consume the application's stake. + numBlocksPerSession := int64(sharedParams.GetNumBlocksPerSession()) + numBlocksUntilProofWindowCloses := sharedtypes.GetSessionEndToProofWindowCloseBlocks(sharedParams) + pendingSessions := (numBlocksUntilProofWindowCloses + numBlocksPerSession - 1) / numBlocksPerSession + + appStakePerSessionSupplier := appStakePerSupplier.Quo(math.NewInt(pendingSessions)) + appStakePerSessionSupplierCoin := cosmostypes.NewCoin(volatile.DenomuPOKT, appStakePerSessionSupplier) + + return appStakePerSessionSupplierCoin +} + +// shouldLogOverServicing returns true if the number of occurrences is a power of 2. +// This is used to log the over-servicing warning with an exponential backoff. +func shouldLogOverServicing(occurrence uint64) bool { + return (occurrence & (occurrence - 1)) == 0 +} diff --git a/pkg/relayer/proxy/server_builder.go b/pkg/relayer/proxy/server_builder.go index b59b1d490..e386aa68d 100644 --- a/pkg/relayer/proxy/server_builder.go +++ b/pkg/relayer/proxy/server_builder.go @@ -128,6 +128,7 @@ func (rp *relayerProxy) initializeProxyServers() (proxyServerMap map[string]rela serverConfig, rp.servedRelaysPublishCh, rp, + rp.relayMeter, ) default: return nil, ErrRelayerProxyUnsupportedTransportType diff --git a/pkg/relayer/proxy/synchronous.go b/pkg/relayer/proxy/synchronous.go index df3bb8e35..66cde7e6d 100644 --- a/pkg/relayer/proxy/synchronous.go +++ b/pkg/relayer/proxy/synchronous.go @@ -47,6 +47,10 @@ type synchronousRPCServer struct { // servedRelaysProducer is a channel that emits the relays that have been served, allowing // the servedRelays observable to fan-out notifications to its subscribers. servedRelaysProducer chan<- *types.Relay + + // relayMeter is the relay meter that the RelayServer uses to meter the relays and claim the relay price. + // It is used to ensure that the relays are metered and priced correctly. + relayMeter relayer.RelayMeter } // NewSynchronousServer creates a new HTTP server that listens for incoming @@ -61,6 +65,7 @@ func NewSynchronousServer( serverConfig *config.RelayMinerServerConfig, servedRelaysProducer chan<- *types.Relay, proxy relayer.RelayerProxy, + relayMeter relayer.RelayMeter, ) relayer.RelayServer { return &synchronousRPCServer{ logger: logger, @@ -68,6 +73,7 @@ func NewSynchronousServer( relayerProxy: proxy, servedRelaysProducer: servedRelaysProducer, serverConfig: serverConfig, + relayMeter: relayMeter, } } @@ -240,6 +246,14 @@ func (sync *synchronousRPCServer) serveHTTP( return nil, err } + // Optimistically accumulate the relay reward before actually serving the relay. + // The relay price will be deducted from the application's stake before the relay is served. + // If the relay comes out to be not reward / volume applicable, the miner will refund the + // claimed price back to the application. + if err := sync.relayMeter.AccumulateRelayReward(ctx, relayRequest.Meta); err != nil { + return nil, err + } + // Deserialize the relay request payload to get the upstream HTTP request. poktHTTPRequest, err := sdktypes.DeserializeHTTPRequest(relayRequest.Payload) if err != nil { diff --git a/pkg/relayer/session/session_test.go b/pkg/relayer/session/session_test.go index f00f6d58b..5b5757040 100644 --- a/pkg/relayer/session/session_test.go +++ b/pkg/relayer/session/session_test.go @@ -44,7 +44,7 @@ func TestRelayerSessionsManager_ColdStartRelayMinerWithUnclaimedRelays(t *testin // along with its dependencies before starting it. // It takes in the proofParams to configure the proof requirements and the proofCount // to assert the number of proofs to be requested. -// TODO_BETA(@red-0ne): Add a test case which verifies that the service's compute units per relay is used as +// TODO_MAINNET(@red-0ne): Add a test case which verifies that the service's compute units per relay is used as // the weight of a relay when updating a session's SMT. func requireProofCountEqualsExpectedValueFromProofParams(t *testing.T, proofParams prooftypes.Params, proofCount int) { var ( diff --git a/pkg/relayer/session/sessiontree.go b/pkg/relayer/session/sessiontree.go index 78641c9d5..bf83cf0ad 100644 --- a/pkg/relayer/session/sessiontree.go +++ b/pkg/relayer/session/sessiontree.go @@ -21,13 +21,6 @@ import ( var _ relayer.SessionTree = (*sessionTree)(nil) // sessionTree is an implementation of the SessionTree interface. -// TODO_BETA(@red-0ne): Per the Relay Mining paper, we need to optimistically store -// the number of requests that an application can pay for. This needs to be tracked -// based on the app's stake in the beginning of a session and the number of nodes -// per session. An operator should be able to specify "overservicing_compute_units_limit" -// whereby an upper bound on how much it can overservice an application is set. The -// default value for this should be -1, implying "unlimited". -// Ref discussion: https://github.com/pokt-network/poktroll/pull/755#discussion_r1737287860 type sessionTree struct { logger polylog.Logger @@ -75,15 +68,6 @@ type sessionTree struct { // NewSessionTree creates a new sessionTree from a Session and a storePrefix. It also takes a function // removeFromRelayerSessions that removes the sessionTree from the RelayerSessionsManager. // It returns an error if the KVStore fails to be created. -// -// TODO_BETA(@red-0ne): When starting a new session, check what the MaxClaimableAmount -// (in uPOKT) by the Supplier as a function of -// (app_stake, compute_units_per_relay_for_service, global_compute_units_to_token_multiplier). -// TODO_CONFIG_NOTE: Whether or not the RelayMiner stop handling requests when the max is reached should be -// configurable by the operator. -// TODO_ERROR_NOTE: If overservicing is set to false, create a new error that the relay is rejected -// specifically because the supplier has reached the max claimable amount, so the caller should relay -// the request to another supplier. func NewSessionTree( sessionHeader *sessiontypes.SessionHeader, supplierOperatorAddress *cosmostypes.AccAddress, diff --git a/proto/poktroll/application/types.proto b/proto/poktroll/application/types.proto index c4c0625cb..951359be2 100644 --- a/proto/poktroll/application/types.proto +++ b/proto/poktroll/application/types.proto @@ -25,7 +25,7 @@ message Application { // - https://github.com/pokt-network/poktroll/pull/750#discussion_r1735025033 // - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7 repeated poktroll.shared.ApplicationServiceConfig service_configs = 3; // 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. repeated string delegatee_gateway_addresses = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.nullable) = false]; // 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/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/service/relay_mining_difficulty.proto b/proto/poktroll/service/relay_mining_difficulty.proto index aaade441a..5c669c4f0 100644 --- a/proto/poktroll/service/relay_mining_difficulty.proto +++ b/proto/poktroll/service/relay_mining_difficulty.proto @@ -27,7 +27,7 @@ message RelayMiningDifficulty { // 0b0000111... (until 32 bytes are filled up). bytes target_hash = 4; - // TODO_BETA(@Olshansk): Add a `hash_algorithm` field either in this + // TODO_MAINNET(@bryanchriswhite): Add a `hash_algorithm` field either in this // structure or elsewhere so we can support changing it over time. There should // be one source of truth, somewhere on chain, to stay in sync with the SMT // configuration. diff --git a/proto/poktroll/service/tx.proto b/proto/poktroll/service/tx.proto index cb8974856..44bc0c988 100644 --- a/proto/poktroll/service/tx.proto +++ b/proto/poktroll/service/tx.proto @@ -66,7 +66,6 @@ message MsgUpdateParamResponse { // 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. message MsgAddService { option (cosmos.msg.v1.signer) = "owner_address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the service owner. 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/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/proto/poktroll/shared/service.proto b/proto/poktroll/shared/service.proto index 4f8a4cfbf..33d8ca1b7 100644 --- a/proto/poktroll/shared/service.proto +++ b/proto/poktroll/shared/service.proto @@ -15,7 +15,7 @@ message Service { // For example, what if we want to request a session for a certain service but with some additional configs that identify it? string id = 1; // 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. string name = 2; // (Optional) Semantic human readable name for the service // The cost of a single relay for this service in terms of compute units. diff --git a/proto/poktroll/tokenomics/params.proto b/proto/poktroll/tokenomics/params.proto index b36c48403..62971780f 100644 --- a/proto/poktroll/tokenomics/params.proto +++ b/proto/poktroll/tokenomics/params.proto @@ -12,6 +12,22 @@ message Params { option (amino.name) = "poktroll/x/tokenomics/Params"; option (gogoproto.equal) = true; + // mint_allocation_dao is the percentage of the minted tokens which are sent + // to the DAO reward address during claim settlement. + double mint_allocation_dao = 1 [(gogoproto.jsontag) = "mint_allocation_dao", (gogoproto.moretags) = "yaml:\"mint_allocation_dao\""]; + // mint_allocation_proposer is the percentage of the minted tokens which are sent + // to the block proposer account address during claim settlement. + double mint_allocation_proposer = 2 [(gogoproto.jsontag) = "mint_allocation_proposer", (gogoproto.moretags) = "yaml:\"mint_allocation_proposer\""]; + // mint_allocation_supplier is the percentage of the minted tokens which are sent + // to the block supplier account address during claim settlement. + double mint_allocation_supplier = 3 [(gogoproto.jsontag) = "mint_allocation_supplier", (gogoproto.moretags) = "yaml:\"mint_allocation_supplier\""]; + // mint_allocation_source_owner is the percentage of the minted tokens which are sent + // to the service source owner account address during claim settlement. + double mint_allocation_source_owner = 4 [(gogoproto.jsontag) = "mint_allocation_source_owner", (gogoproto.moretags) = "yaml:\"mint_allocation_source_owner\""]; + // mint_allocation_application is the percentage of the minted tokens which are sent + // to the application account address during claim settlement. + double mint_allocation_application = 5 [(gogoproto.jsontag) = "mint_allocation_application", (gogoproto.moretags) = "yaml:\"mint_allocation_application\""]; + // IMPORTANT: Make sure to update all related files if you're modifying or adding a new parameter. // Try the following grep to find all related places: `grep -r compute_units_to_tokens_multiplier` // TODO_IMPROVE: Look into an opportunity to use an enum to avoid using strings throughout the codebase. diff --git a/proto/poktroll/tokenomics/tx.proto b/proto/poktroll/tokenomics/tx.proto index c7185b48e..a9ebd766a 100644 --- a/proto/poktroll/tokenomics/tx.proto +++ b/proto/poktroll/tokenomics/tx.proto @@ -53,9 +53,7 @@ message MsgUpdateParam { // specified in the `Params` message in `proof/params.proto.` string name = 2; oneof as_type { - string as_string = 3 [(gogoproto.jsontag) = "as_string"]; - int64 as_int64 = 6 [(gogoproto.jsontag) = "as_int64"]; - bytes as_bytes = 7 [(gogoproto.jsontag) = "as_bytes"]; + double as_float = 3 [(gogoproto.jsontag) = "as_float"]; } } diff --git a/tests/integration/params/update_param_test.go b/tests/integration/params/update_param_test.go index 3110ddcf2..064ae7239 100644 --- a/tests/integration/params/update_param_test.go +++ b/tests/integration/params/update_param_test.go @@ -51,9 +51,14 @@ func (s *msgUpdateParamTestSuite) TestUnauthorizedMsgUpdateParamFails() { // to that field's value. validParamsValue := reflect.ValueOf(moduleCfg.ValidParams) for fieldIdx := 0; fieldIdx < validParamsValue.NumField(); fieldIdx++ { - fieldValue := validParamsValue.Field(fieldIdx) + validParamsFieldValue := validParamsValue.Field(fieldIdx) fieldName := validParamsValue.Type().Field(fieldIdx).Name + // Skip fields which in the excludedParams map. + if _, ok := suites.ExcludedParams[fieldName]; ok { + continue + } + testName := fmt.Sprintf("%s_%s", moduleName, fieldName) s.T().Run(testName, func(t *testing.T) { // Reset the app state in order to assert that each module @@ -66,7 +71,7 @@ func (s *msgUpdateParamTestSuite) TestUnauthorizedMsgUpdateParamFails() { updateResBz, err := s.RunUpdateParamAsSigner(t, moduleName, fieldName, - fieldValue.Interface(), + validParamsFieldValue.Interface(), s.unauthorizedAddr, ) require.ErrorContains(t, err, authz.ErrNoAuthorizationFound.Error()) @@ -88,6 +93,11 @@ func (s *msgUpdateParamTestSuite) TestAuthorizedMsgUpdateParamSucceeds() { fieldExpectedValue := validParamsValue.Field(fieldIdx) fieldName := validParamsValue.Type().Field(fieldIdx).Name + // Skip fields which in the excludedParams map. + if _, ok := suites.ExcludedParams[fieldName]; ok { + continue + } + testName := fmt.Sprintf("%s_%s", moduleName, fieldName) s.T().Run(testName, func(t *testing.T) { // Reset the app state in order to assert that each module 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/testutil/integration/suites/param_configs.go b/testutil/integration/suites/param_configs.go index 3f11ac943..dd8c548da 100644 --- a/testutil/integration/suites/param_configs.go +++ b/testutil/integration/suites/param_configs.go @@ -23,12 +23,22 @@ type ParamType = string const ( ParamTypeInt64 ParamType = "int64" ParamTypeUint64 ParamType = "uint64" - ParamTypeFloat32 ParamType = "float32" + ParamTypeFloat64 ParamType = "float64" ParamTypeString ParamType = "string" ParamTypeBytes ParamType = "uint8" ParamTypeCoin ParamType = "Coin" ) +// TODO_UPNEXT(@bryanchriswhite): Promote mint_allocation_XXX params to +// a new mint_allocation message type. This map will no longer be needed +var ExcludedParams = map[string]struct{}{ + "MintAllocationDao": {}, + "MintAllocationProposer": {}, + "MintAllocationSupplier": {}, + "MintAllocationSourceOwner": {}, + "MintAllocationApplication": {}, +} + // ModuleParamConfig holds type information about a module's parameters update // message(s) along with default and valid non-default values and a query constructor // function for the module. It is used by ParamsSuite to construct and send @@ -104,10 +114,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, } @@ -207,7 +224,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(), @@ -218,10 +235,21 @@ var ( ParamsMsgs: ModuleParamsMessages{ MsgUpdateParams: tokenomicstypes.MsgUpdateParams{}, MsgUpdateParamsResponse: tokenomicstypes.MsgUpdateParamsResponse{}, + MsgUpdateParam: tokenomicstypes.MsgUpdateParam{}, + MsgUpdateParamResponse: tokenomicstypes.MsgUpdateParamResponse{}, QueryParamsRequest: tokenomicstypes.QueryParamsRequest{}, QueryParamsResponse: tokenomicstypes.QueryParamsResponse{}, }, - ValidParams: tokenomicstypes.Params{}, + ValidParams: tokenomicstypes.Params{ + MintAllocationDao: tokenomicstypes.DefaultMintAllocationDao, + MintAllocationProposer: tokenomicstypes.DefaultMintAllocationProposer, + MintAllocationSupplier: tokenomicstypes.DefaultMintAllocationSupplier, + MintAllocationSourceOwner: tokenomicstypes.DefaultMintAllocationSourceOwner, + MintAllocationApplication: tokenomicstypes.DefaultMintAllocationApplication, + }, + ParamTypes: map[ParamType]any{ + 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 7da33f997..af4bc1852 100644 --- a/testutil/integration/suites/update_params.go +++ b/testutil/integration/suites/update_params.go @@ -248,7 +248,7 @@ 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 ParamTypeString: msgAsTypeValue.Elem().FieldByName("AsString").Set(paramReflectValue) diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index cb4e93d9a..7520f5a73 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -235,6 +235,10 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) ( // Mock the session keeper mockSessionKeeper := mocks.NewMockSessionKeeper(ctrl) + mockSessionKeeper.EXPECT(). + GetParams(gomock.Any()). + Return(sessiontypes.DefaultParams()). + AnyTimes() // Mock the service keeper mockServiceKeeper := mocks.NewMockServiceKeeper(ctrl) diff --git a/tools/installer/full-node.sh b/tools/installer/full-node.sh index 6faca639b..0804bc278 100644 --- a/tools/installer/full-node.sh +++ b/tools/installer/full-node.sh @@ -35,7 +35,7 @@ get_user_input() { CHAIN_ID=${CHAIN_ID:-"poktroll"} # Fetch seeds from the provided URL - SEEDS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/poktrolld/testnet-validated.seeds" + SEEDS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/alpha/testnet-validated.seeds" SEEDS=$(curl -s "$SEEDS_URL") if [ -z "$SEEDS" ]; then print_color $RED "Failed to fetch seeds from $SEEDS_URL. Please check your internet connection and try again." @@ -94,7 +94,7 @@ setup_env_vars() { echo "export DAEMON_HOME=\$HOME/.poktroll" >> \$HOME/.profile echo "export DAEMON_RESTART_AFTER_UPGRADE=true" >> \$HOME/.profile echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=true" >> \$HOME/.profile - echo "export UNSAFE_SKIP_BACKUP=true" >> \$HOME/.profile + echo "export UNSAFE_SKIP_BACKUP=false" >> \$HOME/.profile source \$HOME/.profile EOF print_color $GREEN "Environment variables set up successfully." @@ -138,12 +138,16 @@ setup_poktrolld() { exit 1 fi - # Use the direct download link for the latest release - LATEST_RELEASE_URL="https://github.com/pokt-network/poktroll/releases/latest/download/poktroll_linux_${ARCH}.tar.gz" + # Get the version genesis started from. We can't just use `latest` as the new binary won't sync from genesis. + # We need to start syncing from scratch using the version that was used when the network started. + POKTROLLD_VERSION=$(curl -s https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/alpha/testnet-validated.init-version) + + # Use the direct download link for the correct release + RELEASE_URL="https://github.com/pokt-network/poktroll/releases/download/${POKTROLLD_VERSION}/poktroll_linux_${ARCH}.tar.gz" sudo -u "$POKTROLL_USER" bash << EOF mkdir -p \$HOME/.poktroll/cosmovisor/genesis/bin - curl -L "$LATEST_RELEASE_URL" | tar -zxvf - -C \$HOME/.poktroll/cosmovisor/genesis/bin + curl -L "$RELEASE_URL" | tar -zxvf - -C \$HOME/.poktroll/cosmovisor/genesis/bin chmod +x \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld ln -sf \$HOME/.poktroll/cosmovisor/genesis/bin/poktrolld \$HOME/bin/poktrolld source \$HOME/.profile @@ -156,7 +160,7 @@ configure_poktrolld() { print_color $YELLOW "Configuring Poktrolld..." # Ask for confirmation to download the genesis file - GENESIS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/poktrolld/testnet-validated.json" + GENESIS_URL="https://raw.githubusercontent.com/pokt-network/pocket-network-genesis/master/shannon/alpha/testnet-validated.json" print_color $YELLOW "The script will download the genesis file from:" print_color $YELLOW "$GENESIS_URL" read -p "Are you OK with downloading and using this genesis file? (y/N): " confirm_genesis 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/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/tools/scripts/params/tokenomics_all.json b/tools/scripts/params/tokenomics_all.json new file mode 100644 index 000000000..1b27a34c6 --- /dev/null +++ b/tools/scripts/params/tokenomics_all.json @@ -0,0 +1,17 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.tokenomics.MsgUpdateParams", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "params": { + "mint_allocation_dao": 0.1, + "mint_allocation_proposer": 0.05, + "mint_allocation_supplier": 0.7, + "mint_allocation_source_owner": 0.15, + "mint_allocation_application": 0.0 + } + } + ] + } +} \ No newline at end of file diff --git a/tools/scripts/params/tokenomics_mint_allocation_application.json b/tools/scripts/params/tokenomics_mint_allocation_application.json new file mode 100644 index 000000000..5f94c64de --- /dev/null +++ b/tools/scripts/params/tokenomics_mint_allocation_application.json @@ -0,0 +1,12 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.tokenomics.MsgUpdateParam", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "name": "mint_allocation_application", + "as_double": 0.0 + } + ] + } +} diff --git a/tools/scripts/params/tokenomics_mint_allocation_dao.json b/tools/scripts/params/tokenomics_mint_allocation_dao.json new file mode 100644 index 000000000..0cbd04e5c --- /dev/null +++ b/tools/scripts/params/tokenomics_mint_allocation_dao.json @@ -0,0 +1,12 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.tokenomics.MsgUpdateParam", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "name": "mint_allocation_dao", + "as_float": 0.1 + } + ] + } +} diff --git a/tools/scripts/params/tokenomics_mint_allocation_proposer.json b/tools/scripts/params/tokenomics_mint_allocation_proposer.json new file mode 100644 index 000000000..f068abe2f --- /dev/null +++ b/tools/scripts/params/tokenomics_mint_allocation_proposer.json @@ -0,0 +1,12 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.tokenomics.MsgUpdateParam", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "name": "mint_allocation_proposer", + "as_float": 0.05 + } + ] + } +} diff --git a/tools/scripts/params/tokenomics_mint_allocation_source_owner.json b/tools/scripts/params/tokenomics_mint_allocation_source_owner.json new file mode 100644 index 000000000..6b04849f9 --- /dev/null +++ b/tools/scripts/params/tokenomics_mint_allocation_source_owner.json @@ -0,0 +1,12 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.tokenomics.MsgUpdateParam", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "name": "mint_allocation_source_owner", + "as_float": 0.15 + } + ] + } +} diff --git a/tools/scripts/params/tokenomics_mint_allocation_supplier.json b/tools/scripts/params/tokenomics_mint_allocation_supplier.json new file mode 100644 index 000000000..30d9c3dd9 --- /dev/null +++ b/tools/scripts/params/tokenomics_mint_allocation_supplier.json @@ -0,0 +1,12 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.tokenomics.MsgUpdateParam", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "name": "mint_allocation_supplier", + "as_float": 0.7 + } + ] + } +} 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/proof/keeper/msg_server_submit_proof.go b/x/proof/keeper/msg_server_submit_proof.go index c19fbd2e6..d7c526b23 100644 --- a/x/proof/keeper/msg_server_submit_proof.go +++ b/x/proof/keeper/msg_server_submit_proof.go @@ -233,8 +233,7 @@ func (k Keeper) ProofRequirementForClaim(ctx context.Context, claim *types.Claim } // Require a proof if the claim's compute units meets or exceeds the threshold. - // TODO_BETA(@red-0ne): Should the threshold be dependant on the stake as well - // so we slash proportional to the compute units? + // TODO_BETA(@olshansk): Should the threshold be dependant on the stake as well so we slash proportional to the compute units? // TODO_BETA(@red-0ne): It might make sense to include whether there was a proof // submission error downstream from here. This would require a more comprehensive metrics API. if claimeduPOKT.Amount.GTE(proofParams.GetProofRequirementThreshold().Amount) { @@ -301,7 +300,7 @@ func (k Keeper) getProofRequirementSeedBlockHash( proofWindowOpenHeight := sharedtypes.GetProofWindowOpenHeight(sharedParams, sessionEndHeight) proofWindowOpenBlockHash := k.sessionKeeper.GetBlockHash(ctx, proofWindowOpenHeight) - // TODO_BETA(@red-0ne): Update the method header of this function to accept (sharedParams, Claim, BlockHash). + // TODO_TECHDEBT(@red-0ne): Update the method header of this function to accept (sharedParams, Claim, BlockHash). // After doing so, please review all calling sites and simplify them accordingly. earliestSupplierProofCommitHeight := sharedtypes.GetEarliestSupplierProofCommitHeight( sharedParams, 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/keeper/proof_validation.go b/x/proof/keeper/proof_validation.go index 778d66d8c..850c97f5b 100644 --- a/x/proof/keeper/proof_validation.go +++ b/x/proof/keeper/proof_validation.go @@ -251,10 +251,6 @@ func (k Keeper) validateClosestPath( // be received before proceeding. proofPathSeedBlockHash := k.sessionKeeper.GetBlockHash(ctx, earliestSupplierProofCommitHeight-1) - // TODO_BETA(@red-0ne): Investigate "proof for the path provided does not match one expected by the on-chain protocol" - // error that may occur due to block height differing from the off-chain part. - k.logger.Info("E2E_DEBUG: height for block hash when verifying the proof", earliestSupplierProofCommitHeight, sessionHeader.GetSessionId()) - expectedProofPath := protocol.GetPathForProof(proofPathSeedBlockHash, sessionHeader.GetSessionId()) if !bytes.Equal(proof.Path, expectedProofPath) { return types.ErrProofInvalidProof.Wrapf( 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/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/session/keeper/msg_server_update_param.go b/x/session/keeper/msg_server_update_param.go new file mode 100644 index 000000000..7804372d6 --- /dev/null +++ b/x/session/keeper/msg_server_update_param.go @@ -0,0 +1,67 @@ +package keeper + +import ( + "context" + "fmt" + + "google.golang.org/grpc/status" + + sessiontypes "github.com/pokt-network/poktroll/x/session/types" + suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" + + "google.golang.org/grpc/codes" +) + +// 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()) + } + + updatedParams := k.GetParams(ctx) + + 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/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go index 8dae1a7a5..10d2c11e9 100644 --- a/x/session/keeper/session_hydrator.go +++ b/x/session/keeper/session_hydrator.go @@ -19,11 +19,6 @@ import ( var SHA3HashLen = crypto.SHA3_256.Size() -// TODO_BETA(@bryanchriswhite): Make this a governance parameter -const ( - NumSupplierPerSession = 15 -) - const ( sessionIDComponentDelimiter = "." ) @@ -175,6 +170,7 @@ func (k Keeper) hydrateSessionApplication(ctx context.Context, sh *sessionHydrat func (k Keeper) hydrateSessionSuppliers(ctx context.Context, sh *sessionHydrator) error { logger := k.Logger().With("method", "hydrateSessionSuppliers") + numSuppliersPerSession := int(k.GetParams(ctx).NumSuppliersPerSession) suppliers := k.supplierKeeper.GetAllSuppliers(ctx) candidateSuppliers := make([]*sharedtypes.Supplier, 0) @@ -197,7 +193,7 @@ func (k Keeper) hydrateSessionSuppliers(ctx context.Context, sh *sessionHydrator } } - defer telemetry.SessionSuppliersGauge(len(candidateSuppliers), NumSupplierPerSession, sh.sessionHeader.ServiceId) + defer telemetry.SessionSuppliersGauge(len(candidateSuppliers), numSuppliersPerSession, sh.sessionHeader.ServiceId) if len(candidateSuppliers) == 0 { logger.Error("[ERROR] no suppliers found for session") @@ -208,15 +204,15 @@ func (k Keeper) hydrateSessionSuppliers(ctx context.Context, sh *sessionHydrator ) } - if len(candidateSuppliers) < NumSupplierPerSession { + if len(candidateSuppliers) < numSuppliersPerSession { logger.Debug(fmt.Sprintf( "Number of available suppliers (%d) is less than the maximum number of possible suppliers per session (%d)", len(candidateSuppliers), - NumSupplierPerSession, + numSuppliersPerSession, )) sh.session.Suppliers = candidateSuppliers } else { - sh.session.Suppliers = pseudoRandomSelection(candidateSuppliers, NumSupplierPerSession, sh.sessionIDBz) + sh.session.Suppliers = pseudoRandomSelection(candidateSuppliers, numSuppliersPerSession, sh.sessionIDBz) } return 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/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/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/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 new file mode 100644 index 000000000..ace4d5b71 --- /dev/null +++ b/x/session/types/message_update_param.go @@ -0,0 +1,56 @@ +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 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: 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 { + 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 new file mode 100644 index 000000000..f1d101f90 --- /dev/null +++ b/x/session/types/message_update_param_test.go @@ -0,0 +1,54 @@ +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 { + desc string + msg MsgUpdateParam + expectedErr error + }{ + { + desc: "invalid: authority address invalid", + msg: MsgUpdateParam{ + Authority: "invalid_address", + Name: "", // Doesn't matter for this test + AsType: &MsgUpdateParam_AsUint64{AsUint64: 0}, + }, + expectedErr: sdkerrors.ErrInvalidAddress, + }, { + 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.desc, func(t *testing.T) { + err := tt.msg.ValidateBasic() + 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:]) 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/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. diff --git a/x/shared/types/session.go b/x/shared/types/session.go index ea75a0e3b..355d83c1e 100644 --- a/x/shared/types/session.go +++ b/x/shared/types/session.go @@ -176,3 +176,16 @@ func GetSettlementSessionEndHeight(sharedParams *Params, queryHeight int64) int6 return GetSessionEndToProofWindowCloseBlocks(sharedParams) + GetSessionEndHeight(sharedParams, queryHeight) + 1 } + +// GetNumPendingSessions returns the number of pending sessions (i.e. that have not +// yet been settled). +func GetNumPendingSessions(sharedParams *Params) int64 { + // Get the number of blocks between the end of a session and the block height + // at which the session claim is settled. + numPendingSessionsBlocks := GetSessionEndToProofWindowCloseBlocks(sharedParams) + // Use the number of blocks per session to calculate the number of pending sessions. + numBlocksPerSession := int64(sharedParams.GetNumBlocksPerSession()) + // numBlocksPerSession - 1 is added to round up the integer division so that pending + // sessions are all the sessions that have their end height at least `pendingBlocks` old. + return (numPendingSessionsBlocks + numBlocksPerSession - 1) / numBlocksPerSession +} diff --git a/x/supplier/keeper/msg_server_stake_supplier.go b/x/supplier/keeper/msg_server_stake_supplier.go index a23392fd6..d92a41201 100644 --- a/x/supplier/keeper/msg_server_stake_supplier.go +++ b/x/supplier/keeper/msg_server_stake_supplier.go @@ -15,9 +15,8 @@ import ( ) var ( - // TODO_BETA: Make supplier staking fee a governance parameter - // TODO_BETA(@red-0ne): Update supplier staking documentation to remove the upstaking - // requirement and introduce the staking fee. + // TODO_BETA(@bryanchriswhite): Make supplier staking fee a governance parameter + // TODO_BETA(@red-0ne): Update supplier staking documentation to remove the upstaking requirement and introduce the staking fee. SupplierStakingFee = sdk.NewInt64Coin(volatile.DenomuPOKT, 1) ) @@ -112,7 +111,7 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie supplier.UnstakeSessionEndHeight = sharedtypes.SupplierNotUnstaking } - // TODO_BETA: Remove requirement of MUST ALWAYS stake or upstake (>= 0 delta) + // TODO_BETA(@red-0ne): Remove requirement of MUST ALWAYS stake or upstake (>= 0 delta) // TODO_POST_MAINNET: Should we allow stake decrease down to min stake? if coinsToEscrow.IsNegative() { err = types.ErrSupplierInvalidStake.Wrapf( 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" ) diff --git a/x/tokenomics/keeper/msg_server_update_param.go b/x/tokenomics/keeper/msg_server_update_param.go index 79f0befa2..6ce663fb5 100644 --- a/x/tokenomics/keeper/msg_server_update_param.go +++ b/x/tokenomics/keeper/msg_server_update_param.go @@ -2,32 +2,66 @@ package keeper import ( "context" + "fmt" - "github.com/pokt-network/poktroll/x/tokenomics/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) // UpdateParam updates a single parameter in the tokenomics module and returns // all active parameters. func (k msgServer) UpdateParam( ctx context.Context, - msg *types.MsgUpdateParam, -) (*types.MsgUpdateParamResponse, error) { + msg *tokenomicstypes.MsgUpdateParam, +) (*tokenomicstypes.MsgUpdateParamResponse, error) { + logger := k.logger.With( + "method", "UpdateParam", + "param_name", msg.Name, + ) + if err := msg.ValidateBasic(); err != nil { return nil, err } if k.GetAuthority() != msg.Authority { - return nil, types.ErrTokenomicsInvalidSigner.Wrapf("invalid authority; expected %s, got %s", k.GetAuthority(), msg.Authority) + return nil, tokenomicstypes.ErrTokenomicsInvalidSigner.Wrapf("invalid authority; expected %s, got %s", k.GetAuthority(), msg.Authority) } params := k.GetParams(ctx) + switch msg.Name { + case tokenomicstypes.ParamMintAllocationDao: + case tokenomicstypes.ParamMintAllocationProposer: + case tokenomicstypes.ParamMintAllocationSupplier: + case tokenomicstypes.ParamMintAllocationSourceOwner: + case tokenomicstypes.ParamMintAllocationApplication: + return nil, status.Error( + codes.InvalidArgument, + tokenomicstypes.ErrTokenomicsParamInvalid.Wrapf( + "%s cannot be updated individually as all mint allocation percentages MUST ALWAYS sum to 1", msg.Name, + ).Error(), + ) + default: + return nil, status.Error( + codes.InvalidArgument, + tokenomicstypes.ErrTokenomicsParamInvalid.Wrapf("unsupported param %q", msg.Name).Error(), + ) + } + + if err := params.ValidateBasic(); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + if err := k.SetParams(ctx, params); err != nil { - return nil, err + err = fmt.Errorf("unable to set params: %w", err) + logger.Error(err.Error()) + return nil, status.Error(codes.Internal, err.Error()) } updatedParams := k.GetParams(ctx) - return &types.MsgUpdateParamResponse{ + return &tokenomicstypes.MsgUpdateParamResponse{ Params: &updatedParams, }, nil } diff --git a/x/tokenomics/keeper/msg_server_update_param_test.go b/x/tokenomics/keeper/msg_server_update_param_test.go new file mode 100644 index 000000000..84ee340f6 --- /dev/null +++ b/x/tokenomics/keeper/msg_server_update_param_test.go @@ -0,0 +1,25 @@ +package keeper_test + +import ( + "testing" +) + +func TestMsgUpdateParam_UpdateMintAllocationDaoOnly(t *testing.T) { + t.Skip("since the mint allocation percentages must sum to 1, it is not possible to modify only one of them") +} + +func TestMsgUpdateParam_UpdateMintAllocationProposerOnly(t *testing.T) { + t.Skip("since the mint allocation percentages must sum to 1, it is not possible to modify only one of them") +} + +func TestMsgUpdateParam_UpdateMintAllocationSupplierOnly(t *testing.T) { + t.Skip("since the mint allocation percentages must sum to 1, it is not possible to modify only one of them") +} + +func TestMsgUpdateParam_UpdateMintAllocationSourceOwnerOnly(t *testing.T) { + t.Skip("since the mint allocation percentages must sum to 1, it is not possible to modify only one of them") +} + +func TestMsgUpdateParam_UpdateMintAllocationApplicationOnly(t *testing.T) { + t.Skip("since the mint allocation percentages must sum to 1, it is not possible to modify only one of them") +} diff --git a/x/tokenomics/keeper/msg_update_params_test.go b/x/tokenomics/keeper/msg_update_params_test.go index a112ec5d8..b6518bce3 100644 --- a/x/tokenomics/keeper/msg_update_params_test.go +++ b/x/tokenomics/keeper/msg_update_params_test.go @@ -6,17 +6,17 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/testutil/sample" - "github.com/pokt-network/poktroll/x/tokenomics/types" + tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) func TestMsgUpdateParams(t *testing.T) { tokenomicsKeeper, srv, ctx := setupMsgServer(t) - require.NoError(t, tokenomicsKeeper.SetParams(ctx, types.DefaultParams())) + require.NoError(t, tokenomicsKeeper.SetParams(ctx, tokenomicstypes.DefaultParams())) tests := []struct { desc string - req *types.MsgUpdateParams + req *tokenomicstypes.MsgUpdateParams shouldError bool expectedErrMsg string @@ -24,9 +24,9 @@ func TestMsgUpdateParams(t *testing.T) { { desc: "invalid authority address", - req: &types.MsgUpdateParams{ + req: &tokenomicstypes.MsgUpdateParams{ Authority: "invalid", - Params: types.Params{}, + Params: tokenomicstypes.DefaultParams(), }, shouldError: true, @@ -35,9 +35,9 @@ func TestMsgUpdateParams(t *testing.T) { { desc: "incorrect authority address", - req: &types.MsgUpdateParams{ + req: &tokenomicstypes.MsgUpdateParams{ Authority: sample.AccAddress(), - Params: types.Params{}, + Params: tokenomicstypes.DefaultParams(), }, shouldError: true, @@ -46,9 +46,15 @@ func TestMsgUpdateParams(t *testing.T) { { desc: "successful param update", - req: &types.MsgUpdateParams{ + req: &tokenomicstypes.MsgUpdateParams{ Authority: tokenomicsKeeper.GetAuthority(), - Params: types.Params{}, + Params: tokenomicstypes.Params{ + MintAllocationDao: 0.1, + MintAllocationProposer: 0.1, + MintAllocationSupplier: 0.1, + MintAllocationSourceOwner: 0.1, + MintAllocationApplication: 0.6, + }, }, shouldError: false, diff --git a/x/tokenomics/keeper/params_test.go b/x/tokenomics/keeper/params_test.go new file mode 100644 index 000000000..cdcca60a7 --- /dev/null +++ b/x/tokenomics/keeper/params_test.go @@ -0,0 +1,179 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" +) + +func TestParams_ValidateMintAllocationDao(t *testing.T) { + tests := []struct { + desc string + mintAllocatioDao any + expectedErr error + }{ + { + desc: "invalid type", + mintAllocatioDao: "0", + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrap("invalid parameter type: string"), + }, + { + desc: "invalid MintAllocationDao (<0)", + mintAllocatioDao: -0.1, + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrapf("mint allocation to DAO must be greater than or equal to 0: got %f", -0.1), + }, + { + desc: "valid MintAllocationDao", + mintAllocatioDao: tokenomicstypes.DefaultMintAllocationDao, + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := tokenomicstypes.ValidateMintAllocationDao(test.mintAllocatioDao) + if test.expectedErr != nil { + require.ErrorContains(t, err, test.expectedErr.Error()) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestParams_ValidateMintAllocationProposer(t *testing.T) { + tests := []struct { + desc string + mintAllocatioProposer any + expectedErr error + }{ + { + desc: "invalid type", + mintAllocatioProposer: "0", + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrap("invalid parameter type: string"), + }, + { + desc: "invalid MintAllocationProposer (<0)", + mintAllocatioProposer: -0.1, + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrapf("mint allocation to proposer must be greater than or equal to 0: got %f", -0.1), + }, + { + desc: "valid MintAllocationProposer", + mintAllocatioProposer: tokenomicstypes.DefaultMintAllocationProposer, + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := tokenomicstypes.ValidateMintAllocationProposer(test.mintAllocatioProposer) + if test.expectedErr != nil { + require.ErrorContains(t, err, test.expectedErr.Error()) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestParams_ValidateMintAllocationSupplier(t *testing.T) { + tests := []struct { + desc string + mintAllocatioSupplier any + expectedErr error + }{ + { + desc: "invalid type", + mintAllocatioSupplier: "0", + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrap("invalid parameter type: string"), + }, + { + desc: "invalid MintAllocationSupplier (<0)", + mintAllocatioSupplier: -0.1, + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrapf("mint allocation to supplier must be greater than or equal to 0: got %f", -0.1), + }, + { + desc: "valid MintAllocationSupplier", + mintAllocatioSupplier: tokenomicstypes.DefaultMintAllocationSupplier, + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := tokenomicstypes.ValidateMintAllocationSupplier(test.mintAllocatioSupplier) + if test.expectedErr != nil { + require.ErrorContains(t, err, test.expectedErr.Error()) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestParams_ValidateMintAllocationSourceOwner(t *testing.T) { + tests := []struct { + desc string + mintAllocatioSourceOwner any + expectedErr error + }{ + { + desc: "invalid type", + mintAllocatioSourceOwner: "0", + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrap("invalid parameter type: string"), + }, + { + desc: "invalid MintAllocationSourceOwner (<0)", + mintAllocatioSourceOwner: -0.1, + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrapf("mint allocation to source owner must be greater than or equal to 0: got %f", -0.1), + }, + { + desc: "valid MintAllocationSourceOwner", + mintAllocatioSourceOwner: tokenomicstypes.DefaultMintAllocationSourceOwner, + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := tokenomicstypes.ValidateMintAllocationSourceOwner(test.mintAllocatioSourceOwner) + if test.expectedErr != nil { + require.ErrorContains(t, err, test.expectedErr.Error()) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestParams_ValidateMintAllocationApplication(t *testing.T) { + tests := []struct { + desc string + mintAllocatioApplication any + expectedErr error + }{ + { + desc: "invalid type", + mintAllocatioApplication: "0", + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrap("invalid parameter type: string"), + }, + { + desc: "invalid MintAllocationApplication (<0)", + mintAllocatioApplication: -0.1, + expectedErr: tokenomicstypes.ErrTokenomicsParamInvalid.Wrapf("mint allocation to application must be greater than or equal to 0: got %f", -0.1), + }, + { + desc: "valid MintAllocationApplication", + mintAllocatioApplication: tokenomicstypes.DefaultMintAllocationApplication, + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + err := tokenomicstypes.ValidateMintAllocationApplication(test.mintAllocatioApplication) + if test.expectedErr != nil { + require.ErrorContains(t, err, test.expectedErr.Error()) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/tokenomics/keeper/settle_pending_claims.go b/x/tokenomics/keeper/settle_pending_claims.go index 610ddd60a..551549e11 100644 --- a/x/tokenomics/keeper/settle_pending_claims.go +++ b/x/tokenomics/keeper/settle_pending_claims.go @@ -151,8 +151,8 @@ func (k Keeper) SettlePendingClaims(ctx cosmostypes.Context) ( // If the proof is missing or invalid -> expire it if expirationReason != tokenomicstypes.ClaimExpirationReason_EXPIRATION_REASON_UNSPECIFIED { - // TODO_BETA(@red-0ne): Slash the supplier in proportion - // to their stake. Consider allowing suppliers to RemoveClaim via a new + // TODO_BETA(@red-0ne): Slash the supplier in proportion to their stake. + // TODO_POST_MAINNET: Consider allowing suppliers to RemoveClaim via a new // message in case it was sent by accident // Proof was required but is invalid or not found. @@ -216,6 +216,14 @@ func (k Keeper) SettlePendingClaims(ctx cosmostypes.Context) ( appAddress := claim.GetSessionHeader().GetApplicationAddress() applicationInitialStake := applicationInitialStakeMap[appAddress] + // TODO_MAINNET(@red-0ne): Add tests to ensure that a zero application stake + // is handled correctly. + if applicationInitialStake.IsZero() { + logger.Error(fmt.Sprintf("application %q has a zero initial stake", appAddress)) + + continue + } + // Manage the mint & burn accounting for the claim. if err = k.ProcessTokenLogicModules(ctx, result, applicationInitialStake); err != nil { logger.Error(fmt.Sprintf("error processing token logic modules for claim %q: %v", claim.SessionHeader.SessionId, err)) diff --git a/x/tokenomics/keeper/token_logic_modules.go b/x/tokenomics/keeper/token_logic_modules.go index b7fac1fa2..dbc0c3bdc 100644 --- a/x/tokenomics/keeper/token_logic_modules.go +++ b/x/tokenomics/keeper/token_logic_modules.go @@ -16,7 +16,6 @@ import ( "github.com/pokt-network/poktroll/telemetry" apptypes "github.com/pokt-network/poktroll/x/application/types" servicekeeper "github.com/pokt-network/poktroll/x/service/keeper" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" tlm "github.com/pokt-network/poktroll/x/tokenomics/token_logic_module" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" @@ -176,13 +175,25 @@ func (k Keeper) ProcessTokenLogicModules( // Ensure the claim amount is within the limits set by Relay Mining. // If not, update the settlement amount and emit relevant events. - actualSettlementCoin, err := k.ensureClaimAmountLimits(ctx, logger, &application, &supplier, claimSettlementCoin, applicationInitialStake) + // TODO_MAINNET(@red-0ne): Consider pulling this out of Keeper#ProcessTokenLogicModules + // and ensure claim amount limits are enforced before TLM processing. + actualSettlementCoin, err := k.ensureClaimAmountLimits(ctx, logger, &sharedParams, &application, &supplier, claimSettlementCoin, applicationInitialStake) if err != nil { return err } logger = logger.With("actual_settlement_upokt", actualSettlementCoin) logger.Info(fmt.Sprintf("About to start processing TLMs for (%d) compute units, equal to (%s) claimed", numClaimComputeUnits, actualSettlementCoin)) + // TODO_MAINNET(@red-0ne): Add tests to ensure that a zero settlement coin + // due to integer division rounding is handled correctly. + if actualSettlementCoin.Amount.IsZero() { + logger.Warn(fmt.Sprintf( + "actual settlement coin is zero, skipping TLM processing, application %q stake %s", + application.Address, application.Stake, + )) + return nil + } + // Execute all the token logic modules processors for _, tokenLogicModule := range k.tokenLogicModules { tlmName := tokenLogicModule.GetId().String() @@ -230,9 +241,11 @@ func (k Keeper) ProcessTokenLogicModules( k.applicationKeeper.SetApplication(ctx, application) logger.Info(fmt.Sprintf("updated on-chain application record with address %q", application.Address)) - // TODO_MAINNET: If the application stake has dropped to (near?) zero, should - // we unstake it? Should we use it's balance? Should there be a payee of last resort? - // Make sure to document whatever decision we come to. + // TODO_MAINNET(@bryanchriswhite): If the application stake has dropped to (near?) zero: + // - Unstake it + // - Emit an event + // - Ensure this doesn't happen + // - Document the decision // State mutation: Update the suppliers's on-chain record k.supplierKeeper.SetSupplier(ctx, supplier) @@ -253,6 +266,7 @@ func (k Keeper) ProcessTokenLogicModules( func (k Keeper) ensureClaimAmountLimits( ctx context.Context, logger log.Logger, + sharedParams *sharedtypes.Params, application *apptypes.Application, supplier *sharedtypes.Supplier, claimSettlementCoin cosmostypes.Coin, @@ -263,8 +277,6 @@ func (k Keeper) ensureClaimAmountLimits( ) { logger = logger.With("helper", "ensureClaimAmountLimits") - // TODO_BETA(@red-0ne): Make relay miners use the appStake at the beginning - // of a session to determine the maximum amount they can claim. // Note that this also incorporates MintPerClaimGlobalInflation since applications // are being overcharged by that amount and the funds are sent to the DAO/PNF // before being reimbursed to the application in the future. @@ -277,25 +289,20 @@ func (k Keeper) ensureClaimAmountLimits( minRequiredAppStakeAmt := claimSettlementCoin.Amount.Add(globalInflationAmt) totalClaimedCoin := sdk.NewCoin(volatile.DenomuPOKT, minRequiredAppStakeAmt) - // TODO_BETA(@red-0ne): Introduce a session sliding window to account for potential consumption - // during the current session (i.e. Not the session being settled) such as: - // maxClaimableAmt = (AppStake / (currSessNum - settlingSessNum + 1) / NumSuppliersPerSession) - // In conjunction with single service applications, this would make maxClaimableAmt - // effectively addressing the issue of over-servicing. - // Example: - // - Current session num: 3 - // - Settling session num: 2 - // - Application already requested work for session 3 - // Problem: - // - If the application consumes its entire stake in settlement of session 2 - // - Then over-servicing in session 3 (i.e. No stake left to consume) - // Solution: - // - By dividing the claimable stake by 2 (3 - 2 + 1), settling session 2 assumes that - // the application will consume its maxClaimableAmt the current session (3). - // - Off-chain actors could use this formula during the servicing of session num 3 - // and assume maxClaimableAmt will be settled in session 2. - // - Guarantee no over-servicing at the cost of higher application stake requirements. - maxClaimableAmt := appStake.Amount.Quo(math.NewInt(sessionkeeper.NumSupplierPerSession)) + // get the number of pending sessions that share the application stake at claim time + // This is used to calculate the maximum claimable amount for the supplier within a session. + numPendingSessions := sharedtypes.GetNumPendingSessions(sharedParams) + + // The maximum any single supplier can claim is a fraction of the app's total stake + // divided by the number of suppliers per session. + // Re decentralization - This ensures the app biases towards using all suppliers in a session. + // Re costs - This is an easy way to split the stake evenly. + // TODO_FUTURE: See if there's a way to let the application prefer (the best) + // supplier(s) in a session while maintaining a simple solution to implement this. + numSuppliersPerSession := int64(k.sessionKeeper.GetParams(ctx).NumSuppliersPerSession) + maxClaimableAmt := appStake.Amount. + Quo(math.NewInt(numSuppliersPerSession)). + Quo(math.NewInt(numPendingSessions)) maxClaimSettlementAmt := supplierAppStakeToMaxSettlementAmount(maxClaimableAmt) // Check if the claimable amount is capped by the max claimable amount. diff --git a/x/tokenomics/keeper/token_logic_modules_test.go b/x/tokenomics/keeper/token_logic_modules_test.go index 1f85be7e3..dce5267b3 100644 --- a/x/tokenomics/keeper/token_logic_modules_test.go +++ b/x/tokenomics/keeper/token_logic_modules_test.go @@ -26,7 +26,6 @@ import ( testsession "github.com/pokt-network/poktroll/testutil/session" apptypes "github.com/pokt-network/poktroll/x/application/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" @@ -56,8 +55,9 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { keepers.SetService(ctx, *service) // Ensure the claim is within relay mining bounds + numSuppliersPerSession := int64(keepers.SessionKeeper.GetParams(ctx).NumSuppliersPerSession) numTokensClaimed := int64(numRelays * serviceComputeUnitsPerRelay * globalComputeUnitsToTokensMultiplier) - maxClaimableAmountPerSupplier := appInitialStake.Quo(cosmosmath.NewInt(sessionkeeper.NumSupplierPerSession)) + maxClaimableAmountPerSupplier := appInitialStake.Quo(cosmosmath.NewInt(numSuppliersPerSession)) require.GreaterOrEqual(t, maxClaimableAmountPerSupplier.Int64(), numTokensClaimed) // Retrieve the app and supplier module addresses @@ -65,9 +65,9 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { supplierModuleAddress := authtypes.NewModuleAddress(suppliertypes.ModuleName).String() // Set compute_units_to_tokens_multiplier to simplify expectation calculations. - err := keepers.SharedKeeper.SetParams(ctx, sharedtypes.Params{ - ComputeUnitsToTokensMultiplier: globalComputeUnitsToTokensMultiplier, - }) + sharedParams := keepers.SharedKeeper.GetParams(ctx) + sharedParams.ComputeUnitsToTokensMultiplier = globalComputeUnitsToTokensMultiplier + err := keepers.SharedKeeper.SetParams(ctx, sharedParams) require.NoError(t, err) // TODO_TECHDEBT: Setting inflation to zero so we are testing the BurnEqualsMint logic exclusively. // Once it is a governance param, update it using the keeper above. @@ -191,7 +191,8 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid_SupplierExceedsMaxClai // Determine the max a supplier can claim maxClaimableAmountPerSupplier := int64(numRelays * serviceComputeUnitsPerRelay * globalComputeUnitsToTokensMultiplier) // Figure out what the app's initial stake should be to cover the max claimable amount - appInitialStake := cosmosmath.NewInt(maxClaimableAmountPerSupplier*sessionkeeper.NumSupplierPerSession + 1) + numSuppliersPerSession := int64(keepers.SessionKeeper.GetParams(ctx).NumSuppliersPerSession) + appInitialStake := cosmosmath.NewInt(maxClaimableAmountPerSupplier*numSuppliersPerSession + 1) // Increase the number of relay such that the supplier did "free work" and would // be able to claim more than the max claimable amount. numRelays *= 5 @@ -202,9 +203,9 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid_SupplierExceedsMaxClai supplierModuleAddress := authtypes.NewModuleAddress(suppliertypes.ModuleName).String() // Set compute_units_to_tokens_multiplier to simplify expectation calculations. - err := keepers.SharedKeeper.SetParams(ctx, sharedtypes.Params{ - ComputeUnitsToTokensMultiplier: globalComputeUnitsToTokensMultiplier, - }) + sharedParams := keepers.SharedKeeper.GetParams(ctx) + sharedParams.ComputeUnitsToTokensMultiplier = globalComputeUnitsToTokensMultiplier + err := keepers.SharedKeeper.SetParams(ctx, sharedParams) require.NoError(t, err) // TODO_TECHDEBT: Setting inflation to zero so we are testing the BurnEqualsMint logic exclusively. // Once it is a governance param, update it using the keeper above. @@ -351,9 +352,9 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t keepers.SetService(ctx, *service) // Set compute_units_to_tokens_multiplier to simplify expectation calculations. - err := keepers.SharedKeeper.SetParams(ctx, sharedtypes.Params{ - ComputeUnitsToTokensMultiplier: globalComputeUnitsToTokensMultiplier, - }) + sharedParams := keepers.SharedKeeper.GetParams(ctx) + sharedParams.ComputeUnitsToTokensMultiplier = globalComputeUnitsToTokensMultiplier + err := keepers.SharedKeeper.SetParams(ctx, sharedParams) require.NoError(t, err) // Add a new application with non-zero app stake end balance to assert against. @@ -427,13 +428,14 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t } // Compute mint per actor + tokenomicsParams := keepers.Keeper.GetParams(ctx) numTokensMinted := numTokensClaimed * tlm.GlobalInflationPerClaim numTokensMintedInt := cosmosmath.NewIntFromUint64(uint64(numTokensMinted)) - daoMint := cosmosmath.NewInt(int64(numTokensMinted * tlm.MintAllocationDAO)) - propMint := cosmosmath.NewInt(int64(numTokensMinted * tlm.MintAllocationProposer)) - serviceOwnerMint := cosmosmath.NewInt(int64(numTokensMinted * tlm.MintAllocationSourceOwner)) - appMint := cosmosmath.NewInt(int64(numTokensMinted * tlm.MintAllocationApplication)) - supplierMint := float32(numTokensMinted * tlm.MintAllocationSupplier) + daoMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationDao)) + propMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationProposer)) + serviceOwnerMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationSourceOwner)) + appMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicsParams.MintAllocationApplication)) + supplierMint := float32(numTokensMinted * tokenomicsParams.MintAllocationSupplier) // Ensure the balance was increased to the appropriate amount. require.Equal(t, daoBalanceBefore.Amount.Add(daoMint).Add(numTokensMintedInt), daoBalanceAfter.Amount) @@ -448,7 +450,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t rewardShare := int64(float32(numTokensClaimed) * revShare.RevSharePercentage / 100) balanceIncrease := cosmosmath.NewInt(mintShare + rewardShare) expectedBalanceAfter := balanceBefore.Amount.Add(balanceIncrease).Int64() - // TODO_MAINNET: Remove the InDelta check and use the exact amount once the floating point arithmetic is fixed + // TODO_MAINNET(@red-0ne): Remove the InDelta check and use the exact amount once the floating point arithmetic is fixed acceptableRoundingDelta := tlm.MintDistributionAllowableTolerancePercent * float64(balanceAfter) require.InDelta(t, expectedBalanceAfter, balanceAfter, acceptableRoundingDelta) } diff --git a/x/tokenomics/module/helpers_test.go b/x/tokenomics/module/helpers_test.go index 5ae39a812..48091129c 100644 --- a/x/tokenomics/module/helpers_test.go +++ b/x/tokenomics/module/helpers_test.go @@ -17,6 +17,8 @@ var _ = strconv.IntSize // networkWithDefaultConfig is a helper function to create a network for testing // with a default tokenomics genesis state. +// +//lint:ignore U1000 Ignore unused function for testing purposes func networkWithDefaultConfig(t *testing.T) *network.Network { t.Helper() diff --git a/x/tokenomics/module/tx_update_params.go b/x/tokenomics/module/tx_update_params.go index 43aae6072..d36dc4525 100644 --- a/x/tokenomics/module/tx_update_params.go +++ b/x/tokenomics/module/tx_update_params.go @@ -13,7 +13,9 @@ import ( var _ = strconv.Itoa(0) -// TODO_POST_MAINNET(@bryanchriswhite, #322): Update the CLI once we determine settle on how to maintain and update parameters. +// TODO_UPNEXT(@bryanchriswhite): Remove this. It's not used nor useful. +// Parameter updates currently happen via authz exec messages and in the +// future will be committed via governance proposals. func CmdUpdateParams() *cobra.Command { cmd := &cobra.Command{ Use: "update-params", diff --git a/x/tokenomics/module/tx_update_params_test.go b/x/tokenomics/module/tx_update_params_test.go deleted file mode 100644 index c21dca4f8..000000000 --- a/x/tokenomics/module/tx_update_params_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package tokenomics_test - -import ( - "fmt" - "testing" - - cometcli "github.com/cometbft/cometbft/libs/cli" - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/gogo/status" - "github.com/stretchr/testify/require" - - "github.com/pokt-network/poktroll/testutil/network" - tokenomics "github.com/pokt-network/poktroll/x/tokenomics/module" -) - -func TestCLI_UpdateParams(t *testing.T) { - net := networkWithDefaultConfig(t) - ctx := net.Validators[0].ClientCtx - - common := []string{ - fmt.Sprintf("--%s=json", cometcli.OutputFlag), - fmt.Sprintf("--%s=%s", flags.FlagFrom, net.Validators[0].Address.String()), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFees, network.NewBondDenomCoins(t, net, 10)), - } - - tests := []struct { - desc string - args []string - expectedErr error - expectedExtraErrMsg string - }{ - { - desc: "valid update of all params", - args: []string{}, - expectedErr: nil, - }, - } - - for _, test := range tests { - t.Run(test.desc, func(t *testing.T) { - args := append(common, test.args...) - out, err := clitestutil.ExecTestCLICmd(ctx, tokenomics.CmdUpdateParams(), args) - if test.expectedErr != nil { - _, ok := status.FromError(test.expectedErr) - require.True(t, ok) - require.ErrorIs(t, err, test.expectedErr) - require.Contains(t, err.Error(), test.expectedExtraErrMsg) - } else { - require.NoError(t, err) - var resp sdk.TxResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.NotNil(t, resp) - require.NotNil(t, resp.TxHash) - // You can reference Cosmos SDK error codes here: https://github.com/cosmos/cosmos-sdk/blob/main/types/errors/errors.go - require.Equal(t, uint32(0), resp.Code, "tx response failed: %v", resp) - } - }) - } -} diff --git a/x/tokenomics/types/expected_keepers.go b/x/tokenomics/types/expected_keepers.go index 541a39c9c..38d6670b9 100644 --- a/x/tokenomics/types/expected_keepers.go +++ b/x/tokenomics/types/expected_keepers.go @@ -78,6 +78,7 @@ type SessionKeeper interface { GetSession(context.Context, *sessiontypes.QueryGetSessionRequest) (*sessiontypes.QueryGetSessionResponse, error) GetBlockHash(ctx context.Context, height int64) []byte StoreBlockHash(ctx context.Context) + GetParams(ctx context.Context) sessiontypes.Params } type SupplierKeeper interface { diff --git a/x/tokenomics/types/genesis_test.go b/x/tokenomics/types/genesis_test.go index 0e84dc6be..94360494c 100644 --- a/x/tokenomics/types/genesis_test.go +++ b/x/tokenomics/types/genesis_test.go @@ -5,24 +5,24 @@ import ( "github.com/stretchr/testify/require" - "github.com/pokt-network/poktroll/x/tokenomics/types" + tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) func TestGenesisState_Validate(t *testing.T) { tests := []struct { desc string - genState *types.GenesisState + genState *tokenomicstypes.GenesisState isValid bool }{ { desc: "default is valid", - genState: types.DefaultGenesis(), + genState: tokenomicstypes.DefaultGenesis(), isValid: true, }, { desc: "valid genesis state", - genState: &types.GenesisState{ - Params: types.Params{}, + genState: &tokenomicstypes.GenesisState{ + Params: tokenomicstypes.DefaultParams(), // this line is used by starport scaffolding # types/genesis/validField }, isValid: true, diff --git a/x/tokenomics/types/message_update_param.go b/x/tokenomics/types/message_update_param.go index 1474f95ae..1ff96a105 100644 --- a/x/tokenomics/types/message_update_param.go +++ b/x/tokenomics/types/message_update_param.go @@ -8,24 +8,20 @@ import ( var _ sdk.Msg = (*MsgUpdateParam)(nil) -func NewMsgUpdateParam(authority string, name string, value any) (*MsgUpdateParam, error) { - var valueAsType isMsgUpdateParam_AsType - - switch v := value.(type) { - case string: - valueAsType = &MsgUpdateParam_AsString{AsString: v} - case int64: - valueAsType = &MsgUpdateParam_AsInt64{AsInt64: v} - case []byte: - valueAsType = &MsgUpdateParam_AsBytes{AsBytes: v} +func NewMsgUpdateParam(authority string, name string, asTypeAny any) (*MsgUpdateParam, error) { + var asTypeIface isMsgUpdateParam_AsType + + switch asType := asTypeAny.(type) { + case float64: + asTypeIface = &MsgUpdateParam_AsFloat{AsFloat: asType} default: - return nil, fmt.Errorf("unexpected param value type: %T", value) + return nil, fmt.Errorf("unexpected param value type: %T", asTypeAny) } return &MsgUpdateParam{ Authority: authority, Name: name, - AsType: valueAsType, + AsType: asTypeIface, }, nil } @@ -45,7 +41,43 @@ func (msg *MsgUpdateParam) ValidateBasic() error { // Parameter name must be supported by this module. switch msg.Name { + case ParamMintAllocationDao: + if err := msg.paramTypeIsFloat(); err != nil { + return err + } + return ValidateMintAllocationDao(msg.GetAsFloat()) + case ParamMintAllocationProposer: + if err := msg.paramTypeIsFloat(); err != nil { + return err + } + return ValidateMintAllocationProposer(msg.GetAsFloat()) + case ParamMintAllocationSupplier: + if err := msg.paramTypeIsFloat(); err != nil { + return err + } + return ValidateMintAllocationSupplier(msg.GetAsFloat()) + case ParamMintAllocationSourceOwner: + if err := msg.paramTypeIsFloat(); err != nil { + return err + } + return ValidateMintAllocationSourceOwner(msg.GetAsFloat()) + case ParamMintAllocationApplication: + if err := msg.paramTypeIsFloat(); err != nil { + return err + } + return ValidateMintAllocationApplication(msg.GetAsFloat()) default: return ErrTokenomicsParamNameInvalid.Wrapf("unsupported param %q", msg.Name) } } + +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_AsFloat{}, msg.AsType, + ) + } + + return nil +} diff --git a/x/tokenomics/types/message_update_param_test.go b/x/tokenomics/types/message_update_param_test.go index ffe0f74a0..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_AsInt64{AsInt64: 1}, + AsType: &MsgUpdateParam_AsFloat{AsFloat: 1}, }, expectedErr: ErrTokenomicsAddressInvalid, @@ -29,10 +29,18 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { msg: MsgUpdateParam{ Authority: sample.AccAddress(), Name: "invalid", - AsType: &MsgUpdateParam_AsInt64{AsInt64: 1}, + AsType: &MsgUpdateParam_AsFloat{AsFloat: 1}, }, expectedErr: ErrTokenomicsParamNameInvalid, }, + { + name: "valid: correct address, param name, and type", + msg: MsgUpdateParam{ + Authority: sample.AccAddress(), + Name: ParamMintAllocationDao, + AsType: &MsgUpdateParam_AsFloat{AsFloat: DefaultMintAllocationDao}, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/tokenomics/types/message_update_params_test.go b/x/tokenomics/types/message_update_params_test.go index 914051b92..76396bbf5 100644 --- a/x/tokenomics/types/message_update_params_test.go +++ b/x/tokenomics/types/message_update_params_test.go @@ -15,7 +15,7 @@ func TestMsgUpdateParams_ValidateBasic(t *testing.T) { expectedErr error }{ { - desc: "invalid authority address", + desc: "invalid: non-bech32 authority address", msg: MsgUpdateParams{ Authority: "invalid_address", Params: Params{}, @@ -23,11 +23,33 @@ func TestMsgUpdateParams_ValidateBasic(t *testing.T) { expectedErr: ErrTokenomicsAddressInvalid, }, { - desc: "valid address", + desc: "invalid: empty params", msg: MsgUpdateParams{ Authority: sample.AccAddress(), Params: Params{}, }, + expectedErr: ErrTokenomicsParamInvalid, + }, + { + desc: "valid: address and default params", + msg: MsgUpdateParams{ + Authority: sample.AccAddress(), + Params: DefaultParams(), + }, + }, + { + desc: "invalid: mint allocation params don't sum to 1", + msg: MsgUpdateParams{ + Authority: sample.AccAddress(), + Params: Params{ + MintAllocationDao: 0.1, + MintAllocationProposer: 0.1, + MintAllocationSupplier: 0.1, + MintAllocationSourceOwner: 0.1, + MintAllocationApplication: 0.1, + }, + }, + expectedErr: ErrTokenomicsParamInvalid, }, } diff --git a/x/tokenomics/types/params.go b/x/tokenomics/types/params.go index d83b1b2f9..b19069928 100644 --- a/x/tokenomics/types/params.go +++ b/x/tokenomics/types/params.go @@ -14,6 +14,22 @@ import ( var DaoRewardAddress string var ( + KeyMintAllocationDao = []byte("MintAllocationDao") + ParamMintAllocationDao = "mint_allocation_dao" + DefaultMintAllocationDao float64 = 0.1 + KeyMintAllocationProposer = []byte("MintAllocationProposer") + ParamMintAllocationProposer = "mint_allocation_proposer" + DefaultMintAllocationProposer float64 = 0.05 + KeyMintAllocationSupplier = []byte("MintAllocationSupplier") + ParamMintAllocationSupplier = "mint_allocation_supplier" + DefaultMintAllocationSupplier float64 = 0.7 + KeyMintAllocationSourceOwner = []byte("MintAllocationSourceOwner") + ParamMintAllocationSourceOwner = "mint_allocation_source_owner" + DefaultMintAllocationSourceOwner float64 = 0.15 + KeyMintAllocationApplication = []byte("MintAllocationApplication") + ParamMintAllocationApplication = "mint_allocation_application" + DefaultMintAllocationApplication float64 = 0.0 + _ paramtypes.ParamSet = (*Params)(nil) ) @@ -23,21 +39,174 @@ func ParamKeyTable() paramtypes.KeyTable { } // NewParams creates a new Params instance -func NewParams() Params { - return Params{} +func NewParams( + mintAllocationDao, + mintAllocationProposer, + mintAllocationSupplier, + mintAllocationSourceOwner, + mintAllocationApplication float64, +) Params { + return Params{ + MintAllocationDao: mintAllocationDao, + MintAllocationProposer: mintAllocationProposer, + MintAllocationSupplier: mintAllocationSupplier, + MintAllocationSourceOwner: mintAllocationSourceOwner, + MintAllocationApplication: mintAllocationApplication, + } } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams() + return NewParams( + DefaultMintAllocationDao, + DefaultMintAllocationProposer, + DefaultMintAllocationSupplier, + DefaultMintAllocationSourceOwner, + DefaultMintAllocationApplication, + ) } // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair( + KeyMintAllocationDao, + &p.MintAllocationDao, + ValidateMintAllocationDao, + ), + paramtypes.NewParamSetPair( + KeyMintAllocationProposer, + &p.MintAllocationProposer, + ValidateMintAllocationProposer, + ), + paramtypes.NewParamSetPair( + KeyMintAllocationSupplier, + &p.MintAllocationSupplier, + ValidateMintAllocationSupplier, + ), + paramtypes.NewParamSetPair( + KeyMintAllocationSourceOwner, + &p.MintAllocationSourceOwner, + ValidateMintAllocationSourceOwner, + ), + paramtypes.NewParamSetPair( + KeyMintAllocationApplication, + &p.MintAllocationApplication, + ValidateMintAllocationApplication, + ), + } } // ValidateBasic does a sanity check on the provided params. func (params *Params) ValidateBasic() error { + if err := ValidateMintAllocationDao(params.MintAllocationDao); err != nil { + return err + } + + if err := ValidateMintAllocationProposer(params.MintAllocationProposer); err != nil { + return err + } + + if err := ValidateMintAllocationSupplier(params.MintAllocationSupplier); err != nil { + return err + } + + if err := ValidateMintAllocationSourceOwner(params.MintAllocationSourceOwner); err != nil { + return err + } + + if err := ValidateMintAllocationApplication(params.MintAllocationApplication); err != nil { + return err + } + + if err := ValidateMintAllocationSum(params); err != nil { + return err + } + + return nil +} + +// ValidateMintAllocationDao validates the MintAllocationDao param. +func ValidateMintAllocationDao(mintAllocationDao any) error { + mintAllocationDaoFloat, ok := mintAllocationDao.(float64) + if !ok { + return ErrTokenomicsParamInvalid.Wrapf("invalid parameter type: %T", mintAllocationDao) + } + + if mintAllocationDaoFloat < 0 { + return ErrTokenomicsParamInvalid.Wrapf("mint allocation to DAO must be greater than or equal to 0: got %f", mintAllocationDaoFloat) + } + + return nil +} + +// ValidateMintAllocationProposer validates the MintAllocationProposer param. +func ValidateMintAllocationProposer(mintAllocationProposer any) error { + mintAllocationProposerFloat, ok := mintAllocationProposer.(float64) + if !ok { + return ErrTokenomicsParamInvalid.Wrapf("invalid parameter type: %T", mintAllocationProposer) + } + + if mintAllocationProposerFloat < 0 { + return ErrTokenomicsParamInvalid.Wrapf("mint allocation to proposer must be greater than or equal to 0: got %f", mintAllocationProposerFloat) + } + + return nil +} + +// ValidateMintAllocationSupplier validates the MintAllocationSupplier param. +func ValidateMintAllocationSupplier(mintAllocationSupplier any) error { + mintAllocationSupplierFloat, ok := mintAllocationSupplier.(float64) + if !ok { + return ErrTokenomicsParamInvalid.Wrapf("invalid parameter type: %T", mintAllocationSupplier) + } + + if mintAllocationSupplierFloat < 0 { + return ErrTokenomicsParamInvalid.Wrapf("mint allocation to supplier must be greater than or equal to 0: got %f", mintAllocationSupplierFloat) + } + + return nil +} + +// ValidateMintAllocationSourceOwner validates the MintAllocationSourceOwner param. +func ValidateMintAllocationSourceOwner(mintAllocationSourceOwner any) error { + mintAllocationSourceOwnerFloat, ok := mintAllocationSourceOwner.(float64) + if !ok { + return ErrTokenomicsParamInvalid.Wrapf("invalid parameter type: %T", mintAllocationSourceOwner) + } + + if mintAllocationSourceOwnerFloat < 0 { + return ErrTokenomicsParamInvalid.Wrapf("mint allocation to source owner must be greater than or equal to 0: got %f", mintAllocationSourceOwnerFloat) + } + + return nil +} + +// ValidateMintAllocationApplication validates the MintAllocationApplication param. +func ValidateMintAllocationApplication(mintAllocationApplication any) error { + mintAllocationApplicationFloat, ok := mintAllocationApplication.(float64) + if !ok { + return ErrTokenomicsParamInvalid.Wrapf("invalid parameter type: %T", mintAllocationApplication) + } + + if mintAllocationApplicationFloat < 0 { + return ErrTokenomicsParamInvalid.Wrapf("mint allocation to application must be greater than or equal to 0: got %f", mintAllocationApplicationFloat) + } + + return nil +} + +// ValidateMintAllocationSum validates that the sum of all actor mint allocations is exactly 1. +func ValidateMintAllocationSum(params *Params) error { + sum := params.MintAllocationDao + + params.MintAllocationProposer + + params.MintAllocationSupplier + + params.MintAllocationSourceOwner + + params.MintAllocationApplication + + if sum != 1 { + return ErrTokenomicsParamInvalid.Wrapf("mint allocation percentages do not add to 1.0: got %f", sum) + } + return nil } diff --git a/x/tokenomics/types/params.pb.go b/x/tokenomics/types/params.pb.go index 909476b25..7c59416cb 100644 --- a/x/tokenomics/types/params.pb.go +++ b/x/tokenomics/types/params.pb.go @@ -4,6 +4,7 @@ package types import ( + encoding_binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" @@ -26,6 +27,21 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the tokenomics module. type Params struct { + // mint_allocation_dao is the percentage of the minted tokens which are sent + // to the DAO reward address during claim settlement. + MintAllocationDao float64 `protobuf:"fixed64,1,opt,name=mint_allocation_dao,json=mintAllocationDao,proto3" json:"mint_allocation_dao" yaml:"mint_allocation_dao"` + // mint_allocation_proposer is the percentage of the minted tokens which are sent + // to the block proposer account address during claim settlement. + MintAllocationProposer float64 `protobuf:"fixed64,2,opt,name=mint_allocation_proposer,json=mintAllocationProposer,proto3" json:"mint_allocation_proposer" yaml:"mint_allocation_proposer"` + // mint_allocation_supplier is the percentage of the minted tokens which are sent + // to the block supplier account address during claim settlement. + MintAllocationSupplier float64 `protobuf:"fixed64,3,opt,name=mint_allocation_supplier,json=mintAllocationSupplier,proto3" json:"mint_allocation_supplier" yaml:"mint_allocation_supplier"` + // mint_allocation_source_owner is the percentage of the minted tokens which are sent + // to the service source owner account address during claim settlement. + MintAllocationSourceOwner float64 `protobuf:"fixed64,4,opt,name=mint_allocation_source_owner,json=mintAllocationSourceOwner,proto3" json:"mint_allocation_source_owner" yaml:"mint_allocation_source_owner"` + // mint_allocation_application is the percentage of the minted tokens which are sent + // to the application account address during claim settlement. + MintAllocationApplication float64 `protobuf:"fixed64,5,opt,name=mint_allocation_application,json=mintAllocationApplication,proto3" json:"mint_allocation_application" yaml:"mint_allocation_application"` } func (m *Params) Reset() { *m = Params{} } @@ -57,6 +73,41 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetMintAllocationDao() float64 { + if m != nil { + return m.MintAllocationDao + } + return 0 +} + +func (m *Params) GetMintAllocationProposer() float64 { + if m != nil { + return m.MintAllocationProposer + } + return 0 +} + +func (m *Params) GetMintAllocationSupplier() float64 { + if m != nil { + return m.MintAllocationSupplier + } + return 0 +} + +func (m *Params) GetMintAllocationSourceOwner() float64 { + if m != nil { + return m.MintAllocationSourceOwner + } + return 0 +} + +func (m *Params) GetMintAllocationApplication() float64 { + if m != nil { + return m.MintAllocationApplication + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "poktroll.tokenomics.Params") } @@ -64,19 +115,32 @@ func init() { func init() { proto.RegisterFile("poktroll/tokenomics/params.proto", fileDescriptor_df10a06914fc6eee) } var fileDescriptor_df10a06914fc6eee = []byte{ - // 184 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0xc8, 0xcf, 0x2e, - 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0xcb, 0xcf, 0xcd, 0x4c, 0x2e, 0xd6, - 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xa9, - 0xd0, 0x43, 0xa8, 0x90, 0x12, 0x4c, 0xcc, 0xcd, 0xcc, 0xcb, 0xd7, 0x07, 0x93, 0x10, 0x75, 0x52, - 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, 0x3e, 0x88, 0x05, 0x11, 0x55, 0xd2, 0xe7, 0x62, 0x0b, - 0x00, 0x9b, 0x66, 0xa5, 0xfa, 0x62, 0x81, 0x3c, 0x63, 0xd7, 0xf3, 0x0d, 0x5a, 0x32, 0x70, 0x2b, - 0x2b, 0x90, 0x2d, 0x85, 0x28, 0x73, 0x0a, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, - 0x1b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, - 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x8c, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, - 0x73, 0xf5, 0x41, 0xc6, 0xe8, 0xe6, 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0xeb, 0x63, 0x37, 0xb3, - 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x14, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x45, 0xfa, 0x9e, 0x90, 0xec, 0x00, 0x00, 0x00, + // 397 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x31, 0x8e, 0xda, 0x40, + 0x14, 0x86, 0x99, 0x24, 0x50, 0xb8, 0xc3, 0x44, 0x91, 0x43, 0x90, 0x07, 0x39, 0x8a, 0x14, 0x45, + 0x0a, 0x2e, 0x50, 0x1a, 0x9a, 0x08, 0x94, 0x28, 0x65, 0x08, 0xe9, 0xd2, 0xa0, 0xc1, 0x19, 0x11, + 0x0b, 0xdb, 0x6f, 0x34, 0x1e, 0x44, 0x38, 0x40, 0xa4, 0x68, 0xab, 0xbd, 0xc1, 0xee, 0x11, 0xf6, + 0x18, 0x5b, 0x52, 0x52, 0x8d, 0x56, 0xa6, 0xd8, 0x95, 0x4b, 0x9f, 0x60, 0xe5, 0x31, 0x06, 0x16, + 0x6c, 0x9a, 0xd1, 0xd3, 0xfb, 0xbf, 0x79, 0xff, 0x5f, 0xfc, 0x5a, 0x9b, 0xc1, 0x4c, 0x70, 0xf0, + 0x3c, 0x5b, 0xc0, 0x8c, 0x06, 0xe0, 0xbb, 0x4e, 0x68, 0x33, 0xc2, 0x89, 0x1f, 0x76, 0x18, 0x07, + 0x01, 0x7a, 0x23, 0x27, 0x3a, 0x7b, 0xa2, 0x59, 0x27, 0xbe, 0x1b, 0x80, 0xad, 0xde, 0x8c, 0x6b, + 0xbe, 0x9c, 0xc2, 0x14, 0xd4, 0x68, 0xa7, 0x53, 0xb6, 0xb5, 0xae, 0xaa, 0x5a, 0x6d, 0xa8, 0xce, + 0xe9, 0x54, 0x6b, 0xf8, 0x6e, 0x20, 0xc6, 0xc4, 0xf3, 0xc0, 0x21, 0xc2, 0x85, 0x60, 0xfc, 0x9b, + 0x80, 0x81, 0xda, 0xe8, 0x3d, 0x1a, 0x7c, 0x8a, 0x25, 0x2e, 0x92, 0x13, 0x89, 0x9b, 0x4b, 0xe2, + 0x7b, 0x3d, 0xab, 0x40, 0xb4, 0x46, 0xf5, 0x74, 0xdb, 0xdf, 0x2d, 0xbf, 0x10, 0xd0, 0x97, 0x9a, + 0x71, 0x8c, 0x32, 0x0e, 0x0c, 0x42, 0xca, 0x8d, 0x67, 0xca, 0xeb, 0x73, 0x2c, 0x71, 0x29, 0x93, + 0x48, 0x8c, 0x8b, 0x0d, 0x73, 0xc2, 0x1a, 0xbd, 0x7a, 0xea, 0x3a, 0xdc, 0x0a, 0x45, 0xd6, 0xe1, + 0x9c, 0x31, 0xcf, 0xa5, 0xdc, 0x78, 0x5e, 0x6e, 0x9d, 0x33, 0xe5, 0xd6, 0x39, 0x71, 0x62, 0xfd, + 0x73, 0x2b, 0xe8, 0xff, 0x91, 0xd6, 0x3a, 0xf9, 0x05, 0x73, 0xee, 0xd0, 0x31, 0x2c, 0x02, 0xca, + 0x8d, 0x17, 0xca, 0xff, 0x5b, 0x2c, 0xf1, 0x59, 0x2e, 0x91, 0xf8, 0x6d, 0x49, 0x86, 0x03, 0xca, + 0x1a, 0xbd, 0x3e, 0xca, 0xa1, 0xc4, 0xef, 0xa9, 0xa6, 0xff, 0x43, 0xda, 0x9b, 0xe3, 0xcf, 0x24, + 0x8d, 0x99, 0xcd, 0x46, 0x55, 0x25, 0xf9, 0x1a, 0x4b, 0x7c, 0x0e, 0x4b, 0x24, 0xb6, 0x8a, 0x83, + 0x1c, 0x40, 0x27, 0x39, 0xfa, 0x7b, 0xad, 0xf7, 0xee, 0xe1, 0x1a, 0xa3, 0x8b, 0xfb, 0x9b, 0x0f, + 0xad, 0x5d, 0xc7, 0xff, 0x1e, 0xb6, 0x3c, 0xab, 0xe5, 0xe0, 0xc7, 0x6d, 0x64, 0xa2, 0x55, 0x64, + 0xa2, 0x75, 0x64, 0xa2, 0xbb, 0xc8, 0x44, 0x97, 0x1b, 0xb3, 0xb2, 0xda, 0x98, 0x95, 0xf5, 0xc6, + 0xac, 0xfc, 0xea, 0x4e, 0x5d, 0xf1, 0x67, 0x3e, 0xe9, 0x38, 0xe0, 0xdb, 0xe9, 0x99, 0x8f, 0x01, + 0x15, 0x0b, 0xe0, 0x33, 0xbb, 0xf8, 0xa6, 0x58, 0x32, 0x1a, 0x4e, 0x6a, 0xaa, 0xfb, 0xdd, 0xc7, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x45, 0x21, 0xe2, 0x5d, 0x03, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -98,6 +162,21 @@ func (this *Params) Equal(that interface{}) bool { } else if this == nil { return false } + if this.MintAllocationDao != that1.MintAllocationDao { + return false + } + if this.MintAllocationProposer != that1.MintAllocationProposer { + return false + } + if this.MintAllocationSupplier != that1.MintAllocationSupplier { + return false + } + if this.MintAllocationSourceOwner != that1.MintAllocationSourceOwner { + return false + } + if this.MintAllocationApplication != that1.MintAllocationApplication { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -120,6 +199,36 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MintAllocationApplication != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.MintAllocationApplication)))) + i-- + dAtA[i] = 0x29 + } + if m.MintAllocationSourceOwner != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.MintAllocationSourceOwner)))) + i-- + dAtA[i] = 0x21 + } + if m.MintAllocationSupplier != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.MintAllocationSupplier)))) + i-- + dAtA[i] = 0x19 + } + if m.MintAllocationProposer != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.MintAllocationProposer)))) + i-- + dAtA[i] = 0x11 + } + if m.MintAllocationDao != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.MintAllocationDao)))) + i-- + dAtA[i] = 0x9 + } return len(dAtA) - i, nil } @@ -140,6 +249,21 @@ func (m *Params) Size() (n int) { } var l int _ = l + if m.MintAllocationDao != 0 { + n += 9 + } + if m.MintAllocationProposer != 0 { + n += 9 + } + if m.MintAllocationSupplier != 0 { + n += 9 + } + if m.MintAllocationSourceOwner != 0 { + n += 9 + } + if m.MintAllocationApplication != 0 { + n += 9 + } return n } @@ -178,6 +302,61 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field MintAllocationDao", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.MintAllocationDao = float64(math.Float64frombits(v)) + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field MintAllocationProposer", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.MintAllocationProposer = float64(math.Float64frombits(v)) + case 3: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field MintAllocationSupplier", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.MintAllocationSupplier = float64(math.Float64frombits(v)) + case 4: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field MintAllocationSourceOwner", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.MintAllocationSourceOwner = float64(math.Float64frombits(v)) + case 5: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field MintAllocationApplication", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.MintAllocationApplication = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/tokenomics/types/tx.pb.go b/x/tokenomics/types/tx.pb.go index 9f18a148c..d824fd4af 100644 --- a/x/tokenomics/types/tx.pb.go +++ b/x/tokenomics/types/tx.pb.go @@ -5,6 +5,7 @@ package types import ( context "context" + encoding_binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -125,9 +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_AsString - // *MsgUpdateParam_AsInt64 - // *MsgUpdateParam_AsBytes + // *MsgUpdateParam_AsFloat AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` } @@ -166,19 +165,11 @@ type isMsgUpdateParam_AsType interface { Size() int } -type MsgUpdateParam_AsString struct { - AsString string `protobuf:"bytes,3,opt,name=as_string,json=asString,proto3,oneof" json:"as_string"` -} -type MsgUpdateParam_AsInt64 struct { - AsInt64 int64 `protobuf:"varint,6,opt,name=as_int64,json=asInt64,proto3,oneof" json:"as_int64"` -} -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 float64 `protobuf:"fixed64,3,opt,name=as_float,json=asFloat,proto3,oneof" json:"as_float"` } -func (*MsgUpdateParam_AsString) isMsgUpdateParam_AsType() {} -func (*MsgUpdateParam_AsInt64) isMsgUpdateParam_AsType() {} -func (*MsgUpdateParam_AsBytes) isMsgUpdateParam_AsType() {} +func (*MsgUpdateParam_AsFloat) isMsgUpdateParam_AsType() {} func (m *MsgUpdateParam) GetAsType() isMsgUpdateParam_AsType { if m != nil { @@ -201,33 +192,17 @@ func (m *MsgUpdateParam) GetName() string { return "" } -func (m *MsgUpdateParam) GetAsString() string { - if x, ok := m.GetAsType().(*MsgUpdateParam_AsString); ok { - return x.AsString - } - return "" -} - -func (m *MsgUpdateParam) GetAsInt64() int64 { - if x, ok := m.GetAsType().(*MsgUpdateParam_AsInt64); ok { - return x.AsInt64 +func (m *MsgUpdateParam) GetAsFloat() float64 { + if x, ok := m.GetAsType().(*MsgUpdateParam_AsFloat); ok { + return x.AsFloat } return 0 } -func (m *MsgUpdateParam) GetAsBytes() []byte { - if x, ok := m.GetAsType().(*MsgUpdateParam_AsBytes); ok { - return x.AsBytes - } - return nil -} - // XXX_OneofWrappers is for the internal use of the proto package. func (*MsgUpdateParam) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*MsgUpdateParam_AsString)(nil), - (*MsgUpdateParam_AsInt64)(nil), - (*MsgUpdateParam_AsBytes)(nil), + (*MsgUpdateParam_AsFloat)(nil), } } @@ -283,39 +258,36 @@ func init() { func init() { proto.RegisterFile("poktroll/tokenomics/tx.proto", fileDescriptor_aa0f2fdbd9b6d7eb) } var fileDescriptor_aa0f2fdbd9b6d7eb = []byte{ - // 508 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xf6, 0x11, 0x48, 0xea, 0x6b, 0x28, 0xc2, 0x54, 0xd4, 0x35, 0xc8, 0xb1, 0x02, 0x48, 0x21, - 0xb4, 0xb6, 0x68, 0x50, 0x85, 0x3a, 0x20, 0xe1, 0xa9, 0x0c, 0x91, 0xc0, 0x88, 0x85, 0xc5, 0xba, - 0x24, 0x27, 0xd7, 0x4a, 0xed, 0xb3, 0xfc, 0xae, 0xd0, 0x6c, 0x88, 0x91, 0x89, 0x9f, 0xc1, 0x98, - 0x81, 0x7f, 0xc0, 0xd2, 0xb1, 0x30, 0x75, 0x8a, 0x50, 0x32, 0x44, 0xea, 0x5f, 0x60, 0x41, 0x3e, - 0x3b, 0x4e, 0x13, 0x59, 0x22, 0x62, 0x49, 0xde, 0x7d, 0xdf, 0xf7, 0xde, 0xdd, 0xf7, 0xde, 0x33, - 0xbe, 0x1f, 0xb1, 0x3e, 0x8f, 0xd9, 0xf1, 0xb1, 0xc5, 0x59, 0x9f, 0x86, 0x2c, 0xf0, 0xbb, 0x60, - 0xf1, 0x53, 0x33, 0x8a, 0x19, 0x67, 0xca, 0x9d, 0x19, 0x6b, 0xce, 0x59, 0xed, 0x36, 0x09, 0xfc, - 0x90, 0x59, 0xe2, 0x37, 0xd5, 0x69, 0x5b, 0x5d, 0x06, 0x01, 0x03, 0x2b, 0x00, 0xcf, 0xfa, 0xf0, - 0x34, 0xf9, 0xcb, 0x88, 0xed, 0x94, 0x70, 0xc5, 0xc9, 0x4a, 0x0f, 0x19, 0xb5, 0xe9, 0x31, 0x8f, - 0xa5, 0x78, 0x12, 0x65, 0xa8, 0x51, 0xf4, 0x9e, 0x88, 0xc4, 0x24, 0xc8, 0xf2, 0xea, 0x3f, 0x10, - 0xbe, 0xd5, 0x06, 0xef, 0x5d, 0xd4, 0x23, 0x9c, 0xbe, 0x16, 0x8c, 0xb2, 0x8f, 0x65, 0x72, 0xc2, - 0x8f, 0x58, 0xec, 0xf3, 0x81, 0x8a, 0x0c, 0xd4, 0x90, 0x6d, 0xf5, 0xd7, 0xf7, 0xdd, 0xcd, 0xec, - 0xc2, 0x97, 0xbd, 0x5e, 0x4c, 0x01, 0xde, 0xf2, 0xd8, 0x0f, 0x3d, 0x67, 0x2e, 0x55, 0x5e, 0xe0, - 0x72, 0x5a, 0x5b, 0xbd, 0x66, 0xa0, 0xc6, 0xfa, 0xde, 0x3d, 0xb3, 0xc0, 0xb0, 0x99, 0x5e, 0x62, - 0xcb, 0x67, 0xa3, 0x9a, 0xf4, 0x6d, 0x3a, 0x6c, 0x22, 0x27, 0xcb, 0x3a, 0x78, 0xfe, 0x79, 0x3a, - 0x6c, 0xce, 0xeb, 0x7d, 0x99, 0x0e, 0x9b, 0x8f, 0x72, 0x03, 0xa7, 0x57, 0x2d, 0x2c, 0xbd, 0xb8, - 0xbe, 0x8d, 0xb7, 0x96, 0x20, 0x87, 0x42, 0xc4, 0x42, 0xa0, 0xf5, 0x3f, 0x08, 0x6f, 0x2c, 0x72, - 0xff, 0xed, 0x4f, 0xc1, 0xd7, 0x43, 0x12, 0x50, 0xe1, 0x4e, 0x76, 0x44, 0xac, 0xec, 0x60, 0x99, - 0x80, 0x0b, 0x42, 0xab, 0x96, 0x44, 0xad, 0x9b, 0x97, 0xa3, 0xda, 0x1c, 0x3c, 0x94, 0x9c, 0x35, - 0x92, 0x15, 0x53, 0x1e, 0xe3, 0x35, 0x02, 0xae, 0x1f, 0xf2, 0xfd, 0x67, 0x6a, 0xd9, 0x40, 0x8d, - 0x92, 0x5d, 0xbd, 0x1c, 0xd5, 0x72, 0xec, 0x50, 0x72, 0x2a, 0x04, 0x5e, 0x25, 0x61, 0x26, 0xed, - 0x0c, 0x38, 0x05, 0xb5, 0x62, 0xa0, 0x46, 0x35, 0x97, 0x0a, 0x2c, 0x95, 0xda, 0x49, 0x78, 0xb0, - 0xb1, 0xd8, 0x37, 0x5b, 0xc6, 0x15, 0x02, 0x2e, 0x1f, 0x44, 0xb4, 0xde, 0xc6, 0x77, 0x17, 0xcd, - 0xcf, 0xfa, 0xa2, 0xb4, 0xf2, 0x61, 0xa1, 0x7f, 0x0e, 0x6b, 0x36, 0xa1, 0xbd, 0x9f, 0x08, 0x97, - 0xda, 0xe0, 0x29, 0x1d, 0x5c, 0x5d, 0xd8, 0x98, 0x87, 0x85, 0xc9, 0x4b, 0x23, 0xd1, 0x76, 0x56, - 0x51, 0xe5, 0x0f, 0x74, 0xf1, 0xfa, 0xd5, 0xa1, 0x3d, 0x58, 0x21, 0x59, 0x7b, 0xb2, 0x82, 0x68, - 0x76, 0x81, 0x76, 0xe3, 0x53, 0xb2, 0x7d, 0xf6, 0x9b, 0xb3, 0xb1, 0x8e, 0xce, 0xc7, 0x3a, 0xba, - 0x18, 0xeb, 0xe8, 0xf7, 0x58, 0x47, 0x5f, 0x27, 0xba, 0x74, 0x3e, 0xd1, 0xa5, 0x8b, 0x89, 0x2e, - 0xbd, 0x6f, 0x79, 0x3e, 0x3f, 0x3a, 0xe9, 0x98, 0x5d, 0x16, 0x58, 0x49, 0xed, 0xdd, 0x90, 0xf2, - 0x8f, 0x2c, 0xee, 0x5b, 0xc5, 0x8b, 0x99, 0x34, 0x1d, 0x3a, 0x65, 0xf1, 0x6d, 0xb5, 0xfe, 0x06, - 0x00, 0x00, 0xff, 0xff, 0x02, 0x3d, 0xf2, 0x43, 0x0f, 0x04, 0x00, 0x00, + // 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, + 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x9d, 0x94, 0x78, 0x72, 0x7e, 0x71, + 0x6e, 0x7e, 0xb1, 0x7e, 0x6e, 0x71, 0xba, 0x7e, 0x99, 0x21, 0x88, 0x82, 0x4a, 0x48, 0x42, 0x24, + 0xe2, 0xc1, 0x3c, 0x7d, 0x08, 0x07, 0x2a, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x11, 0x07, 0xb1, + 0xa0, 0xa2, 0x0a, 0xd8, 0xdc, 0x53, 0x90, 0x58, 0x94, 0x98, 0x0b, 0xd5, 0xa7, 0x74, 0x98, 0x91, + 0x8b, 0xdf, 0xb7, 0x38, 0x3d, 0xb4, 0x20, 0x25, 0xb1, 0x24, 0x35, 0x00, 0x2c, 0x23, 0x64, 0xc6, + 0xc5, 0x99, 0x58, 0x5a, 0x92, 0x91, 0x5f, 0x94, 0x59, 0x52, 0x29, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, + 0xe9, 0x24, 0x71, 0x69, 0x8b, 0xae, 0x08, 0xd4, 0x42, 0xc7, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0xe2, + 0xe0, 0x92, 0xa2, 0xcc, 0xbc, 0xf4, 0x20, 0x84, 0x52, 0x21, 0x3b, 0x2e, 0x36, 0x88, 0xd9, 0x12, + 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xd2, 0x7a, 0x58, 0x3c, 0xac, 0x07, 0xb1, 0xc4, 0x89, 0xf3, + 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, 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. @@ -547,46 +519,17 @@ func (m *MsgUpdateParam) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgUpdateParam_AsString) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParam_AsString) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= len(m.AsString) - copy(dAtA[i:], m.AsString) - i = encodeVarintTx(dAtA, i, uint64(len(m.AsString))) - i-- - dAtA[i] = 0x1a - return len(dAtA) - i, nil -} -func (m *MsgUpdateParam_AsInt64) 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_AsInt64) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateParam_AsFloat) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - i = encodeVarintTx(dAtA, i, uint64(m.AsInt64)) + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.AsFloat)))) i-- - dAtA[i] = 0x30 - return len(dAtA) - i, nil -} -func (m *MsgUpdateParam_AsBytes) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParam_AsBytes) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.AsBytes != nil { - i -= len(m.AsBytes) - copy(dAtA[i:], m.AsBytes) - i = encodeVarintTx(dAtA, i, uint64(len(m.AsBytes))) - i-- - dAtA[i] = 0x3a - } + dAtA[i] = 0x19 return len(dAtA) - i, nil } func (m *MsgUpdateParamResponse) Marshal() (dAtA []byte, err error) { @@ -679,35 +622,13 @@ func (m *MsgUpdateParam) Size() (n int) { return n } -func (m *MsgUpdateParam_AsString) Size() (n int) { +func (m *MsgUpdateParam_AsFloat) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.AsString) - n += 1 + l + sovTx(uint64(l)) - return n -} -func (m *MsgUpdateParam_AsInt64) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 1 + sovTx(uint64(m.AsInt64)) - return n -} -func (m *MsgUpdateParam_AsBytes) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AsBytes != nil { - l = len(m.AsBytes) - n += 1 + l + sovTx(uint64(l)) - } + n += 9 return n } func (m *MsgUpdateParamResponse) Size() (n int) { @@ -988,90 +909,16 @@ func (m *MsgUpdateParam) Unmarshal(dAtA []byte) error { m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AsString", wireType) + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field AsFloat", 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.AsType = &MsgUpdateParam_AsString{string(dAtA[iNdEx:postIndex])} - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AsInt64", wireType) - } - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AsType = &MsgUpdateParam_AsInt64{v} - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AsBytes", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { + var v uint64 + if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.AsType = &MsgUpdateParam_AsBytes{v} - iNdEx = postIndex + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.AsType = &MsgUpdateParam_AsFloat{float64(math.Float64frombits(v))} default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:])