From 2eaf50e465ac03e7b78aeb20f7740037cd26749c Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 9 Jul 2024 16:19:37 +0200 Subject: [PATCH 1/8] chore: add EventApplicationOverserviced --- api/poktroll/tokenomics/event.pulsar.go | 715 +++++++++++++++++++++++- proto/poktroll/tokenomics/event.proto | 7 + x/tokenomics/types/event.pb.go | 364 ++++++++++-- 3 files changed, 1026 insertions(+), 60 deletions(-) diff --git a/api/poktroll/tokenomics/event.pulsar.go b/api/poktroll/tokenomics/event.pulsar.go index ca0ebfa25..863dabcaa 100644 --- a/api/poktroll/tokenomics/event.pulsar.go +++ b/api/poktroll/tokenomics/event.pulsar.go @@ -2,10 +2,11 @@ package tokenomics import ( - proof "github.com/pokt-network/poktroll/api/poktroll/proof" + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" + proof "github.com/pokt-network/poktroll/api/poktroll/proof" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -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,57 @@ func (x *EventRelayMiningDifficultyUpdated) GetNewNumRelaysEma() uint64 { return 0 } +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 +2602,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 +2657,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 +2697,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 +2762,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 +2781,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/proto/poktroll/tokenomics/event.proto b/proto/poktroll/tokenomics/event.proto index 2652f330e..884c0c094 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,9 @@ message EventRelayMiningDifficultyUpdated { uint64 prev_num_relays_ema = 4; uint64 new_num_relays_ema = 5; } + +message EventApplicationOverserviced { + string application_addr = 1; + cosmos.base.v1beta1.Coin expected_burn = 2; + cosmos.base.v1beta1.Coin effective_burn = 3; +} diff --git a/x/tokenomics/types/event.pb.go b/x/tokenomics/types/event.pb.go index 3d4b74ee8..f344ba456 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,116 @@ func (m *EventRelayMiningDifficultyUpdated) GetNewNumRelaysEma() uint64 { return 0 } +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 +497,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 +630,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 +1108,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 From 4e04cd987d292d313648dd55fa25a669e82fa11c Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 9 Jul 2024 16:25:13 +0200 Subject: [PATCH 2/8] chore: emit EventApplicationOverserviced --- .../keeper/settle_session_accounting.go | 61 +++++++++++-------- x/tokenomics/types/errors.go | 1 + 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/x/tokenomics/keeper/settle_session_accounting.go b/x/tokenomics/keeper/settle_session_accounting.go index 16e7e6f0a..2e9b6e9cc 100644 --- a/x/tokenomics/keeper/settle_session_accounting.go +++ b/x/tokenomics/keeper/settle_session_accounting.go @@ -4,15 +4,15 @@ import ( "context" "fmt" - math "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/math" + cosmostypes "github.com/cosmos/cosmos-sdk/types" "github.com/pokt-network/smt" "github.com/pokt-network/poktroll/telemetry" 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 @@ -29,7 +29,7 @@ func (k Keeper) SettleSessionAccounting( ) error { logger := k.Logger().With("method", "SettleSessionAccounting") - settlementAmt := sdk.NewCoin("upokt", math.NewInt(0)) + settlementAmt := cosmostypes.NewCoin("upokt", math.NewInt(0)) isSuccessful := false // This is emitted only when the function returns. defer telemetry.EventSuccessCounter( @@ -41,28 +41,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 @@ -72,7 +72,7 @@ func (k Keeper) SettleSessionAccounting( // since it's used to get compute units from the root hash. if root == nil || len(root) != smt.SmstRootSizeBytes { logger.Error(fmt.Sprintf("received an invalid root hash of size: %d", len(root))) - return types.ErrTokenomicsRootHashInvalid + return tokenomicstypes.ErrTokenomicsRootHashInvalid } claimComputeUnits := root.Sum() @@ -90,14 +90,14 @@ 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 = k.getCoinFromComputeUnits(ctx, root) - settlementAmtuPOKT := sdk.NewCoins(settlementAmt) + settlementAmtuPOKT := cosmostypes.NewCoins(settlementAmt) logger.Info(fmt.Sprintf( "%d compute units equate to %s for session %s", @@ -116,7 +116,7 @@ func (k Keeper) SettleSessionAccounting( if err := k.bankKeeper.MintCoins( ctx, suppliertypes.ModuleName, settlementAmtuPOKT, ); err != nil { - return types.ErrTokenomicsSupplierModuleMintFailed.Wrapf( + return tokenomicstypes.ErrTokenomicsSupplierModuleMintFailed.Wrapf( "minting %s to the supplier module account: %v", settlementAmt, err, @@ -129,7 +129,7 @@ func (k Keeper) SettleSessionAccounting( if err := k.bankKeeper.SendCoinsFromModuleToAccount( ctx, suppliertypes.ModuleName, supplierAddr, settlementAmtuPOKT, ); err != nil { - return types.ErrTokenomicsSupplierModuleMintFailed.Wrapf( + return tokenomicstypes.ErrTokenomicsSupplierModuleMintFailed.Wrapf( "sending %s to supplier with address %s: %v", settlementAmt, supplierAddr, @@ -139,7 +139,7 @@ func (k Keeper) SettleSessionAccounting( logger.Info(fmt.Sprintf("sent %s from the supplier module to the supplier account with address %q", settlementAmt, supplierAddr)) // Verify that the application has enough uPOKT to pay for the services it consumed - if application.Stake.IsLT(settlementAmt) { + if application.GetStake().IsLT(settlementAmt) { logger.Warn(fmt.Sprintf( "THIS SHOULD NEVER HAPPEN. Application with address %s needs to be charged more than it has staked: %v > %v", applicationAddress, @@ -150,9 +150,22 @@ func (k Keeper) SettleSessionAccounting( // 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 + settlementAmt = cosmostypes.NewCoin("upokt", math.Int(application.Stake.Amount)) + settlementAmtuPOKT = cosmostypes.NewCoins(settlementAmt) + + applicationOverservicedEvent := &tokenomicstypes.EventApplicationOverserviced{ + ApplicationAddr: applicationAddress.String(), + ExpectedBurn: &settlementAmt, + EffectiveBurn: application.GetStake(), + } + if err = cosmostypes.UnwrapSDKContext(ctx).EventManager().EmitTypedEvent(applicationOverservicedEvent); err != nil { + return tokenomicstypes.ErrTokenomicsApplicationOverserviced.Wrapf( + "application address: %; expected burn %s; effective burn: %s", + application.GetAddress(), + settlementAmt.String(), + application.GetStake().String(), + ) + } } // Burn uPOKT from the application module account which was held in escrow @@ -160,14 +173,14 @@ func (k Keeper) SettleSessionAccounting( if err := k.bankKeeper.BurnCoins( ctx, apptypes.ModuleName, settlementAmtuPOKT, ); 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", settlementAmt, err) } logger.Info(fmt.Sprintf("burned %s from the application module account", settlementAmt)) // Update the application's on-chain stake newAppStake, err := (*application.Stake).SafeSub(settlementAmt) 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) @@ -177,10 +190,10 @@ func (k Keeper) SettleSessionAccounting( return nil } -func (k Keeper) getCoinFromComputeUnits(ctx context.Context, root smt.MerkleRoot) sdk.Coin { +func (k Keeper) getCoinFromComputeUnits(ctx context.Context, root smt.MerkleRoot) cosmostypes.Coin { // Retrieve the existing tokenomics params params := k.GetParams(ctx) upokt := math.NewInt(int64(root.Sum() * params.ComputeUnitsToTokensMultiplier)) - return sdk.NewCoin("upokt", upokt) + return cosmostypes.NewCoin("upokt", upokt) } 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") ) From ae5036c1d27a0dbc89e7d5dd9c0511bc2c8ce334 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 9 Jul 2024 16:46:19 +0200 Subject: [PATCH 3/8] chore: add comment --- api/poktroll/tokenomics/event.pulsar.go | 2 ++ proto/poktroll/tokenomics/event.proto | 2 ++ x/tokenomics/types/event.pb.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/api/poktroll/tokenomics/event.pulsar.go b/api/poktroll/tokenomics/event.pulsar.go index 863dabcaa..abc75bb3c 100644 --- a/api/poktroll/tokenomics/event.pulsar.go +++ b/api/poktroll/tokenomics/event.pulsar.go @@ -2544,6 +2544,8 @@ 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 diff --git a/proto/poktroll/tokenomics/event.proto b/proto/poktroll/tokenomics/event.proto index 884c0c094..f45cd6389 100644 --- a/proto/poktroll/tokenomics/event.proto +++ b/proto/poktroll/tokenomics/event.proto @@ -36,6 +36,8 @@ message EventRelayMiningDifficultyUpdated { 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; diff --git a/x/tokenomics/types/event.pb.go b/x/tokenomics/types/event.pb.go index f344ba456..8ac8e9321 100644 --- a/x/tokenomics/types/event.pb.go +++ b/x/tokenomics/types/event.pb.go @@ -236,6 +236,8 @@ 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"` From 70caf94ee5e4aea911d560a86fb7601e0f3cabe0 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 10 Jul 2024 12:09:28 +0200 Subject: [PATCH 4/8] fixup --- x/tokenomics/keeper/settle_session_accounting.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/tokenomics/keeper/settle_session_accounting.go b/x/tokenomics/keeper/settle_session_accounting.go index 2e9b6e9cc..5ea6ff547 100644 --- a/x/tokenomics/keeper/settle_session_accounting.go +++ b/x/tokenomics/keeper/settle_session_accounting.go @@ -160,7 +160,7 @@ func (k Keeper) SettleSessionAccounting( } if err = cosmostypes.UnwrapSDKContext(ctx).EventManager().EmitTypedEvent(applicationOverservicedEvent); err != nil { return tokenomicstypes.ErrTokenomicsApplicationOverserviced.Wrapf( - "application address: %; expected burn %s; effective burn: %s", + "application address: %s; expected burn %s; effective burn: %s", application.GetAddress(), settlementAmt.String(), application.GetStake().String(), From 35532e181ab8150ac6bd454f765d7780f24045f4 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Mon, 15 Jul 2024 12:41:05 +0200 Subject: [PATCH 5/8] chore: review feedback improvements --- x/tokenomics/keeper/settle_session_accounting.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x/tokenomics/keeper/settle_session_accounting.go b/x/tokenomics/keeper/settle_session_accounting.go index 5ea6ff547..f9cfd96d5 100644 --- a/x/tokenomics/keeper/settle_session_accounting.go +++ b/x/tokenomics/keeper/settle_session_accounting.go @@ -158,7 +158,9 @@ func (k Keeper) SettleSessionAccounting( ExpectedBurn: &settlementAmt, EffectiveBurn: application.GetStake(), } - if err = cosmostypes.UnwrapSDKContext(ctx).EventManager().EmitTypedEvent(applicationOverservicedEvent); err != nil { + + 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(), From b3235404a73387f855731da2a1b88e0847c54906 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 16 Jul 2024 10:16:25 +0200 Subject: [PATCH 6/8] chore: review feedback --- .../keeper/settle_session_accounting.go | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/x/tokenomics/keeper/settle_session_accounting.go b/x/tokenomics/keeper/settle_session_accounting.go index f9cfd96d5..da67c0159 100644 --- a/x/tokenomics/keeper/settle_session_accounting.go +++ b/x/tokenomics/keeper/settle_session_accounting.go @@ -29,12 +29,12 @@ func (k Keeper) SettleSessionAccounting( ) error { logger := k.Logger().With("method", "SettleSessionAccounting") - settlementAmt := cosmostypes.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 { return float32(settlementAmt.Amount.Int64()) }, + func() float32 { return float32(settlementCoin.Amount.Int64()) }, func() bool { return isSuccessful }, ) @@ -96,13 +96,13 @@ func (k Keeper) SettleSessionAccounting( logger.Info(fmt.Sprintf("About to start settling claim for %d compute units", claimComputeUnits)) // Calculate the amount of tokens to mint & burn - settlementAmt = k.getCoinFromComputeUnits(ctx, root) - settlementAmtuPOKT := cosmostypes.NewCoins(settlementAmt) + settlementCoin = k.getCoinFromComputeUnits(ctx, root) + settlementCoins := cosmostypes.NewCoins(settlementCoin) logger.Info(fmt.Sprintf( "%d compute units equate to %s for session %s", claimComputeUnits, - settlementAmt, + settlementCoin, sessionHeader.SessionId, )) @@ -114,48 +114,49 @@ 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 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 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.GetStake().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 = cosmostypes.NewCoin("upokt", math.Int(application.Stake.Amount)) - settlementAmtuPOKT = cosmostypes.NewCoins(settlementAmt) + expectedBurn := application.Stake + settlementCoin = *application.Stake + settlementCoins = cosmostypes.NewCoins(settlementCoin) applicationOverservicedEvent := &tokenomicstypes.EventApplicationOverserviced{ ApplicationAddr: applicationAddress.String(), - ExpectedBurn: &settlementAmt, + ExpectedBurn: expectedBurn, EffectiveBurn: application.GetStake(), } @@ -164,7 +165,7 @@ func (k Keeper) SettleSessionAccounting( return tokenomicstypes.ErrTokenomicsApplicationOverserviced.Wrapf( "application address: %s; expected burn %s; effective burn: %s", application.GetAddress(), - settlementAmt.String(), + expectedBurn.String(), application.GetStake().String(), ) } @@ -173,14 +174,14 @@ func (k Keeper) SettleSessionAccounting( // 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 tokenomicstypes.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 tokenomicstypes.ErrTokenomicsApplicationNewStakeInvalid.Wrapf("application %q stake cannot be reduced to a negative amount %v", applicationAddress, newAppStake) } From 4ccd7740f28cbaea03e07610411a08145503e3dc Mon Sep 17 00:00:00 2001 From: Bryan White Date: Tue, 16 Jul 2024 18:04:08 +0200 Subject: [PATCH 7/8] fix EventApplicationOverserviced & test --- api/poktroll/tokenomics/event.pulsar.go | 2 +- .../keeper/settle_session_accounting.go | 6 +++--- .../keeper/settle_session_accounting_test.go | 20 +++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/api/poktroll/tokenomics/event.pulsar.go b/api/poktroll/tokenomics/event.pulsar.go index abc75bb3c..8ea69eae8 100644 --- a/api/poktroll/tokenomics/event.pulsar.go +++ b/api/poktroll/tokenomics/event.pulsar.go @@ -3,10 +3,10 @@ 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" _ "github.com/cosmos/gogoproto/gogoproto" - proof "github.com/pokt-network/poktroll/api/poktroll/proof" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/x/tokenomics/keeper/settle_session_accounting.go b/x/tokenomics/keeper/settle_session_accounting.go index 0379109c4..e92f2b5d0 100644 --- a/x/tokenomics/keeper/settle_session_accounting.go +++ b/x/tokenomics/keeper/settle_session_accounting.go @@ -150,13 +150,13 @@ func (k Keeper) SettleSessionAccounting( // 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... - expectedBurn := application.Stake - settlementCoin = *application.Stake + expectedBurn := settlementCoin + settlementCoin = *application.GetStake() settlementCoins = cosmostypes.NewCoins(settlementCoin) applicationOverservicedEvent := &tokenomicstypes.EventApplicationOverserviced{ ApplicationAddr: applicationAddress.String(), - ExpectedBurn: expectedBurn, + ExpectedBurn: &expectedBurn, EffectiveBurn: application.GetStake(), } diff --git a/x/tokenomics/keeper/settle_session_accounting_test.go b/x/tokenomics/keeper/settle_session_accounting_test.go index 8a01fcbc8..480761b66 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" @@ -251,6 +252,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) { From cd8d232fbcf7e477f600a4841755f0a790eac695 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 17 Jul 2024 11:01:03 +0200 Subject: [PATCH 8/8] chore: review feedback improvements Co-authored-by: Daniel Olshansky --- x/tokenomics/keeper/settle_session_accounting.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/tokenomics/keeper/settle_session_accounting.go b/x/tokenomics/keeper/settle_session_accounting.go index e92f2b5d0..abefd8eed 100644 --- a/x/tokenomics/keeper/settle_session_accounting.go +++ b/x/tokenomics/keeper/settle_session_accounting.go @@ -151,6 +151,7 @@ func (k Keeper) SettleSessionAccounting( // 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... expectedBurn := settlementCoin + // Make the settlement amount the maximum stake that the application has remaining. settlementCoin = *application.GetStake() settlementCoins = cosmostypes.NewCoins(settlementCoin)