From 0fa4c54a98397e769d8b18fb238f7af1bbf4ca93 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 7 Sep 2023 08:40:29 +0200 Subject: [PATCH] fix(config): mempool.max-txs configuration is invalid (backport #17649) (#17650) --- CHANGELOG.md | 1 + server/config/config.go | 2 +- server/config/config_test.go | 18 ++++++++++++++++++ server/config/toml.go | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81e9134cafd7..a90cc99c14f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (baseapp) [#17518](https://github.com/cosmos/cosmos-sdk/pull/17518) Utilizing voting power from vote extensions (CometBFT) instead of the current bonded tokens (x/staking) to determine if a set of vote extensions are valid. +* (config) [#17649](https://github.com/cosmos/cosmos-sdk/pull/17649) Fix `mempool.max-txs` configuration is invalid in `app.config`. ## [v0.50.0-rc.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.0-rc.0) - 2023-08-18 diff --git a/server/config/config.go b/server/config/config.go index 107b3aabf1f1..0020e4be3b4b 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -166,7 +166,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"` } // State Streaming configuration diff --git a/server/config/config_test.go b/server/config/config_test.go index c15186e73a2d..662fd06e3f8e 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -208,3 +208,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 8c0a615cd955..14f82bf61cc0 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -234,7 +234,7 @@ stop-node-on-err = {{ .Streaming.ABCI.StopNodeOnErr }} # # 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