新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!

Commit d57600be authored by gh lu's avatar gh lu

feat: Add vtproto

--story=0
parent 254b8f9b
gen:
cd pb/proto && protoc -I=. --gogofaster_out=plugins=grpc:../protogo --gogofaster_opt=paths=source_relative dockervm_message.proto
cd pb/proto && protoc \
--go_out=../protogo --plugin protoc-gen-go="$(GOPATH)/bin/protoc-gen-go" \
--go-grpc_out=../protogo --go-grpc_opt=require_unimplemented_servers=false --plugin protoc-gen-go-grpc="$(GOPATH)/bin/protoc-gen-go-grpc" \
--go-vtproto_out=../protogo --plugin protoc-gen-go-vtproto="$(GOPATH)/bin/protoc-gen-go-vtproto" \
--go_opt=paths=source_relative \
--go-grpc_opt=paths=source_relative \
--go-vtproto_opt=paths=source_relative \
--go-vtproto_opt=features=marshal+unmarshal+size+pool \
--go-vtproto_opt=pool=chainmaker.org/chainmaker/contract-sdk-go/pb/protogo.DockerVMMessage \
dockervm_message.proto
mockgen:
mockgen -destination ./sdk/mock_sdk_interface.go -package sdk -source ./sdk/sdk_interface.go
......
......@@ -2,7 +2,7 @@ syntax = "proto3";
package proto;
option go_package = "chainmaker.org/chainmaker/vm-engine/vm_mgr/pb/protogo";
option go_package = "chainmaker.org/chainmaker/contract-sdk-go/pb/protogo";
service DockerVMRpc {
rpc DockerVMCommunicate(stream DockerVMMessage) returns(stream DockerVMMessage) {};
......
This diff is collapsed.
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.17.3
// source: dockervm_message.proto
package protogo
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
// DockerVMRpcClient is the client API for DockerVMRpc 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 DockerVMRpcClient interface {
DockerVMCommunicate(ctx context.Context, opts ...grpc.CallOption) (DockerVMRpc_DockerVMCommunicateClient, error)
}
type dockerVMRpcClient struct {
cc grpc.ClientConnInterface
}
func NewDockerVMRpcClient(cc grpc.ClientConnInterface) DockerVMRpcClient {
return &dockerVMRpcClient{cc}
}
func (c *dockerVMRpcClient) DockerVMCommunicate(ctx context.Context, opts ...grpc.CallOption) (DockerVMRpc_DockerVMCommunicateClient, error) {
stream, err := c.cc.NewStream(ctx, &DockerVMRpc_ServiceDesc.Streams[0], "/proto.DockerVMRpc/DockerVMCommunicate", opts...)
if err != nil {
return nil, err
}
x := &dockerVMRpcDockerVMCommunicateClient{stream}
return x, nil
}
type DockerVMRpc_DockerVMCommunicateClient interface {
Send(*DockerVMMessage) error
Recv() (*DockerVMMessage, error)
grpc.ClientStream
}
type dockerVMRpcDockerVMCommunicateClient struct {
grpc.ClientStream
}
func (x *dockerVMRpcDockerVMCommunicateClient) Send(m *DockerVMMessage) error {
return x.ClientStream.SendMsg(m)
}
func (x *dockerVMRpcDockerVMCommunicateClient) Recv() (*DockerVMMessage, error) {
m := new(DockerVMMessage)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// DockerVMRpcServer is the server API for DockerVMRpc service.
// All implementations should embed UnimplementedDockerVMRpcServer
// for forward compatibility
type DockerVMRpcServer interface {
DockerVMCommunicate(DockerVMRpc_DockerVMCommunicateServer) error
}
// UnimplementedDockerVMRpcServer should be embedded to have forward compatible implementations.
type UnimplementedDockerVMRpcServer struct {
}
func (UnimplementedDockerVMRpcServer) DockerVMCommunicate(DockerVMRpc_DockerVMCommunicateServer) error {
return status.Errorf(codes.Unimplemented, "method DockerVMCommunicate not implemented")
}
// UnsafeDockerVMRpcServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to DockerVMRpcServer will
// result in compilation errors.
type UnsafeDockerVMRpcServer interface {
mustEmbedUnimplementedDockerVMRpcServer()
}
func RegisterDockerVMRpcServer(s grpc.ServiceRegistrar, srv DockerVMRpcServer) {
s.RegisterService(&DockerVMRpc_ServiceDesc, srv)
}
func _DockerVMRpc_DockerVMCommunicate_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(DockerVMRpcServer).DockerVMCommunicate(&dockerVMRpcDockerVMCommunicateServer{stream})
}
type DockerVMRpc_DockerVMCommunicateServer interface {
Send(*DockerVMMessage) error
Recv() (*DockerVMMessage, error)
grpc.ServerStream
}
type dockerVMRpcDockerVMCommunicateServer struct {
grpc.ServerStream
}
func (x *dockerVMRpcDockerVMCommunicateServer) Send(m *DockerVMMessage) error {
return x.ServerStream.SendMsg(m)
}
func (x *dockerVMRpcDockerVMCommunicateServer) Recv() (*DockerVMMessage, error) {
m := new(DockerVMMessage)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// DockerVMRpc_ServiceDesc is the grpc.ServiceDesc for DockerVMRpc service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var DockerVMRpc_ServiceDesc = grpc.ServiceDesc{
ServiceName: "proto.DockerVMRpc",
HandlerType: (*DockerVMRpcServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "DockerVMCommunicate",
Handler: _DockerVMRpc_DockerVMCommunicate_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "dockervm_message.proto",
}
This diff is collapsed.
......@@ -106,7 +106,8 @@ func (c *ContractEngineClient) listenTxRequest() error {
// holds return values from gRPC Recv below
// recv message
for {
msg, err := c.rpcClient.Recv()
msg := protogo.DockerVMMessageFromVTPool()
err := c.rpcClient.RecvMsg(msg)
switch {
case err != nil:
err := fmt.Errorf("client receive error from contract engine: %s", err)
......
......@@ -69,7 +69,8 @@ func (r *RuntimeClient) recvRoutine() error {
r.logger.Debugf("close runtime client receive goroutine")
return errors.New("close runtime client receive goroutine")
default:
receivedMsg, recvErr := r.rpcClient.Recv()
receivedMsg := protogo.DockerVMMessageFromVTPool()
recvErr := r.rpcClient.RecvMsg(receivedMsg)
if recvErr != nil {
r.logger.Errorf("client receive err from runtime %s", recvErr)
......@@ -99,6 +100,7 @@ func (r *RuntimeClient) recvRoutine() error {
default:
r.logger.Errorf("unknown message type, received msg: [%v]", receivedMsg)
}
//receivedMsg.ReturnToVTPool()
}
}
}
......
......@@ -121,6 +121,7 @@ func (h *TxHandler) handleTxRequest(msg *protogo.DockerVMMessage) error {
defer func() {
currentTxDuration.TotalDuration = time.Since(startTime).Nanoseconds()
h.sandboxLogger.Debugf(currentTxDuration.ToString())
msg.ReturnToVTPool()
}()
args := msg.GetRequest().GetParameters()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment