Skip to content

Commit

Permalink
grpc use v2, rm replace
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Dec 20, 2024
1 parent 767cb6f commit 3230e23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module github.com/cosmos/relayer/v2

go 1.21

replace google.golang.org/grpc => google.golang.org/grpc v1.64.1

require (
cosmossdk.io/api v0.7.6
cosmossdk.io/errors v1.0.1
Expand Down
8 changes: 4 additions & 4 deletions relayer/chains/cosmos/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cosmos
import (
"context"
"errors"
"google.golang.org/grpc/mem"
"reflect"
"strconv"
"sync"
Expand All @@ -27,14 +28,13 @@ import (

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) {
// Two things can happen here:
// 1. either we're broadcasting a Tx, in which call we call Tendermint's broadcast endpoint directly,
// 2. or we are querying for state, in which case we call ABCI's Querier.

// In both cases, we don't allow empty request req (it will panic unexpectedly).
if reflect.ValueOf(req).IsNil() {
return sdkerrors.Wrap(legacyerrors.ErrInvalidRequest, "request cannot be nil")
Expand Down Expand Up @@ -65,7 +65,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 +126,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 @@ -3,6 +3,7 @@ package penumbra
import (
"context"
"errors"
"google.golang.org/grpc/mem"
"reflect"
"strconv"
"sync"
Expand All @@ -27,7 +28,7 @@ import (

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 3230e23

Please sign in to comment.