diff --git a/api/poktroll/tokenomics/event.pulsar.go b/api/poktroll/tokenomics/event.pulsar.go index ca0ebfa25..8ea69eae8 100644 --- a/api/poktroll/tokenomics/event.pulsar.go +++ b/api/poktroll/tokenomics/event.pulsar.go @@ -2,6 +2,7 @@ package tokenomics import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" proof "github.com/pokt-network/poktroll/api/poktroll/proof" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" @@ -1768,6 +1769,584 @@ func (x *fastReflection_EventRelayMiningDifficultyUpdated) ProtoMethods() *proto } } +var ( + md_EventApplicationOverserviced protoreflect.MessageDescriptor + fd_EventApplicationOverserviced_application_addr protoreflect.FieldDescriptor + fd_EventApplicationOverserviced_expected_burn protoreflect.FieldDescriptor + fd_EventApplicationOverserviced_effective_burn protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_tokenomics_event_proto_init() + md_EventApplicationOverserviced = File_poktroll_tokenomics_event_proto.Messages().ByName("EventApplicationOverserviced") + fd_EventApplicationOverserviced_application_addr = md_EventApplicationOverserviced.Fields().ByName("application_addr") + fd_EventApplicationOverserviced_expected_burn = md_EventApplicationOverserviced.Fields().ByName("expected_burn") + fd_EventApplicationOverserviced_effective_burn = md_EventApplicationOverserviced.Fields().ByName("effective_burn") +} + +var _ protoreflect.Message = (*fastReflection_EventApplicationOverserviced)(nil) + +type fastReflection_EventApplicationOverserviced EventApplicationOverserviced + +func (x *EventApplicationOverserviced) ProtoReflect() protoreflect.Message { + return (*fastReflection_EventApplicationOverserviced)(x) +} + +func (x *EventApplicationOverserviced) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_tokenomics_event_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_EventApplicationOverserviced_messageType fastReflection_EventApplicationOverserviced_messageType +var _ protoreflect.MessageType = fastReflection_EventApplicationOverserviced_messageType{} + +type fastReflection_EventApplicationOverserviced_messageType struct{} + +func (x fastReflection_EventApplicationOverserviced_messageType) Zero() protoreflect.Message { + return (*fastReflection_EventApplicationOverserviced)(nil) +} +func (x fastReflection_EventApplicationOverserviced_messageType) New() protoreflect.Message { + return new(fastReflection_EventApplicationOverserviced) +} +func (x fastReflection_EventApplicationOverserviced_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_EventApplicationOverserviced +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_EventApplicationOverserviced) Descriptor() protoreflect.MessageDescriptor { + return md_EventApplicationOverserviced +} + +// 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_EventApplicationOverserviced) Type() protoreflect.MessageType { + return _fastReflection_EventApplicationOverserviced_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_EventApplicationOverserviced) New() protoreflect.Message { + return new(fastReflection_EventApplicationOverserviced) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_EventApplicationOverserviced) Interface() protoreflect.ProtoMessage { + return (*EventApplicationOverserviced)(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_EventApplicationOverserviced) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ApplicationAddr != "" { + value := protoreflect.ValueOfString(x.ApplicationAddr) + if !f(fd_EventApplicationOverserviced_application_addr, value) { + return + } + } + if x.ExpectedBurn != nil { + value := protoreflect.ValueOfMessage(x.ExpectedBurn.ProtoReflect()) + if !f(fd_EventApplicationOverserviced_expected_burn, value) { + return + } + } + if x.EffectiveBurn != nil { + value := protoreflect.ValueOfMessage(x.EffectiveBurn.ProtoReflect()) + if !f(fd_EventApplicationOverserviced_effective_burn, 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_EventApplicationOverserviced) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationOverserviced.application_addr": + return x.ApplicationAddr != "" + case "poktroll.tokenomics.EventApplicationOverserviced.expected_burn": + return x.ExpectedBurn != nil + case "poktroll.tokenomics.EventApplicationOverserviced.effective_burn": + return x.EffectiveBurn != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationOverserviced")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationOverserviced 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_EventApplicationOverserviced) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationOverserviced.application_addr": + x.ApplicationAddr = "" + case "poktroll.tokenomics.EventApplicationOverserviced.expected_burn": + x.ExpectedBurn = nil + case "poktroll.tokenomics.EventApplicationOverserviced.effective_burn": + x.EffectiveBurn = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationOverserviced")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationOverserviced 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_EventApplicationOverserviced) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.tokenomics.EventApplicationOverserviced.application_addr": + value := x.ApplicationAddr + return protoreflect.ValueOfString(value) + case "poktroll.tokenomics.EventApplicationOverserviced.expected_burn": + value := x.ExpectedBurn + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.tokenomics.EventApplicationOverserviced.effective_burn": + value := x.EffectiveBurn + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationOverserviced")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationOverserviced 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_EventApplicationOverserviced) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationOverserviced.application_addr": + x.ApplicationAddr = value.Interface().(string) + case "poktroll.tokenomics.EventApplicationOverserviced.expected_burn": + x.ExpectedBurn = value.Message().Interface().(*v1beta1.Coin) + case "poktroll.tokenomics.EventApplicationOverserviced.effective_burn": + x.EffectiveBurn = value.Message().Interface().(*v1beta1.Coin) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationOverserviced")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationOverserviced 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_EventApplicationOverserviced) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationOverserviced.expected_burn": + if x.ExpectedBurn == nil { + x.ExpectedBurn = new(v1beta1.Coin) + } + return protoreflect.ValueOfMessage(x.ExpectedBurn.ProtoReflect()) + case "poktroll.tokenomics.EventApplicationOverserviced.effective_burn": + if x.EffectiveBurn == nil { + x.EffectiveBurn = new(v1beta1.Coin) + } + return protoreflect.ValueOfMessage(x.EffectiveBurn.ProtoReflect()) + case "poktroll.tokenomics.EventApplicationOverserviced.application_addr": + panic(fmt.Errorf("field application_addr of message poktroll.tokenomics.EventApplicationOverserviced is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.tokenomics.EventApplicationOverserviced")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationOverserviced 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_EventApplicationOverserviced) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.tokenomics.EventApplicationOverserviced.application_addr": + return protoreflect.ValueOfString("") + case "poktroll.tokenomics.EventApplicationOverserviced.expected_burn": + m := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.tokenomics.EventApplicationOverserviced.effective_burn": + 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.EventApplicationOverserviced")) + } + panic(fmt.Errorf("message poktroll.tokenomics.EventApplicationOverserviced 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_EventApplicationOverserviced) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.tokenomics.EventApplicationOverserviced", 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_EventApplicationOverserviced) 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_EventApplicationOverserviced) 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_EventApplicationOverserviced) 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_EventApplicationOverserviced) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*EventApplicationOverserviced) + 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)) + } + if x.ExpectedBurn != nil { + l = options.Size(x.ExpectedBurn) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.EffectiveBurn != nil { + l = options.Size(x.EffectiveBurn) + 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().(*EventApplicationOverserviced) + 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.EffectiveBurn != nil { + encoded, err := options.Marshal(x.EffectiveBurn) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1a + } + if x.ExpectedBurn != nil { + encoded, err := options.Marshal(x.ExpectedBurn) + 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] = 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().(*EventApplicationOverserviced) + 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: EventApplicationOverserviced: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EventApplicationOverserviced: 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 ExpectedBurn", 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.ExpectedBurn == nil { + x.ExpectedBurn = &v1beta1.Coin{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.ExpectedBurn); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field EffectiveBurn", 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.EffectiveBurn == nil { + x.EffectiveBurn = &v1beta1.Coin{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.EffectiveBurn); 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 @@ -1965,6 +2544,59 @@ func (x *EventRelayMiningDifficultyUpdated) GetNewNumRelaysEma() uint64 { return 0 } +// EventApplicationOverserviced is emitted when an application has less stake +// than the expected burn. +type EventApplicationOverserviced 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"` + ExpectedBurn *v1beta1.Coin `protobuf:"bytes,2,opt,name=expected_burn,json=expectedBurn,proto3" json:"expected_burn,omitempty"` + EffectiveBurn *v1beta1.Coin `protobuf:"bytes,3,opt,name=effective_burn,json=effectiveBurn,proto3" json:"effective_burn,omitempty"` +} + +func (x *EventApplicationOverserviced) Reset() { + *x = EventApplicationOverserviced{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_tokenomics_event_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EventApplicationOverserviced) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventApplicationOverserviced) ProtoMessage() {} + +// Deprecated: Use EventApplicationOverserviced.ProtoReflect.Descriptor instead. +func (*EventApplicationOverserviced) Descriptor() ([]byte, []int) { + return file_poktroll_tokenomics_event_proto_rawDescGZIP(), []int{3} +} + +func (x *EventApplicationOverserviced) GetApplicationAddr() string { + if x != nil { + return x.ApplicationAddr + } + return "" +} + +func (x *EventApplicationOverserviced) GetExpectedBurn() *v1beta1.Coin { + if x != nil { + return x.ExpectedBurn + } + return nil +} + +func (x *EventApplicationOverserviced) GetEffectiveBurn() *v1beta1.Coin { + if x != nil { + return x.EffectiveBurn + } + return nil +} + var File_poktroll_tokenomics_event_proto protoreflect.FileDescriptor var file_poktroll_tokenomics_event_proto_rawDesc = []byte{ @@ -1972,7 +2604,9 @@ var file_poktroll_tokenomics_event_proto_rawDesc = []byte{ 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x6f, 0x6d, 0x69, 0x63, 0x73, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x70, 0x6f, + 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x2f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, @@ -2025,19 +2659,32 @@ var file_poktroll_tokenomics_event_proto_rawDesc = []byte{ 0x65, 0x6c, 0x61, 0x79, 0x73, 0x45, 0x6d, 0x61, 0x12, 0x2b, 0x0a, 0x12, 0x6e, 0x65, 0x77, 0x5f, 0x6e, 0x75, 0x6d, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x5f, 0x65, 0x6d, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x6e, 0x65, 0x77, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x6c, 0x61, - 0x79, 0x73, 0x45, 0x6d, 0x61, 0x42, 0xb8, 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, + 0x79, 0x73, 0x45, 0x6d, 0x61, 0x22, 0xcb, 0x01, 0x0a, 0x1c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, + 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x64, 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, 0x3e, 0x0a, 0x0d, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x62, 0x75, + 0x72, 0x6e, 0x18, 0x02, 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, 0x0c, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x42, 0x75, 0x72, + 0x6e, 0x12, 0x40, 0x0a, 0x0e, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x62, + 0x75, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x43, 0x6f, 0x69, 0x6e, 0x52, 0x0d, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x42, + 0x75, 0x72, 0x6e, 0x42, 0xb8, 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 ( @@ -2052,23 +2699,27 @@ func file_poktroll_tokenomics_event_proto_rawDescGZIP() []byte { return file_poktroll_tokenomics_event_proto_rawDescData } -var file_poktroll_tokenomics_event_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_poktroll_tokenomics_event_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_poktroll_tokenomics_event_proto_goTypes = []interface{}{ (*EventClaimExpired)(nil), // 0: poktroll.tokenomics.EventClaimExpired (*EventClaimSettled)(nil), // 1: poktroll.tokenomics.EventClaimSettled (*EventRelayMiningDifficultyUpdated)(nil), // 2: poktroll.tokenomics.EventRelayMiningDifficultyUpdated - (*proof.Claim)(nil), // 3: poktroll.proof.Claim - (proof.ProofRequirementReason)(0), // 4: poktroll.proof.ProofRequirementReason + (*EventApplicationOverserviced)(nil), // 3: poktroll.tokenomics.EventApplicationOverserviced + (*proof.Claim)(nil), // 4: poktroll.proof.Claim + (proof.ProofRequirementReason)(0), // 5: poktroll.proof.ProofRequirementReason + (*v1beta1.Coin)(nil), // 6: cosmos.base.v1beta1.Coin } var file_poktroll_tokenomics_event_proto_depIdxs = []int32{ - 3, // 0: poktroll.tokenomics.EventClaimExpired.claim:type_name -> poktroll.proof.Claim - 3, // 1: poktroll.tokenomics.EventClaimSettled.claim:type_name -> poktroll.proof.Claim - 4, // 2: poktroll.tokenomics.EventClaimSettled.proof_requirement:type_name -> poktroll.proof.ProofRequirementReason - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 4, // 0: poktroll.tokenomics.EventClaimExpired.claim:type_name -> poktroll.proof.Claim + 4, // 1: poktroll.tokenomics.EventClaimSettled.claim:type_name -> poktroll.proof.Claim + 5, // 2: poktroll.tokenomics.EventClaimSettled.proof_requirement:type_name -> poktroll.proof.ProofRequirementReason + 6, // 3: poktroll.tokenomics.EventApplicationOverserviced.expected_burn:type_name -> cosmos.base.v1beta1.Coin + 6, // 4: poktroll.tokenomics.EventApplicationOverserviced.effective_burn:type_name -> cosmos.base.v1beta1.Coin + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_poktroll_tokenomics_event_proto_init() } @@ -2113,6 +2764,18 @@ func file_poktroll_tokenomics_event_proto_init() { return nil } } + file_poktroll_tokenomics_event_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EventApplicationOverserviced); 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{ @@ -2120,7 +2783,7 @@ func file_poktroll_tokenomics_event_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_poktroll_tokenomics_event_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/config.yml b/config.yml index 23ab20d44..fe52ad944 100644 --- a/config.yml +++ b/config.yml @@ -183,6 +183,9 @@ genesis: service: params: add_service_fee: "1000000000" + serviceList: + - id: anvil + name: "" proof: params: proof_request_probability: "0.25" diff --git a/localnet/poktrolld/config/supplier1_stake_config.yaml b/localnet/poktrolld/config/supplier1_stake_config.yaml index ca2e931f2..91978a6e7 100644 --- a/localnet/poktrolld/config/supplier1_stake_config.yaml +++ b/localnet/poktrolld/config/supplier1_stake_config.yaml @@ -2,10 +2,6 @@ # so that the stake command causes a state change. stake_amount: 1000069upokt services: - - service_id: svc1 - endpoints: - - publicly_exposed_url: http://localhost:8081 - rpc_type: JSON_RPC # The endpoint URL for the Anvil service is provided via the RelayMiner. # The RelayMiner acts as a proxy, forwarding requests to the actual Anvil data node behind it. # This setup allows for flexible and dynamic service provisioning within the network. diff --git a/proto/poktroll/tokenomics/event.proto b/proto/poktroll/tokenomics/event.proto index 2652f330e..f45cd6389 100644 --- a/proto/poktroll/tokenomics/event.proto +++ b/proto/poktroll/tokenomics/event.proto @@ -4,6 +4,7 @@ package poktroll.tokenomics; option go_package = "github.com/pokt-network/poktroll/x/tokenomics/types"; import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "poktroll/proof/claim.proto"; import "poktroll/proof/requirement.proto"; @@ -34,3 +35,11 @@ message EventRelayMiningDifficultyUpdated { uint64 prev_num_relays_ema = 4; uint64 new_num_relays_ema = 5; } + +// EventApplicationOverserviced is emitted when an application has less stake +// than the expected burn. +message EventApplicationOverserviced { + string application_addr = 1; + cosmos.base.v1beta1.Coin expected_burn = 2; + cosmos.base.v1beta1.Coin effective_burn = 3; +} diff --git a/testutil/integration/app.go b/testutil/integration/app.go index 05f036e69..76852d661 100644 --- a/testutil/integration/app.go +++ b/testutil/integration/app.go @@ -338,12 +338,14 @@ func NewCompleteIntegrationApp(t *testing.T) *App { logger, authority.String(), bankKeeper, + serviceKeeper, ) supplierModule := supplier.NewAppModule( cdc, supplierKeeper, accountKeeper, bankKeeper, + serviceKeeper, ) // Prepare the session keeper and module diff --git a/testutil/keeper/proof.go b/testutil/keeper/proof.go index 35ab490db..03ea7b4b2 100644 --- a/testutil/keeper/proof.go +++ b/testutil/keeper/proof.go @@ -28,6 +28,7 @@ import ( applicationmocks "github.com/pokt-network/poktroll/testutil/application/mocks" gatewaymocks "github.com/pokt-network/poktroll/testutil/gateway/mocks" "github.com/pokt-network/poktroll/testutil/proof/mocks" + servicemocks "github.com/pokt-network/poktroll/testutil/service/mocks" sessionmocks "github.com/pokt-network/poktroll/testutil/session/mocks" suppliermocks "github.com/pokt-network/poktroll/testutil/supplier/mocks" appkeeper "github.com/pokt-network/poktroll/x/application/keeper" @@ -37,6 +38,8 @@ import ( "github.com/pokt-network/poktroll/x/proof/keeper" "github.com/pokt-network/poktroll/x/proof/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" + servicekeeper "github.com/pokt-network/poktroll/x/service/keeper" + servicetypes "github.com/pokt-network/poktroll/x/service/types" sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" sharedkeeper "github.com/pokt-network/poktroll/x/shared/keeper" @@ -118,6 +121,7 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul gatewaytypes.StoreKey, authtypes.StoreKey, sharedtypes.StoreKey, + servicetypes.StoreKey, ) // Construct a multistore & mount store keys for each keeper that will interact with the state store. @@ -179,6 +183,15 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul ) require.NoError(t, appKeeper.SetParams(ctx, apptypes.DefaultParams())) + // Construct a service keeper need by the supplier keeper. + serviceKeeper := servicekeeper.NewKeeper( + cdc, + runtime.NewKVStoreService(keys[types.StoreKey]), + log.NewNopLogger(), + authority.String(), + servicemocks.NewMockBankKeeper(ctrl), + ) + // Construct a real supplier keeper to add suppliers to sessions. supplierKeeper := supplierkeeper.NewKeeper( cdc, @@ -186,6 +199,7 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul log.NewNopLogger(), authority.String(), suppliermocks.NewMockBankKeeper(ctrl), + serviceKeeper, ) require.NoError(t, supplierKeeper.SetParams(ctx, suppliertypes.DefaultParams())) diff --git a/testutil/keeper/supplier.go b/testutil/keeper/supplier.go index 6f502a316..6f8efb086 100644 --- a/testutil/keeper/supplier.go +++ b/testutil/keeper/supplier.go @@ -20,6 +20,8 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/testutil/supplier/mocks" + servicekeeper "github.com/pokt-network/poktroll/x/service/keeper" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" "github.com/pokt-network/poktroll/x/supplier/keeper" "github.com/pokt-network/poktroll/x/supplier/types" ) @@ -42,6 +44,15 @@ func SupplierKeeper(t testing.TB) (keeper.Keeper, context.Context) { mockBankKeeper := mocks.NewMockBankKeeper(ctrl) mockBankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), types.ModuleName, gomock.Any()).AnyTimes() mockBankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), types.ModuleName, gomock.Any(), gomock.Any()).AnyTimes() + mockBankKeeper.EXPECT().SpendableCoins(gomock.Any(), gomock.Any()).AnyTimes() + + serviceKeeper := servicekeeper.NewKeeper( + cdc, + runtime.NewKVStoreService(storeKey), + log.NewNopLogger(), + authority.String(), + mockBankKeeper, + ) k := keeper.NewKeeper( cdc, @@ -49,6 +60,7 @@ func SupplierKeeper(t testing.TB) (keeper.Keeper, context.Context) { log.NewNopLogger(), authority.String(), mockBankKeeper, + serviceKeeper, ) ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) @@ -56,6 +68,10 @@ func SupplierKeeper(t testing.TB) (keeper.Keeper, context.Context) { // Initialize params require.NoError(t, k.SetParams(ctx, types.DefaultParams())) + // Add existing services used in the test. + serviceKeeper.SetService(ctx, sharedtypes.Service{Id: "svcId"}) + serviceKeeper.SetService(ctx, sharedtypes.Service{Id: "svcId2"}) + return k, ctx } diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index 802634be4..a0b5ffc19 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -36,6 +36,8 @@ import ( gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" proofkeeper "github.com/pokt-network/poktroll/x/proof/keeper" prooftypes "github.com/pokt-network/poktroll/x/proof/types" + servicekeeper "github.com/pokt-network/poktroll/x/service/keeper" + servicetypes "github.com/pokt-network/poktroll/x/service/types" sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" sharedkeeper "github.com/pokt-network/poktroll/x/shared/keeper" @@ -290,6 +292,15 @@ func NewTokenomicsModuleKeepers( ) require.NoError(t, appKeeper.SetParams(ctx, apptypes.DefaultParams())) + // Construct a service keeper needed by the supplier keeper. + serviceKeeper := servicekeeper.NewKeeper( + cdc, + runtime.NewKVStoreService(keys[servicetypes.StoreKey]), + log.NewNopLogger(), + authority.String(), + bankKeeper, + ) + // Construct a real supplier keeper to add suppliers to sessions. supplierKeeper := supplierkeeper.NewKeeper( cdc, @@ -297,6 +308,7 @@ func NewTokenomicsModuleKeepers( log.NewNopLogger(), authority.String(), bankKeeper, + serviceKeeper, ) require.NoError(t, supplierKeeper.SetParams(ctx, suppliertypes.DefaultParams())) diff --git a/x/service/keeper/service.go b/x/service/keeper/service.go index fe060e9a7..6c4722195 100644 --- a/x/service/keeper/service.go +++ b/x/service/keeper/service.go @@ -46,8 +46,8 @@ func (k Keeper) RemoveService( store.Delete(types.ServiceKey(serviceId)) } -// GetAllService returns all service -func (k Keeper) GetAllService(ctx context.Context) (services []sharedtypes.Service) { +// GetAllServices returns all services +func (k Keeper) GetAllServices(ctx context.Context) (services []sharedtypes.Service) { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.ServiceKeyPrefix)) iterator := storetypes.KVStorePrefixIterator(store, []byte{}) diff --git a/x/service/keeper/service_test.go b/x/service/keeper/service_test.go index cd236d332..12cbd52c5 100644 --- a/x/service/keeper/service_test.go +++ b/x/service/keeper/service_test.go @@ -69,6 +69,6 @@ func TestServiceGetAll(t *testing.T) { services := createNServices(keeper, ctx, 10) require.ElementsMatch(t, nullify.Fill(services), - nullify.Fill(keeper.GetAllService(ctx)), + nullify.Fill(keeper.GetAllServices(ctx)), ) } diff --git a/x/service/module/genesis.go b/x/service/module/genesis.go index fded93481..96a1f6275 100644 --- a/x/service/module/genesis.go +++ b/x/service/module/genesis.go @@ -24,7 +24,7 @@ func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) - genesis.ServiceList = k.GetAllService(ctx) + genesis.ServiceList = k.GetAllServices(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/service/types/expected_keepers.go b/x/service/types/expected_keepers.go index 8157cc89b..01652cde6 100644 --- a/x/service/types/expected_keepers.go +++ b/x/service/types/expected_keepers.go @@ -22,4 +22,5 @@ type BankKeeper interface { // than "delegate" funds from one account to another which is more closely // linked to staking. SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error } diff --git a/x/supplier/keeper/keeper.go b/x/supplier/keeper/keeper.go index ef87b8f4d..af1753c79 100644 --- a/x/supplier/keeper/keeper.go +++ b/x/supplier/keeper/keeper.go @@ -21,7 +21,8 @@ type ( // should be the x/gov module account. authority string - bankKeeper types.BankKeeper + bankKeeper types.BankKeeper + serviceKeeper types.ServiceKeeper } ) @@ -32,6 +33,7 @@ func NewKeeper( authority string, bankKeeper types.BankKeeper, + serviceKeeper types.ServiceKeeper, ) Keeper { if _, err := sdk.AccAddressFromBech32(authority); err != nil { panic(fmt.Sprintf("invalid authority address: %s", authority)) @@ -43,7 +45,8 @@ func NewKeeper( authority: authority, logger: logger, - bankKeeper: bankKeeper, + bankKeeper: bankKeeper, + serviceKeeper: serviceKeeper, } } diff --git a/x/supplier/keeper/msg_server_stake_supplier.go b/x/supplier/keeper/msg_server_stake_supplier.go index f0a823d0f..56cd1ee5e 100644 --- a/x/supplier/keeper/msg_server_stake_supplier.go +++ b/x/supplier/keeper/msg_server_stake_supplier.go @@ -27,6 +27,14 @@ func (k msgServer) StakeSupplier(ctx context.Context, msg *types.MsgStakeSupplie return nil, err } + // Check if the services the supplier is staking for exist + for _, serviceConfig := range msg.Services { + if _, serviceFound := k.serviceKeeper.GetService(ctx, serviceConfig.Service.Id); !serviceFound { + logger.Error(fmt.Sprintf("service %q does not exist", serviceConfig.Service.Id)) + return nil, types.ErrSupplierServiceNotFound.Wrapf("service %q does not exist", serviceConfig.Service.Id) + } + } + // Check if the supplier already exists or not var err error var coinsToEscrow sdk.Coin diff --git a/x/supplier/keeper/msg_server_stake_supplier_test.go b/x/supplier/keeper/msg_server_stake_supplier_test.go index b0d3f1d50..8e4e0c247 100644 --- a/x/supplier/keeper/msg_server_stake_supplier_test.go +++ b/x/supplier/keeper/msg_server_stake_supplier_test.go @@ -234,3 +234,33 @@ func TestMsgServer_StakeSupplier_FailLoweringStake(t *testing.T) { require.Equal(t, int64(100), supplierFound.Stake.Amount.Int64()) require.Len(t, supplierFound.Services, 1) } + +func TestMsgServer_StakeSupplier_FailWithNonExistingService(t *testing.T) { + k, ctx := keepertest.SupplierKeeper(t) + srv := keeper.NewMsgServerImpl(k) + + // Prepare the supplier + supplierAddr := sample.AccAddress() + stakeMsg := &types.MsgStakeSupplier{ + Address: supplierAddr, + Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, + Services: []*sharedtypes.SupplierServiceConfig{ + { + Service: &sharedtypes.Service{ + Id: "newService", + }, + Endpoints: []*sharedtypes.SupplierEndpoint{ + { + Url: "http://localhost:8080", + RpcType: sharedtypes.RPCType_JSON_RPC, + Configs: make([]*sharedtypes.ConfigOption, 0), + }, + }, + }, + }, + } + + // Stake the supplier & verify that it fails because the service does not exist. + _, err := srv.StakeSupplier(ctx, stakeMsg) + require.ErrorIs(t, err, types.ErrSupplierServiceNotFound) +} diff --git a/x/supplier/module/module.go b/x/supplier/module/module.go index 8ac44e592..fd71be1b8 100644 --- a/x/supplier/module/module.go +++ b/x/supplier/module/module.go @@ -98,6 +98,7 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper + serviceKeeper types.ServiceKeeper } func NewAppModule( @@ -105,12 +106,14 @@ func NewAppModule( keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, + serviceKeeper types.ServiceKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, accountKeeper: accountKeeper, bankKeeper: bankKeeper, + serviceKeeper: serviceKeeper, } } @@ -179,6 +182,7 @@ type ModuleInputs struct { AccountKeeper types.AccountKeeper BankKeeper types.BankKeeper + ServiceKeeper types.ServiceKeeper } type ModuleOutputs struct { @@ -200,12 +204,14 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { in.Logger, authority.String(), in.BankKeeper, + in.ServiceKeeper, ) m := NewAppModule( in.Cdc, k, in.AccountKeeper, in.BankKeeper, + in.ServiceKeeper, ) return ModuleOutputs{SupplierKeeper: k, Module: m} diff --git a/x/supplier/types/errors.go b/x/supplier/types/errors.go index c89c13e39..6ceca8f4e 100644 --- a/x/supplier/types/errors.go +++ b/x/supplier/types/errors.go @@ -16,4 +16,5 @@ var ( ErrSupplierInvalidSessionId = sdkerrors.Register(ModuleName, 1107, "invalid session ID") ErrSupplierInvalidService = sdkerrors.Register(ModuleName, 1108, "invalid service in supplier") ErrSupplierInvalidSessionEndHeight = sdkerrors.Register(ModuleName, 1109, "invalid session ending height") + ErrSupplierServiceNotFound = sdkerrors.Register(ModuleName, 1110, "service not found") ) diff --git a/x/supplier/types/expected_keepers.go b/x/supplier/types/expected_keepers.go index ba491c020..90d24fee0 100644 --- a/x/supplier/types/expected_keepers.go +++ b/x/supplier/types/expected_keepers.go @@ -6,6 +6,8 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) // AccountKeeper defines the expected interface for the Account module. @@ -16,6 +18,12 @@ type AccountKeeper interface { // BankKeeper defines the expected interface for the Bank module. type BankKeeper interface { + SpendableCoins(context.Context, sdk.AccAddress) sdk.Coins SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error } + +// ServiceKeeper defines the expected interface for the Service module. +type ServiceKeeper interface { + GetService(ctx context.Context, serviceId string) (sharedtypes.Service, bool) +} diff --git a/x/tokenomics/keeper/settle_session_accounting.go b/x/tokenomics/keeper/settle_session_accounting.go index 695ca9fdd..b00808158 100644 --- a/x/tokenomics/keeper/settle_session_accounting.go +++ b/x/tokenomics/keeper/settle_session_accounting.go @@ -6,7 +6,7 @@ import ( "fmt" "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" + cosmostypes "github.com/cosmos/cosmos-sdk/types" "github.com/pokt-network/poktroll/app/volatile" "github.com/pokt-network/smt" @@ -15,7 +15,7 @@ import ( apptypes "github.com/pokt-network/poktroll/x/application/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" - "github.com/pokt-network/poktroll/x/tokenomics/types" + tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) // SettleSessionAccounting is responsible for all of the post-session accounting @@ -32,16 +32,16 @@ func (k Keeper) SettleSessionAccounting( ) (err error) { logger := k.Logger().With("method", "SettleSessionAccounting") - settlementAmt := sdk.NewCoin("upokt", math.NewInt(0)) + settlementCoin := cosmostypes.NewCoin("upokt", math.NewInt(0)) isSuccessful := false // This is emitted only when the function returns. defer telemetry.EventSuccessCounter( "settle_session_accounting", func() float32 { - if settlementAmt.Amount.BigInt() == nil { + if settlementCoin.Amount.BigInt() == nil { return 0 } - return float32(settlementAmt.Amount.Int64()) + return float32(settlementCoin.Amount.Int64()) }, func() bool { return isSuccessful }, ) @@ -49,28 +49,28 @@ func (k Keeper) SettleSessionAccounting( // Make sure the claim is not nil if claim == nil { logger.Error("received a nil claim") - return types.ErrTokenomicsClaimNil + return tokenomicstypes.ErrTokenomicsClaimNil } // Retrieve & validate the session header sessionHeader := claim.GetSessionHeader() if sessionHeader == nil { logger.Error("received a nil session header") - return types.ErrTokenomicsSessionHeaderNil + return tokenomicstypes.ErrTokenomicsSessionHeaderNil } if err := sessionHeader.ValidateBasic(); err != nil { logger.Error("received an invalid session header", "error", err) - return types.ErrTokenomicsSessionHeaderInvalid + return tokenomicstypes.ErrTokenomicsSessionHeaderInvalid } - supplierAddr, err := sdk.AccAddressFromBech32(claim.GetSupplierAddress()) + supplierAddr, err := cosmostypes.AccAddressFromBech32(claim.GetSupplierAddress()) if err != nil || supplierAddr == nil { - return types.ErrTokenomicsSupplierAddressInvalid + return tokenomicstypes.ErrTokenomicsSupplierAddressInvalid } - applicationAddress, err := sdk.AccAddressFromBech32(sessionHeader.GetApplicationAddress()) + applicationAddress, err := cosmostypes.AccAddressFromBech32(sessionHeader.GetApplicationAddress()) if err != nil || applicationAddress == nil { - return types.ErrTokenomicsApplicationAddressInvalid + return tokenomicstypes.ErrTokenomicsApplicationAddressInvalid } // Retrieve the sum of the root as a proxy into the amount of work done @@ -85,7 +85,7 @@ func (k Keeper) SettleSessionAccounting( claimComputeUnits, err := root.Sum() if err != nil { - return types.ErrTokenomicsRootHashInvalid.Wrapf("%v", err) + return tokenomicstypes.ErrTokenomicsRootHashInvalid.Wrapf("%v", err) } // Helpers for logging the same metadata throughout this function calls @@ -102,24 +102,23 @@ func (k Keeper) SettleSessionAccounting( application, foundApplication := k.applicationKeeper.GetApplication(ctx, applicationAddress.String()) if !foundApplication { logger.Warn(fmt.Sprintf("application for claim with address %q not found", applicationAddress)) - return types.ErrTokenomicsApplicationNotFound + return tokenomicstypes.ErrTokenomicsApplicationNotFound } logger.Info(fmt.Sprintf("About to start settling claim for %d compute units", claimComputeUnits)) // Calculate the amount of tokens to mint & burn - settlementAmt, err = k.getCoinFromComputeUnits(ctx, root) + settlementCoin, err = k.getCoinFromComputeUnits(ctx, root) if err != nil { - fmt.Println(">>> returning...") return err } - settlementAmtuPOKT := sdk.NewCoins(settlementAmt) + settlementCoins := cosmostypes.NewCoins(settlementCoin) logger.Info(fmt.Sprintf( "%d compute units equate to %s for session %s", claimComputeUnits, - settlementAmt, + settlementCoin, sessionHeader.SessionId, )) @@ -131,60 +130,77 @@ func (k Keeper) SettleSessionAccounting( // Mint new uPOKT to the supplier module account. // These funds will be transferred to the supplier below. if err = k.bankKeeper.MintCoins( - ctx, suppliertypes.ModuleName, settlementAmtuPOKT, + ctx, suppliertypes.ModuleName, settlementCoins, ); err != nil { - return types.ErrTokenomicsSupplierModuleMintFailed.Wrapf( + return tokenomicstypes.ErrTokenomicsSupplierModuleMintFailed.Wrapf( "minting %s to the supplier module account: %v", - settlementAmt, + settlementCoin, err, ) } - logger.Info(fmt.Sprintf("minted %s in the supplier module", settlementAmt)) + logger.Info(fmt.Sprintf("minted %s in the supplier module", settlementCoin)) // Send the newley minted uPOKT from the supplier module account // to the supplier's account. if err = k.bankKeeper.SendCoinsFromModuleToAccount( - ctx, suppliertypes.ModuleName, supplierAddr, settlementAmtuPOKT, + ctx, suppliertypes.ModuleName, supplierAddr, settlementCoins, ); err != nil { - return types.ErrTokenomicsSupplierModuleMintFailed.Wrapf( + return tokenomicstypes.ErrTokenomicsSupplierModuleMintFailed.Wrapf( "sending %s to supplier with address %s: %v", - settlementAmt, + settlementCoin, supplierAddr, err, ) } - logger.Info(fmt.Sprintf("sent %s from the supplier module to the supplier account with address %q", settlementAmt, supplierAddr)) + logger.Info(fmt.Sprintf("sent %s from the supplier module to the supplier account with address %q", settlementCoin, supplierAddr)) // Verify that the application has enough uPOKT to pay for the services it consumed - if application.Stake.IsLT(settlementAmt) { + if application.GetStake().IsLT(settlementCoin) { logger.Warn(fmt.Sprintf( "THIS SHOULD NEVER HAPPEN. Application with address %s needs to be charged more than it has staked: %v > %v", applicationAddress, - settlementAmtuPOKT, + settlementCoins, application.Stake, )) // TODO_MAINNET(@Olshansk, @RawthiL): The application was over-serviced in the last session so it basically // goes "into debt". Need to design a way to handle this when we implement // probabilistic proofs and add all the parameter logic. Do we touch the application balance? // Do we just let it go into debt? Do we penalize the application? Do we unstake it? Etc... - settlementAmt = sdk.NewCoin("upokt", math.Int(application.Stake.Amount)) - settlementAmtuPOKT = sdk.NewCoins(settlementAmt) - // TODO_BLOCKER(@Olshansk): The application should be immediately unstaked at this point in time + expectedBurn := settlementCoin + // Make the settlement amount the maximum stake that the application has remaining. + settlementCoin = *application.GetStake() + settlementCoins = cosmostypes.NewCoins(settlementCoin) + + applicationOverservicedEvent := &tokenomicstypes.EventApplicationOverserviced{ + ApplicationAddr: applicationAddress.String(), + ExpectedBurn: &expectedBurn, + EffectiveBurn: application.GetStake(), + } + + eventManager := cosmostypes.UnwrapSDKContext(ctx).EventManager() + if err = eventManager.EmitTypedEvent(applicationOverservicedEvent); err != nil { + return tokenomicstypes.ErrTokenomicsApplicationOverserviced.Wrapf( + "application address: %s; expected burn %s; effective burn: %s", + application.GetAddress(), + expectedBurn.String(), + application.GetStake().String(), + ) + } } // Burn uPOKT from the application module account which was held in escrow // on behalf of the application account. if err = k.bankKeeper.BurnCoins( - ctx, apptypes.ModuleName, settlementAmtuPOKT, + ctx, apptypes.ModuleName, settlementCoins, ); err != nil { - return types.ErrTokenomicsApplicationModuleBurn.Wrapf("burning %s from the application module account: %v", settlementAmt, err) + return tokenomicstypes.ErrTokenomicsApplicationModuleBurn.Wrapf("burning %s from the application module account: %v", settlementCoin, err) } - logger.Info(fmt.Sprintf("burned %s from the application module account", settlementAmt)) + logger.Info(fmt.Sprintf("burned %s from the application module account", settlementCoin)) // Update the application's on-chain stake - newAppStake, err := (*application.Stake).SafeSub(settlementAmt) + newAppStake, err := application.Stake.SafeSub(settlementCoin) if err != nil { - return types.ErrTokenomicsApplicationNewStakeInvalid.Wrapf("application %q stake cannot be reduced to a negative amount %v", applicationAddress, newAppStake) + return tokenomicstypes.ErrTokenomicsApplicationNewStakeInvalid.Wrapf("application %q stake cannot be reduced to a negative amount %v", applicationAddress, newAppStake) } application.Stake = &newAppStake k.applicationKeeper.SetApplication(ctx, application) @@ -194,20 +210,20 @@ func (k Keeper) SettleSessionAccounting( return nil } -func (k Keeper) getCoinFromComputeUnits(ctx context.Context, root smt.MerkleSumRoot) (sdk.Coin, error) { +func (k Keeper) getCoinFromComputeUnits(ctx context.Context, root smt.MerkleSumRoot) (cosmostypes.Coin, error) { // Retrieve the existing tokenomics params params := k.GetParams(ctx) sum, err := root.Sum() if err != nil { - return sdk.Coin{}, err + return cosmostypes.Coin{}, err } upokt := math.NewInt(int64(sum * params.ComputeUnitsToTokensMultiplier)) if upokt.IsNegative() { - return sdk.Coin{}, types.ErrTokenomicsRootHashInvalid.Wrap("sum * compute_units_to_tokens_multiplier is negative") + return cosmostypes.Coin{}, tokenomicstypes.ErrTokenomicsRootHashInvalid.Wrap("sum * compute_units_to_tokens_multiplier is negative") } - return sdk.NewCoin(volatile.DenomuPOKT, upokt), nil + return cosmostypes.NewCoin(volatile.DenomuPOKT, upokt), nil } diff --git a/x/tokenomics/keeper/settle_session_accounting_test.go b/x/tokenomics/keeper/settle_session_accounting_test.go index 38671e11f..b18aecb89 100644 --- a/x/tokenomics/keeper/settle_session_accounting_test.go +++ b/x/tokenomics/keeper/settle_session_accounting_test.go @@ -7,6 +7,7 @@ import ( "testing" "cosmossdk.io/math" + "github.com/cometbft/cometbft/libs/json" cosmostypes "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -252,6 +253,25 @@ func TestSettleSessionAccounting_AppStakeTooLow(t *testing.T) { // Assert that `suppliertypes.ModuleName` account module balance is *unchanged* supplierModuleEndBalance := getBalance(t, ctx, keepers, supplierModuleAddress) require.EqualValues(t, supplierModuleStartBalance, supplierModuleEndBalance) + + sdkCtx := cosmostypes.UnwrapSDKContext(ctx) + events := sdkCtx.EventManager().Events() + + appAddrAttribute, _ := events.GetAttributes("application_addr") + expectedBurnAttribute, _ := events.GetAttributes("expected_burn") + effectiveBurnAttribute, _ := events.GetAttributes("effective_burn") + + require.Equal(t, 1, len(appAddrAttribute)) + require.Equal(t, fmt.Sprintf("\"%s\"", app.GetAddress()), appAddrAttribute[0].Value) + + var expectedBurnEventCoin, effectiveBurnEventCoin cosmostypes.Coin + err = json.Unmarshal([]byte(expectedBurnAttribute[0].Value), &expectedBurnEventCoin) + require.NoError(t, err) + err = json.Unmarshal([]byte(effectiveBurnAttribute[0].Value), &effectiveBurnEventCoin) + require.NoError(t, err) + + require.EqualValues(t, expectedAppBurn, expectedBurnEventCoin) + require.Greater(t, expectedBurnEventCoin.Amount.Uint64(), effectiveBurnEventCoin.Amount.Uint64()) } func TestSettleSessionAccounting_AppNotFound(t *testing.T) { diff --git a/x/tokenomics/types/errors.go b/x/tokenomics/types/errors.go index d2f45037c..659142d1c 100644 --- a/x/tokenomics/types/errors.go +++ b/x/tokenomics/types/errors.go @@ -25,4 +25,5 @@ var ( ErrTokenomicsUnmarshalInvalid = sdkerrors.Register(ModuleName, 1118, "failed to unmarshal the provided bytes") ErrTokenomicsDuplicateIndex = sdkerrors.Register(ModuleName, 1119, "cannot have a duplicate index") ErrTokenomicsMissingRelayMiningDifficulty = sdkerrors.Register(ModuleName, 1120, "missing relay mining difficulty") + ErrTokenomicsApplicationOverserviced = sdkerrors.Register(ModuleName, 1121, "application was overserviced") ) diff --git a/x/tokenomics/types/event.pb.go b/x/tokenomics/types/event.pb.go index 3d4b74ee8..8ac8e9321 100644 --- a/x/tokenomics/types/event.pb.go +++ b/x/tokenomics/types/event.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + types1 "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" types "github.com/pokt-network/poktroll/x/proof/types" @@ -235,48 +236,118 @@ func (m *EventRelayMiningDifficultyUpdated) GetNewNumRelaysEma() uint64 { return 0 } +// EventApplicationOverserviced is emitted when an application has less stake +// than the expected burn. +type EventApplicationOverserviced struct { + ApplicationAddr string `protobuf:"bytes,1,opt,name=application_addr,json=applicationAddr,proto3" json:"application_addr,omitempty"` + ExpectedBurn *types1.Coin `protobuf:"bytes,2,opt,name=expected_burn,json=expectedBurn,proto3" json:"expected_burn,omitempty"` + EffectiveBurn *types1.Coin `protobuf:"bytes,3,opt,name=effective_burn,json=effectiveBurn,proto3" json:"effective_burn,omitempty"` +} + +func (m *EventApplicationOverserviced) Reset() { *m = EventApplicationOverserviced{} } +func (m *EventApplicationOverserviced) String() string { return proto.CompactTextString(m) } +func (*EventApplicationOverserviced) ProtoMessage() {} +func (*EventApplicationOverserviced) Descriptor() ([]byte, []int) { + return fileDescriptor_a78874bbf91a58c7, []int{3} +} +func (m *EventApplicationOverserviced) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventApplicationOverserviced) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventApplicationOverserviced.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventApplicationOverserviced) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventApplicationOverserviced.Merge(m, src) +} +func (m *EventApplicationOverserviced) XXX_Size() int { + return m.Size() +} +func (m *EventApplicationOverserviced) XXX_DiscardUnknown() { + xxx_messageInfo_EventApplicationOverserviced.DiscardUnknown(m) +} + +var xxx_messageInfo_EventApplicationOverserviced proto.InternalMessageInfo + +func (m *EventApplicationOverserviced) GetApplicationAddr() string { + if m != nil { + return m.ApplicationAddr + } + return "" +} + +func (m *EventApplicationOverserviced) GetExpectedBurn() *types1.Coin { + if m != nil { + return m.ExpectedBurn + } + return nil +} + +func (m *EventApplicationOverserviced) GetEffectiveBurn() *types1.Coin { + if m != nil { + return m.EffectiveBurn + } + return nil +} + func init() { proto.RegisterType((*EventClaimExpired)(nil), "poktroll.tokenomics.EventClaimExpired") proto.RegisterType((*EventClaimSettled)(nil), "poktroll.tokenomics.EventClaimSettled") proto.RegisterType((*EventRelayMiningDifficultyUpdated)(nil), "poktroll.tokenomics.EventRelayMiningDifficultyUpdated") + proto.RegisterType((*EventApplicationOverserviced)(nil), "poktroll.tokenomics.EventApplicationOverserviced") } func init() { proto.RegisterFile("poktroll/tokenomics/event.proto", fileDescriptor_a78874bbf91a58c7) } var fileDescriptor_a78874bbf91a58c7 = []byte{ - // 504 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x93, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0xc7, 0xe3, 0x34, 0xfd, 0x49, 0xde, 0x9f, 0xd4, 0x92, 0x2d, 0x15, 0x56, 0x00, 0x27, 0xe4, - 0x80, 0x22, 0xa1, 0xd8, 0x52, 0x2b, 0x71, 0x42, 0x48, 0xa4, 0x44, 0x2a, 0x87, 0x22, 0x64, 0xe8, - 0x85, 0x8b, 0xe5, 0xda, 0x13, 0x7b, 0x89, 0x77, 0xd7, 0xac, 0xd7, 0xf9, 0xf3, 0x16, 0x3c, 0x00, - 0x2f, 0xc0, 0x43, 0x70, 0xe7, 0xd8, 0x23, 0xa7, 0x08, 0x25, 0xb7, 0x3c, 0x05, 0xda, 0x75, 0x9b, - 0x58, 0x29, 0x3c, 0x00, 0x97, 0x64, 0x35, 0xdf, 0xcf, 0xcc, 0x7c, 0x3d, 0xa3, 0x41, 0xed, 0x8c, - 0x8f, 0xa5, 0xe0, 0x69, 0xea, 0x4a, 0x3e, 0x06, 0xc6, 0x29, 0x09, 0x73, 0x17, 0x26, 0xc0, 0xa4, - 0x93, 0x09, 0x2e, 0x39, 0x3e, 0xba, 0x05, 0x9c, 0x2d, 0xd0, 0xba, 0x1f, 0xf3, 0x98, 0x6b, 0xdd, - 0x55, 0xaf, 0x12, 0x6d, 0xb5, 0x36, 0xb5, 0x32, 0xc1, 0xf9, 0xc8, 0x0d, 0xd3, 0x80, 0xd0, 0x1b, - 0xad, 0xb3, 0xa3, 0x09, 0xf8, 0x5c, 0x10, 0x01, 0x74, 0xd3, 0xa8, 0xfb, 0xdd, 0x40, 0xcd, 0xa1, - 0x6a, 0x7c, 0xa6, 0xd2, 0x86, 0xb3, 0x8c, 0x08, 0x88, 0xf0, 0x73, 0xb4, 0xaf, 0xcb, 0x58, 0x46, - 0xc7, 0xe8, 0xfd, 0x7f, 0x72, 0xec, 0x6c, 0xec, 0xe8, 0x3a, 0x8e, 0x86, 0x07, 0xe6, 0x7a, 0xd1, - 0x2e, 0x39, 0xaf, 0xfc, 0xc3, 0x7d, 0x84, 0x58, 0x41, 0x7d, 0x01, 0x69, 0x30, 0xcf, 0xad, 0x7a, - 0xc7, 0xe8, 0x35, 0x06, 0x07, 0xeb, 0x45, 0xbb, 0x12, 0xf5, 0x4c, 0x56, 0x50, 0x4f, 0x3f, 0xf1, - 0x2b, 0xd4, 0x54, 0x42, 0xc8, 0x69, 0x56, 0x48, 0xf0, 0x0b, 0x46, 0x64, 0x6e, 0xed, 0xe9, 0xac, - 0xe3, 0xf5, 0xa2, 0x7d, 0x57, 0xf4, 0x0e, 0x59, 0x41, 0xcf, 0xca, 0xc8, 0xa5, 0x0a, 0x74, 0xbf, - 0xd5, 0xab, 0xfe, 0xdf, 0x83, 0x94, 0xe9, 0xbf, 0xe4, 0x1f, 0x7f, 0x42, 0x4d, 0x6d, 0xc9, 0xaf, - 0xac, 0xc6, 0x6a, 0x74, 0x8c, 0xde, 0xc1, 0xc9, 0xd3, 0x5d, 0xd7, 0xef, 0xd4, 0xaf, 0xb7, 0xe5, - 0x3c, 0x08, 0x72, 0xce, 0xca, 0x56, 0x77, 0x8a, 0x78, 0xf7, 0xb2, 0x1d, 0xbc, 0xfb, 0xb5, 0x8e, - 0x9e, 0xe8, 0x59, 0x69, 0xfb, 0x17, 0x84, 0x11, 0x16, 0xbf, 0x26, 0xa3, 0x11, 0x09, 0x8b, 0x54, - 0xce, 0x2f, 0xb3, 0x28, 0x90, 0x10, 0xe1, 0xc7, 0x08, 0xe5, 0x20, 0x26, 0x24, 0x04, 0x9f, 0x44, - 0x7a, 0x80, 0xa6, 0x67, 0xde, 0x44, 0xde, 0x44, 0xf8, 0x25, 0x7a, 0x94, 0x09, 0x98, 0xf8, 0x32, - 0x10, 0x31, 0x48, 0x3f, 0x09, 0xf2, 0xc4, 0x4f, 0x60, 0xe6, 0x03, 0x0b, 0x79, 0x04, 0x91, 0x1e, - 0x9a, 0xe9, 0x59, 0x8a, 0xf9, 0xa0, 0x91, 0xf3, 0x20, 0x4f, 0xce, 0x61, 0x36, 0x2c, 0x75, 0xfc, - 0x02, 0x3d, 0x64, 0x30, 0xfd, 0x6b, 0xfa, 0x9e, 0x4e, 0x7f, 0xc0, 0x60, 0xfa, 0xc7, 0xec, 0x3e, - 0x3a, 0xd2, 0xdd, 0xb7, 0xfb, 0xf0, 0x81, 0x06, 0x7a, 0x60, 0x0d, 0xf5, 0xc5, 0x30, 0x79, 0x7b, - 0xbb, 0x9d, 0x21, 0x0d, 0xf0, 0x33, 0x84, 0x55, 0xb3, 0x1d, 0x7a, 0x5f, 0xd3, 0x87, 0x0c, 0xa6, - 0x55, 0x78, 0x70, 0xf1, 0x63, 0x69, 0x1b, 0xd7, 0x4b, 0xdb, 0xf8, 0xb5, 0xb4, 0x8d, 0x2f, 0x2b, - 0xbb, 0x76, 0xbd, 0xb2, 0x6b, 0x3f, 0x57, 0x76, 0xed, 0xe3, 0x69, 0x4c, 0x64, 0x52, 0x5c, 0x39, - 0x21, 0xa7, 0xae, 0xda, 0x49, 0x9f, 0x81, 0x9c, 0x72, 0x31, 0x76, 0x37, 0xe7, 0x35, 0xab, 0x1e, - 0xb2, 0x9c, 0x67, 0x90, 0x5f, 0xfd, 0xa7, 0x0f, 0xec, 0xf4, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xe2, 0x1a, 0xdf, 0x58, 0xec, 0x03, 0x00, 0x00, + // 621 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x94, 0xcb, 0x6e, 0x13, 0x3d, + 0x14, 0xc7, 0x3b, 0xbd, 0x7c, 0x52, 0xdc, 0xaf, 0x37, 0x97, 0x8a, 0x50, 0xca, 0x24, 0x64, 0x81, + 0x8a, 0x50, 0x67, 0xd4, 0x56, 0x62, 0x85, 0x2a, 0x9a, 0x12, 0xa9, 0x2c, 0x0a, 0x68, 0xa0, 0x1b, + 0x36, 0x23, 0x67, 0x7c, 0x92, 0x98, 0xce, 0xd8, 0xc6, 0xe3, 0x99, 0xa4, 0x6f, 0xc1, 0x03, 0xf0, + 0x02, 0x3c, 0x04, 0x7b, 0x24, 0x36, 0x5d, 0xb2, 0xaa, 0x50, 0xbb, 0xeb, 0x53, 0x20, 0x7b, 0x72, + 0x19, 0xa5, 0x20, 0xd6, 0x6c, 0x12, 0xeb, 0xfc, 0x7f, 0xe7, 0x9c, 0xbf, 0x8f, 0xc7, 0x46, 0x35, + 0x29, 0xce, 0xb4, 0x12, 0x71, 0xec, 0x6b, 0x71, 0x06, 0x5c, 0x24, 0x2c, 0x4a, 0x7d, 0xc8, 0x81, + 0x6b, 0x4f, 0x2a, 0xa1, 0x05, 0x5e, 0x1f, 0x01, 0xde, 0x04, 0xd8, 0xbc, 0xd3, 0x15, 0x5d, 0x61, + 0x75, 0xdf, 0xac, 0x0a, 0x74, 0xd3, 0x8d, 0x44, 0x9a, 0x88, 0xd4, 0x6f, 0x93, 0x14, 0xfc, 0x7c, + 0xb7, 0x0d, 0x9a, 0xec, 0xfa, 0x91, 0x60, 0x7c, 0xa8, 0x6f, 0x8e, 0x7b, 0x49, 0x25, 0x44, 0xc7, + 0x8f, 0x62, 0xc2, 0x92, 0xa1, 0x56, 0x9f, 0xd2, 0x14, 0x7c, 0xcc, 0x98, 0x82, 0x64, 0x6c, 0xa4, + 0xf1, 0xd5, 0x41, 0x6b, 0x2d, 0x63, 0xec, 0xc8, 0xa4, 0xb5, 0x06, 0x92, 0x29, 0xa0, 0xf8, 0x29, + 0x5a, 0xb0, 0x65, 0xaa, 0x4e, 0xdd, 0xd9, 0x5e, 0xdc, 0xdb, 0xf0, 0xc6, 0x76, 0x6d, 0x1d, 0xcf, + 0xc2, 0xcd, 0xca, 0xcd, 0x65, 0xad, 0xe0, 0x82, 0xe2, 0x0f, 0xef, 0x20, 0xc4, 0xb3, 0x24, 0x54, + 0x10, 0x93, 0xf3, 0xb4, 0x3a, 0x5b, 0x77, 0xb6, 0xe7, 0x9b, 0xcb, 0x37, 0x97, 0xb5, 0x52, 0x34, + 0xa8, 0xf0, 0x2c, 0x09, 0xec, 0x12, 0x1f, 0xa2, 0x35, 0x23, 0x44, 0x22, 0x91, 0x99, 0x86, 0x30, + 0xe3, 0x4c, 0xa7, 0xd5, 0x39, 0x9b, 0xb5, 0x71, 0x73, 0x59, 0xbb, 0x2d, 0x06, 0x2b, 0x3c, 0x4b, + 0x8e, 0x8a, 0xc8, 0xa9, 0x09, 0x34, 0xbe, 0xcc, 0x96, 0xfd, 0xbf, 0x05, 0xad, 0xe3, 0x7f, 0xc9, + 0x3f, 0xfe, 0x80, 0xd6, 0xac, 0xa5, 0xb0, 0x74, 0x34, 0xd5, 0xf9, 0xba, 0xb3, 0xbd, 0xbc, 0xf7, + 0x68, 0xda, 0xf5, 0x1b, 0xf3, 0x1b, 0x4c, 0xb8, 0x00, 0x48, 0x2a, 0x78, 0xd1, 0xea, 0x56, 0x91, + 0x60, 0x55, 0x4e, 0xe1, 0x8d, 0xcf, 0xb3, 0xe8, 0xa1, 0x9d, 0x95, 0xb5, 0x7f, 0xc2, 0x38, 0xe3, + 0xdd, 0x17, 0xac, 0xd3, 0x61, 0x51, 0x16, 0xeb, 0xf3, 0x53, 0x49, 0x89, 0x06, 0x8a, 0x1f, 0x20, + 0x94, 0x82, 0xca, 0x59, 0x04, 0x21, 0xa3, 0x76, 0x80, 0x95, 0xa0, 0x32, 0x8c, 0xbc, 0xa4, 0xf8, + 0x00, 0x6d, 0x49, 0x05, 0x79, 0xa8, 0x89, 0xea, 0x82, 0x0e, 0x7b, 0x24, 0xed, 0x85, 0x3d, 0x18, + 0x84, 0xc0, 0x23, 0x41, 0x81, 0xda, 0xa1, 0x55, 0x82, 0xaa, 0x61, 0xde, 0x59, 0xe4, 0x98, 0xa4, + 0xbd, 0x63, 0x18, 0xb4, 0x0a, 0x1d, 0x3f, 0x43, 0xf7, 0x39, 0xf4, 0xff, 0x98, 0x3e, 0x67, 0xd3, + 0xef, 0x72, 0xe8, 0xff, 0x36, 0x7b, 0x07, 0xad, 0xdb, 0xee, 0x93, 0xf3, 0x08, 0x21, 0x21, 0x76, + 0x60, 0xf3, 0x66, 0xc7, 0x90, 0xbf, 0x1a, 0x9d, 0x4e, 0x2b, 0x21, 0xf8, 0x09, 0xc2, 0xa6, 0xd9, + 0x14, 0xbd, 0x60, 0xe9, 0x15, 0x0e, 0xfd, 0x32, 0xdc, 0xf8, 0xee, 0xa0, 0x2d, 0x3b, 0x9e, 0x43, + 0x29, 0x63, 0x16, 0x11, 0xcd, 0x04, 0x7f, 0x9d, 0x83, 0x1a, 0xee, 0x9d, 0xe2, 0xc7, 0x68, 0x95, + 0x4c, 0xa4, 0x90, 0x50, 0xaa, 0x86, 0xf3, 0x59, 0x29, 0xc5, 0x0f, 0x29, 0x55, 0xf8, 0x00, 0x2d, + 0xc1, 0x40, 0x42, 0xa4, 0x81, 0x86, 0xed, 0x4c, 0x71, 0x3b, 0x96, 0xc5, 0xbd, 0x7b, 0x5e, 0x71, + 0x99, 0x3d, 0x73, 0x99, 0xbd, 0xe1, 0x65, 0xf6, 0x8e, 0x04, 0xe3, 0xc1, 0xff, 0x23, 0xbe, 0x99, + 0x29, 0x8e, 0x9f, 0xa3, 0x65, 0xe8, 0x74, 0x20, 0xd2, 0x2c, 0x87, 0xa2, 0xc0, 0xdc, 0xdf, 0x0a, + 0x2c, 0x8d, 0x13, 0x4c, 0x85, 0xe6, 0xc9, 0xb7, 0x2b, 0xd7, 0xb9, 0xb8, 0x72, 0x9d, 0x9f, 0x57, + 0xae, 0xf3, 0xe9, 0xda, 0x9d, 0xb9, 0xb8, 0x76, 0x67, 0x7e, 0x5c, 0xbb, 0x33, 0xef, 0xf7, 0xbb, + 0x4c, 0xf7, 0xb2, 0xb6, 0x17, 0x89, 0xc4, 0x37, 0x5f, 0xd8, 0x0e, 0x07, 0xdd, 0x17, 0xea, 0xcc, + 0x1f, 0x3f, 0x16, 0x83, 0xf2, 0xb3, 0xa5, 0xcf, 0x25, 0xa4, 0xed, 0xff, 0xec, 0x73, 0xb1, 0xff, + 0x2b, 0x00, 0x00, 0xff, 0xff, 0x67, 0x30, 0x58, 0x9b, 0xda, 0x04, 0x00, 0x00, } func (m *EventClaimExpired) Marshal() (dAtA []byte, err error) { @@ -428,6 +499,60 @@ func (m *EventRelayMiningDifficultyUpdated) MarshalToSizedBuffer(dAtA []byte) (i return len(dAtA) - i, nil } +func (m *EventApplicationOverserviced) 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 *EventApplicationOverserviced) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventApplicationOverserviced) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EffectiveBurn != nil { + { + size, err := m.EffectiveBurn.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.ExpectedBurn != nil { + { + size, err := m.ExpectedBurn.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + 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 @@ -507,6 +632,27 @@ func (m *EventRelayMiningDifficultyUpdated) Size() (n int) { return n } +func (m *EventApplicationOverserviced) 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)) + } + if m.ExpectedBurn != nil { + l = m.ExpectedBurn.Size() + n += 1 + l + sovEvent(uint64(l)) + } + if m.EffectiveBurn != nil { + l = m.EffectiveBurn.Size() + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + func sovEvent(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -964,6 +1110,160 @@ func (m *EventRelayMiningDifficultyUpdated) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventApplicationOverserviced) 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: EventApplicationOverserviced: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventApplicationOverserviced: 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 ExpectedBurn", 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.ExpectedBurn == nil { + m.ExpectedBurn = &types1.Coin{} + } + if err := m.ExpectedBurn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EffectiveBurn", 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.EffectiveBurn == nil { + m.EffectiveBurn = &types1.Coin{} + } + if err := m.EffectiveBurn.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