From 0be5e3ba8aacbb88447009f1de0ba24c70d95c8e Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 24 Oct 2023 11:42:06 +0800 Subject: [PATCH] Problem: chain-id is not parsed from genesis config (#1217) * Problem: chain-id is not parsed from genesis config Solution: - simpliy use the default behavior in sdk * Update CHANGELOG.md Signed-off-by: yihuang --------- Signed-off-by: yihuang --- CHANGELOG.md | 1 + cmd/cronosd/cmd/root.go | 26 +------------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc3d16e300..905bf90c07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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* diff --git a/cmd/cronosd/cmd/root.go b/cmd/cronosd/cmd/root.go index 65d4502059..8e53172f17 100644 --- a/cmd/cronosd/cmd/root.go +++ b/cmd/cronosd/cmd/root.go @@ -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" @@ -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,