-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
refactor: provide a helper for baseapp options #14175
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,9 @@ import ( | |
"errors" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
|
||
rosettaCmd "cosmossdk.io/tools/rosetta/cmd" | ||
|
||
"github.com/spf13/cast" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
tmcfg "github.com/tendermint/tendermint/config" | ||
|
@@ -18,7 +16,6 @@ import ( | |
"cosmossdk.io/simapp" | ||
"cosmossdk.io/simapp/params" | ||
|
||
"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" | ||
|
@@ -29,12 +26,8 @@ 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/store" | ||
"github.com/cosmos/cosmos-sdk/store/snapshots" | ||
snapshottypes "github.com/cosmos/cosmos-sdk/store/snapshots/types" | ||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/mempool" | ||
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" | ||
|
@@ -263,52 +256,13 @@ func 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is sad that we have no tooling to catch these. I thought golanglint was smart enough to see this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missed this one thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm this seems like it was a bug, it was never used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this is what I meant. It wasn't used and no tooling catched that before you. So it's kinda sad that there is no tooling to catch that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A linter wouldn't catch this as |
||
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { | ||
skipUpgradeHeights[int64(h)] = true | ||
} | ||
|
||
pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots") | ||
snapshotDB, err := dbm.NewDB("metadata", server.GetAppDBBackend(appOpts), 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)), | ||
) | ||
baseappOptions := server.DefaultBaseappOptions(appOpts) | ||
|
||
return simapp.NewSimApp( | ||
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.SetMempool(mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(cast.ToInt(appOpts.Get(server.FlagMempoolMaxTxs))))), | ||
baseappOptions..., | ||
) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DefaultBaseAppOptions