From ad343e7827f17e2d6cf5d6d85ed8993a851397f4 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 1/8] 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 | 9 ++ node/config.go | 2 +- node/grpc/server.go | 4 + node/grpc/server_test.go | 7 ++ 7 files changed, 280 insertions(+), 54 deletions(-) diff --git a/api/grpc/node/node.pb.go b/api/grpc/node/node.pb.go index ebfd8c58e..ea7be1ab0 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 0dcf6f0eb..ee0bd3147 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 f31646742..18d8cc056 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 6b2715211..7a7455f9a 100644 --- a/node/Makefile +++ b/node/Makefile @@ -19,9 +19,18 @@ build: clean go mod tidy go build -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 e1f09ec1a..60cdc70b2 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 45f77c150..362b03387 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 5bc8b5e27..be99835e0 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) From c08bbf8a387bd54fac0947f0b58653dbbfc21683 Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Tue, 9 Jul 2024 17:23:28 -0700 Subject: [PATCH 2/8] Lint --- api/proto/node/node.proto | 4 ++-- node/config.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/proto/node/node.proto b/api/proto/node/node.proto index 18d8cc056..56f2f20ee 100644 --- a/api/proto/node/node.proto +++ b/api/proto/node/node.proto @@ -14,7 +14,7 @@ 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 + // Retrieve version info metadata rpc VersionInfo(VersionInfoRequest) returns (VersionInfoReply) {} } @@ -23,7 +23,7 @@ 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 + // Retrieve version info metadata rpc VersionInfo(VersionInfoRequest) returns (VersionInfoReply) {} } diff --git a/node/config.go b/node/config.go index 60cdc70b2..1608525a0 100644 --- a/node/config.go +++ b/node/config.go @@ -31,7 +31,7 @@ var ( // this is used for eigen metrics QuorumNames = map[core.QuorumID]string{ 0: "eth_quorum", - 1: "permissioned_quorum", + 1: "eignen_quorum", } SemVer = "0.0.0" GitCommit = "" From fb9314f5936c60702dc9d6aa6fbd808f3a2cb7cb Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:41:46 -0700 Subject: [PATCH 3/8] Add node system info --- api/grpc/node/node.pb.go | 154 +++++++++++++++++++++------------- api/grpc/node/node_grpc.pb.go | 64 +++++++------- api/proto/node/node.proto | 20 +++-- go.mod | 2 +- node/grpc/server.go | 12 ++- node/grpc/server_test.go | 8 +- 6 files changed, 156 insertions(+), 104 deletions(-) diff --git a/api/grpc/node/node.pb.go b/api/grpc/node/node.pb.go index ea7be1ab0..3555da51a 100644 --- a/api/grpc/node/node.pb.go +++ b/api/grpc/node/node.pb.go @@ -853,15 +853,15 @@ func (x *BatchHeader) GetReferenceBlockNumber() uint32 { return 0 } -// Version info request -type VersionInfoRequest struct { +// Node info request +type NodeInfoRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *VersionInfoRequest) Reset() { - *x = VersionInfoRequest{} +func (x *NodeInfoRequest) Reset() { + *x = NodeInfoRequest{} if protoimpl.UnsafeEnabled { mi := &file_node_node_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -869,13 +869,13 @@ func (x *VersionInfoRequest) Reset() { } } -func (x *VersionInfoRequest) String() string { +func (x *NodeInfoRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*VersionInfoRequest) ProtoMessage() {} +func (*NodeInfoRequest) ProtoMessage() {} -func (x *VersionInfoRequest) ProtoReflect() protoreflect.Message { +func (x *NodeInfoRequest) ProtoReflect() protoreflect.Message { mi := &file_node_node_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -887,22 +887,26 @@ func (x *VersionInfoRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use VersionInfoRequest.ProtoReflect.Descriptor instead. -func (*VersionInfoRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use NodeInfoRequest.ProtoReflect.Descriptor instead. +func (*NodeInfoRequest) Descriptor() ([]byte, []int) { return file_node_node_proto_rawDescGZIP(), []int{13} } -// Version info reply -type VersionInfoReply struct { +// Node info reply +type NodeInfoReply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Semver string `protobuf:"bytes,1,opt,name=semver,proto3" json:"semver,omitempty"` + Semver string `protobuf:"bytes,1,opt,name=semver,proto3" json:"semver,omitempty"` + Arch string `protobuf:"bytes,2,opt,name=arch,proto3" json:"arch,omitempty"` + Os string `protobuf:"bytes,3,opt,name=os,proto3" json:"os,omitempty"` + NumCpu uint32 `protobuf:"varint,4,opt,name=num_cpu,json=numCpu,proto3" json:"num_cpu,omitempty"` + MemBytes uint64 `protobuf:"varint,5,opt,name=mem_bytes,json=memBytes,proto3" json:"mem_bytes,omitempty"` } -func (x *VersionInfoReply) Reset() { - *x = VersionInfoReply{} +func (x *NodeInfoReply) Reset() { + *x = NodeInfoReply{} if protoimpl.UnsafeEnabled { mi := &file_node_node_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -910,13 +914,13 @@ func (x *VersionInfoReply) Reset() { } } -func (x *VersionInfoReply) String() string { +func (x *NodeInfoReply) String() string { return protoimpl.X.MessageStringOf(x) } -func (*VersionInfoReply) ProtoMessage() {} +func (*NodeInfoReply) ProtoMessage() {} -func (x *VersionInfoReply) ProtoReflect() protoreflect.Message { +func (x *NodeInfoReply) ProtoReflect() protoreflect.Message { mi := &file_node_node_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -928,18 +932,46 @@ func (x *VersionInfoReply) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use VersionInfoReply.ProtoReflect.Descriptor instead. -func (*VersionInfoReply) Descriptor() ([]byte, []int) { +// Deprecated: Use NodeInfoReply.ProtoReflect.Descriptor instead. +func (*NodeInfoReply) Descriptor() ([]byte, []int) { return file_node_node_proto_rawDescGZIP(), []int{14} } -func (x *VersionInfoReply) GetSemver() string { +func (x *NodeInfoReply) GetSemver() string { if x != nil { return x.Semver } return "" } +func (x *NodeInfoReply) GetArch() string { + if x != nil { + return x.Arch + } + return "" +} + +func (x *NodeInfoReply) GetOs() string { + if x != nil { + return x.Os + } + return "" +} + +func (x *NodeInfoReply) GetNumCpu() uint32 { + if x != nil { + return x.NumCpu + } + return 0 +} + +func (x *NodeInfoReply) GetMemBytes() uint64 { + if x != nil { + return x.MemBytes + } + return 0 +} + var File_node_node_proto protoreflect.FileDescriptor var file_node_node_proto_rawDesc = []byte{ @@ -1038,38 +1070,42 @@ 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, 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, + 0x72, 0x22, 0x11, 0x0a, 0x0f, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x22, 0x81, 0x01, 0x0a, 0x0d, 0x4e, 0x6f, 0x64, 0x65, 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, 0x12, 0x12, + 0x0a, 0x04, 0x61, 0x72, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x72, + 0x63, 0x68, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x6f, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x75, 0x6d, 0x5f, 0x63, 0x70, 0x75, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x43, 0x70, 0x75, 0x12, 0x1b, 0x0a, 0x09, 0x6d, + 0x65, 0x6d, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, + 0x6d, 0x65, 0x6d, 0x42, 0x79, 0x74, 0x65, 0x73, 0x32, 0x88, 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, 0x38, 0x0a, 0x08, 0x4e, 0x6f, 0x64, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, + 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x70, 0x6c, + 0x79, 0x22, 0x00, 0x32, 0xda, 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, 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, + 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, 0x38, 0x0a, 0x08, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x15, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x6f, 0x64, 0x65, + 0x2e, 0x4e, 0x6f, 0x64, 0x65, 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 ( @@ -1099,8 +1135,8 @@ var file_node_node_proto_goTypes = []interface{}{ (*BlobHeader)(nil), // 10: node.BlobHeader (*BlobQuorumInfo)(nil), // 11: node.BlobQuorumInfo (*BatchHeader)(nil), // 12: node.BatchHeader - (*VersionInfoRequest)(nil), // 13: node.VersionInfoRequest - (*VersionInfoReply)(nil), // 14: node.VersionInfoReply + (*NodeInfoRequest)(nil), // 13: node.NodeInfoRequest + (*NodeInfoReply)(nil), // 14: node.NodeInfoReply (*common.G1Commitment)(nil), // 15: common.G1Commitment } var file_node_node_proto_depIdxs = []int32{ @@ -1115,15 +1151,15 @@ var file_node_node_proto_depIdxs = []int32{ 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 - 13, // 11: node.Dispersal.VersionInfo:input_type -> node.VersionInfoRequest + 13, // 11: node.Dispersal.NodeInfo:input_type -> node.NodeInfoRequest 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 + 13, // 14: node.Retrieval.NodeInfo:input_type -> node.NodeInfoRequest 1, // 15: node.Dispersal.StoreChunks:output_type -> node.StoreChunksReply - 14, // 16: node.Dispersal.VersionInfo:output_type -> node.VersionInfoReply + 14, // 16: node.Dispersal.NodeInfo:output_type -> node.NodeInfoReply 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 + 14, // 19: node.Retrieval.NodeInfo:output_type -> node.NodeInfoReply 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 @@ -1294,7 +1330,7 @@ func file_node_node_proto_init() { } } file_node_node_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VersionInfoRequest); i { + switch v := v.(*NodeInfoRequest); i { case 0: return &v.state case 1: @@ -1306,7 +1342,7 @@ func file_node_node_proto_init() { } } file_node_node_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VersionInfoReply); i { + switch v := v.(*NodeInfoReply); i { case 0: return &v.state case 1: diff --git a/api/grpc/node/node_grpc.pb.go b/api/grpc/node/node_grpc.pb.go index ee0bd3147..ecc29fc9f 100644 --- a/api/grpc/node/node_grpc.pb.go +++ b/api/grpc/node/node_grpc.pb.go @@ -25,8 +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) + // Retrieve node info metadata + NodeInfo(ctx context.Context, in *NodeInfoRequest, opts ...grpc.CallOption) (*NodeInfoReply, error) } type dispersalClient struct { @@ -46,9 +46,9 @@ func (c *dispersalClient) StoreChunks(ctx context.Context, in *StoreChunksReques 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...) +func (c *dispersalClient) NodeInfo(ctx context.Context, in *NodeInfoRequest, opts ...grpc.CallOption) (*NodeInfoReply, error) { + out := new(NodeInfoReply) + err := c.cc.Invoke(ctx, "/node.Dispersal/NodeInfo", in, out, opts...) if err != nil { return nil, err } @@ -66,8 +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) + // Retrieve node info metadata + NodeInfo(context.Context, *NodeInfoRequest) (*NodeInfoReply, error) mustEmbedUnimplementedDispersalServer() } @@ -78,8 +78,8 @@ 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) NodeInfo(context.Context, *NodeInfoRequest) (*NodeInfoReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method NodeInfo not implemented") } func (UnimplementedDispersalServer) mustEmbedUnimplementedDispersalServer() {} @@ -112,20 +112,20 @@ 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) +func _Dispersal_NodeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NodeInfoRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(DispersalServer).VersionInfo(ctx, in) + return srv.(DispersalServer).NodeInfo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/node.Dispersal/VersionInfo", + FullMethod: "/node.Dispersal/NodeInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DispersalServer).VersionInfo(ctx, req.(*VersionInfoRequest)) + return srv.(DispersalServer).NodeInfo(ctx, req.(*NodeInfoRequest)) } return interceptor(ctx, in, info, handler) } @@ -142,8 +142,8 @@ var Dispersal_ServiceDesc = grpc.ServiceDesc{ Handler: _Dispersal_StoreChunks_Handler, }, { - MethodName: "VersionInfo", - Handler: _Dispersal_VersionInfo_Handler, + MethodName: "NodeInfo", + Handler: _Dispersal_NodeInfo_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -158,8 +158,8 @@ type RetrievalClient interface { RetrieveChunks(ctx context.Context, in *RetrieveChunksRequest, opts ...grpc.CallOption) (*RetrieveChunksReply, error) // 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) + // Retrieve node info metadata + NodeInfo(ctx context.Context, in *NodeInfoRequest, opts ...grpc.CallOption) (*NodeInfoReply, error) } type retrievalClient struct { @@ -188,9 +188,9 @@ func (c *retrievalClient) GetBlobHeader(ctx context.Context, in *GetBlobHeaderRe 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...) +func (c *retrievalClient) NodeInfo(ctx context.Context, in *NodeInfoRequest, opts ...grpc.CallOption) (*NodeInfoReply, error) { + out := new(NodeInfoReply) + err := c.cc.Invoke(ctx, "/node.Retrieval/NodeInfo", in, out, opts...) if err != nil { return nil, err } @@ -205,8 +205,8 @@ type RetrievalServer interface { RetrieveChunks(context.Context, *RetrieveChunksRequest) (*RetrieveChunksReply, error) // 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) + // Retrieve node info metadata + NodeInfo(context.Context, *NodeInfoRequest) (*NodeInfoReply, error) mustEmbedUnimplementedRetrievalServer() } @@ -220,8 +220,8 @@ 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) NodeInfo(context.Context, *NodeInfoRequest) (*NodeInfoReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method NodeInfo not implemented") } func (UnimplementedRetrievalServer) mustEmbedUnimplementedRetrievalServer() {} @@ -272,20 +272,20 @@ 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) +func _Retrieval_NodeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NodeInfoRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(RetrievalServer).VersionInfo(ctx, in) + return srv.(RetrievalServer).NodeInfo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/node.Retrieval/VersionInfo", + FullMethod: "/node.Retrieval/NodeInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RetrievalServer).VersionInfo(ctx, req.(*VersionInfoRequest)) + return srv.(RetrievalServer).NodeInfo(ctx, req.(*NodeInfoRequest)) } return interceptor(ctx, in, info, handler) } @@ -306,8 +306,8 @@ var Retrieval_ServiceDesc = grpc.ServiceDesc{ Handler: _Retrieval_GetBlobHeader_Handler, }, { - MethodName: "VersionInfo", - Handler: _Retrieval_VersionInfo_Handler, + MethodName: "NodeInfo", + Handler: _Retrieval_NodeInfo_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/api/proto/node/node.proto b/api/proto/node/node.proto index 56f2f20ee..dd5b7f37d 100644 --- a/api/proto/node/node.proto +++ b/api/proto/node/node.proto @@ -14,8 +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 info metadata - rpc VersionInfo(VersionInfoRequest) returns (VersionInfoReply) {} + // Retrieve node info metadata + rpc NodeInfo(NodeInfoRequest) returns (NodeInfoReply) {} } service Retrieval { @@ -23,8 +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 info metadata - rpc VersionInfo(VersionInfoRequest) returns (VersionInfoReply) {} + // Retrieve node info metadata + rpc NodeInfo(NodeInfoRequest) returns (NodeInfoReply) {} } // Requests and replies @@ -158,11 +158,15 @@ message BatchHeader { uint32 reference_block_number = 3; } -// Version info request -message VersionInfoRequest { +// Node info request +message NodeInfoRequest { } -// Version info reply -message VersionInfoReply { +// Node info reply +message NodeInfoReply { string semver = 1; + string arch = 2; + string os = 3; + uint32 num_cpu = 4; + uint64 mem_bytes = 5; } diff --git a/go.mod b/go.mod index ed50d2642..2bad729c8 100644 --- a/go.mod +++ b/go.mod @@ -195,7 +195,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible github.com/stretchr/objx v0.5.2 // indirect github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 diff --git a/node/grpc/server.go b/node/grpc/server.go index 362b03387..c29b22b3b 100644 --- a/node/grpc/server.go +++ b/node/grpc/server.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "runtime" "sync" "time" @@ -17,6 +18,7 @@ import ( "github.com/Layr-Labs/eigenda/encoding" "github.com/Layr-Labs/eigenda/node" "github.com/Layr-Labs/eigensdk-go/logging" + "github.com/shirou/gopsutil/mem" "google.golang.org/grpc" "google.golang.org/grpc/reflection" @@ -130,8 +132,14 @@ 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) NodeInfo(ctx context.Context, in *pb.NodeInfoRequest) (*pb.NodeInfoReply, error) { + memBytes := uint64(0) + v, err := mem.VirtualMemory() + if err == nil { + memBytes = v.Total + } + + return &pb.NodeInfoReply{Semver: node.SemVer, Os: runtime.GOOS, Arch: runtime.GOARCH, NumCpu: uint32(runtime.NumCPU()), MemBytes: memBytes}, nil } func (s *Server) handleStoreChunksRequest(ctx context.Context, in *pb.StoreChunksRequest) (*pb.StoreChunksReply, error) { diff --git a/node/grpc/server_test.go b/node/grpc/server_test.go index be99835e0..9a333ff6b 100644 --- a/node/grpc/server_test.go +++ b/node/grpc/server_test.go @@ -278,10 +278,14 @@ func storeChunks(t *testing.T, server *grpc.Server) ([32]byte, [32]byte, []*core return batchHeaderHash, batchRoot, blobHeaders, blobHeadersProto } -func TestVersionInfoRequest(t *testing.T) { +func TestNodeInfoRequest(t *testing.T) { server := newTestServer(t, true) - resp, err := server.VersionInfo(context.Background(), &pb.VersionInfoRequest{}) + resp, err := server.NodeInfo(context.Background(), &pb.NodeInfoRequest{}) assert.True(t, resp.Semver == "0.0.0") + assert.True(t, resp.Os != "") + assert.True(t, resp.Arch != "") + assert.True(t, resp.NumCpu > 0) + assert.True(t, resp.MemBytes >= 0) assert.True(t, err == nil) } From 6d73a4ab15d5e57a146cd6a1c85512500f4eff44 Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:36:07 -0700 Subject: [PATCH 4/8] Lint --- api/proto/node/node.proto | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/proto/node/node.proto b/api/proto/node/node.proto index dd5b7f37d..1e99dfa2d 100644 --- a/api/proto/node/node.proto +++ b/api/proto/node/node.proto @@ -164,9 +164,9 @@ message NodeInfoRequest { // Node info reply message NodeInfoReply { - string semver = 1; - string arch = 2; - string os = 3; - uint32 num_cpu = 4; + string semver = 1; + string arch = 2; + string os = 3; + uint32 num_cpu = 4; uint64 mem_bytes = 5; } From b23166c3bb9f5166164e9d40a9d4aeb82053703e Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:08:55 -0700 Subject: [PATCH 5/8] Add automaxprocs to correctly determine CPU resources in container --- node/grpc/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/node/grpc/server.go b/node/grpc/server.go index c29b22b3b..4f65981b9 100644 --- a/node/grpc/server.go +++ b/node/grpc/server.go @@ -20,6 +20,8 @@ import ( "github.com/Layr-Labs/eigensdk-go/logging" "github.com/shirou/gopsutil/mem" + _ "go.uber.org/automaxprocs" + "google.golang.org/grpc" "google.golang.org/grpc/reflection" "google.golang.org/protobuf/proto" @@ -139,7 +141,7 @@ func (s *Server) NodeInfo(ctx context.Context, in *pb.NodeInfoRequest) (*pb.Node memBytes = v.Total } - return &pb.NodeInfoReply{Semver: node.SemVer, Os: runtime.GOOS, Arch: runtime.GOARCH, NumCpu: uint32(runtime.NumCPU()), MemBytes: memBytes}, nil + return &pb.NodeInfoReply{Semver: node.SemVer, Os: runtime.GOOS, Arch: runtime.GOARCH, NumCpu: uint32(runtime.GOMAXPROCS(0)), MemBytes: memBytes}, nil } func (s *Server) handleStoreChunksRequest(ctx context.Context, in *pb.StoreChunksRequest) (*pb.StoreChunksReply, error) { From 44695eaf209d0296a2ee50f406649f32203e71c6 Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:40:28 -0700 Subject: [PATCH 6/8] Allow operator to disable host resource information (os, arch, cpus, mem) on the NodeInfo endpoint --- node/config.go | 2 ++ node/flags/flags.go | 8 ++++++++ node/grpc/server.go | 4 ++++ node/grpc/server_test.go | 4 ---- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/node/config.go b/node/config.go index 1608525a0..8a2d95143 100644 --- a/node/config.go +++ b/node/config.go @@ -72,6 +72,7 @@ type Config struct { ClientIPHeader string UseSecureGrpc bool ReachabilityPollIntervalSec uint64 + DisableNodeInfoResources bool EthClientConfig geth.EthClientConfig LoggerConfig common.LoggerConfig @@ -201,5 +202,6 @@ func NewConfig(ctx *cli.Context) (*Config, error) { NumBatchDeserializationWorkers: ctx.GlobalInt(flags.NumBatchDeserializationWorkersFlag.Name), ClientIPHeader: ctx.GlobalString(flags.ClientIPHeaderFlag.Name), UseSecureGrpc: ctx.GlobalBoolT(flags.ChurnerUseSecureGRPC.Name), + DisableNodeInfoResources: ctx.GlobalBool(flags.DisableNodeInfoResourcesFlag.Name), }, nil } diff --git a/node/flags/flags.go b/node/flags/flags.go index d6a5d8abf..7e81119c4 100644 --- a/node/flags/flags.go +++ b/node/flags/flags.go @@ -259,6 +259,13 @@ var ( Value: "", EnvVar: common.PrefixEnvVar(EnvVarPrefix, "CLIENT_IP_HEADER"), } + + DisableNodeInfoResourcesFlag = cli.BoolFlag{ + Name: common.PrefixFlag(FlagPrefix, "disable-node-info-resources"), + Usage: "Disable system resource information (OS, architecture, CPU, memory) on the NodeInfo API", + Required: false, + EnvVar: common.PrefixEnvVar(EnvVarPrefix, "DISABLE_NODE_INFO_RESOURCES"), + } ) var requiredFlags = []cli.Flag{ @@ -299,6 +306,7 @@ var optionalFlags = []cli.Flag{ EcdsaKeyFileFlag, EcdsaKeyPasswordFlag, DataApiUrlFlag, + DisableNodeInfoResourcesFlag, } func init() { diff --git a/node/grpc/server.go b/node/grpc/server.go index 4f65981b9..9d249e213 100644 --- a/node/grpc/server.go +++ b/node/grpc/server.go @@ -135,6 +135,10 @@ func (s *Server) serveRetrieval() error { } func (s *Server) NodeInfo(ctx context.Context, in *pb.NodeInfoRequest) (*pb.NodeInfoReply, error) { + if s.config.DisableNodeInfoResources { + return &pb.NodeInfoReply{Semver: node.SemVer, Os: "", Arch: "", NumCpu: 0, MemBytes: 0}, nil + } + memBytes := uint64(0) v, err := mem.VirtualMemory() if err == nil { diff --git a/node/grpc/server_test.go b/node/grpc/server_test.go index 9a333ff6b..84623ec94 100644 --- a/node/grpc/server_test.go +++ b/node/grpc/server_test.go @@ -282,10 +282,6 @@ func TestNodeInfoRequest(t *testing.T) { server := newTestServer(t, true) resp, err := server.NodeInfo(context.Background(), &pb.NodeInfoRequest{}) assert.True(t, resp.Semver == "0.0.0") - assert.True(t, resp.Os != "") - assert.True(t, resp.Arch != "") - assert.True(t, resp.NumCpu > 0) - assert.True(t, resp.MemBytes >= 0) assert.True(t, err == nil) } From afd5cd27d2b1b3a694a6ccc59a5379cfb9490e33 Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:02:59 -0700 Subject: [PATCH 7/8] Lint --- node/grpc/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/grpc/server.go b/node/grpc/server.go index 9d249e213..b6dbae008 100644 --- a/node/grpc/server.go +++ b/node/grpc/server.go @@ -136,7 +136,7 @@ func (s *Server) serveRetrieval() error { func (s *Server) NodeInfo(ctx context.Context, in *pb.NodeInfoRequest) (*pb.NodeInfoReply, error) { if s.config.DisableNodeInfoResources { - return &pb.NodeInfoReply{Semver: node.SemVer, Os: "", Arch: "", NumCpu: 0, MemBytes: 0}, nil + return &pb.NodeInfoReply{Semver: node.SemVer}, nil } memBytes := uint64(0) From 7360628b728cd895922329a88605af575b7de34e Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:46:03 -0700 Subject: [PATCH 8/8] Lint --- api/grpc/node/node.pb.go | 2 +- api/grpc/node/node_grpc.pb.go | 35 +++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/api/grpc/node/node.pb.go b/api/grpc/node/node.pb.go index 3555da51a..4ce01f3a0 100644 --- a/api/grpc/node/node.pb.go +++ b/api/grpc/node/node.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.28.1 // protoc v5.26.1 // source: node/node.proto diff --git a/api/grpc/node/node_grpc.pb.go b/api/grpc/node/node_grpc.pb.go index ecc29fc9f..20ef64b70 100644 --- a/api/grpc/node/node_grpc.pb.go +++ b/api/grpc/node/node_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v5.26.1 +// source: node/node.proto package node @@ -14,6 +18,11 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + Dispersal_StoreChunks_FullMethodName = "/node.Dispersal/StoreChunks" + Dispersal_NodeInfo_FullMethodName = "/node.Dispersal/NodeInfo" +) + // 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. @@ -39,7 +48,7 @@ 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, "/node.Dispersal/StoreChunks", in, out, opts...) + err := c.cc.Invoke(ctx, Dispersal_StoreChunks_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -48,7 +57,7 @@ func (c *dispersalClient) StoreChunks(ctx context.Context, in *StoreChunksReques func (c *dispersalClient) NodeInfo(ctx context.Context, in *NodeInfoRequest, opts ...grpc.CallOption) (*NodeInfoReply, error) { out := new(NodeInfoReply) - err := c.cc.Invoke(ctx, "/node.Dispersal/NodeInfo", in, out, opts...) + err := c.cc.Invoke(ctx, Dispersal_NodeInfo_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -104,7 +113,7 @@ func _Dispersal_StoreChunks_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/node.Dispersal/StoreChunks", + FullMethod: Dispersal_StoreChunks_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DispersalServer).StoreChunks(ctx, req.(*StoreChunksRequest)) @@ -122,7 +131,7 @@ func _Dispersal_NodeInfo_Handler(srv interface{}, ctx context.Context, dec func( } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/node.Dispersal/NodeInfo", + FullMethod: Dispersal_NodeInfo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DispersalServer).NodeInfo(ctx, req.(*NodeInfoRequest)) @@ -150,6 +159,12 @@ var Dispersal_ServiceDesc = grpc.ServiceDesc{ Metadata: "node/node.proto", } +const ( + Retrieval_RetrieveChunks_FullMethodName = "/node.Retrieval/RetrieveChunks" + Retrieval_GetBlobHeader_FullMethodName = "/node.Retrieval/GetBlobHeader" + Retrieval_NodeInfo_FullMethodName = "/node.Retrieval/NodeInfo" +) + // 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. @@ -172,7 +187,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, "/node.Retrieval/RetrieveChunks", in, out, opts...) + err := c.cc.Invoke(ctx, Retrieval_RetrieveChunks_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -181,7 +196,7 @@ 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, "/node.Retrieval/GetBlobHeader", in, out, opts...) + err := c.cc.Invoke(ctx, Retrieval_GetBlobHeader_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -190,7 +205,7 @@ func (c *retrievalClient) GetBlobHeader(ctx context.Context, in *GetBlobHeaderRe func (c *retrievalClient) NodeInfo(ctx context.Context, in *NodeInfoRequest, opts ...grpc.CallOption) (*NodeInfoReply, error) { out := new(NodeInfoReply) - err := c.cc.Invoke(ctx, "/node.Retrieval/NodeInfo", in, out, opts...) + err := c.cc.Invoke(ctx, Retrieval_NodeInfo_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -246,7 +261,7 @@ func _Retrieval_RetrieveChunks_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/node.Retrieval/RetrieveChunks", + FullMethod: Retrieval_RetrieveChunks_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RetrievalServer).RetrieveChunks(ctx, req.(*RetrieveChunksRequest)) @@ -264,7 +279,7 @@ func _Retrieval_GetBlobHeader_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/node.Retrieval/GetBlobHeader", + FullMethod: Retrieval_GetBlobHeader_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RetrievalServer).GetBlobHeader(ctx, req.(*GetBlobHeaderRequest)) @@ -282,7 +297,7 @@ func _Retrieval_NodeInfo_Handler(srv interface{}, ctx context.Context, dec func( } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/node.Retrieval/NodeInfo", + FullMethod: Retrieval_NodeInfo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RetrievalServer).NodeInfo(ctx, req.(*NodeInfoRequest))