Skip to content

Commit

Permalink
Use grpc codec v2 during grpc invokes
Browse files Browse the repository at this point in the history
  • Loading branch information
pharr117 committed Jan 8, 2025
1 parent fd7f246 commit 86aa4f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions relayer/chains/cosmos/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/encoding"
"google.golang.org/grpc/encoding/proto"
"google.golang.org/grpc/mem"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)

var _ gogogrpc.ClientConn = &CosmosProvider{}

var protoCodec = encoding.GetCodec(proto.Name)
var protoCodec = encoding.GetCodecV2(proto.Name)

// Invoke implements the grpc ClientConn.Invoke method
func (cc *CosmosProvider) Invoke(ctx context.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error) {
Expand Down Expand Up @@ -65,7 +66,7 @@ func (cc *CosmosProvider) Invoke(ctx context.Context, method string, req, reply
return err
}

if err = protoCodec.Unmarshal(abciRes.Value, reply); err != nil {
if err = protoCodec.Unmarshal([]mem.Buffer{mem.NewBuffer(&abciRes.Value, nil)}, reply); err != nil {
return err
}

Expand Down Expand Up @@ -126,7 +127,7 @@ func (cc *CosmosProvider) RunGRPCQuery(ctx context.Context, method string, req i

abciReq := abci.RequestQuery{
Path: method,
Data: reqBz,
Data: reqBz.Materialize(),
Height: height,
Prove: prove,
}
Expand Down
7 changes: 4 additions & 3 deletions relayer/chains/penumbra/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/encoding"
"google.golang.org/grpc/encoding/proto"
"google.golang.org/grpc/mem"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)

var _ gogogrpc.ClientConn = &PenumbraProvider{}

var protoCodec = encoding.GetCodec(proto.Name)
var protoCodec = encoding.GetCodecV2(proto.Name)

// Invoke implements the grpc ClientConn.Invoke method
func (cc *PenumbraProvider) Invoke(ctx context.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error) {
Expand Down Expand Up @@ -65,7 +66,7 @@ func (cc *PenumbraProvider) Invoke(ctx context.Context, method string, req, repl
return err
}

if err = protoCodec.Unmarshal(abciRes.Value, reply); err != nil {
if err = protoCodec.Unmarshal([]mem.Buffer{mem.NewBuffer(&abciRes.Value, nil)}, reply); err != nil {
return err
}

Expand Down Expand Up @@ -126,7 +127,7 @@ func (cc *PenumbraProvider) RunGRPCQuery(ctx context.Context, method string, req

abciReq := abci.RequestQuery{
Path: method,
Data: reqBz,
Data: reqBz.Materialize(),
Height: height,
Prove: prove,
}
Expand Down

0 comments on commit 86aa4f8

Please sign in to comment.