diff --git a/app/peerinfo/adhoc.go b/app/peerinfo/adhoc.go index fc720fb6c..057c0d102 100644 --- a/app/peerinfo/adhoc.go +++ b/app/peerinfo/adhoc.go @@ -22,8 +22,9 @@ func DoOnce(ctx context.Context, tcpNode host.Host, peerID peer.ID) (*pbv1.PeerI rtt = d } + req := new(pbv1.PeerInfo) // TODO(corver): Populate request fields and make them required. resp := new(pbv1.PeerInfo) - err := p2p.SendReceive(ctx, tcpNode, peerID, &pbv1.PeerInfo{}, resp, protocolID1, + err := p2p.SendReceive(ctx, tcpNode, peerID, req, resp, protocolID1, p2p.WithSendReceiveRTT(rttCallback), p2p.WithDelimitedProtocol(protocolID2)) if err != nil { return nil, 0, false, err diff --git a/app/peerinfo/peerinfo.go b/app/peerinfo/peerinfo.go index 1ebceef1e..4e1fda820 100644 --- a/app/peerinfo/peerinfo.go +++ b/app/peerinfo/peerinfo.go @@ -177,6 +177,9 @@ func (p *PeerInfo) sendOnce(ctx context.Context, now time.Time) { p2p.WithSendReceiveRTT(rttCallback), p2p.WithDelimitedProtocol(protocolID2)) if err != nil { return // Logging handled by send func. + } else if resp.SentAt == nil || resp.StartedAt == nil { + log.Error(ctx, "Invalid peerinfo response", err, z.Str("peer", p2p.PeerName(peerID))) + return } expectedSentAt := time.Now().Add(-rtt / 2) diff --git a/app/peerinfo/peerinfopb/v1/peerinfo.pb.go b/app/peerinfo/peerinfopb/v1/peerinfo.pb.go index 8eab23223..9141e8658 100644 --- a/app/peerinfo/peerinfopb/v1/peerinfo.pb.go +++ b/app/peerinfo/peerinfopb/v1/peerinfo.pb.go @@ -28,9 +28,9 @@ type PeerInfo struct { CharonVersion string `protobuf:"bytes,1,opt,name=charon_version,json=charonVersion,proto3" json:"charon_version,omitempty"` LockHash []byte `protobuf:"bytes,2,opt,name=lock_hash,json=lockHash,proto3" json:"lock_hash,omitempty"` - SentAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=sent_at,json=sentAt,proto3" json:"sent_at,omitempty"` + SentAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=sent_at,json=sentAt,proto3,oneof" json:"sent_at,omitempty"` GitHash string `protobuf:"bytes,4,opt,name=git_hash,json=gitHash,proto3" json:"git_hash,omitempty"` - StartedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=started_at,json=startedAt,proto3" json:"started_at,omitempty"` + StartedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=started_at,json=startedAt,proto3,oneof" json:"started_at,omitempty"` } func (x *PeerInfo) Reset() { @@ -109,25 +109,27 @@ var file_app_peerinfo_peerinfopb_v1_peerinfo_proto_rawDesc = []byte{ 0x2e, 0x70, 0x65, 0x65, 0x72, 0x69, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x65, 0x65, 0x72, 0x69, 0x6e, 0x66, 0x6f, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd9, 0x01, 0x0a, 0x08, 0x50, 0x65, 0x65, + 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xfe, 0x01, 0x0a, 0x08, 0x50, 0x65, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x68, 0x61, 0x72, 0x6f, 0x6e, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x68, 0x61, 0x72, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x08, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x33, 0x0a, 0x07, 0x73, 0x65, 0x6e, + 0x08, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x38, 0x0a, 0x07, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 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, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x41, 0x74, 0x12, 0x19, - 0x0a, 0x08, 0x67, 0x69, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x67, 0x69, 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, - 0x72, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 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, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6f, 0x62, 0x6f, 0x6c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x63, - 0x68, 0x61, 0x72, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x65, 0x65, 0x72, 0x69, 0x6e, - 0x66, 0x6f, 0x2f, 0x70, 0x65, 0x65, 0x72, 0x69, 0x6e, 0x66, 0x6f, 0x70, 0x62, 0x2f, 0x76, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x48, 0x00, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x41, 0x74, + 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x69, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x69, 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, 0x3e, + 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, + 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, 0x48, 0x01, + 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x41, 0x74, 0x88, 0x01, 0x01, 0x42, 0x0a, + 0x0a, 0x08, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x74, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x62, 0x6f, 0x6c, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x2f, 0x63, 0x68, 0x61, 0x72, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, + 0x65, 0x65, 0x72, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x70, 0x65, 0x65, 0x72, 0x69, 0x6e, 0x66, 0x6f, + 0x70, 0x62, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -176,6 +178,7 @@ func file_app_peerinfo_peerinfopb_v1_peerinfo_proto_init() { } } } + file_app_peerinfo_peerinfopb_v1_peerinfo_proto_msgTypes[0].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/peerinfo/peerinfopb/v1/peerinfo.proto b/app/peerinfo/peerinfopb/v1/peerinfo.proto index 3128a792d..8be280928 100644 --- a/app/peerinfo/peerinfopb/v1/peerinfo.proto +++ b/app/peerinfo/peerinfopb/v1/peerinfo.proto @@ -7,9 +7,11 @@ option go_package = "github.com/obolnetwork/charon/app/peerinfo/peerinfopb/v1"; import "google/protobuf/timestamp.proto"; message PeerInfo { - string charon_version = 1; - bytes lock_hash = 2; - google.protobuf.Timestamp sent_at = 3; - string git_hash = 4; - google.protobuf.Timestamp started_at = 5; + string charon_version = 1; + bytes lock_hash = 2; + optional google.protobuf.Timestamp sent_at = 3; + string git_hash = 4; + optional google.protobuf.Timestamp started_at = 5; + + // TODO(corver): Always populate timestamps when sending, then make them required after subsequent release. } diff --git a/app/protonil/protonil.go b/app/protonil/protonil.go index fe3811392..c9fd03e60 100644 --- a/app/protonil/protonil.go +++ b/app/protonil/protonil.go @@ -24,6 +24,10 @@ const maxFieldNumber = 64 // Note this only applies to "message" fields, not primitive scalars or "map" or "list" fields // since their zero values are valid. func Check(msg proto.Message) error { + if msg == nil { + return errors.New("nil protobuf message") + } + rMsg := msg.ProtoReflect() if !rMsg.IsValid() { return errors.New("nil protobuf message") @@ -46,8 +50,44 @@ func Check(msg proto.Message) error { } checked++ - if field.IsMap() || field.IsList() { - // Nil maps and lists are equivalent to empty maps and lists. + // Check the values of map fields. + if field.IsMap() { + var err error + rMsg.Get(field).Map().Range(func(_ protoreflect.MapKey, val protoreflect.Value) bool { + value, ok := valueToMsg(val) + if !ok { + // Not a message value type. + return false + } + + err = Check(value.Interface()) + + return err == nil + }) + + if err != nil { + return errors.Wrap(err, "map value", z.Any("map", field.Name())) + } + + continue + } + + // Check elements of list fields. + if field.IsList() { + list := rMsg.Get(field).List() + for i := 0; i < list.Len(); i++ { + elem, ok := valueToMsg(list.Get(i)) + if !ok { + // Not a message element type. + break + } + + if err := Check(elem.Interface()); err != nil { + return errors.Wrap(err, "list element", + z.Any("list", field.Name()), z.Int("index", i)) + } + } + continue } @@ -80,3 +120,15 @@ func Check(msg proto.Message) error { return nil } + +// valueToMsg converts a protoreflect.Value to a protoreflect.Message if possible. +func valueToMsg(val protoreflect.Value) (protoreflect.Message, bool) { + iface := val.Interface() + if iface == nil { + return nil, false + } + + elemMsg, ok := iface.(protoreflect.Message) + + return elemMsg, ok +} diff --git a/app/protonil/protonil_test.go b/app/protonil/protonil_test.go index 30a1e5990..d66321dc8 100644 --- a/app/protonil/protonil_test.go +++ b/app/protonil/protonil_test.go @@ -20,23 +20,23 @@ import ( func TestCheck(t *testing.T) { tests := []struct { name string - m1 *v1.M1 + msg proto.Message wantErr string }{ { name: "nil", - m1: nil, + msg: nil, wantErr: "nil protobuf message", }, { - name: "zero m1, nil m2", - m1: &v1.M1{}, + name: "zero msg, nil m2", + msg: &v1.M1{}, wantErr: "nil proto field", }, { name: "all populated", - m1: &v1.M1{ - Name: "m1", + msg: &v1.M1{ + Name: "msg", M2: &v1.M2{ Name: "m2", M3: &v1.M3{Name: "m3"}, @@ -52,8 +52,8 @@ func TestCheck(t *testing.T) { }, { name: "optionals nil", - m1: &v1.M1{ - Name: "m1", + msg: &v1.M1{ + Name: "msg", M2: &v1.M2{ Name: "m2", M3: &v1.M3{Name: "m3"}, @@ -65,8 +65,8 @@ func TestCheck(t *testing.T) { }, { name: "nil m3 in optional m2", - m1: &v1.M1{ - Name: "m1", + msg: &v1.M1{ + Name: "msg", M2: &v1.M2{ Name: "m2", M3: &v1.M3{Name: "m3"}, @@ -78,10 +78,49 @@ func TestCheck(t *testing.T) { }, wantErr: "inner message field: nil proto field", }, + { + name: "zero m4", + msg: &v1.M4{}, + wantErr: "", + }, + { + name: "m4 with non-empty containers", + msg: &v1.M4{ + M3Map: map[string]*v1.M3{ + "k0": {Name: "v0"}, + "k1": {Name: "v1"}, + }, + M3List: []*v1.M3{ + {Name: "elem0"}, + {Name: "elem1"}, + }, + }, + wantErr: "", + }, + { + name: "m4 with nil map value", + msg: &v1.M4{ + M3Map: map[string]*v1.M3{ + "k0": nil, + "k1": {Name: "v1"}, + }, + }, + wantErr: "map value: nil protobuf message", + }, + { + name: "m4 with nil list element", + msg: &v1.M4{ + M3List: []*v1.M3{ + nil, + {Name: "elem1"}, + }, + }, + wantErr: "list element: nil protobuf message", + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - err := protonil.Check(test.m1) + err := protonil.Check(test.msg) if test.wantErr != "" { require.ErrorContains(t, err, test.wantErr) } else { @@ -96,6 +135,7 @@ func TestFuzz(t *testing.T) { new(v1.M1), new(v1.M2), new(v1.M3), + new(v1.M4), new(manifestpb.Cluster), new(manifestpb.SignedMutation), new(manifestpb.SignedMutationList), diff --git a/app/protonil/testdata/v1/test.pb.go b/app/protonil/testdata/v1/test.pb.go index 4e9e3911d..e96a1f948 100644 --- a/app/protonil/testdata/v1/test.pb.go +++ b/app/protonil/testdata/v1/test.pb.go @@ -193,6 +193,69 @@ func (x *M3) GetName() string { return "" } +type M4 struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + M3Map map[string]*M3 `protobuf:"bytes,2,rep,name=m3_map,json=m3Map,proto3" json:"m3_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + M3List []*M3 `protobuf:"bytes,3,rep,name=m3_list,json=m3List,proto3" json:"m3_list,omitempty"` +} + +func (x *M4) Reset() { + *x = M4{} + if protoimpl.UnsafeEnabled { + mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *M4) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*M4) ProtoMessage() {} + +func (x *M4) ProtoReflect() protoreflect.Message { + mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use M4.ProtoReflect.Descriptor instead. +func (*M4) Descriptor() ([]byte, []int) { + return file_app_protonil_testdata_v1_test_proto_rawDescGZIP(), []int{3} +} + +func (x *M4) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *M4) GetM3Map() map[string]*M3 { + if x != nil { + return x.M3Map + } + return nil +} + +func (x *M4) GetM3List() []*M3 { + if x != nil { + return x.M3List + } + return nil +} + // MaxIndex is used to test the max index type MaxIndex struct { state protoimpl.MessageState @@ -205,7 +268,7 @@ type MaxIndex struct { func (x *MaxIndex) Reset() { *x = MaxIndex{} if protoimpl.UnsafeEnabled { - mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[3] + mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -218,7 +281,7 @@ func (x *MaxIndex) String() string { func (*MaxIndex) ProtoMessage() {} func (x *MaxIndex) ProtoReflect() protoreflect.Message { - mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[3] + mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -231,7 +294,7 @@ func (x *MaxIndex) ProtoReflect() protoreflect.Message { // Deprecated: Use MaxIndex.ProtoReflect.Descriptor instead. func (*MaxIndex) Descriptor() ([]byte, []int) { - return file_app_protonil_testdata_v1_test_proto_rawDescGZIP(), []int{3} + return file_app_protonil_testdata_v1_test_proto_rawDescGZIP(), []int{4} } func (x *MaxIndex) GetName() string { @@ -259,7 +322,7 @@ type Attack struct { func (x *Attack) Reset() { *x = Attack{} if protoimpl.UnsafeEnabled { - mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[4] + mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -272,7 +335,7 @@ func (x *Attack) String() string { func (*Attack) ProtoMessage() {} func (x *Attack) ProtoReflect() protoreflect.Message { - mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[4] + mi := &file_app_protonil_testdata_v1_test_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -285,7 +348,7 @@ func (x *Attack) ProtoReflect() protoreflect.Message { // Deprecated: Use Attack.ProtoReflect.Descriptor instead. func (*Attack) Descriptor() ([]byte, []int) { - return file_app_protonil_testdata_v1_test_proto_rawDescGZIP(), []int{4} + return file_app_protonil_testdata_v1_test_proto_rawDescGZIP(), []int{5} } func (x *Attack) GetName() string { @@ -351,7 +414,22 @@ var file_app_protonil_testdata_v1_test_proto_rawDesc = []byte{ 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x88, 0x01, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x6d, 0x33, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x22, 0x18, 0x0a, 0x02, 0x4d, 0x33, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x22, 0x1e, 0x0a, 0x08, 0x4d, 0x61, 0x78, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, + 0x61, 0x6d, 0x65, 0x22, 0xed, 0x01, 0x0a, 0x02, 0x4d, 0x34, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3e, + 0x0a, 0x06, 0x6d, 0x33, 0x5f, 0x6d, 0x61, 0x70, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6e, 0x69, 0x6c, 0x2e, 0x74, 0x65, + 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x34, 0x2e, 0x4d, 0x33, 0x4d, + 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x6d, 0x33, 0x4d, 0x61, 0x70, 0x12, 0x35, + 0x0a, 0x07, 0x6d, 0x33, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x6e, 0x69, 0x6c, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x33, 0x52, 0x06, 0x6d, + 0x33, 0x4c, 0x69, 0x73, 0x74, 0x1a, 0x56, 0x0a, 0x0a, 0x4d, 0x33, 0x4d, 0x61, 0x70, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x32, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x6e, 0x69, 0x6c, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, + 0x4d, 0x33, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, 0x04, 0x08, + 0x04, 0x10, 0x05, 0x22, 0x1e, 0x0a, 0x08, 0x4d, 0x61, 0x78, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x41, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x99, 0x02, 0x0a, 0x06, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, @@ -390,28 +468,33 @@ func file_app_protonil_testdata_v1_test_proto_rawDescGZIP() []byte { return file_app_protonil_testdata_v1_test_proto_rawDescData } -var file_app_protonil_testdata_v1_test_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_app_protonil_testdata_v1_test_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_app_protonil_testdata_v1_test_proto_goTypes = []interface{}{ (*M1)(nil), // 0: app.protonil.testdata.v1.M1 (*M2)(nil), // 1: app.protonil.testdata.v1.M2 (*M3)(nil), // 2: app.protonil.testdata.v1.M3 - (*MaxIndex)(nil), // 3: app.protonil.testdata.v1.MaxIndex - (*Attack)(nil), // 4: app.protonil.testdata.v1.Attack + (*M4)(nil), // 3: app.protonil.testdata.v1.M4 + (*MaxIndex)(nil), // 4: app.protonil.testdata.v1.MaxIndex + (*Attack)(nil), // 5: app.protonil.testdata.v1.Attack + nil, // 6: app.protonil.testdata.v1.M4.M3MapEntry } var file_app_protonil_testdata_v1_test_proto_depIdxs = []int32{ - 1, // 0: app.protonil.testdata.v1.M1.m2:type_name -> app.protonil.testdata.v1.M2 - 1, // 1: app.protonil.testdata.v1.M1.m2_optional:type_name -> app.protonil.testdata.v1.M2 - 2, // 2: app.protonil.testdata.v1.M2.m3:type_name -> app.protonil.testdata.v1.M3 - 2, // 3: app.protonil.testdata.v1.M2.m3_optional:type_name -> app.protonil.testdata.v1.M3 - 1, // 4: app.protonil.testdata.v1.Attack.m2:type_name -> app.protonil.testdata.v1.M2 - 1, // 5: app.protonil.testdata.v1.Attack.m2_optional:type_name -> app.protonil.testdata.v1.M2 - 2, // 6: app.protonil.testdata.v1.Attack.m3_unknown:type_name -> app.protonil.testdata.v1.M3 - 2, // 7: app.protonil.testdata.v1.Attack.m3_attack:type_name -> app.protonil.testdata.v1.M3 - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 1, // 0: app.protonil.testdata.v1.M1.m2:type_name -> app.protonil.testdata.v1.M2 + 1, // 1: app.protonil.testdata.v1.M1.m2_optional:type_name -> app.protonil.testdata.v1.M2 + 2, // 2: app.protonil.testdata.v1.M2.m3:type_name -> app.protonil.testdata.v1.M3 + 2, // 3: app.protonil.testdata.v1.M2.m3_optional:type_name -> app.protonil.testdata.v1.M3 + 6, // 4: app.protonil.testdata.v1.M4.m3_map:type_name -> app.protonil.testdata.v1.M4.M3MapEntry + 2, // 5: app.protonil.testdata.v1.M4.m3_list:type_name -> app.protonil.testdata.v1.M3 + 1, // 6: app.protonil.testdata.v1.Attack.m2:type_name -> app.protonil.testdata.v1.M2 + 1, // 7: app.protonil.testdata.v1.Attack.m2_optional:type_name -> app.protonil.testdata.v1.M2 + 2, // 8: app.protonil.testdata.v1.Attack.m3_unknown:type_name -> app.protonil.testdata.v1.M3 + 2, // 9: app.protonil.testdata.v1.Attack.m3_attack:type_name -> app.protonil.testdata.v1.M3 + 2, // 10: app.protonil.testdata.v1.M4.M3MapEntry.value:type_name -> app.protonil.testdata.v1.M3 + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_app_protonil_testdata_v1_test_proto_init() } @@ -457,7 +540,7 @@ func file_app_protonil_testdata_v1_test_proto_init() { } } file_app_protonil_testdata_v1_test_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MaxIndex); i { + switch v := v.(*M4); i { case 0: return &v.state case 1: @@ -469,6 +552,18 @@ func file_app_protonil_testdata_v1_test_proto_init() { } } file_app_protonil_testdata_v1_test_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MaxIndex); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_protonil_testdata_v1_test_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Attack); i { case 0: return &v.state @@ -483,14 +578,14 @@ func file_app_protonil_testdata_v1_test_proto_init() { } file_app_protonil_testdata_v1_test_proto_msgTypes[0].OneofWrappers = []interface{}{} file_app_protonil_testdata_v1_test_proto_msgTypes[1].OneofWrappers = []interface{}{} - file_app_protonil_testdata_v1_test_proto_msgTypes[4].OneofWrappers = []interface{}{} + file_app_protonil_testdata_v1_test_proto_msgTypes[5].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_protonil_testdata_v1_test_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/app/protonil/testdata/v1/test.proto b/app/protonil/testdata/v1/test.proto index c2d7ed312..bb69f95e2 100644 --- a/app/protonil/testdata/v1/test.proto +++ b/app/protonil/testdata/v1/test.proto @@ -20,6 +20,13 @@ message M3 { string name = 2; // Note it doesn't start at 1 } +message M4 { + string name = 1; + map m3_map = 2; + repeated M3 m3_list = 3; + reserved 4; +} + // MaxIndex is used to test the max index message MaxIndex { string name = 65; diff --git a/core/corepb/v1/consensus.pb.go b/core/corepb/v1/consensus.pb.go index a3a9df501..64e45244f 100644 --- a/core/corepb/v1/consensus.pb.go +++ b/core/corepb/v1/consensus.pb.go @@ -27,18 +27,14 @@ type QBFTMsg struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Type int64 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` - Duty *Duty `protobuf:"bytes,2,opt,name=duty,proto3" json:"duty,omitempty"` - PeerIdx int64 `protobuf:"varint,3,opt,name=peer_idx,json=peerIdx,proto3" json:"peer_idx,omitempty"` - Round int64 `protobuf:"varint,4,opt,name=round,proto3" json:"round,omitempty"` - PreparedRound int64 `protobuf:"varint,6,opt,name=prepared_round,json=preparedRound,proto3" json:"prepared_round,omitempty"` - Signature []byte `protobuf:"bytes,8,opt,name=signature,proto3" json:"signature,omitempty"` - // Deprecated: Marked as deprecated in core/corepb/v1/consensus.proto. - Value *anypb.Any `protobuf:"bytes,9,opt,name=value,proto3" json:"value,omitempty"` // Prefer value_hash and ConsensusMsg.values. Remove in v0.15. - // Deprecated: Marked as deprecated in core/corepb/v1/consensus.proto. - PreparedValue *anypb.Any `protobuf:"bytes,10,opt,name=prepared_value,json=preparedValue,proto3" json:"prepared_value,omitempty"` // Prefer prepared_value_hash and ConsensusMsg.values. Remove in v0.15. - ValueHash []byte `protobuf:"bytes,11,opt,name=value_hash,json=valueHash,proto3" json:"value_hash,omitempty"` - PreparedValueHash []byte `protobuf:"bytes,12,opt,name=prepared_value_hash,json=preparedValueHash,proto3" json:"prepared_value_hash,omitempty"` + Type int64 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` + Duty *Duty `protobuf:"bytes,2,opt,name=duty,proto3" json:"duty,omitempty"` + PeerIdx int64 `protobuf:"varint,3,opt,name=peer_idx,json=peerIdx,proto3" json:"peer_idx,omitempty"` + Round int64 `protobuf:"varint,4,opt,name=round,proto3" json:"round,omitempty"` + PreparedRound int64 `protobuf:"varint,6,opt,name=prepared_round,json=preparedRound,proto3" json:"prepared_round,omitempty"` + Signature []byte `protobuf:"bytes,8,opt,name=signature,proto3" json:"signature,omitempty"` + ValueHash []byte `protobuf:"bytes,11,opt,name=value_hash,json=valueHash,proto3" json:"value_hash,omitempty"` + PreparedValueHash []byte `protobuf:"bytes,12,opt,name=prepared_value_hash,json=preparedValueHash,proto3" json:"prepared_value_hash,omitempty"` } func (x *QBFTMsg) Reset() { @@ -115,22 +111,6 @@ func (x *QBFTMsg) GetSignature() []byte { return nil } -// Deprecated: Marked as deprecated in core/corepb/v1/consensus.proto. -func (x *QBFTMsg) GetValue() *anypb.Any { - if x != nil { - return x.Value - } - return nil -} - -// Deprecated: Marked as deprecated in core/corepb/v1/consensus.proto. -func (x *QBFTMsg) GetPreparedValue() *anypb.Any { - if x != nil { - return x.PreparedValue - } - return nil -} - func (x *QBFTMsg) GetValueHash() []byte { if x != nil { return x.ValueHash @@ -400,7 +380,7 @@ var file_core_corepb_v1_consensus_proto_rawDesc = []byte{ 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x89, 0x03, 0x0a, 0x07, 0x51, 0x42, 0x46, 0x54, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa4, 0x02, 0x0a, 0x07, 0x51, 0x42, 0x46, 0x54, 0x4d, 0x73, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x75, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x72, @@ -412,62 +392,56 @@ var file_core_corepb_v1_consensus_proto_rawDesc = []byte{ 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, - 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x2e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x02, 0x18, 0x01, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x0e, 0x70, 0x72, 0x65, 0x70, 0x61, - 0x72, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0d, 0x70, 0x72, 0x65, 0x70, 0x61, - 0x72, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x72, 0x65, 0x70, 0x61, - 0x72, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0c, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x11, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x48, 0x61, 0x73, 0x68, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, - 0x07, 0x10, 0x08, 0x22, 0xa6, 0x01, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, - 0x73, 0x4d, 0x73, 0x67, 0x12, 0x29, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, + 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x11, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x48, 0x61, 0x73, 0x68, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x07, + 0x10, 0x08, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0a, 0x10, 0x0b, 0x22, 0xa6, + 0x01, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, + 0x29, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x42, + 0x46, 0x54, 0x4d, 0x73, 0x67, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x3d, 0x0a, 0x0d, 0x6a, 0x75, + 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x70, 0x62, 0x2e, - 0x76, 0x31, 0x2e, 0x51, 0x42, 0x46, 0x54, 0x4d, 0x73, 0x67, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, - 0x3d, 0x0a, 0x0d, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, - 0x72, 0x65, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x42, 0x46, 0x54, 0x4d, 0x73, 0x67, 0x52, - 0x0d, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, - 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x7f, 0x0a, 0x13, - 0x53, 0x6e, 0x69, 0x66, 0x66, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, - 0x4d, 0x73, 0x67, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x18, 0x01, 0x20, 0x01, 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, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2e, 0x0a, - 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x72, - 0x65, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x73, - 0x65, 0x6e, 0x73, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0xbf, 0x01, - 0x0a, 0x18, 0x53, 0x6e, 0x69, 0x66, 0x66, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, - 0x75, 0x73, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 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, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, - 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x70, - 0x65, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x70, - 0x65, 0x65, 0x72, 0x49, 0x64, 0x78, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x73, 0x67, 0x73, 0x18, 0x04, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x72, 0x65, - 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6e, 0x69, 0x66, 0x66, 0x65, 0x64, 0x43, 0x6f, 0x6e, - 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x52, 0x04, 0x6d, 0x73, 0x67, 0x73, 0x22, - 0x7e, 0x0a, 0x19, 0x53, 0x6e, 0x69, 0x66, 0x66, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, - 0x73, 0x75, 0x73, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x46, 0x0a, 0x09, - 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x28, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x70, 0x62, 0x2e, 0x76, 0x31, + 0x76, 0x31, 0x2e, 0x51, 0x42, 0x46, 0x54, 0x4d, 0x73, 0x67, 0x52, 0x0d, 0x6a, 0x75, 0x73, 0x74, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x06, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, + 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x7f, 0x0a, 0x13, 0x53, 0x6e, 0x69, 0x66, 0x66, + 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x38, + 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 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, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2e, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x72, + 0x65, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, + 0x4d, 0x73, 0x67, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0xbf, 0x01, 0x0a, 0x18, 0x53, 0x6e, 0x69, + 0x66, 0x66, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x49, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, + 0x5f, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 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, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x41, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x69, + 0x64, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x70, 0x65, 0x65, 0x72, 0x49, 0x64, + 0x78, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x73, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x23, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6e, 0x69, 0x66, 0x66, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, - 0x73, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x69, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x69, 0x74, 0x48, 0x61, 0x73, 0x68, 0x42, - 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x62, - 0x6f, 0x6c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x63, 0x68, 0x61, 0x72, 0x6f, 0x6e, - 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x70, 0x62, 0x2f, 0x76, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x4d, 0x73, 0x67, 0x52, 0x04, 0x6d, 0x73, 0x67, 0x73, 0x22, 0x7e, 0x0a, 0x19, 0x53, 0x6e, + 0x69, 0x66, 0x66, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x46, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6e, 0x69, 0x66, + 0x66, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, + 0x19, 0x0a, 0x08, 0x67, 0x69, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x67, 0x69, 0x74, 0x48, 0x61, 0x73, 0x68, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x62, 0x6f, 0x6c, 0x6e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x63, 0x68, 0x61, 0x72, 0x6f, 0x6e, 0x2f, 0x63, 0x6f, 0x72, 0x65, + 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x70, 0x62, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -494,22 +468,20 @@ var file_core_corepb_v1_consensus_proto_goTypes = []interface{}{ (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp } var file_core_corepb_v1_consensus_proto_depIdxs = []int32{ - 5, // 0: core.corepb.v1.QBFTMsg.duty:type_name -> core.corepb.v1.Duty - 6, // 1: core.corepb.v1.QBFTMsg.value:type_name -> google.protobuf.Any - 6, // 2: core.corepb.v1.QBFTMsg.prepared_value:type_name -> google.protobuf.Any - 0, // 3: core.corepb.v1.ConsensusMsg.msg:type_name -> core.corepb.v1.QBFTMsg - 0, // 4: core.corepb.v1.ConsensusMsg.justification:type_name -> core.corepb.v1.QBFTMsg - 6, // 5: core.corepb.v1.ConsensusMsg.values:type_name -> google.protobuf.Any - 7, // 6: core.corepb.v1.SniffedConsensusMsg.timestamp:type_name -> google.protobuf.Timestamp - 1, // 7: core.corepb.v1.SniffedConsensusMsg.msg:type_name -> core.corepb.v1.ConsensusMsg - 7, // 8: core.corepb.v1.SniffedConsensusInstance.started_at:type_name -> google.protobuf.Timestamp - 2, // 9: core.corepb.v1.SniffedConsensusInstance.msgs:type_name -> core.corepb.v1.SniffedConsensusMsg - 3, // 10: core.corepb.v1.SniffedConsensusInstances.instances:type_name -> core.corepb.v1.SniffedConsensusInstance - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 5, // 0: core.corepb.v1.QBFTMsg.duty:type_name -> core.corepb.v1.Duty + 0, // 1: core.corepb.v1.ConsensusMsg.msg:type_name -> core.corepb.v1.QBFTMsg + 0, // 2: core.corepb.v1.ConsensusMsg.justification:type_name -> core.corepb.v1.QBFTMsg + 6, // 3: core.corepb.v1.ConsensusMsg.values:type_name -> google.protobuf.Any + 7, // 4: core.corepb.v1.SniffedConsensusMsg.timestamp:type_name -> google.protobuf.Timestamp + 1, // 5: core.corepb.v1.SniffedConsensusMsg.msg:type_name -> core.corepb.v1.ConsensusMsg + 7, // 6: core.corepb.v1.SniffedConsensusInstance.started_at:type_name -> google.protobuf.Timestamp + 2, // 7: core.corepb.v1.SniffedConsensusInstance.msgs:type_name -> core.corepb.v1.SniffedConsensusMsg + 3, // 8: core.corepb.v1.SniffedConsensusInstances.instances:type_name -> core.corepb.v1.SniffedConsensusInstance + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_core_corepb_v1_consensus_proto_init() } diff --git a/core/corepb/v1/consensus.proto b/core/corepb/v1/consensus.proto index 9fb18b68f..289c5d98c 100644 --- a/core/corepb/v1/consensus.proto +++ b/core/corepb/v1/consensus.proto @@ -17,8 +17,8 @@ message QBFTMsg { int64 prepared_round = 6; reserved 7 ; bytes signature = 8; - google.protobuf.Any value = 9 [deprecated = true]; // Prefer value_hash and ConsensusMsg.values. Remove in v0.15. - google.protobuf.Any prepared_value = 10 [deprecated = true]; // Prefer prepared_value_hash and ConsensusMsg.values. Remove in v0.15. + reserved 9; + reserved 10; bytes value_hash = 11; bytes prepared_value_hash = 12; } diff --git a/core/proto.go b/core/proto.go index 15af679f5..33b0291cd 100644 --- a/core/proto.go +++ b/core/proto.go @@ -9,6 +9,7 @@ import ( ssz "github.com/ferranbt/fastssz" "github.com/obolnetwork/charon/app/errors" + "github.com/obolnetwork/charon/app/protonil" "github.com/obolnetwork/charon/app/z" pbv1 "github.com/obolnetwork/charon/core/corepb/v1" ) @@ -47,8 +48,8 @@ func ParSignedDataFromProto(typ DutyType, data *pbv1.ParSignedData) (ParSignedDa // For now, it is a good way to catch compatibility issues. But we should // recover panics and return an error before launching mainnet. - if data == nil { - return ParSignedData{}, errors.New("partial signed data proto cannot be nil") + if err := protonil.Check(data); err != nil { + return ParSignedData{}, errors.Wrap(err, "invalid partial signed proto") } var signedData SignedData diff --git a/core/proto_test.go b/core/proto_test.go index a0912ebf7..e797828dd 100644 --- a/core/proto_test.go +++ b/core/proto_test.go @@ -23,7 +23,7 @@ func TestDutyProto(t *testing.T) { duty2 := core.DutyFromProto(pb1) pb2 := core.DutyToProto(duty2) require.Equal(t, duty1, duty2) - require.Equal(t, pb1, pb2) + testutil.RequireProtoEqual(t, pb1, pb2) } func TestParSignedDataSetProto(t *testing.T) { @@ -98,7 +98,7 @@ func TestParSignedDataSetProto(t *testing.T) { pb2, err := core.ParSignedDataSetToProto(set2) require.NoError(t, err) require.Equal(t, set1, set2) - require.Equal(t, pb1, pb2) + testutil.RequireProtoEqual(t, pb1, pb2) b, err := proto.Marshal(pb1) require.NoError(t, err) @@ -106,8 +106,7 @@ func TestParSignedDataSetProto(t *testing.T) { pb3 := new(pbv1.ParSignedDataSet) err = proto.Unmarshal(b, pb3) require.NoError(t, err) - - require.True(t, proto.Equal(pb1, pb3)) + testutil.RequireProtoEqual(t, pb1, pb3) }) } } @@ -152,7 +151,7 @@ func TestUnsignedDataToProto(t *testing.T) { pb2, err := core.UnsignedDataSetToProto(set2) require.NoError(t, err) require.Equal(t, set1, set2) - require.Equal(t, pb1, pb2) + testutil.RequireProtoEqual(t, pb1, pb2) b, err := proto.Marshal(pb1) require.NoError(t, err) @@ -160,8 +159,7 @@ func TestUnsignedDataToProto(t *testing.T) { pb3 := new(pbv1.UnsignedDataSet) err = proto.Unmarshal(b, pb3) require.NoError(t, err) - - require.True(t, proto.Equal(pb1, pb3)) + testutil.RequireProtoEqual(t, pb1, pb3) }) } } @@ -181,7 +179,7 @@ func TestParSignedData(t *testing.T) { pb2, err := core.ParSignedDataToProto(parSig2) require.NoError(t, err) require.Equal(t, parSig1, parSig2) - require.Equal(t, pb1, pb2) + testutil.RequireProtoEqual(t, pb1, pb2) b, err := proto.Marshal(pb1) require.NoError(t, err) @@ -189,8 +187,7 @@ func TestParSignedData(t *testing.T) { pb3 := new(pbv1.ParSignedData) err = proto.Unmarshal(b, pb3) require.NoError(t, err) - - require.True(t, proto.Equal(pb1, pb3)) + testutil.RequireProtoEqual(t, pb1, pb3) }) } } @@ -239,7 +236,7 @@ func randomSignedData(t *testing.T) map[core.DutyType]core.SignedData { func TestNilPointerChecks(t *testing.T) { _, err := core.ParSignedDataFromProto(core.DutyAttester, nil) - require.ErrorContains(t, err, "partial signed data proto cannot be nil") + require.ErrorContains(t, err, "invalid partial signed proto: nil protobuf message") _, err = core.ParSignedDataSetFromProto(core.DutyAttester, nil) require.ErrorContains(t, err, "invalid partial signed data set proto fields") diff --git a/p2p/receive.go b/p2p/receive.go index 99709e9ba..0966658cf 100644 --- a/p2p/receive.go +++ b/p2p/receive.go @@ -15,6 +15,7 @@ import ( "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/log" + "github.com/obolnetwork/charon/app/protonil" "github.com/obolnetwork/charon/app/z" ) @@ -84,6 +85,9 @@ func RegisterHandler(logTopic string, tcpNode host.Host, pID protocol.ID, } else if err != nil { log.Error(ctx, "LibP2P read request", err, z.Any("duration", time.Since(t0))) return + } else if err := protonil.Check(req); err != nil { + log.Warn(ctx, "LibP2P received invalid proto", err) + return } resp, ok, err := handlerFunc(ctx, s.Conn().RemotePeer(), req)