diff --git a/docs/proto/provider.md b/docs/proto/provider.md index 420052a9..bb8bd9b1 100644 --- a/docs/proto/provider.md +++ b/docs/proto/provider.md @@ -43,8 +43,12 @@ - [akash/inventory/v1/cluster.proto](#akash/inventory/v1/cluster.proto) - [Cluster](#akash.inventory.v1.Cluster) + - [akash/inventory/v1/resources.proto](#akash/inventory/v1/resources.proto) + - [NodeResources](#akash.inventory.v1.NodeResources) + - [akash/inventory/v1/node.proto](#akash/inventory/v1/node.proto) - [Node](#akash.inventory.v1.Node) + - [NodeCapabilities](#akash.inventory.v1.NodeCapabilities) - [akash/inventory/v1/resourcepair.proto](#akash/inventory/v1/resourcepair.proto) - [ResourcePair](#akash.inventory.v1.ResourcePair) @@ -545,6 +549,42 @@ + + + + + + + + + + + +

Top

+ + ## akash/inventory/v1/resources.proto + + + + + + ### NodeResources + NodeResources reports node inventory details + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `cpu` | [CPU](#akash.inventory.v1.CPU) | | | + | `memory` | [Memory](#akash.inventory.v1.Memory) | | | + | `gpu` | [GPU](#akash.inventory.v1.GPU) | | | + | `ephemeral_storage` | [ResourcePair](#akash.inventory.v1.ResourcePair) | | | + | `volumes_attached` | [ResourcePair](#akash.inventory.v1.ResourcePair) | | | + | `volumes_mounted` | [ResourcePair](#akash.inventory.v1.ResourcePair) | | | + + + + + @@ -570,10 +610,24 @@ | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | - | `cpu` | [CPU](#akash.inventory.v1.CPU) | | | - | `memory` | [Memory](#akash.inventory.v1.Memory) | | | - | `gpu` | [GPU](#akash.inventory.v1.GPU) | | | - | `storage` | [Storage](#akash.inventory.v1.Storage) | | | + | `name` | [string](#string) | | | + | `resources` | [NodeResources](#akash.inventory.v1.NodeResources) | | | + | `capabilities` | [NodeCapabilities](#akash.inventory.v1.NodeCapabilities) | | | + + + + + + + + + ### NodeCapabilities + NodeCapabilities extended list of node capabilities + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `storage_classes` | [string](#string) | repeated | | @@ -654,6 +708,7 @@ | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `vendor` | [string](#string) | | | + | `vendor_id` | [string](#string) | | | | `name` | [string](#string) | | | | `modelid` | [string](#string) | | | | `interface` | [string](#string) | | | @@ -751,7 +806,8 @@ | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | - | `QueryCluster` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Cluster](#akash.inventory.v1.Cluster) stream | QueryNode defines a method to query and stream hardware state of the cluster buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | | + | `QueryCluster` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Cluster](#akash.inventory.v1.Cluster) | QueryCluster defines a method to query hardware state of the cluster buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | GET|/v1/inventory| + | `StreamCluster` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Cluster](#akash.inventory.v1.Cluster) stream | StreamCluster defines a method to stream hardware state of the cluster buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | | @@ -761,7 +817,8 @@ | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | - | `QueryNode` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Node](#akash.inventory.v1.Node) stream | QueryNode defines a method to query and stream hardware state of the node buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | | + | `QueryNode` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Node](#akash.inventory.v1.Node) | QueryNode defines a method to query hardware state of the node buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | GET|/v1/node| + | `StreamNode` | [VoidNoParam](#akash.inventory.v1.VoidNoParam) | [Node](#akash.inventory.v1.Node) stream | StreamNode defines a method to stream hardware state of the node buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE buf:lint:ignore RPC_RESPONSE_STANDARD_NAME | | diff --git a/go/inventory/v1/gpu.go b/go/inventory/v1/gpu.go index 51321b1f..01038c24 100644 --- a/go/inventory/v1/gpu.go +++ b/go/inventory/v1/gpu.go @@ -26,6 +26,7 @@ func (r *GPU) Dup() GPU { func (s *GPUInfo) Dup() GPUInfo { res := GPUInfo{ Vendor: s.Vendor, + VendorID: s.VendorID, Name: s.Name, ModelID: s.ModelID, Interface: s.Interface, diff --git a/go/inventory/v1/gpu.pb.go b/go/inventory/v1/gpu.pb.go index 0aa2f459..f69ac814 100644 --- a/go/inventory/v1/gpu.pb.go +++ b/go/inventory/v1/gpu.pb.go @@ -26,10 +26,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GPUInfo reports GPU details type GPUInfo struct { Vendor string `protobuf:"bytes,1,opt,name=vendor,proto3" json:"vendor" yaml:"vendor"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name" yaml:"name"` - ModelID string `protobuf:"bytes,3,opt,name=modelid,proto3" json:"model_id" yaml:"model_id"` - Interface string `protobuf:"bytes,4,opt,name=interface,proto3" json:"interface" yaml:"interface"` - MemorySize string `protobuf:"bytes,5,opt,name=memory_size,json=memorySize,proto3" json:"memory_size" yaml:"memory_size"` + VendorID string `protobuf:"bytes,2,opt,name=vendor_id,json=vendorId,proto3" json:"vendor_id" yaml:"vendor_id"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name" yaml:"name"` + ModelID string `protobuf:"bytes,4,opt,name=modelid,proto3" json:"model_id" yaml:"model_id"` + Interface string `protobuf:"bytes,5,opt,name=interface,proto3" json:"interface" yaml:"interface"` + MemorySize string `protobuf:"bytes,6,opt,name=memory_size,json=memorySize,proto3" json:"memory_size" yaml:"memory_size"` } func (m *GPUInfo) Reset() { *m = GPUInfo{} } @@ -72,6 +73,13 @@ func (m *GPUInfo) GetVendor() string { return "" } +func (m *GPUInfo) GetVendorID() string { + if m != nil { + return m.VendorID + } + return "" +} + func (m *GPUInfo) GetName() string { if m != nil { return m.Name @@ -161,37 +169,39 @@ func init() { func init() { proto.RegisterFile("akash/inventory/v1/gpu.proto", fileDescriptor_2cc01b12bd00ffcc) } var fileDescriptor_2cc01b12bd00ffcc = []byte{ - // 476 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x4d, 0x6b, 0x13, 0x41, - 0x18, 0xce, 0x26, 0x31, 0x1f, 0x13, 0x44, 0x19, 0x3c, 0x2c, 0x55, 0xf6, 0x0d, 0x03, 0x85, 0x22, - 0xb8, 0x4b, 0x93, 0x9b, 0xe0, 0x25, 0x14, 0x4a, 0xa0, 0x95, 0xb8, 0xb5, 0x1e, 0xbc, 0xd4, 0x69, - 0x32, 0xd9, 0x0e, 0xed, 0xee, 0xc4, 0xc9, 0x26, 0x92, 0xfe, 0x0a, 0x7f, 0x87, 0xbf, 0xa4, 0xc7, - 0x9e, 0xc4, 0xd3, 0x28, 0x9b, 0x83, 0x90, 0xe3, 0xfe, 0x02, 0x99, 0xd9, 0x2f, 0xc5, 0xde, 0xf6, - 0x7d, 0xbe, 0xde, 0xe5, 0x7d, 0x06, 0xbd, 0xa0, 0xd7, 0x74, 0x79, 0xe5, 0xf1, 0x68, 0xcd, 0xa2, - 0x58, 0xc8, 0x8d, 0xb7, 0x3e, 0xf4, 0x82, 0xc5, 0xca, 0x5d, 0x48, 0x11, 0x0b, 0x8c, 0x0d, 0xeb, - 0x96, 0xac, 0xbb, 0x3e, 0xdc, 0x7b, 0x16, 0x88, 0x40, 0x18, 0xda, 0xd3, 0x5f, 0x99, 0x72, 0x6f, - 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 0xff, 0xbb, 0x0a, 0x24, 0x3e, 0x0a, 0x4b, 0x03, 0xf9, - 0x6e, 0xa1, 0xc6, 0xf1, 0xe4, 0x1c, 0x87, 0xa8, 0xf3, 0x79, 0x45, 0xa3, 0x98, 0xc7, 0x1b, 0x73, - 0xe7, 0xde, 0xa0, 0xef, 0xfe, 0xdf, 0xaa, 0xeb, 0xe7, 0x5d, 0x4d, 0x28, 0x97, 0x23, 0xef, 0x4e, - 0x41, 0x2d, 0x51, 0xd0, 0x79, 0x97, 0x3b, 0xf5, 0x65, 0x8a, 0x94, 0xea, 0x32, 0x05, 0x42, 0xfc, - 0x92, 0xc4, 0x9f, 0x50, 0x93, 0x47, 0x73, 0x61, 0xd7, 0xfb, 0x8d, 0x83, 0xde, 0xe0, 0xf9, 0x43, - 0xab, 0xf2, 0xfe, 0xcb, 0x2d, 0x4d, 0x3d, 0xe9, 0xda, 0xb4, 0xb1, 0xaa, 0x4d, 0x4f, 0xe4, 0xdb, - 0x4f, 0xe8, 0xe4, 0xfa, 0x33, 0xdf, 0x08, 0x46, 0x27, 0x77, 0x89, 0x63, 0xdd, 0x27, 0x8e, 0xf5, - 0x2b, 0x71, 0xac, 0xaf, 0x5b, 0xa7, 0x76, 0xbf, 0x75, 0x6a, 0x3f, 0xb6, 0x4e, 0xed, 0xe3, 0x20, - 0xe0, 0xf1, 0xd5, 0xea, 0xd2, 0x9d, 0x8a, 0xd0, 0x33, 0x7b, 0x5f, 0x45, 0x2c, 0xfe, 0x22, 0xe4, - 0x75, 0x3e, 0xd1, 0x05, 0xf7, 0x02, 0xf1, 0xcf, 0x1b, 0xbd, 0x6c, 0x99, 0x77, 0x39, 0xfc, 0x13, - 0x00, 0x00, 0xff, 0xff, 0x73, 0xf7, 0x44, 0x3a, 0x08, 0x03, 0x00, 0x00, + // 505 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x4f, 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xd1, 0x09, 0x07, 0x99, 0x44, 0xb6, 0x49, 0x18, 0x1e, 0x6d, 0x24, 0xaa, + 0x04, 0x5b, 0x89, 0x9e, 0xdf, 0x8f, 0x19, 0xb3, 0x10, 0x07, 0xb6, 0xa9, 0x87, 0x21, 0xec, 0x83, + 0x46, 0x42, 0x62, 0xea, 0xd4, 0x75, 0x0c, 0xca, 0x24, 0x6a, 0xbc, 0x27, 0x31, 0xdd, 0x48, 0xa4, + 0xf1, 0xad, 0x44, 0x1d, 0xe3, 0x56, 0x1d, 0x0e, 0x34, 0x08, 0x8f, 0x40, 0x2b, 0xe6, 0x21, 0xbd, + 0x66, 0xa1, 0xd3, 0xd0, 0xbe, 0xd7, 0x99, 0x44, 0xad, 0x53, 0x05, 0xe9, 0xe9, 0xb6, 0x66, 0xcd, + 0xf0, 0x67, 0xc6, 0x5e, 0x20, 0x38, 0x28, 0xac, 0xf0, 0x04, 0xb4, 0x59, 0x92, 0x52, 0x31, 0x25, + 0x13, 0xea, 0x3c, 0xd1, 0x39, 0x5e, 0x26, 0x51, 0x7b, 0x58, 0x80, 0xea, 0x3f, 0x4a, 0x45, 0xf5, + 0x1f, 0x25, 0x84, 0x83, 0x8a, 0x86, 0x1f, 0x41, 0x27, 0xa6, 0x31, 0x17, 0xab, 0xf1, 0x9c, 0xdd, + 0x50, 0xa7, 0xa9, 0xf3, 0xfa, 0x99, 0x44, 0xe0, 0x54, 0xc3, 0x67, 0xec, 0x46, 0x05, 0xde, 0x17, + 0x6d, 0x25, 0x82, 0xf9, 0xd7, 0x55, 0x20, 0x0e, 0x40, 0x5c, 0x1a, 0xf0, 0x2f, 0x0b, 0xd4, 0x8f, + 0x47, 0xe7, 0x30, 0x06, 0xf6, 0xd7, 0x05, 0x49, 0x52, 0x96, 0xae, 0xf4, 0xce, 0x3a, 0xbd, 0xae, + 0xf7, 0xf0, 0x42, 0xbc, 0x20, 0xdf, 0xfb, 0x88, 0x30, 0x31, 0xf0, 0x6f, 0x25, 0xaa, 0xa9, 0xbd, + 0x7c, 0xc8, 0x9d, 0xea, 0x65, 0x8a, 0x94, 0xea, 0x65, 0x0a, 0x04, 0x07, 0x25, 0x09, 0xbf, 0x80, + 0x06, 0x4b, 0xa6, 0xdc, 0xd9, 0xe9, 0xd6, 0xf7, 0x3b, 0xbd, 0x97, 0x8f, 0x8d, 0xca, 0x6f, 0xa9, + 0x9c, 0xd2, 0x50, 0x9d, 0x5a, 0x9b, 0x32, 0x56, 0x6b, 0x53, 0x1d, 0xfe, 0xf1, 0x07, 0xd9, 0xb9, + 0xfe, 0x2c, 0xd0, 0x82, 0xc1, 0xc9, 0x6d, 0xe6, 0x5a, 0x77, 0x99, 0x6b, 0xfd, 0xcd, 0x5c, 0xeb, + 0xfb, 0xda, 0xad, 0xdd, 0xad, 0xdd, 0xda, 0xef, 0xb5, 0x5b, 0xfb, 0xdc, 0x8b, 0x58, 0x7a, 0xb9, + 0xb8, 0xf0, 0x26, 0x3c, 0xf6, 0xf5, 0xdc, 0x83, 0x84, 0xa6, 0xdf, 0xb8, 0xb8, 0xca, 0x3b, 0x32, + 0x63, 0x7e, 0xc4, 0xff, 0xbb, 0xf7, 0x8b, 0xa6, 0xbe, 0xf1, 0xfe, 0xbf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xed, 0x18, 0x1d, 0x0d, 0x54, 0x03, 0x00, 0x00, } func (m *GPUInfo) Marshal() (dAtA []byte, err error) { @@ -219,27 +229,34 @@ func (m *GPUInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.MemorySize) i = encodeVarintGpu(dAtA, i, uint64(len(m.MemorySize))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } if len(m.Interface) > 0 { i -= len(m.Interface) copy(dAtA[i:], m.Interface) i = encodeVarintGpu(dAtA, i, uint64(len(m.Interface))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.ModelID) > 0 { i -= len(m.ModelID) copy(dAtA[i:], m.ModelID) i = encodeVarintGpu(dAtA, i, uint64(len(m.ModelID))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) i = encodeVarintGpu(dAtA, i, uint64(len(m.Name))) i-- + dAtA[i] = 0x1a + } + if len(m.VendorID) > 0 { + i -= len(m.VendorID) + copy(dAtA[i:], m.VendorID) + i = encodeVarintGpu(dAtA, i, uint64(len(m.VendorID))) + i-- dAtA[i] = 0x12 } if len(m.Vendor) > 0 { @@ -320,6 +337,10 @@ func (m *GPUInfo) Size() (n int) { if l > 0 { n += 1 + l + sovGpu(uint64(l)) } + l = len(m.VendorID) + if l > 0 { + n += 1 + l + sovGpu(uint64(l)) + } l = len(m.Name) if l > 0 { n += 1 + l + sovGpu(uint64(l)) @@ -424,6 +445,38 @@ func (m *GPUInfo) Unmarshal(dAtA []byte) error { m.Vendor = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VendorID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGpu + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGpu + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VendorID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } @@ -455,7 +508,7 @@ func (m *GPUInfo) Unmarshal(dAtA []byte) error { } m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ModelID", wireType) } @@ -487,7 +540,7 @@ func (m *GPUInfo) Unmarshal(dAtA []byte) error { } m.ModelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Interface", wireType) } @@ -519,7 +572,7 @@ func (m *GPUInfo) Unmarshal(dAtA []byte) error { } m.Interface = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MemorySize", wireType) } diff --git a/go/inventory/v1/node.go b/go/inventory/v1/node.go index bfde9bec..f4e2bca8 100644 --- a/go/inventory/v1/node.go +++ b/go/inventory/v1/node.go @@ -1,5 +1,17 @@ package v1 +func (nd *NodeCapabilities) Dup() NodeCapabilities { + res := NodeCapabilities{ + StorageClasses: make([]string, 0, len(nd.StorageClasses)), + } + + for _, class := range nd.StorageClasses { + res.StorageClasses = append(res.StorageClasses, class) + } + + return res +} + func (nd Nodes) Dup() Nodes { res := make(Nodes, 0, len(nd)) @@ -11,11 +23,20 @@ func (nd Nodes) Dup() Nodes { func (nd *Node) Dup() Node { res := Node{ - CPU: nd.CPU.Dup(), - GPU: nd.GPU.Dup(), - Memory: nd.Memory.Dup(), - EphemeralStorage: nd.EphemeralStorage.Dup(), + Name: nd.Name, + Resources: nd.Resources.Dup(), + Capabilities: nd.Capabilities.Dup(), } return res } + +func (nd *Node) IsStorageClassSupported(class string) bool { + for _, val := range nd.Capabilities.StorageClasses { + if val == class { + return true + } + } + + return false +} diff --git a/go/inventory/v1/node.pb.go b/go/inventory/v1/node.pb.go index 038729d4..d37c2d29 100644 --- a/go/inventory/v1/node.pb.go +++ b/go/inventory/v1/node.pb.go @@ -23,19 +23,63 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// NodeCapabilities extended list of node capabilities +type NodeCapabilities struct { + StorageClasses []string `protobuf:"bytes,1,rep,name=storage_classes,json=storageClasses,proto3" json:"storage_classes" yaml:"storage_classes"` +} + +func (m *NodeCapabilities) Reset() { *m = NodeCapabilities{} } +func (m *NodeCapabilities) String() string { return proto.CompactTextString(m) } +func (*NodeCapabilities) ProtoMessage() {} +func (*NodeCapabilities) Descriptor() ([]byte, []int) { + return fileDescriptor_5f97c0fb35079221, []int{0} +} +func (m *NodeCapabilities) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NodeCapabilities) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NodeCapabilities.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *NodeCapabilities) XXX_Merge(src proto.Message) { + xxx_messageInfo_NodeCapabilities.Merge(m, src) +} +func (m *NodeCapabilities) XXX_Size() int { + return m.Size() +} +func (m *NodeCapabilities) XXX_DiscardUnknown() { + xxx_messageInfo_NodeCapabilities.DiscardUnknown(m) +} + +var xxx_messageInfo_NodeCapabilities proto.InternalMessageInfo + +func (m *NodeCapabilities) GetStorageClasses() []string { + if m != nil { + return m.StorageClasses + } + return nil +} + // Node reports node inventory details type Node struct { - CPU CPU `protobuf:"bytes,1,opt,name=cpu,proto3" json:"cpu" yaml:"cpu"` - Memory Memory `protobuf:"bytes,2,opt,name=memory,proto3" json:"memory" yaml:"memory"` - GPU GPU `protobuf:"bytes,3,opt,name=gpu,proto3,castrepeated=GPUs" json:"gpu" yaml:"gpu"` - EphemeralStorage Storage `protobuf:"bytes,4,opt,name=storage,proto3" json:"EphemeralStorage" yaml:"EphemeralStorage"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name" yaml:"name"` + Resources NodeResources `protobuf:"bytes,2,opt,name=resources,proto3" json:"resources" yaml:"resources"` + Capabilities NodeCapabilities `protobuf:"bytes,3,opt,name=capabilities,proto3" json:"capabilities" yaml:"capabilities"` } func (m *Node) Reset() { *m = Node{} } func (m *Node) String() string { return proto.CompactTextString(m) } func (*Node) ProtoMessage() {} func (*Node) Descriptor() ([]byte, []int) { - return fileDescriptor_5f97c0fb35079221, []int{0} + return fileDescriptor_5f97c0fb35079221, []int{1} } func (m *Node) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -64,66 +108,92 @@ func (m *Node) XXX_DiscardUnknown() { var xxx_messageInfo_Node proto.InternalMessageInfo -func (m *Node) GetCPU() CPU { +func (m *Node) GetName() string { if m != nil { - return m.CPU + return m.Name } - return CPU{} + return "" } -func (m *Node) GetMemory() Memory { +func (m *Node) GetResources() NodeResources { if m != nil { - return m.Memory + return m.Resources } - return Memory{} + return NodeResources{} } -func (m *Node) GetGPU() GPU { +func (m *Node) GetCapabilities() NodeCapabilities { if m != nil { - return m.GPU + return m.Capabilities } - return GPU{} -} - -func (m *Node) GetEphemeralStorage() Storage { - if m != nil { - return m.EphemeralStorage - } - return Storage{} + return NodeCapabilities{} } func init() { + proto.RegisterType((*NodeCapabilities)(nil), "akash.inventory.v1.NodeCapabilities") proto.RegisterType((*Node)(nil), "akash.inventory.v1.Node") } func init() { proto.RegisterFile("akash/inventory/v1/node.proto", fileDescriptor_5f97c0fb35079221) } var fileDescriptor_5f97c0fb35079221 = []byte{ - // 374 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x3d, 0x6b, 0xbb, 0x40, - 0x1c, 0xc7, 0xf5, 0x6f, 0xc8, 0x1f, 0x2c, 0x85, 0x22, 0x85, 0x88, 0x6d, 0xbd, 0xe0, 0x94, 0x0e, - 0x55, 0x92, 0x6e, 0x1d, 0x0d, 0xc5, 0xa1, 0x0f, 0x88, 0xc1, 0xa5, 0xd0, 0xc1, 0x18, 0xb9, 0x84, - 0x44, 0xef, 0x30, 0x9a, 0x92, 0xa5, 0x6b, 0xd7, 0xbe, 0x8e, 0xbe, 0x92, 0x8c, 0x19, 0x3b, 0x5d, - 0x8b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d6, 0xd6, 0xd5, 0x61, 0xae, 0xf0, 0xb3, 0x2b, - 0xc4, 0xb9, 0xf1, 0xf2, 0x06, 0x6a, 0x8e, 0xeb, 0x4f, 0xbd, 0x12, 0x29, 0x8f, 0xf2, 0x7f, 0xfe, - 0xef, 0xd4, 0x1a, 0x2d, 0x3e, 0xaa, 0x2a, 0xee, 0xb1, 0x88, 0xed, 0xf0, 0xf2, 0x83, 0x4b, 0x3c, - 0x8c, 0xe2, 0x28, 0x0d, 0x26, 0x9c, 0xac, 0x2b, 0xce, 0x36, 0x04, 0x34, 0xd8, 0xda, 0xef, 0xc4, - 0xf0, 0xb6, 0x4b, 0xed, 0xeb, 0x45, 0xa1, 0x8b, 0xcb, 0x42, 0x17, 0xdf, 0x0b, 0x5d, 0x7c, 0x5e, - 0xe9, 0xc2, 0x72, 0xa5, 0x0b, 0xaf, 0x2b, 0x5d, 0xb8, 0xeb, 0xc0, 0x51, 0x36, 0xcc, 0xfb, 0x66, - 0x88, 0x62, 0x8b, 0x2a, 0x9d, 0x25, 0x51, 0xf6, 0x80, 0xd2, 0x31, 0x9f, 0x02, 0x3c, 0xb2, 0x20, - 0xfa, 0xf2, 0xc8, 0xfd, 0x3a, 0x7d, 0xde, 0xf3, 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x3d, - 0xc9, 0x60, 0xa8, 0x02, 0x00, 0x00, + // 375 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x31, 0x4f, 0xc2, 0x40, + 0x1c, 0xc5, 0x7b, 0x40, 0x4c, 0x5a, 0x08, 0x92, 0x6a, 0x4c, 0x43, 0x62, 0x0f, 0x2f, 0x0e, 0x2c, + 0xb6, 0x01, 0x36, 0x1d, 0x4c, 0xca, 0x6a, 0x18, 0xea, 0xe6, 0x62, 0x8e, 0x72, 0x29, 0x0d, 0xb4, + 0x47, 0x7a, 0x05, 0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cc, 0x9f, 0xa3, 0x54, 0x3a, 0xa0, 0x5b, + 0xef, 0x5f, 0x69, 0xbf, 0xa7, 0xa3, 0x25, 0x0d, 0xe6, 0x8f, 0xd1, 0xe8, 0x6f, 0x38, 0x14, 0x42, + 0x0e, 0xc5, 0x5c, 0x8a, 0x38, 0x3c, 0x04, 0xc5, 0x1c, 0xb6, 0xb2, 0xaa, 0x5c, 0x42, 0xe6, 0x01, + 0xcb, 0x6f, 0x40, 0x6a, 0x58, 0x85, 0x69, 0x29, 0xd5, 0xb4, 0xf8, 0xfa, 0xbf, 0xe2, 0xe2, 0x64, + 0x8d, 0xbb, 0x7d, 0x77, 0xa3, 0xa8, 0x46, 0x1c, 0x96, 0x12, 0x63, 0x0e, 0xcf, 0xb2, 0x1b, 0x14, + 0x55, 0x64, 0x96, 0x4c, 0xc6, 0xc3, 0x26, 0x54, 0xc1, 0x36, 0x54, 0xc1, 0x57, 0xa8, 0x82, 0xf7, + 0x9d, 0x2a, 0x6c, 0x77, 0xaa, 0xf0, 0xb9, 0x53, 0x85, 0xa7, 0xbe, 0xed, 0x04, 0xd3, 0xe5, 0x58, + 0xb3, 0xa8, 0xab, 0xa7, 0x97, 0xba, 0xf1, 0x48, 0xf0, 0x42, 0xfd, 0xd9, 0xfe, 0x84, 0x17, 0x8e, + 0x6e, 0xd3, 0xd2, 0x5a, 0x8c, 0x4f, 0xd2, 0x6d, 0x18, 0x7c, 0x07, 0x00, 0x00, 0xff, 0xff, 0x7f, + 0xc1, 0xd6, 0x12, 0x7c, 0x02, 0x00, 0x00, +} + +func (m *NodeCapabilities) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NodeCapabilities) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NodeCapabilities) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.StorageClasses) > 0 { + for iNdEx := len(m.StorageClasses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.StorageClasses[iNdEx]) + copy(dAtA[i:], m.StorageClasses[iNdEx]) + i = encodeVarintNode(dAtA, i, uint64(len(m.StorageClasses[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil } func (m *Node) Marshal() (dAtA []byte, err error) { @@ -147,17 +217,7 @@ func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size, err := m.EphemeralStorage.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintNode(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size, err := m.GPU.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Capabilities.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -167,7 +227,7 @@ func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a { - size, err := m.Memory.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Resources.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -176,16 +236,13 @@ func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - { - size, err := m.CPU.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintNode(dAtA, i, uint64(size)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintNode(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -200,19 +257,34 @@ func encodeVarintNode(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *NodeCapabilities) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.StorageClasses) > 0 { + for _, s := range m.StorageClasses { + l = len(s) + n += 1 + l + sovNode(uint64(l)) + } + } + return n +} + func (m *Node) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.CPU.Size() - n += 1 + l + sovNode(uint64(l)) - l = m.Memory.Size() - n += 1 + l + sovNode(uint64(l)) - l = m.GPU.Size() + l = len(m.Name) + if l > 0 { + n += 1 + l + sovNode(uint64(l)) + } + l = m.Resources.Size() n += 1 + l + sovNode(uint64(l)) - l = m.EphemeralStorage.Size() + l = m.Capabilities.Size() n += 1 + l + sovNode(uint64(l)) return n } @@ -223,7 +295,7 @@ func sovNode(x uint64) (n int) { func sozNode(x uint64) (n int) { return sovNode(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Node) Unmarshal(dAtA []byte) error { +func (m *NodeCapabilities) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -246,17 +318,17 @@ func (m *Node) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Node: wiretype end group for non-group") + return fmt.Errorf("proto: NodeCapabilities: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Node: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: NodeCapabilities: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CPU", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StorageClasses", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowNode @@ -266,30 +338,79 @@ func (m *Node) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthNode } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthNode } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.CPU.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.StorageClasses = append(m.StorageClasses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipNode(dAtA[iNdEx:]) + if err != nil { return err } - iNdEx = postIndex - case 2: + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNode + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Node) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNode + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Node: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Node: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Memory", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowNode @@ -299,28 +420,27 @@ func (m *Node) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthNode } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthNode } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Memory.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GPU", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Resources", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -347,13 +467,13 @@ func (m *Node) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.GPU.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Resources.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EphemeralStorage", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Capabilities", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -380,7 +500,7 @@ func (m *Node) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.EphemeralStorage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Capabilities.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/go/inventory/v1/resourcepair.go b/go/inventory/v1/resourcepair.go index f01980e9..712c6f88 100644 --- a/go/inventory/v1/resourcepair.go +++ b/go/inventory/v1/resourcepair.go @@ -1,5 +1,34 @@ package v1 +import ( + "math" + + sdk "github.com/cosmos/cosmos-sdk/types" + "k8s.io/apimachinery/pkg/api/resource" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +func NewResourcePair(allocatable, allocated int64, format resource.Format) ResourcePair { + res := ResourcePair{ + Allocatable: resource.NewQuantity(allocatable, format), + Allocated: resource.NewQuantity(allocated, format), + Attributes: nil, + } + + return res +} + +func NewResourcePairMilli(allocatable, allocated int64, format resource.Format) ResourcePair { + res := ResourcePair{ + Allocatable: resource.NewMilliQuantity(allocatable, format), + Allocated: resource.NewMilliQuantity(allocated, format), + Attributes: nil, + } + + return res +} + func (m *ResourcePair) Equal(rhs ResourcePair) bool { if m == nil { return false @@ -28,3 +57,61 @@ func (m *ResourcePair) Dup() ResourcePair { return res } + +func (m *ResourcePair) SubMilliNLZ(val types.ResourceValue) bool { + avail := m.Available() + + res := sdk.NewInt(avail.MilliValue()) + res = res.Sub(val.Val) + if res.IsNegative() { + return false + } + + allocated := m.Allocated.DeepCopy() + allocated.Add(*resource.NewMilliQuantity(int64(val.Value()), resource.DecimalSI)) + + allocatable := m.Allocatable.DeepCopy() + + *m = ResourcePair{ + Allocatable: &allocatable, + Allocated: &allocated, + } + + return true +} + +func (m *ResourcePair) SubNLZ(val types.ResourceValue) bool { + avail := m.Available() + + res := sdk.NewInt(avail.Value()) + res = res.Sub(val.Val) + + if res.IsNegative() { + return false + } + + allocated := m.Allocated.DeepCopy() + allocated.Add(*resource.NewQuantity(int64(val.Value()), resource.DecimalSI)) + + allocatable := m.Allocatable.DeepCopy() + + *m = ResourcePair{ + Allocatable: &allocatable, + Allocated: &allocated, + } + + return true +} + +func (m *ResourcePair) Available() *resource.Quantity { + result := m.Allocatable.DeepCopy() + + if result.Value() == -1 { + result = *resource.NewQuantity(math.MaxInt64, resource.DecimalSI) + } + + // Modifies the value in place + (&result).Sub(*m.Allocated) + + return &result +} diff --git a/go/inventory/v1/resourcepair.pb.go b/go/inventory/v1/resourcepair.pb.go index 93e241bd..34540b76 100644 --- a/go/inventory/v1/resourcepair.pb.go +++ b/go/inventory/v1/resourcepair.pb.go @@ -96,34 +96,34 @@ func init() { } var fileDescriptor_995cee7bf7b692e7 = []byte{ - // 425 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0x3d, 0x8f, 0xd3, 0x30, - 0x18, 0x8e, 0x29, 0x42, 0xba, 0x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f, 0xb5, 0x8d, 0x3e, 0xed, 0x6c, 0x63, 0xbb, 0xb3, 0x8d, 0x6f, 0x3b, 0xdb, 0x78, - 0xbb, 0xf8, 0x3f, 0xc3, 0xf1, 0x41, 0x7b, 0x0f, 0xda, 0x03, 0xba, 0xfe, 0x1d, 0x00, 0x00, 0xff, - 0xff, 0x97, 0xe9, 0xcc, 0xe0, 0xed, 0x02, 0x00, 0x00, + // 428 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3f, 0x8f, 0xd3, 0x30, + 0x18, 0xc6, 0x63, 0x8a, 0x90, 0x2e, 0x65, 0x40, 0xd1, 0x0d, 0xd5, 0x21, 0xe2, 0x53, 0x24, 0xa4, + 0x1b, 0xc0, 0x56, 0x7b, 0x0c, 0xa7, 0xdb, 0x5a, 0x56, 0x06, 0xc8, 0xc8, 0xe6, 0x24, 0xaf, 0x52, + 0x2b, 0x7f, 0x1c, 0x39, 0x4e, 0x50, 0x36, 0xc4, 0xc8, 0xc4, 0x47, 0x60, 0xe6, 0x63, 0x30, 0x75, + 0xec, 0xc8, 0x64, 0x50, 0xba, 0x40, 0xc7, 0x7e, 0x02, 0x94, 0x3f, 0x6d, 0x82, 0x60, 0x40, 0xb7, + 0xc5, 0xef, 0xfb, 0xf8, 0xf7, 0x3c, 0xca, 0x63, 0xf3, 0x29, 0x8b, 0x58, 0xbe, 0xa6, 0x3c, 0x2d, + 0x21, 0x55, 0x42, 0x56, 0xb4, 0x9c, 0x53, 0x09, 0xb9, 0x28, 0xa4, 0x0f, 0x19, 0xe3, 0x92, 0x64, + 0x52, 0x28, 0x61, 0x59, 0xad, 0x8c, 0x9c, 0x64, 0xa4, 0x9c, 0x5f, 0x9c, 0x87, 0x22, 0x14, 0xed, + 0x9a, 0x36, 0x5f, 0x9d, 0xf2, 0xc2, 0xe9, 0x80, 0x1e, 0xcb, 0x81, 0x96, 0x73, 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x84, 0x2b, 0x48, 0x32, 0x55, 0x1d, 0x34, 0x7e, 0xdc, 0x3b, 0xfe, 0x63, 0xeb, + 0x7c, 0xf9, 0x8e, 0x5f, 0x86, 0x5c, 0xad, 0x0b, 0x8f, 0xf8, 0x22, 0xa1, 0xad, 0xd1, 0xf3, 0x14, + 0xd4, 0x3b, 0x21, 0xa3, 0xfe, 0xd4, 0x34, 0x1a, 0x0a, 0x9a, 0x8a, 0x00, 0xa8, 0xaa, 0x32, 0xc8, + 0xe9, 0x5f, 0x19, 0x72, 0x77, 0x94, 0xfa, 0xf6, 0xfe, 0xcf, 0xcf, 0xd8, 0x58, 0xbd, 0xda, 0xd4, + 0x36, 0xda, 0xd6, 0x36, 0xfa, 0x51, 0xdb, 0xe8, 0xd3, 0xce, 0x36, 0xb6, 0x3b, 0xdb, 0xf8, 0xb6, + 0xb3, 0x8d, 0xb7, 0x8b, 0xff, 0x33, 0x1c, 0x3f, 0x68, 0xef, 0x41, 0xfb, 0x80, 0xae, 0x7f, 0x07, + 0x00, 0x00, 0xff, 0xff, 0xf4, 0xbc, 0x8c, 0x91, 0xed, 0x02, 0x00, 0x00, } func (m *ResourcePair) Marshal() (dAtA []byte, err error) { diff --git a/go/inventory/v1/resources.go b/go/inventory/v1/resources.go new file mode 100644 index 00000000..f3a6487e --- /dev/null +++ b/go/inventory/v1/resources.go @@ -0,0 +1,14 @@ +package v1 + +func (s *NodeResources) Dup() NodeResources { + res := NodeResources{ + CPU: s.CPU.Dup(), + GPU: s.GPU.Dup(), + Memory: s.Memory.Dup(), + EphemeralStorage: s.EphemeralStorage.Dup(), + VolumesAttached: s.VolumesAttached.Dup(), + VolumesMounted: s.VolumesMounted.Dup(), + } + + return res +} diff --git a/go/inventory/v1/resources.pb.go b/go/inventory/v1/resources.pb.go new file mode 100644 index 00000000..3f290fb9 --- /dev/null +++ b/go/inventory/v1/resources.pb.go @@ -0,0 +1,606 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/inventory/v1/resources.proto + +package v1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// NodeResources reports node inventory details +type NodeResources struct { + CPU CPU `protobuf:"bytes,1,opt,name=cpu,proto3" json:"cpu" yaml:"cpu"` + Memory Memory `protobuf:"bytes,2,opt,name=memory,proto3" json:"memory" yaml:"memory"` + GPU GPU `protobuf:"bytes,3,opt,name=gpu,proto3,castrepeated=GPUs" json:"gpu" yaml:"gpu"` + EphemeralStorage ResourcePair `protobuf:"bytes,4,opt,name=ephemeral_storage,json=ephemeralStorage,proto3" json:"ephemeral_storage" yaml:"ephemeral_storage"` + VolumesAttached ResourcePair `protobuf:"bytes,5,opt,name=volumes_attached,json=volumesAttached,proto3" json:"volumes_attached" yaml:"volumes_attached"` + VolumesMounted ResourcePair `protobuf:"bytes,6,opt,name=volumes_mounted,json=volumesMounted,proto3" json:"volumes_mounted" yaml:"volumes_mounted"` +} + +func (m *NodeResources) Reset() { *m = NodeResources{} } +func (m *NodeResources) String() string { return proto.CompactTextString(m) } +func (*NodeResources) ProtoMessage() {} +func (*NodeResources) Descriptor() ([]byte, []int) { + return fileDescriptor_f20a722bd8ee01b5, []int{0} +} +func (m *NodeResources) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NodeResources) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NodeResources.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *NodeResources) XXX_Merge(src proto.Message) { + xxx_messageInfo_NodeResources.Merge(m, src) +} +func (m *NodeResources) XXX_Size() int { + return m.Size() +} +func (m *NodeResources) XXX_DiscardUnknown() { + xxx_messageInfo_NodeResources.DiscardUnknown(m) +} + +var xxx_messageInfo_NodeResources proto.InternalMessageInfo + +func (m *NodeResources) GetCPU() CPU { + if m != nil { + return m.CPU + } + return CPU{} +} + +func (m *NodeResources) GetMemory() Memory { + if m != nil { + return m.Memory + } + return Memory{} +} + +func (m *NodeResources) GetGPU() GPU { + if m != nil { + return m.GPU + } + return GPU{} +} + +func (m *NodeResources) GetEphemeralStorage() ResourcePair { + if m != nil { + return m.EphemeralStorage + } + return ResourcePair{} +} + +func (m *NodeResources) GetVolumesAttached() ResourcePair { + if m != nil { + return m.VolumesAttached + } + return ResourcePair{} +} + +func (m *NodeResources) GetVolumesMounted() ResourcePair { + if m != nil { + return m.VolumesMounted + } + return ResourcePair{} +} + +func init() { + proto.RegisterType((*NodeResources)(nil), "akash.inventory.v1.NodeResources") +} + +func init() { + proto.RegisterFile("akash/inventory/v1/resources.proto", fileDescriptor_f20a722bd8ee01b5) +} + +var fileDescriptor_f20a722bd8ee01b5 = []byte{ + // 488 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0x87, 0x37, 0x6e, 0xbb, 0x87, 0x48, 0xdb, 0x35, 0x88, 0x0d, 0x8b, 0x64, 0x96, 0x01, 0xa1, + 0x1e, 0x4c, 0x68, 0xbd, 0x79, 0x33, 0x8b, 0x2e, 0xa2, 0x95, 0x90, 0xb2, 0x1e, 0x04, 0x59, 0xa6, + 0xd9, 0x61, 0x36, 0x74, 0xb3, 0x33, 0x4c, 0x32, 0x91, 0x7e, 0x09, 0x11, 0xbc, 0xf8, 0x19, 0xfc, + 0x24, 0x3d, 0x16, 0x4f, 0x9e, 0x46, 0xd9, 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x5d, 0x2f, 0x9d, 0xd6, 0xaf, 0xa5, 0xd3, 0xfa, 0x78, 0x42, 0xe2, 0x6c, 0x2a, 0xce, + 0xdd, 0x88, 0x26, 0x5e, 0xad, 0xf6, 0x6c, 0x8e, 0xb3, 0xcf, 0x94, 0x5f, 0xe8, 0x0a, 0xb1, 0xd8, + 0x23, 0x74, 0xe5, 0xd5, 0x9c, 0x77, 0xea, 0x97, 0xf2, 0xfc, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x7c, 0x50, 0xd8, 0xc7, 0xfd, 0x03, 0x00, 0x00, +} + +func (m *NodeResources) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NodeResources) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NodeResources) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.VolumesMounted.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size, err := m.VolumesAttached.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size, err := m.EphemeralStorage.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size, err := m.GPU.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.Memory.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.CPU.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintResources(dAtA []byte, offset int, v uint64) int { + offset -= sovResources(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *NodeResources) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.CPU.Size() + n += 1 + l + sovResources(uint64(l)) + l = m.Memory.Size() + n += 1 + l + sovResources(uint64(l)) + l = m.GPU.Size() + n += 1 + l + sovResources(uint64(l)) + l = m.EphemeralStorage.Size() + n += 1 + l + sovResources(uint64(l)) + l = m.VolumesAttached.Size() + n += 1 + l + sovResources(uint64(l)) + l = m.VolumesMounted.Size() + n += 1 + l + sovResources(uint64(l)) + return n +} + +func sovResources(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozResources(x uint64) (n int) { + return sovResources(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *NodeResources) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NodeResources: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NodeResources: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CPU", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CPU.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Memory", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Memory.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GPU", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GPU.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EphemeralStorage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.EphemeralStorage.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VolumesAttached", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VolumesAttached.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VolumesMounted", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VolumesMounted.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipResources(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthResources + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipResources(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowResources + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowResources + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowResources + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthResources + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupResources + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthResources + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthResources = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowResources = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupResources = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/inventory/v1/service.pb.go b/go/inventory/v1/service.pb.go index 838d37d7..fc05ccd8 100644 --- a/go/inventory/v1/service.pb.go +++ b/go/inventory/v1/service.pb.go @@ -8,6 +8,7 @@ import ( fmt "fmt" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -71,22 +72,27 @@ func init() { func init() { proto.RegisterFile("akash/inventory/v1/service.proto", fileDescriptor_19b1fad552cee5dc) } var fileDescriptor_19b1fad552cee5dc = []byte{ - // 235 bytes of a gzipped FileDescriptorProto + // 312 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xcc, 0x4e, 0x2c, 0xce, 0xd0, 0xcf, 0xcc, 0x2b, 0x4b, 0xcd, 0x2b, 0xc9, 0x2f, 0xaa, 0xd4, 0x2f, 0x33, 0xd4, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x02, 0xab, - 0xd0, 0x83, 0xab, 0xd0, 0x2b, 0x33, 0x94, 0x92, 0xc5, 0xa2, 0x2b, 0x2f, 0x3f, 0x05, 0xaa, 0x45, - 0x0a, 0x9b, 0xa1, 0xc9, 0x39, 0xa5, 0xc5, 0x25, 0xa9, 0x45, 0x10, 0x15, 0x4a, 0xbc, 0x5c, 0xdc, - 0x61, 0xf9, 0x99, 0x29, 0x7e, 0xf9, 0x01, 0x89, 0x45, 0x89, 0xb9, 0x46, 0xc1, 0x5c, 0xec, 0x7e, - 0xf9, 0x29, 0xa9, 0x41, 0x01, 0xce, 0x42, 0x1e, 0x5c, 0x9c, 0x81, 0xa5, 0xa9, 0x45, 0x95, 0x20, - 0xbe, 0x90, 0xbc, 0x1e, 0xa6, 0xe5, 0x7a, 0x48, 0x1a, 0xa5, 0x24, 0xb0, 0x29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ff, + 0xf3, 0x65, 0xa5, 0x58, 0x76, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -101,10 +107,14 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type NodeRPCClient interface { - // QueryNode defines a method to query and stream hardware state of the node + // QueryNode defines a method to query hardware state of the node // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME - QueryNode(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (NodeRPC_QueryNodeClient, error) + QueryNode(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (*Node, error) + // StreamNode defines a method to stream hardware state of the node + // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + StreamNode(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (NodeRPC_StreamNodeClient, error) } type nodeRPCClient struct { @@ -115,12 +125,21 @@ func NewNodeRPCClient(cc grpc1.ClientConn) NodeRPCClient { return &nodeRPCClient{cc} } -func (c *nodeRPCClient) QueryNode(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (NodeRPC_QueryNodeClient, error) { - stream, err := c.cc.NewStream(ctx, &_NodeRPC_serviceDesc.Streams[0], "/akash.inventory.v1.NodeRPC/QueryNode", opts...) +func (c *nodeRPCClient) QueryNode(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (*Node, error) { + out := new(Node) + err := c.cc.Invoke(ctx, "/akash.inventory.v1.NodeRPC/QueryNode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *nodeRPCClient) StreamNode(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (NodeRPC_StreamNodeClient, error) { + stream, err := c.cc.NewStream(ctx, &_NodeRPC_serviceDesc.Streams[0], "/akash.inventory.v1.NodeRPC/StreamNode", opts...) if err != nil { return nil, err } - x := &nodeRPCQueryNodeClient{stream} + x := &nodeRPCStreamNodeClient{stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -130,16 +149,16 @@ func (c *nodeRPCClient) QueryNode(ctx context.Context, in *VoidNoParam, opts ... return x, nil } -type NodeRPC_QueryNodeClient interface { +type NodeRPC_StreamNodeClient interface { Recv() (*Node, error) grpc.ClientStream } -type nodeRPCQueryNodeClient struct { +type nodeRPCStreamNodeClient struct { grpc.ClientStream } -func (x *nodeRPCQueryNodeClient) Recv() (*Node, error) { +func (x *nodeRPCStreamNodeClient) Recv() (*Node, error) { m := new(Node) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err @@ -149,53 +168,83 @@ func (x *nodeRPCQueryNodeClient) Recv() (*Node, error) { // NodeRPCServer is the server API for NodeRPC service. type NodeRPCServer interface { - // QueryNode defines a method to query and stream hardware state of the node + // QueryNode defines a method to query hardware state of the node // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME - QueryNode(*VoidNoParam, NodeRPC_QueryNodeServer) error + QueryNode(context.Context, *VoidNoParam) (*Node, error) + // StreamNode defines a method to stream hardware state of the node + // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + StreamNode(*VoidNoParam, NodeRPC_StreamNodeServer) error } // UnimplementedNodeRPCServer can be embedded to have forward compatible implementations. type UnimplementedNodeRPCServer struct { } -func (*UnimplementedNodeRPCServer) QueryNode(req *VoidNoParam, srv NodeRPC_QueryNodeServer) error { - return status.Errorf(codes.Unimplemented, "method QueryNode not implemented") +func (*UnimplementedNodeRPCServer) QueryNode(ctx context.Context, req *VoidNoParam) (*Node, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryNode not implemented") +} +func (*UnimplementedNodeRPCServer) StreamNode(req *VoidNoParam, srv NodeRPC_StreamNodeServer) error { + return status.Errorf(codes.Unimplemented, "method StreamNode not implemented") } func RegisterNodeRPCServer(s grpc1.Server, srv NodeRPCServer) { s.RegisterService(&_NodeRPC_serviceDesc, srv) } -func _NodeRPC_QueryNode_Handler(srv interface{}, stream grpc.ServerStream) error { +func _NodeRPC_QueryNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VoidNoParam) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NodeRPCServer).QueryNode(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/akash.inventory.v1.NodeRPC/QueryNode", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NodeRPCServer).QueryNode(ctx, req.(*VoidNoParam)) + } + return interceptor(ctx, in, info, handler) +} + +func _NodeRPC_StreamNode_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(VoidNoParam) if err := stream.RecvMsg(m); err != nil { return err } - return srv.(NodeRPCServer).QueryNode(m, &nodeRPCQueryNodeServer{stream}) + return srv.(NodeRPCServer).StreamNode(m, &nodeRPCStreamNodeServer{stream}) } -type NodeRPC_QueryNodeServer interface { +type NodeRPC_StreamNodeServer interface { Send(*Node) error grpc.ServerStream } -type nodeRPCQueryNodeServer struct { +type nodeRPCStreamNodeServer struct { grpc.ServerStream } -func (x *nodeRPCQueryNodeServer) Send(m *Node) error { +func (x *nodeRPCStreamNodeServer) Send(m *Node) error { return x.ServerStream.SendMsg(m) } var _NodeRPC_serviceDesc = grpc.ServiceDesc{ ServiceName: "akash.inventory.v1.NodeRPC", HandlerType: (*NodeRPCServer)(nil), - Methods: []grpc.MethodDesc{}, + Methods: []grpc.MethodDesc{ + { + MethodName: "QueryNode", + Handler: _NodeRPC_QueryNode_Handler, + }, + }, Streams: []grpc.StreamDesc{ { - StreamName: "QueryNode", - Handler: _NodeRPC_QueryNode_Handler, + StreamName: "StreamNode", + Handler: _NodeRPC_StreamNode_Handler, ServerStreams: true, }, }, @@ -206,10 +255,14 @@ var _NodeRPC_serviceDesc = grpc.ServiceDesc{ // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type ClusterRPCClient interface { - // QueryNode defines a method to query and stream hardware state of the cluster + // QueryCluster defines a method to query hardware state of the cluster // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME - QueryCluster(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (ClusterRPC_QueryClusterClient, error) + QueryCluster(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (*Cluster, error) + // StreamCluster defines a method to stream hardware state of the cluster + // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + StreamCluster(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (ClusterRPC_StreamClusterClient, error) } type clusterRPCClient struct { @@ -220,12 +273,21 @@ func NewClusterRPCClient(cc grpc1.ClientConn) ClusterRPCClient { return &clusterRPCClient{cc} } -func (c *clusterRPCClient) QueryCluster(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (ClusterRPC_QueryClusterClient, error) { - stream, err := c.cc.NewStream(ctx, &_ClusterRPC_serviceDesc.Streams[0], "/akash.inventory.v1.ClusterRPC/QueryCluster", opts...) +func (c *clusterRPCClient) QueryCluster(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (*Cluster, error) { + out := new(Cluster) + err := c.cc.Invoke(ctx, "/akash.inventory.v1.ClusterRPC/QueryCluster", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *clusterRPCClient) StreamCluster(ctx context.Context, in *VoidNoParam, opts ...grpc.CallOption) (ClusterRPC_StreamClusterClient, error) { + stream, err := c.cc.NewStream(ctx, &_ClusterRPC_serviceDesc.Streams[0], "/akash.inventory.v1.ClusterRPC/StreamCluster", opts...) if err != nil { return nil, err } - x := &clusterRPCQueryClusterClient{stream} + x := &clusterRPCStreamClusterClient{stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -235,16 +297,16 @@ func (c *clusterRPCClient) QueryCluster(ctx context.Context, in *VoidNoParam, op return x, nil } -type ClusterRPC_QueryClusterClient interface { +type ClusterRPC_StreamClusterClient interface { Recv() (*Cluster, error) grpc.ClientStream } -type clusterRPCQueryClusterClient struct { +type clusterRPCStreamClusterClient struct { grpc.ClientStream } -func (x *clusterRPCQueryClusterClient) Recv() (*Cluster, error) { +func (x *clusterRPCStreamClusterClient) Recv() (*Cluster, error) { m := new(Cluster) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err @@ -254,53 +316,83 @@ func (x *clusterRPCQueryClusterClient) Recv() (*Cluster, error) { // ClusterRPCServer is the server API for ClusterRPC service. type ClusterRPCServer interface { - // QueryNode defines a method to query and stream hardware state of the cluster + // QueryCluster defines a method to query hardware state of the cluster // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME - QueryCluster(*VoidNoParam, ClusterRPC_QueryClusterServer) error + QueryCluster(context.Context, *VoidNoParam) (*Cluster, error) + // StreamCluster defines a method to stream hardware state of the cluster + // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + StreamCluster(*VoidNoParam, ClusterRPC_StreamClusterServer) error } // UnimplementedClusterRPCServer can be embedded to have forward compatible implementations. type UnimplementedClusterRPCServer struct { } -func (*UnimplementedClusterRPCServer) QueryCluster(req *VoidNoParam, srv ClusterRPC_QueryClusterServer) error { - return status.Errorf(codes.Unimplemented, "method QueryCluster not implemented") +func (*UnimplementedClusterRPCServer) QueryCluster(ctx context.Context, req *VoidNoParam) (*Cluster, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryCluster not implemented") +} +func (*UnimplementedClusterRPCServer) StreamCluster(req *VoidNoParam, srv ClusterRPC_StreamClusterServer) error { + return status.Errorf(codes.Unimplemented, "method StreamCluster not implemented") } func RegisterClusterRPCServer(s grpc1.Server, srv ClusterRPCServer) { s.RegisterService(&_ClusterRPC_serviceDesc, srv) } -func _ClusterRPC_QueryCluster_Handler(srv interface{}, stream grpc.ServerStream) error { +func _ClusterRPC_QueryCluster_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VoidNoParam) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ClusterRPCServer).QueryCluster(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/akash.inventory.v1.ClusterRPC/QueryCluster", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ClusterRPCServer).QueryCluster(ctx, req.(*VoidNoParam)) + } + return interceptor(ctx, in, info, handler) +} + +func _ClusterRPC_StreamCluster_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(VoidNoParam) if err := stream.RecvMsg(m); err != nil { return err } - return srv.(ClusterRPCServer).QueryCluster(m, &clusterRPCQueryClusterServer{stream}) + return srv.(ClusterRPCServer).StreamCluster(m, &clusterRPCStreamClusterServer{stream}) } -type ClusterRPC_QueryClusterServer interface { +type ClusterRPC_StreamClusterServer interface { Send(*Cluster) error grpc.ServerStream } -type clusterRPCQueryClusterServer struct { +type clusterRPCStreamClusterServer struct { grpc.ServerStream } -func (x *clusterRPCQueryClusterServer) Send(m *Cluster) error { +func (x *clusterRPCStreamClusterServer) Send(m *Cluster) error { return x.ServerStream.SendMsg(m) } var _ClusterRPC_serviceDesc = grpc.ServiceDesc{ ServiceName: "akash.inventory.v1.ClusterRPC", HandlerType: (*ClusterRPCServer)(nil), - Methods: []grpc.MethodDesc{}, + Methods: []grpc.MethodDesc{ + { + MethodName: "QueryCluster", + Handler: _ClusterRPC_QueryCluster_Handler, + }, + }, Streams: []grpc.StreamDesc{ { - StreamName: "QueryCluster", - Handler: _ClusterRPC_QueryCluster_Handler, + StreamName: "StreamCluster", + Handler: _ClusterRPC_StreamCluster_Handler, ServerStreams: true, }, }, diff --git a/go/inventory/v1/service.pb.gw.go b/go/inventory/v1/service.pb.gw.go new file mode 100644 index 00000000..b0c9685c --- /dev/null +++ b/go/inventory/v1/service.pb.gw.go @@ -0,0 +1,272 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: akash/inventory/v1/service.proto + +/* +Package v1 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package v1 + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_NodeRPC_QueryNode_0(ctx context.Context, marshaler runtime.Marshaler, client NodeRPCClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq VoidNoParam + var metadata runtime.ServerMetadata + + msg, err := client.QueryNode(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_NodeRPC_QueryNode_0(ctx context.Context, marshaler runtime.Marshaler, server NodeRPCServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq VoidNoParam + var metadata runtime.ServerMetadata + + msg, err := server.QueryNode(ctx, &protoReq) + return msg, metadata, err + +} + +func request_ClusterRPC_QueryCluster_0(ctx context.Context, marshaler runtime.Marshaler, client ClusterRPCClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq VoidNoParam + var metadata runtime.ServerMetadata + + msg, err := client.QueryCluster(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_ClusterRPC_QueryCluster_0(ctx context.Context, marshaler runtime.Marshaler, server ClusterRPCServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq VoidNoParam + var metadata runtime.ServerMetadata + + msg, err := server.QueryCluster(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterNodeRPCHandlerServer registers the http handlers for service NodeRPC to "mux". +// UnaryRPC :call NodeRPCServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterNodeRPCHandlerFromEndpoint instead. +func RegisterNodeRPCHandlerServer(ctx context.Context, mux *runtime.ServeMux, server NodeRPCServer) error { + + mux.Handle("GET", pattern_NodeRPC_QueryNode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_NodeRPC_QueryNode_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NodeRPC_QueryNode_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterClusterRPCHandlerServer registers the http handlers for service ClusterRPC to "mux". +// UnaryRPC :call ClusterRPCServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterClusterRPCHandlerFromEndpoint instead. +func RegisterClusterRPCHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ClusterRPCServer) error { + + mux.Handle("GET", pattern_ClusterRPC_QueryCluster_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ClusterRPC_QueryCluster_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ClusterRPC_QueryCluster_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterNodeRPCHandlerFromEndpoint is same as RegisterNodeRPCHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterNodeRPCHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterNodeRPCHandler(ctx, mux, conn) +} + +// RegisterNodeRPCHandler registers the http handlers for service NodeRPC to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterNodeRPCHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterNodeRPCHandlerClient(ctx, mux, NewNodeRPCClient(conn)) +} + +// RegisterNodeRPCHandlerClient registers the http handlers for service NodeRPC +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "NodeRPCClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "NodeRPCClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "NodeRPCClient" to call the correct interceptors. +func RegisterNodeRPCHandlerClient(ctx context.Context, mux *runtime.ServeMux, client NodeRPCClient) error { + + mux.Handle("GET", pattern_NodeRPC_QueryNode_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_NodeRPC_QueryNode_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NodeRPC_QueryNode_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_NodeRPC_QueryNode_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "node"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_NodeRPC_QueryNode_0 = runtime.ForwardResponseMessage +) + +// RegisterClusterRPCHandlerFromEndpoint is same as RegisterClusterRPCHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterClusterRPCHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterClusterRPCHandler(ctx, mux, conn) +} + +// RegisterClusterRPCHandler registers the http handlers for service ClusterRPC to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterClusterRPCHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterClusterRPCHandlerClient(ctx, mux, NewClusterRPCClient(conn)) +} + +// RegisterClusterRPCHandlerClient registers the http handlers for service ClusterRPC +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ClusterRPCClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ClusterRPCClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "ClusterRPCClient" to call the correct interceptors. +func RegisterClusterRPCHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ClusterRPCClient) error { + + mux.Handle("GET", pattern_ClusterRPC_QueryCluster_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ClusterRPC_QueryCluster_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ClusterRPC_QueryCluster_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_ClusterRPC_QueryCluster_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "inventory"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_ClusterRPC_QueryCluster_0 = runtime.ForwardResponseMessage +) diff --git a/go/node/client/v1beta2/client.go b/go/node/client/v1beta2/client.go index aef6364d..9bc8d6ee 100644 --- a/go/node/client/v1beta2/client.go +++ b/go/node/client/v1beta2/client.go @@ -25,6 +25,7 @@ type QueryClient interface { ptypes.QueryClient atypes.QueryClient ctypes.QueryClient + // authtypes.QueryClient ClientContext() sdkclient.Context } diff --git a/go/node/client/v1beta2/query.go b/go/node/client/v1beta2/query.go index 764f59a5..a392bb6d 100644 --- a/go/node/client/v1beta2/query.go +++ b/go/node/client/v1beta2/query.go @@ -6,6 +6,18 @@ import ( "google.golang.org/grpc" sdkclient "github.com/cosmos/cosmos-sdk/client" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + authztypes "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidtypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + proptypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" atypes "github.com/akash-network/akash-api/go/node/audit/v1beta3" ctypes "github.com/akash-network/akash-api/go/node/cert/v1beta3" @@ -14,13 +26,29 @@ import ( ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3" ) +type sdkClients struct { + auth authtypes.QueryClient + bank banktypes.QueryClient + authz authztypes.QueryClient + distr distrtypes.QueryClient + evid evidtypes.QueryClient + feegrant feegranttypes.QueryClient + gov govtypes.QueryClient + mint minttypes.QueryClient + params proptypes.QueryClient + slashing slashingtypes.QueryClient + staking stakingtypes.QueryClient + upgrade upgradetypes.QueryClient +} + type queryClient struct { dclient dtypes.QueryClient mclient mtypes.QueryClient pclient ptypes.QueryClient aclient atypes.QueryClient cclient ctypes.QueryClient - cctx sdkclient.Context + // sdk sdkClients + cctx sdkclient.Context } // NewQueryClient creates new query client instance @@ -35,7 +63,23 @@ func newQueryClient(cctx sdkclient.Context) *queryClient { pclient: ptypes.NewQueryClient(cctx), aclient: atypes.NewQueryClient(cctx), cclient: ctypes.NewQueryClient(cctx), - cctx: cctx, + + // sdk: sdkClients{ + // auth: authtypes.NewQueryClient(cctx), + // bank: banktypes.NewQueryClient(cctx), + // authz: authztypes.NewQueryClient(cctx), + // distr: distrtypes.NewQueryClient(cctx), + // evid: evidtypes.NewQueryClient(cctx), + // feegrant: feegranttypes.NewQueryClient(cctx), + // gov: govtypes.NewQueryClient(cctx), + // mint: minttypes.NewQueryClient(cctx), + // params: proptypes.NewQueryClient(cctx), + // slashing: slashingtypes.NewQueryClient(cctx), + // staking: stakingtypes.NewQueryClient(cctx), + // upgrade: upgradetypes.NewQueryClient(cctx), + // }, + + cctx: cctx, } } @@ -158,3 +202,32 @@ func (c *queryClient) Certificates(ctx context.Context, in *ctypes.QueryCertific } return c.cclient.Certificates(ctx, in, opts...) } + +// func (c *queryClient) Accounts(ctx context.Context, in *authtypes.QueryAccountsRequest, opts ...grpc.CallOption) (*authtypes.QueryAccountsResponse, error) { +// if c.cclient == nil { +// return &authtypes.QueryAccountsResponse{}, ErrClientNotFound +// } +// +// return c.sdk.auth.Accounts(ctx, in, opts...) +// } +// +// func (c *queryClient) Account(ctx context.Context, in *authtypes.QueryAccountRequest, opts ...grpc.CallOption) (*authtypes.QueryAccountResponse, error) { +// if c.cclient == nil { +// return &authtypes.QueryAccountResponse{}, ErrClientNotFound +// } +// +// return c.sdk.auth.Account(ctx, in, opts...) +// } +// +// func (c *queryClient) Params(ctx context.Context, in *authtypes.QueryParamsRequest, opts ...grpc.CallOption) (*authtypes.QueryParamsResponse, error) { +// if c.cclient == nil { +// return &authtypes.QueryParamsResponse{}, ErrClientNotFound +// } +// +// return c.sdk.auth.Accounts(ctx, in, opts...) +// } +// +// func (c *queryClient) ModuleAccountByName(ctx context.Context, in *authtypes.QueryModuleAccountByNameRequest, opts ...grpc.CallOption) (*authtypes.QueryModuleAccountByNameResponse, error) { +// // TODO implement me +// panic("implement me") +// } diff --git a/go/util/units/units.go b/go/util/units/units.go new file mode 100644 index 00000000..e74ab695 --- /dev/null +++ b/go/util/units/units.go @@ -0,0 +1,149 @@ +package units + +import ( + "fmt" + "math" + "math/big" + "regexp" + "strings" + + "gopkg.in/yaml.v3" + + "github.com/akash-network/akash-api/go/node/types/unit" +) + +type ByteQuantity uint64 +type MemoryQuantity uint64 + +var ( + ErrNegativeValue = fmt.Errorf("units: negative value not allowed") + ErrOverflow = fmt.Errorf("units: overflow") + ErrInvalidFormat = fmt.Errorf("units: invalid format") + ErrInvalidSuffix = fmt.Errorf("units: invalid suffix") +) + +var ( + regexpUnits = regexp.MustCompile(`^([-+]?(([1-9]\d*|0)?[.]\d*|[1-9]\d*))(k|[KMGTPE]i?)?$`) +) + +var ( + unitSuffixes = map[string]uint64{ + "": 0, + "k": unit.K, + "Ki": unit.Ki, + "M": unit.M, + "Mi": unit.Mi, + "G": unit.G, + "Gi": unit.Gi, + "T": unit.T, + "Ti": unit.Ti, + "P": unit.P, + "Pi": unit.Pi, + "E": unit.E, + "Ei": unit.Ei, + } +) + +func (u *ByteQuantity) UnmarshalYAML(node *yaml.Node) error { + val, err := ByteQuantityFromString(node.Value) + if err != nil { + return err + } + + *u = val + + return nil +} + +func ToStringWithSuffix(val uint64, suffix string) string { + unit, exists := unitSuffixes[suffix] + + if exists { + val /= unit + } else { + suffix = "" + } + + return fmt.Sprintf("%d%s", val, suffix) +} + +func (u *ByteQuantity) StringWithSuffix(suffix string) string { + return ToStringWithSuffix(uint64(*u), suffix) +} + +func (u *MemoryQuantity) UnmarshalYAML(node *yaml.Node) error { + val, err := MemoryQuantityFromString(node.Value) + if err != nil { + return err + } + + *u = val + + return nil +} + +func (u *MemoryQuantity) StringWithSuffix(suffix string) string { + return ToStringWithSuffix(uint64(*u), suffix) +} + +func ByteQuantityFromString(sval string) (ByteQuantity, error) { + val, err := ParseWithSuffix(sval) + if err != nil { + return 0, err + } + + return ByteQuantity(val), nil +} + +func MemoryQuantityFromString(sval string) (MemoryQuantity, error) { + if !strings.HasSuffix(sval, "i") { + return 0, ErrInvalidSuffix + } + + val, err := ParseWithSuffix(sval) + if err != nil { + return 0, err + } + + return MemoryQuantity(val), nil +} + +func ParseWithSuffix(sval string) (uint64, error) { // strings.SplitAfter() + match := regexpUnits.FindAllStringSubmatch(sval, -1) + if len(match) != 1 { + return 0, ErrInvalidFormat + } + + tokens := match[0] + if len(tokens) != 5 { + return 0, ErrInvalidFormat + } + + num := tokens[1] + suffixStr := tokens[4] + + suffix, valid := unitSuffixes[suffixStr] + + if !valid { + return 0, ErrInvalidSuffix + } + + val, _, err := new(big.Float).Parse(num, 10) + if err != nil { + return 0, ErrInvalidFormat + } + + if suffix > 0 { + units := new(big.Float).SetUint64(suffix) + val = val.Mul(val, units) + } + + res, acc := val.Uint64() + if res == 0 && acc == big.Above { + return 0, ErrNegativeValue + } else if res == math.MaxUint64 && acc == big.Below { + return 0, ErrOverflow + } + + return res, nil +} diff --git a/go/util/units/units_test.go b/go/util/units/units_test.go new file mode 100644 index 00000000..c21943cf --- /dev/null +++ b/go/util/units/units_test.go @@ -0,0 +1,68 @@ +package units + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v3" + + "github.com/akash-network/akash-api/go/node/types/unit" +) + +func TestByteQuantity(t *testing.T) { + type vtype struct { + Val ByteQuantity `yaml:"val"` + } + + tests := []struct { + text string + value uint64 + err bool + }{ + {`val: 1`, 1, false}, + {`val: -1`, 0, true}, + + {`val: 01`, 0, true}, + + {`val: -01`, 0, true}, + + {`val: "1M"`, unit.M, false}, + {`val: "-1M"`, 0, true}, + + {`val: "0.5M"`, unit.M / 2, false}, + {`val: "-0.5M"`, 0, true}, + + {`val: "00.5M"`, 0, true}, + {`val: "-00.5M"`, 0, true}, + + {`val: "3M"`, 3 * unit.M, false}, + {`val: "3G"`, 3 * unit.G, false}, + {`val: "3T"`, 3 * unit.T, false}, + {`val: "3P"`, 3 * unit.P, false}, + {`val: "3E"`, 3 * unit.E, false}, + + {`val: ""`, 0, true}, + } + + for idx, test := range tests { + t.Run(fmt.Sprintf("%d", idx), func(t *testing.T) { + buf := []byte(test.text) + obj := &vtype{} + + err := yaml.Unmarshal(buf, obj) + + if test.err { + assert.Error(t, err) + assert.Equal(t, ByteQuantity(test.value), obj.Val) + return + } + + if !assert.NoError(t, err) { + return + } + + assert.Equal(t, ByteQuantity(test.value), obj.Val) + }) + } +} diff --git a/make/mod.mk b/make/mod.mk index 1b5b42b1..a1668340 100644 --- a/make/mod.mk +++ b/make/mod.mk @@ -13,6 +13,7 @@ lint: - cosmos_proto - google - confio + - k8s.io endef .PHONY: deps-tidy @@ -28,14 +29,15 @@ modsensure: deps-tidy deps-vendor .PHONY: modvendor modvendor: export VENDOR_BUF:=$(VENDOR_BUF) -modvendor: $(MODVENDOR) modsensure +modvendor: $(MODVENDOR) $(PROTOC) modsensure @echo "vendoring non-go files..." $(MODVENDOR) -copy="**/*.proto" -include=github.com/cosmos/cosmos-sdk/proto,github.com/cosmos/cosmos-sdk/third_party/proto $(MODVENDOR) -copy="**/Makefile" -include=github.com/cosmos/gogoproto $(MODVENDOR) -copy="**/*.proto" -include=github.com/cosmos/cosmos-proto/proto $(MODVENDOR) -copy="**/swagger.yaml" -include=github.com/cosmos/cosmos-proto/client/docs/swagger-ui $(MODVENDOR) -copy="**/*.proto" -include=k8s.io/apimachinery - @echo "$${VENDOR_BUF}" > vendor/k8s.io/apimachinery/pkg/api/resource/buf.yaml + @ln -snf ../../vendor/k8s.io .cache/include/k8s.io + @echo "$${VENDOR_BUF}" > vendor/k8s.io/buf.yaml + @echo "$${VENDOR_BUF}" > .cache/include/google/buf.yaml @echo "$${VENDOR_BUF}" > vendor/github.com/cosmos/cosmos-sdk/proto/buf.yaml @echo "$${VENDOR_BUF}" > vendor/github.com/cosmos/cosmos-sdk/third_party/proto/buf.yaml - @ln -snf ../../vendor/k8s.io .cache/include/k8s.io diff --git a/proto/provider/akash/inventory/v1/gpu.proto b/proto/provider/akash/inventory/v1/gpu.proto index a314e4cf..7f35edfb 100644 --- a/proto/provider/akash/inventory/v1/gpu.proto +++ b/proto/provider/akash/inventory/v1/gpu.proto @@ -14,22 +14,29 @@ message GPUInfo { (gogoproto.jsontag) = "vendor", (gogoproto.moretags) = "yaml:\"vendor\"" ]; - string name = 2 [ + + string vendor_id = 2 [ + (gogoproto.customname) = "VendorID", + (gogoproto.jsontag) = "vendor_id", + (gogoproto.moretags) = "yaml:\"vendor_id\"" + ]; + + string name = 3 [ (gogoproto.customname) = "Name", (gogoproto.jsontag) = "name", (gogoproto.moretags) = "yaml:\"name\"" ]; - string modelid = 3 [ + string modelid = 4 [ (gogoproto.customname) = "ModelID", (gogoproto.jsontag) = "model_id", (gogoproto.moretags) = "yaml:\"model_id\"" ]; - string interface = 4 [ + string interface = 5 [ (gogoproto.customname) = "Interface", (gogoproto.jsontag) = "interface", (gogoproto.moretags) = "yaml:\"interface\"" ]; - string memory_size = 5 [ + string memory_size = 6 [ (gogoproto.customname) = "MemorySize", (gogoproto.jsontag) = "memory_size", (gogoproto.moretags) = "yaml:\"memory_size\"" diff --git a/proto/provider/akash/inventory/v1/memory.proto b/proto/provider/akash/inventory/v1/memory.proto index 02919aac..287dcf26 100644 --- a/proto/provider/akash/inventory/v1/memory.proto +++ b/proto/provider/akash/inventory/v1/memory.proto @@ -3,7 +3,6 @@ syntax = "proto3"; package akash.inventory.v1; import "gogoproto/gogo.proto"; - import "akash/inventory/v1/resourcepair.proto"; option go_package = "github.com/akash-network/akash-api/go/inventory/v1"; diff --git a/proto/provider/akash/inventory/v1/node.proto b/proto/provider/akash/inventory/v1/node.proto index 9d5c6f82..6a796560 100644 --- a/proto/provider/akash/inventory/v1/node.proto +++ b/proto/provider/akash/inventory/v1/node.proto @@ -2,41 +2,38 @@ syntax = "proto3"; package akash.inventory.v1; import "gogoproto/gogo.proto"; -import "akash/inventory/v1/cpu.proto"; -import "akash/inventory/v1/gpu.proto"; -import "akash/inventory/v1/storage.proto"; -import "akash/inventory/v1/memory.proto"; +import "akash/inventory/v1/resources.proto"; option go_package = "github.com/akash-network/akash-api/go/inventory/v1"; -// Node reports node inventory details -message Node { - CPU cpu = 1 [ - (gogoproto.nullable) = false, - (gogoproto.customname) = "CPU", - (gogoproto.jsontag) = "cpu", - (gogoproto.moretags) = "yaml:\"cpu\"" +// NodeCapabilities extended list of node capabilities +message NodeCapabilities { + repeated string storage_classes = 1 [ + (gogoproto.customname) = "StorageClasses", + (gogoproto.jsontag) = "storage_classes", + (gogoproto.moretags) = "yaml:\"storage_classes\"" ]; +} - Memory memory = 2 [ - (gogoproto.nullable) = false, - (gogoproto.customname) = "Memory", - (gogoproto.jsontag) = "memory", - (gogoproto.moretags) = "yaml:\"memory\"" +// Node reports node inventory details +message Node { + string name = 1 [ + (gogoproto.customname) = "Name", + (gogoproto.jsontag) = "name", + (gogoproto.moretags) = "yaml:\"name\"" ]; - GPU gpu = 3 [ + NodeResources resources = 2 [ (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "GPUs", - (gogoproto.customname) = "GPU", - (gogoproto.jsontag) = "gpu", - (gogoproto.moretags) = "yaml:\"gpu\"" + (gogoproto.customname) = "Resources", + (gogoproto.jsontag) = "resources", + (gogoproto.moretags) = "yaml:\"resources\"" ]; - Storage storage = 4 [ + NodeCapabilities capabilities = 3 [ (gogoproto.nullable) = false, - (gogoproto.customname) = "EphemeralStorage", - (gogoproto.jsontag) = "EphemeralStorage", - (gogoproto.moretags) = "yaml:\"EphemeralStorage\"" + (gogoproto.customname) = "Capabilities", + (gogoproto.jsontag) = "capabilities", + (gogoproto.moretags) = "yaml:\"capabilities\"" ]; } diff --git a/proto/provider/akash/inventory/v1/resourcepair.proto b/proto/provider/akash/inventory/v1/resourcepair.proto index 14ee2191..9f036d8f 100644 --- a/proto/provider/akash/inventory/v1/resourcepair.proto +++ b/proto/provider/akash/inventory/v1/resourcepair.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package akash.inventory.v1; -import "akash/base/v1beta3/attribute.proto"; import "gogoproto/gogo.proto"; +import "akash/base/v1beta3/attribute.proto"; import "k8s.io/apimachinery/pkg/api/resource/generated.proto"; option go_package = "github.com/akash-network/akash-api/go/inventory/v1"; diff --git a/proto/provider/akash/inventory/v1/resources.proto b/proto/provider/akash/inventory/v1/resources.proto new file mode 100644 index 00000000..9e30fd16 --- /dev/null +++ b/proto/provider/akash/inventory/v1/resources.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; +package akash.inventory.v1; + +import "gogoproto/gogo.proto"; +import "akash/inventory/v1/cpu.proto"; +import "akash/inventory/v1/gpu.proto"; +import "akash/inventory/v1/memory.proto"; +import "akash/inventory/v1/resourcepair.proto"; + +option go_package = "github.com/akash-network/akash-api/go/inventory/v1"; + +// NodeResources reports node inventory details +message NodeResources { + CPU cpu = 1 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "CPU", + (gogoproto.jsontag) = "cpu", + (gogoproto.moretags) = "yaml:\"cpu\"" + ]; + + Memory memory = 2 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Memory", + (gogoproto.jsontag) = "memory", + (gogoproto.moretags) = "yaml:\"memory\"" + ]; + + GPU gpu = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "GPUs", + (gogoproto.customname) = "GPU", + (gogoproto.jsontag) = "gpu", + (gogoproto.moretags) = "yaml:\"gpu\"" + ]; + + ResourcePair ephemeral_storage = 4 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "EphemeralStorage", + (gogoproto.jsontag) = "ephemeral_storage", + (gogoproto.moretags) = "yaml:\"ephemeral_storage\"" + ]; + + ResourcePair volumes_attached = 5 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "VolumesAttached", + (gogoproto.jsontag) = "volumes_attached", + (gogoproto.moretags) = "yaml:\"volumes_attached\"" + ]; + + ResourcePair volumes_mounted = 6 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "VolumesMounted", + (gogoproto.jsontag) = "volumes_mounted", + (gogoproto.moretags) = "yaml:\"volumes_mounted\"" + ]; +} diff --git a/proto/provider/akash/inventory/v1/service.proto b/proto/provider/akash/inventory/v1/service.proto index 063bf17f..9fa4ee8a 100644 --- a/proto/provider/akash/inventory/v1/service.proto +++ b/proto/provider/akash/inventory/v1/service.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package akash.inventory.v1; +import "google/api/annotations.proto"; import "akash/inventory/v1/node.proto"; import "akash/inventory/v1/cluster.proto"; @@ -11,16 +12,35 @@ message VoidNoParam {} // NodeRPC defines the RPC server of node service NodeRPC { - // QueryNode defines a method to query and stream hardware state of the node + // QueryNode defines a method to query hardware state of the node // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME - rpc QueryNode(VoidNoParam) returns (stream Node); + rpc QueryNode(VoidNoParam) returns (Node) { + option (google.api.http) = { + get: "/v1/node", + response_body: "*" + }; + } + + // StreamNode defines a method to stream hardware state of the node + // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + rpc StreamNode(VoidNoParam) returns (stream Node); } // ClusterRPC defines the RPC server of cluster service ClusterRPC { - // QueryNode defines a method to query and stream hardware state of the cluster + // QueryCluster defines a method to query hardware state of the cluster + // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + rpc QueryCluster(VoidNoParam) returns (Cluster) { + option (google.api.http) = { + get: "/v1/inventory", + response_body: "*" + }; + } + // StreamCluster defines a method to stream hardware state of the cluster // buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE // buf:lint:ignore RPC_RESPONSE_STANDARD_NAME - rpc QueryCluster(VoidNoParam) returns (stream Cluster); + rpc StreamCluster(VoidNoParam) returns (stream Cluster); } diff --git a/proto/provider/akash/inventory/v1/storage.proto b/proto/provider/akash/inventory/v1/storage.proto index 911c016b..de39e9ce 100644 --- a/proto/provider/akash/inventory/v1/storage.proto +++ b/proto/provider/akash/inventory/v1/storage.proto @@ -3,24 +3,23 @@ syntax = "proto3"; package akash.inventory.v1; import "gogoproto/gogo.proto"; - import "akash/inventory/v1/resourcepair.proto"; option go_package = "github.com/akash-network/akash-api/go/inventory/v1"; // StorageInfo reports Storage details message StorageInfo { - string class = 1 [ - (gogoproto.customname) = "Class", - (gogoproto.jsontag) = "class", - (gogoproto.moretags) = "yaml:\"class\"" - ]; - string iops = 2 [ - (gogoproto.customname) = "IOPS", - (gogoproto.jsontag) = "iops", - (gogoproto.moretags) = "yaml:\"iops\"" - ]; - } + string class = 1 [ + (gogoproto.customname) = "Class", + (gogoproto.jsontag) = "class", + (gogoproto.moretags) = "yaml:\"class\"" + ]; + string iops = 2 [ + (gogoproto.customname) = "IOPS", + (gogoproto.jsontag) = "iops", + (gogoproto.moretags) = "yaml:\"iops\"" + ]; +} // Storage reports Storage inventory details message Storage { diff --git a/script/protocgen-legacy.sh b/script/protocgen-legacy.sh index 6378e078..dc1538e8 100755 --- a/script/protocgen-legacy.sh +++ b/script/protocgen-legacy.sh @@ -32,15 +32,6 @@ for dir in $proto_dirs; do $(find "${dir}" -maxdepth 1 -name '*.proto') done -# shellcheck disable=SC2046 -.cache/bin/protoc \ - -I "proto/node" \ - -I "vendor/github.com/cosmos/cosmos-sdk/proto" \ - -I "vendor/github.com/cosmos/cosmos-sdk/third_party/proto" \ - --doc_out=./docs/proto \ - --doc_opt=./docs/protodoc-markdown.tmpl,node.md \ - $(find "./proto/node" -maxdepth 4 -name '*.proto') - proto_dirs=$(find ./proto/provider -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) #shellcheck disable=SC2046 for dir in $proto_dirs; do @@ -52,8 +43,30 @@ for dir in $proto_dirs; do -I "vendor" \ --gocosmos_out=plugins=interfacetype+grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \ $(find "${dir}" -maxdepth 1 -name '*.proto') + + # command to generate gRPC gateway (*.pb.gw.go in respective modules) files + .cache/bin/protoc \ + -I "proto/provider" \ + -I "proto/node" \ + -I ".cache/include" \ + -I "vendor/github.com/cosmos/cosmos-sdk/proto" \ + -I "vendor/github.com/cosmos/cosmos-sdk/third_party/proto" \ + --grpc-gateway_out=logtostderr=true:. \ + $(find "${dir}" -maxdepth 1 -name '*.proto') done +# move proto files to the right places +cp -rv github.com/akash-network/akash-api/* ./ + +# shellcheck disable=SC2046 +.cache/bin/protoc \ + -I "proto/node" \ + -I "vendor/github.com/cosmos/cosmos-sdk/proto" \ + -I "vendor/github.com/cosmos/cosmos-sdk/third_party/proto" \ + --doc_out=./docs/proto \ + --doc_opt=./docs/protodoc-markdown.tmpl,node.md \ + $(find "./proto/node" -maxdepth 4 -name '*.proto') + # shellcheck disable=SC2046 .cache/bin/protoc \ -I "proto/provider" \ @@ -64,6 +77,3 @@ done --doc_out=./docs/proto \ --doc_opt=./docs/protodoc-markdown.tmpl,provider.md \ $(find "./proto/provider" -maxdepth 4 -name '*.proto') - -# move proto files to the right places -cp -rv github.com/akash-network/akash-api/* ./