Skip to content

Commit 09b5008

Browse files
authored
Remove legacy gov proposal dependencies (#1587)
* Remove legacy gov proposal dependencies * Fix comments * Fix lint * Update files * Fix lint * Fix lint
1 parent 0f82c95 commit 09b5008

File tree

13 files changed

+168
-162
lines changed

13 files changed

+168
-162
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ Available flags:
199199

200200
* `-X github.com/CosmWasm/wasmd/app.NodeDir=.corald` - set the config/data directory for the node (default `~/.wasmd`)
201201
* `-X github.com/CosmWasm/wasmd/app.Bech32Prefix=coral` - set the bech32 prefix for all accounts (default `wasm`)
202-
* `-X github.com/CosmWasm/wasmd/app.ProposalsEnabled=true` - enable all x/wasm governance proposals (default `false`)
203-
* `-X github.com/CosmWasm/wasmd/app.EnableSpecificProposals=MigrateContract,UpdateAdmin,ClearAdmin` -
204-
enable a subset of the x/wasm governance proposal types (overrides `ProposalsEnabled`)
205202

206203
Examples:
207204

@@ -228,8 +225,7 @@ We strongly suggest **to limit the max block gas in the genesis** and not use th
228225
```
229226

230227
Tip: if you want to lock this down to a permisisoned network, the following script can edit the genesis file
231-
to only allow permissioned use of code upload or instantiating. (Make sure you set `app.ProposalsEnabled=true`
232-
in this binary):
228+
to only allow permissioned use of code upload or instantiating:
233229

234230
`sed -i 's/permission": "Everybody"/permission": "Nobody"/' .../config/genesis.json`
235231

UPGRADING.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,80 @@ docker run --rm -it \
208208
query gov votes 1
209209
```
210210

211+
## Vote on the upgrade (Starting from wasmd v0.40.0)
212+
213+
Starting from `v0.40.0` of `wasmd`, which incorporates cosmos-sdk `v0.47.x`,
214+
there have been changes in how upgrade proposals are handled. Below,
215+
we provide an example of how to achieve the same outcome as described
216+
in the preceding section.
217+
218+
Please be aware that some commands have been replaced by an interactive
219+
Command Line Interface (CLI), and the process of submitting a proposal
220+
is now divided into two distinct steps: `proposal creation` and `proposal submission`.
221+
222+
```sh
223+
# create the proposal
224+
docker run --rm -it \
225+
--mount type=volume,source=musselnet_client,target=/root \
226+
--network=host \
227+
cosmwasm/wasmd:v0.40.0 wasmd \
228+
tx gov draft-proposal \
229+
--from validator --chain-id testing
230+
231+
# choose <software-upgrade> from the interactive CLI and fill all the fields
232+
# of the generated json file draft_proposal.json
233+
# example:
234+
{
235+
"messages": [
236+
{
237+
"@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade",
238+
"authority": "wasm10d07y265gmmuvt4z0w9aw880jnsr700js7zslc",
239+
"plan": {
240+
"name": "Upgrade",
241+
"time": "0001-01-01T00:00:00Z",
242+
"height": "500",
243+
"info": "",
244+
"upgraded_client_state": null
245+
}
246+
}
247+
],
248+
"metadata": "ipfs://CID",
249+
"deposit": "100000ustake",
250+
"title": "Upgrade",
251+
"summary": "summary"
252+
}
253+
254+
# submit the proposal
255+
docker run --rm -it \
256+
--mount type=volume,source=musselnet_client,target=/root \
257+
--network=host \
258+
cosmwasm/wasmd:v0.40.0 wasmd \
259+
tx gov submit-proposal draft_proposal.json \
260+
--from validator --chain-id testing
261+
262+
# make sure it looks good
263+
docker run --rm -it \
264+
--mount type=volume,source=musselnet_client,target=/root \
265+
--network=host \
266+
cosmwasm/wasmd:v0.40.0 wasmd \
267+
query gov proposal 1
268+
269+
# vote for it
270+
docker run --rm -it \
271+
--mount type=volume,source=musselnet_client,target=/root \
272+
--network=host \
273+
cosmwasm/wasmd:v0.40.0 wasmd \
274+
tx gov vote 1 yes \
275+
--from validator --chain-id testing
276+
277+
# ensure vote was counted
278+
docker run --rm -it \
279+
--mount type=volume,source=musselnet_client,target=/root \
280+
--network=host \
281+
cosmwasm/wasmd:v0.40.0 wasmd \
282+
query gov votes 1
283+
```
284+
211285
## Swap out binaries
212286

213287
Now, we just wait about 5 minutes for the vote to pass, and ensure it is passed:

app/app.go

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -134,33 +134,8 @@ const appName = "WasmApp"
134134
var (
135135
NodeDir = ".wasmd"
136136
Bech32Prefix = "wasm"
137-
138-
// If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals.
139-
// If EnabledSpecificProposals is "", and this is not "true", then disable all x/wasm proposals.
140-
ProposalsEnabled = "false"
141-
// If set to non-empty string it must be comma-separated list of values that are all a subset
142-
// of "EnableAllProposals" (takes precedence over ProposalsEnabled)
143-
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
144-
EnableSpecificProposals = ""
145137
)
146138

147-
// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to
148-
// produce a list of enabled proposals to pass into wasmd app.
149-
func GetEnabledProposals() []wasmtypes.ProposalType {
150-
if EnableSpecificProposals == "" {
151-
if ProposalsEnabled == "true" {
152-
return wasmtypes.EnableAllProposals
153-
}
154-
return wasmtypes.DisableAllProposals
155-
}
156-
chunks := strings.Split(EnableSpecificProposals, ",")
157-
proposals, err := wasmtypes.ConvertToProposals(chunks)
158-
if err != nil {
159-
panic(err)
160-
}
161-
return proposals
162-
}
163-
164139
// These constants are derived from the above variables.
165140
// These are the ones we will want to use in the code, based on
166141
// any overrides above
@@ -306,7 +281,6 @@ func NewWasmApp(
306281
db dbm.DB,
307282
traceStore io.Writer,
308283
loadLatest bool,
309-
enabledProposals []wasmtypes.ProposalType,
310284
appOpts servertypes.AppOptions,
311285
wasmOpts []wasmkeeper.Option,
312286
baseAppOptions ...func(*baseapp.BaseApp),
@@ -605,10 +579,13 @@ func NewWasmApp(
605579
wasmOpts...,
606580
)
607581

582+
// DEPRECATED: DO NOT USE
583+
//
608584
// The gov proposal types can be individually enabled
609-
if len(enabledProposals) != 0 {
610-
govRouter.AddRoute(wasmtypes.RouterKey, wasmkeeper.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) //nolint:staticcheck // we still need this despite the deprecation of the gov handler
611-
}
585+
// if len(enabledProposals) != 0 {
586+
// govRouter.AddRoute(wasmtypes.RouterKey, wasmkeeper.NewWasmProposalHandler(app.WasmKeeper, enabledProposals))
587+
//}
588+
612589
// Set legacy router for backwards compatibility with gov v1beta1
613590
app.GovKeeper.SetLegacyRouter(govRouter)
614591

app/app_test.go

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ import (
66

77
dbm "github.com/cometbft/cometbft-db"
88
"github.com/cometbft/cometbft/libs/log"
9-
"github.com/stretchr/testify/assert"
109
"github.com/stretchr/testify/require"
1110

1211
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
1312
sdk "github.com/cosmos/cosmos-sdk/types"
1413

1514
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
16-
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
1715
)
1816

1917
var emptyWasmOpts []wasmkeeper.Option
@@ -28,7 +26,7 @@ func TestWasmdExport(t *testing.T) {
2826
gapp.Commit()
2927

3028
// Making a new app object with the db, so that initchain hasn't been called
31-
newGapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, wasmtypes.EnableAllProposals, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), emptyWasmOpts)
29+
newGapp := NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), emptyWasmOpts)
3230
_, err := newGapp.ExportAppStateAndValidators(false, []string{}, nil)
3331
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
3432
}
@@ -54,34 +52,3 @@ func TestGetMaccPerms(t *testing.T) {
5452
dup := GetMaccPerms()
5553
require.Equal(t, maccPerms, dup, "duplicated module account permissions differed from actual module account permissions")
5654
}
57-
58-
func TestGetEnabledProposals(t *testing.T) {
59-
cases := map[string]struct {
60-
proposalsEnabled string
61-
specificEnabled string
62-
expected []wasmtypes.ProposalType
63-
}{
64-
"all disabled": {
65-
proposalsEnabled: "false",
66-
expected: wasmtypes.DisableAllProposals,
67-
},
68-
"all enabled": {
69-
proposalsEnabled: "true",
70-
expected: wasmtypes.EnableAllProposals,
71-
},
72-
"some enabled": {
73-
proposalsEnabled: "okay",
74-
specificEnabled: "StoreCode,InstantiateContract",
75-
expected: []wasmtypes.ProposalType{wasmtypes.ProposalTypeStoreCode, wasmtypes.ProposalTypeInstantiateContract},
76-
},
77-
}
78-
79-
for name, tc := range cases {
80-
t.Run(name, func(t *testing.T) {
81-
ProposalsEnabled = tc.proposalsEnabled
82-
EnableSpecificProposals = tc.specificEnabled
83-
proposals := GetEnabledProposals()
84-
assert.Equal(t, tc.expected, proposals)
85-
})
86-
}
87-
}

app/sim_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func TestAppImportExport(t *testing.T) {
130130
require.NoError(t, os.RemoveAll(newDir))
131131
}()
132132

133-
newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
133+
newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
134134
require.Equal(t, "WasmApp", newApp.Name())
135135

136136
var genesisState GenesisState
@@ -233,7 +233,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
233233
require.NoError(t, os.RemoveAll(newDir))
234234
}()
235235

236-
newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
236+
newApp := NewWasmApp(log.NewNopLogger(), newDB, nil, true, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
237237
require.Equal(t, "WasmApp", newApp.Name())
238238

239239
newApp.InitChain(abci.RequestInitChain{
@@ -275,7 +275,7 @@ func setupSimulationApp(t *testing.T, msg string) (simtypes.Config, dbm.DB, simt
275275
appOptions[flags.FlagHome] = dir // ensure a unique folder
276276
appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue
277277

278-
app := NewWasmApp(logger, db, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
278+
app := NewWasmApp(logger, db, nil, true, appOptions, emptyWasmOpts, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID))
279279
require.Equal(t, "WasmApp", app.Name())
280280
return config, db, appOptions, app
281281
}
@@ -314,7 +314,7 @@ func TestAppStateDeterminism(t *testing.T) {
314314
}
315315

316316
db := dbm.NewMemDB()
317-
app := NewWasmApp(logger, db, nil, true, wasmtypes.EnableAllProposals, appOptions, emptyWasmOpts, interBlockCacheOpt(), baseapp.SetChainID(SimAppChainID))
317+
app := NewWasmApp(logger, db, nil, true, appOptions, emptyWasmOpts, interBlockCacheOpt(), baseapp.SetChainID(SimAppChainID))
318318

319319
fmt.Printf(
320320
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",

app/test_helpers.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import (
4444
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
4545

4646
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
47-
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
4847
)
4948

5049
// SetupOptions defines arguments that are passed into `WasmApp` constructor.
@@ -70,7 +69,7 @@ func setup(tb testing.TB, chainID string, withGenesis bool, invCheckPeriod uint,
7069
appOptions := make(simtestutil.AppOptionsMap, 0)
7170
appOptions[flags.FlagHome] = nodeHome // ensure unique folder
7271
appOptions[server.FlagInvCheckPeriod] = invCheckPeriod
73-
app := NewWasmApp(log.NewNopLogger(), db, nil, true, wasmtypes.EnableAllProposals, appOptions, opts, bam.SetChainID(chainID), bam.SetSnapshot(snapshotStore, snapshottypes.SnapshotOptions{KeepRecent: 2}))
72+
app := NewWasmApp(log.NewNopLogger(), db, nil, true, appOptions, opts, bam.SetChainID(chainID), bam.SetSnapshot(snapshotStore, snapshottypes.SnapshotOptions{KeepRecent: 2}))
7473
if withGenesis {
7574
return app, NewDefaultGenesisState(app.AppCodec())
7675
}
@@ -96,7 +95,7 @@ func NewWasmAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOpti
9695
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
9796
}
9897

99-
app := NewWasmApp(options.Logger, options.DB, nil, true, wasmtypes.EnableAllProposals, options.AppOpts, options.WasmOpts)
98+
app := NewWasmApp(options.Logger, options.DB, nil, true, options.AppOpts, options.WasmOpts)
10099
genesisState := NewDefaultGenesisState(app.appCodec)
101100
genesisState, err = GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)
102101
require.NoError(t, err)
@@ -282,10 +281,10 @@ func NewTestNetworkFixture() network.TestFixture {
282281
}
283282
defer os.RemoveAll(dir)
284283

285-
app := NewWasmApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, wasmtypes.EnableAllProposals, simtestutil.NewAppOptionsWithFlagHome(dir), emptyWasmOptions)
284+
app := NewWasmApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(dir), emptyWasmOptions)
286285
appCtr := func(val network.ValidatorI) servertypes.Application {
287286
return NewWasmApp(
288-
val.GetCtx().Logger, dbm.NewMemDB(), nil, true, wasmtypes.EnableAllProposals,
287+
val.GetCtx().Logger, dbm.NewMemDB(), nil, true,
289288
simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir),
290289
emptyWasmOptions,
291290
bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),

benchmarks/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
func setup(db dbm.DB, withGenesis bool, invCheckPeriod uint, opts ...wasmkeeper.Option) (*app.WasmApp, app.GenesisState) { //nolint:unparam
35-
wasmApp := app.NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, wasmtypes.EnableAllProposals, simtestutil.EmptyAppOptions{}, nil)
35+
wasmApp := app.NewWasmApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, simtestutil.EmptyAppOptions{}, nil)
3636

3737
if withGenesis {
3838
return wasmApp, app.NewDefaultGenesisState(wasmApp.AppCodec())

cmd/wasmd/root.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ func newApp(
253253

254254
return app.NewWasmApp(
255255
logger, db, traceStore, true,
256-
app.GetEnabledProposals(),
257256
appOpts,
258257
wasmOpts,
259258
baseappOptions...,
@@ -292,7 +291,6 @@ func appExport(
292291
db,
293292
traceStore,
294293
height == -1,
295-
app.GetEnabledProposals(),
296294
appOpts,
297295
emptyWasmOpts,
298296
)

contrib/local/04-gov.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ set -o errexit -o nounset -o pipefail
33

44
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
55

6-
echo "Compile with buildflag ''-X github.com/CosmWasm/wasmd/app.ProposalsEnabled=true' to enable gov"
76
sleep 1
87
echo "## Submit a CosmWasm gov proposal"
98
RESP=$(wasmd tx wasm submit-proposal store-instantiate "$DIR/../../x/wasm/keeper/testdata/reflect.wasm" \

0 commit comments

Comments
 (0)