Skip to content

Commit cece42b

Browse files
authored
refactor: remove capability module (cosmos#15344)
1 parent 67a792d commit cece42b

5 files changed

Lines changed: 3 additions & 45 deletions

File tree

app.go

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ import (
6666
"github.com/cosmos/cosmos-sdk/x/bank"
6767
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
6868
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
69-
"github.com/cosmos/cosmos-sdk/x/capability"
70-
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
71-
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
7269
consensus "github.com/cosmos/cosmos-sdk/x/consensus"
7370
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
7471
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
@@ -117,7 +114,6 @@ var (
117114
auth.AppModuleBasic{},
118115
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
119116
bank.AppModuleBasic{},
120-
capability.AppModuleBasic{},
121117
staking.AppModuleBasic{},
122118
mint.AppModuleBasic{},
123119
distr.AppModuleBasic{},
@@ -174,7 +170,6 @@ type SimApp struct {
174170
// keepers
175171
AccountKeeper authkeeper.AccountKeeper
176172
BankKeeper bankkeeper.Keeper
177-
CapabilityKeeper *capabilitykeeper.Keeper
178173
StakingKeeper *stakingkeeper.Keeper
179174
SlashingKeeper slashingkeeper.Keeper
180175
MintKeeper mintkeeper.Keeper
@@ -261,14 +256,13 @@ func NewSimApp(
261256
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
262257
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
263258
govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
264-
evidencetypes.StoreKey, capabilitytypes.StoreKey,
265-
authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
259+
evidencetypes.StoreKey, authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
266260
)
267261

268262
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
269263
// NOTE: The testingkey is just mounted for testing purposes. Actual applications should
270264
// not include this key.
271-
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, "testingkey")
265+
memKeys := storetypes.NewMemoryStoreKeys("testingkey")
272266

273267
// register the streaming service with the BaseApp
274268
if err := bApp.SetStreamingService(appOpts, appCodec, keys); err != nil {
@@ -292,11 +286,6 @@ func NewSimApp(
292286
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
293287
bApp.SetParamStore(&app.ConsensusParamsKeeper)
294288

295-
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
296-
// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
297-
// their scoped modules in `NewApp` with `ScopeToModule`
298-
app.CapabilityKeeper.Seal()
299-
300289
// add keepers
301290
app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, keys[authtypes.StoreKey], authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String())
302291

@@ -400,7 +389,6 @@ func NewSimApp(
400389
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)),
401390
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
402391
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
403-
capability.NewAppModule(appCodec, *app.CapabilityKeeper, false),
404392
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)),
405393
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
406394
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
@@ -421,10 +409,8 @@ func NewSimApp(
421409
// there is nothing left over in the validator fee pool, so as to keep the
422410
// CanWithdrawInvariant invariant.
423411
// NOTE: staking module is required if HistoricalEntries param > 0
424-
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
425412
app.ModuleManager.SetOrderBeginBlockers(
426413
upgradetypes.ModuleName,
427-
capabilitytypes.ModuleName,
428414
minttypes.ModuleName,
429415
distrtypes.ModuleName,
430416
slashingtypes.ModuleName,
@@ -445,11 +431,7 @@ func NewSimApp(
445431
// NOTE: The genutils module must occur after staking so that pools are
446432
// properly initialized with tokens from genesis accounts.
447433
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
448-
// NOTE: Capability module must occur first so that it can initialize any capabilities
449-
// so that other modules that want to create or claim capabilities afterwards in InitChain
450-
// can do so safely.
451-
genesisModuleOrder := []string{
452-
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName,
434+
genesisModuleOrder := []string{authtypes.ModuleName, banktypes.ModuleName,
453435
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
454436
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
455437
feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,

app_config.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
99
authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1"
1010
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
11-
capabilitymodulev1 "cosmossdk.io/api/cosmos/capability/module/v1"
1211
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
1312
crisismodulev1 "cosmossdk.io/api/cosmos/crisis/module/v1"
1413
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
@@ -38,7 +37,6 @@ import (
3837
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
3938
"github.com/cosmos/cosmos-sdk/x/authz"
4039
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
41-
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
4240
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
4341
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
4442
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
@@ -86,10 +84,8 @@ var (
8684
// there is nothing left over in the validator fee pool, so as to keep the
8785
// CanWithdrawInvariant invariant.
8886
// NOTE: staking module is required if HistoricalEntries param > 0
89-
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
9087
BeginBlockers: []string{
9188
upgradetypes.ModuleName,
92-
capabilitytypes.ModuleName,
9389
minttypes.ModuleName,
9490
distrtypes.ModuleName,
9591
slashingtypes.ModuleName,
@@ -115,11 +111,7 @@ var (
115111
// NOTE: The genutils module must occur after staking so that pools are
116112
// properly initialized with tokens from genesis accounts.
117113
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
118-
// NOTE: Capability module must occur first so that it can initialize any capabilities
119-
// so that other modules that want to create or claim capabilities afterwards in InitChain
120-
// can do so safely.
121114
InitGenesis: []string{
122-
capabilitytypes.ModuleName,
123115
authtypes.ModuleName,
124116
banktypes.ModuleName,
125117
distrtypes.ModuleName,
@@ -198,12 +190,6 @@ var (
198190
Name: distrtypes.ModuleName,
199191
Config: appconfig.WrapAny(&distrmodulev1.Module{}),
200192
},
201-
{
202-
Name: capabilitytypes.ModuleName,
203-
Config: appconfig.WrapAny(&capabilitymodulev1.Module{
204-
SealKeeper: true,
205-
}),
206-
},
207193
{
208194
Name: evidencetypes.ModuleName,
209195
Config: appconfig.WrapAny(&evidencemodulev1.Module{}),

app_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
2828
"github.com/cosmos/cosmos-sdk/x/bank"
2929
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
30-
"github.com/cosmos/cosmos-sdk/x/capability"
3130
"github.com/cosmos/cosmos-sdk/x/crisis"
3231
"github.com/cosmos/cosmos-sdk/x/distribution"
3332
"github.com/cosmos/cosmos-sdk/x/genutil"
@@ -199,7 +198,6 @@ func TestRunMigrations(t *testing.T) {
199198
"evidence": evidence.AppModule{}.ConsensusVersion(),
200199
"crisis": crisis.AppModule{}.ConsensusVersion(),
201200
"genutil": genutil.AppModule{}.ConsensusVersion(),
202-
"capability": capability.AppModule{}.ConsensusVersion(),
203201
},
204202
)
205203
if tc.expRunErr {
@@ -249,7 +247,6 @@ func TestInitGenesisOnMigration(t *testing.T) {
249247
"evidence": evidence.AppModule{}.ConsensusVersion(),
250248
"crisis": crisis.AppModule{}.ConsensusVersion(),
251249
"genutil": genutil.AppModule{}.ConsensusVersion(),
252-
"capability": capability.AppModule{}.ConsensusVersion(),
253250
},
254251
)
255252
require.NoError(t, err)

app_v2.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ import (
4646
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
4747
"github.com/cosmos/cosmos-sdk/x/bank"
4848
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
49-
"github.com/cosmos/cosmos-sdk/x/capability"
50-
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
5149
consensus "github.com/cosmos/cosmos-sdk/x/consensus"
5250
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
5351
"github.com/cosmos/cosmos-sdk/x/crisis"
@@ -84,7 +82,6 @@ var (
8482
auth.AppModuleBasic{},
8583
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
8684
bank.AppModuleBasic{},
87-
capability.AppModuleBasic{},
8885
staking.AppModuleBasic{},
8986
mint.AppModuleBasic{},
9087
distr.AppModuleBasic{},
@@ -126,7 +123,6 @@ type SimApp struct {
126123
// keepers
127124
AccountKeeper authkeeper.AccountKeeper
128125
BankKeeper bankkeeper.Keeper
129-
CapabilityKeeper *capabilitykeeper.Keeper
130126
StakingKeeper *stakingkeeper.Keeper
131127
SlashingKeeper slashingkeeper.Keeper
132128
MintKeeper mintkeeper.Keeper
@@ -210,7 +206,6 @@ func NewSimApp(
210206
&app.autoCliOpts,
211207
&app.AccountKeeper,
212208
&app.BankKeeper,
213-
&app.CapabilityKeeper,
214209
&app.StakingKeeper,
215210
&app.SlashingKeeper,
216211
&app.MintKeeper,

sim_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
2828
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
2929
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
30-
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
3130
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
3231
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
3332
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
@@ -209,7 +208,6 @@ func TestAppImportExport(t *testing.T) {
209208
{app.GetKey(paramtypes.StoreKey), newApp.GetKey(paramtypes.StoreKey), [][]byte{}},
210209
{app.GetKey(govtypes.StoreKey), newApp.GetKey(govtypes.StoreKey), [][]byte{}},
211210
{app.GetKey(evidencetypes.StoreKey), newApp.GetKey(evidencetypes.StoreKey), [][]byte{}},
212-
{app.GetKey(capabilitytypes.StoreKey), newApp.GetKey(capabilitytypes.StoreKey), [][]byte{}},
213211
{app.GetKey(authzkeeper.StoreKey), newApp.GetKey(authzkeeper.StoreKey), [][]byte{authzkeeper.GrantKey, authzkeeper.GrantQueuePrefix}},
214212
}
215213

0 commit comments

Comments
 (0)