From 42c741ad2c9e4173c2c49a2475283f2c0c3cbef6 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 17 Nov 2023 17:09:36 +0000 Subject: [PATCH] refactor(simapp,confix): change example of custom app.toml extension (backport #18496) (#18497) Co-authored-by: Julien Robert --- simapp/simd/cmd/commands.go | 36 ++++++++++++++++---------------- tools/confix/CHANGELOG.md | 4 ++++ tools/confix/data/v0.45-app.toml | 12 ++--------- tools/confix/data/v0.46-app.toml | 12 ++--------- tools/confix/data/v0.47-app.toml | 7 ------- tools/confix/data/v0.50-app.toml | 7 ------- 6 files changed, 26 insertions(+), 52 deletions(-) diff --git a/simapp/simd/cmd/commands.go b/simapp/simd/cmd/commands.go index 1cf3415581..3607670e53 100644 --- a/simapp/simd/cmd/commands.go +++ b/simapp/simd/cmd/commands.go @@ -51,19 +51,18 @@ func initCometBFTConfig() *cmtcfg.Config { 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"` + // CustomConfig defines an arbitrary custom config to extend app.toml. + // If you don't need it, you can remove it. + // If you wish to add fields that correspond to flags that aren't in the SDK server config, + // this custom config can as well help. + type CustomConfig struct { + CustomField string `mapstructure:"custom-field"` } type CustomAppConfig struct { serverconfig.Config `mapstructure:",squash"` - WASM WASMConfig `mapstructure:"wasm"` + Custom CustomConfig `mapstructure:"custom"` } // Optionally allow the chain developer to overwrite the SDK's default @@ -77,28 +76,29 @@ func initAppConfig() (string, interface{}) { // 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 + // - if you set srvCfg.MinGasPrices non-empty, validatorcan be used to extend the app.toml.s 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" // srvCfg.BaseConfig.IAVLDisableFastNode = true // disable fastnode by default + // Now we set the custom config default values. customAppConfig := CustomAppConfig{ Config: *srvCfg, - WASM: WASMConfig{ - LruSize: 1, - QueryGasLimit: 300000, + Custom: CustomConfig{ + CustomField: "anything", }, } + // The default SDK app template is defined in serverconfig.DefaultConfigTemplate. + // We append the custom config template to the default one. + // And we set the default config to the custom app template. 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 = {{ .WASM.QueryGasLimit }} -# 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 = {{ .WASM.LruSize }}` +[custom] +# That field will be parsed by server.InterceptConfigsPreRunHandler and held by viper. +# Do not forget to add quotes around the value if it is a string. +custom-field = "{{ .Custom.CustomField }}"` return customAppTemplate, customAppConfig } diff --git a/tools/confix/CHANGELOG.md b/tools/confix/CHANGELOG.md index 6e5ab7f2ec..63f1be6f63 100644 --- a/tools/confix/CHANGELOG.md +++ b/tools/confix/CHANGELOG.md @@ -29,6 +29,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## [Unreleased] + +* [#18496](https://github.com/cosmos/cosmos-sdk/pull/18496) Remove invalid non SDK config from app.toml migration templates. + ## [v0.1.0](https://github.com/cosmos/cosmos-sdk/releases/tag/tools/confix/v0.1.0) - 2023-11-07 * [#17904](https://github.com/cosmos/cosmos-sdk/pull/17904) Add `view` command. diff --git a/tools/confix/data/v0.45-app.toml b/tools/confix/data/v0.45-app.toml index e6f15079c8..b0f6dff823 100644 --- a/tools/confix/data/v0.45-app.toml +++ b/tools/confix/data/v0.45-app.toml @@ -99,8 +99,7 @@ prometheus-retention-time = 0 # # Example: # [["chain_id", "cosmoshub-1"]] -global-labels = [ -] +global-labels = [] ############################################################################### ### API Configuration ### @@ -208,7 +207,7 @@ streamers = [] [streamers] [streamers.file] -keys = ["*", ] +keys = ["*"] write_dir = "" prefix = "" @@ -221,10 +220,3 @@ stop-node-on-error = "true" # fsync specifies if call fsync after writing the files. fsync = "false" - -[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 diff --git a/tools/confix/data/v0.46-app.toml b/tools/confix/data/v0.46-app.toml index 6dd5e64fbf..28a1087519 100644 --- a/tools/confix/data/v0.46-app.toml +++ b/tools/confix/data/v0.46-app.toml @@ -108,8 +108,7 @@ prometheus-retention-time = 0 # # Example: # [["chain_id", "cosmoshub-1"]] -global-labels = [ -] +global-labels = [] ############################################################################### ### API Configuration ### @@ -237,7 +236,7 @@ streamers = [] [streamers] [streamers.file] -keys = ["*", ] +keys = ["*"] write_dir = "" prefix = "" @@ -250,10 +249,3 @@ stop-node-on-error = "true" # fsync specifies if call fsync after writing the files. fsync = "false" - -[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 diff --git a/tools/confix/data/v0.47-app.toml b/tools/confix/data/v0.47-app.toml index dd9d7419a5..891431b8a5 100644 --- a/tools/confix/data/v0.47-app.toml +++ b/tools/confix/data/v0.47-app.toml @@ -260,10 +260,3 @@ fsync = "false" # Note, this configuration only applies to SDK built-in app-side mempool # implementations. max-txs = 5000 - -[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 diff --git a/tools/confix/data/v0.50-app.toml b/tools/confix/data/v0.50-app.toml index 4574f2503c..d7b7aa48c2 100644 --- a/tools/confix/data/v0.50-app.toml +++ b/tools/confix/data/v0.50-app.toml @@ -222,10 +222,3 @@ stop-node-on-err = true # Note, this configuration only applies to SDK built-in app-side mempool # implementations. max-txs = 5000 - -[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