diff --git a/baseapp/abci.go b/baseapp/abci.go index d988ead0fcf4..b46afd6c73ef 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -379,9 +379,17 @@ func (app *BaseApp) snapshot(height int64) { // Query implements the ABCI interface. It delegates to CommitMultiStore if it // implements Queryable. -func (app *BaseApp) Query(req abci.RequestQuery) abci.ResponseQuery { +func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) { defer telemetry.MeasureSince(time.Now(), "abci", "query") + // Add panic recovery for all queries. + // ref: https://github.com/cosmos/cosmos-sdk/pull/8039 + defer func() { + if r := recover(); r != nil { + res = sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrPanic, "%v", r)) + } + }() + // when a client did not provide a query height, manually inject the latest if req.Height == 0 { req.Height = app.LastBlockHeight() diff --git a/baseapp/grpcserver.go b/baseapp/grpcserver.go index 74e8b8a21cac..a4342e0b8955 100644 --- a/baseapp/grpcserver.go +++ b/baseapp/grpcserver.go @@ -5,6 +5,8 @@ import ( "strconv" gogogrpc "github.com/gogo/protobuf/grpc" + grpcmiddleware "github.com/grpc-ecosystem/go-grpc-middleware" + grpcrecovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" @@ -74,7 +76,10 @@ func (app *BaseApp) RegisterGRPCServer(server gogogrpc.Server) { newMethods[i] = grpc.MethodDesc{ MethodName: method.MethodName, Handler: func(srv interface{}, ctx context.Context, dec func(interface{}) error, _ grpc.UnaryServerInterceptor) (interface{}, error) { - return methodHandler(srv, ctx, dec, interceptor) + return methodHandler(srv, ctx, dec, grpcmiddleware.ChainUnaryServer( + grpcrecovery.UnaryServerInterceptor(), + interceptor, + )) }, } } diff --git a/types/query/query.pb.go b/client/grpc/tmservice/query.pb.go similarity index 93% rename from types/query/query.pb.go rename to client/grpc/tmservice/query.pb.go index 266d337002e8..c08d33dc2d4a 100644 --- a/types/query/query.pb.go +++ b/client/grpc/tmservice/query.pb.go @@ -1,11 +1,12 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: cosmos/base/tendermint/v1beta1/query.proto -package query +package tmservice import ( context "context" fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -35,7 +36,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GetValidatorSetByHeightRequest struct { Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` // pagination defines an pagination for the request. - Pagination *PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *GetValidatorSetByHeightRequest) Reset() { *m = GetValidatorSetByHeightRequest{} } @@ -78,7 +79,7 @@ func (m *GetValidatorSetByHeightRequest) GetHeight() int64 { return 0 } -func (m *GetValidatorSetByHeightRequest) GetPagination() *PageRequest { +func (m *GetValidatorSetByHeightRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } @@ -90,7 +91,7 @@ type GetValidatorSetByHeightResponse struct { BlockHeight int64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` Validators []*Validator `protobuf:"bytes,2,rep,name=validators,proto3" json:"validators,omitempty"` // pagination defines an pagination for the response. - Pagination *PageResponse `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` + Pagination *query.PageResponse `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *GetValidatorSetByHeightResponse) Reset() { *m = GetValidatorSetByHeightResponse{} } @@ -140,7 +141,7 @@ func (m *GetValidatorSetByHeightResponse) GetValidators() []*Validator { return nil } -func (m *GetValidatorSetByHeightResponse) GetPagination() *PageResponse { +func (m *GetValidatorSetByHeightResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } @@ -150,7 +151,7 @@ func (m *GetValidatorSetByHeightResponse) GetPagination() *PageResponse { // GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method. type GetLatestValidatorSetRequest struct { // pagination defines an pagination for the request. - Pagination *PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *GetLatestValidatorSetRequest) Reset() { *m = GetLatestValidatorSetRequest{} } @@ -186,7 +187,7 @@ func (m *GetLatestValidatorSetRequest) XXX_DiscardUnknown() { var xxx_messageInfo_GetLatestValidatorSetRequest proto.InternalMessageInfo -func (m *GetLatestValidatorSetRequest) GetPagination() *PageRequest { +func (m *GetLatestValidatorSetRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } @@ -198,7 +199,7 @@ type GetLatestValidatorSetResponse struct { BlockHeight int64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` Validators []*Validator `protobuf:"bytes,2,rep,name=validators,proto3" json:"validators,omitempty"` // pagination defines an pagination for the response. - Pagination *PageResponse `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` + Pagination *query.PageResponse `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *GetLatestValidatorSetResponse) Reset() { *m = GetLatestValidatorSetResponse{} } @@ -248,7 +249,7 @@ func (m *GetLatestValidatorSetResponse) GetValidators() []*Validator { return nil } -func (m *GetLatestValidatorSetResponse) GetPagination() *PageResponse { +func (m *GetLatestValidatorSetResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } @@ -864,72 +865,72 @@ func init() { } var fileDescriptor_40c93fb3ef485c5d = []byte{ - // 1031 bytes of a gzipped FileDescriptorProto + // 1040 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0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 0xb2, 0xa1, 0x8c, 0xc3, 0x30, 0x21, 0x42, 0x28, 0xfe, - 0xd7, 0xfc, 0xec, 0x13, 0x2d, 0x42, 0x99, 0xf7, 0x5a, 0xc1, 0x11, 0xe9, 0xab, 0x46, 0xac, 0xf8, - 0x33, 0xbc, 0xd7, 0x7a, 0x40, 0xfa, 0xa9, 0xee, 0x63, 0x26, 0x69, 0x1c, 0x05, 0x9c, 0x7d, 0x49, - 0x12, 0xc5, 0xa5, 0xe4, 0x57, 0xb5, 0x6d, 0x2f, 0x35, 0xa1, 0x35, 0x98, 0xe7, 0x09, 0xe3, 0x4c, - 0x90, 0x24, 0xe0, 0x09, 0x65, 0x09, 0x95, 0x7d, 0xfb, 0x8a, 0x8a, 0x9b, 0xcb, 0x1c, 0x7b, 0xc6, - 0xee, 0x34, 0x60, 0x71, 0x87, 0xc8, 0xad, 0xb4, 0x6c, 0x63, 0xde, 0x13, 0xe7, 0x6b, 0xb0, 0xcf, - 0x42, 0xcc, 0xb1, 0xbc, 0x0e, 0xb3, 0xfa, 0x58, 0x68, 0x68, 0x8e, 0xff, 0x66, 0xbe, 0xca, 0xfa, - 0x56, 0x2b, 0xe8, 0xee, 0xb6, 0x5f, 0x56, 0xa1, 0xbb, 0x21, 0x5a, 0x87, 0xab, 0x6a, 0x69, 0x2e, - 0xdd, 0xe2, 0x05, 0x10, 0x5f, 0x47, 0x39, 0x8b, 0xf0, 0xca, 0xa0, 0x39, 0xb4, 0x43, 0x33, 0x76, - 0x1e, 0xc3, 0x8d, 0xe7, 0x1d, 0xff, 0x25, 0xaf, 0x05, 0x98, 0xdf, 0x21, 0x72, 0xbf, 0x1f, 0xb7, - 0x69, 0x1c, 0x65, 0x9c, 0x5c, 0x40, 0x79, 0xa3, 0xe1, 0x63, 0x43, 0x59, 0x68, 0x93, 0xa2, 0x33, - 0xeb, 0x67, 0x9f, 0xce, 0x75, 0x15, 0xff, 0x90, 0x85, 0x64, 0x37, 0x3e, 0x60, 0x59, 0x96, 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, 0x89, 0xd5, 0xcf, 0x06, 0x0f, 0x8e, 0x9c, + 0x76, 0x87, 0xe0, 0x48, 0x38, 0x61, 0xcc, 0xda, 0x8e, 0xe8, 0x72, 0x35, 0xc6, 0x5a, 0x45, 0xf9, + 0x74, 0xdf, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x82, 0x6b, 0xb0, 0xbd, 0xc0, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2181,7 +2182,7 @@ func (m *GetValidatorSetByHeightRequest) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pagination == nil { - m.Pagination = &PageRequest{} + m.Pagination = &query.PageRequest{} } if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2323,7 +2324,7 @@ func (m *GetValidatorSetByHeightResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pagination == nil { - m.Pagination = &PageResponse{} + m.Pagination = &query.PageResponse{} } if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2412,7 +2413,7 @@ func (m *GetLatestValidatorSetRequest) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pagination == nil { - m.Pagination = &PageRequest{} + m.Pagination = &query.PageRequest{} } if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2554,7 +2555,7 @@ func (m *GetLatestValidatorSetResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pagination == nil { - m.Pagination = &PageResponse{} + m.Pagination = &query.PageResponse{} } if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/types/query/query.pb.gw.go b/client/grpc/tmservice/query.pb.gw.go similarity index 99% rename from types/query/query.pb.gw.go rename to client/grpc/tmservice/query.pb.gw.go index 01b943030d1d..1fcd85268212 100644 --- a/types/query/query.pb.gw.go +++ b/client/grpc/tmservice/query.pb.gw.go @@ -2,11 +2,11 @@ // source: cosmos/base/tendermint/v1beta1/query.proto /* -Package query is a reverse proxy. +Package tmservice is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package query +package tmservice import ( "context" diff --git a/client/grpc/tmservice/service.go b/client/grpc/tmservice/service.go index b1198eb67331..b4d9f8c95261 100644 --- a/client/grpc/tmservice/service.go +++ b/client/grpc/tmservice/service.go @@ -21,10 +21,10 @@ type queryServer struct { interfaceRegistry codectypes.InterfaceRegistry } -var _ qtypes.ServiceServer = queryServer{} +var _ ServiceServer = queryServer{} // NewQueryServer creates a new tendermint query server. -func NewQueryServer(clientCtx client.Context, interfaceRegistry codectypes.InterfaceRegistry) qtypes.ServiceServer { +func NewQueryServer(clientCtx client.Context, interfaceRegistry codectypes.InterfaceRegistry) ServiceServer { return queryServer{ clientCtx: clientCtx, interfaceRegistry: interfaceRegistry, @@ -32,18 +32,18 @@ func NewQueryServer(clientCtx client.Context, interfaceRegistry codectypes.Inter } // GetSyncing implements ServiceServer.GetSyncing -func (s queryServer) GetSyncing(_ context.Context, _ *qtypes.GetSyncingRequest) (*qtypes.GetSyncingResponse, error) { +func (s queryServer) GetSyncing(_ context.Context, _ *GetSyncingRequest) (*GetSyncingResponse, error) { status, err := getNodeStatus(s.clientCtx) if err != nil { return nil, err } - return &qtypes.GetSyncingResponse{ + return &GetSyncingResponse{ Syncing: status.SyncInfo.CatchingUp, }, nil } // GetLatestBlock implements ServiceServer.GetLatestBlock -func (s queryServer) GetLatestBlock(context.Context, *qtypes.GetLatestBlockRequest) (*qtypes.GetLatestBlockResponse, error) { +func (s queryServer) GetLatestBlock(context.Context, *GetLatestBlockRequest) (*GetLatestBlockResponse, error) { status, err := getBlock(s.clientCtx, nil) if err != nil { return nil, err @@ -55,14 +55,14 @@ func (s queryServer) GetLatestBlock(context.Context, *qtypes.GetLatestBlockReque return nil, err } - return &qtypes.GetLatestBlockResponse{ + return &GetLatestBlockResponse{ BlockId: &protoBlockID, Block: protoBlock, }, nil } // GetBlockByHeight implements ServiceServer.GetBlockByHeight -func (s queryServer) GetBlockByHeight(_ context.Context, req *qtypes.GetBlockByHeightRequest) (*qtypes.GetBlockByHeightResponse, error) { +func (s queryServer) GetBlockByHeight(_ context.Context, req *GetBlockByHeightRequest) (*GetBlockByHeightResponse, error) { chainHeight, err := rpc.GetChainHeight(s.clientCtx) if err != nil { return nil, err @@ -81,14 +81,14 @@ func (s queryServer) GetBlockByHeight(_ context.Context, req *qtypes.GetBlockByH if err != nil { return nil, err } - return &qtypes.GetBlockByHeightResponse{ + return &GetBlockByHeightResponse{ BlockId: &protoBlockID, Block: protoBlock, }, nil } // GetLatestValidatorSet implements ServiceServer.GetLatestValidatorSet -func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *qtypes.GetLatestValidatorSetRequest) (*qtypes.GetLatestValidatorSetResponse, error) { +func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *GetLatestValidatorSetRequest) (*GetLatestValidatorSetResponse, error) { page, limit, err := qtypes.ParsePagination(req.Pagination) if err != nil { return nil, err @@ -99,13 +99,13 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *qtypes.GetL return nil, err } - outputValidatorsRes := &qtypes.GetLatestValidatorSetResponse{ + outputValidatorsRes := &GetLatestValidatorSetResponse{ BlockHeight: validatorsRes.BlockHeight, - Validators: make([]*qtypes.Validator, len(validatorsRes.Validators)), + Validators: make([]*Validator, len(validatorsRes.Validators)), } for i, validator := range validatorsRes.Validators { - outputValidatorsRes.Validators[i] = &qtypes.Validator{ + outputValidatorsRes.Validators[i] = &Validator{ Address: validator.Address, ProposerPriority: validator.ProposerPriority, PubKey: validator.PubKey, @@ -116,7 +116,7 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *qtypes.GetL } // GetValidatorSetByHeight implements ServiceServer.GetValidatorSetByHeight -func (s queryServer) GetValidatorSetByHeight(ctx context.Context, req *qtypes.GetValidatorSetByHeightRequest) (*qtypes.GetValidatorSetByHeightResponse, error) { +func (s queryServer) GetValidatorSetByHeight(ctx context.Context, req *GetValidatorSetByHeightRequest) (*GetValidatorSetByHeightResponse, error) { page, limit, err := qtypes.ParsePagination(req.Pagination) if err != nil { return nil, err @@ -136,13 +136,13 @@ func (s queryServer) GetValidatorSetByHeight(ctx context.Context, req *qtypes.Ge return nil, err } - outputValidatorsRes := &qtypes.GetValidatorSetByHeightResponse{ + outputValidatorsRes := &GetValidatorSetByHeightResponse{ BlockHeight: validatorsRes.BlockHeight, - Validators: make([]*qtypes.Validator, len(validatorsRes.Validators)), + Validators: make([]*Validator, len(validatorsRes.Validators)), } for i, validator := range validatorsRes.Validators { - outputValidatorsRes.Validators[i] = &qtypes.Validator{ + outputValidatorsRes.Validators[i] = &Validator{ Address: validator.Address, ProposerPriority: validator.ProposerPriority, PubKey: validator.PubKey, @@ -153,7 +153,7 @@ func (s queryServer) GetValidatorSetByHeight(ctx context.Context, req *qtypes.Ge } // GetNodeInfo implements ServiceServer.GetNodeInfo -func (s queryServer) GetNodeInfo(ctx context.Context, req *qtypes.GetNodeInfoRequest) (*qtypes.GetNodeInfoResponse, error) { +func (s queryServer) GetNodeInfo(ctx context.Context, req *GetNodeInfoRequest) (*GetNodeInfoResponse, error) { status, err := getNodeStatus(s.clientCtx) if err != nil { return nil, err @@ -162,19 +162,19 @@ func (s queryServer) GetNodeInfo(ctx context.Context, req *qtypes.GetNodeInfoReq protoNodeInfo := status.NodeInfo.ToProto() nodeInfo := version.NewInfo() - deps := make([]*qtypes.Module, len(nodeInfo.BuildDeps)) + deps := make([]*Module, len(nodeInfo.BuildDeps)) for i, dep := range nodeInfo.BuildDeps { - deps[i] = &qtypes.Module{ + deps[i] = &Module{ Path: dep.Path, Sum: dep.Sum, Version: dep.Version, } } - resp := qtypes.GetNodeInfoResponse{ + resp := GetNodeInfoResponse{ DefaultNodeInfo: protoNodeInfo, - ApplicationVersion: &qtypes.VersionInfo{ + ApplicationVersion: &VersionInfo{ AppName: nodeInfo.AppName, Name: nodeInfo.Name, GitCommit: nodeInfo.GitCommit, @@ -193,7 +193,7 @@ func RegisterTendermintService( clientCtx client.Context, interfaceRegistry codectypes.InterfaceRegistry, ) { - qtypes.RegisterServiceServer( + RegisterServiceServer( qrt, NewQueryServer(clientCtx, interfaceRegistry), ) @@ -202,5 +202,5 @@ func RegisterTendermintService( // RegisterGRPCGatewayRoutes mounts the tendermint service's GRPC-gateway routes on the // given Mux. func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux) { - qtypes.RegisterServiceHandlerClient(context.Background(), mux, qtypes.NewServiceClient(clientConn)) + RegisterServiceHandlerClient(context.Background(), mux, NewServiceClient(clientConn)) } diff --git a/client/grpc/tmservice/service_test.go b/client/grpc/tmservice/service_test.go index bb145e6e21ca..2210486f4427 100644 --- a/client/grpc/tmservice/service_test.go +++ b/client/grpc/tmservice/service_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/suite" + "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/testutil/network" qtypes "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/types/rest" @@ -19,7 +20,7 @@ type IntegrationTestSuite struct { cfg network.Config network *network.Network - queryClient qtypes.ServiceClient + queryClient tmservice.ServiceClient } func (s *IntegrationTestSuite) SetupSuite() { @@ -36,7 +37,7 @@ func (s *IntegrationTestSuite) SetupSuite() { _, err := s.network.WaitForHeight(1) s.Require().NoError(err) - s.queryClient = qtypes.NewServiceClient(s.network.Validators[0].ClientCtx) + s.queryClient = tmservice.NewServiceClient(s.network.Validators[0].ClientCtx) } func (s *IntegrationTestSuite) TearDownSuite() { @@ -47,13 +48,13 @@ func (s *IntegrationTestSuite) TearDownSuite() { func (s IntegrationTestSuite) TestQueryNodeInfo() { val := s.network.Validators[0] - res, err := s.queryClient.GetNodeInfo(context.Background(), &qtypes.GetNodeInfoRequest{}) + res, err := s.queryClient.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{}) s.Require().NoError(err) s.Require().Equal(res.ApplicationVersion.AppName, version.NewInfo().AppName) restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/node_info", val.APIAddress)) s.Require().NoError(err) - var getInfoRes qtypes.GetNodeInfoResponse + var getInfoRes tmservice.GetNodeInfoResponse s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &getInfoRes)) s.Require().Equal(getInfoRes.ApplicationVersion.AppName, version.NewInfo().AppName) } @@ -61,35 +62,35 @@ func (s IntegrationTestSuite) TestQueryNodeInfo() { func (s IntegrationTestSuite) TestQuerySyncing() { val := s.network.Validators[0] - _, err := s.queryClient.GetSyncing(context.Background(), &qtypes.GetSyncingRequest{}) + _, err := s.queryClient.GetSyncing(context.Background(), &tmservice.GetSyncingRequest{}) s.Require().NoError(err) restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/syncing", val.APIAddress)) s.Require().NoError(err) - var syncingRes qtypes.GetSyncingResponse + var syncingRes tmservice.GetSyncingResponse s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &syncingRes)) } func (s IntegrationTestSuite) TestQueryLatestBlock() { val := s.network.Validators[0] - _, err := s.queryClient.GetLatestBlock(context.Background(), &qtypes.GetLatestBlockRequest{}) + _, err := s.queryClient.GetLatestBlock(context.Background(), &tmservice.GetLatestBlockRequest{}) s.Require().NoError(err) restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/blocks/latest", val.APIAddress)) s.Require().NoError(err) - var blockInfoRes qtypes.GetLatestBlockResponse + var blockInfoRes tmservice.GetLatestBlockResponse s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &blockInfoRes)) } func (s IntegrationTestSuite) TestQueryBlockByHeight() { val := s.network.Validators[0] - _, err := s.queryClient.GetBlockByHeight(context.Background(), &qtypes.GetBlockByHeightRequest{Height: 1}) + _, err := s.queryClient.GetBlockByHeight(context.Background(), &tmservice.GetBlockByHeightRequest{Height: 1}) s.Require().NoError(err) restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/blocks/%d", val.APIAddress, 1)) s.Require().NoError(err) - var blockInfoRes qtypes.GetBlockByHeightResponse + var blockInfoRes tmservice.GetBlockByHeightResponse s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &blockInfoRes)) } @@ -97,13 +98,13 @@ func (s IntegrationTestSuite) TestQueryLatestValidatorSet() { val := s.network.Validators[0] // nil pagination - _, err := s.queryClient.GetLatestValidatorSet(context.Background(), &qtypes.GetLatestValidatorSetRequest{ + _, err := s.queryClient.GetLatestValidatorSet(context.Background(), &tmservice.GetLatestValidatorSetRequest{ Pagination: nil, }) s.Require().NoError(err) //with pagination - _, err = s.queryClient.GetLatestValidatorSet(context.Background(), &qtypes.GetLatestValidatorSetRequest{Pagination: &qtypes.PageRequest{ + _, err = s.queryClient.GetLatestValidatorSet(context.Background(), &tmservice.GetLatestValidatorSetRequest{Pagination: &qtypes.PageRequest{ Offset: 0, Limit: 10, }}) @@ -116,7 +117,7 @@ func (s IntegrationTestSuite) TestQueryLatestValidatorSet() { // rest request with pagination restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validators/latest?pagination.offset=%d&pagination.limit=%d", val.APIAddress, 0, 1)) s.Require().NoError(err) - var validatorSetRes qtypes.GetLatestValidatorSetResponse + var validatorSetRes tmservice.GetLatestValidatorSetResponse s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &validatorSetRes)) } @@ -124,13 +125,13 @@ func (s IntegrationTestSuite) TestQueryValidatorSetByHeight() { val := s.network.Validators[0] // nil pagination - _, err := s.queryClient.GetValidatorSetByHeight(context.Background(), &qtypes.GetValidatorSetByHeightRequest{ + _, err := s.queryClient.GetValidatorSetByHeight(context.Background(), &tmservice.GetValidatorSetByHeightRequest{ Height: 1, Pagination: nil, }) s.Require().NoError(err) - _, err = s.queryClient.GetValidatorSetByHeight(context.Background(), &qtypes.GetValidatorSetByHeightRequest{ + _, err = s.queryClient.GetValidatorSetByHeight(context.Background(), &tmservice.GetValidatorSetByHeightRequest{ Height: 1, Pagination: &qtypes.PageRequest{ Offset: 0, @@ -144,7 +145,7 @@ func (s IntegrationTestSuite) TestQueryValidatorSetByHeight() { // rest query with pagination restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validators/%d?pagination.offset=%d&pagination.limit=%d", val.APIAddress, 1, 0, 1)) - var validatorSetRes qtypes.GetValidatorSetByHeightResponse + var validatorSetRes tmservice.GetValidatorSetByHeightResponse s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &validatorSetRes)) } diff --git a/go.mod b/go.mod index 39e28042489b..8163ebbfbe62 100644 --- a/go.mod +++ b/go.mod @@ -23,6 +23,7 @@ require ( github.com/golang/snappy v0.0.2 // indirect github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 + github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/golang-lru v0.5.4 github.com/magiconair/properties v1.8.4 diff --git a/go.sum b/go.sum index da0703bd69d8..b6ae47006000 100644 --- a/go.sum +++ b/go.sum @@ -247,6 +247,7 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.1/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 h1:FlFbCRLd5Jr4iYXZufAvgWN6Ao0JrI5chLINnUXDDr0= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= diff --git a/proto/cosmos/base/tendermint/v1beta1/query.proto b/proto/cosmos/base/tendermint/v1beta1/query.proto index b5220231ac0b..640522e7a9f2 100644 --- a/proto/cosmos/base/tendermint/v1beta1/query.proto +++ b/proto/cosmos/base/tendermint/v1beta1/query.proto @@ -8,7 +8,7 @@ import "tendermint/types/block.proto"; import "tendermint/types/types.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/types/query"; +option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/tmservice"; // Service defines the gRPC querier service for tendermint queries. service Service { diff --git a/server/grpc/server_test.go b/server/grpc/server_test.go index bfa39d818523..9afa0b750b04 100644 --- a/server/grpc/server_test.go +++ b/server/grpc/server_test.go @@ -11,13 +11,14 @@ import ( "github.com/stretchr/testify/suite" "google.golang.org/grpc" "google.golang.org/grpc/metadata" - rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" "github.com/cosmos/cosmos-sdk/testutil/network" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" + "github.com/cosmos/cosmos-sdk/types/tx" + txtypes "github.com/cosmos/cosmos-sdk/types/tx" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -99,6 +100,19 @@ func (s *IntegrationTestSuite) TestGRPCServer() { } // Make sure the following services are present s.Require().True(servicesMap["cosmos.bank.v1beta1.Query"]) + + // Query the tx via gRPC without pagination. This used to panic, see + // https://github.com/cosmos/cosmos-sdk/issues/8038. + txServiceClient := txtypes.NewServiceClient(conn) + _, err = txServiceClient.GetTxsEvent( + context.Background(), + &tx.GetTxsEventRequest{ + Event: "message.action=send", + }, + ) + // TODO Once https://github.com/cosmos/cosmos-sdk/pull/8029 is merged, this + // should not error anymore. + s.Require().Error(err) } // Test and enforce that we upfront reject any connections to baseapp containing diff --git a/types/errors/abci.go b/types/errors/abci.go index f297e4ca6987..df85f6bc89df 100644 --- a/types/errors/abci.go +++ b/types/errors/abci.go @@ -151,12 +151,14 @@ func errIsNil(err error) bool { return false } +var errPanicWithMsg = Wrapf(ErrPanic, "panic message redacted to hide potentially sensitive system info") + // Redact replaces an error that is not initialized as an ABCI Error with a // generic internal error instance. If the error is an ABCI Error, that error is // simply returned. func Redact(err error) error { if ErrPanic.Is(err) { - return ErrPanic + return errPanicWithMsg } if abciCode(err) == internalABCICode { return errInternal diff --git a/types/errors/abci_test.go b/types/errors/abci_test.go index 18d6b1f2e693..02c12e7bbdd6 100644 --- a/types/errors/abci_test.go +++ b/types/errors/abci_test.go @@ -171,7 +171,7 @@ func (s *abciTestSuite) TestRedact() { }{ "panic looses message": { err: Wrap(ErrPanic, "some secret stack trace"), - changed: ErrPanic, + changed: errPanicWithMsg, }, "sdk errors untouched": { err: Wrap(ErrUnauthorized, "cannot drop db"), @@ -233,7 +233,7 @@ func (s *abciTestSuite) TestABCIInfoSerializeErr() { }, "redact in default encoder": { src: myPanic, - exp: "panic", + exp: "panic message redacted to hide potentially sensitive system info: panic", }, "do not redact in debug encoder": { src: myPanic, diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index a1bacb55cb40..54fe14fd72f3 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -127,7 +127,8 @@ func (s IntegrationTestSuite) TestGetTxEvents() { // Query the tx via gRPC. grpcRes, err := s.queryClient.GetTxsEvent( context.Background(), - &tx.GetTxsEventRequest{Event: "message.action=send", + &tx.GetTxsEventRequest{ + Event: "message.action=send", Pagination: &query.PageRequest{ CountTotal: false, Offset: 0, @@ -139,14 +140,26 @@ func (s IntegrationTestSuite) TestGetTxEvents() { s.Require().Equal(len(grpcRes.Txs), 1) s.Require().Equal("foobar", grpcRes.Txs[0].Body.Memo) + // Query the tx via gRPC without pagination. This used to panic, see + // https://github.com/cosmos/cosmos-sdk/issues/8038. + grpcRes, err = s.queryClient.GetTxsEvent( + context.Background(), + &tx.GetTxsEventRequest{ + Event: "message.action=send", + }, + ) + // TODO Once https://github.com/cosmos/cosmos-sdk/pull/8029 is merged, this + // should not error anymore. + s.Require().Error(err) + // Query the tx via grpc-gateway. restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/txs?event=%s&pagination.offset=%d&pagination.limit=%d", val.APIAddress, "message.action=send", 0, 1)) s.Require().NoError(err) var getTxRes tx.GetTxsEventResponse s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &getTxRes)) - s.Require().Equal(len(grpcRes.Txs), 1) + s.Require().Equal(len(getTxRes.Txs), 1) s.Require().Equal("foobar", getTxRes.Txs[0].Body.Memo) - s.Require().NotZero(grpcRes.TxResponses[0].Height) + s.Require().NotZero(getTxRes.TxResponses[0].Height) } func (s IntegrationTestSuite) TestGetTx() {