diff --git a/api/poktroll/tokenomics/event.pulsar.go b/api/poktroll/tokenomics/event.pulsar.go index 507b21ed9..cf18db79d 100644 --- a/api/poktroll/tokenomics/event.pulsar.go +++ b/api/poktroll/tokenomics/event.pulsar.go @@ -2616,6 +2616,761 @@ func (x *fastReflection_EventSupplierSlashed) ProtoMethods() *protoiface.Methods } } +var ( + md_EventApplicationReimbursementRequest protoreflect.MessageDescriptor + fd_EventApplicationReimbursementRequest_application_addr protoreflect.FieldDescriptor + fd_EventApplicationReimbursementRequest_supplier_operator_addr protoreflect.FieldDescriptor + fd_EventApplicationReimbursementRequest_supplier_owner_addr protoreflect.FieldDescriptor + fd_EventApplicationReimbursementRequest_service_id protoreflect.FieldDescriptor + fd_EventApplicationReimbursementRequest_session_id protoreflect.FieldDescriptor + fd_EventApplicationReimbursementRequest_amount protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_tokenomics_event_proto_init() + md_EventApplicationReimbursementRequest = File_poktroll_tokenomics_event_proto.Messages().ByName("EventApplicationReimbursementRequest") + fd_EventApplicationReimbursementRequest_application_addr = md_EventApplicationReimbursementRequest.Fields().ByName("application_addr") + fd_EventApplicationReimbursementRequest_supplier_operator_addr = md_EventApplicationReimbursementRequest.Fields().ByName("supplier_operator_addr") + fd_EventApplicationReimbursementRequest_supplier_owner_addr = md_EventApplicationReimbursementRequest.Fields().ByName("supplier_owner_addr") + fd_EventApplicationReimbursementRequest_service_id = md_EventApplicationReimbursementRequest.Fields().ByName("service_id") + fd_EventApplicationReimbursementRequest_session_id = md_EventApplicationReimbursementRequest.Fields().ByName("session_id") + fd_EventApplicationReimbursementRequest_amount = md_EventApplicationReimbursementRequest.Fields().ByName("amount") +} + +var _ protoreflect.Message = (*fastReflection_EventApplicationReimbursementRequest)(nil) + +type fastReflection_EventApplicationReimbursementRequest EventApplicationReimbursementRequest + +func (x *EventApplicationReimbursementRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_EventApplicationReimbursementRequest)(x) +} + +func (x *EventApplicationReimbursementRequest) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_tokenomics_event_proto_msgTypes[4] + 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_EventApplicationReimbursementRequest_messageType fastReflection_EventApplicationReimbursementRequest_messageType +var _ protoreflect.MessageType = fastReflection_EventApplicationReimbursementRequest_messageType{} + +type fastReflection_EventApplicationReimbursementRequest_messageType struct{} + +func (x fastReflection_EventApplicationReimbursementRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_EventApplicationReimbursementRequest)(nil) +} +func (x fastReflection_EventApplicationReimbursementRequest_messageType) New() protoreflect.Message { + return new(fastReflection_EventApplicationReimbursementRequest) +} +func (x fastReflection_EventApplicationReimbursementRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_EventApplicationReimbursementRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_EventApplicationReimbursementRequest) Descriptor() protoreflect.MessageDescriptor { + return md_EventApplicationReimbursementRequest +} + +// 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_EventApplicationReimbursementRequest) Type() protoreflect.MessageType { + return _fastReflection_EventApplicationReimbursementRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_EventApplicationReimbursementRequest) New() protoreflect.Message { + return new(fastReflection_EventApplicationReimbursementRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_EventApplicationReimbursementRequest) Interface() protoreflect.ProtoMessage { + return (*EventApplicationReimbursementRequest)(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_EventApplicationReimbursementRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ApplicationAddr != "" { + value := protoreflect.ValueOfString(x.ApplicationAddr) + if !f(fd_EventApplicationReimbursementRequest_application_addr, value) { + return + } + } + if x.SupplierOperatorAddr != "" { + value := protoreflect.ValueOfString(x.SupplierOperatorAddr) + if !f(fd_EventApplicationReimbursementRequest_supplier_operator_addr, value) { + return + } + } + if x.SupplierOwnerAddr != "" { + value := protoreflect.ValueOfString(x.SupplierOwnerAddr) + if !f(fd_EventApplicationReimbursementRequest_supplier_owner_addr, value) { + return + } + } + if x.ServiceId != "" { + value := protoreflect.ValueOfString(x.ServiceId) + if !f(fd_EventApplicationReimbursementRequest_service_id, value) { + return + } + } + if x.SessionId != "" { + value := protoreflect.ValueOfString(x.SessionId) + if !f(fd_EventApplicationReimbursementRequest_session_id, value) { + return + } + } + if x.Amount != nil { + value := protoreflect.ValueOfMessage(x.Amount.ProtoReflect()) + if !f(fd_EventApplicationReimbursementRequest_amount, 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_EventApplicationReimbursementRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationReimbursementRequest.application_addr": + return x.ApplicationAddr != "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_operator_addr": + return x.SupplierOperatorAddr != "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_owner_addr": + return x.SupplierOwnerAddr != "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.service_id": + return x.ServiceId != "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.session_id": + return x.SessionId != "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.amount": + return x.Amount != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationReimbursementRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationReimbursementRequest 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_EventApplicationReimbursementRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationReimbursementRequest.application_addr": + x.ApplicationAddr = "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_operator_addr": + x.SupplierOperatorAddr = "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_owner_addr": + x.SupplierOwnerAddr = "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.service_id": + x.ServiceId = "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.session_id": + x.SessionId = "" + case "poktroll.tokenomics.EventApplicationReimbursementRequest.amount": + x.Amount = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationReimbursementRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationReimbursementRequest 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_EventApplicationReimbursementRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.tokenomics.EventApplicationReimbursementRequest.application_addr": + value := x.ApplicationAddr + return protoreflect.ValueOfString(value) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_operator_addr": + value := x.SupplierOperatorAddr + return protoreflect.ValueOfString(value) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_owner_addr": + value := x.SupplierOwnerAddr + return protoreflect.ValueOfString(value) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.service_id": + value := x.ServiceId + return protoreflect.ValueOfString(value) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.session_id": + value := x.SessionId + return protoreflect.ValueOfString(value) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.amount": + value := x.Amount + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationReimbursementRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationReimbursementRequest 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_EventApplicationReimbursementRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationReimbursementRequest.application_addr": + x.ApplicationAddr = value.Interface().(string) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_operator_addr": + x.SupplierOperatorAddr = value.Interface().(string) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_owner_addr": + x.SupplierOwnerAddr = value.Interface().(string) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.service_id": + x.ServiceId = value.Interface().(string) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.session_id": + x.SessionId = value.Interface().(string) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.amount": + x.Amount = value.Message().Interface().(*v1beta1.Coin) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationReimbursementRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationReimbursementRequest 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_EventApplicationReimbursementRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationReimbursementRequest.amount": + if x.Amount == nil { + x.Amount = new(v1beta1.Coin) + } + return protoreflect.ValueOfMessage(x.Amount.ProtoReflect()) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.application_addr": + panic(fmt.Errorf("field application_addr of message poktroll.tokenomics.EventApplicationReimbursementRequest is not mutable")) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_operator_addr": + panic(fmt.Errorf("field supplier_operator_addr of message poktroll.tokenomics.EventApplicationReimbursementRequest is not mutable")) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_owner_addr": + panic(fmt.Errorf("field supplier_owner_addr of message poktroll.tokenomics.EventApplicationReimbursementRequest is not mutable")) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.service_id": + panic(fmt.Errorf("field service_id of message poktroll.tokenomics.EventApplicationReimbursementRequest is not mutable")) + case "poktroll.tokenomics.EventApplicationReimbursementRequest.session_id": + panic(fmt.Errorf("field session_id of message poktroll.tokenomics.EventApplicationReimbursementRequest is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationReimbursementRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationReimbursementRequest 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_EventApplicationReimbursementRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationReimbursementRequest.application_addr": + return protoreflect.ValueOfString("") + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_operator_addr": + return protoreflect.ValueOfString("") + case "poktroll.tokenomics.EventApplicationReimbursementRequest.supplier_owner_addr": + return protoreflect.ValueOfString("") + case "poktroll.tokenomics.EventApplicationReimbursementRequest.service_id": + return protoreflect.ValueOfString("") + case "poktroll.tokenomics.EventApplicationReimbursementRequest.session_id": + return protoreflect.ValueOfString("") + case "poktroll.tokenomics.EventApplicationReimbursementRequest.amount": + m := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationReimbursementRequest")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationReimbursementRequest 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_EventApplicationReimbursementRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.tokenomics.EventApplicationReimbursementRequest", 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_EventApplicationReimbursementRequest) 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_EventApplicationReimbursementRequest) 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_EventApplicationReimbursementRequest) 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_EventApplicationReimbursementRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*EventApplicationReimbursementRequest) + 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.ApplicationAddr) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.SupplierOperatorAddr) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.SupplierOwnerAddr) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.ServiceId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.SessionId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Amount != nil { + l = options.Size(x.Amount) + 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().(*EventApplicationReimbursementRequest) + 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.Amount != nil { + encoded, err := options.Marshal(x.Amount) + 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] = 0x32 + } + if len(x.SessionId) > 0 { + i -= len(x.SessionId) + copy(dAtA[i:], x.SessionId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SessionId))) + i-- + dAtA[i] = 0x2a + } + 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] = 0x22 + } + if len(x.SupplierOwnerAddr) > 0 { + i -= len(x.SupplierOwnerAddr) + copy(dAtA[i:], x.SupplierOwnerAddr) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SupplierOwnerAddr))) + i-- + dAtA[i] = 0x1a + } + if len(x.SupplierOperatorAddr) > 0 { + i -= len(x.SupplierOperatorAddr) + copy(dAtA[i:], x.SupplierOperatorAddr) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SupplierOperatorAddr))) + i-- + dAtA[i] = 0x12 + } + if len(x.ApplicationAddr) > 0 { + i -= len(x.ApplicationAddr) + copy(dAtA[i:], x.ApplicationAddr) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ApplicationAddr))) + 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().(*EventApplicationReimbursementRequest) + 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: EventApplicationReimbursementRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EventApplicationReimbursementRequest: 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 ApplicationAddr", 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.ApplicationAddr = 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 SupplierOperatorAddr", 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.SupplierOperatorAddr = 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 SupplierOwnerAddr", 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.SupplierOwnerAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SessionId", 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.SessionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Amount", 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.Amount == nil { + x.Amount = &v1beta1.Coin{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Amount); 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 @@ -2974,6 +3729,83 @@ func (x *EventSupplierSlashed) GetSlashingAmount() *v1beta1.Coin { return nil } +// EventApplicationReimbursementRequest is emitted when an application requests +// a reimbursement +type EventApplicationReimbursementRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ApplicationAddr string `protobuf:"bytes,1,opt,name=application_addr,json=applicationAddr,proto3" json:"application_addr,omitempty"` + SupplierOperatorAddr string `protobuf:"bytes,2,opt,name=supplier_operator_addr,json=supplierOperatorAddr,proto3" json:"supplier_operator_addr,omitempty"` + SupplierOwnerAddr string `protobuf:"bytes,3,opt,name=supplier_owner_addr,json=supplierOwnerAddr,proto3" json:"supplier_owner_addr,omitempty"` + ServiceId string `protobuf:"bytes,4,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + SessionId string `protobuf:"bytes,5,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + Amount *v1beta1.Coin `protobuf:"bytes,6,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *EventApplicationReimbursementRequest) Reset() { + *x = EventApplicationReimbursementRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_tokenomics_event_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EventApplicationReimbursementRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventApplicationReimbursementRequest) ProtoMessage() {} + +// Deprecated: Use EventApplicationReimbursementRequest.ProtoReflect.Descriptor instead. +func (*EventApplicationReimbursementRequest) Descriptor() ([]byte, []int) { + return file_poktroll_tokenomics_event_proto_rawDescGZIP(), []int{4} +} + +func (x *EventApplicationReimbursementRequest) GetApplicationAddr() string { + if x != nil { + return x.ApplicationAddr + } + return "" +} + +func (x *EventApplicationReimbursementRequest) GetSupplierOperatorAddr() string { + if x != nil { + return x.SupplierOperatorAddr + } + return "" +} + +func (x *EventApplicationReimbursementRequest) GetSupplierOwnerAddr() string { + if x != nil { + return x.SupplierOwnerAddr + } + return "" +} + +func (x *EventApplicationReimbursementRequest) GetServiceId() string { + if x != nil { + return x.ServiceId + } + return "" +} + +func (x *EventApplicationReimbursementRequest) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *EventApplicationReimbursementRequest) GetAmount() *v1beta1.Coin { + if x != nil { + return x.Amount + } + return nil +} + var File_poktroll_tokenomics_event_proto protoreflect.FileDescriptor var file_poktroll_tokenomics_event_proto_rawDesc = []byte{ @@ -3076,26 +3908,45 @@ var file_poktroll_tokenomics_event_proto_rawDesc = []byte{ 0x73, 0x68, 0x69, 0x6e, 0x67, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x52, 0x0e, 0x73, - 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x2a, 0x60, 0x0a, - 0x15, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x45, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x1d, 0x45, 0x58, 0x50, 0x49, 0x52, 0x41, - 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x4f, - 0x4f, 0x46, 0x5f, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, - 0x50, 0x52, 0x4f, 0x4f, 0x46, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x02, 0x42, - 0xbc, 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, - 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, 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, + 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa8, 0x02, + 0x0a, 0x24, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x69, 0x6d, 0x62, 0x75, 0x72, 0x73, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x64, 0x64, + 0x72, 0x12, 0x34, 0x0a, 0x16, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x5f, 0x6f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x14, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x4f, 0x70, 0x65, 0x72, 0x61, + 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x70, 0x6c, + 0x69, 0x65, 0x72, 0x5f, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x4f, 0x77, + 0x6e, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x31, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, + 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, + 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x2a, 0x60, 0x0a, 0x15, 0x43, 0x6c, 0x61, 0x69, + 0x6d, 0x45, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x61, 0x73, 0x6f, + 0x6e, 0x12, 0x21, 0x0a, 0x1d, 0x45, 0x58, 0x50, 0x49, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x4f, 0x4f, 0x46, 0x5f, 0x4d, 0x49, + 0x53, 0x53, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x52, 0x4f, 0x4f, 0x46, + 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x02, 0x42, 0xbc, 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, 0x0a, 0x45, 0x76, 0x65, 0x6e, + 0x74, 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 ( @@ -3111,32 +3962,34 @@ func file_poktroll_tokenomics_event_proto_rawDescGZIP() []byte { } var file_poktroll_tokenomics_event_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_poktroll_tokenomics_event_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_poktroll_tokenomics_event_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_poktroll_tokenomics_event_proto_goTypes = []interface{}{ - (ClaimExpirationReason)(0), // 0: poktroll.tokenomics.ClaimExpirationReason - (*EventClaimExpired)(nil), // 1: poktroll.tokenomics.EventClaimExpired - (*EventClaimSettled)(nil), // 2: poktroll.tokenomics.EventClaimSettled - (*EventApplicationOverserviced)(nil), // 3: poktroll.tokenomics.EventApplicationOverserviced - (*EventSupplierSlashed)(nil), // 4: poktroll.tokenomics.EventSupplierSlashed - (*proof.Claim)(nil), // 5: poktroll.proof.Claim - (*v1beta1.Coin)(nil), // 6: cosmos.base.v1beta1.Coin - (proof.ProofRequirementReason)(0), // 7: poktroll.proof.ProofRequirementReason + (ClaimExpirationReason)(0), // 0: poktroll.tokenomics.ClaimExpirationReason + (*EventClaimExpired)(nil), // 1: poktroll.tokenomics.EventClaimExpired + (*EventClaimSettled)(nil), // 2: poktroll.tokenomics.EventClaimSettled + (*EventApplicationOverserviced)(nil), // 3: poktroll.tokenomics.EventApplicationOverserviced + (*EventSupplierSlashed)(nil), // 4: poktroll.tokenomics.EventSupplierSlashed + (*EventApplicationReimbursementRequest)(nil), // 5: poktroll.tokenomics.EventApplicationReimbursementRequest + (*proof.Claim)(nil), // 6: poktroll.proof.Claim + (*v1beta1.Coin)(nil), // 7: cosmos.base.v1beta1.Coin + (proof.ProofRequirementReason)(0), // 8: poktroll.proof.ProofRequirementReason } var file_poktroll_tokenomics_event_proto_depIdxs = []int32{ - 5, // 0: poktroll.tokenomics.EventClaimExpired.claim:type_name -> poktroll.proof.Claim - 0, // 1: poktroll.tokenomics.EventClaimExpired.expiration_reason:type_name -> poktroll.tokenomics.ClaimExpirationReason - 6, // 2: poktroll.tokenomics.EventClaimExpired.claimed_upokt:type_name -> cosmos.base.v1beta1.Coin - 5, // 3: poktroll.tokenomics.EventClaimSettled.claim:type_name -> poktroll.proof.Claim - 7, // 4: poktroll.tokenomics.EventClaimSettled.proof_requirement:type_name -> poktroll.proof.ProofRequirementReason - 6, // 5: poktroll.tokenomics.EventClaimSettled.claimed_upokt:type_name -> cosmos.base.v1beta1.Coin - 6, // 6: poktroll.tokenomics.EventApplicationOverserviced.expected_burn:type_name -> cosmos.base.v1beta1.Coin - 6, // 7: poktroll.tokenomics.EventApplicationOverserviced.effective_burn:type_name -> cosmos.base.v1beta1.Coin - 6, // 8: poktroll.tokenomics.EventSupplierSlashed.slashing_amount:type_name -> cosmos.base.v1beta1.Coin - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 6, // 0: poktroll.tokenomics.EventClaimExpired.claim:type_name -> poktroll.proof.Claim + 0, // 1: poktroll.tokenomics.EventClaimExpired.expiration_reason:type_name -> poktroll.tokenomics.ClaimExpirationReason + 7, // 2: poktroll.tokenomics.EventClaimExpired.claimed_upokt:type_name -> cosmos.base.v1beta1.Coin + 6, // 3: poktroll.tokenomics.EventClaimSettled.claim:type_name -> poktroll.proof.Claim + 8, // 4: poktroll.tokenomics.EventClaimSettled.proof_requirement:type_name -> poktroll.proof.ProofRequirementReason + 7, // 5: poktroll.tokenomics.EventClaimSettled.claimed_upokt:type_name -> cosmos.base.v1beta1.Coin + 7, // 6: poktroll.tokenomics.EventApplicationOverserviced.expected_burn:type_name -> cosmos.base.v1beta1.Coin + 7, // 7: poktroll.tokenomics.EventApplicationOverserviced.effective_burn:type_name -> cosmos.base.v1beta1.Coin + 7, // 8: poktroll.tokenomics.EventSupplierSlashed.slashing_amount:type_name -> cosmos.base.v1beta1.Coin + 7, // 9: poktroll.tokenomics.EventApplicationReimbursementRequest.amount:type_name -> cosmos.base.v1beta1.Coin + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_poktroll_tokenomics_event_proto_init() } @@ -3193,6 +4046,18 @@ func file_poktroll_tokenomics_event_proto_init() { return nil } } + file_poktroll_tokenomics_event_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EventApplicationReimbursementRequest); 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{ @@ -3200,7 +4065,7 @@ func file_poktroll_tokenomics_event_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_poktroll_tokenomics_event_proto_rawDesc, NumEnums: 1, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/e2e/tests/0_settlement.feature b/e2e/tests/0_settlement.feature index fb3e228d6..a6595eb37 100644 --- a/e2e/tests/0_settlement.feature +++ b/e2e/tests/0_settlement.feature @@ -6,7 +6,7 @@ # that can be used to clear the state of the chain between tests. Feature: Tokenomics Namespace - Scenario: Settle the session when a valid claim is within max limits and a valid proof is submitted and required via threshold + Scenario: TLM Mint=Burn when a valid claim is within max limits and a valid proof is submitted and required via threshold # Baseline Given the user has the pocketd binary installed # Network preparation and validation @@ -35,12 +35,13 @@ Feature: Tokenomics Namespace And the user should wait for the ClaimSettled event with "THRESHOLD" proof requirement to be broadcast # Validate the results # Please note that supplier mint is > app burn because of inflation - # TODO_TECHDEBT: Update this test such the the inflation is set and enforce that Mint=Burn + # TODO_TECHDEBT: Update this test such the inflation is set and enforce that Mint=Burn # Then add a separate test that only validates that inflation is enforced correctly Then the account balance of "supplier1" should be "898" uPOKT "more" than before - And the "application" stake of "app1" should be "840" uPOKT "less" than before + # The application stake should be less 840 * (1 + glbal_inflation) = 840 * 1.1 = 924 + And the "application" stake of "app1" should be "924" uPOKT "less" than before - Scenario: Settle the session when a valid claim is create but not required + Scenario: TLM Mint=Burn when a valid claim is create but not required # Baseline Given the user has the pocketd binary installed # Network preparation and validation @@ -70,9 +71,10 @@ Feature: Tokenomics Namespace And the user should wait for the ClaimSettled event with "NOT_REQUIRED" proof requirement to be broadcast # Validate the results # Please note that supplier mint is > app burn because of inflation - # TODO_TECHDEBT: Update this test such the the inflation is set and enforce that Mint=Burn + # TODO_TECHDEBT: Update this test such the inflation is set and enforce that Mint=Burn Then the account balance of "supplier1" should be "449" uPOKT "more" than before - And the "application" stake of "app1" should be "420" uPOKT "less" than before + # The application stake should be less 420 * (1 + glbal_inflation) = 420 * 1.1 = 462 + And the "application" stake of "app1" should be "462" uPOKT "less" than before # TODO_TEST: Implement the following scenarios # Scenario: Supplier revenue shares are properly distributed diff --git a/proto/poktroll/tokenomics/event.proto b/proto/poktroll/tokenomics/event.proto index fb807d121..23c4f8e10 100644 --- a/proto/poktroll/tokenomics/event.proto +++ b/proto/poktroll/tokenomics/event.proto @@ -79,4 +79,15 @@ message EventSupplierSlashed { // Amount slashed from the supplier's stake due to the expired claims. // This is a function of the number of expired claims and proof missing penalty. cosmos.base.v1beta1.Coin slashing_amount = 3; +} + +// EventApplicationReimbursementRequest is emitted when an application requests +// a reimbursement. +message EventApplicationReimbursementRequest { + string application_addr = 1; + string supplier_operator_addr = 2; + string supplier_owner_addr = 3; + string service_id = 4; + string session_id = 5; + cosmos.base.v1beta1.Coin amount = 6; } \ No newline at end of file diff --git a/tests/integration/application/min_stake_test.go b/tests/integration/application/min_stake_test.go index dc14736dc..52bc57912 100644 --- a/tests/integration/application/min_stake_test.go +++ b/tests/integration/application/min_stake_test.go @@ -5,7 +5,6 @@ import ( "testing" cosmoslog "cosmossdk.io/log" - "cosmossdk.io/math" cosmostypes "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/require" @@ -25,6 +24,7 @@ import ( 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" + tokenomicskeeper "github.com/pokt-network/poktroll/x/tokenomics/keeper" ) type applicationMinStakeTestSuite struct { @@ -51,7 +51,7 @@ func TestApplicationMinStakeTestSuite(t *testing.T) { } func (s *applicationMinStakeTestSuite) SetupTest() { - s.keepers, s.ctx = keeper.NewTokenomicsModuleKeepers(s.T(), cosmoslog.NewNopLogger()) + s.keepers, s.ctx = keeper.NewTokenomicsModuleKeepers(s.T(), cosmoslog.NewNopLogger(), keeper.WithProofRequirement(false)) proofParams := prooftypes.DefaultParams() proofParams.ProofRequestProbability = 0 @@ -235,7 +235,8 @@ func (s *applicationMinStakeTestSuite) getExpectedApp(claim *prooftypes.Claim) * expectedBurnCoin, err := claim.GetClaimeduPOKT(sharedParams, relayMiningDifficulty) require.NoError(s.T(), err) - expectedEndStake := s.appStake.Sub(expectedBurnCoin) + globalInflationAmt, _ := tokenomicskeeper.CalculateGlobalPerClaimMintInflationFromSettlementAmount(expectedBurnCoin) + expectedEndStake := s.appStake.Sub(expectedBurnCoin).Sub(globalInflationAmt) return &apptypes.Application{ Address: s.appBech32, Stake: &expectedEndStake, @@ -304,8 +305,11 @@ func (s *applicationMinStakeTestSuite) assertUnbondingEndEventObserved(expectedA func (s *applicationMinStakeTestSuite) assertAppStakeIsReturnedToBalance() { s.T().Helper() - expectedAppBurn := math.NewInt(int64(s.numRelays * s.numComputeUnitsPerRelay * sharedtypes.DefaultComputeUnitsToTokensMultiplier)) - expectedAppBalance := s.appStake.SubAmount(expectedAppBurn) + expectedAppBurn := int64(s.numRelays * s.numComputeUnitsPerRelay * sharedtypes.DefaultComputeUnitsToTokensMultiplier) + expectedAppBurnCoin := cosmostypes.NewInt64Coin(volatile.DenomuPOKT, expectedAppBurn) + globalInflationCoin, _ := tokenomicskeeper.CalculateGlobalPerClaimMintInflationFromSettlementAmount(expectedAppBurnCoin) + expectedAppBalance := s.appStake.Sub(expectedAppBurnCoin).Sub(globalInflationCoin) + appBalance := s.getAppBalance() require.Equal(s.T(), expectedAppBalance.Amount.Int64(), appBalance.Amount.Int64()) } diff --git a/tests/integration/tokenomics/relay_mining_integration_test.go b/tests/integration/tokenomics/relay_mining_integration_test.go index 2beeb2196..b97dc4b15 100644 --- a/tests/integration/tokenomics/relay_mining_integration_test.go +++ b/tests/integration/tokenomics/relay_mining_integration_test.go @@ -1,7 +1,6 @@ package integration_test import ( - "math" "math/big" "testing" @@ -84,6 +83,7 @@ func TestComputeNewDifficultyHash_RewardsReflectWorkCompleted(t *testing.T) { testutils.WithService(service), testutils.WithApplication(application), testutils.WithSupplier(supplier), + testutils.WithProofRequirement(false), ) sdkCtx := sdk.UnwrapSDKContext(ctx) sdkCtx = sdkCtx.WithBlockHeight(1) @@ -94,13 +94,6 @@ func TestComputeNewDifficultyHash_RewardsReflectWorkCompleted(t *testing.T) { err := keepers.SharedKeeper.SetParams(sdkCtx, sharedParams) require.NoError(t, err) - // Set the global proof params so we never need a proof (for simplicity of this test) - err = keepers.ProofKeeper.SetParams(sdkCtx, prooftypes.Params{ - ProofRequestProbability: 0, // we never need a proof randomly - ProofRequirementThreshold: &sdk.Coin{Denom: volatile.DenomuPOKT, Amount: sdkmath.NewInt(math.MaxInt64)}, // a VERY high threshold - }) - require.NoError(t, err) - // Update the relay mining difficulty so there's always a difficulty to retrieve // for the test service. _, err = keepers.ServiceKeeper.UpdateRelayMiningDifficulty(sdkCtx, map[string]uint64{service.Id: 1}) diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index 75d6551f4..73d6f8a05 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -2,10 +2,11 @@ package keeper import ( "context" + "math" "testing" "cosmossdk.io/log" - "cosmossdk.io/math" + cosmosmath "cosmossdk.io/math" "cosmossdk.io/store" "cosmossdk.io/store/metrics" storetypes "cosmossdk.io/store/types" @@ -29,6 +30,7 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/app" + "github.com/pokt-network/poktroll/app/volatile" "github.com/pokt-network/poktroll/testutil/sample" "github.com/pokt-network/poktroll/testutil/tokenomics/mocks" appkeeper "github.com/pokt-network/poktroll/x/application/keeper" @@ -117,7 +119,7 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) ( // Prepare the test application. application := apptypes.Application{ Address: sample.AccAddress(), - Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100000)}, + Stake: &sdk.Coin{Denom: "upokt", Amount: cosmosmath.NewInt(100000)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{ServiceId: service.Id}}, } @@ -126,7 +128,7 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) ( supplier := sharedtypes.Supplier{ OwnerAddress: supplierOwnerAddr, OperatorAddress: supplierOwnerAddr, - Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100000)}, + Stake: &sdk.Coin{Denom: "upokt", Amount: cosmosmath.NewInt(100000)}, Services: []*sharedtypes.SupplierServiceConfig{ { ServiceId: service.Id, @@ -199,6 +201,9 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) ( mockBankKeeper.EXPECT(). SendCoinsFromModuleToModule(gomock.Any(), tokenomicstypes.ModuleName, suppliertypes.ModuleName, gomock.Any()). AnyTimes() + mockBankKeeper.EXPECT(). + SendCoinsFromModuleToModule(gomock.Any(), apptypes.ModuleName, tokenomicstypes.ModuleName, gomock.Any()). + AnyTimes() // Mock the account keeper mockAccountKeeper := mocks.NewMockAccountKeeper(ctrl) @@ -346,9 +351,9 @@ func NewTokenomicsModuleKeepers( require.NoError(t, bankKeeper.SetParams(sdkCtx, banktypes.DefaultParams())) // Provide some initial funds to the suppliers & applications module accounts. - err = bankKeeper.MintCoins(sdkCtx, suppliertypes.ModuleName, sdk.NewCoins(sdk.NewCoin("upokt", math.NewInt(1000000000000)))) + err = bankKeeper.MintCoins(sdkCtx, suppliertypes.ModuleName, sdk.NewCoins(sdk.NewCoin("upokt", cosmosmath.NewInt(1000000000000)))) require.NoError(t, err) - err = bankKeeper.MintCoins(sdkCtx, apptypes.ModuleName, sdk.NewCoins(sdk.NewCoin("upokt", math.NewInt(1000000000000)))) + err = bankKeeper.MintCoins(sdkCtx, apptypes.ModuleName, sdk.NewCoins(sdk.NewCoin("upokt", cosmosmath.NewInt(1000000000000)))) require.NoError(t, err) // Construct a real shared keeper. @@ -513,3 +518,33 @@ func WithProposerAddr(addr string) TokenomicsModuleKeepersOpt { return sdkCtx } } + +// WithProofRequirement is an option to enable or disable the proof requirement +// in the tokenomics module keepers by setting the proof request probability to +// 1 or 0, respectively whie setting the proof requirement threshold to 0 or +// MaxInt64, respectively. +func WithProofRequirement(proofRequired bool) TokenomicsModuleKeepersOpt { + return func(ctx context.Context, keepers *TokenomicsModuleKeepers) context.Context { + + proofParams := keepers.ProofKeeper.GetParams(ctx) + if proofRequired { + // Require a proof 100% of the time probabilistically speaking. + proofParams.ProofRequestProbability = 1 + // Require a proof of any claim amount (i.e. anything greater than 0). + proofRequirementThreshold := cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 0) + proofParams.ProofRequirementThreshold = &proofRequirementThreshold + } else { + // Never require a proof probabilistically speaking. + proofParams.ProofRequestProbability = 0 + // Require a proof for MaxInt64 claim amount (i.e. should never trigger). + proofRequirementThreshold := cosmostypes.NewInt64Coin(volatile.DenomuPOKT, math.MaxInt64) + proofParams.ProofRequirementThreshold = &proofRequirementThreshold + } + + if err := keepers.ProofKeeper.SetParams(ctx, proofParams); err != nil { + panic(err) + } + + return ctx + } +} diff --git a/x/tokenomics/keeper/settle_pending_claims.go b/x/tokenomics/keeper/settle_pending_claims.go index fd314d9b2..37a48b3f2 100644 --- a/x/tokenomics/keeper/settle_pending_claims.go +++ b/x/tokenomics/keeper/settle_pending_claims.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "fmt" "cosmossdk.io/math" @@ -8,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/pokt-network/poktroll/app/volatile" + apptypes "github.com/pokt-network/poktroll/x/application/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" servicekeeper "github.com/pokt-network/poktroll/x/service/keeper" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" @@ -35,6 +37,15 @@ func (k Keeper) SettlePendingClaims(ctx sdk.Context) ( return settledResult, expiredResult, err } + // Capture the applications initial stake which will be used to calculate the + // max share any claim could burn from the application stake. + // This ensures that each supplier can calculate the maximum amount it can take + // from an application's stake. + applicationInitialStakeMap, err := k.getApplicationInitialStakeMap(ctx, expiringClaims) + if err != nil { + return settledResult, expiredResult, err + } + blockHeight := ctx.BlockHeight() logger.Info(fmt.Sprintf("found %d expiring claims at block height %d", len(expiringClaims), blockHeight)) @@ -176,8 +187,11 @@ func (k Keeper) SettlePendingClaims(ctx sdk.Context) ( // 1. The claim does not require a proof. // 2. The claim requires a proof and a valid proof was found. + appAddress := claim.GetSessionHeader().GetApplicationAddress() + applicationInitialStake := applicationInitialStakeMap[appAddress] + // Manage the mint & burn accounting for the claim. - if err = k.ProcessTokenLogicModules(ctx, &claim); err != nil { + if err = k.ProcessTokenLogicModules(ctx, &claim, applicationInitialStake); err != nil { logger.Error(fmt.Sprintf("error processing token logic modules for claim %q: %v", claim.SessionHeader.SessionId, err)) return settledResult, expiredResult, err } @@ -402,3 +416,34 @@ func (k Keeper) slashSupplierStake( return nil } + +// getApplicationInitialStakeMap returns a map from an application address to the +// initial stake of the application. This is used to calculate the maximum share +// any claim could burn from the application stake. +func (k Keeper) getApplicationInitialStakeMap( + ctx context.Context, + expiringClaims []prooftypes.Claim, +) (applicationInitialStakeMap map[string]sdk.Coin, err error) { + applicationInitialStakeMap = make(map[string]sdk.Coin) + for _, claim := range expiringClaims { + appAddress := claim.SessionHeader.ApplicationAddress + // The same application is participating in other claims being settled, + // so we already capture its initial stake. + if _, isAppFound := applicationInitialStakeMap[appAddress]; isAppFound { + continue + } + + app, isAppFound := k.applicationKeeper.GetApplication(ctx, appAddress) + if !isAppFound { + err := apptypes.ErrAppNotFound.Wrapf( + "trying to settle a claim for an application that does not exist (which should never happen) with address: %q", + appAddress, + ) + return nil, err + } + + applicationInitialStakeMap[appAddress] = *app.GetStake() + } + + return applicationInitialStakeMap, nil +} diff --git a/x/tokenomics/keeper/token_logic_modules.go b/x/tokenomics/keeper/token_logic_modules.go index 6272d33d3..3dba9136a 100644 --- a/x/tokenomics/keeper/token_logic_modules.go +++ b/x/tokenomics/keeper/token_logic_modules.go @@ -27,8 +27,10 @@ import ( var ( // Governance parameters for the TLMGlobalMint module - // TODO_BETA(@red-0ne): Make this a governance parameter and give it a non-zero value + tests. - MintPerClaimedTokenGlobalInflation = 0.1 + // TODO_BETA(@red-0ne, #732): Make this a governance parameter and give it a non-zero value + tests. + // GlobalInflationPerClaim is the percentage of the claim amount that is minted + // by TLMGlobalMint to reward the actors in the network. + GlobalInflationPerClaim = 0.1 ) const ( @@ -68,11 +70,20 @@ const ( // global governance parameters in order to reward the participants providing // services while keeping inflation in check. TLMGlobalMint + + // TLMGlobalMintReimbursementRequest is the token logic module that complements + // TLMGlobalMint to enable permissionless demand. + // In order to prevent self-dealing attacks, applications will be overcharged by + // the amount equal to global inflation, those funds will be sent to the DAO/PNF, + // and an event will be emitted to track and send reimbursements; managed offchain by PNF. + // TODO_POST_MAINNET: Introduce proper tokenomics based on the research done by @rawthil and @shane. + TLMGlobalMintReimbursementRequest ) var tokenLogicModuleStrings = [...]string{ "TLMRelayBurnEqualsMint", "TLMGlobalMint", + "TLMGlobalMintReimbursementRequest", } func (tlm TokenLogicModule) String() string { @@ -105,8 +116,9 @@ type TokenLogicModuleProcessor func( // tokenLogicModuleProcessorMap is a map of TLMs to their respective independent processors. var tokenLogicModuleProcessorMap = map[TokenLogicModule]TokenLogicModuleProcessor{ - TLMRelayBurnEqualsMint: Keeper.TokenLogicModuleRelayBurnEqualsMint, - TLMGlobalMint: Keeper.TokenLogicModuleGlobalMint, + TLMRelayBurnEqualsMint: Keeper.TokenLogicModuleRelayBurnEqualsMint, + TLMGlobalMint: Keeper.TokenLogicModuleGlobalMint, + TLMGlobalMintReimbursementRequest: Keeper.TokenLogicModuleGlobalMintReimbursementRequest, } func init() { @@ -115,8 +127,11 @@ func init() { panic("mint allocation percentages do not add to 1.0") } - // TODO_BETA(@red-0ne): Ensure that if `TLMGlobalMint` is present in the map, - // then TLMGlobalMintReimbursementRequest will need to be there too. + _, hasGlobalMintTLM := tokenLogicModuleProcessorMap[TLMGlobalMint] + _, hasGlobalMintReimbursementRequestTLM := tokenLogicModuleProcessorMap[TLMGlobalMintReimbursementRequest] + if hasGlobalMintTLM != hasGlobalMintReimbursementRequestTLM { + panic("TLMGlobalMint and TLMGlobalMintReimbursementRequest must be (de-)activated together") + } } // ProcessTokenLogicModules is the entrypoint for all TLM processing. @@ -131,6 +146,7 @@ func init() { func (k Keeper) ProcessTokenLogicModules( ctx context.Context, claim *prooftypes.Claim, + applicationInitialStake cosmostypes.Coin, ) (err error) { logger := k.Logger().With("method", "ProcessTokenLogicModules") @@ -276,7 +292,7 @@ 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) + actualSettlementCoin, err := k.ensureClaimAmountLimits(ctx, logger, &application, &supplier, claimSettlementCoin, applicationInitialStake) if err != nil { return err } @@ -404,14 +420,13 @@ func (k Keeper) TokenLogicModuleGlobalMint( ) error { logger := k.Logger().With("method", "TokenLogicModuleGlobalMint") - if MintPerClaimedTokenGlobalInflation == 0 { - // TODO_BETA(@red-0ne): Make sure to skip GMRR TLM in this case as well. + if GlobalInflationPerClaim == 0 { logger.Warn("global inflation is set to zero. Skipping Global Mint TLM.") return nil } // Determine how much new uPOKT to mint based on global inflation - newMintCoin, newMintAmtFloat := calculateGlobalPerClaimMintInflationFromSettlementAmount(settlementCoin) + newMintCoin, newMintAmtFloat := CalculateGlobalPerClaimMintInflationFromSettlementAmount(settlementCoin) if newMintCoin.Amount.Int64() == 0 { return tokenomicstypes.ErrTokenomicsMintAmountZero } @@ -481,6 +496,107 @@ func (k Keeper) TokenLogicModuleGlobalMint( return nil } +// TokenLogicModuleGlobalMintReimbursementRequest processes the business logic +// for the GlobalMintReimbursementRequest TLM. +func (k Keeper) TokenLogicModuleGlobalMintReimbursementRequest( + ctx context.Context, + service *sharedtypes.Service, + sessionHeader *sessiontypes.SessionHeader, + application *apptypes.Application, + supplier *sharedtypes.Supplier, + actualSettlementCoin cosmostypes.Coin, + relayMiningDifficulty *servicetypes.RelayMiningDifficulty, +) error { + logger := k.Logger().With("method", "TokenLogicModuleGlobalMintReimbursementRequest") + + // Do not process the reimbursement request if there is no global inflation. + if GlobalInflationPerClaim == 0 { + logger.Warn("global inflation is set to zero. Skipping Global Mint Reimbursement Request TLM.") + return nil + } + + // Determine how much new uPOKT to mint based on global inflation + newMintCoin, _ := CalculateGlobalPerClaimMintInflationFromSettlementAmount(actualSettlementCoin) + if newMintCoin.Amount.Int64() == 0 { + return tokenomicstypes.ErrTokenomicsMintAmountZero + } + + newAppStake, err := application.Stake.SafeSub(newMintCoin) + // This should THEORETICALLY NEVER fall below zero. + // `ensureClaimAmountLimits` should have already checked and adjusted the settlement + // amount so that the application stake covers the global inflation. + // TODO_POST_MAINNET: Consider removing this since it should never happen just to simplify the code + if err != nil { + return err + } + application.Stake = &newAppStake + logger.Info(fmt.Sprintf("updated application %q stake to %s", application.Address, newAppStake)) + + globalInflationMintedCoinsForClaim := sdk.NewCoins(newMintCoin) + + // Send the global per claim mint inflation uPOKT from the tokenomics module + // account to PNF/DAO. + daoAccountAddr, err := cosmostypes.AccAddressFromBech32(k.GetAuthority()) + if err != nil { + return tokenomicstypes.ErrTokenomicsApplicationReimbursementRequestFailed.Wrapf( + "getting PNF/DAO address: %v", + err, + ) + } + + // Send the global per claim mint inflation uPOKT from the application module + // account to the tokenomics module account as an intermediary step. + if err := k.bankKeeper.SendCoinsFromModuleToModule( + ctx, apptypes.ModuleName, tokenomicstypes.ModuleName, globalInflationMintedCoinsForClaim, + ); err != nil { + return tokenomicstypes.ErrTokenomicsApplicationReimbursementRequestFailed.Wrapf( + "sending %s from the application module account to the tokenomics module account: %v", + newMintCoin, err, + ) + } + logger.Info(fmt.Sprintf( + "sent (%s) from the application module account to the tokenomics module account", + newMintCoin, + )) + + // Send the global per claim mint inflation uPOKT from the tokenomics module + // for second order economic effects. + // See: https://discord.com/channels/824324475256438814/997192534168182905/1299372745632649408 + if err := k.bankKeeper.SendCoinsFromModuleToAccount( + ctx, tokenomicstypes.ModuleName, daoAccountAddr, globalInflationMintedCoinsForClaim, + ); err != nil { + return tokenomicstypes.ErrTokenomicsApplicationReimbursementRequestFailed.Wrapf( + "sending %s from the tokenomics module account to the PNF/DAO account: %v", + newMintCoin, err, + ) + } + + // Prepare and emit the event for the application that'll required reimbursement. + // Recall that it is being overcharged to compoensate for global inflation while + // preventing self-dealing attacks. + reimbursementRequestEvent := &tokenomicstypes.EventApplicationReimbursementRequest{ + ApplicationAddr: application.Address, + SupplierOperatorAddr: supplier.OperatorAddress, + SupplierOwnerAddr: supplier.OwnerAddress, + ServiceId: service.Id, + SessionId: sessionHeader.SessionId, + Amount: &newMintCoin, + } + + eventManger := cosmostypes.UnwrapSDKContext(ctx).EventManager() + if err := eventManger.EmitTypedEvent(reimbursementRequestEvent); err != nil { + err = tokenomicstypes.ErrTokenomicsEmittingEventFailed.Wrapf( + "(%+v): %s", + reimbursementRequestEvent, err, + ) + + logger.Error(err.Error()) + return err + } + + return nil +} + func (k Keeper) ensureMintedCoinsAreDistributed( logger log.Logger, appCoin, supplierCoin, daoCoin, serviceCoin, proposerCoin, newMintCoin cosmostypes.Coin, @@ -560,41 +676,76 @@ func (k Keeper) ensureClaimAmountLimits( application *apptypes.Application, supplier *sharedtypes.Supplier, claimSettlementCoin cosmostypes.Coin, + initialApplicationStake cosmostypes.Coin, ) ( actualSettlementCoins cosmostypes.Coin, err error, ) { logger = logger.With("helper", "ensureClaimAmountLimits") - // TODO_BETA(@red-0ne): The application stake gets reduced with every claim - // settlement. Relay miners use the appStake at the beginning of a session to determine - // the maximum amount they can claim. We need to somehow access and propagate this - // value (via context?) so it is the same for all TLM processors for each claim. - // Note that this will also need to incorporate MintPerClaimGlobalInflation because - // applications are being overcharged by that amount in the meantime. Whatever the - // solution and implementation ends up being, make sure to KISS. - appStake := application.GetStake() - - // Determine the max claimable amount for the supplier based on the application's stake in this session. - maxClaimableCoin := sdk.NewCoin(volatile.DenomuPOKT, appStake.Amount.Quo(math.NewInt(sessionkeeper.NumSupplierPerSession))) - - if maxClaimableCoin.Amount.GTE(claimSettlementCoin.Amount) { + // 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. + appStake := initialApplicationStake + + // The application should have enough stake to cover for the global mint reimbursement. + // This amount is deducted from the maximum claimable amount. + globalInflationCoin, _ := CalculateGlobalPerClaimMintInflationFromSettlementAmount(claimSettlementCoin) + globalInflationAmt := globalInflationCoin.Amount + 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)) + maxClaimSettlementAmt := supplierAppStakeToMaxSettlementAmount(maxClaimableAmt) + + // Check if the claimable amount is capped by the max claimable amount. + // As per the Relay Mining paper, the Supplier claim MUST NOT exceed the application's + // allocated stake. If it does, the claim is capped by the application's allocated stake + // and the supplier is effectively "overserviced". + if minRequiredAppStakeAmt.GT(maxClaimableAmt) { + logger.Warn(fmt.Sprintf("Claim by supplier %s EXCEEDS LIMITS for application %s. Max claimable amount < Claim amount: %v < %v", + supplier.GetOperatorAddress(), application.GetAddress(), maxClaimableAmt, claimSettlementCoin.Amount)) + + minRequiredAppStakeAmt = maxClaimableAmt + maxClaimSettlementAmt = supplierAppStakeToMaxSettlementAmount(minRequiredAppStakeAmt) + } + + // Nominal case: The claimable amount is within the limits set by Relay Mining. + if claimSettlementCoin.Amount.LTE(maxClaimSettlementAmt) { logger.Info(fmt.Sprintf("Claim by supplier %s IS WITHIN LIMITS of servicing application %s. Max claimable amount >= Claim amount: %v >= %v", - supplier.GetOperatorAddress(), application.GetAddress(), maxClaimableCoin, claimSettlementCoin.Amount)) + supplier.GetOperatorAddress(), application.GetAddress(), maxClaimSettlementAmt, claimSettlementCoin.Amount)) return claimSettlementCoin, nil } - logger.Warn(fmt.Sprintf("Claim by supplier %s EXCEEDS LIMITS for application %s. Max claimable amount < Claim amount: %v < %v", - supplier.GetOperatorAddress(), application.GetAddress(), maxClaimableCoin, claimSettlementCoin.Amount)) - - // Reduce the settlement amount if the application was over-serviced - actualSettlementCoins = maxClaimableCoin + // Claimable amount is capped by the max claimable amount or the application allocated stake. + // Determine the max claimable amount for the supplier based on the application's stake in this session. + maxClaimableCoin := sdk.NewCoin(volatile.DenomuPOKT, maxClaimSettlementAmt) // Prepare and emit the event for the application being overserviced applicationOverservicedEvent := &tokenomicstypes.EventApplicationOverserviced{ - ApplicationAddr: application.Address, + ApplicationAddr: application.GetAddress(), SupplierOperatorAddr: supplier.GetOperatorAddress(), - ExpectedBurn: &claimSettlementCoin, + ExpectedBurn: &totalClaimedCoin, EffectiveBurn: &maxClaimableCoin, } eventManager := cosmostypes.UnwrapSDKContext(ctx).EventManager() @@ -603,7 +754,7 @@ func (k Keeper) ensureClaimAmountLimits( tokenomicstypes.ErrTokenomicsEmittingEventFailed.Wrapf("error emitting event %v", applicationOverservicedEvent) } - return actualSettlementCoins, nil + return maxClaimableCoin, nil } // distributeSupplierRewardsToShareHolders distributes the supplier rewards to its @@ -662,14 +813,15 @@ func (k Keeper) distributeSupplierRewardsToShareHolders( return nil } -// calculateGlobalPerClaimMintInflationFromSettlementAmount calculates the amount +// CalculateGlobalPerClaimMintInflationFromSettlementAmount calculates the amount // of uPOKT to mint based on the global per claim inflation rate as a function of // the settlement amount for a particular claim(s) or session(s). -func calculateGlobalPerClaimMintInflationFromSettlementAmount(settlementCoin sdk.Coin) (sdk.Coin, big.Float) { +// DEV_NOTE: This function is publically exposed to be used in the tests. +func CalculateGlobalPerClaimMintInflationFromSettlementAmount(settlementCoin sdk.Coin) (sdk.Coin, big.Float) { // Determine how much new uPOKT to mint based on global per claim inflation. // TODO_MAINNET(@red-0ne): Consider using fixed point arithmetic for deterministic results. settlementAmtFloat := new(big.Float).SetUint64(settlementCoin.Amount.Uint64()) - newMintAmtFloat := new(big.Float).Mul(settlementAmtFloat, big.NewFloat(MintPerClaimedTokenGlobalInflation)) + newMintAmtFloat := new(big.Float).Mul(settlementAmtFloat, big.NewFloat(GlobalInflationPerClaim)) // DEV_NOTE: If new mint is less than 1 and more than 0, ceil it to 1 so that // we never expect to process a claim with 0 minted tokens. if newMintAmtFloat.Cmp(big.NewFloat(1)) < 0 && newMintAmtFloat.Cmp(big.NewFloat(0)) > 0 { @@ -680,6 +832,22 @@ func calculateGlobalPerClaimMintInflationFromSettlementAmount(settlementCoin sdk return mintAmtCoin, *newMintAmtFloat } +// supplierAppStakeToMaxSettlementAmount calculates the max amount of uPOKT the supplier +// can claim based on the stake allocated to the supplier and the global inflation +// allocation percentage. +// This is the inverse of CalculateGlobalPerClaimMintInflationFromSettlementAmount: +// stake = maxSettlementAmt + globalInflationAmt +// stake = maxSettlementAmt + (maxSettlementAmt * MintPerClaimedTokenGlobalInflation) +// stake = maxSettlementAmt * (1 + MintPerClaimedTokenGlobalInflation) +// maxSettlementAmt = stake / (1 + MintPerClaimedTokenGlobalInflation) +func supplierAppStakeToMaxSettlementAmount(stakeAmount math.Int) math.Int { + stakeAmountFloat := big.NewFloat(0).SetInt(stakeAmount.BigInt()) + maxSettlementAmountFloat := big.NewFloat(0).Quo(stakeAmountFloat, big.NewFloat(1+GlobalInflationPerClaim)) + + settlementAmount, _ := maxSettlementAmountFloat.Int(nil) + return math.NewIntFromBigInt(settlementAmount) +} + // calculateAllocationAmount does big float arithmetic to determine the absolute // amount from amountFloat based on the allocation percentage provided. // TODO_MAINNET(@red-0ne): Measure and limit the precision loss here. diff --git a/x/tokenomics/keeper/token_logic_modules_test.go b/x/tokenomics/keeper/token_logic_modules_test.go index 34267c9d9..db5aa8320 100644 --- a/x/tokenomics/keeper/token_logic_modules_test.go +++ b/x/tokenomics/keeper/token_logic_modules_test.go @@ -4,9 +4,10 @@ import ( "bytes" "context" "fmt" + "math" "testing" - "cosmossdk.io/math" + cosmosmath "cosmossdk.io/math" cosmostypes "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -42,8 +43,8 @@ func init() { func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { // Test Parameters - appInitialStake := apptypes.DefaultMinStake.Amount.Mul(math.NewInt(2)) - supplierInitialStake := math.NewInt(1000000) + appInitialStake := apptypes.DefaultMinStake.Amount.Mul(cosmosmath.NewInt(2)) + supplierInitialStake := cosmosmath.NewInt(1000000) supplierRevShareRatios := []float32{12.5, 37.5, 50} globalComputeUnitsToTokensMultiplier := uint64(1) serviceComputeUnitsPerRelay := uint64(1) @@ -56,7 +57,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { // Ensure the claim is within relay mining bounds numTokensClaimed := int64(numRelays * serviceComputeUnitsPerRelay * globalComputeUnitsToTokensMultiplier) - maxClaimableAmountPerSupplier := appInitialStake.Quo(math.NewInt(sessionkeeper.NumSupplierPerSession)) + maxClaimableAmountPerSupplier := appInitialStake.Quo(cosmosmath.NewInt(sessionkeeper.NumSupplierPerSession)) require.GreaterOrEqual(t, maxClaimableAmountPerSupplier.Int64(), numTokensClaimed) // Retrieve the app and supplier module addresses @@ -70,10 +71,10 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { 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. - prevInflationValue := tokenomicskeeper.MintPerClaimedTokenGlobalInflation - tokenomicskeeper.MintPerClaimedTokenGlobalInflation = 0 + prevInflationValue := tokenomicskeeper.GlobalInflationPerClaim + tokenomicskeeper.GlobalInflationPerClaim = 0 t.Cleanup(func() { - tokenomicskeeper.MintPerClaimedTokenGlobalInflation = prevInflationValue + tokenomicskeeper.GlobalInflationPerClaim = prevInflationValue }) // Add a new application with non-zero app stake end balance to assert against. @@ -118,7 +119,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { claim := prepareTestClaim(numRelays, service, &app, &supplier) // Process the token logic modules - err = keepers.ProcessTokenLogicModules(ctx, &claim) + err = keepers.ProcessTokenLogicModules(ctx, &claim, appStake) require.NoError(t, err) // Assert that `applicationAddress` account balance is *unchanged* @@ -126,7 +127,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { require.EqualValues(t, appStartBalance, appEndBalance) // Determine the expected app end stake amount and the expected app burn - appBurn := math.NewInt(numTokensClaimed) + appBurn := cosmosmath.NewInt(numTokensClaimed) expectedAppEndStakeAmount := appInitialStake.Sub(appBurn) // Assert that `applicationAddress` staked balance has decreased by the appropriate amount @@ -166,13 +167,13 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid(t *testing.T) { // DEV_NOTE: Most of the setup here is a copy-paste of TLMBurnEqualsMintValid // except that the application stake is calculated to explicitly be too low to // handle all the relays completed. -func TestProcessTokenLogicModules_TLMBurnEqualsMint_Invalid_SupplierExceedsMaxClaimableAmount(t *testing.T) { +func TestProcessTokenLogicModules_TLMBurnEqualsMint_Valid_SupplierExceedsMaxClaimableAmount(t *testing.T) { // Test Parameters globalComputeUnitsToTokensMultiplier := uint64(1) serviceComputeUnitsPerRelay := uint64(100) service := prepareTestService(serviceComputeUnitsPerRelay) numRelays := uint64(1000) // By a single supplier for application in this session - supplierInitialStake := math.NewInt(1000000) + supplierInitialStake := cosmosmath.NewInt(1000000) supplierRevShareRatios := []float32{12.5, 37.5, 50} // Prepare the keepers @@ -183,7 +184,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Invalid_SupplierExceedsMaxCl // 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 := math.NewInt(maxClaimableAmountPerSupplier*sessionkeeper.NumSupplierPerSession + 1) + appInitialStake := cosmosmath.NewInt(maxClaimableAmountPerSupplier*sessionkeeper.NumSupplierPerSession + 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 @@ -200,10 +201,10 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Invalid_SupplierExceedsMaxCl 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. - prevInflationValue := tokenomicskeeper.MintPerClaimedTokenGlobalInflation - tokenomicskeeper.MintPerClaimedTokenGlobalInflation = 0 + prevInflationValue := tokenomicskeeper.GlobalInflationPerClaim + tokenomicskeeper.GlobalInflationPerClaim = 0 t.Cleanup(func() { - tokenomicskeeper.MintPerClaimedTokenGlobalInflation = prevInflationValue + tokenomicskeeper.GlobalInflationPerClaim = prevInflationValue }) // Add a new application with non-zero app stake end balance to assert against. @@ -248,7 +249,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Invalid_SupplierExceedsMaxCl claim := prepareTestClaim(numRelays, service, &app, &supplier) // Process the token logic modules - err = keepers.ProcessTokenLogicModules(ctx, &claim) + err = keepers.ProcessTokenLogicModules(ctx, &claim, appStake) require.NoError(t, err) // Assert that `applicationAddress` account balance is *unchanged* @@ -256,7 +257,7 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Invalid_SupplierExceedsMaxCl require.EqualValues(t, appStartBalance, appEndBalance) // Determine the expected app end stake amount and the expected app burn - appBurn := math.NewInt(maxClaimableAmountPerSupplier) + appBurn := cosmosmath.NewInt(maxClaimableAmountPerSupplier) appBurnCoin := sdk.NewCoin(volatile.DenomuPOKT, appBurn) expectedAppEndStakeAmount := appInitialStake.Sub(appBurn) @@ -313,8 +314,8 @@ func TestProcessTokenLogicModules_TLMBurnEqualsMint_Invalid_SupplierExceedsMaxCl func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t *testing.T) { // Test Parameters - appInitialStake := apptypes.DefaultMinStake.Amount.Mul(math.NewInt(2)) - supplierInitialStake := math.NewInt(1000000) + appInitialStake := apptypes.DefaultMinStake.Amount.Mul(cosmosmath.NewInt(2)) + supplierInitialStake := cosmosmath.NewInt(1000000) supplierRevShareRatios := []float32{12.5, 37.5, 50} globalComputeUnitsToTokensMultiplier := uint64(1) serviceComputeUnitsPerRelay := uint64(1) @@ -383,7 +384,7 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t } // Process the token logic modules - err = keepers.ProcessTokenLogicModules(ctx, &claim) + err = keepers.ProcessTokenLogicModules(ctx, &claim, appStake) require.NoError(t, err) // Determine balances after inflation @@ -398,15 +399,16 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t } // Compute mint per actor - numTokensMinted := numTokensClaimed * tokenomicskeeper.MintPerClaimedTokenGlobalInflation - daoMint := math.NewInt(int64(numTokensMinted * tokenomicskeeper.MintAllocationDAO)) - propMint := math.NewInt(int64(numTokensMinted * tokenomicskeeper.MintAllocationProposer)) - serviceOwnerMint := math.NewInt(int64(numTokensMinted * tokenomicskeeper.MintAllocationSourceOwner)) - appMint := math.NewInt(int64(numTokensMinted * tokenomicskeeper.MintAllocationApplication)) + numTokensMinted := numTokensClaimed * tokenomicskeeper.GlobalInflationPerClaim + numTokensMintedInt := cosmosmath.NewIntFromUint64(uint64(numTokensMinted)) + daoMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicskeeper.MintAllocationDAO)) + propMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicskeeper.MintAllocationProposer)) + serviceOwnerMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicskeeper.MintAllocationSourceOwner)) + appMint := cosmosmath.NewInt(int64(numTokensMinted * tokenomicskeeper.MintAllocationApplication)) supplierMint := float32(numTokensMinted * tokenomicskeeper.MintAllocationSupplier) // Ensure the balance was increase be the appropriate amount - require.Equal(t, daoBalanceBefore.Amount.Add(daoMint), daoBalanceAfter.Amount) + require.Equal(t, daoBalanceBefore.Amount.Add(daoMint).Add(numTokensMintedInt), daoBalanceAfter.Amount) require.Equal(t, propBalanceBefore.Amount.Add(propMint), propBalanceAfter.Amount) require.Equal(t, serviceOwnerBalanceBefore.Amount.Add(serviceOwnerMint), serviceOwnerBalanceAfter.Amount) require.Equal(t, appBalanceBefore.Amount.Add(appMint), appBalanceAfter.Amount) @@ -416,12 +418,19 @@ func TestProcessTokenLogicModules_TLMGlobalMint_Valid_MintDistributionCorrect(t balanceAfter := supplierShareholderBalancesAfter[addr].Amount.Int64() mintShare := int64(supplierMint * revShare.RevSharePercentage / 100) rewardShare := int64(float32(numTokensClaimed) * revShare.RevSharePercentage / 100) - balanceIncrease := math.NewInt(mintShare + rewardShare) + 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 acceptableRoundingDelta := tokenomicskeeper.MintDistributionAllowableTolerancePercent * float64(balanceAfter) require.InDelta(t, expectedBalanceAfter, balanceAfter, acceptableRoundingDelta) } + + foundApp, appFound := keepers.GetApplication(ctx, appAddress) + require.True(t, appFound) + + appStakeAfter := foundApp.GetStake().Amount + numTokensClaimedInt := cosmosmath.NewIntFromUint64(uint64(numTokensClaimed)) + require.Equal(t, appInitialStake.Sub(numTokensMintedInt).Sub(numTokensClaimedInt), appStakeAfter) } func TestProcessTokenLogicModules_AppNotFound(t *testing.T) { @@ -443,7 +452,7 @@ func TestProcessTokenLogicModules_AppNotFound(t *testing.T) { } // Process the token logic modules - err := keeper.ProcessTokenLogicModules(ctx, &claim) + err := keeper.ProcessTokenLogicModules(ctx, &claim, uPOKTCoin(math.MaxInt)) require.Error(t, err) require.ErrorIs(t, err, tokenomicstypes.ErrTokenomicsApplicationNotFound) } @@ -466,7 +475,7 @@ func TestProcessTokenLogicModules_ServiceNotFound(t *testing.T) { } // Execute test function - err := keeper.ProcessTokenLogicModules(ctx, &claim) + err := keeper.ProcessTokenLogicModules(ctx, &claim, uPOKTCoin(math.MaxInt)) require.Error(t, err) require.ErrorIs(t, err, tokenomicstypes.ErrTokenomicsServiceNotFound) @@ -536,7 +545,7 @@ func TestProcessTokenLogicModules_InvalidRoot(t *testing.T) { claim.RootHash = smt.MerkleRoot(test.root[:]) // Execute test function - err := keeper.ProcessTokenLogicModules(ctx, &claim) + err := keeper.ProcessTokenLogicModules(ctx, &claim, uPOKTCoin(math.MaxInt)) // Assert the error if test.errExpected { @@ -626,7 +635,7 @@ func TestProcessTokenLogicModules_InvalidClaim(t *testing.T) { err = fmt.Errorf("panic occurred: %v", r) } }() - return keeper.ProcessTokenLogicModules(ctx, test.claim) + return keeper.ProcessTokenLogicModules(ctx, test.claim, uPOKTCoin(math.MaxInt)) }() // Assert the error @@ -640,6 +649,18 @@ func TestProcessTokenLogicModules_InvalidClaim(t *testing.T) { } } +func TestProcessTokenLogicModules_AppStakeInsufficientToCoverGlobalInflationAmount(t *testing.T) { + t.Skip("TODO_MAINNET(@red-0ne): Test application stake that is insufficient to cover the global inflation amount, for reimbursment and the max claim should scale down proportionally") +} + +func TestProcessTokenLogicModules_AppStakeTooLowRoundingToZero(t *testing.T) { + t.Skip("TODO_MAINNET(@red-0ne): Test application stake that is too low which results in stake/num_suppliers rounding down to zero") +} + +func TestProcessTokenLogicModules_AppStakeDropsBelowMinStakeAfterSession(t *testing.T) { + t.Skip("TODO_MAINNET(@red-0ne): Test that application stake being auto-unbonding after the stake drops below the required minimum when settling session accounting") +} + // prepareTestClaim uses the given number of relays and compute unit per relay in the // service provided to set up the test claim correctly. func prepareTestClaim( diff --git a/x/tokenomics/types/errors.go b/x/tokenomics/types/errors.go index 2d80c19ea..ce1e4595b 100644 --- a/x/tokenomics/types/errors.go +++ b/x/tokenomics/types/errors.go @@ -36,4 +36,5 @@ var ( ErrTokenomicsMintAmountZero = sdkerrors.Register(ModuleName, 1127, "mint amount cannot be zero") ErrTokenomicsTLMError = sdkerrors.Register(ModuleName, 1128, "failed to process TLM") ErrTokenomicsCalculation = sdkerrors.Register(ModuleName, 1129, "tokenomics calculation error") + ErrTokenomicsApplicationModuleSendFailed = sdkerrors.Register(ModuleName, 1130, "failed to send uPOKT from application module account") ) diff --git a/x/tokenomics/types/event.pb.go b/x/tokenomics/types/event.pb.go index 6f4278908..8570fd911 100644 --- a/x/tokenomics/types/event.pb.go +++ b/x/tokenomics/types/event.pb.go @@ -369,65 +369,153 @@ func (m *EventSupplierSlashed) GetSlashingAmount() *types1.Coin { return nil } +// EventApplicationReimbursementRequest is emitted when an application requests +// a reimbursement +type EventApplicationReimbursementRequest struct { + ApplicationAddr string `protobuf:"bytes,1,opt,name=application_addr,json=applicationAddr,proto3" json:"application_addr,omitempty"` + SupplierOperatorAddr string `protobuf:"bytes,2,opt,name=supplier_operator_addr,json=supplierOperatorAddr,proto3" json:"supplier_operator_addr,omitempty"` + SupplierOwnerAddr string `protobuf:"bytes,3,opt,name=supplier_owner_addr,json=supplierOwnerAddr,proto3" json:"supplier_owner_addr,omitempty"` + ServiceId string `protobuf:"bytes,4,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + SessionId string `protobuf:"bytes,5,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + Amount *types1.Coin `protobuf:"bytes,6,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *EventApplicationReimbursementRequest) Reset() { *m = EventApplicationReimbursementRequest{} } +func (m *EventApplicationReimbursementRequest) String() string { return proto.CompactTextString(m) } +func (*EventApplicationReimbursementRequest) ProtoMessage() {} +func (*EventApplicationReimbursementRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a78874bbf91a58c7, []int{4} +} +func (m *EventApplicationReimbursementRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventApplicationReimbursementRequest) 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 *EventApplicationReimbursementRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventApplicationReimbursementRequest.Merge(m, src) +} +func (m *EventApplicationReimbursementRequest) XXX_Size() int { + return m.Size() +} +func (m *EventApplicationReimbursementRequest) XXX_DiscardUnknown() { + xxx_messageInfo_EventApplicationReimbursementRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_EventApplicationReimbursementRequest proto.InternalMessageInfo + +func (m *EventApplicationReimbursementRequest) GetApplicationAddr() string { + if m != nil { + return m.ApplicationAddr + } + return "" +} + +func (m *EventApplicationReimbursementRequest) GetSupplierOperatorAddr() string { + if m != nil { + return m.SupplierOperatorAddr + } + return "" +} + +func (m *EventApplicationReimbursementRequest) GetSupplierOwnerAddr() string { + if m != nil { + return m.SupplierOwnerAddr + } + return "" +} + +func (m *EventApplicationReimbursementRequest) GetServiceId() string { + if m != nil { + return m.ServiceId + } + return "" +} + +func (m *EventApplicationReimbursementRequest) GetSessionId() string { + if m != nil { + return m.SessionId + } + return "" +} + +func (m *EventApplicationReimbursementRequest) GetAmount() *types1.Coin { + if m != nil { + return m.Amount + } + return nil +} + func init() { proto.RegisterEnum("poktroll.tokenomics.ClaimExpirationReason", ClaimExpirationReason_name, ClaimExpirationReason_value) proto.RegisterType((*EventClaimExpired)(nil), "poktroll.tokenomics.EventClaimExpired") proto.RegisterType((*EventClaimSettled)(nil), "poktroll.tokenomics.EventClaimSettled") proto.RegisterType((*EventApplicationOverserviced)(nil), "poktroll.tokenomics.EventApplicationOverserviced") proto.RegisterType((*EventSupplierSlashed)(nil), "poktroll.tokenomics.EventSupplierSlashed") + proto.RegisterType((*EventApplicationReimbursementRequest)(nil), "poktroll.tokenomics.EventApplicationReimbursementRequest") } func init() { proto.RegisterFile("poktroll/tokenomics/event.proto", fileDescriptor_a78874bbf91a58c7) } var fileDescriptor_a78874bbf91a58c7 = []byte{ - // 739 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0x4d, 0x53, 0xdb, 0x3a, - 0x14, 0x8d, 0x43, 0x60, 0x06, 0x3d, 0x12, 0x12, 0x3f, 0x60, 0x02, 0xef, 0x61, 0xf3, 0x58, 0xbc, - 0xa1, 0x4c, 0xb1, 0x07, 0xe8, 0x74, 0xd9, 0x69, 0x12, 0x42, 0xc7, 0x33, 0x6d, 0x12, 0x94, 0xd2, - 0x61, 0xba, 0xa8, 0xeb, 0xd8, 0x22, 0xb8, 0xc4, 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f, 0x89, 0xc0, 0x6c, 0x78, 0x03, 0xfe, 0xc7, 0xf5, 0x07, - 0xb8, 0xfe, 0x39, 0x09, 0xfe, 0x95, 0xae, 0x17, 0xc2, 0xb0, 0xe5, 0xbb, 0xf2, 0x63, 0xaa, 0xb6, - 0x11, 0x65, 0x88, 0xb6, 0x7d, 0x17, 0x79, 0xea, 0x23, 0x90, 0x75, 0x46, 0x29, 0xdb, 0xf1, 0x3c, - 0x2a, 0x7b, 0x61, 0x16, 0xce, 0x8f, 0xc5, 0x0b, 0x9e, 0x47, 0xd5, 0x27, 0x60, 0x89, 0x45, 0x22, - 0x86, 0xa8, 0x4d, 0x42, 0x44, 0x1d, 0x4e, 0x68, 0x4c, 0x48, 0x4a, 0xc2, 0xc2, 0x20, 0x5b, 0xed, - 0x27, 0x25, 0xeb, 0x19, 0x48, 0xa3, 0xb3, 0x10, 0xb9, 0xa2, 0x10, 0x8d, 0x88, 0x62, 0x69, 0xe0, - 0xa4, 0x43, 0xc1, 0xb9, 0x01, 0xbe, 0x18, 0x51, 0xac, 0x3e, 0x07, 0x19, 0x74, 0x7c, 0x8c, 0x5c, - 0xee, 0xb7, 0x51, 0x2c, 0x90, 0xba, 0x4f, 0x20, 0x3d, 0x24, 0x08, 0x85, 0xf5, 0xaf, 0x0a, 0x58, - 0x90, 0x35, 0xa8, 0xf7, 0xf7, 0x57, 0x6f, 0x39, 0xec, 0x04, 0x79, 0x13, 0x0e, 0xa4, 0x4c, 0x38, - 0xd0, 0x63, 0xa0, 0x4a, 0x7b, 0xe3, 0xbb, 0x33, 0x6e, 0x21, 0x26, 0x4b, 0x90, 0x82, 0x59, 0xe1, - 0x6d, 0x9c, 0x90, 0x0d, 0xc4, 0xd4, 0x22, 0x98, 0x67, 0x62, 0x39, 0x1f, 0x37, 0x6d, 0x27, 0x20, - 0x11, 0xe6, 0xf7, 0x17, 0x20, 0x33, 0x60, 0x14, 0x24, 0x61, 0xf3, 0x3d, 0x58, 0xbc, 0xf3, 0xe2, - 0x54, 0xff, 0x03, 0xab, 0xe5, 0xa3, 0x9a, 0x05, 0x0b, 0xaf, 0xad, 0x6a, 0xc5, 0x86, 0xe5, 0x42, - 0xbd, 0x5a, 0xb1, 0x0f, 0x2b, 0xf5, 0x5a, 0xb9, 0x64, 0xed, 0x5b, 0xe5, 0xbd, 0x6c, 0x42, 0xcd, - 0x81, 0x74, 0x0d, 0x56, 0xab, 0xfb, 0xf6, 0x2b, 0xab, 0x5e, 0xb7, 0x2a, 0x2f, 0xb2, 0xca, 0x28, - 0x64, 0x55, 0xde, 0x14, 0x5e, 0x5a, 0x7b, 0xd9, 0x64, 0xf1, 0xe0, 0x5b, 0x57, 0x53, 0x2e, 0xba, - 0x9a, 0x72, 0xd9, 0xd5, 0x94, 0xef, 0x5d, 0x4d, 0xf9, 0x72, 0xa5, 0x25, 0x2e, 0xae, 0xb4, 0xc4, - 0xe5, 0x95, 0x96, 0x78, 0xbb, 0xdb, 0xf4, 0xf9, 0x49, 0xd4, 0x30, 0x5c, 0x12, 0x98, 0xa2, 0xab, - 0xb6, 0x30, 0xe2, 0x9f, 0x08, 0x3d, 0x35, 0x87, 0x0f, 0xcd, 0xd9, 0xf8, 0xb3, 0x26, 0xdf, 0x9b, - 0xc6, 0x8c, 0x7c, 0x70, 0x76, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x71, 0x30, 0x08, 0xfa, - 0x06, 0x00, 0x00, + // 823 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcf, 0x6f, 0xdb, 0x36, + 0x14, 0x8e, 0x9c, 0x34, 0x80, 0xb9, 0xc6, 0xb5, 0xd5, 0xa4, 0x70, 0xb3, 0x45, 0xca, 0x8c, 0x61, + 0xc8, 0x8a, 0x55, 0x42, 0xda, 0x61, 0xc7, 0x61, 0xb6, 0xeb, 0x0e, 0x02, 0x36, 0xdb, 0xa5, 0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f, 0x0f, 0x88, 0x7c, 0x91, 0xf6, 0x9d, 0x90, 0xc5, + 0xae, 0xba, 0x80, 0x0f, 0x29, 0xc8, 0x57, 0x8c, 0x9f, 0xb9, 0xf3, 0x37, 0xf9, 0x7c, 0xf9, 0x1f, + 0x80, 0x7e, 0x9a, 0xfb, 0xdb, 0xfa, 0x6d, 0x7e, 0xfc, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8b, + 0xd5, 0xac, 0x44, 0x25, 0x08, 0x00, 0x00, } func (m *EventClaimExpired) Marshal() (dAtA []byte, err error) { @@ -672,6 +760,76 @@ func (m *EventSupplierSlashed) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *EventApplicationReimbursementRequest) 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 *EventApplicationReimbursementRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventApplicationReimbursementRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Amount != nil { + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if len(m.SessionId) > 0 { + i -= len(m.SessionId) + copy(dAtA[i:], m.SessionId) + i = encodeVarintEvent(dAtA, i, uint64(len(m.SessionId))) + i-- + dAtA[i] = 0x2a + } + if len(m.ServiceId) > 0 { + i -= len(m.ServiceId) + copy(dAtA[i:], m.ServiceId) + i = encodeVarintEvent(dAtA, i, uint64(len(m.ServiceId))) + i-- + dAtA[i] = 0x22 + } + if len(m.SupplierOwnerAddr) > 0 { + i -= len(m.SupplierOwnerAddr) + copy(dAtA[i:], m.SupplierOwnerAddr) + i = encodeVarintEvent(dAtA, i, uint64(len(m.SupplierOwnerAddr))) + i-- + dAtA[i] = 0x1a + } + if len(m.SupplierOperatorAddr) > 0 { + i -= len(m.SupplierOperatorAddr) + copy(dAtA[i:], m.SupplierOperatorAddr) + i = encodeVarintEvent(dAtA, i, uint64(len(m.SupplierOperatorAddr))) + i-- + dAtA[i] = 0x12 + } + if len(m.ApplicationAddr) > 0 { + i -= len(m.ApplicationAddr) + copy(dAtA[i:], m.ApplicationAddr) + i = encodeVarintEvent(dAtA, i, uint64(len(m.ApplicationAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { offset -= sovEvent(v) base := offset @@ -786,6 +944,39 @@ func (m *EventSupplierSlashed) Size() (n int) { return n } +func (m *EventApplicationReimbursementRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ApplicationAddr) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.SupplierOperatorAddr) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.SupplierOwnerAddr) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.ServiceId) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.SessionId) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + if m.Amount != nil { + l = m.Amount.Size() + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + func sovEvent(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1511,6 +1702,252 @@ func (m *EventSupplierSlashed) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventApplicationReimbursementRequest) 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 ErrIntOverflowEvent + } + 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: EventApplicationReimbursementRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventApplicationReimbursementRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ApplicationAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ApplicationAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SupplierOperatorAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SupplierOperatorAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SupplierOwnerAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SupplierOwnerAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ServiceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ServiceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SessionId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SessionId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Amount == nil { + m.Amount = &types1.Coin{} + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEvent(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0