Skip to content

Commit

Permalink
fix: use proper db_backend type when reading chain-id (#19573)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang committed Feb 27, 2024
1 parent f7dc97b commit 792b6da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit 792b6da

Please sign in to comment.