@@ -6,14 +6,6 @@ import (
66 "os"
77 "path/filepath"
88
9- "github.com/spf13/cast"
10- "github.com/spf13/cobra"
11- "github.com/spf13/pflag"
12-
13- tmcli "github.com/tendermint/tendermint/libs/cli"
14- "github.com/tendermint/tendermint/libs/log"
15- dbm "github.com/tendermint/tm-db"
16-
179 "github.com/cosmos/cosmos-sdk/baseapp"
1810 "github.com/cosmos/cosmos-sdk/client"
1911 "github.com/cosmos/cosmos-sdk/client/config"
@@ -22,18 +14,24 @@ import (
2214 "github.com/cosmos/cosmos-sdk/client/keys"
2315 "github.com/cosmos/cosmos-sdk/client/rpc"
2416 "github.com/cosmos/cosmos-sdk/server"
17+ serverconfig "github.com/cosmos/cosmos-sdk/server/config"
2518 servertypes "github.com/cosmos/cosmos-sdk/server/types"
2619 "github.com/cosmos/cosmos-sdk/snapshots"
2720 "github.com/cosmos/cosmos-sdk/store"
2821 sdk "github.com/cosmos/cosmos-sdk/types"
2922 "github.com/cosmos/cosmos-sdk/types/module"
30- authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
3123 authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
3224 "github.com/cosmos/cosmos-sdk/x/auth/types"
3325 vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
3426 banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
3527 "github.com/cosmos/cosmos-sdk/x/crisis"
3628 genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
29+ "github.com/spf13/cast"
30+ "github.com/spf13/cobra"
31+ "github.com/spf13/pflag"
32+ tmcli "github.com/tendermint/tendermint/libs/cli"
33+ "github.com/tendermint/tendermint/libs/log"
34+ dbm "github.com/tendermint/tm-db"
3735)
3836
3937type (
@@ -125,7 +123,7 @@ func NewRootCmd(
125123
126124 encodingConfig := MakeEncodingConfig(moduleBasics)
127125 initClientCtx := client.Context{}.
128- WithJSONMarshaler (encodingConfig.Marshaler).
126+ WithCodec (encodingConfig.Marshaler).
129127 WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
130128 WithTxConfig(encodingConfig.TxConfig).
131129 WithLegacyAmino(encodingConfig.Amino).
@@ -150,7 +148,9 @@ func NewRootCmd(
150148 return err
151149 }
152150
153- return server.InterceptConfigsPreRunHandler(cmd)
151+ customAppTemplate, customAppConfig := initAppConfig()
152+
153+ return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig)
154154 },
155155 }
156156
@@ -178,8 +178,6 @@ func initRootCmd(
178178 buildApp AppBuilder,
179179 options rootOptions,
180180) {
181- authclient.Codec = encodingConfig.Marshaler
182-
183181 rootCmd.AddCommand(
184182 genutilcli.InitCmd(moduleBasics, defaultNodeHome),
185183 genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, defaultNodeHome),
@@ -400,3 +398,59 @@ func (a appCreator) appExport(
400398
401399 return exportableApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
402400}
401+
402+ // initAppConfig helps to override default appConfig template and configs.
403+ // return "", nil if no custom configuration is required for the application.
404+ func initAppConfig() (string, interface{}) {
405+ // The following code snippet is just for reference.
406+
407+ // WASMConfig defines configuration for the wasm module.
408+ type WASMConfig struct {
409+ // This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
410+ QueryGasLimit uint64 `mapstructure:"query_gas_limit"`
411+
412+ // Address defines the gRPC-web server to listen on
413+ LruSize uint64 `mapstructure:"lru_size"`
414+ }
415+
416+ type CustomAppConfig struct {
417+ serverconfig.Config
418+
419+ WASM WASMConfig `mapstructure:"wasm"`
420+ }
421+
422+ // Optionally allow the chain developer to overwrite the SDK's default
423+ // server config.
424+ srvCfg := serverconfig.DefaultConfig()
425+ // The SDK's default minimum gas price is set to "" (empty value) inside
426+ // app.toml. If left empty by validators, the node will halt on startup.
427+ // However, the chain developer can set a default app.toml value for their
428+ // validators here.
429+ //
430+ // In summary:
431+ // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their
432+ // own app.toml config,
433+ // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their
434+ // own app.toml to override, or use this default value.
435+ //
436+ // In simapp, we set the min gas prices to 0.
437+ srvCfg.MinGasPrices = "0stake"
438+
439+ customAppConfig := CustomAppConfig{
440+ Config: *srvCfg,
441+ WASM: WASMConfig{
442+ LruSize: 1,
443+ QueryGasLimit: 300000,
444+ },
445+ }
446+
447+ customAppTemplate := serverconfig.DefaultConfigTemplate + `
448+ [wasm]
449+ # This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
450+ query_gas_limit = 300000
451+ # This is the number of wasm vm instances we keep cached in memory for speed-up
452+ # Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally
453+ lru_size = 0`
454+
455+ return customAppTemplate, customAppConfig
456+ }
0 commit comments