Remove legacy gov proposal dependencies (#1587)
* Remove legacy gov proposal dependencies * Fix comments * Fix lint * Update files * Fix lint * Fix lint
This commit is contained in:
@@ -199,9 +199,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:
|
||||
|
||||
@@ -228,8 +225,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`
|
||||
|
||||
|
||||
74
UPGRADING.md
74
UPGRADING.md
@@ -208,6 +208,80 @@ docker run --rm -it \
|
||||
query gov votes 1
|
||||
```
|
||||
|
||||
## Vote on the upgrade (Starting from wasmd v0.40.0)
|
||||
|
||||
Starting from `v0.40.0` of `wasmd`, which incorporates cosmos-sdk `v0.47.x`,
|
||||
there have been changes in how upgrade proposals are handled. Below,
|
||||
we provide an example of how to achieve the same outcome as described
|
||||
in the preceding section.
|
||||
|
||||
Please be aware that some commands have been replaced by an interactive
|
||||
Command Line Interface (CLI), and the process of submitting a proposal
|
||||
is now divided into two distinct steps: `proposal creation` and `proposal submission`.
|
||||
|
||||
```sh
|
||||
# create the proposal
|
||||
docker run --rm -it \
|
||||
--mount type=volume,source=musselnet_client,target=/root \
|
||||
--network=host \
|
||||
cosmwasm/wasmd:v0.40.0 wasmd \
|
||||
tx gov draft-proposal \
|
||||
--from validator --chain-id testing
|
||||
|
||||
# choose <software-upgrade> from the interactive CLI and fill all the fields
|
||||
# of the generated json file draft_proposal.json
|
||||
# example:
|
||||
{
|
||||
"messages": [
|
||||
{
|
||||
"@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade",
|
||||
"authority": "wasm10d07y265gmmuvt4z0w9aw880jnsr700js7zslc",
|
||||
"plan": {
|
||||
"name": "Upgrade",
|
||||
"time": "0001-01-01T00:00:00Z",
|
||||
"height": "500",
|
||||
"info": "",
|
||||
"upgraded_client_state": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"metadata": "ipfs://CID",
|
||||
"deposit": "100000ustake",
|
||||
"title": "Upgrade",
|
||||
"summary": "summary"
|
||||
}
|
||||
|
||||
# submit the proposal
|
||||
docker run --rm -it \
|
||||
--mount type=volume,source=musselnet_client,target=/root \
|
||||
--network=host \
|
||||
cosmwasm/wasmd:v0.40.0 wasmd \
|
||||
tx gov submit-proposal draft_proposal.json \
|
||||
--from validator --chain-id testing
|
||||
|
||||
# make sure it looks good
|
||||
docker run --rm -it \
|
||||
--mount type=volume,source=musselnet_client,target=/root \
|
||||
--network=host \
|
||||
cosmwasm/wasmd:v0.40.0 wasmd \
|
||||
query gov proposal 1
|
||||
|
||||
# vote for it
|
||||
docker run --rm -it \
|
||||
--mount type=volume,source=musselnet_client,target=/root \
|
||||
--network=host \
|
||||
cosmwasm/wasmd:v0.40.0 wasmd \
|
||||
tx gov vote 1 yes \
|
||||
--from validator --chain-id testing
|
||||
|
||||
# ensure vote was counted
|
||||
docker run --rm -it \
|
||||
--mount type=volume,source=musselnet_client,target=/root \
|
||||
--network=host \
|
||||
cosmwasm/wasmd:v0.40.0 wasmd \
|
||||
query gov votes 1
|
||||
```
|
||||
|
||||
## Swap out binaries
|
||||
|
||||
Now, we just wait about 5 minutes for the vote to pass, and ensure it is passed:
|
||||
|
||||
35
app/app.go
35
app/app.go
@@ -134,33 +134,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 +281,6 @@ func NewWasmApp(
|
||||
db dbm.DB,
|
||||
traceStore io.Writer,
|
||||
loadLatest bool,
|
||||
enabledProposals []wasmtypes.ProposalType,
|
||||
appOpts servertypes.AppOptions,
|
||||
wasmOpts []wasmkeeper.Option,
|
||||
baseAppOptions ...func(*baseapp.BaseApp),
|
||||
@@ -605,10 +579,13 @@ func NewWasmApp(
|
||||
wasmOpts...,
|
||||
)
|
||||
|
||||
// DEPRECATED: DO NOT USE
|
||||
//
|
||||
// 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
|
||||
}
|
||||
// if len(enabledProposals) != 0 {
|
||||
// govRouter.AddRoute(wasmtypes.RouterKey, wasmkeeper.NewWasmProposalHandler(app.WasmKeeper, enabledProposals))
|
||||
//}
|
||||
|
||||
// Set legacy router for backwards compatibility with gov v1beta1
|
||||
app.GovKeeper.SetLegacyRouter(govRouter)
|
||||
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)),
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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" \
|
||||
|
||||
@@ -6,45 +6,28 @@ a high-level, technical introduction meant to provide context before
|
||||
looking into the code, or constructing proposals.
|
||||
|
||||
## Proposal Types
|
||||
We have added 9 new wasm specific proposal types that cover the contract's live cycle and authorization:
|
||||
We have added 15 new wasm specific proposal messages that cover the contract's live cycle and authorization:
|
||||
|
||||
* `StoreCodeProposal` - upload a wasm binary
|
||||
* `InstantiateContractProposal` - instantiate a wasm contract
|
||||
* `MigrateContractProposal` - migrate a wasm contract to a new code version
|
||||
* `SudoContractProposal` - call into the protected `sudo` entry point of a contract
|
||||
* `ExecuteContractProposal` - execute a wasm contract as an arbitrary user
|
||||
* `UpdateAdminProposal` - set a new admin for a contract
|
||||
* `ClearAdminProposal` - clear admin for a contract to prevent further migrations
|
||||
* `PinCodes` - pin the given code ids in cache. This trades memory for reduced startup time and lowers gas cost
|
||||
* `UnpinCodes` - unpin the given code ids from the cache. This frees up memory and returns to standard speed and gas cost
|
||||
* `UpdateInstantiateConfigProposal` - update instantiate permissions to a list of given code ids.
|
||||
* `StoreAndInstantiateContractProposal` - upload and instantiate a wasm contract.
|
||||
|
||||
For details see the proposal type [implementation](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/types/proposal.go)
|
||||
|
||||
### Unit tests
|
||||
[Proposal type validations](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/types/proposal_test.go)
|
||||
|
||||
## Proposal Handler
|
||||
The [wasmd proposal_handler](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/keeper/proposal_handler.go) implements the `gov.Handler` function
|
||||
and executes the wasmd proposal types after a successful tally.
|
||||
|
||||
The proposal handler uses a [`GovAuthorizationPolicy`](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/keeper/authz_policy.go#L29) to bypass the existing contract's authorization policy.
|
||||
|
||||
### Tests
|
||||
* [Integration: Submit and execute proposal](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/keeper/proposal_integration_test.go)
|
||||
|
||||
## Gov Integration
|
||||
The wasmd proposal handler can be added to the gov router in the [abci app](https://github.com/CosmWasm/wasmd/blob/master/app/app.go#L306)
|
||||
to receive proposal execution calls.
|
||||
```go
|
||||
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.wasmKeeper, enabledProposals))
|
||||
```
|
||||
* `MsgStoreCode` - upload a wasm binary
|
||||
* `MsgInstantiateContract` - instantiate a wasm contract
|
||||
* `MsgInstantiateContract2` - instantiate a wasm contract with a predictable address
|
||||
* `MsgMigrateContract` - migrate a wasm contract to a new code version
|
||||
* `MsgSudoContract` - call into the protected `sudo` entry point of a contract
|
||||
* `MsgExecuteContract` - execute a wasm contract as an arbitrary user
|
||||
* `MsgUpdateAdmin` - set a new admin for a contract
|
||||
* `MsgClearAdmin` - clear admin for a contract to prevent further migrations
|
||||
* `MsgPinCodes` - pin the given code ids in cache. This trades memory for reduced startup time and lowers gas cost
|
||||
* `MsgUnpinCodes` - unpin the given code ids from the cache. This frees up memory and returns to standard speed and gas cost
|
||||
* `MsgUpdateInstantiateConfig` - update instantiate permissions to a list of given code ids.
|
||||
* `MsgStoreAndInstantiateContract` - upload and instantiate a wasm contract.
|
||||
* `MsgRemoveCodeUploadParamsAddresses` - remove addresses from code upload params.
|
||||
* `MsgAddCodeUploadParamsAddresses` - add addresses to code upload params.
|
||||
* `MsgStoreAndMigrateContract` - upload and migrate a wasm contract.
|
||||
|
||||
## Wasmd Authorization Settings
|
||||
|
||||
Settings via sdk `params` module:
|
||||
- `code_upload_access` - who can upload a wasm binary: `Nobody`, `Everybody`, `OnlyAddress`
|
||||
- `code_upload_access` - who can upload a wasm binary: `Nobody`, `Everybody`, `AnyOfAddresses`
|
||||
- `instantiate_default_permission` - platform default, who can instantiate a wasm binary when the code owner has not set it
|
||||
|
||||
See [params.go](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/types/params.go)
|
||||
@@ -62,12 +45,19 @@ See [params.go](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/types/param
|
||||
},
|
||||
```
|
||||
|
||||
The values can be updated via gov proposal implemented in the `params` module.
|
||||
The values can be updated via gov proposal `MsgUpdateParams`.
|
||||
|
||||
### Update Params Via [ParamChangeProposal](https://github.com/cosmos/cosmos-sdk/blob/v0.45.3/proto/cosmos/params/v1beta1/params.proto#L10)
|
||||
### Update Params Via [MsgUpdateParams](https://github.com/CosmWasm/wasmd/blob/v0.41.0/proto/cosmwasm/wasm/v1/tx.proto#L263)
|
||||
Example to submit a parameter change gov proposal:
|
||||
|
||||
- First create a draft proposal using the interactive CLI
|
||||
```sh
|
||||
wasmd tx gov submit-proposal param-change <proposal-json-file> --from validator --chain-id=testing -b block
|
||||
wasmd tx gov draft-proposal
|
||||
```
|
||||
|
||||
- Submit the proposal
|
||||
```sh
|
||||
wasmd tx gov submit-proposal <proposal-json-file> --from validator --chain-id=testing -b block
|
||||
```
|
||||
#### Content examples
|
||||
* Disable wasm code uploads
|
||||
@@ -115,14 +105,34 @@ wasmd tx gov submit-proposal param-change <proposal-json-file> --from validator
|
||||
"subspace": "wasm",
|
||||
"key": "uploadAccess",
|
||||
"value": {
|
||||
"permission": "OnlyAddress",
|
||||
"address": "cosmos1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq0fr2sh"
|
||||
"permission": "AnyOfAddresses",
|
||||
"addresses": ["cosmos1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq0fr2sh"]
|
||||
}
|
||||
}
|
||||
],
|
||||
"deposit": ""
|
||||
}
|
||||
```
|
||||
|
||||
* Restrict code uploads to two addresses
|
||||
```json
|
||||
{
|
||||
"title": "Foo",
|
||||
"description": "Bar",
|
||||
"changes": [
|
||||
{
|
||||
"subspace": "wasm",
|
||||
"key": "uploadAccess",
|
||||
"value": {
|
||||
"permission": "AnyOfAddresses",
|
||||
"addresses": ["cosmos1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq0fr2sh", "cosmos1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0fr2sh"]
|
||||
}
|
||||
}
|
||||
],
|
||||
"deposit": ""
|
||||
}
|
||||
```
|
||||
|
||||
* Set chain **default** instantiation settings to nobody
|
||||
```json
|
||||
{
|
||||
@@ -154,15 +164,6 @@ wasmd tx gov submit-proposal param-change <proposal-json-file> --from validator
|
||||
}
|
||||
```
|
||||
|
||||
### Enable gov proposals at **compile time**.
|
||||
As gov proposals bypass the existing authorization policy they are disabled and require to be enabled at compile time.
|
||||
```
|
||||
-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)
|
||||
```
|
||||
|
||||
The `ParamChangeProposal` is always enabled.
|
||||
|
||||
### Tests
|
||||
* [params validation unit tests](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/types/params_test.go)
|
||||
* [genesis validation tests](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/types/genesis_test.go)
|
||||
@@ -171,35 +172,25 @@ The `ParamChangeProposal` is always enabled.
|
||||
## CLI
|
||||
|
||||
```shell script
|
||||
wasmd tx gov submit-proposal [command]
|
||||
wasmd tx wasm submit-proposal [command]
|
||||
|
||||
Available Commands:
|
||||
wasm-store Submit a wasm binary proposal
|
||||
instantiate-contract Submit an instantiate wasm contract proposal
|
||||
migrate-contract Submit a migrate wasm contract to a new code version proposal
|
||||
set-contract-admin Submit a new admin for a contract proposal
|
||||
clear-contract-admin Submit a clear admin for a contract to prevent further migrations proposal
|
||||
add-code-upload-params-addresses Submit an add code upload params addresses proposal to add addresses to code upload config params
|
||||
clear-contract-admin Submit a clear admin for a contract to prevent further migrations proposal
|
||||
execute-contract Submit a execute wasm contract proposal (run by any address)
|
||||
instantiate-contract Submit an instantiate wasm contract proposal
|
||||
instantiate-contract-2 Submit an instantiate wasm contract proposal with predictable address
|
||||
migrate-contract Submit a migrate wasm contract to a new code version proposal
|
||||
pin-codes Submit a pin code proposal for pinning a code to cache
|
||||
remove-code-upload-params-addresses Submit a remove code upload params addresses proposal to remove addresses from code upload config params
|
||||
set-contract-admin Submit a new admin for a contract proposal
|
||||
store-instantiate Submit and instantiate a wasm contract proposal
|
||||
sudo-contract Submit a sudo wasm contract proposal (to call privileged commands)
|
||||
unpin-codes Submit a unpin code proposal for unpinning a code to cache
|
||||
update-instantiate-config Submit an update instantiate config proposal.
|
||||
wasm-store Submit a wasm binary proposal
|
||||
...
|
||||
```
|
||||
## Rest
|
||||
New [`ProposalHandlers`](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/client/proposal_handler.go)
|
||||
|
||||
* Integration
|
||||
```shell script
|
||||
gov.NewAppModuleBasic(append(wasmclient.ProposalHandlers, paramsclient.ProposalHandler, distr.ProposalHandler, upgradeclient.ProposalHandler)...),
|
||||
```
|
||||
In [abci app](https://github.com/CosmWasm/wasmd/blob/master/app/app.go#L109)
|
||||
|
||||
### Tests
|
||||
* [Rest Unit tests](https://github.com/CosmWasm/wasmd/blob/master/x/wasm/client/proposal_handler_test.go)
|
||||
* [Rest smoke LCD test](https://github.com/CosmWasm/wasmd/blob/master/lcd_test/wasm_test.go)
|
||||
|
||||
|
||||
|
||||
## Pull requests
|
||||
* https://github.com/CosmWasm/wasmd/pull/190
|
||||
* https://github.com/CosmWasm/wasmd/pull/186
|
||||
* https://github.com/CosmWasm/wasmd/pull/183
|
||||
* https://github.com/CosmWasm/wasmd/pull/180
|
||||
* https://github.com/CosmWasm/wasmd/pull/179
|
||||
* https://github.com/CosmWasm/wasmd/pull/173
|
||||
|
||||
@@ -565,6 +565,7 @@ func TestInstantiateWithAccounts(t *testing.T) {
|
||||
|
||||
senderAddr := DeterministicAccountAddress(t, 1)
|
||||
keepers.Faucet.Fund(parentCtx, senderAddr, sdk.NewInt64Coin("denom", 100000000))
|
||||
myTestLabel := "testing"
|
||||
mySalt := []byte(`my salt`)
|
||||
contractAddr := BuildContractAddressPredictable(example.Checksum, senderAddr, mySalt, []byte{})
|
||||
|
||||
|
||||
@@ -26,6 +26,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{
|
||||
@@ -123,6 +124,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{
|
||||
@@ -181,6 +183,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{
|
||||
@@ -240,6 +243,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{
|
||||
@@ -321,6 +325,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{
|
||||
@@ -380,6 +385,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{
|
||||
@@ -460,6 +466,7 @@ func TestMigrateProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecuteProposal(t *testing.T) {
|
||||
t.Skip("DEPRECATED")
|
||||
ctx, keepers := CreateTestInput(t, false, "staking")
|
||||
bankKeeper := keepers.BankKeeper
|
||||
|
||||
@@ -515,6 +522,7 @@ func TestExecuteProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSudoProposal(t *testing.T) {
|
||||
t.Skip("DEPRECATED")
|
||||
ctx, keepers := CreateTestInput(t, false, "staking")
|
||||
bankKeeper := keepers.BankKeeper
|
||||
|
||||
@@ -562,6 +570,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)
|
||||
@@ -652,6 +661,7 @@ func TestAdminProposals(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPinCodesProposal(t *testing.T) {
|
||||
t.Skip("DEPRECATED")
|
||||
ctx, keepers := CreateTestInput(t, false, "staking")
|
||||
wasmKeeper := keepers.WasmKeeper
|
||||
|
||||
@@ -743,6 +753,7 @@ func TestPinCodesProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUnpinCodesProposal(t *testing.T) {
|
||||
t.Skip("DEPRECATED")
|
||||
ctx, keepers := CreateTestInput(t, false, "staking")
|
||||
wasmKeeper := keepers.WasmKeeper
|
||||
|
||||
@@ -833,6 +844,7 @@ func TestUnpinCodesProposal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateInstantiateConfigProposal(t *testing.T) {
|
||||
t.Skip("DEPRECATED")
|
||||
ctx, keepers := CreateTestInput(t, false, "staking")
|
||||
wasmKeeper := keepers.WasmKeeper
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user