From dad400ce41e210f229ae112531446b37a2d6d981 Mon Sep 17 00:00:00 2001 From: zale144 Date: Sun, 23 Jun 2024 08:44:55 +0200 Subject: [PATCH] feat(app): wire authz and feegrant modules to app (#270) --- app/ante/ante.go | 1 + app/app.go | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/app/ante/ante.go b/app/ante/ante.go index 25cf34ee..42408397 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -140,6 +140,7 @@ func NewHandler(options HandlerOptions) (sdk.AnteHandler, error) { } anteHandler = cosmosHandler( options, + // nolint:staticcheck cosmosante.NewLegacyEip712SigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), // Use old signature verification: uses EIP instead of the cosmos signature validator ) case "/ethermint.types.v1.ExtensionOptionDynamicFeeTx": // TODO: can delete? diff --git a/app/app.go b/app/app.go index 138577ea..b6c69c39 100644 --- a/app/app.go +++ b/app/app.go @@ -10,6 +10,9 @@ import ( "github.com/dymensionxyz/rollapp-evm/app/ante" + "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/gorilla/mux" "github.com/rakyll/statik/fs" "github.com/spf13/cast" @@ -28,7 +31,7 @@ import ( "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" - simapp "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store/streaming" storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -51,6 +54,9 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" + feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" @@ -95,13 +101,14 @@ import ( ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper" ibctestingtypes "github.com/cosmos/ibc-go/v6/testing/types" - rollappparams "github.com/dymensionxyz/rollapp-evm/app/params" srvflags "github.com/evmos/evmos/v12/server/flags" + rollappparams "github.com/dymensionxyz/rollapp-evm/app/params" + // unnamed import of statik for swagger UI support _ "github.com/cosmos/cosmos-sdk/client/docs/statik" - staking "github.com/dymensionxyz/dymension-rdk/x/staking" + "github.com/dymensionxyz/dymension-rdk/x/staking" stakingkeeper "github.com/dymensionxyz/dymension-rdk/x/staking/keeper" "github.com/dymensionxyz/dymension-rdk/x/sequencers" @@ -147,7 +154,8 @@ const ( var ( AccountAddressPrefix string kvstorekeys = []string{ - authtypes.StoreKey, banktypes.StoreKey, + authtypes.StoreKey, authzkeeper.StoreKey, + feegrant.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, seqtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, @@ -190,6 +198,7 @@ var ( // and genesis verification. ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, + authzmodule.AppModuleBasic{}, genutil.AppModuleBasic{}, bank.AppModuleBasic{}, capability.AppModuleBasic{}, @@ -200,6 +209,7 @@ var ( distr.AppModuleBasic{}, gov.NewAppModuleBasic(getGovProposalHandlers()), params.AppModuleBasic{}, + feegrantmodule.AppModuleBasic{}, upgrade.AppModuleBasic{}, ibc.AppModuleBasic{}, vesting.AppModuleBasic{}, @@ -218,6 +228,7 @@ var ( // module account permissions maccPerms = map[string][]string{ authtypes.FeeCollectorName: nil, + authz.ModuleName: nil, distrtypes.ModuleName: nil, minttypes.ModuleName: {authtypes.Minter}, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, @@ -276,6 +287,7 @@ type App struct { // keepers AccountKeeper authkeeper.AccountKeeper + AuthzKeeper authzkeeper.Keeper BankKeeper bankkeeper.Keeper CapabilityKeeper *capabilitykeeper.Keeper StakingKeeper stakingkeeper.Keeper @@ -289,6 +301,7 @@ type App struct { ParamsKeeper paramskeeper.Keeper IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly TransferKeeper transferkeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -399,6 +412,13 @@ func NewRollapp( sdk.GetConfig().GetBech32AccountAddrPrefix(), ) + app.AuthzKeeper = authzkeeper.NewKeeper( + keys[authzkeeper.StoreKey], + appCodec, + app.MsgServiceRouter(), + app.AccountKeeper, + ) + app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, keys[banktypes.StoreKey], @@ -435,6 +455,7 @@ func NewRollapp( &stakingKeeper, &app.SequencersKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), ) + app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String()) // register the staking hooks @@ -580,9 +601,11 @@ func NewRollapp( encodingConfig.TxConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, nil), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), capability.NewAppModule(appCodec, *app.CapabilityKeeper), + feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, app.BankKeeper), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), @@ -624,11 +647,13 @@ func NewRollapp( ibchost.ModuleName, ibctransfertypes.ModuleName, authtypes.ModuleName, + authz.ModuleName, banktypes.ModuleName, govtypes.ModuleName, erc20types.ModuleName, claimstypes.ModuleName, genutiltypes.ModuleName, + feegrant.ModuleName, epochstypes.ModuleName, paramstypes.ModuleName, hubgentypes.ModuleName, @@ -644,6 +669,7 @@ func NewRollapp( feemarkettypes.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, + authz.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, vestingtypes.ModuleName, @@ -651,6 +677,7 @@ func NewRollapp( erc20types.ModuleName, claimstypes.ModuleName, genutiltypes.ModuleName, + feegrant.ModuleName, epochstypes.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, @@ -670,6 +697,7 @@ func NewRollapp( initGenesisList := []string{ capabilitytypes.ModuleName, authtypes.ModuleName, + authz.ModuleName, banktypes.ModuleName, evmtypes.ModuleName, feemarkettypes.ModuleName, @@ -688,6 +716,7 @@ func NewRollapp( paramstypes.ModuleName, upgradetypes.ModuleName, ibctransfertypes.ModuleName, + feegrant.ModuleName, hubgentypes.ModuleName, denommetadatamoduletypes.ModuleName, }