Unverified Commit e8642532 authored by Ethan Frey's avatar Ethan Frey Committed by GitHub
Browse files

Add migration step to make x/wasm permissioned (#832)

* Add migration step to make x/wasm permissioned

* go fmt
parent c42447df
Showing with 13 additions and 8 deletions
+13 -8
......@@ -2,6 +2,7 @@ package app
import (
"encoding/json"
"github.com/CosmWasm/wasmd/x/wasm"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
)
......@@ -15,12 +16,6 @@ import (
// object provided to it during init.
type GenesisState map[string]json.RawMessage
const (
// DefaultMaxWasmCodeSize limit max bytes read to prevent gzip bombs
// 600 KB is copied from x/wasm, but you can customize here as desired
DefaultMaxWasmCodeSize = 600 * 1024 * 2
)
// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState() GenesisState {
encCfg := MakeEncodingConfig()
......@@ -31,7 +26,9 @@ func NewDefaultGenesisState() GenesisState {
Params: wasmtypes.Params{
CodeUploadAccess: wasmtypes.AllowNobody,
InstantiateDefaultPermission: wasmtypes.AccessTypeEverybody,
MaxWasmCodeSize: DefaultMaxWasmCodeSize,
// DefaultMaxWasmCodeSize limit max bytes read to prevent gzip bombs
// It is 1200 KB in x/wasm, update it later via governance if really needed
MaxWasmCodeSize: wasmtypes.DefaultMaxWasmCodeSize,
},
}
gen[wasm.ModuleName] = encCfg.Marshaler.MustMarshalJSON(&wasmGen)
......
......@@ -3,9 +3,10 @@ package v7
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/CosmWasm/wasmd/x/wasm"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
)
func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator,
......@@ -23,6 +24,13 @@ func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator,
return newVM, err
}
// Since we provide custom DefaultGenesis (privileges StoreCode) in app/genesis.go rather than
// the wasm module, we need to set the params here when migrating (is it is not customized).
params := wasmKeeper.GetParams(ctx)
params.CodeUploadAccess = wasmtypes.AllowNobody
wasmKeeper.SetParams(ctx, params)
// override here
return newVM, err
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment