From 45b57f0aae1cc564d391157b6a251b3f89fa1826 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Sat, 2 Sep 2023 06:15:29 +0200 Subject: [PATCH] feat: use DefaultBaseappOptions for app.New method (#3614) * add DefaultBaseappOptions * remove unused import * add changelog * Update ignite/pkg/cosmosanalysis/testdata/chain/go.mod Co-authored-by: Maksym Hontar <99190705+max-hontar@users.noreply.github.com> --------- Co-authored-by: Pantani Co-authored-by: Maksym Hontar <99190705+max-hontar@users.noreply.github.com> --- changelog.md | 5 +- .../pkg/cosmosanalysis/testdata/chain/go.mod | 2 +- .../{{binaryNamePrefix}}d/cmd/root.go.plush | 58 +------------------ 3 files changed, 3 insertions(+), 62 deletions(-) diff --git a/changelog.md b/changelog.md index 5d10c475c5..fba07df3c9 100644 --- a/changelog.md +++ b/changelog.md @@ -5,14 +5,11 @@ ### Features - [#3476](https://github.com/ignite/cli/pull/3476) Use `buf.build` binary to code generate from proto files +- [#3614](https://github.com/ignite/cli/pull/3614) feat: use DefaultBaseappOptions for app.New method - [#3536](https://github.com/ignite/cli/pull/3536) Change app.go to v2 and add AppWiring feature ### Changes -- [#3559](https://github.com/ignite/cli/pull/3559) Bump network plugin version to `v0.1.1` - -### Changes - - [#3581](https://github.com/ignite/cli/pull/3581) Bump cometbft and cometbft-db in the template - [#3559](https://github.com/ignite/cli/pull/3559) Bump network plugin version to `v0.1.1` - [#3522](https://github.com/ignite/cli/pull/3522) Remove indentation from `chain serve` output diff --git a/ignite/pkg/cosmosanalysis/testdata/chain/go.mod b/ignite/pkg/cosmosanalysis/testdata/chain/go.mod index b6531de06f..f2463f6dd2 100644 --- a/ignite/pkg/cosmosanalysis/testdata/chain/go.mod +++ b/ignite/pkg/cosmosanalysis/testdata/chain/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( cosmossdk.io/api v0.3.1 - github.com/cometbft/cometbft v0.37.1 + github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/cosmos-sdk v0.47.3 github.com/cosmos/gogoproto v1.4.10 diff --git a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush index 41062b9fb3..c8183e85c9 100644 --- a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush +++ b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush @@ -4,15 +4,12 @@ import ( "errors" "io" "os" - "path/filepath" "strings" dbm "github.com/cometbft/cometbft-db" tmcfg "github.com/cometbft/cometbft/config" tmcli "github.com/cometbft/cometbft/libs/cli" "github.com/cometbft/cometbft/libs/log" - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" @@ -22,10 +19,6 @@ import ( "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/snapshots" - snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" - "github.com/cosmos/cosmos-sdk/store" - sdk "github.com/cosmos/cosmos-sdk/types" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -228,67 +221,18 @@ func (a appCreator) newApp( traceStore io.Writer, appOpts servertypes.AppOptions, ) servertypes.Application { - var cache sdk.MultiStorePersistentCache - - if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) { - cache = store.NewCommitKVStoreCacheManager() - } - skipUpgradeHeights := make(map[int64]bool) for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { skipUpgradeHeights[int64(h)] = true } - pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts) - if err != nil { - panic(err) - } - - homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) - chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) - if chainID == "" { - // fallback to genesis chain-id - appGenesis, err := tmtypes.GenesisDocFromFile(filepath.Join(homeDir, "config", "genesis.json")) - if err != nil { - panic(err) - } - - chainID = appGenesis.ChainID - } - - snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots") - snapshotDB, err := dbm.NewDB("metadata", dbm.GoLevelDBBackend, snapshotDir) - if err != nil { - panic(err) - } - snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir) - if err != nil { - panic(err) - } - - snapshotOptions := snapshottypes.NewSnapshotOptions( - cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)), - cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)), - ) - return app.New( logger, db, traceStore, true, appOpts, - baseapp.SetPruning(pruningOpts), - baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), - baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))), - baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))), - baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))), - baseapp.SetInterBlockCache(cache), - baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))), - baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))), - baseapp.SetSnapshot(snapshotStore, snapshotOptions), - baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), - baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))), - baseapp.SetChainID(chainID), + server.DefaultBaseappOptions(appOpts)..., ) }