diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dba91e888f1..1e078ca0a4e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Bug Fixes + +* (server) [#19573](https://github.com/cosmos/cosmos-sdk/pull/19573) Use proper `db_backend` type when reading chain-id + ## [v0.47.9](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.9) - 2024-02-19 ### Bug Fixes diff --git a/server/util.go b/server/util.go index 2348fb4c1634..e22137aad0da 100644 --- a/server/util.go +++ b/server/util.go @@ -462,7 +462,8 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) { chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) if chainID == "" { // read the chainID from home directory (either from comet or genesis). - chainId, err := readChainIdFromHome(homeDir) + dbBackend := cast.ToString(appOpts.Get("db_backend")) + chainId, err := readChainIdFromHome(homeDir, dbBackend) if err != nil { panic(err) } @@ -503,9 +504,10 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) { } // readChainIdFromHome reads chain id from home directory. -func readChainIdFromHome(homeDir string) (string, error) { +func readChainIdFromHome(homeDir string, dbBackend string) (string, error) { cfg := tmcfg.DefaultConfig() cfg.SetRoot(homeDir) + cfg.BaseConfig.DBBackend = dbBackend // if the node's current height is not zero then try to read the chainID from comet db. db, err := node.DefaultDBProvider(&node.DBContext{ID: "blockstore", Config: cfg})