Skip to content

Commit

Permalink
fix: use correct config key for db_backend (backport #17406) (#17411)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
mergify[bot] and julienrbrt authored Aug 16, 2023
1 parent 0a28ba9 commit 72a6397
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand Down

0 comments on commit 72a6397

Please sign in to comment.