From bc65a831a448b5dd01350f40cba697b576b0a9e7 Mon Sep 17 00:00:00 2001 From: Marko Date: Sat, 8 Jan 2022 08:05:25 +0100 Subject: [PATCH] remove duplicate app.toml code (#737) * remove duplicate code * touchup Co-authored-by: Marko Baricevic --- cmd/osmosisd/cmd/init.go | 9 -------- cmd/osmosisd/cmd/root.go | 47 +++++----------------------------------- 2 files changed, 5 insertions(+), 51 deletions(-) diff --git a/cmd/osmosisd/cmd/init.go b/cmd/osmosisd/cmd/init.go index cfc36de119c..3902f1e5394 100644 --- a/cmd/osmosisd/cmd/init.go +++ b/cmd/osmosisd/cmd/init.go @@ -23,7 +23,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/server" - appcfg "github.com/cosmos/cosmos-sdk/server/config" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -100,13 +99,6 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { config.SetRoot(clientCtx.HomeDir) - //Override default settings in app.toml - appConfig := appcfg.DefaultConfig() - appConfig.API.Enable = true - appConfig.StateSync.SnapshotInterval = 1500 - appConfig.StateSync.SnapshotKeepRecent = 2 - appConfig.MinGasPrices = "0uosmo" - chainID, _ := cmd.Flags().GetString(flags.FlagChainID) if chainID == "" { chainID = fmt.Sprintf("test-chain-%v", tmrand.Str(6)) @@ -167,7 +159,6 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { toPrint := newPrintInfo(config.Moniker, chainID, nodeID, "", appState) tmcfg.WriteConfigFile(filepath.Join(config.RootDir, "config", "config.toml"), config) - appcfg.WriteConfigFile(filepath.Join(config.RootDir, "config", "app.toml"), appConfig) return displayInfo(toPrint) }, diff --git a/cmd/osmosisd/cmd/root.go b/cmd/osmosisd/cmd/root.go index 9b59e153adb..50d11731eb1 100644 --- a/cmd/osmosisd/cmd/root.go +++ b/cmd/osmosisd/cmd/root.go @@ -81,57 +81,20 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { // initAppConfig helps to override default appConfig template and configs. // return "", nil if no custom configuration is required for the application. func initAppConfig() (string, interface{}) { - // The following code snippet is just for reference. - - // WASMConfig defines configuration for the wasm module. - type WASMConfig struct { - // This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries - QueryGasLimit uint64 `mapstructure:"query_gas_limit"` - - // Address defines the gRPC-web server to listen on - LruSize uint64 `mapstructure:"lru_size"` - } type CustomAppConfig struct { serverconfig.Config - - WASM WASMConfig `mapstructure:"wasm"` } // Optionally allow the chain developer to overwrite the SDK's default // server config. srvCfg := serverconfig.DefaultConfig() - // The SDK's default minimum gas price is set to "" (empty value) inside - // app.toml. If left empty by validators, the node will halt on startup. - // However, the chain developer can set a default app.toml value for their - // validators here. - // - // In summary: - // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their - // own app.toml config, - // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their - // own app.toml to override, or use this default value. - // - // In simapp, we set the min gas prices to 0. - srvCfg.MinGasPrices = "0stake" - - customAppConfig := CustomAppConfig{ - Config: *srvCfg, - WASM: WASMConfig{ - LruSize: 1, - QueryGasLimit: 300000, - }, - } - - customAppTemplate := serverconfig.DefaultConfigTemplate + ` -[wasm] -# This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries -query_gas_limit = 300000 -# This is the number of wasm vm instances we keep cached in memory for speed-up -# Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally -lru_size = 0` + srvCfg.API.Enable = true + srvCfg.StateSync.SnapshotInterval = 1500 + srvCfg.StateSync.SnapshotKeepRecent = 2 + srvCfg.MinGasPrices = "0uosmo" - return customAppTemplate, customAppConfig + return serverconfig.DefaultConfigTemplate, CustomAppConfig{Config: *srvCfg} } func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {