This commit is contained in:
Ethan Frey
2022-04-28 17:20:45 +02:00
parent f79a46b396
commit 5c82f4edd0
3 changed files with 44 additions and 31 deletions

View File

@@ -4,8 +4,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
channelkeeper "github.com/cosmos/ibc-go/v3/modules/core/04-channel/keeper"
ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante"
"github.com/cosmos/ibc-go/v3/modules/core/keeper"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
@@ -16,7 +16,7 @@ import (
type HandlerOptions struct {
ante.HandlerOptions
IBCChannelkeeper channelkeeper.Keeper
IBCKeeper *keeper.Keeper
WasmConfig *wasmTypes.WasmConfig
TXCounterStoreKey sdk.StoreKey
}
@@ -62,6 +62,6 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewAnteDecorator(options.IBCKeeper),
}
return sdk.ChainAnteDecorators(anteDecorators...), nil
}

View File

@@ -20,7 +20,6 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
@@ -240,10 +239,12 @@ type WasmApp struct {
paramsKeeper paramskeeper.Keeper
ibcKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
evidenceKeeper evidencekeeper.Keeper
transferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
wasmKeeper wasm.Keeper
// icaControllerKeeper icacontrollerkeeper.Keeper
// icaHostKeeper icahostkeeper.Keeper
transferKeeper ibctransferkeeper.Keeper
feeGrantKeeper feegrantkeeper.Keeper
authzKeeper authzkeeper.Keeper
wasmKeeper wasm.Keeper
scopedIBCKeeper capabilitykeeper.ScopedKeeper
scopedTransferKeeper capabilitykeeper.ScopedKeeper
@@ -280,7 +281,6 @@ func NewWasmApp(
bApp := baseapp.NewBaseApp(appName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)
keys := sdk.NewKVStoreKeys(
@@ -340,12 +340,12 @@ func NewWasmApp(
app.getSubspace(banktypes.ModuleName),
app.ModuleAccountAddrs(),
)
app.AuthzKeeper = authzkeeper.NewKeeper(
app.authzKeeper = authzkeeper.NewKeeper(
keys[authzkeeper.StoreKey],
appCodec,
app.BaseApp.MsgServiceRouter(),
)
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
app.feeGrantKeeper = feegrantkeeper.NewKeeper(
appCodec,
keys[feegrant.StoreKey],
app.accountKeeper,
@@ -434,23 +434,38 @@ func NewWasmApp(
transferModule := transfer.NewAppModule(app.transferKeeper)
icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper)
// TODO: enable ICA something like this
// initialize ICA module with mock module as the authentication module on the controller side
icaAuthModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp("", scopedICAMockKeeper))
app.ICAAuthModule = icaAuthModule
// icaModule := ica.NewAppModule(&app.icaControllerKeeper, &app.icaHostKeeper)
icaControllerIBCModule := icacontroller.NewIBCModule(app.ICAControllerKeeper, icaAuthModule)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)
// // NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do
// // not replicate if you do not need to test core IBC or light clients.
// mockModule := ibcmock.NewAppModule(&app.ibcKeeper.PortKeeper)
// mockIBCModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp(ibcmock.ModuleName, scopedIBCMockKeeper))
// app.icaControllerKeeper = icacontrollerkeeper.NewKeeper(
// appCodec, keys[icacontrollertypes.StoreKey], app.getSubspace(icacontrollertypes.SubModuleName),
// app.ibcKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee
// app.ibcKeeper.ChannelKeeper, &app.ibcKeeper.PortKeeper,
// scopedicaControllerKeeper, app.MsgServiceRouter(),
// )
// // initialize ICA module with mock module as the authentication module on the controller side
// icaAuthModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp("", scopedICAMockKeeper))
// app.icaAuthModule = icaAuthModule
// icaControllerIBCModule := icacontroller.NewIBCModule(app.icaControllerKeeper, icaAuthModule)
// icaHostIBCModule := icahost.NewIBCModule(app.icaHostKeeper)
// Create static IBC router, add app routes, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibcmock.ModuleName+icacontrollertypes.SubModuleName, icaControllerIBCModule). // ica with mock auth module stack route to ica (top level of middleware stack)
AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
AddRoute(ibcmock.ModuleName, mockIBCModule)
app.IBCKeeper.SetRouter(ibcRouter)
ibcRouter.
// AddRoute(icacontrollertypes.SubModuleName, icaControllerIBCModule).
// AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
// AddRoute(ibcmock.ModuleName+icacontrollertypes.SubModuleName, icaControllerIBCModule). // ica with mock auth module stack route to ica (top level of middleware stack)
AddRoute(ibctransfertypes.ModuleName, transferModule).
// AddRoute(ibcmock.ModuleName, mockIBCModule)
app.ibcKeeper.SetRouter(ibcRouter)
// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
@@ -533,8 +548,8 @@ func NewWasmApp(
upgrade.NewAppModule(app.upgradeKeeper),
wasm.NewAppModule(appCodec, &app.wasmKeeper, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
evidence.NewAppModule(app.evidenceKeeper),
feegrantmodule.NewAppModule(appCodec, app.accountKeeper, app.bankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
feegrantmodule.NewAppModule(appCodec, app.accountKeeper, app.bankKeeper, app.feeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.ibcKeeper),
params.NewAppModule(app.paramsKeeper),
transferModule,
@@ -639,8 +654,8 @@ func NewWasmApp(
auth.NewAppModule(appCodec, app.accountKeeper, authsims.RandomGenesisAccounts),
bank.NewAppModule(appCodec, app.bankKeeper, app.accountKeeper),
capability.NewAppModule(appCodec, *app.capabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.accountKeeper, app.bankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
feegrantmodule.NewAppModule(appCodec, app.accountKeeper, app.bankKeeper, app.feeGrantKeeper, app.interfaceRegistry),
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.govKeeper, app.accountKeeper, app.bankKeeper),
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper),
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
@@ -654,7 +669,6 @@ func NewWasmApp(
)
app.sm.RegisterStoreDecoders()
// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tkeys)
@@ -665,11 +679,11 @@ func NewWasmApp(
HandlerOptions: ante.HandlerOptions{
AccountKeeper: app.accountKeeper,
BankKeeper: app.bankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
FeegrantKeeper: app.feeGrantKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
IBCChannelkeeper: app.ibcKeeper.ChannelKeeper,
IBCKeeper: app.ibcKeeper,
WasmConfig: &wasmConfig,
TXCounterStoreKey: keys[wasm.StoreKey],
},

View File

@@ -118,7 +118,6 @@ var TestingStakeParams = stakingtypes.Params{
MaxEntries: 10,
HistoricalEntries: 10,
BondDenom: "stake",
MinCommissionRate: sdk.NewDec(0),
}
type TestFaucet struct {