From e69ed6fae260a417c25b799557e209b75270f24c Mon Sep 17 00:00:00 2001 From: huangzhiran Date: Thu, 17 Oct 2024 16:33:16 +0800 Subject: [PATCH] tmp --- build/docker-compose-dev.yml | 2 +- vm/instance.go | 30 +- vm/instance_test.go | 76 ----- vm/proto/vm.pb.go | 392 +++++++++++++++++++++++ vm/proto/{vm_runtime.proto => vm.proto} | 0 vm/proto/vm_grpc.pb.go | 146 +++++++++ vm/proto/vm_runtime.pb.go | 393 ------------------------ vm/proto/vm_runtime_grpc.pb.go | 137 --------- vm/vm.go | 2 +- 9 files changed, 552 insertions(+), 626 deletions(-) delete mode 100644 vm/instance_test.go create mode 100644 vm/proto/vm.pb.go rename vm/proto/{vm_runtime.proto => vm.proto} (100%) create mode 100644 vm/proto/vm_grpc.pb.go delete mode 100644 vm/proto/vm_runtime.pb.go delete mode 100644 vm/proto/vm_runtime_grpc.pb.go diff --git a/build/docker-compose-dev.yml b/build/docker-compose-dev.yml index 711e3f32..35813305 100644 --- a/build/docker-compose-dev.yml +++ b/build/docker-compose-dev.yml @@ -26,7 +26,7 @@ services: - 4003:4001 risc0: - image: ghcr.io/iotexproject/risc0server:v0.0.7 + image: ghcr.io/iotexproject/risc0server:v0.0.8 depends_on: - "postgres" container_name: risc0-service diff --git a/vm/instance.go b/vm/instance.go index eb846c55..98064768 100644 --- a/vm/instance.go +++ b/vm/instance.go @@ -10,34 +10,28 @@ import ( "github.com/iotexproject/w3bstream/vm/proto" ) -func create(ctx context.Context, conn *grpc.ClientConn, projectID uint64, executeBinary, expParam string) error { - cli := proto.NewVmRuntimeClient(conn) +func create(ctx context.Context, conn *grpc.ClientConn, projectID uint64, executeBinary, expParam []byte) error { + cli := proto.NewVMClient(conn) - req := &proto.CreateRequest{ + req := &proto.NewProjectRequest{ ProjectID: projectID, - Content: executeBinary, - ExpParam: expParam, + Binary: executeBinary, + Metadata: expParam, } - if _, err := cli.Create(ctx, req); err != nil { + if _, err := cli.NewProject(ctx, req); err != nil { return errors.Wrap(err, "failed to create vm instance") } return nil } func execute(ctx context.Context, conn *grpc.ClientConn, task *task.Task) ([]byte, error) { - ds := []string{} - for _, d := range task.Payloads { - ds = append(ds, string(d)) + req := &proto.ExecuteTaskRequest{ + ProjectID: task.ProjectID, + TaskID: task.ID.Bytes(), + Payloads: task.Payloads, } - req := &proto.ExecuteRequest{ - ProjectID: task.ProjectID, - TaskID: 0, // TODO - ClientID: "0", // TODO - SequencerSignature: "", // TODO - Datas: ds, - } - cli := proto.NewVmRuntimeClient(conn) - resp, err := cli.Execute(ctx, req) + cli := proto.NewVMClient(conn) + resp, err := cli.ExecuteTask(ctx, req) if err != nil { return nil, errors.Wrap(err, "failed to execute vm instance") } diff --git a/vm/instance_test.go b/vm/instance_test.go deleted file mode 100644 index f3649127..00000000 --- a/vm/instance_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package vm - -import ( - "context" - "testing" - - "github.com/agiledragon/gomonkey/v2" - "github.com/pkg/errors" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - - "github.com/iotexproject/w3bstream/task" - "github.com/iotexproject/w3bstream/vm/proto" -) - -type MockClient struct{} - -func (*MockClient) Create(ctx context.Context, in *proto.CreateRequest, opts ...grpc.CallOption) (*proto.CreateResponse, error) { - return nil, nil -} - -func (*MockClient) Execute(ctx context.Context, in *proto.ExecuteRequest, opts ...grpc.CallOption) (*proto.ExecuteResponse, error) { - return nil, nil -} - -func TestCreateInstance(t *testing.T) { - r := require.New(t) - t.Run("FailedToInvokeGRPCCreate", func(t *testing.T) { - p := gomonkey.NewPatches() - defer p.Reset() - - p.ApplyFuncReturn(grpc.Dial, &grpc.ClientConn{}, nil) - p.ApplyFuncReturn(proto.NewVmRuntimeClient, &MockClient{}) - p.ApplyMethodReturn(&MockClient{}, "Create", nil, errors.New(t.Name())) - - err := create(context.Background(), nil, 100, "any", "any") - r.ErrorContains(err, t.Name()) - }) - t.Run("Success", func(t *testing.T) { - p := gomonkey.NewPatches() - defer p.Reset() - - p.ApplyFuncReturn(grpc.Dial, &grpc.ClientConn{}, nil) - p.ApplyFuncReturn(proto.NewVmRuntimeClient, &MockClient{}) - p.ApplyMethodReturn(&MockClient{}, "Create", &proto.CreateResponse{}, nil) - p.ApplyMethodReturn(&grpc.ClientConn{}, "Close", nil) - - err := create(context.Background(), nil, 100, "any", "any") - r.NoError(err, t.Name()) - }) -} - -func TestExecuteInstance(t *testing.T) { - r := require.New(t) - t.Run("FailedToCallGRPCExecute", func(t *testing.T) { - p := gomonkey.NewPatches() - defer p.Reset() - - p.ApplyFuncReturn(proto.NewVmRuntimeClient, &MockClient{}) - p.ApplyMethodReturn(&MockClient{}, "Execute", nil, errors.New(t.Name())) - - _, err := execute(context.Background(), nil, &task.Task{}) - r.ErrorContains(err, t.Name()) - }) - t.Run("Success", func(t *testing.T) { - p := gomonkey.NewPatches() - defer p.Reset() - - p.ApplyFuncReturn(proto.NewVmRuntimeClient, &MockClient{}) - p.ApplyMethodReturn(&MockClient{}, "Execute", &proto.ExecuteResponse{Result: []byte("any")}, nil) - - res, err := execute(context.Background(), nil, &task.Task{Payloads: [][]byte{[]byte("data")}}) - r.NoError(err, t.Name()) - r.Equal(res, []byte("any")) - }) -} diff --git a/vm/proto/vm.pb.go b/vm/proto/vm.pb.go new file mode 100644 index 00000000..65862a36 --- /dev/null +++ b/vm/proto/vm.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.25.0 +// source: vm.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type NewProjectRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProjectID uint64 `protobuf:"varint,1,opt,name=projectID,proto3" json:"projectID,omitempty"` + ProjectVersion string `protobuf:"bytes,2,opt,name=projectVersion,proto3" json:"projectVersion,omitempty"` + Binary []byte `protobuf:"bytes,3,opt,name=binary,proto3" json:"binary,omitempty"` + Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (x *NewProjectRequest) Reset() { + *x = NewProjectRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_vm_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NewProjectRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NewProjectRequest) ProtoMessage() {} + +func (x *NewProjectRequest) ProtoReflect() protoreflect.Message { + mi := &file_vm_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NewProjectRequest.ProtoReflect.Descriptor instead. +func (*NewProjectRequest) Descriptor() ([]byte, []int) { + return file_vm_proto_rawDescGZIP(), []int{0} +} + +func (x *NewProjectRequest) GetProjectID() uint64 { + if x != nil { + return x.ProjectID + } + return 0 +} + +func (x *NewProjectRequest) GetProjectVersion() string { + if x != nil { + return x.ProjectVersion + } + return "" +} + +func (x *NewProjectRequest) GetBinary() []byte { + if x != nil { + return x.Binary + } + return nil +} + +func (x *NewProjectRequest) GetMetadata() []byte { + if x != nil { + return x.Metadata + } + return nil +} + +type NewProjectResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *NewProjectResponse) Reset() { + *x = NewProjectResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_vm_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NewProjectResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NewProjectResponse) ProtoMessage() {} + +func (x *NewProjectResponse) ProtoReflect() protoreflect.Message { + mi := &file_vm_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NewProjectResponse.ProtoReflect.Descriptor instead. +func (*NewProjectResponse) Descriptor() ([]byte, []int) { + return file_vm_proto_rawDescGZIP(), []int{1} +} + +type ExecuteTaskRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProjectID uint64 `protobuf:"varint,1,opt,name=projectID,proto3" json:"projectID,omitempty"` + ProjectVersion string `protobuf:"bytes,2,opt,name=projectVersion,proto3" json:"projectVersion,omitempty"` + TaskID []byte `protobuf:"bytes,3,opt,name=taskID,proto3" json:"taskID,omitempty"` + Payloads [][]byte `protobuf:"bytes,4,rep,name=payloads,proto3" json:"payloads,omitempty"` +} + +func (x *ExecuteTaskRequest) Reset() { + *x = ExecuteTaskRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_vm_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExecuteTaskRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecuteTaskRequest) ProtoMessage() {} + +func (x *ExecuteTaskRequest) ProtoReflect() protoreflect.Message { + mi := &file_vm_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecuteTaskRequest.ProtoReflect.Descriptor instead. +func (*ExecuteTaskRequest) Descriptor() ([]byte, []int) { + return file_vm_proto_rawDescGZIP(), []int{2} +} + +func (x *ExecuteTaskRequest) GetProjectID() uint64 { + if x != nil { + return x.ProjectID + } + return 0 +} + +func (x *ExecuteTaskRequest) GetProjectVersion() string { + if x != nil { + return x.ProjectVersion + } + return "" +} + +func (x *ExecuteTaskRequest) GetTaskID() []byte { + if x != nil { + return x.TaskID + } + return nil +} + +func (x *ExecuteTaskRequest) GetPayloads() [][]byte { + if x != nil { + return x.Payloads + } + return nil +} + +type ExecuteTaskResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` +} + +func (x *ExecuteTaskResponse) Reset() { + *x = ExecuteTaskResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_vm_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExecuteTaskResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExecuteTaskResponse) ProtoMessage() {} + +func (x *ExecuteTaskResponse) ProtoReflect() protoreflect.Message { + mi := &file_vm_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExecuteTaskResponse.ProtoReflect.Descriptor instead. +func (*ExecuteTaskResponse) Descriptor() ([]byte, []int) { + return file_vm_proto_rawDescGZIP(), []int{3} +} + +func (x *ExecuteTaskResponse) GetResult() []byte { + if x != nil { + return x.Result + } + return nil +} + +var File_vm_proto protoreflect.FileDescriptor + +var file_vm_proto_rawDesc = []byte{ + 0x0a, 0x08, 0x76, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x76, 0x6d, 0x22, 0x8d, + 0x01, 0x0a, 0x11, 0x4e, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, + 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x69, + 0x6e, 0x61, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x62, 0x69, 0x6e, 0x61, + 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x14, + 0x0a, 0x12, 0x4e, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x8e, 0x01, 0x0a, 0x12, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, + 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x22, 0x2d, 0x0a, 0x13, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, + 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x32, 0x81, 0x01, 0x0a, 0x02, 0x56, 0x4d, 0x12, 0x3b, 0x0a, 0x0a, 0x4e, + 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x4e, + 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x4e, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0b, 0x45, 0x78, 0x65, 0x63, + 0x75, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x78, 0x65, + 0x63, 0x75, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_vm_proto_rawDescOnce sync.Once + file_vm_proto_rawDescData = file_vm_proto_rawDesc +) + +func file_vm_proto_rawDescGZIP() []byte { + file_vm_proto_rawDescOnce.Do(func() { + file_vm_proto_rawDescData = protoimpl.X.CompressGZIP(file_vm_proto_rawDescData) + }) + return file_vm_proto_rawDescData +} + +var file_vm_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_vm_proto_goTypes = []interface{}{ + (*NewProjectRequest)(nil), // 0: vm.NewProjectRequest + (*NewProjectResponse)(nil), // 1: vm.NewProjectResponse + (*ExecuteTaskRequest)(nil), // 2: vm.ExecuteTaskRequest + (*ExecuteTaskResponse)(nil), // 3: vm.ExecuteTaskResponse +} +var file_vm_proto_depIdxs = []int32{ + 0, // 0: vm.VM.NewProject:input_type -> vm.NewProjectRequest + 2, // 1: vm.VM.ExecuteTask:input_type -> vm.ExecuteTaskRequest + 1, // 2: vm.VM.NewProject:output_type -> vm.NewProjectResponse + 3, // 3: vm.VM.ExecuteTask:output_type -> vm.ExecuteTaskResponse + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_vm_proto_init() } +func file_vm_proto_init() { + if File_vm_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_vm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NewProjectRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_vm_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NewProjectResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_vm_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExecuteTaskRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_vm_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExecuteTaskResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_vm_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_vm_proto_goTypes, + DependencyIndexes: file_vm_proto_depIdxs, + MessageInfos: file_vm_proto_msgTypes, + }.Build() + File_vm_proto = out.File + file_vm_proto_rawDesc = nil + file_vm_proto_goTypes = nil + file_vm_proto_depIdxs = nil +} diff --git a/vm/proto/vm_runtime.proto b/vm/proto/vm.proto similarity index 100% rename from vm/proto/vm_runtime.proto rename to vm/proto/vm.proto diff --git a/vm/proto/vm_grpc.pb.go b/vm/proto/vm_grpc.pb.go new file mode 100644 index 00000000..dc6ba7b3 --- /dev/null +++ b/vm/proto/vm_grpc.pb.go @@ -0,0 +1,146 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.25.0 +// source: vm.proto + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + VM_NewProject_FullMethodName = "/vm.VM/NewProject" + VM_ExecuteTask_FullMethodName = "/vm.VM/ExecuteTask" +) + +// VMClient is the client API for VM service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type VMClient interface { + NewProject(ctx context.Context, in *NewProjectRequest, opts ...grpc.CallOption) (*NewProjectResponse, error) + ExecuteTask(ctx context.Context, in *ExecuteTaskRequest, opts ...grpc.CallOption) (*ExecuteTaskResponse, error) +} + +type vMClient struct { + cc grpc.ClientConnInterface +} + +func NewVMClient(cc grpc.ClientConnInterface) VMClient { + return &vMClient{cc} +} + +func (c *vMClient) NewProject(ctx context.Context, in *NewProjectRequest, opts ...grpc.CallOption) (*NewProjectResponse, error) { + out := new(NewProjectResponse) + err := c.cc.Invoke(ctx, VM_NewProject_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *vMClient) ExecuteTask(ctx context.Context, in *ExecuteTaskRequest, opts ...grpc.CallOption) (*ExecuteTaskResponse, error) { + out := new(ExecuteTaskResponse) + err := c.cc.Invoke(ctx, VM_ExecuteTask_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// VMServer is the server API for VM service. +// All implementations must embed UnimplementedVMServer +// for forward compatibility +type VMServer interface { + NewProject(context.Context, *NewProjectRequest) (*NewProjectResponse, error) + ExecuteTask(context.Context, *ExecuteTaskRequest) (*ExecuteTaskResponse, error) + mustEmbedUnimplementedVMServer() +} + +// UnimplementedVMServer must be embedded to have forward compatible implementations. +type UnimplementedVMServer struct { +} + +func (UnimplementedVMServer) NewProject(context.Context, *NewProjectRequest) (*NewProjectResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NewProject not implemented") +} +func (UnimplementedVMServer) ExecuteTask(context.Context, *ExecuteTaskRequest) (*ExecuteTaskResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExecuteTask not implemented") +} +func (UnimplementedVMServer) mustEmbedUnimplementedVMServer() {} + +// UnsafeVMServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to VMServer will +// result in compilation errors. +type UnsafeVMServer interface { + mustEmbedUnimplementedVMServer() +} + +func RegisterVMServer(s grpc.ServiceRegistrar, srv VMServer) { + s.RegisterService(&VM_ServiceDesc, srv) +} + +func _VM_NewProject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NewProjectRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VMServer).NewProject(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: VM_NewProject_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VMServer).NewProject(ctx, req.(*NewProjectRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _VM_ExecuteTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ExecuteTaskRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VMServer).ExecuteTask(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: VM_ExecuteTask_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VMServer).ExecuteTask(ctx, req.(*ExecuteTaskRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// VM_ServiceDesc is the grpc.ServiceDesc for VM service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var VM_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "vm.VM", + HandlerType: (*VMServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "NewProject", + Handler: _VM_NewProject_Handler, + }, + { + MethodName: "ExecuteTask", + Handler: _VM_ExecuteTask_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "vm.proto", +} diff --git a/vm/proto/vm_runtime.pb.go b/vm/proto/vm_runtime.pb.go deleted file mode 100644 index 715800c7..00000000 --- a/vm/proto/vm_runtime.pb.go +++ /dev/null @@ -1,393 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v5.27.0 -// source: proto/vm_runtime.proto - -package proto - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type CreateRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProjectID uint64 `protobuf:"varint,1,opt,name=projectID,proto3" json:"projectID,omitempty"` - Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` - ExpParam string `protobuf:"bytes,3,opt,name=expParam,proto3" json:"expParam,omitempty"` -} - -func (x *CreateRequest) Reset() { - *x = CreateRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_vm_runtime_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateRequest) ProtoMessage() {} - -func (x *CreateRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_vm_runtime_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateRequest.ProtoReflect.Descriptor instead. -func (*CreateRequest) Descriptor() ([]byte, []int) { - return file_proto_vm_runtime_proto_rawDescGZIP(), []int{0} -} - -func (x *CreateRequest) GetProjectID() uint64 { - if x != nil { - return x.ProjectID - } - return 0 -} - -func (x *CreateRequest) GetContent() string { - if x != nil { - return x.Content - } - return "" -} - -func (x *CreateRequest) GetExpParam() string { - if x != nil { - return x.ExpParam - } - return "" -} - -type CreateResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *CreateResponse) Reset() { - *x = CreateResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_vm_runtime_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateResponse) ProtoMessage() {} - -func (x *CreateResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_vm_runtime_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateResponse.ProtoReflect.Descriptor instead. -func (*CreateResponse) Descriptor() ([]byte, []int) { - return file_proto_vm_runtime_proto_rawDescGZIP(), []int{1} -} - -type ExecuteRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProjectID uint64 `protobuf:"varint,1,opt,name=projectID,proto3" json:"projectID,omitempty"` - TaskID uint64 `protobuf:"varint,2,opt,name=taskID,proto3" json:"taskID,omitempty"` - ClientID string `protobuf:"bytes,3,opt,name=clientID,proto3" json:"clientID,omitempty"` - SequencerSignature string `protobuf:"bytes,4,opt,name=sequencerSignature,proto3" json:"sequencerSignature,omitempty"` - Datas []string `protobuf:"bytes,5,rep,name=datas,proto3" json:"datas,omitempty"` -} - -func (x *ExecuteRequest) Reset() { - *x = ExecuteRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_vm_runtime_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ExecuteRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExecuteRequest) ProtoMessage() {} - -func (x *ExecuteRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_vm_runtime_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ExecuteRequest.ProtoReflect.Descriptor instead. -func (*ExecuteRequest) Descriptor() ([]byte, []int) { - return file_proto_vm_runtime_proto_rawDescGZIP(), []int{2} -} - -func (x *ExecuteRequest) GetProjectID() uint64 { - if x != nil { - return x.ProjectID - } - return 0 -} - -func (x *ExecuteRequest) GetTaskID() uint64 { - if x != nil { - return x.TaskID - } - return 0 -} - -func (x *ExecuteRequest) GetClientID() string { - if x != nil { - return x.ClientID - } - return "" -} - -func (x *ExecuteRequest) GetSequencerSignature() string { - if x != nil { - return x.SequencerSignature - } - return "" -} - -func (x *ExecuteRequest) GetDatas() []string { - if x != nil { - return x.Datas - } - return nil -} - -type ExecuteResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` -} - -func (x *ExecuteResponse) Reset() { - *x = ExecuteResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_proto_vm_runtime_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ExecuteResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExecuteResponse) ProtoMessage() {} - -func (x *ExecuteResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_vm_runtime_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ExecuteResponse.ProtoReflect.Descriptor instead. -func (*ExecuteResponse) Descriptor() ([]byte, []int) { - return file_proto_vm_runtime_proto_rawDescGZIP(), []int{3} -} - -func (x *ExecuteResponse) GetResult() []byte { - if x != nil { - return x.Result - } - return nil -} - -var File_proto_vm_runtime_proto protoreflect.FileDescriptor - -var file_proto_vm_runtime_proto_rawDesc = []byte{ - 0x0a, 0x16, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x6d, 0x5f, 0x72, 0x75, 0x6e, 0x74, 0x69, - 0x6d, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x76, 0x6d, 0x5f, 0x72, 0x75, 0x6e, - 0x74, 0x69, 0x6d, 0x65, 0x22, 0x63, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, - 0x74, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, - 0x08, 0x65, 0x78, 0x70, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x65, 0x78, 0x70, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x22, 0x10, 0x0a, 0x0e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa8, 0x01, 0x0a, 0x0e, - 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, - 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, - 0x74, 0x61, 0x73, 0x6b, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x74, 0x61, - 0x73, 0x6b, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x44, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x44, - 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x72, 0x53, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x73, 0x65, - 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x72, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x64, 0x61, 0x74, 0x61, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x05, 0x64, 0x61, 0x74, 0x61, 0x73, 0x22, 0x29, 0x0a, 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x32, 0x90, 0x01, 0x0a, 0x09, 0x56, 0x6d, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, - 0x3f, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x19, 0x2e, 0x76, 0x6d, 0x5f, 0x72, - 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x76, 0x6d, 0x5f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, - 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x42, 0x0a, 0x07, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x12, 0x1a, 0x2e, 0x76, 0x6d, - 0x5f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x76, 0x6d, 0x5f, 0x72, 0x75, 0x6e, - 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_proto_vm_runtime_proto_rawDescOnce sync.Once - file_proto_vm_runtime_proto_rawDescData = file_proto_vm_runtime_proto_rawDesc -) - -func file_proto_vm_runtime_proto_rawDescGZIP() []byte { - file_proto_vm_runtime_proto_rawDescOnce.Do(func() { - file_proto_vm_runtime_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_vm_runtime_proto_rawDescData) - }) - return file_proto_vm_runtime_proto_rawDescData -} - -var file_proto_vm_runtime_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_proto_vm_runtime_proto_goTypes = []interface{}{ - (*CreateRequest)(nil), // 0: vm_runtime.CreateRequest - (*CreateResponse)(nil), // 1: vm_runtime.CreateResponse - (*ExecuteRequest)(nil), // 2: vm_runtime.ExecuteRequest - (*ExecuteResponse)(nil), // 3: vm_runtime.ExecuteResponse -} -var file_proto_vm_runtime_proto_depIdxs = []int32{ - 0, // 0: vm_runtime.VmRuntime.Create:input_type -> vm_runtime.CreateRequest - 2, // 1: vm_runtime.VmRuntime.Execute:input_type -> vm_runtime.ExecuteRequest - 1, // 2: vm_runtime.VmRuntime.Create:output_type -> vm_runtime.CreateResponse - 3, // 3: vm_runtime.VmRuntime.Execute:output_type -> vm_runtime.ExecuteResponse - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_proto_vm_runtime_proto_init() } -func file_proto_vm_runtime_proto_init() { - if File_proto_vm_runtime_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_proto_vm_runtime_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_vm_runtime_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_vm_runtime_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExecuteRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proto_vm_runtime_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExecuteResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_proto_vm_runtime_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_proto_vm_runtime_proto_goTypes, - DependencyIndexes: file_proto_vm_runtime_proto_depIdxs, - MessageInfos: file_proto_vm_runtime_proto_msgTypes, - }.Build() - File_proto_vm_runtime_proto = out.File - file_proto_vm_runtime_proto_rawDesc = nil - file_proto_vm_runtime_proto_goTypes = nil - file_proto_vm_runtime_proto_depIdxs = nil -} diff --git a/vm/proto/vm_runtime_grpc.pb.go b/vm/proto/vm_runtime_grpc.pb.go deleted file mode 100644 index 6a94546a..00000000 --- a/vm/proto/vm_runtime_grpc.pb.go +++ /dev/null @@ -1,137 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. - -package proto - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// VmRuntimeClient is the client API for VmRuntime service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type VmRuntimeClient interface { - Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) - Execute(ctx context.Context, in *ExecuteRequest, opts ...grpc.CallOption) (*ExecuteResponse, error) -} - -type vmRuntimeClient struct { - cc grpc.ClientConnInterface -} - -func NewVmRuntimeClient(cc grpc.ClientConnInterface) VmRuntimeClient { - return &vmRuntimeClient{cc} -} - -func (c *vmRuntimeClient) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) { - out := new(CreateResponse) - err := c.cc.Invoke(ctx, "/vm_runtime.VmRuntime/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *vmRuntimeClient) Execute(ctx context.Context, in *ExecuteRequest, opts ...grpc.CallOption) (*ExecuteResponse, error) { - out := new(ExecuteResponse) - err := c.cc.Invoke(ctx, "/vm_runtime.VmRuntime/Execute", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// VmRuntimeServer is the server API for VmRuntime service. -// All implementations must embed UnimplementedVmRuntimeServer -// for forward compatibility -type VmRuntimeServer interface { - Create(context.Context, *CreateRequest) (*CreateResponse, error) - Execute(context.Context, *ExecuteRequest) (*ExecuteResponse, error) - mustEmbedUnimplementedVmRuntimeServer() -} - -// UnimplementedVmRuntimeServer must be embedded to have forward compatible implementations. -type UnimplementedVmRuntimeServer struct { -} - -func (UnimplementedVmRuntimeServer) Create(context.Context, *CreateRequest) (*CreateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (UnimplementedVmRuntimeServer) Execute(context.Context, *ExecuteRequest) (*ExecuteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Execute not implemented") -} -func (UnimplementedVmRuntimeServer) mustEmbedUnimplementedVmRuntimeServer() {} - -// UnsafeVmRuntimeServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to VmRuntimeServer will -// result in compilation errors. -type UnsafeVmRuntimeServer interface { - mustEmbedUnimplementedVmRuntimeServer() -} - -func RegisterVmRuntimeServer(s grpc.ServiceRegistrar, srv VmRuntimeServer) { - s.RegisterService(&VmRuntime_ServiceDesc, srv) -} - -func _VmRuntime_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(VmRuntimeServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/vm_runtime.VmRuntime/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(VmRuntimeServer).Create(ctx, req.(*CreateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _VmRuntime_Execute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ExecuteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(VmRuntimeServer).Execute(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/vm_runtime.VmRuntime/Execute", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(VmRuntimeServer).Execute(ctx, req.(*ExecuteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// VmRuntime_ServiceDesc is the grpc.ServiceDesc for VmRuntime service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var VmRuntime_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "vm_runtime.VmRuntime", - HandlerType: (*VmRuntimeServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _VmRuntime_Create_Handler, - }, - { - MethodName: "Execute", - Handler: _VmRuntime_Execute_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "proto/vm_runtime.proto", -} diff --git a/vm/vm.go b/vm/vm.go index 748cdff2..59c746e9 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -21,7 +21,7 @@ func (r *Handler) Handle(task *task.Task, vmTypeID uint64, code string, expParam return nil, errors.Errorf("unsupported vm type id %d", vmTypeID) } - if err := create(context.Background(), conn, task.ProjectID, code, expParam); err != nil { + if err := create(context.Background(), conn, task.ProjectID, []byte(code), []byte(expParam)); err != nil { return nil, errors.Wrap(err, "failed to create vm instance") } slog.Debug("create vm instance success", "vm_type_id", vmTypeID)