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 proper db_backend type when reading chain-id #19573

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Changes from 1 commit
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
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"))
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
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
Loading