Skip to content

Commit

Permalink
feat: add authz module (#1290)
Browse files Browse the repository at this point in the history
# Related Github tickets

- #2163

# Background

Add the authz module to paloma, so we can grant authorizations to
delegate and claim rewards.

NOTE: this adds a migration assuming the next release is going to be
2.2.1

# Testing completed

- [ ] test coverage exists or has been added/updated
- [x] tested in a private testnet

# Breaking changes

- [x] I have checked my code for breaking changes
- [x] If there are breaking changes, there is a supporting migration.
  • Loading branch information
maharifu authored Sep 13, 2024
1 parent e6db292 commit d8f2f56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -234,6 +237,7 @@ type App struct {
ParamsKeeper paramskeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper

ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -339,6 +343,7 @@ func New(
metrixmoduletypes.StoreKey,
wasmtypes.StoreKey,
palomamoduletypes.StoreKey,
authzkeeper.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := storetypes.NewMemoryStoreKeys(
Expand Down Expand Up @@ -732,6 +737,8 @@ func New(
}),
)

app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), app.AccountKeeper)

// register wasm gov proposal types
// enabledProposals := GetEnabledProposals()
// if len(enabledProposals) != 0 {
Expand Down Expand Up @@ -830,6 +837,7 @@ func New(
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
ibctm.NewAppModule(),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
)

app.ModuleManager.RegisterInvariants(app.CrisisKeeper)
Expand Down Expand Up @@ -867,6 +875,7 @@ func New(
authtypes.ModuleName,
vestingtypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
valsetmoduletypes.ModuleName,
palomamoduletypes.ModuleName,
evmmoduletypes.ModuleName,
Expand Down Expand Up @@ -935,6 +944,7 @@ func New(
vestingtypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
ibctransfertypes.ModuleName,
schedulermoduletypes.ModuleName,
consensusmoduletypes.ModuleName,
Expand Down
12 changes: 12 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
Expand Down Expand Up @@ -160,6 +161,17 @@ func (app *App) RegisterUpgradeHandlers(semverVersion string) {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

if upgradeInfo.Name == "v2.2.1" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
authzkeeper.StoreKey,
},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

app.UpgradeKeeper.SetUpgradeHandler(semverVersion, func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.ModuleManager.RunMigrations(ctx, app.configurator, fromVM)
})
Expand Down

0 comments on commit d8f2f56

Please sign in to comment.