Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct config key for db_backend #17406

Merged
merged 7 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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) [#17251](https://github.com/cosmos/cosmos-sdk/pull/17251) VerifyVoteExtensions and ExtendVote initialize their own contexts/states, allowing VerifyVoteExtensions being called without ExtendVote.
* (x/auth) [#17209](https://github.com/cosmos/cosmos-sdk/pull/17209) Internal error on AccountInfo when account's public key is not set.
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-disable-fastnode = {{ .BaseConfig.IAVLDisableFastNode }}

# 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 CometBFT's config.toml.
# The fallback is the db_backend value set in CometBFT'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 @@ -403,7 +403,7 @@ func ListenForQuitSignals(g *errgroup.Group, block bool, cancelFn context.Cancel
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"))
}

// Cosmos SDK has migrated to cosmos-db which does not support all the backends which tm-db supported
Expand Down
11 changes: 11 additions & 0 deletions server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"testing"

cmtcfg "github.com/cometbft/cometbft/config"
db "github.com/cosmos/cosmos-db"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -37,6 +39,15 @@ func preRunETestImpl(cmd *cobra.Command, args []string) error {
return errCanceledInPreRun
}

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)
Expand Down
10 changes: 4 additions & 6 deletions tools/confix/data/v0.47-app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ iavl-lazy-loading = false

# 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 = ""

###############################################################################
Expand Down Expand Up @@ -107,8 +106,7 @@ prometheus-retention-time = 0
#
# Example:
# [["chain_id", "cosmoshub-1"]]
global-labels = [
]
global-labels = []

###############################################################################
### API Configuration ###
Expand Down Expand Up @@ -236,7 +234,7 @@ streamers = []

[streamers]
[streamers.file]
keys = ["*", ]
keys = ["*"]
write_dir = ""
prefix = ""

Expand Down Expand Up @@ -268,4 +266,4 @@ max-txs = "5000"
query_gas_limit = 300000
# This is the number of wasm vm instances we keep cached in memory for speed-up
# Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally
lru_size = 0
lru_size = 0
6 changes: 2 additions & 4 deletions tools/confix/data/v0.50-app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ iavl-disable-fastnode = false

# 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 CometBFT's config.toml.
# The fallback is the db_backend value set in CometBFT's config.toml.
app-db-backend = ""

###############################################################################
Expand Down Expand Up @@ -107,8 +106,7 @@ prometheus-retention-time = 0
#
# Example:
# [["chain_id", "cosmoshub-1"]]
global-labels = [
]
global-labels = []

###############################################################################
### API Configuration ###
Expand Down