From 3230e23c3f1dc8e423d8476ec03bd6ce6ab0284d Mon Sep 17 00:00:00 2001 From: Lazar Date: Fri, 20 Dec 2024 11:08:23 +0100 Subject: [PATCH] grpc use v2, rm replace --- go.mod | 2 -- relayer/chains/cosmos/grpc_query.go | 8 ++++---- relayer/chains/penumbra/grpc_query.go | 7 ++++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 578674060..0387b20b2 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/relayer/chains/cosmos/grpc_query.go b/relayer/chains/cosmos/grpc_query.go index 5c35b334b..ef21223f7 100644 --- a/relayer/chains/cosmos/grpc_query.go +++ b/relayer/chains/cosmos/grpc_query.go @@ -3,6 +3,7 @@ package cosmos import ( "context" "errors" + "google.golang.org/grpc/mem" "reflect" "strconv" "sync" @@ -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") @@ -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 } @@ -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, } diff --git a/relayer/chains/penumbra/grpc_query.go b/relayer/chains/penumbra/grpc_query.go index a66951248..be24dfe93 100644 --- a/relayer/chains/penumbra/grpc_query.go +++ b/relayer/chains/penumbra/grpc_query.go @@ -3,6 +3,7 @@ package penumbra import ( "context" "errors" + "google.golang.org/grpc/mem" "reflect" "strconv" "sync" @@ -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) { @@ -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 } @@ -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, }