From fec5aea43ad71e59aa9423406411bc1d4a94a7c7 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Thu, 20 Jul 2023 12:16:02 +1000 Subject: [PATCH] Swap uint64s to wrapperspb --- pkg/proto/eth/v1/committee.pb.go | 61 +++++++++++-------- pkg/proto/eth/v1/committee.proto | 8 ++- .../event/beacon/eth/v1/beacon_committee.go | 9 +-- 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/pkg/proto/eth/v1/committee.pb.go b/pkg/proto/eth/v1/committee.pb.go index ca5a94e6..8c5f971f 100644 --- a/pkg/proto/eth/v1/committee.pb.go +++ b/pkg/proto/eth/v1/committee.pb.go @@ -11,6 +11,7 @@ package v1 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" reflect "reflect" sync "sync" ) @@ -28,9 +29,9 @@ type Committee struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` - Slot uint64 `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty"` - Validators []uint64 `protobuf:"varint,3,rep,packed,name=validators,proto3" json:"validators,omitempty"` + Index *wrapperspb.UInt64Value `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` + Slot *wrapperspb.UInt64Value `protobuf:"bytes,2,opt,name=slot,proto3" json:"slot,omitempty"` + Validators []*wrapperspb.UInt64Value `protobuf:"bytes,3,rep,name=validators,proto3" json:"validators,omitempty"` } func (x *Committee) Reset() { @@ -65,21 +66,21 @@ func (*Committee) Descriptor() ([]byte, []int) { return file_pkg_proto_eth_v1_committee_proto_rawDescGZIP(), []int{0} } -func (x *Committee) GetIndex() uint64 { +func (x *Committee) GetIndex() *wrapperspb.UInt64Value { if x != nil { return x.Index } - return 0 + return nil } -func (x *Committee) GetSlot() uint64 { +func (x *Committee) GetSlot() *wrapperspb.UInt64Value { if x != nil { return x.Slot } - return 0 + return nil } -func (x *Committee) GetValidators() []uint64 { +func (x *Committee) GetValidators() []*wrapperspb.UInt64Value { if x != nil { return x.Validators } @@ -91,16 +92,24 @@ var File_pkg_proto_eth_v1_committee_proto protoreflect.FileDescriptor var file_pkg_proto_eth_v1_committee_proto_rawDesc = []byte{ 0x0a, 0x20, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x0b, 0x78, 0x61, 0x74, 0x75, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x22, - 0x55, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x14, 0x0a, 0x05, - 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, - 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x04, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x74, 0x68, 0x70, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x70, 0x73, - 0x2f, 0x78, 0x61, 0x74, 0x75, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6f, 0x12, 0x0b, 0x78, 0x61, 0x74, 0x75, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x1a, + 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0xaf, 0x01, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x32, 0x0a, + 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, + 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, + 0x78, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x73, + 0x6c, 0x6f, 0x74, 0x12, 0x3c, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x73, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x65, 0x74, 0x68, 0x70, 0x61, 0x6e, 0x64, 0x61, 0x6f, 0x70, 0x73, 0x2f, 0x78, 0x61, 0x74, 0x75, + 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -117,14 +126,18 @@ func file_pkg_proto_eth_v1_committee_proto_rawDescGZIP() []byte { var file_pkg_proto_eth_v1_committee_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_pkg_proto_eth_v1_committee_proto_goTypes = []interface{}{ - (*Committee)(nil), // 0: xatu.eth.v1.Committee + (*Committee)(nil), // 0: xatu.eth.v1.Committee + (*wrapperspb.UInt64Value)(nil), // 1: google.protobuf.UInt64Value } var file_pkg_proto_eth_v1_committee_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: xatu.eth.v1.Committee.index:type_name -> google.protobuf.UInt64Value + 1, // 1: xatu.eth.v1.Committee.slot:type_name -> google.protobuf.UInt64Value + 1, // 2: xatu.eth.v1.Committee.validators:type_name -> google.protobuf.UInt64Value + 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_pkg_proto_eth_v1_committee_proto_init() } diff --git a/pkg/proto/eth/v1/committee.proto b/pkg/proto/eth/v1/committee.proto index 5e37f146..4a5ab9e7 100644 --- a/pkg/proto/eth/v1/committee.proto +++ b/pkg/proto/eth/v1/committee.proto @@ -4,11 +4,13 @@ syntax = "proto3"; package xatu.eth.v1; +import "google/protobuf/wrappers.proto"; + option go_package = "github.com/ethpandaops/xatu/pkg/proto/eth/v1"; // Committee is a set of validators that are assigned to a commitee for a given slot. message Committee { - uint64 index = 1; - uint64 slot = 2; - repeated uint64 validators = 3; + google.protobuf.UInt64Value index = 1; + google.protobuf.UInt64Value slot = 2; + repeated google.protobuf.UInt64Value validators = 3; } diff --git a/pkg/sentry/event/beacon/eth/v1/beacon_committee.go b/pkg/sentry/event/beacon/eth/v1/beacon_committee.go index 0c2fc2c6..56a42edb 100644 --- a/pkg/sentry/event/beacon/eth/v1/beacon_committee.go +++ b/pkg/sentry/event/beacon/eth/v1/beacon_committee.go @@ -14,6 +14,7 @@ import ( ttlcache "github.com/savid/ttlcache/v3" "github.com/sirupsen/logrus" "google.golang.org/protobuf/types/known/timestamppb" + "google.golang.org/protobuf/types/known/wrapperspb" ) type BeaconCommittee struct { @@ -44,9 +45,9 @@ func NewBeaconCommittee(log logrus.FieldLogger, event *v1.BeaconCommittee, epoch } func (e *BeaconCommittee) Decorate(ctx context.Context) (*xatu.DecoratedEvent, error) { - validators := make([]uint64, len(e.event.Validators)) + validators := make([]*wrapperspb.UInt64Value, len(e.event.Validators)) for i := range e.event.Validators { - validators[i] = uint64(e.event.Validators[i]) + validators[i] = &wrapperspb.UInt64Value{Value: uint64(e.event.Validators[i])} } decoratedEvent := &xatu.DecoratedEvent{ @@ -60,8 +61,8 @@ func (e *BeaconCommittee) Decorate(ctx context.Context) (*xatu.DecoratedEvent, e }, Data: &xatu.DecoratedEvent_EthV1BeaconCommittee{ EthV1BeaconCommittee: &xatuethv1.Committee{ - Slot: uint64(e.event.Slot), - Index: uint64(e.event.Index), + Slot: &wrapperspb.UInt64Value{Value: uint64(e.event.Slot)}, + Index: &wrapperspb.UInt64Value{Value: uint64(e.event.Index)}, Validators: validators, }, },