Skip to content

Commit

Permalink
WIP - debugging grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit committed Apr 16, 2024
1 parent 671ead5 commit b2b17ed
Show file tree
Hide file tree
Showing 8 changed files with 584 additions and 584 deletions.
540 changes: 540 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion integration_tests/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (s *IntegrationTestSuite) initValidatorConfigs() {
valConfig.P2P.AddrBookStrict = false
valConfig.P2P.ExternalAddress = fmt.Sprintf("%s:%d", val.instanceName(), 26656)
valConfig.RPC.ListenAddress = "tcp://0.0.0.0:26657"
valConfig.RPC.GRPCListenAddress = "tcp://0.0.0.0:9090"
valConfig.RPC.GRPCListenAddress = "tcp://0.0.0.0:9090"
valConfig.StateSync.Enable = false
valConfig.LogLevel = "info"

Expand Down
29 changes: 21 additions & 8 deletions module/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"path/filepath"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/errors"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
Expand All @@ -21,6 +23,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/types"
ccodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/runtime"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -124,7 +127,7 @@ var (
genutil.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
consensus.AppModuleBasic{},
consensus.AppModuleBasic{},
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distr.AppModuleBasic{},
Expand Down Expand Up @@ -283,8 +286,8 @@ func NewGravityApp(
app.paramsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tKeys[paramstypes.TStoreKey])

authority := authtypes.NewModuleAddress(govtypes.ModuleName).String()
// set the BaseApp's parameter store

// set the BaseApp's parameter store
app.consensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authority)
bApp.SetParamStore(&app.consensusParamsKeeper)

Expand Down Expand Up @@ -538,7 +541,7 @@ func NewGravityApp(
genutiltypes.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
consensusparamtypes.ModuleName,
gravitytypes.ModuleName,
)
app.mm.SetOrderEndBlockers(
Expand All @@ -558,7 +561,7 @@ func NewGravityApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
consensusparamtypes.ModuleName,
gravitytypes.ModuleName,
)
app.mm.SetOrderInitGenesis(
Expand All @@ -584,7 +587,6 @@ func NewGravityApp(
app.mm.RegisterInvariants(&app.crisisKeeper)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

app.setupUpgradeHandlers()

app.sm = module.NewSimulationManager(
Expand Down Expand Up @@ -640,6 +642,10 @@ func NewGravityApp(
ibc.NewAppModule(app.ibcKeeper),
params.NewAppModule(app.paramsKeeper),
transferModule,
gravity.NewAppModule(
app.gravityKeeper,
app.bankKeeper,
),
)

app.sm.RegisterStoreDecoders()
Expand All @@ -648,6 +654,13 @@ func NewGravityApp(
app.MountTransientStores(tKeys)
app.MountMemoryStores(memKeys)

autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules))
reflectionSvc, err := runtimeservices.NewReflectionService()
if err != nil {
panic(err)
}
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)

anteHandler, err := ante.NewAnteHandler(
ante.HandlerOptions{
AccountKeeper: app.accountKeeper,
Expand Down Expand Up @@ -813,8 +826,8 @@ func (app *Gravity) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICo

// Register node gRPC service for grpc-gateway.
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.

// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// TODO: build the custom gravity swagger files and add here?
Expand Down
6 changes: 3 additions & 3 deletions module/cmd/gravity/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a
panic(err)
}

homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
if chainID == "" {
// fallback to genesis chain-id
appGenesis, err := tmtypes.GenesisDocFromFile(filepath.Join(homeDir, "config", "genesis.json"))
Expand Down Expand Up @@ -230,7 +230,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
baseapp.SetSnapshot(snapshotStore, snapshotOpts),
baseapp.SetChainID(chainID),
baseapp.SetChainID(chainID),
)
}

Expand Down
4 changes: 0 additions & 4 deletions module/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@ require (
replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76

github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10

github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)

Expand Down
Loading

0 comments on commit b2b17ed

Please sign in to comment.