Skip to content

Commit 72a6397

Browse files
fix: use correct config key for db_backend (backport #17406) (#17411)
Co-authored-by: Julien Robert <julien@rbrt.fr>
1 parent 0a28ba9 commit 72a6397

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4747

4848
### Bug Fixes
4949

50+
* (server) [#17181](https://github.com/cosmos/cosmos-sdk/pull/17181) Fix `db_backend` lookup fallback from `config.toml`.
5051
* (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.
5152
* (baseapp) [#17159](https://github.com/cosmos/cosmos-sdk/pull/17159) Validators can propose blocks that exceed the gas limit.
5253
* (baseapp) [#16547](https://github.com/cosmos/cosmos-sdk/pull/16547) Ensure a transaction's gas limit cannot exceed the block gas limit.

server/config/toml.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ iavl-lazy-loading = {{ .BaseConfig.IAVLLazyLoading }}
8383
8484
# AppDBBackend defines the database backend type to use for the application and snapshots DBs.
8585
# An empty string indicates that a fallback will be used.
86-
# First fallback is the deprecated compile-time types.DBBackend value.
87-
# Second fallback (if the types.DBBackend also isn't set), is the db-backend value set in Tendermint's config.toml.
86+
# The fallback is the db_backend value set in Tendermint's config.toml.
8887
app-db-backend = "{{ .BaseConfig.AppDBBackend }}"
8988
9089
###############################################################################

server/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ func WaitForQuitSignals() ErrorCode {
392392
func GetAppDBBackend(opts types.AppOptions) dbm.BackendType {
393393
rv := cast.ToString(opts.Get("app-db-backend"))
394394
if len(rv) == 0 {
395-
rv = cast.ToString(opts.Get("db-backend"))
395+
rv = cast.ToString(opts.Get("db_backend"))
396396
}
397397
if len(rv) != 0 {
398398
return dbm.BackendType(rv)

server/util_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import (
1010
"strings"
1111
"testing"
1212

13+
db "github.com/cometbft/cometbft-db"
1314
tmcfg "github.com/cometbft/cometbft/config"
1415
"github.com/spf13/cobra"
16+
"github.com/spf13/viper"
1517
"github.com/stretchr/testify/require"
1618

1719
"github.com/cosmos/cosmos-sdk/client"
@@ -38,6 +40,15 @@ func preRunETestImpl(cmd *cobra.Command, args []string) error {
3840
return cancelledInPreRun
3941
}
4042

43+
func TestGetAppDBBackend(t *testing.T) {
44+
v := viper.New()
45+
require.Equal(t, server.GetAppDBBackend(v), db.GoLevelDBBackend)
46+
v.Set("db_backend", "dbtype1") // value from CometBFT config
47+
require.Equal(t, server.GetAppDBBackend(v), db.BackendType("dbtype1"))
48+
v.Set("app-db-backend", "dbtype2") // value from app.toml
49+
require.Equal(t, server.GetAppDBBackend(v), db.BackendType("dbtype2"))
50+
}
51+
4152
func TestInterceptConfigsPreRunHandlerCreatesConfigFilesWhenMissing(t *testing.T) {
4253
tempDir := t.TempDir()
4354
cmd := server.StartCmd(nil, "/foobar")

0 commit comments

Comments
 (0)