From 980e17c4304f103420f169050a9a2f97979c7184 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 7 Sep 2023 08:40:09 +0200 Subject: [PATCH] fix(config): mempool.max-txs configuration is invalid (backport #17649) (#17651) --- CHANGELOG.md | 4 ++++ server/config/config.go | 2 +- server/config/config_test.go | 19 +++++++++++++++++++ server/config/toml.go | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02203d95b8b8..47613d5b84ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Bug Fixes + +* (config) [#17649](https://github.com/cosmos/cosmos-sdk/pull/17649) Fix `mempool.max-txs` configuration is invalid in `app.config`. + ## [v0.47.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.5) - 2023-09-01 ### Features diff --git a/server/config/config.go b/server/config/config.go index 90dad0c943cb..3e01afe60757 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -209,7 +209,7 @@ type MempoolConfig struct { // the mempool is disabled entirely, zero indicates that the mempool is // unbounded in how many txs it may contain, and a positive value indicates // the maximum amount of txs it may contain. - MaxTxs int + MaxTxs int `mapstructure:"max-txs"` } type ( diff --git a/server/config/config_test.go b/server/config/config_test.go index c18244d36220..a706424d8833 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -2,6 +2,7 @@ package config import ( "bytes" + "os" "path/filepath" "testing" @@ -165,3 +166,21 @@ func TestSetConfigTemplate(t *testing.T) { actual := setBuffer.String() require.Equal(t, expected, actual, "resulting config strings") } + +func TestAppConfig(t *testing.T) { + appConfigFile := filepath.Join(t.TempDir(), "app.toml") + defer func() { + _ = os.Remove(appConfigFile) + }() + + defAppConfig := DefaultConfig() + SetConfigTemplate(DefaultConfigTemplate) + WriteConfigFile(appConfigFile, defAppConfig) + + v := viper.New() + v.SetConfigFile(appConfigFile) + require.NoError(t, v.ReadInConfig()) + appCfg := new(Config) + require.NoError(t, v.Unmarshal(appCfg)) + require.EqualValues(t, appCfg, defAppConfig) +} diff --git a/server/config/toml.go b/server/config/toml.go index 1ec7ce6a2e2d..870bcb618bdc 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -272,7 +272,7 @@ fsync = "{{ .Streamers.File.Fsync }}" # # Note, this configuration only applies to SDK built-in app-side mempool # implementations. -max-txs = "{{ .Mempool.MaxTxs }}" +max-txs = {{ .Mempool.MaxTxs }} ` var configTemplate *template.Template