Skip to content

Commit

Permalink
Problem: chain-id is not parsed from genesis config (#1217)
Browse files Browse the repository at this point in the history
* Problem: chain-id is not parsed from genesis config

Solution:
- simpliy use the default behavior in sdk

* Update CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

---------

Signed-off-by: yihuang <huang@crypto.com>
  • Loading branch information
yihuang committed Oct 24, 2023
1 parent 44d0284 commit ed22664
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Bug Fixes

- [#1215](https://github.com/crypto-org-chain/cronos/pull/1215) Update ethermint to fix of concurrent write in fee history.
- [#1217](https://github.com/crypto-org-chain/cronos/pull/1217) Use the default chain-id behavour in sdk.

*October 17, 2023*

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"))
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

0 comments on commit ed22664

Please sign in to comment.