Skip to content

Commit

Permalink
fix(config): mempool.max-txs configuration is invalid (backport #17649)…
Browse files Browse the repository at this point in the history
… (#17651)
  • Loading branch information
mergify[bot] authored Sep 7, 2023
1 parent 9413cdd commit 980e17c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
19 changes: 19 additions & 0 deletions server/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"bytes"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 980e17c

Please sign in to comment.