Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename GRPCRouter #8079

Merged
merged 4 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion baseapp/grpcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

func TestGRPCRouter(t *testing.T) {
func TestGRPCGatewayRouter(t *testing.T) {
qr := baseapp.NewGRPCQueryRouter()
interfaceRegistry := testdata.NewTestInterfaceRegistry()
qr.SetInterfaceRegistry(interfaceRegistry)
Expand Down
10 changes: 5 additions & 5 deletions server/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (

// Server defines the server's API interface.
type Server struct {
Router *mux.Router
GRPCRouter *runtime.ServeMux
ClientCtx client.Context
Router *mux.Router
Copy link
Contributor

@amaury1093 amaury1093 Dec 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're at it, we could also rename this one to LegacyAPIRouter

edit: oh wait, or is that the main router, i.e. holding both legacy routes and GRPCGatewayRouter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can rename this to LegacyRouter. There already seems to be a GRPCGatewayRouter for the gateway.

Copy link
Collaborator Author

@anilcse anilcse Dec 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's the main router, we cannot rename it as Legacy

Edit: @alexanderbez not really, we are registering GRPCGatewayRoutes on this Router

GRPCGatewayRouter *runtime.ServeMux
ClientCtx client.Context

logger log.Logger
metrics *telemetry.Metrics
Expand Down Expand Up @@ -63,7 +63,7 @@ func New(clientCtx client.Context, logger log.Logger) *Server {
Router: mux.NewRouter(),
ClientCtx: clientCtx,
logger: logger,
GRPCRouter: runtime.NewServeMux(
GRPCGatewayRouter: runtime.NewServeMux(
// Custom marshaler option is required for gogo proto
runtime.WithMarshalerOption(runtime.MIMEWildcard, marshalerOption),

Expand Down Expand Up @@ -124,7 +124,7 @@ func (s *Server) Close() error {
}

func (s *Server) registerGRPCGatewayRoutes() {
s.Router.PathPrefix("/").Handler(s.GRPCRouter)
s.Router.PathPrefix("/").Handler(s.GRPCGatewayRouter)
}

func (s *Server) registerMetrics() {
Expand Down
3 changes: 2 additions & 1 deletion server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"strings"
"testing"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client/flags"
)

var CancelledInPreRun = errors.New("Canelled in prerun")
Expand Down
6 changes: 3 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,13 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon
// Register legacy tx routes.
authrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router)
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// register swagger API from root so that other applications can override easily
if apiConfig.Swagger {
Expand Down
3 changes: 2 additions & 1 deletion store/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tm-db"

anilcse marked this conversation as resolved.
Show resolved Hide resolved
tmstrings "github.com/tendermint/tendermint/libs/strings"

snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
"github.com/cosmos/cosmos-sdk/types/kv"
tmstrings "github.com/tendermint/tendermint/libs/strings"
)

type Store interface {
Expand Down
3 changes: 2 additions & 1 deletion types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"sort"
"strings"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/gogo/protobuf/jsonpb"
proto "github.com/gogo/protobuf/proto"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/cosmos/cosmos-sdk/codec"
)

// ----------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion types/tx_msg.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package types

import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/gogo/protobuf/proto"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)

type (
Expand Down
3 changes: 2 additions & 1 deletion x/bank/client/rest/rest.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package rest

import (
"github.com/cosmos/cosmos-sdk/client/rest"
"github.com/gorilla/mux"

"github.com/cosmos/cosmos-sdk/client/rest"

"github.com/cosmos/cosmos-sdk/client"
)

Expand Down
1 change: 1 addition & 0 deletions x/distribution/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/armon/go-metrics"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
Expand Down
2 changes: 1 addition & 1 deletion x/evidence/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *IntegrationTestSuite) TestGetQueryCmd() {
expectedOutput string
expectErr bool
}{
"non-existant evidence": {
"non-existent evidence": {
[]string{"DF0C23E8634E480F84B9D5674A7CDC9816466DEC28A3358F73260F68D28D7660"},
"evidence DF0C23E8634E480F84B9D5674A7CDC9816466DEC28A3358F73260F68D28D7660 not found",
true,
Expand Down
3 changes: 2 additions & 1 deletion x/gov/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package keeper_test
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
)

var (
Expand Down
1 change: 1 addition & 0 deletions x/gov/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"

"github.com/armon/go-metrics"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
Expand Down
10 changes: 5 additions & 5 deletions x/ibc/core/02-client/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (suite *KeeperTestSuite) TestQueryClientState() {
{
"success",
func() {
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
suite.keeper.SetClientState(suite.ctx, testClientID, clientState)

var err error
Expand Down Expand Up @@ -183,10 +183,10 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
"invalid height",
func() {
req = &types.QueryConsensusStateRequest{
ClientId: testClientID,
ClientId: testClientID,
RevisionNumber: 0,
RevisionHeight: 0,
LatestHeight: false,
LatestHeight: false,
}
},
false,
Expand All @@ -204,7 +204,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
{
"success latest height",
func() {
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false)
cs := ibctmtypes.NewConsensusState(
suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), nil,
)
Expand Down Expand Up @@ -235,7 +235,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() {
suite.Require().NoError(err)

req = &types.QueryConsensusStateRequest{
ClientId: testClientID,
ClientId: testClientID,
RevisionNumber: 0,
RevisionHeight: height,
}
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/02-client/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"math"
"testing"

"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
)

// tests ParseClientIdentifier and IsValidClientID
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/02-client/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package types
import (
"testing"

"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
)

func TestValidateParams(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions x/ibc/core/03-connection/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
"invalid connection ID",
func() {
req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: "",
ConnectionId: "",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -349,7 +349,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
"connection not found",
func() {
req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: "test-connection-id",
ConnectionId: "test-connection-id",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -362,7 +362,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
_, _, connA, _, _, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED)

req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: connA.ID,
ConnectionId: connA.ID,
RevisionNumber: 0,
RevisionHeight: uint64(suite.chainA.GetContext().BlockHeight()), // use current height
}
Expand All @@ -379,7 +379,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() {
expClientID = clientA

req = &types.QueryConnectionConsensusStateRequest{
ConnectionId: connA.ID,
ConnectionId: connA.ID,
RevisionNumber: clientState.GetLatestHeight().GetRevisionNumber(),
RevisionHeight: clientState.GetLatestHeight().GetRevisionHeight(),
}
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/03-connection/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"math"
"testing"

"github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
)

// tests ParseConnectionSequence and IsValidConnectionID
Expand Down
24 changes: 12 additions & 12 deletions x/ibc/core/04-channel/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
"invalid port ID",
func() {
req = &types.QueryChannelConsensusStateRequest{
PortId: "",
ChannelId: "test-channel-id",
PortId: "",
ChannelId: "test-channel-id",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -449,8 +449,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
"invalid channel ID",
func() {
req = &types.QueryChannelConsensusStateRequest{
PortId: "test-port-id",
ChannelId: "",
PortId: "test-port-id",
ChannelId: "",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -461,8 +461,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
"channel not found",
func() {
req = &types.QueryChannelConsensusStateRequest{
PortId: "test-port-id",
ChannelId: "test-channel-id",
PortId: "test-port-id",
ChannelId: "test-channel-id",
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -482,8 +482,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
suite.chainA.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), channelA.PortID, channelA.ID, channel)

req = &types.QueryChannelConsensusStateRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PortId: channelA.PortID,
ChannelId: channelA.ID,
RevisionNumber: 0,
RevisionHeight: 1,
}
Expand All @@ -495,8 +495,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)

req = &types.QueryChannelConsensusStateRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PortId: channelA.PortID,
ChannelId: channelA.ID,
RevisionNumber: 0,
RevisionHeight: uint64(suite.chainA.GetContext().BlockHeight()), // use current height
}
Expand All @@ -516,8 +516,8 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() {
expClientID = clientA

req = &types.QueryChannelConsensusStateRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PortId: channelA.PortID,
ChannelId: channelA.ID,
RevisionNumber: clientState.GetLatestHeight().GetRevisionNumber(),
RevisionHeight: clientState.GetLatestHeight().GetRevisionHeight(),
}
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/04-channel/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package types_test
import (
"testing"

"github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"
)

// tests ParseChannelSequence and IsValidChannelID
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/23-commitment/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package types

import (
ics23 "github.com/confio/ics23/go"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
crypto "github.com/tendermint/tendermint/proto/tendermint/crypto"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// ConvertProofs converts crypto.ProofOps into MerkleProof
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/core/23-commitment/types/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package types_test
import (
"fmt"

"github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
crypto "github.com/tendermint/tendermint/proto/tendermint/crypto"

"github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types"
)

func (suite *MerkleTestSuite) TestConvertProofs() {
Expand Down
5 changes: 3 additions & 2 deletions x/ibc/core/24-host/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"math"
"testing"

"github.com/stretchr/testify/require"

connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
"github.com/stretchr/testify/require"
)

func TestParseIdentifier(t *testing.T) {
Expand All @@ -23,7 +24,7 @@ func TestParseIdentifier(t *testing.T) {
// one above uint64 max
{"invalid uint64", "connection-18446744073709551616", "connection-", 0, false},
// uint64 == 20 characters
{"invalid large sequence", "connection-2345682193567182931243", "conenction-", 0, false},
{"invalid large sequence", "connection-2345682193567182931243", "connection-", 0, false},
{"capital prefix", "Connection-0", "connection-", 0, false},
{"double prefix", "connection-connection-0", "connection-", 0, false},
{"doesn't have prefix", "connection-0", "prefix", 0, false},
Expand Down
1 change: 1 addition & 0 deletions x/ibc/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/armon/go-metrics"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down
Loading