From 009f87d29478acdccaa6e51b49ff3dbfb813d9d6 Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Fri, 4 Nov 2022 22:50:54 +0100 Subject: [PATCH] alternative for experimental build --- app/app.go | 104 ++++++++++++++++++---------------- app/experimental_appconfig.go | 22 ++----- app/stable_appconfig.go | 22 ++----- app/upgrades.go | 10 ++++ 4 files changed, 72 insertions(+), 86 deletions(-) diff --git a/app/app.go b/app/app.go index a8c151db59..e73331d3d8 100644 --- a/app/app.go +++ b/app/app.go @@ -132,59 +132,63 @@ var ( // ModuleBasics defines the module BasicManager is in charge of setting up basic, // non-dependant module elements, such as codec registration // and genesis verification. - ModuleBasics = module.NewBasicManager( - append([]module.AppModuleBasic{ - auth.AppModuleBasic{}, - genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - BankModule{}, - capability.AppModuleBasic{}, - StakingModule{}, - MintModule{}, - distr.AppModuleBasic{}, - GovModule{AppModuleBasic: gov.NewAppModuleBasic(getGovProposalHandlers())}, - params.AppModuleBasic{}, - CrisisModule{}, - SlashingModule{}, - feegrantmodule.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - authzmodule.AppModuleBasic{}, - groupmodule.AppModuleBasic{}, - vesting.AppModuleBasic{}, - nftmodule.AppModuleBasic{}, - ibc.AppModuleBasic{}, - ibctransfer.AppModuleBasic{}, - gravity.AppModuleBasic{}, - leverage.AppModuleBasic{}, - oracle.AppModuleBasic{}, - bech32ibc.AppModuleBasic{}, - }, setCustomModuleBasics()...)..., - ) + ModuleBasics module.BasicManager // module account permissions - maccPerms = func() map[string][]string { - perms := map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - nft.ModuleName: nil, - - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - gravitytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - leveragetypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - oracletypes.ModuleName: nil, - } - - for k, v := range setCustomMaccPerms() { - perms[k] = v - } - return perms - }() + maccPerms map[string][]string ) +func init() { + moduleBasics := []module.AppModuleBasic{ + auth.AppModuleBasic{}, + genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + BankModule{}, + capability.AppModuleBasic{}, + StakingModule{}, + MintModule{}, + distr.AppModuleBasic{}, + GovModule{AppModuleBasic: gov.NewAppModuleBasic(getGovProposalHandlers())}, + params.AppModuleBasic{}, + CrisisModule{}, + SlashingModule{}, + feegrantmodule.AppModuleBasic{}, + upgrade.AppModuleBasic{}, + evidence.AppModuleBasic{}, + authzmodule.AppModuleBasic{}, + groupmodule.AppModuleBasic{}, + vesting.AppModuleBasic{}, + nftmodule.AppModuleBasic{}, + ibc.AppModuleBasic{}, + ibctransfer.AppModuleBasic{}, + gravity.AppModuleBasic{}, + leverage.AppModuleBasic{}, + oracle.AppModuleBasic{}, + bech32ibc.AppModuleBasic{}, + } + if Experimental { + moduleBasics = append(moduleBasics, wasm.AppModuleBasic{}) + } + ModuleBasics = module.NewBasicManager(moduleBasics...) + + maccPerms = map[string][]string{ + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + nft.ModuleName: nil, + + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + gravitytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + leveragetypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + oracletypes.ModuleName: nil, + } + if Experimental { + maccPerms[wasm.ModuleName] = []string{authtypes.Burner} + } +} + // UmeeApp defines the ABCI application for the Umee network as an extension of // the Cosmos SDK's BaseApp. type UmeeApp struct { @@ -670,7 +674,7 @@ func New( // RegisterUpgradeHandlers is used for registering any on-chain upgrades. // Make sure it's called after `app.mm` and `app.configurator` are set. - app.registerUpgradeHandlers() + app.RegisterUpgradeHandlers(Experimental) // add test gRPC service for testing gRPC queries in isolation testdata.RegisterQueryServer(app.GRPCQueryRouter(), testdata.QueryImpl{}) diff --git a/app/experimental_appconfig.go b/app/experimental_appconfig.go index 21549d3e9b..114857bcbf 100644 --- a/app/experimental_appconfig.go +++ b/app/experimental_appconfig.go @@ -34,8 +34,11 @@ import ( leverageclient "github.com/umee-network/umee/v3/x/leverage/client" ) -var ( +// Experimental is a flag which determines expermiental features. +// It's set via build flag. +const Experimental = false +var ( // WasmProposalsEnabled enables all x/wasm proposals when it's value is "true" // and EnableSpecificWasmProposals is empty. Otherwise, all x/wasm proposals // are disabled. @@ -74,16 +77,6 @@ func GetWasmEnabledProposals() []wasm.ProposalType { return proposals } -func setCustomModuleBasics() []module.AppModuleBasic { - return []module.AppModuleBasic{wasm.AppModuleBasic{}} -} - -func setCustomMaccPerms() map[string][]string { - return map[string][]string{ - wasm.ModuleName: {authtypes.Burner}, - } -} - func setCustomKVStoreKeys() []string { return []string{wasm.StoreKey} } @@ -211,10 +204,3 @@ func initCustomParamsKeeper(paramsKeeper *paramskeeper.Keeper) { func (app *UmeeApp) initializeCustomScopedKeepers() { app.ScopedWasmKeeper = app.CapabilityKeeper.ScopeToModule(wasm.ModuleName) } - -func (app *UmeeApp) registerUpgradeHandlers() { - _, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() - if err != nil { - panic(err) - } -} diff --git a/app/stable_appconfig.go b/app/stable_appconfig.go index 9f4bf09f76..e02777d387 100644 --- a/app/stable_appconfig.go +++ b/app/stable_appconfig.go @@ -27,6 +27,10 @@ import ( leverageclient "github.com/umee-network/umee/v3/x/leverage/client" ) +// Experimental is a flag which determines expermiental features. +// It's set via build flag. +const Experimental = false + var ( WasmProposalsEnabled = "false" EnableSpecificWasmProposals = "" @@ -40,14 +44,6 @@ func GetWasmEnabledProposals() []wasm.ProposalType { return []wasm.ProposalType{} } -func setCustomModuleBasics() []module.AppModuleBasic { - return []module.AppModuleBasic{} -} - -func setCustomMaccPerms() map[string][]string { - return map[string][]string{} -} - func setCustomKVStoreKeys() []string { return []string{} } @@ -119,13 +115,3 @@ func (app *UmeeApp) setCustomKeepers( } func (app *UmeeApp) initializeCustomScopedKeepers() {} - -func (app *UmeeApp) registerUpgradeHandlers() { - upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() - if err != nil { - panic(err) - } - - app.registerV3_0Upgrade(upgradeInfo) - app.registerV3_1Upgrade(upgradeInfo) -} diff --git a/app/upgrades.go b/app/upgrades.go index f53875a1bd..7408744d45 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -15,6 +15,16 @@ import ( oracletypes "github.com/umee-network/umee/v3/x/oracle/types" ) +func (app UmeeApp) RegisterUpgradeHandlers(experimental bool) { + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(err) + } + + app.registerV3_0Upgrade(upgradeInfo) + app.registerV3_1Upgrade(upgradeInfo) +} + // performs upgrade from v3.0 -> v3.1 func (app *UmeeApp) registerV3_1Upgrade(_ upgradetypes.Plan) { const UpgradeV3_1Plan = "v3.1.0"