fix: use correct config key for db_backend (backport #17406) (#17411)

Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
mergify[bot] 2023-08-16 21:43:20 +02:00 committed by GitHub
parent 0a28ba9f3f
commit 72a6397f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

View File

@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes ### 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. * (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) [#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. * (baseapp) [#16547](https://github.com/cosmos/cosmos-sdk/pull/16547) Ensure a transaction's gas limit cannot exceed the block gas limit.

View File

@ -83,8 +83,7 @@ iavl-lazy-loading = {{ .BaseConfig.IAVLLazyLoading }}
# AppDBBackend defines the database backend type to use for the application and snapshots DBs. # AppDBBackend defines the database backend type to use for the application and snapshots DBs.
# An empty string indicates that a fallback will be used. # An empty string indicates that a fallback will be used.
# First fallback is the deprecated compile-time types.DBBackend value. # The fallback is the db_backend value set in Tendermint's config.toml.
# Second fallback (if the types.DBBackend also isn't set), is the db-backend value set in Tendermint's config.toml.
app-db-backend = "{{ .BaseConfig.AppDBBackend }}" app-db-backend = "{{ .BaseConfig.AppDBBackend }}"
############################################################################### ###############################################################################

View File

@ -392,7 +392,7 @@ func WaitForQuitSignals() ErrorCode {
func GetAppDBBackend(opts types.AppOptions) dbm.BackendType { func GetAppDBBackend(opts types.AppOptions) dbm.BackendType {
rv := cast.ToString(opts.Get("app-db-backend")) rv := cast.ToString(opts.Get("app-db-backend"))
if len(rv) == 0 { if len(rv) == 0 {
rv = cast.ToString(opts.Get("db-backend")) rv = cast.ToString(opts.Get("db_backend"))
} }
if len(rv) != 0 { if len(rv) != 0 {
return dbm.BackendType(rv) return dbm.BackendType(rv)

View File

@ -10,8 +10,10 @@ import (
"strings" "strings"
"testing" "testing"
db "github.com/cometbft/cometbft-db"
tmcfg "github.com/cometbft/cometbft/config" tmcfg "github.com/cometbft/cometbft/config"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
@ -38,6 +40,15 @@ func preRunETestImpl(cmd *cobra.Command, args []string) error {
return cancelledInPreRun 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) { func TestInterceptConfigsPreRunHandlerCreatesConfigFilesWhenMissing(t *testing.T) {
tempDir := t.TempDir() tempDir := t.TempDir()
cmd := server.StartCmd(nil, "/foobar") cmd := server.StartCmd(nil, "/foobar")