diff --git a/README.md b/README.md index a2dd5c05ad..542b98a3d7 100644 --- a/README.md +++ b/README.md @@ -198,9 +198,6 @@ Available flags: * `-X github.com/CosmWasm/wasmd/app.NodeDir=.corald` - set the config/data directory for the node (default `~/.wasmd`) * `-X github.com/CosmWasm/wasmd/app.Bech32Prefix=coral` - set the bech32 prefix for all accounts (default `wasm`) -* `-X github.com/CosmWasm/wasmd/app.ProposalsEnabled=true` - enable all x/wasm governance proposals (default `false`) -* `-X github.com/CosmWasm/wasmd/app.EnableSpecificProposals=MigrateContract,UpdateAdmin,ClearAdmin` - - enable a subset of the x/wasm governance proposal types (overrides `ProposalsEnabled`) Examples: @@ -227,8 +224,7 @@ We strongly suggest **to limit the max block gas in the genesis** and not use th ``` Tip: if you want to lock this down to a permisisoned network, the following script can edit the genesis file -to only allow permissioned use of code upload or instantiating. (Make sure you set `app.ProposalsEnabled=true` -in this binary): +to only allow permissioned use of code upload or instantiating: `sed -i 's/permission": "Everybody"/permission": "Nobody"/' .../config/genesis.json` diff --git a/app/app.go b/app/app.go index 5ad9499835..ae54f92b76 100644 --- a/app/app.go +++ b/app/app.go @@ -28,9 +28,7 @@ import ( ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client" ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" @@ -97,7 +95,6 @@ import ( govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/group" groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper" groupmodule "github.com/cosmos/cosmos-sdk/x/group/module" @@ -111,7 +108,6 @@ import ( paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/x/slashing" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" @@ -134,33 +130,8 @@ const appName = "WasmApp" var ( NodeDir = ".wasmd" Bech32Prefix = "wasm" - - // If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals. - // If EnabledSpecificProposals is "", and this is not "true", then disable all x/wasm proposals. - ProposalsEnabled = "false" - // If set to non-empty string it must be comma-separated list of values that are all a subset - // of "EnableAllProposals" (takes precedence over ProposalsEnabled) - // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 - EnableSpecificProposals = "" ) -// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to -// produce a list of enabled proposals to pass into wasmd app. -func GetEnabledProposals() []wasmtypes.ProposalType { - if EnableSpecificProposals == "" { - if ProposalsEnabled == "true" { - return wasmtypes.EnableAllProposals - } - return wasmtypes.DisableAllProposals - } - chunks := strings.Split(EnableSpecificProposals, ",") - proposals, err := wasmtypes.ConvertToProposals(chunks) - if err != nil { - panic(err) - } - return proposals -} - // These constants are derived from the above variables. // These are the ones we will want to use in the code, based on // any overrides above @@ -306,7 +277,6 @@ func NewWasmApp( db dbm.DB, traceStore io.Writer, loadLatest bool, - enabledProposals []wasmtypes.ProposalType, appOpts servertypes.AppOptions, wasmOpts []wasmkeeper.Option, baseAppOptions ...func(*baseapp.BaseApp), @@ -483,16 +453,6 @@ func NewWasmApp( scopedIBCKeeper, ) - // Register the proposal types - // Deprecated: Avoid adding new handlers, instead use the new proposal flow - // by granting the governance module the right to execute the message. - // See: https://docs.cosmos.network/main/modules/gov#proposal-messages - govRouter := govv1beta1.NewRouter() - govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). // This should be removed. It is still in place to avoid failures of modules that have not yet been upgraded. - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) - govConfig := govtypes.DefaultConfig() /* Example of setting gov params: @@ -605,13 +565,6 @@ func NewWasmApp( wasmOpts..., ) - // The gov proposal types can be individually enabled - if len(enabledProposals) != 0 { - govRouter.AddRoute(wasmtypes.RouterKey, wasmkeeper.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) //nolint:staticcheck // we still need this despite the deprecation of the gov handler - } - // Set legacy router for backwards compatibility with gov v1beta1 - app.GovKeeper.SetLegacyRouter(govRouter) - // Create Transfer Stack var transferStack porttypes.IBCModule transferStack = transfer.NewIBCModule(app.TransferKeeper) diff --git a/app/app_test.go b/app/app_test.go index d83f38fe29..6dfc76942d 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -6,14 +6,12 @@ import ( dbm "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" ) var emptyWasmOpts []wasmkeeper.Option @@ -28,7 +26,7 @@ func TestWasmdExport(t *testing.T) { gapp.Commit() // Making a new app object with the db, so that initchain hasn't been called - newGapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, wasmtypes.EnableAllProposals, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), emptyWasmOpts) + newGapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), emptyWasmOpts) _, err := newGapp.ExportAppStateAndValidators(false, []string{}, nil) require.NoError(t, err, "ExportAppStateAndValidators should not have an error") } @@ -54,34 +52,3 @@ func TestGetMaccPerms(t *testing.T) { dup := GetMaccPerms() require.Equal(t, maccPerms, dup, "duplicated module account permissions differed from actual module account permissions") } - -func TestGetEnabledProposals(t *testing.T) { - cases := map[string]struct { - proposalsEnabled string - specificEnabled string - expected []wasmtypes.ProposalType - }{ - "all disabled": { - proposalsEnabled: "false", - expected: wasmtypes.DisableAllProposals, - }, - "all enabled": { - proposalsEnabled: "true", - expected: wasmtypes.EnableAllProposals, - }, - "some enabled": { - proposalsEnabled: "okay", - specificEnabled: "StoreCode,InstantiateContract", - expected: []wasmtypes.ProposalType{wasmtypes.ProposalTypeStoreCode, wasmtypes.ProposalTypeInstantiateContract}, - }, - } - - for name, tc := range cases { - t.Run(name, func(t *testing.T) { - ProposalsEnabled = tc.proposalsEnabled - EnableSpecificProposals = tc.specificEnabled - proposals := GetEnabledProposals() - assert.Equal(t, tc.expected, proposals) - }) - } -} diff --git a/app/sim_test.go b/app/sim_test.go index 6a69743b35..259bef1481 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -130,7 +130,7 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) + newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.Equal(t, "WasmApp", newApp.Name()) var genesisState GenesisState @@ -233,7 +233,7 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) + newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.Equal(t, "WasmApp", newApp.Name()) newApp.InitChain(abci.RequestInitChain{ @@ -275,7 +275,7 @@ func setupSimulationApp(t *testing.T, msg string) (simtypes.Config, dbm.DB, simt appOptions[flags.FlagHome] = dir // ensure a unique folder appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue - app := NewWasmApp(logger, db, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) + app := NewWasmApp(logger, db, nil, true, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.Equal(t, "WasmApp", app.Name()) return config, db, appOptions, app } @@ -314,7 +314,7 @@ func TestAppStateDeterminism(t *testing.T) { } db := dbm.NewMemDB() - app := NewWasmApp(logger, db, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, interBlockCacheOpt(), baseapp.SetChainID(SimAppChainID)) + app := NewWasmApp(logger, db, nil, true, appOptions, emptyWasmOpts, interBlockCacheOpt(), baseapp.SetChainID(SimAppChainID)) fmt.Printf( "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", diff --git a/app/test_helpers.go b/app/test_helpers.go index 530a643c55..5963ee378d 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -44,7 +44,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" ) // SetupOptions defines arguments that are passed into `WasmApp` constructor. @@ -70,7 +69,7 @@ func setup(tb testing.TB, chainID string, withGenesis bool, invCheckPeriod uint, appOptions := make(simtestutil.AppOptionsMap, 0) appOptions[flags.FlagHome] = nodeHome // ensure unique folder appOptions[server.FlagInvCheckPeriod] = invCheckPeriod - app := NewWasmApp(log.NewNopLogger(), db, nil, true, wasmtypes.EnableAllProposals, appOptions, opts, bam.SetChainID(chainID), bam.SetSnapshot(snapshotStore, snapshottypes.SnapshotOptions{KeepRecent: 2})) + app := NewWasmApp(log.NewNopLogger(), db, nil, true, appOptions, opts, bam.SetChainID(chainID), bam.SetSnapshot(snapshotStore, snapshottypes.SnapshotOptions{KeepRecent: 2})) if withGenesis { return app, NewDefaultGenesisState(app.AppCodec()) } @@ -96,7 +95,7 @@ func NewWasmAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOpti Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), } - app := NewWasmApp(options.Logger, options.DB, nil, true, wasmtypes.EnableAllProposals, options.AppOpts, options.WasmOpts) + app := NewWasmApp(options.Logger, options.DB, nil, true, options.AppOpts, options.WasmOpts) genesisState := NewDefaultGenesisState(app.appCodec) genesisState, err = GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) require.NoError(t, err) @@ -282,10 +281,10 @@ func NewTestNetworkFixture() network.TestFixture { } defer os.RemoveAll(dir) - app := NewWasmApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, wasmtypes.EnableAllProposals, simtestutil.NewAppOptionsWithFlagHome(dir), emptyWasmOptions) + app := NewWasmApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(dir), emptyWasmOptions) appCtr := func(val network.ValidatorI) servertypes.Application { return NewWasmApp( - val.GetCtx().Logger, dbm.NewMemDB(), nil, true, wasmtypes.EnableAllProposals, + val.GetCtx().Logger, dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir), emptyWasmOptions, bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), diff --git a/benchmarks/app_test.go b/benchmarks/app_test.go index 21e0450ee8..4d3e2b87df 100644 --- a/benchmarks/app_test.go +++ b/benchmarks/app_test.go @@ -32,7 +32,7 @@ import ( ) func setup(db dbm.DB, withGenesis bool, invCheckPeriod uint, opts ...wasmkeeper.Option) (*app.WasmApp, app.GenesisState) { //nolint:unparam - wasmApp := app.NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, wasmtypes.EnableAllProposals, simtestutil.EmptyAppOptions{}, nil) + wasmApp := app.NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, simtestutil.EmptyAppOptions{}, nil) if withGenesis { return wasmApp, app.NewDefaultGenesisState(wasmApp.AppCodec()) diff --git a/cmd/wasmd/root.go b/cmd/wasmd/root.go index 8a97351764..b95922095f 100644 --- a/cmd/wasmd/root.go +++ b/cmd/wasmd/root.go @@ -253,7 +253,6 @@ func newApp( return app.NewWasmApp( logger, db, traceStore, true, - app.GetEnabledProposals(), appOpts, wasmOpts, baseappOptions..., @@ -292,7 +291,6 @@ func appExport( db, traceStore, height == -1, - app.GetEnabledProposals(), appOpts, emptyWasmOpts, ) diff --git a/contrib/local/04-gov.sh b/contrib/local/04-gov.sh index 8498beb5f3..5c9325c0f0 100755 --- a/contrib/local/04-gov.sh +++ b/contrib/local/04-gov.sh @@ -3,7 +3,6 @@ set -o errexit -o nounset -o pipefail DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -echo "Compile with buildflag ''-X github.com/CosmWasm/wasmd/app.ProposalsEnabled=true' to enable gov" sleep 1 echo "## Submit a CosmWasm gov proposal" RESP=$(wasmd tx wasm submit-proposal store-instantiate "$DIR/../../x/wasm/keeper/testdata/reflect.wasm" \ diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index d21dbd739e..7b16886369 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -25,6 +25,7 @@ import ( const myTestLabel = "testing" func TestStoreCodeProposal(t *testing.T) { + t.Skip("DEPRECATED") parentCtx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper err := wasmKeeper.SetParams(parentCtx, types.Params{ @@ -122,6 +123,7 @@ func submitLegacyProposal(t *testing.T, ctx sdk.Context, content v1beta1.Content } func TestInstantiateProposal(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper err := wasmKeeper.SetParams(ctx, types.Params{ @@ -180,6 +182,7 @@ func TestInstantiateProposal(t *testing.T) { } func TestInstantiate2Proposal(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper err := wasmKeeper.SetParams(ctx, types.Params{ @@ -239,6 +242,7 @@ func TestInstantiate2Proposal(t *testing.T) { } func TestInstantiateProposal_NoAdmin(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper err := wasmKeeper.SetParams(ctx, types.Params{ @@ -320,6 +324,7 @@ func TestInstantiateProposal_NoAdmin(t *testing.T) { } func TestStoreAndInstantiateContractProposal(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper err := wasmKeeper.SetParams(ctx, types.Params{ @@ -379,6 +384,7 @@ func TestStoreAndInstantiateContractProposal(t *testing.T) { } func TestMigrateProposal(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper err := wasmKeeper.SetParams(ctx, types.Params{ @@ -459,6 +465,7 @@ func TestMigrateProposal(t *testing.T) { } func TestExecuteProposal(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") bankKeeper := keepers.BankKeeper @@ -514,6 +521,7 @@ func TestExecuteProposal(t *testing.T) { } func TestSudoProposal(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") bankKeeper := keepers.BankKeeper @@ -561,6 +569,7 @@ func TestSudoProposal(t *testing.T) { } func TestAdminProposals(t *testing.T) { + t.Skip("DEPRECATED") var ( otherAddress sdk.AccAddress = bytes.Repeat([]byte{0x2}, types.ContractAddrLen) contractAddr = BuildContractAddressClassic(1, 1) @@ -651,6 +660,7 @@ func TestAdminProposals(t *testing.T) { } func TestPinCodesProposal(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper @@ -742,6 +752,7 @@ func TestPinCodesProposal(t *testing.T) { } func TestUnpinCodesProposal(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper @@ -832,6 +843,7 @@ func TestUnpinCodesProposal(t *testing.T) { } func TestUpdateInstantiateConfigProposal(t *testing.T) { + t.Skip("DEPRECATED") ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper diff --git a/x/wasm/keeper/test_common.go b/x/wasm/keeper/test_common.go index 82993cc0ff..733c8d25f1 100644 --- a/x/wasm/keeper/test_common.go +++ b/x/wasm/keeper/test_common.go @@ -59,14 +59,12 @@ import ( govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/mint" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/cosmos/cosmos-sdk/x/params" paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/x/slashing" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" @@ -452,11 +450,6 @@ func createTestInput( // add wasm handler so we can loop-back (contracts calling contracts) contractKeeper := NewDefaultPermissionKeeper(&keeper) - govRouter := govv1beta1.NewRouter(). - AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(paramsKeeper)). - AddRoute(types.RouterKey, NewWasmProposalHandler(&keeper, types.EnableAllProposals)) - govKeeper := govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], @@ -468,7 +461,6 @@ func createTestInput( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) require.NoError(tb, govKeeper.SetParams(ctx, govv1.DefaultParams())) - govKeeper.SetLegacyRouter(govRouter) govKeeper.SetProposalID(ctx, 1) am := module.NewManager( // minimal module set that we use for message/ query tests