refactor(runtime,core): split router service (#20401)

This commit is contained in:
Julien Robert 2024-05-16 10:04:40 +02:00 committed by GitHub
parent 6b716eef9a
commit f02a124667
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 117 additions and 156 deletions

View File

@ -176,7 +176,7 @@ If your module requires a message server or query server, it should be passed in
```diff
-govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AuthKeeper, app.BankKeeper,app.StakingKeeper, app.PoolKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String())
+govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/circuit"), runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String())
+govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/circuit"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String())
```
The signature of the extension interface `HasRegisterInterfaces` has been changed to accept a `cosmossdk.io/core/registry.InterfaceRegistrar` instead of a `codec.InterfaceRegistry`. `HasRegisterInterfaces` is now a part of `cosmossdk.io/core/appmodule`. Modules should update their `HasRegisterInterfaces` implementation to accept a `cosmossdk.io/core/registry.InterfaceRegistrar` interface.

View File

@ -19,7 +19,8 @@ type Environment struct {
EventService event.Service
GasService gas.Service
HeaderService header.Service
RouterService router.Service
QueryRouterService router.Service
MsgRouterService router.Service
TransactionService transaction.Service
KVStoreService store.KVStoreService

View File

@ -6,15 +6,9 @@ import (
"google.golang.org/protobuf/runtime/protoiface"
)
// Service embeds a QueryRouterService and MessageRouterService.
// Each router allows to invoke messages and queries via the corresponding router.
// Service is the interface that wraps the basic methods for a router.
// A router can be a query router or a message router.
type Service interface {
QueryRouterService() Router
MessageRouterService() Router
}
// Router is the interface that wraps the basic methods for a router.
type Router interface {
// CanInvoke returns an error if the given request cannot be invoked.
CanInvoke(ctx context.Context, typeURL string) error
// InvokeTyped execute a message or query. It should be used when the called knows the type of the response.

View File

@ -35,12 +35,15 @@ func NewEnvironment(
type EnvOption func(*appmodule.Environment)
func EnvWithRouterService(
queryServiceRouter *baseapp.GRPCQueryRouter,
msgServiceRouter *baseapp.MsgServiceRouter,
) EnvOption {
func EnvWithMsgRouterService(msgServiceRouter *baseapp.MsgServiceRouter) EnvOption {
return func(env *appmodule.Environment) {
env.RouterService = NewRouterService(env.KVStoreService, queryServiceRouter, msgServiceRouter)
env.MsgRouterService = NewMsgRouterService(msgServiceRouter)
}
}
func EnvWithQueryRouterService(queryServiceRouter *baseapp.GRPCQueryRouter) EnvOption {
return func(env *appmodule.Environment) {
env.QueryRouterService = NewQueryRouterService(queryServiceRouter)
}
}

View File

@ -247,7 +247,8 @@ func ProvideEnvironment(
return kvService, memStoreService, NewEnvironment(
kvService,
logger.With(log.ModuleKey, fmt.Sprintf("x/%s", key.Name())),
EnvWithRouterService(queryServiceRouter, msgServiceRouter),
EnvWithMsgRouterService(msgServiceRouter),
EnvWithQueryRouterService(queryServiceRouter),
EnvWithMemStoreService(memStoreService),
)
}

View File

@ -11,47 +11,22 @@ import (
"google.golang.org/protobuf/runtime/protoiface"
"cosmossdk.io/core/router"
"cosmossdk.io/core/store"
"github.com/cosmos/cosmos-sdk/baseapp"
)
// NewRouterService creates a router.Service which allows to invoke messages and queries using the msg router.
func NewRouterService(storeService store.KVStoreService, queryRouter *baseapp.GRPCQueryRouter, msgRouter baseapp.MessageRouter) router.Service {
return &routerService{
queryRouterService: &queryRouterService{
storeService: storeService, // TODO: this will be used later on as authenticating modules before routing
router: queryRouter,
},
msgRouterService: &msgRouterService{
storeService: storeService, // TODO: this will be used later on as authenticating modules before routing
router: msgRouter,
},
// NewMsgRouterService implements router.Service.
func NewMsgRouterService(msgRouter baseapp.MessageRouter) router.Service {
return &msgRouterService{
router: msgRouter,
}
}
var _ router.Service = (*routerService)(nil)
type routerService struct {
queryRouterService router.Router
msgRouterService router.Router
}
// MessageRouterService implements router.Service.
func (r *routerService) MessageRouterService() router.Router {
return r.msgRouterService
}
// QueryRouterService implements router.Service.
func (r *routerService) QueryRouterService() router.Router {
return r.queryRouterService
}
var _ router.Router = (*msgRouterService)(nil)
var _ router.Service = (*msgRouterService)(nil)
type msgRouterService struct {
storeService store.KVStoreService
router baseapp.MessageRouter
// TODO: eventually authenticate modules to use the message router
router baseapp.MessageRouter
}
// CanInvoke returns an error if the given message cannot be invoked.
@ -104,11 +79,17 @@ func (m *msgRouterService) InvokeUntyped(ctx context.Context, msg protoiface.Mes
return msgResp, m.InvokeTyped(ctx, msg, msgResp)
}
var _ router.Router = (*queryRouterService)(nil)
// NewQueryRouterService implements router.Service.
func NewQueryRouterService(queryRouter *baseapp.GRPCQueryRouter) router.Service {
return &queryRouterService{
router: queryRouter,
}
}
var _ router.Service = (*queryRouterService)(nil)
type queryRouterService struct {
storeService store.KVStoreService
router *baseapp.GRPCQueryRouter
router *baseapp.GRPCQueryRouter
}
// CanInvoke returns an error if the given request cannot be invoked.

View File

@ -31,18 +31,19 @@ func TestRouterService(t *testing.T) {
countertypes.RegisterMsgServer(msgRouter, counterKeeper)
countertypes.RegisterQueryServer(queryRouter, counterKeeper)
routerService := runtime.NewRouterService(storeService, queryRouter, msgRouter)
messageRouterService := runtime.NewMsgRouterService(msgRouter)
queryRouterService := runtime.NewQueryRouterService(queryRouter)
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
// Messages
t.Run("invalid msg", func(t *testing.T) {
_, err := routerService.MessageRouterService().InvokeUntyped(testCtx.Ctx, &bankv1beta1.MsgSend{})
_, err := messageRouterService.InvokeUntyped(testCtx.Ctx, &bankv1beta1.MsgSend{})
require.ErrorContains(t, err, "could not find response type for message cosmos.bank.v1beta1.MsgSend")
})
t.Run("invoke untyped: valid msg (proto v1)", func(t *testing.T) {
resp, err := routerService.MessageRouterService().InvokeUntyped(testCtx.Ctx, &countertypes.MsgIncreaseCounter{
resp, err := messageRouterService.InvokeUntyped(testCtx.Ctx, &countertypes.MsgIncreaseCounter{
Signer: "cosmos1",
Count: 42,
})
@ -52,7 +53,7 @@ func TestRouterService(t *testing.T) {
t.Run("invoke typed: valid msg (proto v1)", func(t *testing.T) {
resp := &countertypes.MsgIncreaseCountResponse{}
err := routerService.MessageRouterService().InvokeTyped(testCtx.Ctx, &countertypes.MsgIncreaseCounter{
err := messageRouterService.InvokeTyped(testCtx.Ctx, &countertypes.MsgIncreaseCounter{
Signer: "cosmos1",
Count: 42,
}, resp)
@ -62,7 +63,7 @@ func TestRouterService(t *testing.T) {
t.Run("invoke typed: valid msg (proto v2)", func(t *testing.T) {
resp := &counterv1.MsgIncreaseCountResponse{}
err := routerService.MessageRouterService().InvokeTyped(testCtx.Ctx, &counterv1.MsgIncreaseCounter{
err := messageRouterService.InvokeTyped(testCtx.Ctx, &counterv1.MsgIncreaseCounter{
Signer: "cosmos1",
Count: 42,
}, resp)
@ -73,7 +74,7 @@ func TestRouterService(t *testing.T) {
// Queries
t.Run("invalid query", func(t *testing.T) {
err := routerService.QueryRouterService().InvokeTyped(testCtx.Ctx, &bankv1beta1.QueryBalanceRequest{}, &bankv1beta1.QueryBalanceResponse{})
err := queryRouterService.InvokeTyped(testCtx.Ctx, &bankv1beta1.QueryBalanceRequest{}, &bankv1beta1.QueryBalanceResponse{})
require.ErrorContains(t, err, "unknown request: cosmos.bank.v1beta1.QueryBalanceRequest")
})
@ -81,7 +82,7 @@ func TestRouterService(t *testing.T) {
_ = counterKeeper.CountStore.Set(testCtx.Ctx, 42)
resp := &countertypes.QueryGetCountResponse{}
err := routerService.QueryRouterService().InvokeTyped(testCtx.Ctx, &countertypes.QueryGetCountRequest{}, resp)
err := queryRouterService.InvokeTyped(testCtx.Ctx, &countertypes.QueryGetCountRequest{}, resp)
require.NoError(t, err)
require.NotNil(t, resp)
require.Equal(t, int64(42), resp.TotalCount)
@ -91,7 +92,7 @@ func TestRouterService(t *testing.T) {
_ = counterKeeper.CountStore.Set(testCtx.Ctx, 42)
resp := &counterv1.QueryGetCountResponse{}
err := routerService.QueryRouterService().InvokeTyped(testCtx.Ctx, &counterv1.QueryGetCountRequest{}, resp)
err := queryRouterService.InvokeTyped(testCtx.Ctx, &counterv1.QueryGetCountRequest{}, resp)
require.NoError(t, err)
require.NotNil(t, resp)
require.Equal(t, int64(42), resp.TotalCount)
@ -100,7 +101,7 @@ func TestRouterService(t *testing.T) {
t.Run("invoke untyped: valid query (proto v1)", func(t *testing.T) {
_ = counterKeeper.CountStore.Set(testCtx.Ctx, 42)
resp, err := routerService.QueryRouterService().InvokeUntyped(testCtx.Ctx, &countertypes.QueryGetCountRequest{})
resp, err := queryRouterService.InvokeUntyped(testCtx.Ctx, &countertypes.QueryGetCountRequest{})
require.NoError(t, err)
require.NotNil(t, resp)
respVal, ok := resp.(*countertypes.QueryGetCountResponse)

View File

@ -248,7 +248,8 @@ func ProvideEnvironment(logger log.Logger, config *runtimev2.Module, key depinje
EventService: stf.NewEventService(),
GasService: stf.NewGasMeterService(),
HeaderService: stf.HeaderService{},
RouterService: stf.NewRouterService(appBuilder.app.queryRouterBuilder, appBuilder.app.msgRouterBuilder),
QueryRouterService: stf.NewQueryRouterService(appBuilder.app.queryRouterBuilder),
MsgRouterService: stf.NewMsgRouterService(appBuilder.app.msgRouterBuilder),
TransactionService: services.NewContextAwareTransactionService(),
KVStoreService: kvService,
MemStoreService: memService,

View File

@ -12,48 +12,20 @@ import (
"cosmossdk.io/core/router"
)
// NewRouterService creates a router.Service which allows to invoke messages and queries using the msg router.
func NewRouterService(queryRouterBuilder, msgRouterBuilder *MsgRouterBuilder) router.Service {
queryRouter, err := queryRouterBuilder.Build()
if err != nil {
panic("cannot create queryRouter")
}
// NewMsgRouterService implements router.Service.
func NewMsgRouterService(msgRouterBuilder *MsgRouterBuilder) router.Service {
msgRouter, err := msgRouterBuilder.Build()
if err != nil {
panic("cannot create msgRouter")
panic(fmt.Errorf("cannot create msgRouter: %w", err))
}
return &routerService{
queryRouterService: &queryRouterService{
builder: queryRouterBuilder,
handler: queryRouter,
},
msgRouterService: &msgRouterService{
builder: msgRouterBuilder,
handler: msgRouter,
},
return &msgRouterService{
builder: msgRouterBuilder,
handler: msgRouter,
}
}
var _ router.Service = (*routerService)(nil)
type routerService struct {
queryRouterService router.Router
msgRouterService router.Router
}
// MessageRouterService implements router.Service.
func (r *routerService) MessageRouterService() router.Router {
return r.msgRouterService
}
// QueryRouterService implements router.Service.
func (r *routerService) QueryRouterService() router.Router {
return r.queryRouterService
}
var _ router.Router = (*msgRouterService)(nil)
var _ router.Service = (*msgRouterService)(nil)
type msgRouterService struct {
builder *MsgRouterBuilder
@ -87,7 +59,20 @@ func (m *msgRouterService) InvokeUntyped(ctx context.Context, msg protoiface.Mes
return m.handler(ctx, msg)
}
var _ router.Router = (*queryRouterService)(nil)
// NewQueryRouterService implements router.Service.
func NewQueryRouterService(queryRouterBuilder *MsgRouterBuilder) router.Service {
queryRouter, err := queryRouterBuilder.Build()
if err != nil {
panic(fmt.Errorf("cannot create queryRouter: %w", err))
}
return &queryRouterService{
builder: queryRouterBuilder,
handler: queryRouter,
}
}
var _ router.Service = (*queryRouterService)(nil)
type queryRouterService struct {
builder *MsgRouterBuilder

View File

@ -33,10 +33,6 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
return nil, errors.New("sign mode handler is required for ante builder")
}
if options.Environment.RouterService == nil {
return nil, errors.New("router service is required for ante builder")
}
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(options.Environment), // outermost AnteDecorator. SetUpContext must be called first
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),

View File

@ -290,7 +290,7 @@ func NewSimApp(
// add keepers
accountsKeeper, err := accounts.NewKeeper(
appCodec,
runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), logger.With(log.ModuleKey, "x/accounts"), runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())),
runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), logger.With(log.ModuleKey, "x/accounts"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
signingCtx.AddressCodec(),
appCodec.InterfaceRegistry(),
// TESTING: do not add
@ -343,7 +343,8 @@ func NewSimApp(
runtime.NewEnvironment(
runtime.NewKVStoreService(keys[stakingtypes.StoreKey]),
logger.With(log.ModuleKey, "x/staking"),
runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())),
runtime.EnvWithMsgRouterService(app.MsgServiceRouter()),
runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())),
app.AuthKeeper,
app.BankKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
@ -373,7 +374,7 @@ func NewSimApp(
app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[circuittypes.StoreKey]), logger.With(log.ModuleKey, "x/circuit")), appCodec, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AuthKeeper.AddressCodec())
app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper)
app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), logger.With(log.ModuleKey, "x/authz"), runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), appCodec, app.AuthKeeper)
app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), logger.With(log.ModuleKey, "x/authz"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), appCodec, app.AuthKeeper)
groupConfig := group.DefaultConfig()
/*
@ -383,7 +384,7 @@ func NewSimApp(
config.MaxProposalTitleLen = 255 // example max title length in characters
config.MaxProposalSummaryLen = 10200 // example max summary length in characters
*/
app.GroupKeeper = groupkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[group.StoreKey]), logger.With(log.ModuleKey, "x/group"), runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), appCodec, app.AuthKeeper, groupConfig)
app.GroupKeeper = groupkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[group.StoreKey]), logger.With(log.ModuleKey, "x/group"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), appCodec, app.AuthKeeper, groupConfig)
// get skipUpgradeHeights from the app options
skipUpgradeHeights := map[int64]bool{}
@ -392,7 +393,7 @@ func NewSimApp(
}
homePath := cast.ToString(appOpts.Get(flags.FlagHome))
// set the governance module account as the authority for conducting upgrades
app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
// Register the proposal types
// Deprecated: Avoid adding new handlers, instead use the new proposal flow
@ -404,7 +405,7 @@ func NewSimApp(
Example of setting gov params:
govConfig.MaxMetadataLen = 10000
*/
govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/gov"), runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String())
govKeeper := govkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/gov"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String())
// Set legacy router for backwards compatibility with gov v1beta1
govKeeper.SetLegacyRouter(govRouter)
@ -419,7 +420,7 @@ func NewSimApp(
// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), logger.With(log.ModuleKey, "x/evidence"), runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), app.StakingKeeper, app.SlashingKeeper, app.AuthKeeper.AddressCodec(),
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), logger.With(log.ModuleKey, "x/evidence"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.StakingKeeper, app.SlashingKeeper, app.AuthKeeper.AddressCodec(),
)
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper
@ -610,7 +611,7 @@ func (app *SimApp) setAnteHandler(txConfig client.TxConfig) {
anteHandler, err := NewAnteHandler(
HandlerOptions{
ante.HandlerOptions{
Environment: runtime.NewEnvironment(nil, app.logger, runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), // nil is set as the kvstoreservice to avoid module access
Environment: runtime.NewEnvironment(nil, app.logger, runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), // nil is set as the kvstoreservice to avoid module access
AccountAbstractionKeeper: app.AccountsKeeper,
AccountKeeper: app.AuthKeeper,
BankKeeper: app.BankKeeper,

View File

@ -81,7 +81,7 @@ func initFixture(t *testing.T) *fixture {
account := baseaccount.NewAccount("base", signing.NewHandlerMap(handler))
accountsKeeper, err := accounts.NewKeeper(
cdc,
runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(queryRouter, router)),
runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(router)),
addresscodec.NewBech32Codec("cosmos"),
cdc.InterfaceRegistry(),
account,

View File

@ -124,7 +124,7 @@ func initFixture(t *testing.T) *fixture {
grpcRouter := baseapp.NewGRPCQueryRouter()
cometService := runtime.NewContextAwareCometInfoService()
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(grpcRouter, msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometService)
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometService)
require.NoError(t, stakingKeeper.Params.Set(newCtx, stakingtypes.DefaultParams()))
poolKeeper := poolkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, stakingKeeper, authority.String())

View File

@ -139,13 +139,13 @@ func initFixture(tb testing.TB) *fixture {
assert.NilError(tb, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(grpcQueryRouter, msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
slashingKeeper := slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), log.NewNopLogger()), cdc, codec.NewLegacyAmino(), stakingKeeper, authority.String())
stakingKeeper.SetHooks(stakingtypes.NewMultiStakingHooks(slashingKeeper.Hooks()))
evidenceKeeper := keeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(grpcQueryRouter, msgRouter)), stakingKeeper, slashingKeeper, addresscodec.NewBech32Codec(sdk.Bech32PrefixAccAddr))
evidenceKeeper := keeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter)), stakingKeeper, slashingKeeper, addresscodec.NewBech32Codec(sdk.Bech32PrefixAccAddr))
router := evidencetypes.NewRouter()
router = router.AddRoute(evidencetypes.RouteEquivocation, testEquivocationHandler(evidenceKeeper))
evidenceKeeper.SetRouter(router)

View File

@ -119,7 +119,7 @@ func initFixture(tb testing.TB) *fixture {
govKeeper := keeper.NewKeeper(
cdc,
runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(queryRouter, router)),
runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(router)),
accountKeeper,
bankKeeper,
stakingKeeper,

View File

@ -85,7 +85,7 @@ func initFixture(tb testing.TB) *fixture {
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
accountKeeper := authkeeper.NewAccountKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(queryRouter, msgRouter)),
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)),
cdc,
authtypes.ProtoBaseAccount,
acctsModKeeper,
@ -99,7 +99,7 @@ func initFixture(tb testing.TB) *fixture {
accountKeeper.GetAuthority(): false,
}
bankKeeper := bankkeeper.NewBaseKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(queryRouter, msgRouter)),
runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)),
cdc,
accountKeeper,
blockedAddresses,
@ -110,9 +110,9 @@ func initFixture(tb testing.TB) *fixture {
cometInfoService := runtime.NewContextAwareCometInfoService()
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(queryRouter, msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometInfoService)
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), cometInfoService)
slashingKeeper := slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(queryRouter, msgRouter)), cdc, &codec.LegacyAmino{}, stakingKeeper, authority.String())
slashingKeeper := slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), cdc, &codec.LegacyAmino{}, stakingKeeper, authority.String())
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper)

View File

@ -138,7 +138,7 @@ func initFixture(tb testing.TB) *fixture {
acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl)
accountKeeper := authkeeper.NewAccountKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(queryRouter, msgRouter)),
runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)),
cdc,
authtypes.ProtoBaseAccount,
acctsModKeeper,
@ -161,7 +161,7 @@ func initFixture(tb testing.TB) *fixture {
assert.NilError(tb, bankKeeper.SetParams(newCtx, banktypes.DefaultParams()))
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(queryRouter, msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[types.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter)), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), runtime.NewContextAwareCometInfoService())
authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts)
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper)

View File

@ -90,7 +90,7 @@ func NewIntegrationApp(
if keys[consensusparamtypes.StoreKey] != nil {
// set baseApp param store
consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithRouterService(grpcRouter, msgRouter)), authtypes.NewModuleAddress("gov").String())
consensusParamsKeeper := consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcRouter), runtime.EnvWithMsgRouterService(msgRouter)), authtypes.NewModuleAddress("gov").String())
bApp.SetParamStore(consensusParamsKeeper.ParamsStore)
consensusparamtypes.RegisterQueryServer(grpcRouter, consensusParamsKeeper)

View File

@ -335,7 +335,7 @@ func (k Keeper) SendModuleMessageUntyped(ctx context.Context, sender []byte, msg
if !bytes.Equal(sender, wantSenders[0]) {
return nil, fmt.Errorf("%w: sender does not match expected sender", ErrUnauthorized)
}
resp, err := k.RouterService.MessageRouterService().InvokeUntyped(ctx, msg)
resp, err := k.MsgRouterService.InvokeUntyped(ctx, msg)
if err != nil {
return nil, err
}
@ -358,14 +358,14 @@ func (k Keeper) sendModuleMessage(ctx context.Context, sender []byte, msg, msgRe
if !bytes.Equal(sender, wantSenders[0]) {
return fmt.Errorf("%w: sender does not match expected sender", ErrUnauthorized)
}
return k.RouterService.MessageRouterService().InvokeTyped(ctx, msg, msgResp)
return k.MsgRouterService.InvokeTyped(ctx, msg, msgResp)
}
// queryModule is the entrypoint for an account to query a module.
// It will try to find the query handler for the given query and execute it.
// If multiple query handlers are found, it will return an error.
func (k Keeper) queryModule(ctx context.Context, queryReq, queryResp implementation.ProtoMsg) error {
return k.RouterService.QueryRouterService().InvokeTyped(ctx, queryReq, queryResp)
return k.QueryRouterService.InvokeTyped(ctx, queryReq, queryResp)
}
// maybeSendFunds will send the provided coins between the provided addresses, if amt

View File

@ -74,10 +74,7 @@ func newKeeper(t *testing.T, accounts ...implementation.AccountCreatorFunc) (Kee
msgRouter.RegisterService(&bankv1beta1.Msg_ServiceDesc, &bankMsgServer{})
ss, ctx := colltest.MockStore()
env := runtime.NewEnvironment(ss, log.NewNopLogger(), runtime.EnvWithRouterService(
queryRouter,
msgRouter,
))
env := runtime.NewEnvironment(ss, log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryRouter), runtime.EnvWithMsgRouterService(msgRouter))
env.EventService = eventService{}
m, err := NewKeeper(codec.NewProtoCodec(ir), env, addressCodec, ir, accounts...)
require.NoError(t, err)

View File

@ -47,7 +47,7 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool,
// TODO: possibly cache the result of this query for other antehandlers to use
var res consensusv1.QueryParamsResponse
if err := sud.env.RouterService.QueryRouterService().InvokeTyped(ctx, &consensusv1.QueryParamsRequest{}, &res); err != nil {
if err := sud.env.QueryRouterService.InvokeTyped(ctx, &consensusv1.QueryParamsRequest{}, &res); err != nil {
return newCtx, err
}

View File

@ -98,7 +98,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
}, nil).AnyTimes()
consensustypes.RegisterQueryServer(grpcQueryRouter, suite.consensusKeeper)
suite.env = runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger(), runtime.EnvWithRouterService(grpcQueryRouter, msgRouter))
suite.env = runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger(), runtime.EnvWithQueryRouterService(grpcQueryRouter), runtime.EnvWithMsgRouterService(msgRouter))
suite.accountKeeper = keeper.NewAccountKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger()), suite.encCfg.Codec, types.ProtoBaseAccount, suite.acctsModKeeper, maccPerms, authcodec.NewBech32Codec("cosmos"),
sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(),

View File

@ -68,7 +68,7 @@ func (suite *GenesisTestSuite) SetupTest() {
msr := suite.baseApp.MsgServiceRouter()
msr.SetInterfaceRegistry(suite.encCfg.InterfaceRegistry)
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(nil, msr))
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithMsgRouterService(msr))
suite.keeper = keeper.NewKeeper(env, suite.encCfg.Codec, suite.accountKeeper)
}

View File

@ -142,7 +142,7 @@ func (k Keeper) DispatchActions(ctx context.Context, grantee sdk.AccAddress, msg
}
// no need to use the branch service here, as if the transaction fails, the transaction will be reverted
_, err = k.RouterService.MessageRouterService().InvokeUntyped(ctx, msg)
_, err = k.MsgRouterService.InvokeUntyped(ctx, msg)
if err != nil {
return nil, fmt.Errorf("failed to execute message %d; message %v: %w", i, msg, err)
}

View File

@ -75,7 +75,7 @@ func (s *TestSuite) SetupTest() {
banktypes.RegisterInterfaces(s.encCfg.InterfaceRegistry)
banktypes.RegisterMsgServer(s.baseApp.MsgServiceRouter(), s.bankKeeper)
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(s.baseApp.GRPCQueryRouter(), s.baseApp.MsgServiceRouter()))
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithQueryRouterService(s.baseApp.GRPCQueryRouter()), runtime.EnvWithMsgRouterService(s.baseApp.MsgServiceRouter()))
s.authzKeeper = authzkeeper.NewKeeper(env, s.encCfg.Codec, s.accountKeeper)
queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.encCfg.InterfaceRegistry)

View File

@ -40,7 +40,7 @@ func (k Keeper) Grant(ctx context.Context, msg *authz.MsgGrant) (*authz.MsgGrant
}
t := authorization.MsgTypeURL()
if err := k.RouterService.MessageRouterService().CanInvoke(ctx, t); err != nil {
if err := k.MsgRouterService.CanInvoke(ctx, t); err != nil {
return nil, sdkerrors.ErrInvalidType.Wrapf("%s doesn't exist", t)
}

View File

@ -66,7 +66,7 @@ func TestExpiredGrantsQueue(t *testing.T) {
accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes()
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(baseApp.GRPCQueryRouter(), baseApp.MsgServiceRouter()))
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithQueryRouterService(baseApp.GRPCQueryRouter()), runtime.EnvWithMsgRouterService(baseApp.MsgServiceRouter()))
authzKeeper := keeper.NewKeeper(env, encCfg.Codec, accountKeeper)
save := func(grantee sdk.AccAddress, exp *time.Time) {

View File

@ -74,7 +74,7 @@ func (k Keeper) handleEquivocationEvidence(ctx context.Context, evidence *types.
// if the difference in time and number of blocks is greater than the allowed
// parameters defined.
var res consensusv1.QueryParamsResponse
if err := k.RouterService.QueryRouterService().InvokeTyped(ctx, &consensusv1.QueryParamsRequest{}, &res); err != nil {
if err := k.QueryRouterService.InvokeTyped(ctx, &consensusv1.QueryParamsRequest{}, &res); err != nil {
return fmt.Errorf("failed to query consensus params: %w", err)
}
if res.Params.Evidence != nil {

View File

@ -196,7 +196,7 @@ func (k Keeper) EndBlocker(ctx context.Context) error {
if err := k.BranchService.Execute(ctx, func(ctx context.Context) error {
// execute all messages
for idx, msg = range messages {
if _, err := safeExecuteHandler(ctx, msg, k.RouterService.MessageRouterService()); err != nil {
if _, err := safeExecuteHandler(ctx, msg, k.MsgRouterService); err != nil {
// `idx` and `err` are populated with the msg index and error.
proposal.Status = v1.StatusFailed
proposal.FailedReason = err.Error()
@ -283,7 +283,7 @@ func (k Keeper) EndBlocker(ctx context.Context) error {
}
// executes route(msg) and recovers from panic.
func safeExecuteHandler(ctx context.Context, msg sdk.Msg, router router.Router) (res protoiface.MessageV1, err error) {
func safeExecuteHandler(ctx context.Context, msg sdk.Msg, router router.Service) (res protoiface.MessageV1, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("handling x/gov proposal msg [%s] PANICKED: %v", msg, r)

View File

@ -10,13 +10,13 @@ import (
"cosmossdk.io/core/router"
)
type mockRouter struct {
router.Router
type mockRouterService struct {
router.Service
panic bool
}
func (m *mockRouter) InvokeUntyped(ctx context.Context, req protoiface.MessageV1) (res protoiface.MessageV1, err error) {
func (m *mockRouterService) InvokeUntyped(ctx context.Context, req protoiface.MessageV1) (res protoiface.MessageV1, err error) {
if m.panic {
panic("test-fail")
}
@ -30,10 +30,10 @@ func TestSafeExecuteHandler(t *testing.T) {
require := require.New(t)
ctx := context.Background()
r, err := safeExecuteHandler(ctx, nil, &mockRouter{panic: true})
r, err := safeExecuteHandler(ctx, nil, &mockRouterService{panic: true})
require.ErrorContains(err, "test-fail")
require.Nil(r)
_, err = safeExecuteHandler(ctx, nil, &mockRouter{panic: false})
_, err = safeExecuteHandler(ctx, nil, &mockRouterService{panic: false})
require.Nil(err)
}

View File

@ -133,7 +133,7 @@ func setupGovKeeper(t *testing.T, expectations ...func(sdk.Context, mocks)) (
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
environment := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(baseApp.GRPCQueryRouter(), baseApp.MsgServiceRouter()))
environment := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithQueryRouterService(baseApp.GRPCQueryRouter()), runtime.EnvWithMsgRouterService(baseApp.MsgServiceRouter()))
// gomock initializations
ctrl := gomock.NewController(t)
@ -199,7 +199,7 @@ func setupGovKeeperWithMaxVoteOptionsLen(t *testing.T, maxVoteOptionsLen uint64,
baseApp.SetCMS(testCtx.CMS)
baseApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
environment := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(baseApp.GRPCQueryRouter(), baseApp.MsgServiceRouter()))
environment := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithQueryRouterService(baseApp.GRPCQueryRouter()), runtime.EnvWithMsgRouterService(baseApp.MsgServiceRouter()))
// gomock initializations
ctrl := gomock.NewController(t)

View File

@ -378,11 +378,11 @@ func (k msgServer) SudoExec(ctx context.Context, msg *v1.MsgSudoExec) (*v1.MsgSu
var msgResp protoiface.MessageV1
if err := k.BranchService.Execute(ctx, func(ctx context.Context) error {
// TODO add route check here
if err := k.RouterService.MessageRouterService().CanInvoke(ctx, sdk.MsgTypeURL(sudoedMsg)); err != nil {
if err := k.MsgRouterService.CanInvoke(ctx, sdk.MsgTypeURL(sudoedMsg)); err != nil {
return errors.Wrapf(govtypes.ErrInvalidProposal, err.Error())
}
msgResp, err = k.RouterService.MessageRouterService().InvokeUntyped(ctx, sudoedMsg)
msgResp, err = k.MsgRouterService.InvokeUntyped(ctx, sudoedMsg)
if err != nil {
return errors.Wrapf(err, "failed to execute sudo-ed message; message %v", sudoedMsg)
}

View File

@ -87,7 +87,7 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata
return v1.Proposal{}, errorsmod.Wrapf(types.ErrInvalidSigner, addr)
}
if err := k.RouterService.MessageRouterService().CanInvoke(ctx, sdk.MsgTypeURL(msg)); err != nil {
if err := k.MsgRouterService.CanInvoke(ctx, sdk.MsgTypeURL(msg)); err != nil {
return v1.Proposal{}, errorsmod.Wrap(types.ErrUnroutableProposalMsg, err.Error())
}

View File

@ -77,7 +77,7 @@ func (s *GenesisTestSuite) SetupTest() {
s.ctx = s.sdkCtx
s.addressCodec = address.NewBech32Codec("cosmos")
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(bApp.GRPCQueryRouter(), bApp.MsgServiceRouter()))
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithQueryRouterService(bApp.GRPCQueryRouter()), runtime.EnvWithMsgRouterService(bApp.MsgServiceRouter()))
s.keeper = keeper.NewKeeper(env, s.cdc, accountKeeper, group.DefaultConfig())
}

View File

@ -75,7 +75,7 @@ func initKeeper(t *testing.T) *fixture {
accountKeeper.EXPECT().NewAccount(gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
accountKeeper.EXPECT().SetAccount(gomock.Any(), gomock.Any()).AnyTimes()
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger(), runtime.EnvWithRouterService(bApp.GRPCQueryRouter(), bApp.MsgServiceRouter()))
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger(), runtime.EnvWithQueryRouterService(bApp.GRPCQueryRouter()), runtime.EnvWithMsgRouterService(bApp.MsgServiceRouter()))
groupKeeper = groupkeeper.NewKeeper(env, encCfg.Codec, accountKeeper, group.DefaultConfig())
queryHelper := baseapp.NewQueryServerTestHelper(ctx, interfaceRegistry)

View File

@ -82,7 +82,7 @@ func (s *TestSuite) SetupTest() {
bApp.SetInterfaceRegistry(encCfg.InterfaceRegistry)
banktypes.RegisterMsgServer(bApp.MsgServiceRouter(), s.bankKeeper)
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger(), runtime.EnvWithRouterService(bApp.GRPCQueryRouter(), bApp.MsgServiceRouter()))
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), log.NewNopLogger(), runtime.EnvWithQueryRouterService(bApp.GRPCQueryRouter()), runtime.EnvWithMsgRouterService(bApp.MsgServiceRouter()))
config := group.DefaultConfig()
s.groupKeeper = keeper.NewKeeper(env, encCfg.Codec, s.accountKeeper, config)
s.ctx = testCtx.Ctx.WithHeaderInfo(header.Info{Time: s.blockTime})

View File

@ -45,7 +45,7 @@ func (k Keeper) doExecuteMsgs(ctx context.Context, proposal group.Proposal, grou
}
for i, msg := range msgs {
if _, err := k.RouterService.MessageRouterService().InvokeUntyped(ctx, msg); err != nil {
if _, err := k.MsgRouterService.InvokeUntyped(ctx, msg); err != nil {
return errorsmod.Wrapf(err, "message %s at position %d", sdk.MsgTypeURL(msg), i)
}
}

View File

@ -87,7 +87,7 @@ func (s *KeeperTestSuite) SetupTest() {
consensustypes.RegisterQueryServer(queryHelper, ck)
bankKeeper := stakingtestutil.NewMockBankKeeper(ctrl)
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(queryHelper.GRPCQueryRouter, s.baseApp.MsgServiceRouter()))
env := runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithQueryRouterService(queryHelper.GRPCQueryRouter), runtime.EnvWithMsgRouterService(s.baseApp.MsgServiceRouter()))
authority, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(stakingtypes.GovModuleName))
s.Require().NoError(err)
keeper := stakingkeeper.NewKeeper(

View File

@ -69,7 +69,7 @@ func (k msgServer) CreateValidator(ctx context.Context, msg *types.MsgCreateVali
}
res := consensusv1.QueryParamsResponse{}
if err := k.RouterService.QueryRouterService().InvokeTyped(ctx, &consensusv1.QueryParamsRequest{}, &res); err != nil {
if err := k.QueryRouterService.InvokeTyped(ctx, &consensusv1.QueryParamsRequest{}, &res); err != nil {
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "failed to query consensus params: %s", err)
}
if res.Params.Validator != nil {

View File

@ -49,7 +49,7 @@ func (k Keeper) PreBlocker(ctx context.Context) error {
var appVersion uint64
var res consensusv1.QueryParamsResponse
if err := k.RouterService.QueryRouterService().InvokeTyped(ctx, &consensusv1.QueryParamsRequest{}, &res); err != nil {
if err := k.QueryRouterService.InvokeTyped(ctx, &consensusv1.QueryParamsRequest{}, &res); err != nil {
return errors.New("failed to query consensus params")
}
if res.Params.Version != nil {

View File

@ -129,7 +129,7 @@ func setupTest(t *testing.T, height int64, skip map[int64]bool) *TestSuite {
)
storeService := runtime.NewKVStoreService(key)
s.env = runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithRouterService(s.baseApp.GRPCQueryRouter(), s.baseApp.MsgServiceRouter()))
s.env = runtime.NewEnvironment(storeService, log.NewNopLogger(), runtime.EnvWithMsgRouterService(s.baseApp.MsgServiceRouter()), runtime.EnvWithQueryRouterService(s.baseApp.GRPCQueryRouter()))
s.baseApp.SetParamStore(&paramStore{params: cmtproto.ConsensusParams{Version: &cmtproto.VersionParams{App: 1}}})