From 6e4b4562d69eaa65d76e201a7754e26b7bc953d4 Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:02:07 -0700 Subject: [PATCH] Adds VersionInfo endpoint to retriever and dispersal services for observability into node versions ``` grpcurl --plaintext localhost:32005 node.Dispersal.VersionInfo { "semver": "0.7.5" } ``` ``` grpcurl --plaintext localhost:32005 node.Dispersal.VersionInfo { "semver": "0.8.0-rc.1" } ``` --- api/grpc/node/node.pb.go | 194 ++++++++++++++++++++++++++++------ api/grpc/node/node_grpc.pb.go | 105 ++++++++++++++---- api/proto/node/node.proto | 13 +++ node/Makefile | 11 +- node/config.go | 2 +- node/grpc/server.go | 4 + node/grpc/server_test.go | 7 ++ 7 files changed, 281 insertions(+), 55 deletions(-) diff --git a/api/grpc/node/node.pb.go b/api/grpc/node/node.pb.go index ebfd8c58eb..ea7be1ab02 100644 --- a/api/grpc/node/node.pb.go +++ b/api/grpc/node/node.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v4.23.4 +// protoc-gen-go v1.26.0 +// protoc v5.26.1 // source: node/node.proto package node @@ -853,6 +853,93 @@ func (x *BatchHeader) GetReferenceBlockNumber() uint32 { return 0 } +// Version info request +type VersionInfoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *VersionInfoRequest) Reset() { + *x = VersionInfoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_node_node_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VersionInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VersionInfoRequest) ProtoMessage() {} + +func (x *VersionInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_node_node_proto_msgTypes[13] + 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 VersionInfoRequest.ProtoReflect.Descriptor instead. +func (*VersionInfoRequest) Descriptor() ([]byte, []int) { + return file_node_node_proto_rawDescGZIP(), []int{13} +} + +// Version info reply +type VersionInfoReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Semver string `protobuf:"bytes,1,opt,name=semver,proto3" json:"semver,omitempty"` +} + +func (x *VersionInfoReply) Reset() { + *x = VersionInfoReply{} + if protoimpl.UnsafeEnabled { + mi := &file_node_node_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VersionInfoReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VersionInfoReply) ProtoMessage() {} + +func (x *VersionInfoReply) ProtoReflect() protoreflect.Message { + mi := &file_node_node_proto_msgTypes[14] + 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 VersionInfoReply.ProtoReflect.Descriptor instead. +func (*VersionInfoReply) Descriptor() ([]byte, []int) { + return file_node_node_proto_rawDescGZIP(), []int{14} +} + +func (x *VersionInfoReply) GetSemver() string { + if x != nil { + return x.Semver + } + return "" +} + var File_node_node_proto protoreflect.FileDescriptor var file_node_node_proto_rawDesc = []byte{ @@ -951,25 +1038,38 @@ var file_node_node_proto_rawDesc = []byte{ 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x14, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x32, 0x4e, 0x0a, 0x09, 0x44, 0x69, 0x73, 0x70, 0x65, 0x72, 0x73, 0x61, 0x6c, 0x12, 0x41, - 0x0a, 0x0b, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x73, 0x12, 0x18, 0x2e, - 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x53, - 0x74, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, - 0x00, 0x32, 0xa0, 0x01, 0x0a, 0x09, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x61, 0x6c, 0x12, - 0x4a, 0x0a, 0x0e, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, - 0x73, 0x12, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, - 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, - 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x43, 0x68, - 0x75, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0d, 0x47, - 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x6e, - 0x6f, 0x64, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x48, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, - 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x70, - 0x6c, 0x79, 0x22, 0x00, 0x42, 0x2c, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x4c, 0x61, 0x79, 0x72, 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x65, 0x69, 0x67, - 0x65, 0x6e, 0x64, 0x61, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x6e, 0x6f, - 0x64, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x22, 0x14, 0x0a, 0x12, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2a, 0x0a, 0x10, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x65, 0x6d, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x6d, + 0x76, 0x65, 0x72, 0x32, 0x91, 0x01, 0x0a, 0x09, 0x44, 0x69, 0x73, 0x70, 0x65, 0x72, 0x73, 0x61, + 0x6c, 0x12, 0x41, 0x0a, 0x0b, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x73, + 0x12, 0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x75, + 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x6e, 0x6f, 0x64, + 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x70, + 0x6c, 0x79, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x0b, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, + 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x32, 0xe3, 0x01, 0x0a, 0x09, 0x52, 0x65, 0x74, 0x72, + 0x69, 0x65, 0x76, 0x61, 0x6c, 0x12, 0x4a, 0x0a, 0x0e, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, + 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x73, 0x12, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x52, + 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x52, 0x65, 0x74, 0x72, + 0x69, 0x65, 0x76, 0x65, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, + 0x00, 0x12, 0x47, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x12, 0x1a, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, + 0x62, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, + 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x0b, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, + 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x2c, 0x5a, + 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x4c, 0x61, 0x79, 0x72, + 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x65, 0x69, 0x67, 0x65, 0x6e, 0x64, 0x61, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -984,7 +1084,7 @@ func file_node_node_proto_rawDescGZIP() []byte { return file_node_node_proto_rawDescData } -var file_node_node_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_node_node_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_node_node_proto_goTypes = []interface{}{ (*StoreChunksRequest)(nil), // 0: node.StoreChunksRequest (*StoreChunksReply)(nil), // 1: node.StoreChunksReply @@ -999,7 +1099,9 @@ var file_node_node_proto_goTypes = []interface{}{ (*BlobHeader)(nil), // 10: node.BlobHeader (*BlobQuorumInfo)(nil), // 11: node.BlobQuorumInfo (*BatchHeader)(nil), // 12: node.BatchHeader - (*common.G1Commitment)(nil), // 13: common.G1Commitment + (*VersionInfoRequest)(nil), // 13: node.VersionInfoRequest + (*VersionInfoReply)(nil), // 14: node.VersionInfoReply + (*common.G1Commitment)(nil), // 15: common.G1Commitment } var file_node_node_proto_depIdxs = []int32{ 12, // 0: node.StoreChunksRequest.batch_header:type_name -> node.BatchHeader @@ -1008,18 +1110,22 @@ var file_node_node_proto_depIdxs = []int32{ 6, // 3: node.GetBlobHeaderReply.proof:type_name -> node.MerkleProof 10, // 4: node.Blob.header:type_name -> node.BlobHeader 8, // 5: node.Blob.bundles:type_name -> node.Bundle - 13, // 6: node.BlobHeader.commitment:type_name -> common.G1Commitment + 15, // 6: node.BlobHeader.commitment:type_name -> common.G1Commitment 9, // 7: node.BlobHeader.length_commitment:type_name -> node.G2Commitment 9, // 8: node.BlobHeader.length_proof:type_name -> node.G2Commitment 11, // 9: node.BlobHeader.quorum_headers:type_name -> node.BlobQuorumInfo 0, // 10: node.Dispersal.StoreChunks:input_type -> node.StoreChunksRequest - 2, // 11: node.Retrieval.RetrieveChunks:input_type -> node.RetrieveChunksRequest - 4, // 12: node.Retrieval.GetBlobHeader:input_type -> node.GetBlobHeaderRequest - 1, // 13: node.Dispersal.StoreChunks:output_type -> node.StoreChunksReply - 3, // 14: node.Retrieval.RetrieveChunks:output_type -> node.RetrieveChunksReply - 5, // 15: node.Retrieval.GetBlobHeader:output_type -> node.GetBlobHeaderReply - 13, // [13:16] is the sub-list for method output_type - 10, // [10:13] is the sub-list for method input_type + 13, // 11: node.Dispersal.VersionInfo:input_type -> node.VersionInfoRequest + 2, // 12: node.Retrieval.RetrieveChunks:input_type -> node.RetrieveChunksRequest + 4, // 13: node.Retrieval.GetBlobHeader:input_type -> node.GetBlobHeaderRequest + 13, // 14: node.Retrieval.VersionInfo:input_type -> node.VersionInfoRequest + 1, // 15: node.Dispersal.StoreChunks:output_type -> node.StoreChunksReply + 14, // 16: node.Dispersal.VersionInfo:output_type -> node.VersionInfoReply + 3, // 17: node.Retrieval.RetrieveChunks:output_type -> node.RetrieveChunksReply + 5, // 18: node.Retrieval.GetBlobHeader:output_type -> node.GetBlobHeaderReply + 14, // 19: node.Retrieval.VersionInfo:output_type -> node.VersionInfoReply + 15, // [15:20] is the sub-list for method output_type + 10, // [10:15] is the sub-list for method input_type 10, // [10:10] is the sub-list for extension type_name 10, // [10:10] is the sub-list for extension extendee 0, // [0:10] is the sub-list for field type_name @@ -1187,6 +1293,30 @@ func file_node_node_proto_init() { return nil } } + file_node_node_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VersionInfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_node_node_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VersionInfoReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1194,7 +1324,7 @@ func file_node_node_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_node_node_proto_rawDesc, NumEnums: 0, - NumMessages: 13, + NumMessages: 15, NumExtensions: 0, NumServices: 2, }, diff --git a/api/grpc/node/node_grpc.pb.go b/api/grpc/node/node_grpc.pb.go index 0dcf6f0eb4..ee0bd31474 100644 --- a/api/grpc/node/node_grpc.pb.go +++ b/api/grpc/node/node_grpc.pb.go @@ -1,8 +1,4 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.4 -// source: node/node.proto package node @@ -18,10 +14,6 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -const ( - Dispersal_StoreChunks_FullMethodName = "/node.Dispersal/StoreChunks" -) - // DispersalClient is the client API for Dispersal service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -33,6 +25,8 @@ type DispersalClient interface { // for the protocol-defined length of custody. It will return a signature at the // end to attest to the data in this request it has processed. StoreChunks(ctx context.Context, in *StoreChunksRequest, opts ...grpc.CallOption) (*StoreChunksReply, error) + // Retrieve version into metadata + VersionInfo(ctx context.Context, in *VersionInfoRequest, opts ...grpc.CallOption) (*VersionInfoReply, error) } type dispersalClient struct { @@ -45,7 +39,16 @@ func NewDispersalClient(cc grpc.ClientConnInterface) DispersalClient { func (c *dispersalClient) StoreChunks(ctx context.Context, in *StoreChunksRequest, opts ...grpc.CallOption) (*StoreChunksReply, error) { out := new(StoreChunksReply) - err := c.cc.Invoke(ctx, Dispersal_StoreChunks_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/node.Dispersal/StoreChunks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dispersalClient) VersionInfo(ctx context.Context, in *VersionInfoRequest, opts ...grpc.CallOption) (*VersionInfoReply, error) { + out := new(VersionInfoReply) + err := c.cc.Invoke(ctx, "/node.Dispersal/VersionInfo", in, out, opts...) if err != nil { return nil, err } @@ -63,6 +66,8 @@ type DispersalServer interface { // for the protocol-defined length of custody. It will return a signature at the // end to attest to the data in this request it has processed. StoreChunks(context.Context, *StoreChunksRequest) (*StoreChunksReply, error) + // Retrieve version into metadata + VersionInfo(context.Context, *VersionInfoRequest) (*VersionInfoReply, error) mustEmbedUnimplementedDispersalServer() } @@ -73,6 +78,9 @@ type UnimplementedDispersalServer struct { func (UnimplementedDispersalServer) StoreChunks(context.Context, *StoreChunksRequest) (*StoreChunksReply, error) { return nil, status.Errorf(codes.Unimplemented, "method StoreChunks not implemented") } +func (UnimplementedDispersalServer) VersionInfo(context.Context, *VersionInfoRequest) (*VersionInfoReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method VersionInfo not implemented") +} func (UnimplementedDispersalServer) mustEmbedUnimplementedDispersalServer() {} // UnsafeDispersalServer may be embedded to opt out of forward compatibility for this service. @@ -96,7 +104,7 @@ func _Dispersal_StoreChunks_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Dispersal_StoreChunks_FullMethodName, + FullMethod: "/node.Dispersal/StoreChunks", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DispersalServer).StoreChunks(ctx, req.(*StoreChunksRequest)) @@ -104,6 +112,24 @@ func _Dispersal_StoreChunks_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Dispersal_VersionInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VersionInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DispersalServer).VersionInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/node.Dispersal/VersionInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DispersalServer).VersionInfo(ctx, req.(*VersionInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Dispersal_ServiceDesc is the grpc.ServiceDesc for Dispersal service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -115,24 +141,25 @@ var Dispersal_ServiceDesc = grpc.ServiceDesc{ MethodName: "StoreChunks", Handler: _Dispersal_StoreChunks_Handler, }, + { + MethodName: "VersionInfo", + Handler: _Dispersal_VersionInfo_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "node/node.proto", } -const ( - Retrieval_RetrieveChunks_FullMethodName = "/node.Retrieval/RetrieveChunks" - Retrieval_GetBlobHeader_FullMethodName = "/node.Retrieval/GetBlobHeader" -) - // RetrievalClient is the client API for Retrieval service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type RetrievalClient interface { // RetrieveChunks retrieves the chunks for a blob custodied at the Node. RetrieveChunks(ctx context.Context, in *RetrieveChunksRequest, opts ...grpc.CallOption) (*RetrieveChunksReply, error) - // Similar to RetrieveChunks, this just returns the header of the blob. + // GetBlobHeader is similar to RetrieveChunks, this just returns the header of the blob. GetBlobHeader(ctx context.Context, in *GetBlobHeaderRequest, opts ...grpc.CallOption) (*GetBlobHeaderReply, error) + // Retrieve version into metadata + VersionInfo(ctx context.Context, in *VersionInfoRequest, opts ...grpc.CallOption) (*VersionInfoReply, error) } type retrievalClient struct { @@ -145,7 +172,7 @@ func NewRetrievalClient(cc grpc.ClientConnInterface) RetrievalClient { func (c *retrievalClient) RetrieveChunks(ctx context.Context, in *RetrieveChunksRequest, opts ...grpc.CallOption) (*RetrieveChunksReply, error) { out := new(RetrieveChunksReply) - err := c.cc.Invoke(ctx, Retrieval_RetrieveChunks_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/node.Retrieval/RetrieveChunks", in, out, opts...) if err != nil { return nil, err } @@ -154,7 +181,16 @@ func (c *retrievalClient) RetrieveChunks(ctx context.Context, in *RetrieveChunks func (c *retrievalClient) GetBlobHeader(ctx context.Context, in *GetBlobHeaderRequest, opts ...grpc.CallOption) (*GetBlobHeaderReply, error) { out := new(GetBlobHeaderReply) - err := c.cc.Invoke(ctx, Retrieval_GetBlobHeader_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/node.Retrieval/GetBlobHeader", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *retrievalClient) VersionInfo(ctx context.Context, in *VersionInfoRequest, opts ...grpc.CallOption) (*VersionInfoReply, error) { + out := new(VersionInfoReply) + err := c.cc.Invoke(ctx, "/node.Retrieval/VersionInfo", in, out, opts...) if err != nil { return nil, err } @@ -167,8 +203,10 @@ func (c *retrievalClient) GetBlobHeader(ctx context.Context, in *GetBlobHeaderRe type RetrievalServer interface { // RetrieveChunks retrieves the chunks for a blob custodied at the Node. RetrieveChunks(context.Context, *RetrieveChunksRequest) (*RetrieveChunksReply, error) - // Similar to RetrieveChunks, this just returns the header of the blob. + // GetBlobHeader is similar to RetrieveChunks, this just returns the header of the blob. GetBlobHeader(context.Context, *GetBlobHeaderRequest) (*GetBlobHeaderReply, error) + // Retrieve version into metadata + VersionInfo(context.Context, *VersionInfoRequest) (*VersionInfoReply, error) mustEmbedUnimplementedRetrievalServer() } @@ -182,6 +220,9 @@ func (UnimplementedRetrievalServer) RetrieveChunks(context.Context, *RetrieveChu func (UnimplementedRetrievalServer) GetBlobHeader(context.Context, *GetBlobHeaderRequest) (*GetBlobHeaderReply, error) { return nil, status.Errorf(codes.Unimplemented, "method GetBlobHeader not implemented") } +func (UnimplementedRetrievalServer) VersionInfo(context.Context, *VersionInfoRequest) (*VersionInfoReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method VersionInfo not implemented") +} func (UnimplementedRetrievalServer) mustEmbedUnimplementedRetrievalServer() {} // UnsafeRetrievalServer may be embedded to opt out of forward compatibility for this service. @@ -205,7 +246,7 @@ func _Retrieval_RetrieveChunks_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Retrieval_RetrieveChunks_FullMethodName, + FullMethod: "/node.Retrieval/RetrieveChunks", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RetrievalServer).RetrieveChunks(ctx, req.(*RetrieveChunksRequest)) @@ -223,7 +264,7 @@ func _Retrieval_GetBlobHeader_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Retrieval_GetBlobHeader_FullMethodName, + FullMethod: "/node.Retrieval/GetBlobHeader", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RetrievalServer).GetBlobHeader(ctx, req.(*GetBlobHeaderRequest)) @@ -231,6 +272,24 @@ func _Retrieval_GetBlobHeader_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Retrieval_VersionInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VersionInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RetrievalServer).VersionInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/node.Retrieval/VersionInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RetrievalServer).VersionInfo(ctx, req.(*VersionInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Retrieval_ServiceDesc is the grpc.ServiceDesc for Retrieval service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -246,6 +305,10 @@ var Retrieval_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetBlobHeader", Handler: _Retrieval_GetBlobHeader_Handler, }, + { + MethodName: "VersionInfo", + Handler: _Retrieval_VersionInfo_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "node/node.proto", diff --git a/api/proto/node/node.proto b/api/proto/node/node.proto index f31646742b..18d8cc0569 100644 --- a/api/proto/node/node.proto +++ b/api/proto/node/node.proto @@ -14,6 +14,8 @@ service Dispersal { // for the protocol-defined length of custody. It will return a signature at the // end to attest to the data in this request it has processed. rpc StoreChunks(StoreChunksRequest) returns (StoreChunksReply) {} + // Retrieve version into metadata + rpc VersionInfo(VersionInfoRequest) returns (VersionInfoReply) {} } service Retrieval { @@ -21,6 +23,8 @@ service Retrieval { rpc RetrieveChunks(RetrieveChunksRequest) returns (RetrieveChunksReply) {} // GetBlobHeader is similar to RetrieveChunks, this just returns the header of the blob. rpc GetBlobHeader(GetBlobHeaderRequest) returns (GetBlobHeaderReply) {} + // Retrieve version into metadata + rpc VersionInfo(VersionInfoRequest) returns (VersionInfoReply) {} } // Requests and replies @@ -153,3 +157,12 @@ message BatchHeader { // The Ethereum block number at which the batch is dispersed. uint32 reference_block_number = 3; } + +// Version info request +message VersionInfoRequest { +} + +// Version info reply +message VersionInfoReply { + string semver = 1; +} diff --git a/node/Makefile b/node/Makefile index 6b2715211d..662e7d7edd 100644 --- a/node/Makefile +++ b/node/Makefile @@ -17,11 +17,20 @@ RELEASE_TAG := $(or $(RELEASE_TAG),latest) build: clean go mod tidy - go build -o ./bin/node ./cmd + go build -ldflags="-X 'github.com/Layr-Labs/eigenda/node.SemVer=${SEMVER}' -X 'github.com/Layr-Labs/eigenda/node.GitCommit=${GITCOMMIT}' -X 'github.com/Layr-Labs/eigenda/node.GitDate=${GITDATE}'" -o ./bin/node ./cmd + +proto: + cd .. && make protoc clean: rm -rf ./bin +lint: + golangci-lint run + +test: + go test -short ./... + docker: docker-node docker-plugin docker-node: diff --git a/node/config.go b/node/config.go index e1f09ec1a7..60cdc70b23 100644 --- a/node/config.go +++ b/node/config.go @@ -33,7 +33,7 @@ var ( 0: "eth_quorum", 1: "permissioned_quorum", } - SemVer = "v0.0.0" + SemVer = "0.0.0" GitCommit = "" GitDate = "" ) diff --git a/node/grpc/server.go b/node/grpc/server.go index 45f77c1501..362b03387a 100644 --- a/node/grpc/server.go +++ b/node/grpc/server.go @@ -130,6 +130,10 @@ func (s *Server) serveRetrieval() error { } +func (s *Server) VersionInfo(ctx context.Context, in *pb.VersionInfoRequest) (*pb.VersionInfoReply, error) { + return &pb.VersionInfoReply{Semver: node.SemVer}, nil +} + func (s *Server) handleStoreChunksRequest(ctx context.Context, in *pb.StoreChunksRequest) (*pb.StoreChunksReply, error) { start := time.Now() diff --git a/node/grpc/server_test.go b/node/grpc/server_test.go index 5bc8b5e27f..be99835e01 100644 --- a/node/grpc/server_test.go +++ b/node/grpc/server_test.go @@ -278,6 +278,13 @@ func storeChunks(t *testing.T, server *grpc.Server) ([32]byte, [32]byte, []*core return batchHeaderHash, batchRoot, blobHeaders, blobHeadersProto } +func TestVersionInfoRequest(t *testing.T) { + server := newTestServer(t, true) + resp, err := server.VersionInfo(context.Background(), &pb.VersionInfoRequest{}) + assert.True(t, resp.Semver == "0.0.0") + assert.True(t, err == nil) +} + func TestStoreChunksRequestValidation(t *testing.T) { server := newTestServer(t, true)