diff --git a/api/layer/oracle/aggregate.pulsar.go b/api/layer/oracle/aggregate.pulsar.go index 7f5db3581..3c4cbb05c 100644 --- a/api/layer/oracle/aggregate.pulsar.go +++ b/api/layer/oracle/aggregate.pulsar.go @@ -2,6 +2,7 @@ package oracle import ( + binary "encoding/binary" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" @@ -10,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" timestamppb "google.golang.org/protobuf/types/known/timestamppb" io "io" + math "math" reflect "reflect" sync "sync" ) @@ -1060,6 +1062,1029 @@ func (x *fastReflection_Aggregate) ProtoMethods() *protoiface.Methods { } } +var _ protoreflect.List = (*_LegacyAggregate_6_list)(nil) + +type _LegacyAggregate_6_list struct { + list *[]*AggregateReporter +} + +func (x *_LegacyAggregate_6_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_LegacyAggregate_6_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_LegacyAggregate_6_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*AggregateReporter) + (*x.list)[i] = concreteValue +} + +func (x *_LegacyAggregate_6_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*AggregateReporter) + *x.list = append(*x.list, concreteValue) +} + +func (x *_LegacyAggregate_6_list) AppendMutable() protoreflect.Value { + v := new(AggregateReporter) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_LegacyAggregate_6_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_LegacyAggregate_6_list) NewElement() protoreflect.Value { + v := new(AggregateReporter) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_LegacyAggregate_6_list) IsValid() bool { + return x.list != nil +} + +var ( + md_LegacyAggregate protoreflect.MessageDescriptor + fd_LegacyAggregate_query_id protoreflect.FieldDescriptor + fd_LegacyAggregate_aggregate_value protoreflect.FieldDescriptor + fd_LegacyAggregate_aggregate_reporter protoreflect.FieldDescriptor + fd_LegacyAggregate_reporter_power protoreflect.FieldDescriptor + fd_LegacyAggregate_standard_deviation protoreflect.FieldDescriptor + fd_LegacyAggregate_reporters protoreflect.FieldDescriptor + fd_LegacyAggregate_flagged protoreflect.FieldDescriptor + fd_LegacyAggregate_index protoreflect.FieldDescriptor + fd_LegacyAggregate_aggregate_report_index protoreflect.FieldDescriptor + fd_LegacyAggregate_height protoreflect.FieldDescriptor + fd_LegacyAggregate_micro_height protoreflect.FieldDescriptor +) + +func init() { + file_layer_oracle_aggregate_proto_init() + md_LegacyAggregate = File_layer_oracle_aggregate_proto.Messages().ByName("LegacyAggregate") + fd_LegacyAggregate_query_id = md_LegacyAggregate.Fields().ByName("query_id") + fd_LegacyAggregate_aggregate_value = md_LegacyAggregate.Fields().ByName("aggregate_value") + fd_LegacyAggregate_aggregate_reporter = md_LegacyAggregate.Fields().ByName("aggregate_reporter") + fd_LegacyAggregate_reporter_power = md_LegacyAggregate.Fields().ByName("reporter_power") + fd_LegacyAggregate_standard_deviation = md_LegacyAggregate.Fields().ByName("standard_deviation") + fd_LegacyAggregate_reporters = md_LegacyAggregate.Fields().ByName("reporters") + fd_LegacyAggregate_flagged = md_LegacyAggregate.Fields().ByName("flagged") + fd_LegacyAggregate_index = md_LegacyAggregate.Fields().ByName("index") + fd_LegacyAggregate_aggregate_report_index = md_LegacyAggregate.Fields().ByName("aggregate_report_index") + fd_LegacyAggregate_height = md_LegacyAggregate.Fields().ByName("height") + fd_LegacyAggregate_micro_height = md_LegacyAggregate.Fields().ByName("micro_height") +} + +var _ protoreflect.Message = (*fastReflection_LegacyAggregate)(nil) + +type fastReflection_LegacyAggregate LegacyAggregate + +func (x *LegacyAggregate) ProtoReflect() protoreflect.Message { + return (*fastReflection_LegacyAggregate)(x) +} + +func (x *LegacyAggregate) slowProtoReflect() protoreflect.Message { + mi := &file_layer_oracle_aggregate_proto_msgTypes[1] + 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_LegacyAggregate_messageType fastReflection_LegacyAggregate_messageType +var _ protoreflect.MessageType = fastReflection_LegacyAggregate_messageType{} + +type fastReflection_LegacyAggregate_messageType struct{} + +func (x fastReflection_LegacyAggregate_messageType) Zero() protoreflect.Message { + return (*fastReflection_LegacyAggregate)(nil) +} +func (x fastReflection_LegacyAggregate_messageType) New() protoreflect.Message { + return new(fastReflection_LegacyAggregate) +} +func (x fastReflection_LegacyAggregate_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_LegacyAggregate +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_LegacyAggregate) Descriptor() protoreflect.MessageDescriptor { + return md_LegacyAggregate +} + +// 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_LegacyAggregate) Type() protoreflect.MessageType { + return _fastReflection_LegacyAggregate_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_LegacyAggregate) New() protoreflect.Message { + return new(fastReflection_LegacyAggregate) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_LegacyAggregate) Interface() protoreflect.ProtoMessage { + return (*LegacyAggregate)(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_LegacyAggregate) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.QueryId) != 0 { + value := protoreflect.ValueOfBytes(x.QueryId) + if !f(fd_LegacyAggregate_query_id, value) { + return + } + } + if x.AggregateValue != "" { + value := protoreflect.ValueOfString(x.AggregateValue) + if !f(fd_LegacyAggregate_aggregate_value, value) { + return + } + } + if x.AggregateReporter != "" { + value := protoreflect.ValueOfString(x.AggregateReporter) + if !f(fd_LegacyAggregate_aggregate_reporter, value) { + return + } + } + if x.ReporterPower != int64(0) { + value := protoreflect.ValueOfInt64(x.ReporterPower) + if !f(fd_LegacyAggregate_reporter_power, value) { + return + } + } + if x.StandardDeviation != float64(0) || math.Signbit(x.StandardDeviation) { + value := protoreflect.ValueOfFloat64(x.StandardDeviation) + if !f(fd_LegacyAggregate_standard_deviation, value) { + return + } + } + if len(x.Reporters) != 0 { + value := protoreflect.ValueOfList(&_LegacyAggregate_6_list{list: &x.Reporters}) + if !f(fd_LegacyAggregate_reporters, value) { + return + } + } + if x.Flagged != false { + value := protoreflect.ValueOfBool(x.Flagged) + if !f(fd_LegacyAggregate_flagged, value) { + return + } + } + if x.Index != uint64(0) { + value := protoreflect.ValueOfUint64(x.Index) + if !f(fd_LegacyAggregate_index, value) { + return + } + } + if x.AggregateReportIndex != int64(0) { + value := protoreflect.ValueOfInt64(x.AggregateReportIndex) + if !f(fd_LegacyAggregate_aggregate_report_index, value) { + return + } + } + if x.Height != int64(0) { + value := protoreflect.ValueOfInt64(x.Height) + if !f(fd_LegacyAggregate_height, value) { + return + } + } + if x.MicroHeight != int64(0) { + value := protoreflect.ValueOfInt64(x.MicroHeight) + if !f(fd_LegacyAggregate_micro_height, 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_LegacyAggregate) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "layer.oracle.LegacyAggregate.query_id": + return len(x.QueryId) != 0 + case "layer.oracle.LegacyAggregate.aggregate_value": + return x.AggregateValue != "" + case "layer.oracle.LegacyAggregate.aggregate_reporter": + return x.AggregateReporter != "" + case "layer.oracle.LegacyAggregate.reporter_power": + return x.ReporterPower != int64(0) + case "layer.oracle.LegacyAggregate.standard_deviation": + return x.StandardDeviation != float64(0) || math.Signbit(x.StandardDeviation) + case "layer.oracle.LegacyAggregate.reporters": + return len(x.Reporters) != 0 + case "layer.oracle.LegacyAggregate.flagged": + return x.Flagged != false + case "layer.oracle.LegacyAggregate.index": + return x.Index != uint64(0) + case "layer.oracle.LegacyAggregate.aggregate_report_index": + return x.AggregateReportIndex != int64(0) + case "layer.oracle.LegacyAggregate.height": + return x.Height != int64(0) + case "layer.oracle.LegacyAggregate.micro_height": + return x.MicroHeight != int64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.LegacyAggregate")) + } + panic(fmt.Errorf("message layer.oracle.LegacyAggregate 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_LegacyAggregate) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "layer.oracle.LegacyAggregate.query_id": + x.QueryId = nil + case "layer.oracle.LegacyAggregate.aggregate_value": + x.AggregateValue = "" + case "layer.oracle.LegacyAggregate.aggregate_reporter": + x.AggregateReporter = "" + case "layer.oracle.LegacyAggregate.reporter_power": + x.ReporterPower = int64(0) + case "layer.oracle.LegacyAggregate.standard_deviation": + x.StandardDeviation = float64(0) + case "layer.oracle.LegacyAggregate.reporters": + x.Reporters = nil + case "layer.oracle.LegacyAggregate.flagged": + x.Flagged = false + case "layer.oracle.LegacyAggregate.index": + x.Index = uint64(0) + case "layer.oracle.LegacyAggregate.aggregate_report_index": + x.AggregateReportIndex = int64(0) + case "layer.oracle.LegacyAggregate.height": + x.Height = int64(0) + case "layer.oracle.LegacyAggregate.micro_height": + x.MicroHeight = int64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.LegacyAggregate")) + } + panic(fmt.Errorf("message layer.oracle.LegacyAggregate 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_LegacyAggregate) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "layer.oracle.LegacyAggregate.query_id": + value := x.QueryId + return protoreflect.ValueOfBytes(value) + case "layer.oracle.LegacyAggregate.aggregate_value": + value := x.AggregateValue + return protoreflect.ValueOfString(value) + case "layer.oracle.LegacyAggregate.aggregate_reporter": + value := x.AggregateReporter + return protoreflect.ValueOfString(value) + case "layer.oracle.LegacyAggregate.reporter_power": + value := x.ReporterPower + return protoreflect.ValueOfInt64(value) + case "layer.oracle.LegacyAggregate.standard_deviation": + value := x.StandardDeviation + return protoreflect.ValueOfFloat64(value) + case "layer.oracle.LegacyAggregate.reporters": + if len(x.Reporters) == 0 { + return protoreflect.ValueOfList(&_LegacyAggregate_6_list{}) + } + listValue := &_LegacyAggregate_6_list{list: &x.Reporters} + return protoreflect.ValueOfList(listValue) + case "layer.oracle.LegacyAggregate.flagged": + value := x.Flagged + return protoreflect.ValueOfBool(value) + case "layer.oracle.LegacyAggregate.index": + value := x.Index + return protoreflect.ValueOfUint64(value) + case "layer.oracle.LegacyAggregate.aggregate_report_index": + value := x.AggregateReportIndex + return protoreflect.ValueOfInt64(value) + case "layer.oracle.LegacyAggregate.height": + value := x.Height + return protoreflect.ValueOfInt64(value) + case "layer.oracle.LegacyAggregate.micro_height": + value := x.MicroHeight + return protoreflect.ValueOfInt64(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.LegacyAggregate")) + } + panic(fmt.Errorf("message layer.oracle.LegacyAggregate 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_LegacyAggregate) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "layer.oracle.LegacyAggregate.query_id": + x.QueryId = value.Bytes() + case "layer.oracle.LegacyAggregate.aggregate_value": + x.AggregateValue = value.Interface().(string) + case "layer.oracle.LegacyAggregate.aggregate_reporter": + x.AggregateReporter = value.Interface().(string) + case "layer.oracle.LegacyAggregate.reporter_power": + x.ReporterPower = value.Int() + case "layer.oracle.LegacyAggregate.standard_deviation": + x.StandardDeviation = value.Float() + case "layer.oracle.LegacyAggregate.reporters": + lv := value.List() + clv := lv.(*_LegacyAggregate_6_list) + x.Reporters = *clv.list + case "layer.oracle.LegacyAggregate.flagged": + x.Flagged = value.Bool() + case "layer.oracle.LegacyAggregate.index": + x.Index = value.Uint() + case "layer.oracle.LegacyAggregate.aggregate_report_index": + x.AggregateReportIndex = value.Int() + case "layer.oracle.LegacyAggregate.height": + x.Height = value.Int() + case "layer.oracle.LegacyAggregate.micro_height": + x.MicroHeight = value.Int() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.LegacyAggregate")) + } + panic(fmt.Errorf("message layer.oracle.LegacyAggregate 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_LegacyAggregate) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "layer.oracle.LegacyAggregate.reporters": + if x.Reporters == nil { + x.Reporters = []*AggregateReporter{} + } + value := &_LegacyAggregate_6_list{list: &x.Reporters} + return protoreflect.ValueOfList(value) + case "layer.oracle.LegacyAggregate.query_id": + panic(fmt.Errorf("field query_id of message layer.oracle.LegacyAggregate is not mutable")) + case "layer.oracle.LegacyAggregate.aggregate_value": + panic(fmt.Errorf("field aggregate_value of message layer.oracle.LegacyAggregate is not mutable")) + case "layer.oracle.LegacyAggregate.aggregate_reporter": + panic(fmt.Errorf("field aggregate_reporter of message layer.oracle.LegacyAggregate is not mutable")) + case "layer.oracle.LegacyAggregate.reporter_power": + panic(fmt.Errorf("field reporter_power of message layer.oracle.LegacyAggregate is not mutable")) + case "layer.oracle.LegacyAggregate.standard_deviation": + panic(fmt.Errorf("field standard_deviation of message layer.oracle.LegacyAggregate is not mutable")) + case "layer.oracle.LegacyAggregate.flagged": + panic(fmt.Errorf("field flagged of message layer.oracle.LegacyAggregate is not mutable")) + case "layer.oracle.LegacyAggregate.index": + panic(fmt.Errorf("field index of message layer.oracle.LegacyAggregate is not mutable")) + case "layer.oracle.LegacyAggregate.aggregate_report_index": + panic(fmt.Errorf("field aggregate_report_index of message layer.oracle.LegacyAggregate is not mutable")) + case "layer.oracle.LegacyAggregate.height": + panic(fmt.Errorf("field height of message layer.oracle.LegacyAggregate is not mutable")) + case "layer.oracle.LegacyAggregate.micro_height": + panic(fmt.Errorf("field micro_height of message layer.oracle.LegacyAggregate is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.LegacyAggregate")) + } + panic(fmt.Errorf("message layer.oracle.LegacyAggregate 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_LegacyAggregate) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "layer.oracle.LegacyAggregate.query_id": + return protoreflect.ValueOfBytes(nil) + case "layer.oracle.LegacyAggregate.aggregate_value": + return protoreflect.ValueOfString("") + case "layer.oracle.LegacyAggregate.aggregate_reporter": + return protoreflect.ValueOfString("") + case "layer.oracle.LegacyAggregate.reporter_power": + return protoreflect.ValueOfInt64(int64(0)) + case "layer.oracle.LegacyAggregate.standard_deviation": + return protoreflect.ValueOfFloat64(float64(0)) + case "layer.oracle.LegacyAggregate.reporters": + list := []*AggregateReporter{} + return protoreflect.ValueOfList(&_LegacyAggregate_6_list{list: &list}) + case "layer.oracle.LegacyAggregate.flagged": + return protoreflect.ValueOfBool(false) + case "layer.oracle.LegacyAggregate.index": + return protoreflect.ValueOfUint64(uint64(0)) + case "layer.oracle.LegacyAggregate.aggregate_report_index": + return protoreflect.ValueOfInt64(int64(0)) + case "layer.oracle.LegacyAggregate.height": + return protoreflect.ValueOfInt64(int64(0)) + case "layer.oracle.LegacyAggregate.micro_height": + return protoreflect.ValueOfInt64(int64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.LegacyAggregate")) + } + panic(fmt.Errorf("message layer.oracle.LegacyAggregate 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_LegacyAggregate) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in layer.oracle.LegacyAggregate", 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_LegacyAggregate) 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_LegacyAggregate) 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_LegacyAggregate) 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_LegacyAggregate) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*LegacyAggregate) + 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.QueryId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.AggregateValue) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.AggregateReporter) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.ReporterPower != 0 { + n += 1 + runtime.Sov(uint64(x.ReporterPower)) + } + if x.StandardDeviation != 0 || math.Signbit(x.StandardDeviation) { + n += 9 + } + if len(x.Reporters) > 0 { + for _, e := range x.Reporters { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.Flagged { + n += 2 + } + if x.Index != 0 { + n += 1 + runtime.Sov(uint64(x.Index)) + } + if x.AggregateReportIndex != 0 { + n += 1 + runtime.Sov(uint64(x.AggregateReportIndex)) + } + if x.Height != 0 { + n += 1 + runtime.Sov(uint64(x.Height)) + } + if x.MicroHeight != 0 { + n += 1 + runtime.Sov(uint64(x.MicroHeight)) + } + 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().(*LegacyAggregate) + 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.MicroHeight != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.MicroHeight)) + i-- + dAtA[i] = 0x58 + } + if x.Height != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Height)) + i-- + dAtA[i] = 0x50 + } + if x.AggregateReportIndex != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.AggregateReportIndex)) + i-- + dAtA[i] = 0x48 + } + if x.Index != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Index)) + i-- + dAtA[i] = 0x40 + } + if x.Flagged { + i-- + if x.Flagged { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } + if len(x.Reporters) > 0 { + for iNdEx := len(x.Reporters) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Reporters[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x32 + } + } + if x.StandardDeviation != 0 || math.Signbit(x.StandardDeviation) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.StandardDeviation)))) + i-- + dAtA[i] = 0x29 + } + if x.ReporterPower != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.ReporterPower)) + i-- + dAtA[i] = 0x20 + } + if len(x.AggregateReporter) > 0 { + i -= len(x.AggregateReporter) + copy(dAtA[i:], x.AggregateReporter) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AggregateReporter))) + i-- + dAtA[i] = 0x1a + } + if len(x.AggregateValue) > 0 { + i -= len(x.AggregateValue) + copy(dAtA[i:], x.AggregateValue) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AggregateValue))) + i-- + dAtA[i] = 0x12 + } + if len(x.QueryId) > 0 { + i -= len(x.QueryId) + copy(dAtA[i:], x.QueryId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.QueryId))) + 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().(*LegacyAggregate) + 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: LegacyAggregate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: LegacyAggregate: 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 QueryId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.QueryId = append(x.QueryId[:0], dAtA[iNdEx:postIndex]...) + if x.QueryId == nil { + x.QueryId = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AggregateValue", 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.AggregateValue = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AggregateReporter", 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.AggregateReporter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ReporterPower", wireType) + } + x.ReporterPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.ReporterPower |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field StandardDeviation", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.StandardDeviation = float64(math.Float64frombits(v)) + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Reporters", 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 + } + x.Reporters = append(x.Reporters, &AggregateReporter{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Reporters[len(x.Reporters)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Flagged", wireType) + } + var v 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++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.Flagged = bool(v != 0) + case 8: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + x.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AggregateReportIndex", wireType) + } + x.AggregateReportIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.AggregateReportIndex |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + x.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MicroHeight", wireType) + } + x.MicroHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.MicroHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + var _ protoreflect.List = (*_AvailableTimestamps_1_list)(nil) type _AvailableTimestamps_1_list struct { @@ -1131,7 +2156,7 @@ func (x *AvailableTimestamps) ProtoReflect() protoreflect.Message { } func (x *AvailableTimestamps) slowProtoReflect() protoreflect.Message { - mi := &file_layer_oracle_aggregate_proto_msgTypes[1] + mi := &file_layer_oracle_aggregate_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1694,6 +2719,133 @@ func (x *Aggregate) GetMicroHeight() int64 { return 0 } +// LegacyAggregate is the old aggregate struct, it is used to decode old aggregates +type LegacyAggregate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // query_id is the id of the query + QueryId []byte `protobuf:"bytes,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` + // aggregate_value is the value of the aggregate + AggregateValue string `protobuf:"bytes,2,opt,name=aggregate_value,json=aggregateValue,proto3" json:"aggregate_value,omitempty"` + // aggregate_reporter is the address of the reporter + AggregateReporter string `protobuf:"bytes,3,opt,name=aggregate_reporter,json=aggregateReporter,proto3" json:"aggregate_reporter,omitempty"` + // reporter_power is the power of the reporter + ReporterPower int64 `protobuf:"varint,4,opt,name=reporter_power,json=reporterPower,proto3" json:"reporter_power,omitempty"` + // standard_deviation is the standard deviation of the reports that were aggregated + StandardDeviation float64 `protobuf:"fixed64,5,opt,name=standard_deviation,json=standardDeviation,proto3" json:"standard_deviation,omitempty"` + // list of reporters that were included in the aggregate + Reporters []*AggregateReporter `protobuf:"bytes,6,rep,name=reporters,proto3" json:"reporters,omitempty"` + // flagged is true if the aggregate was flagged by a dispute + Flagged bool `protobuf:"varint,7,opt,name=flagged,proto3" json:"flagged,omitempty"` + // nonce is the nonce of the aggregate + Index uint64 `protobuf:"varint,8,opt,name=index,proto3" json:"index,omitempty"` + // aggregate_report_index is the index of the aggregate report in the micro reports + AggregateReportIndex int64 `protobuf:"varint,9,opt,name=aggregate_report_index,json=aggregateReportIndex,proto3" json:"aggregate_report_index,omitempty"` + // height of the aggregate report + Height int64 `protobuf:"varint,10,opt,name=height,proto3" json:"height,omitempty"` + // height of the micro report + MicroHeight int64 `protobuf:"varint,11,opt,name=micro_height,json=microHeight,proto3" json:"micro_height,omitempty"` +} + +func (x *LegacyAggregate) Reset() { + *x = LegacyAggregate{} + if protoimpl.UnsafeEnabled { + mi := &file_layer_oracle_aggregate_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LegacyAggregate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LegacyAggregate) ProtoMessage() {} + +// Deprecated: Use LegacyAggregate.ProtoReflect.Descriptor instead. +func (*LegacyAggregate) Descriptor() ([]byte, []int) { + return file_layer_oracle_aggregate_proto_rawDescGZIP(), []int{1} +} + +func (x *LegacyAggregate) GetQueryId() []byte { + if x != nil { + return x.QueryId + } + return nil +} + +func (x *LegacyAggregate) GetAggregateValue() string { + if x != nil { + return x.AggregateValue + } + return "" +} + +func (x *LegacyAggregate) GetAggregateReporter() string { + if x != nil { + return x.AggregateReporter + } + return "" +} + +func (x *LegacyAggregate) GetReporterPower() int64 { + if x != nil { + return x.ReporterPower + } + return 0 +} + +func (x *LegacyAggregate) GetStandardDeviation() float64 { + if x != nil { + return x.StandardDeviation + } + return 0 +} + +func (x *LegacyAggregate) GetReporters() []*AggregateReporter { + if x != nil { + return x.Reporters + } + return nil +} + +func (x *LegacyAggregate) GetFlagged() bool { + if x != nil { + return x.Flagged + } + return false +} + +func (x *LegacyAggregate) GetIndex() uint64 { + if x != nil { + return x.Index + } + return 0 +} + +func (x *LegacyAggregate) GetAggregateReportIndex() int64 { + if x != nil { + return x.AggregateReportIndex + } + return 0 +} + +func (x *LegacyAggregate) GetHeight() int64 { + if x != nil { + return x.Height + } + return 0 +} + +func (x *LegacyAggregate) GetMicroHeight() int64 { + if x != nil { + return x.MicroHeight + } + return 0 +} + type AvailableTimestamps struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1705,7 +2857,7 @@ type AvailableTimestamps struct { func (x *AvailableTimestamps) Reset() { *x = AvailableTimestamps{} if protoimpl.UnsafeEnabled { - mi := &file_layer_oracle_aggregate_proto_msgTypes[1] + mi := &file_layer_oracle_aggregate_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1719,7 +2871,7 @@ func (*AvailableTimestamps) ProtoMessage() {} // Deprecated: Use AvailableTimestamps.ProtoReflect.Descriptor instead. func (*AvailableTimestamps) Descriptor() ([]byte, []int) { - return file_layer_oracle_aggregate_proto_rawDescGZIP(), []int{1} + return file_layer_oracle_aggregate_proto_rawDescGZIP(), []int{2} } func (x *AvailableTimestamps) GetTimestamps() []*timestamppb.Timestamp { @@ -1768,23 +2920,51 @@ var file_layer_oracle_aggregate_proto_rawDesc = []byte{ 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x48, 0x65, 0x69, 0x67, 0x68, - 0x74, 0x22, 0x5b, 0x0a, 0x13, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, 0x12, 0x44, 0x0a, 0x0a, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, - 0x1f, 0x01, 0x52, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, 0x42, 0xa0, - 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x6f, 0x72, 0x61, - 0x63, 0x6c, 0x65, 0x42, 0x0e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x74, 0x65, 0x6c, 0x6c, 0x6f, 0x72, 0x2d, 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x79, 0x65, - 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x6f, 0x72, 0x61, 0x63, - 0x6c, 0x65, 0xa2, 0x02, 0x03, 0x4c, 0x4f, 0x58, 0xaa, 0x02, 0x0c, 0x4c, 0x61, 0x79, 0x65, 0x72, - 0x2e, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0xca, 0x02, 0x0c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x5c, - 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0xe2, 0x02, 0x18, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x4f, - 0x72, 0x61, 0x63, 0x6c, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x0d, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x3a, 0x3a, 0x4f, 0x72, 0x61, 0x63, 0x6c, - 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x22, 0xba, 0x03, 0x0a, 0x0f, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x41, 0x67, 0x67, 0x72, + 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x79, 0x49, 0x64, + 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, 0x67, 0x67, 0x72, 0x65, + 0x67, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x61, 0x67, 0x67, + 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x72, 0x5f, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x12, + 0x2d, 0x0a, 0x12, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x5f, 0x64, 0x65, 0x76, 0x69, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x11, 0x73, 0x74, 0x61, + 0x6e, 0x64, 0x61, 0x72, 0x64, 0x44, 0x65, 0x76, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3d, + 0x0a, 0x09, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x1f, 0x2e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, + 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x65, 0x72, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x73, 0x12, 0x18, 0x0a, + 0x07, 0x66, 0x6c, 0x61, 0x67, 0x67, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x66, 0x6c, 0x61, 0x67, 0x67, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x34, 0x0a, + 0x16, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x14, 0x61, + 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x6d, + 0x69, 0x63, 0x72, 0x6f, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0b, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x5b, + 0x0a, 0x13, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x73, 0x12, 0x44, 0x0a, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, + 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, 0x42, 0xa0, 0x01, 0x0a, 0x10, + 0x63, 0x6f, 0x6d, 0x2e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, + 0x42, 0x0e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, + 0x65, 0x6c, 0x6c, 0x6f, 0x72, 0x2d, 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0xa2, + 0x02, 0x03, 0x4c, 0x4f, 0x58, 0xaa, 0x02, 0x0c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x4f, 0x72, + 0x61, 0x63, 0x6c, 0x65, 0xca, 0x02, 0x0c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x4f, 0x72, 0x61, + 0x63, 0x6c, 0x65, 0xe2, 0x02, 0x18, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x4f, 0x72, 0x61, 0x63, + 0x6c, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x0d, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x3a, 0x3a, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1799,21 +2979,23 @@ func file_layer_oracle_aggregate_proto_rawDescGZIP() []byte { return file_layer_oracle_aggregate_proto_rawDescData } -var file_layer_oracle_aggregate_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_layer_oracle_aggregate_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_layer_oracle_aggregate_proto_goTypes = []interface{}{ (*Aggregate)(nil), // 0: layer.oracle.Aggregate - (*AvailableTimestamps)(nil), // 1: layer.oracle.AvailableTimestamps - (*AggregateReporter)(nil), // 2: layer.oracle.AggregateReporter - (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp + (*LegacyAggregate)(nil), // 1: layer.oracle.LegacyAggregate + (*AvailableTimestamps)(nil), // 2: layer.oracle.AvailableTimestamps + (*AggregateReporter)(nil), // 3: layer.oracle.AggregateReporter + (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp } var file_layer_oracle_aggregate_proto_depIdxs = []int32{ - 2, // 0: layer.oracle.Aggregate.reporters:type_name -> layer.oracle.AggregateReporter - 3, // 1: layer.oracle.AvailableTimestamps.timestamps:type_name -> google.protobuf.Timestamp - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 3, // 0: layer.oracle.Aggregate.reporters:type_name -> layer.oracle.AggregateReporter + 3, // 1: layer.oracle.LegacyAggregate.reporters:type_name -> layer.oracle.AggregateReporter + 4, // 2: layer.oracle.AvailableTimestamps.timestamps:type_name -> google.protobuf.Timestamp + 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 } func init() { file_layer_oracle_aggregate_proto_init() } @@ -1836,6 +3018,18 @@ func file_layer_oracle_aggregate_proto_init() { } } file_layer_oracle_aggregate_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LegacyAggregate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_layer_oracle_aggregate_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AvailableTimestamps); i { case 0: return &v.state @@ -1854,7 +3048,7 @@ func file_layer_oracle_aggregate_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_layer_oracle_aggregate_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/layer/oracle/aggregate.proto b/proto/layer/oracle/aggregate.proto index 8ef63eb1b..026171fe3 100644 --- a/proto/layer/oracle/aggregate.proto +++ b/proto/layer/oracle/aggregate.proto @@ -33,6 +33,33 @@ message Aggregate { int64 micro_height = 11; } +// LegacyAggregate is the old aggregate struct, it is used to decode old aggregates +message LegacyAggregate { + // query_id is the id of the query + bytes query_id = 1; + // aggregate_value is the value of the aggregate + string aggregate_value = 2; + // aggregate_reporter is the address of the reporter + string aggregate_reporter = 3; + // reporter_power is the power of the reporter + int64 reporter_power = 4; + // standard_deviation is the standard deviation of the reports that were aggregated + double standard_deviation = 5; + // list of reporters that were included in the aggregate + repeated AggregateReporter reporters = 6; + // flagged is true if the aggregate was flagged by a dispute + bool flagged = 7; + // nonce is the nonce of the aggregate + uint64 index = 8; + // aggregate_report_index is the index of the aggregate report in the micro reports + int64 aggregate_report_index = 9; + // height of the aggregate report + int64 height = 10; + // height of the micro report + int64 micro_height = 11; +} + + message AvailableTimestamps { repeated google.protobuf.Timestamp timestamps = 1 [ (gogoproto.nullable) = false, diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 9898784c8..27a65e4b4 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -5,6 +5,7 @@ import ( "context" "fmt" gomath "math" + "strconv" "time" "github.com/tellor-io/layer/utils" @@ -12,6 +13,7 @@ import ( regTypes "github.com/tellor-io/layer/x/registry/types" "cosmossdk.io/collections" + collcodec "cosmossdk.io/collections/codec" "cosmossdk.io/collections/indexes" "cosmossdk.io/core/store" "cosmossdk.io/log" @@ -65,7 +67,6 @@ func NewKeeper( } sb := collections.NewSchemaBuilder(storeService) - k := Keeper{ cdc: cdc, storeService: storeService, @@ -88,7 +89,7 @@ func NewKeeper( ), TotalTips: collections.NewMap(sb, types.TotalTipsPrefix, "total_tips", collections.Int64Key, sdk.IntValue), Nonces: collections.NewMap(sb, types.NoncesPrefix, "nonces", collections.BytesKey, collections.Uint64Value), - Aggregates: collections.NewIndexedMap(sb, types.AggregatesPrefix, "aggregates", collections.PairKeyCodec(collections.BytesKey, collections.Int64Key), codec.CollValue[types.Aggregate](cdc), types.NewAggregatesIndex(sb)), + Aggregates: collections.NewIndexedMap(sb, types.AggregatesPrefix, "aggregates", collections.PairKeyCodec(collections.BytesKey, collections.Int64Key), NewAggregateLegacyValueCodec(cdc), types.NewAggregatesIndex(sb)), Reports: collections.NewIndexedMap(sb, types.ReportsPrefix, "reports", @@ -125,6 +126,32 @@ func NewKeeper( return k } +func NewAggregateLegacyValueCodec(cdc codec.BinaryCodec) collcodec.ValueCodec[types.Aggregate] { + return collcodec.NewAltValueCodec(codec.CollValue[types.Aggregate](cdc), func(b []byte) (types.Aggregate, error) { + legacyAgg := types.LegacyAggregate{} + if err := cdc.Unmarshal(b, &legacyAgg); err != nil { + return types.Aggregate{}, err + } + + standardDeviation := strconv.FormatFloat(legacyAgg.StandardDeviation, 'f', -1, 64) + newAgg := types.Aggregate{ + QueryId: legacyAgg.QueryId, + AggregateValue: legacyAgg.AggregateValue, + AggregateReporter: legacyAgg.AggregateReporter, + ReporterPower: legacyAgg.ReporterPower, + StandardDeviation: standardDeviation, + Reporters: legacyAgg.Reporters, + Flagged: legacyAgg.Flagged, + Index: legacyAgg.Index, + AggregateReportIndex: legacyAgg.AggregateReportIndex, + Height: legacyAgg.Height, + MicroHeight: legacyAgg.MicroHeight, + } + + return newAgg, nil + }) +} + // GetAuthority returns the module's authority. func (k Keeper) GetAuthority() string { return k.authority diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index 2ccdc19ed..c979dee57 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -2,10 +2,15 @@ package keeper_test import ( "errors" + "fmt" + "strconv" "testing" "time" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmdb "github.com/cosmos/cosmos-db" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "github.com/tellor-io/layer/app/config" keepertest "github.com/tellor-io/layer/testutil/keeper" @@ -15,10 +20,18 @@ import ( "github.com/tellor-io/layer/x/oracle/mocks" "github.com/tellor-io/layer/x/oracle/types" regtypes "github.com/tellor-io/layer/x/registry/types" + "golang.org/x/exp/rand" "cosmossdk.io/collections" "cosmossdk.io/collections/indexes" + "cosmossdk.io/log" + "cosmossdk.io/store" + storemetrics "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -190,3 +203,117 @@ func (s *KeeperTestSuite) TestFlagAggregateReport() { require.NoError(err) require.True(aggregate.Flagged) } + +func TestAggregateLegacyCodec(t *testing.T) { + storeKey := storetypes.NewKVStoreKey(types.StoreKey) + storeSvc := runtime.NewKVStoreService(storeKey) + sb := collections.NewSchemaBuilder(storeSvc) + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db, log.NewNopLogger(), storemetrics.NewNoOpMetrics()) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + require.NoError(t, stateStore.LoadLatestVersion()) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + oldmap := collections.NewIndexedMap(sb, types.AggregatesPrefix, "aggregates", collections.PairKeyCodec(collections.BytesKey, collections.Int64Key), codec.CollValue[types.LegacyAggregate](cdc), newLegacyAggregatesIndex(sb)) + + // generate test data + testAggs := make([]types.LegacyAggregate, 100) + for i := 0; i < 100; i++ { + // make all values random + agg := types.LegacyAggregate{ + QueryId: []byte(fmt.Sprintf("queryId-%d", i)), + AggregateValue: fmt.Sprintf("aggregateValue-%d", i), + ReporterPower: int64(rand.Intn(1000)), + StandardDeviation: rand.Float64(), + Reporters: []*types.AggregateReporter{ + { + Reporter: sample.AccAddress(), + Power: int64(rand.Intn(1000)), + BlockNumber: int64(rand.Intn(1000)), + }, + { + Reporter: sample.AccAddress(), + Power: int64(rand.Intn(1000)), + BlockNumber: int64(rand.Intn(1000)), + }, + }, + Flagged: rand.Intn(2) == 1, // random bool + Index: uint64(rand.Intn(1000)), + AggregateReportIndex: int64(rand.Intn(1000)), + Height: int64(rand.Intn(1000)), + MicroHeight: int64(rand.Intn(1000)), + } + + err := oldmap.Set(ctx, collections.Join(agg.QueryId, agg.Height), agg) + require.NoError(t, err) + testAggs[i] = agg + } + + // now we replicate the issue, by walking the map + newMap := collections.NewIndexedMap(sb, types.AggregatesPrefix, "aggregates", collections.PairKeyCodec(collections.BytesKey, collections.Int64Key), codec.CollValue[types.Aggregate](cdc), types.NewAggregatesIndex(sb)) + + err := newMap.Walk(ctx, nil, func(key collections.Pair[[]byte, int64], value types.Aggregate) (stop bool, err error) { + return false, nil + }) + require.ErrorContains(t, err, "proto: wrong wireType = 1 for field StandardDeviation") + + // and finally we test the fix we've prepared + fixedNewMap := collections.NewIndexedMap(sb, types.AggregatesPrefix, "aggregates", collections.PairKeyCodec(collections.BytesKey, collections.Int64Key), keeper.NewAggregateLegacyValueCodec(cdc), types.NewAggregatesIndex(sb)) + count := 0 + + // add a new aggregate for good measure + agg := types.Aggregate{StandardDeviation: "0.1998"} + err = fixedNewMap.Set(ctx, collections.Join([]byte("queryId1998"), ctx.BlockTime().UnixMilli()), agg) + require.NoError(t, err) + + err = fixedNewMap.Walk(ctx, nil, func(key collections.Pair[[]byte, int64], value types.Aggregate) (stop bool, err error) { + parsedStdDev, err := strconv.ParseFloat(value.StandardDeviation, 64) + require.NoError(t, err) + + if count == 100 { // check the last value differently as it's not in the testAggs + if value.StandardDeviation != "0.1998" { + return false, fmt.Errorf("StandardDeviation not equal") + } + } else if testAggs[count].StandardDeviation != parsedStdDev { + return false, fmt.Errorf("StandardDeviation not equal") + } + count++ + return false, nil + }) + require.Equal(t, 101, count) // make sure we walked all the values successfully + require.NoError(t, err) +} + +type legacyAggregatesIndex struct { + BlockHeight *indexes.Multi[int64, collections.Pair[[]byte, int64], types.LegacyAggregate] + MicroHeight *indexes.Multi[int64, collections.Pair[[]byte, int64], types.LegacyAggregate] +} + +func (a legacyAggregatesIndex) IndexesList() []collections.Index[collections.Pair[[]byte, int64], types.LegacyAggregate] { + return []collections.Index[collections.Pair[[]byte, int64], types.LegacyAggregate]{ + a.BlockHeight, a.MicroHeight, + } +} + +func newLegacyAggregatesIndex(sb *collections.SchemaBuilder) legacyAggregatesIndex { + return legacyAggregatesIndex{ + BlockHeight: indexes.NewMulti( + sb, types.AggregatesHeightIndexPrefix, "aggregates_by_height", + collections.Int64Key, collections.PairKeyCodec[[]byte, int64](collections.BytesKey, collections.Int64Key), + func(_ collections.Pair[[]byte, int64], v types.LegacyAggregate) (int64, error) { + return v.Height, nil + }, + ), + MicroHeight: indexes.NewMulti( + sb, types.AggregatesMicroHeightIndexPrefix, "aggregates_by_micro_height", + collections.Int64Key, collections.PairKeyCodec[[]byte, int64](collections.BytesKey, collections.Int64Key), + func(_ collections.Pair[[]byte, int64], v types.LegacyAggregate) (int64, error) { + return v.MicroHeight, nil + }, + ), + } +} diff --git a/x/oracle/types/aggregate.pb.go b/x/oracle/types/aggregate.pb.go index 3909a3d44..34b98591f 100644 --- a/x/oracle/types/aggregate.pb.go +++ b/x/oracle/types/aggregate.pb.go @@ -4,6 +4,7 @@ package types import ( + encoding_binary "encoding/binary" fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -163,6 +164,142 @@ func (m *Aggregate) GetMicroHeight() int64 { return 0 } +// LegacyAggregate is the old aggregate struct, it is used to decode old aggregates +type LegacyAggregate struct { + // query_id is the id of the query + QueryId []byte `protobuf:"bytes,1,opt,name=query_id,json=queryId,proto3" json:"query_id,omitempty"` + // aggregate_value is the value of the aggregate + AggregateValue string `protobuf:"bytes,2,opt,name=aggregate_value,json=aggregateValue,proto3" json:"aggregate_value,omitempty"` + // aggregate_reporter is the address of the reporter + AggregateReporter string `protobuf:"bytes,3,opt,name=aggregate_reporter,json=aggregateReporter,proto3" json:"aggregate_reporter,omitempty"` + // reporter_power is the power of the reporter + ReporterPower int64 `protobuf:"varint,4,opt,name=reporter_power,json=reporterPower,proto3" json:"reporter_power,omitempty"` + // standard_deviation is the standard deviation of the reports that were aggregated + StandardDeviation float64 `protobuf:"fixed64,5,opt,name=standard_deviation,json=standardDeviation,proto3" json:"standard_deviation,omitempty"` + // list of reporters that were included in the aggregate + Reporters []*AggregateReporter `protobuf:"bytes,6,rep,name=reporters,proto3" json:"reporters,omitempty"` + // flagged is true if the aggregate was flagged by a dispute + Flagged bool `protobuf:"varint,7,opt,name=flagged,proto3" json:"flagged,omitempty"` + // nonce is the nonce of the aggregate + Index uint64 `protobuf:"varint,8,opt,name=index,proto3" json:"index,omitempty"` + // aggregate_report_index is the index of the aggregate report in the micro reports + AggregateReportIndex int64 `protobuf:"varint,9,opt,name=aggregate_report_index,json=aggregateReportIndex,proto3" json:"aggregate_report_index,omitempty"` + // height of the aggregate report + Height int64 `protobuf:"varint,10,opt,name=height,proto3" json:"height,omitempty"` + // height of the micro report + MicroHeight int64 `protobuf:"varint,11,opt,name=micro_height,json=microHeight,proto3" json:"micro_height,omitempty"` +} + +func (m *LegacyAggregate) Reset() { *m = LegacyAggregate{} } +func (m *LegacyAggregate) String() string { return proto.CompactTextString(m) } +func (*LegacyAggregate) ProtoMessage() {} +func (*LegacyAggregate) Descriptor() ([]byte, []int) { + return fileDescriptor_788ad347f505f8a6, []int{1} +} +func (m *LegacyAggregate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LegacyAggregate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LegacyAggregate.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 *LegacyAggregate) XXX_Merge(src proto.Message) { + xxx_messageInfo_LegacyAggregate.Merge(m, src) +} +func (m *LegacyAggregate) XXX_Size() int { + return m.Size() +} +func (m *LegacyAggregate) XXX_DiscardUnknown() { + xxx_messageInfo_LegacyAggregate.DiscardUnknown(m) +} + +var xxx_messageInfo_LegacyAggregate proto.InternalMessageInfo + +func (m *LegacyAggregate) GetQueryId() []byte { + if m != nil { + return m.QueryId + } + return nil +} + +func (m *LegacyAggregate) GetAggregateValue() string { + if m != nil { + return m.AggregateValue + } + return "" +} + +func (m *LegacyAggregate) GetAggregateReporter() string { + if m != nil { + return m.AggregateReporter + } + return "" +} + +func (m *LegacyAggregate) GetReporterPower() int64 { + if m != nil { + return m.ReporterPower + } + return 0 +} + +func (m *LegacyAggregate) GetStandardDeviation() float64 { + if m != nil { + return m.StandardDeviation + } + return 0 +} + +func (m *LegacyAggregate) GetReporters() []*AggregateReporter { + if m != nil { + return m.Reporters + } + return nil +} + +func (m *LegacyAggregate) GetFlagged() bool { + if m != nil { + return m.Flagged + } + return false +} + +func (m *LegacyAggregate) GetIndex() uint64 { + if m != nil { + return m.Index + } + return 0 +} + +func (m *LegacyAggregate) GetAggregateReportIndex() int64 { + if m != nil { + return m.AggregateReportIndex + } + return 0 +} + +func (m *LegacyAggregate) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *LegacyAggregate) GetMicroHeight() int64 { + if m != nil { + return m.MicroHeight + } + return 0 +} + type AvailableTimestamps struct { Timestamps []time.Time `protobuf:"bytes,1,rep,name=timestamps,proto3,stdtime" json:"timestamps"` } @@ -171,7 +308,7 @@ func (m *AvailableTimestamps) Reset() { *m = AvailableTimestamps{} } func (m *AvailableTimestamps) String() string { return proto.CompactTextString(m) } func (*AvailableTimestamps) ProtoMessage() {} func (*AvailableTimestamps) Descriptor() ([]byte, []int) { - return fileDescriptor_788ad347f505f8a6, []int{1} + return fileDescriptor_788ad347f505f8a6, []int{2} } func (m *AvailableTimestamps) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -209,42 +346,44 @@ func (m *AvailableTimestamps) GetTimestamps() []time.Time { func init() { proto.RegisterType((*Aggregate)(nil), "layer.oracle.Aggregate") + proto.RegisterType((*LegacyAggregate)(nil), "layer.oracle.LegacyAggregate") proto.RegisterType((*AvailableTimestamps)(nil), "layer.oracle.AvailableTimestamps") } func init() { proto.RegisterFile("layer/oracle/aggregate.proto", fileDescriptor_788ad347f505f8a6) } var fileDescriptor_788ad347f505f8a6 = []byte{ - // 451 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0xb3, 0xa4, 0xcd, 0x9f, 0x4d, 0x28, 0x62, 0x89, 0xaa, 0x25, 0x42, 0x8e, 0xa9, 0x54, - 0x61, 0x0e, 0xb5, 0x25, 0xe0, 0xca, 0x21, 0xa5, 0x07, 0x7a, 0x43, 0x16, 0xe2, 0x00, 0x07, 0x6b, - 0x13, 0x4f, 0x37, 0x2b, 0x6d, 0xb2, 0x66, 0xbd, 0x09, 0xcd, 0x5b, 0xf4, 0x61, 0x78, 0x88, 0x1e, - 0x7b, 0xe4, 0x04, 0x28, 0x79, 0x11, 0x94, 0xdd, 0xac, 0x1b, 0x85, 0xde, 0x3c, 0xdf, 0xef, 0x9b, - 0x19, 0x8f, 0xfd, 0xe1, 0x17, 0x92, 0x2d, 0x41, 0x27, 0x4a, 0xb3, 0xb1, 0x84, 0x84, 0x71, 0xae, - 0x81, 0x33, 0x03, 0x71, 0xa1, 0x95, 0x51, 0xa4, 0x6b, 0x69, 0xec, 0x68, 0xbf, 0xc7, 0x15, 0x57, - 0x16, 0x24, 0x9b, 0x27, 0xe7, 0xe9, 0x0f, 0xb8, 0x52, 0x5c, 0x42, 0x62, 0xab, 0xd1, 0xfc, 0x2a, - 0x31, 0x62, 0x0a, 0xa5, 0x61, 0xd3, 0x62, 0x6b, 0x38, 0x7d, 0x78, 0x45, 0xa6, 0xa1, 0x50, 0xda, - 0x80, 0x76, 0xb6, 0x93, 0x9f, 0x75, 0xdc, 0x1e, 0x7a, 0x48, 0x9e, 0xe3, 0xd6, 0xf7, 0x39, 0xe8, - 0x65, 0x26, 0x72, 0x8a, 0x42, 0x14, 0x75, 0xd3, 0xa6, 0xad, 0x2f, 0x73, 0xf2, 0x0a, 0x3f, 0xb9, - 0x1f, 0xb2, 0x60, 0x72, 0x0e, 0xf4, 0x51, 0x88, 0xa2, 0x76, 0x7a, 0x54, 0xc9, 0x5f, 0x36, 0x2a, - 0x39, 0xc3, 0xe4, 0xff, 0x6d, 0xb4, 0x6e, 0xbd, 0x4f, 0x2b, 0x92, 0x6e, 0x01, 0x39, 0xc5, 0x47, - 0xde, 0x94, 0x15, 0xea, 0x07, 0x68, 0x7a, 0x10, 0xa2, 0xa8, 0x9e, 0x3e, 0xf6, 0xea, 0xa7, 0x8d, - 0xb8, 0x99, 0x5a, 0x1a, 0x36, 0xcb, 0x99, 0xce, 0xb3, 0x1c, 0x16, 0x82, 0x19, 0xa1, 0x66, 0xf4, - 0xd0, 0x4d, 0xf5, 0xe4, 0xc2, 0x03, 0xf2, 0x1e, 0xb7, 0x7d, 0x7f, 0x49, 0x1b, 0x61, 0x3d, 0xea, - 0xbc, 0x19, 0xc4, 0xbb, 0x9f, 0x35, 0x1e, 0xee, 0xbf, 0x49, 0x7a, 0xdf, 0x41, 0x28, 0x6e, 0x5e, - 0x49, 0xc6, 0x39, 0xe4, 0xb4, 0x19, 0xa2, 0xa8, 0x95, 0xfa, 0x92, 0xf4, 0xf0, 0xa1, 0x98, 0xe5, - 0x70, 0x4d, 0x5b, 0x21, 0x8a, 0x0e, 0x52, 0x57, 0x90, 0x77, 0xf8, 0x78, 0xff, 0xe6, 0xcc, 0xd9, - 0xda, 0xf6, 0x98, 0xde, 0xde, 0xdd, 0x97, 0xb6, 0xeb, 0x18, 0x37, 0x26, 0x20, 0xf8, 0xc4, 0x50, - 0x6c, 0x5d, 0xdb, 0x8a, 0xbc, 0xc4, 0xdd, 0xa9, 0x18, 0x6b, 0x95, 0x6d, 0x69, 0xc7, 0xd2, 0x8e, - 0xd5, 0x3e, 0x5a, 0xe9, 0xe4, 0x1b, 0x7e, 0x36, 0x5c, 0x30, 0x21, 0xd9, 0x48, 0xc2, 0x67, 0xff, - 0xe7, 0x4b, 0x72, 0x81, 0x71, 0x95, 0x83, 0x92, 0x22, 0x7b, 0x77, 0x3f, 0x76, 0x51, 0x89, 0x7d, - 0x54, 0xe2, 0xaa, 0xe1, 0xbc, 0x75, 0xfb, 0x7b, 0x50, 0xbb, 0xf9, 0x33, 0x40, 0xe9, 0x4e, 0xdf, - 0xf9, 0x87, 0xdb, 0x55, 0x80, 0xee, 0x56, 0x01, 0xfa, 0xbb, 0x0a, 0xd0, 0xcd, 0x3a, 0xa8, 0xdd, - 0xad, 0x83, 0xda, 0xaf, 0x75, 0x50, 0xfb, 0xfa, 0x9a, 0x0b, 0x33, 0x99, 0x8f, 0xe2, 0xb1, 0x9a, - 0x26, 0x06, 0xa4, 0x54, 0xfa, 0x4c, 0xa8, 0xc4, 0x25, 0xed, 0xda, 0x67, 0xcd, 0x2c, 0x0b, 0x28, - 0x47, 0x0d, 0xbb, 0xee, 0xed, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcd, 0x8f, 0x0c, 0x7a, 0xeb, - 0x02, 0x00, 0x00, + // 472 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x94, 0xcf, 0x6e, 0x13, 0x31, + 0x10, 0xc6, 0x63, 0xb6, 0xcd, 0x1f, 0x27, 0xb4, 0xc2, 0x44, 0x95, 0x89, 0xd0, 0x66, 0xa9, 0x54, + 0xb1, 0x1c, 0xba, 0x2b, 0x01, 0x57, 0x0e, 0x29, 0x3d, 0x50, 0x89, 0x03, 0x5a, 0x21, 0x0e, 0x70, + 0x58, 0x39, 0xd9, 0xa9, 0x63, 0xc9, 0x89, 0x17, 0xaf, 0x13, 0x9a, 0xb7, 0xe8, 0xc3, 0x70, 0xe2, + 0x09, 0x7a, 0xec, 0x91, 0x13, 0xa0, 0xe4, 0x45, 0x50, 0xbc, 0xf1, 0x36, 0x0a, 0xbc, 0x00, 0xe2, + 0xb6, 0xf3, 0xfd, 0xbe, 0x99, 0xd9, 0xb1, 0x35, 0xc6, 0x8f, 0x25, 0x5b, 0x80, 0x8e, 0x95, 0x66, + 0x23, 0x09, 0x31, 0xe3, 0x5c, 0x03, 0x67, 0x06, 0xa2, 0x5c, 0x2b, 0xa3, 0x48, 0xc7, 0xd2, 0xa8, + 0xa4, 0xbd, 0x2e, 0x57, 0x5c, 0x59, 0x10, 0xaf, 0xbf, 0x4a, 0x4f, 0xaf, 0xcf, 0x95, 0xe2, 0x12, + 0x62, 0x1b, 0x0d, 0x67, 0x97, 0xb1, 0x11, 0x13, 0x28, 0x0c, 0x9b, 0xe4, 0x1b, 0xc3, 0xc9, 0xdf, + 0x5b, 0xa4, 0x1a, 0x72, 0xa5, 0x0d, 0xe8, 0xd2, 0x76, 0xfc, 0xd5, 0xc3, 0xad, 0x81, 0x83, 0xe4, + 0x11, 0x6e, 0x7e, 0x9e, 0x81, 0x5e, 0xa4, 0x22, 0xa3, 0x28, 0x40, 0x61, 0x27, 0x69, 0xd8, 0xf8, + 0x22, 0x23, 0x4f, 0xf1, 0xe1, 0x5d, 0x91, 0x39, 0x93, 0x33, 0xa0, 0xf7, 0x02, 0x14, 0xb6, 0x92, + 0x83, 0x4a, 0xfe, 0xb0, 0x56, 0xc9, 0x29, 0x26, 0x7f, 0x76, 0xa3, 0x9e, 0xf5, 0x3e, 0xa8, 0x48, + 0xb2, 0x01, 0xe4, 0x04, 0x1f, 0x38, 0x53, 0x9a, 0xab, 0x2f, 0xa0, 0xe9, 0x5e, 0x80, 0x42, 0x2f, + 0xb9, 0xef, 0xd4, 0x77, 0x6b, 0x71, 0x5d, 0xb5, 0x30, 0x6c, 0x9a, 0x31, 0x9d, 0xa5, 0x19, 0xcc, + 0x05, 0x33, 0x42, 0x4d, 0xe9, 0x7e, 0x59, 0xd5, 0x91, 0x73, 0x07, 0xc8, 0x2b, 0xdc, 0x72, 0xf9, + 0x05, 0xad, 0x07, 0x5e, 0xd8, 0x7e, 0xde, 0x8f, 0xb6, 0x8f, 0x35, 0x1a, 0xec, 0xfe, 0x49, 0x72, + 0x97, 0x41, 0x28, 0x6e, 0x5c, 0x4a, 0xc6, 0x39, 0x64, 0xb4, 0x11, 0xa0, 0xb0, 0x99, 0xb8, 0x90, + 0x74, 0xf1, 0xbe, 0x98, 0x66, 0x70, 0x45, 0x9b, 0x01, 0x0a, 0xf7, 0x92, 0x32, 0x20, 0x2f, 0xf1, + 0xd1, 0xee, 0xcc, 0x69, 0x69, 0x6b, 0xd9, 0x61, 0xba, 0x3b, 0x73, 0x5f, 0xd8, 0xac, 0x23, 0x5c, + 0x1f, 0x83, 0xe0, 0x63, 0x43, 0xb1, 0x75, 0x6d, 0x22, 0xf2, 0x04, 0x77, 0x26, 0x62, 0xa4, 0x55, + 0xba, 0xa1, 0x6d, 0x4b, 0xdb, 0x56, 0x7b, 0x63, 0xa5, 0xe3, 0x6f, 0x1e, 0x3e, 0x7c, 0x0b, 0x9c, + 0x8d, 0x16, 0xff, 0xf6, 0xe5, 0xa1, 0xff, 0xf1, 0xf2, 0x3e, 0xe1, 0x87, 0x83, 0x39, 0x13, 0x92, + 0x0d, 0x25, 0xbc, 0x77, 0x6b, 0x5b, 0x90, 0x73, 0x8c, 0xab, 0x25, 0x2e, 0x28, 0xb2, 0x73, 0xf7, + 0xa2, 0x72, 0xcf, 0x23, 0xb7, 0xe7, 0x51, 0x95, 0x70, 0xd6, 0xbc, 0xf9, 0xd1, 0xaf, 0x5d, 0xff, + 0xec, 0xa3, 0x64, 0x2b, 0xef, 0xec, 0xf5, 0xcd, 0xd2, 0x47, 0xb7, 0x4b, 0x1f, 0xfd, 0x5a, 0xfa, + 0xe8, 0x7a, 0xe5, 0xd7, 0x6e, 0x57, 0x7e, 0xed, 0xfb, 0xca, 0xaf, 0x7d, 0x7c, 0xc6, 0x85, 0x19, + 0xcf, 0x86, 0xd1, 0x48, 0x4d, 0x62, 0x03, 0x52, 0x2a, 0x7d, 0x2a, 0x54, 0x5c, 0x3e, 0x13, 0x57, + 0xee, 0xa1, 0x30, 0x8b, 0x1c, 0x8a, 0x61, 0xdd, 0xb6, 0x7b, 0xf1, 0x3b, 0x00, 0x00, 0xff, 0xff, + 0x75, 0xbf, 0x11, 0xd6, 0xa8, 0x04, 0x00, 0x00, } func (m *Aggregate) Marshal() (dAtA []byte, err error) { @@ -347,6 +486,105 @@ func (m *Aggregate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *LegacyAggregate) 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 *LegacyAggregate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LegacyAggregate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MicroHeight != 0 { + i = encodeVarintAggregate(dAtA, i, uint64(m.MicroHeight)) + i-- + dAtA[i] = 0x58 + } + if m.Height != 0 { + i = encodeVarintAggregate(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x50 + } + if m.AggregateReportIndex != 0 { + i = encodeVarintAggregate(dAtA, i, uint64(m.AggregateReportIndex)) + i-- + dAtA[i] = 0x48 + } + if m.Index != 0 { + i = encodeVarintAggregate(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x40 + } + if m.Flagged { + i-- + if m.Flagged { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } + if len(m.Reporters) > 0 { + for iNdEx := len(m.Reporters) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Reporters[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAggregate(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.StandardDeviation != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.StandardDeviation)))) + i-- + dAtA[i] = 0x29 + } + if m.ReporterPower != 0 { + i = encodeVarintAggregate(dAtA, i, uint64(m.ReporterPower)) + i-- + dAtA[i] = 0x20 + } + if len(m.AggregateReporter) > 0 { + i -= len(m.AggregateReporter) + copy(dAtA[i:], m.AggregateReporter) + i = encodeVarintAggregate(dAtA, i, uint64(len(m.AggregateReporter))) + i-- + dAtA[i] = 0x1a + } + if len(m.AggregateValue) > 0 { + i -= len(m.AggregateValue) + copy(dAtA[i:], m.AggregateValue) + i = encodeVarintAggregate(dAtA, i, uint64(len(m.AggregateValue))) + i-- + dAtA[i] = 0x12 + } + if len(m.QueryId) > 0 { + i -= len(m.QueryId) + copy(dAtA[i:], m.QueryId) + i = encodeVarintAggregate(dAtA, i, uint64(len(m.QueryId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *AvailableTimestamps) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -442,6 +680,54 @@ func (m *Aggregate) Size() (n int) { return n } +func (m *LegacyAggregate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.QueryId) + if l > 0 { + n += 1 + l + sovAggregate(uint64(l)) + } + l = len(m.AggregateValue) + if l > 0 { + n += 1 + l + sovAggregate(uint64(l)) + } + l = len(m.AggregateReporter) + if l > 0 { + n += 1 + l + sovAggregate(uint64(l)) + } + if m.ReporterPower != 0 { + n += 1 + sovAggregate(uint64(m.ReporterPower)) + } + if m.StandardDeviation != 0 { + n += 9 + } + if len(m.Reporters) > 0 { + for _, e := range m.Reporters { + l = e.Size() + n += 1 + l + sovAggregate(uint64(l)) + } + } + if m.Flagged { + n += 2 + } + if m.Index != 0 { + n += 1 + sovAggregate(uint64(m.Index)) + } + if m.AggregateReportIndex != 0 { + n += 1 + sovAggregate(uint64(m.AggregateReportIndex)) + } + if m.Height != 0 { + n += 1 + sovAggregate(uint64(m.Height)) + } + if m.MicroHeight != 0 { + n += 1 + sovAggregate(uint64(m.MicroHeight)) + } + return n +} + func (m *AvailableTimestamps) Size() (n int) { if m == nil { return 0 @@ -792,6 +1078,314 @@ func (m *Aggregate) Unmarshal(dAtA []byte) error { } return nil } +func (m *LegacyAggregate) 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 ErrIntOverflowAggregate + } + 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: LegacyAggregate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LegacyAggregate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAggregate + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAggregate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.QueryId = append(m.QueryId[:0], dAtA[iNdEx:postIndex]...) + if m.QueryId == nil { + m.QueryId = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AggregateValue", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + 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 ErrInvalidLengthAggregate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAggregate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AggregateValue = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AggregateReporter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + 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 ErrInvalidLengthAggregate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAggregate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AggregateReporter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReporterPower", wireType) + } + m.ReporterPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReporterPower |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field StandardDeviation", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.StandardDeviation = float64(math.Float64frombits(v)) + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reporters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAggregate + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAggregate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Reporters = append(m.Reporters, &AggregateReporter{}) + if err := m.Reporters[len(m.Reporters)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Flagged", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Flagged = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AggregateReportIndex", wireType) + } + m.AggregateReportIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AggregateReportIndex |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MicroHeight", wireType) + } + m.MicroHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MicroHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipAggregate(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAggregate + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *AvailableTimestamps) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/reporter/types/query.pb.go b/x/reporter/types/query.pb.go index 7801f5ccd..d53f0c79d 100644 --- a/x/reporter/types/query.pb.go +++ b/x/reporter/types/query.pb.go @@ -885,9 +885,9 @@ type QueryClient interface { AllowedAmountExpiration(ctx context.Context, in *QueryAllowedAmountExpirationRequest, opts ...grpc.CallOption) (*QueryAllowedAmountExpirationResponse, error) // NumOfSelectorsByReporter queries the number of selectors by a reporter. NumOfSelectorsByReporter(ctx context.Context, in *QueryNumOfSelectorsByReporterRequest, opts ...grpc.CallOption) (*QueryNumOfSelectorsByReporterResponse, error) - // SpaceAvailableByReporter queries the space available in a reporter. + // SpaceAvailableByReporter queries the space available in a reporter. SpaceAvailableByReporter(ctx context.Context, in *QuerySpaceAvailableByReporterRequest, opts ...grpc.CallOption) (*QuerySpaceAvailableByReporterResponse, error) - // AvailableTips queries the tips available for withdrawal for a given selector. + // AvailableTips queries the tips available for withdrawal for a given selector. AvailableTips(ctx context.Context, in *QueryAvailableTipsRequest, opts ...grpc.CallOption) (*QueryAvailableTipsResponse, error) } @@ -984,9 +984,9 @@ type QueryServer interface { AllowedAmountExpiration(context.Context, *QueryAllowedAmountExpirationRequest) (*QueryAllowedAmountExpirationResponse, error) // NumOfSelectorsByReporter queries the number of selectors by a reporter. NumOfSelectorsByReporter(context.Context, *QueryNumOfSelectorsByReporterRequest) (*QueryNumOfSelectorsByReporterResponse, error) - // SpaceAvailableByReporter queries the space available in a reporter. + // SpaceAvailableByReporter queries the space available in a reporter. SpaceAvailableByReporter(context.Context, *QuerySpaceAvailableByReporterRequest) (*QuerySpaceAvailableByReporterResponse, error) - // AvailableTips queries the tips available for withdrawal for a given selector. + // AvailableTips queries the tips available for withdrawal for a given selector. AvailableTips(context.Context, *QueryAvailableTipsRequest) (*QueryAvailableTipsResponse, error) }