From 52a9860398c48b0c4c44868a54028916f8531cc3 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Mon, 30 Nov 2020 15:35:47 +0100 Subject: [PATCH] Switch to txraw --- Makefile | 2 +- proto/cosmos/tx/v1beta1/service.proto | 70 +++++++------- types/query/query.pb.go | 2 +- types/tx/service.pb.go | 133 ++++++++++++++------------ x/auth/tx/service.go | 25 ++--- x/auth/tx/service_test.go | 14 ++- 6 files changed, 127 insertions(+), 119 deletions(-) diff --git a/Makefile b/Makefile index baace1ee14b0..f9011d13d3b8 100644 --- a/Makefile +++ b/Makefile @@ -357,7 +357,7 @@ devdoc-update: ### Protobuf ### ############################################################################### -proto-all: proto-format proto-lint proto-check-breaking proto-gen +proto-all: proto-format proto-lint proto-gen proto-gen: @echo "Generating Protobuf files" diff --git a/proto/cosmos/tx/v1beta1/service.proto b/proto/cosmos/tx/v1beta1/service.proto index 6a72ab7712a9..d5bc6dd0c399 100644 --- a/proto/cosmos/tx/v1beta1/service.proto +++ b/proto/cosmos/tx/v1beta1/service.proto @@ -6,27 +6,28 @@ import "cosmos/base/abci/v1beta1/abci.proto"; import "cosmos/tx/v1beta1/tx.proto"; import "gogoproto/gogo.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/tx/v1beta1/tx.proto"; option go_package = "github.com/cosmos/cosmos-sdk/types/tx"; // Service defines a gRPC service for interacting with transactions. service Service { - // Simulate simulates executing a transaction for estimating gas usage. - rpc Simulate(SimulateRequest) returns (SimulateResponse) { - option (google.api.http).post = "/cosmos/tx/v1beta1/simulate"; - } - // GetTx fetches a tx by hash. - rpc GetTx(GetTxRequest) returns (GetTxResponse) { - option (google.api.http).get = "/cosmos/tx/v1beta1/tx/{hash}"; - } - // BroadcastTx broadcast transaction. - rpc BroadcastTx(BroadcastTxRequest) returns (BroadcastTxResponse) { - option (google.api.http).post = "/cosmos/tx/v1beta1/txs"; - } - // GetTxsEvent fetches txs by event. - rpc GetTxsEvent(GetTxsEventRequest) returns (GetTxsEventResponse) { - option (google.api.http).get = "/cosmos/tx/v1beta1/txs"; - } + // Simulate simulates executing a transaction for estimating gas usage. + rpc Simulate(SimulateRequest) returns (SimulateResponse) { + option (google.api.http).post = "/cosmos/tx/v1beta1/simulate"; + } + // GetTx fetches a tx by hash. + rpc GetTx(GetTxRequest) returns (GetTxResponse) { + option (google.api.http).get = "/cosmos/tx/v1beta1/tx/{hash}"; + } + // BroadcastTx broadcast transaction. + rpc BroadcastTx(BroadcastTxRequest) returns (BroadcastTxResponse) { + option (google.api.http).post = "/cosmos/tx/v1beta1/txs"; + } + // GetTxsEvent fetches txs by event. + rpc GetTxsEvent(GetTxsEventRequest) returns (GetTxsEventResponse) { + option (google.api.http).get = "/cosmos/tx/v1beta1/txs"; + } } // GetTxsEventRequest is the request type for the Service.TxsByEvents @@ -52,36 +53,35 @@ message GetTxsEventResponse { // BroadcastTxRequest is the request type for the Service.BroadcastTxRequest // RPC method. message BroadcastTxRequest { - // tx_raw is the raw transaction. - bytes tx_raw = 1; - BroadcastMode mode = 2; + // tx_raw is the raw transaction. + cosmos.tx.v1beta1.TxRaw tx_raw = 1; + BroadcastMode mode = 2; } // BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. enum BroadcastMode { - // zero-value for mode ordering - BROADCAST_MODE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "none"]; - // BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for - // the tx to be committed in a block. - BROADCAST_MODE_BLOCK = 1 [(gogoproto.enumvalue_customname) = "block"]; - // BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for - // a CheckTx execution response only. - BROADCAST_MODE_SYNC = 2 [(gogoproto.enumvalue_customname) = "sync"]; - // BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns - // immediately. - BROADCAST_MODE_ASYNC = 3 [(gogoproto.enumvalue_customname) = "async"]; + // zero-value for mode ordering + BROADCAST_MODE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "none"]; + // BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for + // the tx to be committed in a block. + BROADCAST_MODE_BLOCK = 1 [(gogoproto.enumvalue_customname) = "block"]; + // BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for + // a CheckTx execution response only. + BROADCAST_MODE_SYNC = 2 [(gogoproto.enumvalue_customname) = "sync"]; + // BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns + // immediately. + BROADCAST_MODE_ASYNC = 3 [(gogoproto.enumvalue_customname) = "async"]; } // BroadcastTxResponse is the response type for the // Service.BroadcastTx method. message BroadcastTxResponse { - // tx is the queried transaction. - cosmos.tx.v1beta1.Tx tx = 1; - // tx_response is the queried TxResponses. - cosmos.base.abci.v1beta1.TxResponse tx_response = 2; + // tx is the queried transaction. + cosmos.tx.v1beta1.Tx tx = 1; + // tx_response is the queried TxResponses. + cosmos.base.abci.v1beta1.TxResponse tx_response = 2; } - // SimulateRequest is the request type for the Service.Simulate // RPC method. message SimulateRequest { diff --git a/types/query/query.pb.go b/types/query/query.pb.go index c04a6bde32b6..266d337002e8 100644 --- a/types/query/query.pb.go +++ b/types/query/query.pb.go @@ -783,7 +783,7 @@ type Module struct { Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` // module version Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - //checksum + // checksum Sum string `protobuf:"bytes,3,opt,name=sum,proto3" json:"sum,omitempty"` } diff --git a/types/tx/service.pb.go b/types/tx/service.pb.go index 4b3f9bf66e7a..314d91c62048 100644 --- a/types/tx/service.pb.go +++ b/types/tx/service.pb.go @@ -195,7 +195,7 @@ func (m *GetTxsEventResponse) GetPagination() *query.PageResponse { // RPC method. type BroadcastTxRequest struct { // tx_raw is the raw transaction. - TxRaw []byte `protobuf:"bytes,1,opt,name=tx_raw,json=txRaw,proto3" json:"tx_raw,omitempty"` + TxRaw *TxRaw `protobuf:"bytes,1,opt,name=tx_raw,json=txRaw,proto3" json:"tx_raw,omitempty"` Mode BroadcastMode `protobuf:"varint,2,opt,name=mode,proto3,enum=cosmos.tx.v1beta1.BroadcastMode" json:"mode,omitempty"` } @@ -232,7 +232,7 @@ func (m *BroadcastTxRequest) XXX_DiscardUnknown() { var xxx_messageInfo_BroadcastTxRequest proto.InternalMessageInfo -func (m *BroadcastTxRequest) GetTxRaw() []byte { +func (m *BroadcastTxRequest) GetTxRaw() *TxRaw { if m != nil { return m.TxRaw } @@ -522,55 +522,55 @@ func init() { func init() { proto.RegisterFile("cosmos/tx/v1beta1/service.proto", fileDescriptor_e0b00a618705eca7) } var fileDescriptor_e0b00a618705eca7 = []byte{ - // 756 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x4b, 0x4f, 0xdb, 0x4a, - 0x14, 0x8e, 0x13, 0xc2, 0x63, 0x02, 0xf7, 0xe6, 0x0e, 0x70, 0x15, 0xf9, 0x72, 0x8d, 0x71, 0x78, - 0x44, 0x48, 0xb5, 0x45, 0xda, 0x05, 0x8b, 0x4a, 0x15, 0x09, 0x01, 0xa1, 0x96, 0x87, 0x1c, 0xba, - 0x68, 0x37, 0xd1, 0x24, 0x19, 0x8c, 0x45, 0xe2, 0x09, 0x99, 0x09, 0x18, 0xb5, 0x6c, 0xda, 0x1d, - 0xab, 0x4a, 0x5d, 0xb3, 0xed, 0x6f, 0xe9, 0x12, 0xa9, 0x9b, 0x2e, 0x2b, 0xe8, 0x1f, 0xe8, 0x3f, - 0xa8, 0x3c, 0x1e, 0x27, 0x0e, 0x38, 0xc0, 0xae, 0xab, 0x8c, 0x93, 0xef, 0x71, 0xce, 0x37, 0xc7, - 0x27, 0x60, 0xb6, 0x46, 0x68, 0x93, 0x50, 0x83, 0xb9, 0xc6, 0xc9, 0x4a, 0x15, 0x33, 0xb4, 0x62, - 0x50, 0xdc, 0x3e, 0xb1, 0x6b, 0x58, 0x6f, 0x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, 0x88, 0x02, 0x6c, - 0xa6, 0x58, 0xf7, 0xec, 0x09, 0x85, 0x3b, 0x4a, 0xf0, 0x8e, 0x96, 0x1e, 0xec, 0x48, 0x28, 0x85, - 0x5b, 0x42, 0x00, 0x16, 0xda, 0x04, 0xd5, 0x6b, 0x88, 0x32, 0xcf, 0xcc, 0x8f, 0x71, 0x1a, 0x0c, - 0x7b, 0x75, 0xa2, 0x53, 0x9e, 0xe3, 0xb8, 0x99, 0x64, 0xae, 0x89, 0x4e, 0xe1, 0x33, 0x30, 0xd4, - 0x24, 0x75, 0xcc, 0x13, 0xfc, 0x2b, 0xaf, 0x46, 0x34, 0xda, 0xd5, 0xda, 0x26, 0x75, 0x6c, 0x72, - 0xb4, 0xf6, 0x51, 0x02, 0x93, 0x7d, 0x1e, 0x22, 0xb5, 0x05, 0x10, 0x67, 0x2e, 0x37, 0x18, 0x18, - 0x5a, 0x9c, 0xb9, 0xb0, 0x04, 0x52, 0xa1, 0xcc, 0xc4, 0xed, 0x3d, 0x2e, 0x32, 0xd0, 0x8b, 0x4c, - 0x5b, 0x05, 0x7f, 0x97, 0xed, 0x66, 0xa7, 0x81, 0x58, 0x70, 0xb5, 0x8f, 0x2c, 0x40, 0xbb, 0x90, - 0x40, 0xba, 0x47, 0x15, 0xc5, 0x3f, 0x07, 0xa3, 0x16, 0xa2, 0x15, 0xdb, 0x39, 0x20, 0x42, 0x61, - 0x6e, 0x70, 0x49, 0x9b, 0x88, 0x6e, 0x39, 0x07, 0xc4, 0x1c, 0xb1, 0xfc, 0x03, 0x5c, 0x05, 0xc3, - 0x6d, 0x4c, 0x3b, 0x0d, 0x26, 0xda, 0x51, 0x07, 0x73, 0x4d, 0x8e, 0x33, 0x05, 0x5e, 0xd3, 0xc0, - 0x38, 0x9f, 0xc0, 0xa0, 0x07, 0x08, 0x86, 0x0e, 0x11, 0x3d, 0x14, 0xf3, 0xce, 0xcf, 0xda, 0x39, - 0x98, 0x10, 0x98, 0x3f, 0x91, 0xf4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0xb2, 0x06, 0xea, - 0xb9, 0x87, 0x76, 0x68, 0xa4, 0xfb, 0xdd, 0xc5, 0x1e, 0xe9, 0x1e, 0xb1, 0x8a, 0x03, 0x77, 0x38, - 0xc0, 0xbd, 0xf0, 0xe2, 0xeb, 0xb5, 0x22, 0x5d, 0x5d, 0x2b, 0xd2, 0x8f, 0x6b, 0x45, 0xfa, 0x74, - 0xa3, 0xc4, 0xae, 0x6e, 0x94, 0xd8, 0xf7, 0x1b, 0x25, 0xf6, 0x76, 0xc1, 0xb2, 0xd9, 0x61, 0xa7, - 0xaa, 0xd7, 0x48, 0x33, 0xe0, 0xfa, 0x1f, 0x4f, 0x68, 0xfd, 0xc8, 0x60, 0x67, 0x2d, 0xec, 0x89, - 0x55, 0x87, 0xf9, 0xdf, 0xcf, 0xd3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x8b, 0x8d, 0x36, - 0x55, 0x07, 0x00, 0x00, + // 762 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcd, 0x4e, 0xdb, 0x4a, + 0x18, 0x8d, 0x13, 0xc2, 0xcf, 0x04, 0xee, 0xcd, 0x1d, 0xb8, 0x57, 0x91, 0x2f, 0x35, 0xc6, 0xe1, + 0x27, 0x42, 0xaa, 0x2d, 0xd2, 0x2e, 0x58, 0x54, 0xaa, 0x48, 0x08, 0x08, 0xb5, 0xfc, 0xc8, 0xa1, + 0x8b, 0x76, 0x13, 0x4d, 0x92, 0xc1, 0x58, 0x24, 0x9e, 0x90, 0x99, 0x80, 0x11, 0x65, 0xd3, 0xee, + 0x58, 0x55, 0xea, 0x9a, 0x6d, 0x9f, 0xa5, 0x4b, 0xa4, 0x6e, 0xba, 0xac, 0xa0, 0x2f, 0xd0, 0x37, + 0xa8, 0x3c, 0x1e, 0x27, 0x0e, 0x38, 0xc0, 0xae, 0x2b, 0xcf, 0xc0, 0xf9, 0xce, 0x39, 0xdf, 0x99, + 0x99, 0x2f, 0x60, 0xa6, 0x46, 0x68, 0x93, 0x50, 0x83, 0xb9, 0xc6, 0xf1, 0x72, 0x15, 0x33, 0xb4, + 0x6c, 0x50, 0xdc, 0x3e, 0xb6, 0x6b, 0x58, 0x6f, 0xb5, 0x09, 0x23, 0xf0, 0x1f, 0x1f, 0xa0, 0x33, + 0x57, 0x17, 0x00, 0x79, 0xda, 0x22, 0xc4, 0x6a, 0x60, 0x03, 0xb5, 0x6c, 0x03, 0x39, 0x0e, 0x61, + 0x88, 0xd9, 0xc4, 0xa1, 0x7e, 0x81, 0x9c, 0x15, 0x8c, 0x55, 0x44, 0xb1, 0x81, 0xaa, 0x35, 0xbb, + 0x4b, 0xec, 0x6d, 0x04, 0x48, 0xbe, 0x2b, 0xcb, 0x5c, 0xf1, 0xbf, 0x29, 0x8b, 0x58, 0x84, 0x2f, + 0x0d, 0x6f, 0x25, 0xfe, 0xba, 0x14, 0xa6, 0x3d, 0xea, 0xe0, 0xf6, 0x69, 0xb7, 0xb2, 0x85, 0x2c, + 0xdb, 0xe1, 0x1e, 0x1e, 0x66, 0xd7, 0xda, 0x00, 0x6e, 0x60, 0xb6, 0xe7, 0xd2, 0xd2, 0x31, 0x76, + 0x98, 0x89, 0x8f, 0x3a, 0x98, 0x32, 0x38, 0x05, 0x92, 0xd8, 0xdb, 0x67, 0x24, 0x55, 0xca, 0x8d, + 0x99, 0xfe, 0x06, 0xae, 0x03, 0xd0, 0xe3, 0xce, 0xc4, 0x55, 0x29, 0x97, 0xca, 0x2f, 0xe8, 0x22, + 0x10, 0xcf, 0x88, 0xce, 0x8d, 0x04, 0xc1, 0xe8, 0xbb, 0xc8, 0xc2, 0x82, 0xd1, 0x0c, 0x55, 0x6a, + 0x57, 0x12, 0x98, 0xec, 0x13, 0xa5, 0x2d, 0xe2, 0x50, 0x0c, 0x17, 0x41, 0x82, 0xb9, 0x34, 0x23, + 0xa9, 0x89, 0x5c, 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06, 0x08, 0xc1, 0x39, + 0x2e, 0xa8, 0xc0, 0x69, 0x23, 0x6a, 0xa6, 0x1a, 0x67, 0xde, 0xf5, 0x38, 0x87, 0xef, 0x41, 0x2a, + 0xf4, 0x1e, 0xe1, 0xfc, 0x7d, 0xef, 0xb8, 0xa7, 0xbe, 0xf0, 0x10, 0x4c, 0x78, 0x50, 0xb8, 0x87, + 0x8c, 0xf6, 0x5f, 0xa4, 0x07, 0xea, 0xa9, 0x87, 0xa6, 0x6b, 0xa4, 0xfa, 0xdd, 0x91, 0x1f, 0xa9, + 0x1e, 0x31, 0xa4, 0x03, 0x75, 0x38, 0x40, 0xbd, 0xf0, 0xf2, 0xeb, 0xb5, 0x22, 0x5d, 0x5d, 0x2b, + 0xd2, 0x8f, 0x6b, 0x45, 0xfa, 0x74, 0xa3, 0xc4, 0xae, 0x6e, 0x94, 0xd8, 0xf7, 0x1b, 0x25, 0xf6, + 0x6e, 0xde, 0xb2, 0xd9, 0x41, 0xa7, 0xaa, 0xd7, 0x48, 0x33, 0xa8, 0xf5, 0x3f, 0x4f, 0x69, 0xfd, + 0xd0, 0x60, 0xa7, 0x2d, 0xec, 0x91, 0x55, 0x87, 0xf9, 0x0f, 0xd3, 0xb3, 0xdf, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x3d, 0x4b, 0xd2, 0x27, 0x8b, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -899,10 +899,15 @@ func (m *BroadcastTxRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if len(m.TxRaw) > 0 { - i -= len(m.TxRaw) - copy(dAtA[i:], m.TxRaw) - i = encodeVarintService(dAtA, i, uint64(len(m.TxRaw))) + if m.TxRaw != nil { + { + size, err := m.TxRaw.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0xa } @@ -1174,8 +1179,8 @@ func (m *BroadcastTxRequest) Size() (n int) { } var l int _ = l - l = len(m.TxRaw) - if l > 0 { + if m.TxRaw != nil { + l = m.TxRaw.Size() n += 1 + l + sovService(uint64(l)) } if m.Mode != 0 { @@ -1578,7 +1583,7 @@ func (m *BroadcastTxRequest) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TxRaw", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowService @@ -1588,24 +1593,26 @@ func (m *BroadcastTxRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthService } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthService } if postIndex > l { return io.ErrUnexpectedEOF } - m.TxRaw = append(m.TxRaw[:0], dAtA[iNdEx:postIndex]...) if m.TxRaw == nil { - m.TxRaw = []byte{} + m.TxRaw = &TxRaw{} + } + if err := m.TxRaw.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 2: diff --git a/x/auth/tx/service.go b/x/auth/tx/service.go index e6533cb15c54..a04bdab44056 100644 --- a/x/auth/tx/service.go +++ b/x/auth/tx/service.go @@ -7,6 +7,7 @@ import ( "strings" gogogrpc "github.com/gogo/protobuf/grpc" + "github.com/gogo/protobuf/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -204,11 +205,15 @@ func (s txServer) BroadcastTx(ctx context.Context, req *txtypes.BroadcastTxReque } clientCtx := s.clientCtx.WithBroadcastMode(normalizeBoradcastMode((req.Mode))) - resp, err := clientCtx.BroadcastTx(req.TxRaw) - + txBytes, err := proto.Marshal(req.TxRaw) + if err != nil { + return nil, err + } + resp, err := clientCtx.BroadcastTx(txBytes) if err != nil { return nil, err } + // Create a proto codec, we need it to unmarshal the tx bytes. cdc := codec.NewProtoCodec(s.clientCtx.InterfaceRegistry) var protoTx txtypes.Tx @@ -221,20 +226,8 @@ func (s txServer) BroadcastTx(ctx context.Context, req *txtypes.BroadcastTxReque return nil, err } return &txtypes.BroadcastTxResponse{ - Tx: &protoTx, - TxResponse: &sdk.TxResponse{ - Code: resp.Code, - Codespace: resp.Codespace, - Data: resp.Data, - GasUsed: resp.GasUsed, - GasWanted: resp.GasWanted, - Height: resp.Height, - Info: resp.Info, - RawLog: resp.RawLog, - Timestamp: resp.Timestamp, - TxHash: resp.TxHash, - Logs: resp.Logs, - }, + Tx: &protoTx, + TxResponse: resp, }, nil } diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index fab93493e7dd..45b095f011d3 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" clienttx "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/network" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -222,19 +223,26 @@ func (s IntegrationTestSuite) TestBroadcastTx() { err := authclient.SignTx(txFactory, val.ClientCtx, val.Moniker, txBuilder, false) s.Require().NoError(err) + // To get the TxRaw to be broadcasted, we unforunately need to first encode + // the tx into bytes, then decode it into TxRaw. txBytes, err := val.ClientCtx.TxConfig.TxEncoder()(txBuilder.GetTx()) - fmt.Println(string(txBytes)) + s.Require().NoError(err) + // Create a proto codec, we need it to unmarshal the tx bytes. + cdc := codec.NewProtoCodec(val.ClientCtx.InterfaceRegistry) + var txRaw tx.TxRaw + err = cdc.UnmarshalBinaryBare(txBytes, &txRaw) s.Require().NoError(err) // Query the tx via gRPC. grpcRes, err := s.queryClient.BroadcastTx( context.Background(), &tx.BroadcastTxRequest{ - Mode: tx.BroadcastMode_async, - TxRaw: txBytes, + Mode: tx.BroadcastMode_sync, + TxRaw: &txRaw, }, ) s.Require().NoError(err) + s.Require().Equal("foobar", grpcRes.Tx.Body.Memo) }