From 3c5a26ebb5fffd711d15f25e559e877c1b91d333 Mon Sep 17 00:00:00 2001 From: Kevin Yang <5478483+k-yang@users.noreply.github.com> Date: Fri, 28 Jul 2023 16:45:42 -0400 Subject: [PATCH 1/6] fix: use correct config key for db_backend --- server/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/util.go b/server/util.go index 40842f4b2c36..64421a90e44f 100644 --- a/server/util.go +++ b/server/util.go @@ -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 From c42a5f171829b1faf54cfa69513405c55c3e1b1a Mon Sep 17 00:00:00 2001 From: Kevin Yang <5478483+k-yang@users.noreply.github.com> Date: Fri, 28 Jul 2023 16:59:10 -0400 Subject: [PATCH 2/6] chore: update toml comment --- server/config/toml.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/config/toml.go b/server/config/toml.go index 877913fcf20b..6be3a84d353e 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -79,8 +79,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 }}" ############################################################################### From a556e8fd8c0c211387039262f1ae8ca2308c99f0 Mon Sep 17 00:00:00 2001 From: Kevin Yang <5478483+k-yang@users.noreply.github.com> Date: Fri, 28 Jul 2023 17:00:05 -0400 Subject: [PATCH 3/6] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa0fe324d1ec..61202edcb8e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (baseapp) [#17159](https://github.com/cosmos/cosmos-sdk/pull/17159) Validators can propose blocks that exceed the gas limit. * (x/group) [#17146](https://github.com/cosmos/cosmos-sdk/pull/17146) Rename x/group legacy ORM package's error codespace from "orm" to "legacy_orm", preventing collisions with ORM's error codespace "orm". * (x/bank) [#17170](https://github.com/cosmos/cosmos-sdk/pull/17170) Avoid empty spendable error message on send coins. +* (db_backend) [#17181](https://github.com/cosmos/cosmos-sdk/pull/17181) Fix `db_backend` lookup fallback from `config.toml` ### API Breaking Changes From 4e46b8d9f221af5b62f63bffe05393b90dadfe35 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 16 Aug 2023 14:05:25 +0200 Subject: [PATCH 4/6] update confix when relevant --- tools/confix/data/v0.47-app.toml | 10 ++++------ tools/confix/data/v0.50-app.toml | 6 ++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tools/confix/data/v0.47-app.toml b/tools/confix/data/v0.47-app.toml index c45f5f246bdd..c1f239f98e40 100644 --- a/tools/confix/data/v0.47-app.toml +++ b/tools/confix/data/v0.47-app.toml @@ -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 = "" ############################################################################### @@ -107,8 +106,7 @@ prometheus-retention-time = 0 # # Example: # [["chain_id", "cosmoshub-1"]] -global-labels = [ -] +global-labels = [] ############################################################################### ### API Configuration ### @@ -236,7 +234,7 @@ streamers = [] [streamers] [streamers.file] -keys = ["*", ] +keys = ["*"] write_dir = "" prefix = "" @@ -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 \ No newline at end of file +lru_size = 0 diff --git a/tools/confix/data/v0.50-app.toml b/tools/confix/data/v0.50-app.toml index 5e01e120d8b0..7de64885d515 100644 --- a/tools/confix/data/v0.50-app.toml +++ b/tools/confix/data/v0.50-app.toml @@ -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 = "" ############################################################################### @@ -107,8 +106,7 @@ prometheus-retention-time = 0 # # Example: # [["chain_id", "cosmoshub-1"]] -global-labels = [ -] +global-labels = [] ############################################################################### ### API Configuration ### From 532385e8bb388051291af54d1e55f1ae7bcc3e17 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 16 Aug 2023 14:14:04 +0200 Subject: [PATCH 5/6] add test --- server/util_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/util_test.go b/server/util_test.go index 9f8882380893..56cd69738963 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -12,8 +12,10 @@ import ( cmtcfg "github.com/cometbft/cometbft/config" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/stretchr/testify/require" + db "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -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) From 8d0ef63df460c9e13bd2bf262f2eeb9b7089bd13 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 16 Aug 2023 14:23:21 +0200 Subject: [PATCH 6/6] lint --- server/util_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/util_test.go b/server/util_test.go index 56cd69738963..1ca5c0dab9c5 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -11,11 +11,11 @@ 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" - db "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server"