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] 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) }