@@ -13,7 +13,6 @@ import (
13
13
abci "github.com/tendermint/tendermint/abci/types"
14
14
"github.com/tendermint/tendermint/libs/log"
15
15
tmos "github.com/tendermint/tendermint/libs/os"
16
- tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
17
16
dbm "github.com/tendermint/tm-db"
18
17
19
18
"github.com/cosmos/cosmos-sdk/baseapp"
@@ -260,6 +259,9 @@ func NewSimApp(
260
259
// note replicate if you do not need to test core IBC or light clients.
261
260
scopedIBCMockKeeper := app .CapabilityKeeper .ScopeToModule (ibcmock .ModuleName )
262
261
262
+ // seal capability keeper after scoping modules
263
+ app .CapabilityKeeper .Seal ()
264
+
263
265
// add keepers
264
266
app .AccountKeeper = authkeeper .NewAccountKeeper (
265
267
appCodec , keys [authtypes .StoreKey ], app .GetSubspace (authtypes .ModuleName ), authtypes .ProtoBaseAccount , maccPerms ,
@@ -375,8 +377,9 @@ func NewSimApp(
375
377
// there is nothing left over in the validator fee pool, so as to keep the
376
378
// CanWithdrawInvariant invariant.
377
379
// NOTE: staking module is required if HistoricalEntries param > 0
380
+ // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
378
381
app .mm .SetOrderBeginBlockers (
379
- upgradetypes .ModuleName , minttypes .ModuleName , distrtypes .ModuleName , slashingtypes .ModuleName ,
382
+ upgradetypes .ModuleName , capabilitytypes . ModuleName , minttypes .ModuleName , distrtypes .ModuleName , slashingtypes .ModuleName ,
380
383
evidencetypes .ModuleName , stakingtypes .ModuleName , ibchost .ModuleName ,
381
384
)
382
385
app .mm .SetOrderEndBlockers (crisistypes .ModuleName , govtypes .ModuleName , stakingtypes .ModuleName )
@@ -453,16 +456,6 @@ func NewSimApp(
453
456
if err := app .LoadLatestVersion (); err != nil {
454
457
tmos .Exit (err .Error ())
455
458
}
456
-
457
- // Initialize and seal the capability keeper so all persistent capabilities
458
- // are loaded in-memory and prevent any further modules from creating scoped
459
- // sub-keepers.
460
- // This must be done during creation of baseapp rather than in InitChain so
461
- // that in-memory capabilities get regenerated on app restart.
462
- // Note that since this reads from the store, we can only perform it when
463
- // `loadLatest` is set to true.
464
- ctx := app .BaseApp .NewUncachedContext (true , tmproto.Header {})
465
- app .CapabilityKeeper .InitializeAndSeal (ctx )
466
459
}
467
460
468
461
app .ScopedIBCKeeper = scopedIBCKeeper
0 commit comments