diff --git a/CHANGELOG.md b/CHANGELOG.md index 589ea2b29..f4c2a7962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (server) [#17181](https://github.com/cosmos/cosmos-sdk/pull/17181) Fix `db_backend` lookup fallback from `config.toml`. * (runtime) [#17284](https://github.com/cosmos/cosmos-sdk/pull/17284) Properly allow to combine depinject-enabled modules and non-depinject-enabled modules in app v2. * (baseapp) [#17159](https://github.com/cosmos/cosmos-sdk/pull/17159) Validators can propose blocks that exceed the gas limit. * (baseapp) [#16547](https://github.com/cosmos/cosmos-sdk/pull/16547) Ensure a transaction's gas limit cannot exceed the block gas limit. diff --git a/server/config/toml.go b/server/config/toml.go index 666d98463..1ec7ce6a2 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -83,8 +83,7 @@ iavl-lazy-loading = {{ .BaseConfig.IAVLLazyLoading }} # AppDBBackend defines the database backend type to use for the application and snapshots DBs. # An empty string indicates that a fallback will be used. -# First fallback is the deprecated compile-time types.DBBackend value. -# Second fallback (if the types.DBBackend also isn't set), is the db-backend value set in Tendermint's config.toml. +# The fallback is the db_backend value set in Tendermint's config.toml. app-db-backend = "{{ .BaseConfig.AppDBBackend }}" ############################################################################### diff --git a/server/util.go b/server/util.go index 58323b0d2..9a6ae40f7 100644 --- a/server/util.go +++ b/server/util.go @@ -392,7 +392,7 @@ func WaitForQuitSignals() ErrorCode { func GetAppDBBackend(opts types.AppOptions) dbm.BackendType { rv := cast.ToString(opts.Get("app-db-backend")) if len(rv) == 0 { - rv = cast.ToString(opts.Get("db-backend")) + rv = cast.ToString(opts.Get("db_backend")) } if len(rv) != 0 { return dbm.BackendType(rv) diff --git a/server/util_test.go b/server/util_test.go index 85e14a625..2b897c919 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -10,8 +10,10 @@ import ( "strings" "testing" + db "github.com/cometbft/cometbft-db" tmcfg "github.com/cometbft/cometbft/config" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client" @@ -38,6 +40,15 @@ func preRunETestImpl(cmd *cobra.Command, args []string) error { return cancelledInPreRun } +func TestGetAppDBBackend(t *testing.T) { + v := viper.New() + require.Equal(t, server.GetAppDBBackend(v), db.GoLevelDBBackend) + v.Set("db_backend", "dbtype1") // value from CometBFT config + require.Equal(t, server.GetAppDBBackend(v), db.BackendType("dbtype1")) + v.Set("app-db-backend", "dbtype2") // value from app.toml + require.Equal(t, server.GetAppDBBackend(v), db.BackendType("dbtype2")) +} + func TestInterceptConfigsPreRunHandlerCreatesConfigFilesWhenMissing(t *testing.T) { tempDir := t.TempDir() cmd := server.StartCmd(nil, "/foobar")