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

Problem: chain-id is not parsed from genesis config #1217

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## UNRELEASED

### Bug Fixes

- [#1217](https://github.com/crypto-org-chain/cronos/pull/1217) Use the default chain-id behavour in sdk.

*October 17, 2023*

## v1.1.0-rc1
Expand Down
26 changes: 1 addition & 25 deletions cmd/cronosd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import (
"errors"
"io"
"os"
"path/filepath"

"cosmossdk.io/simapp/params"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/spf13/viper"

dbm "github.com/cometbft/cometbft-db"
tmcfg "github.com/cometbft/cometbft/config"
Expand Down Expand Up @@ -243,36 +241,14 @@ type appCreator struct {
// newApp is an AppCreator
func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
home := cast.ToString(appOpts.Get(flags.FlagHome))
snapshotDir := filepath.Join(home, "data", "snapshots")
if err := os.MkdirAll(snapshotDir, os.ModePerm); err != nil {
panic(err)
}

skipUpgradeHeights := make(map[int64]bool)
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
skipUpgradeHeights[int64(h)] = true
}

// Setup chainId
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
if len(chainID) == 0 {
v := viper.New()
v.AddConfigPath(filepath.Join(home, "config"))
yihuang marked this conversation as resolved.
Show resolved Hide resolved
v.SetConfigName("client")
v.SetConfigType("toml")
if err := v.ReadInConfig(); err != nil {
panic(err)
}
conf := new(config.ClientConfig)
if err := v.Unmarshal(conf); err != nil {
panic(err)
}
chainID = conf.ChainID
}
baseappOptions := server.DefaultBaseappOptions(appOpts)
baseappOptions = append(baseappOptions, func(app *baseapp.BaseApp) {
baseapp.SetChainID(chainID)
})

return app.New(
logger, db, traceStore, true, SkipGravity, skipUpgradeHeights,
home,
Expand Down
Loading