Skip to content

Commit

Permalink
app: remove skipUpgradeHeights from NewRegenApp args
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Apr 22, 2024
1 parent 7950aa2 commit 9dee0eb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ type RegenApp struct {
}

// NewRegenApp returns a reference to an initialized RegenApp.
func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
invCheckPeriod uint,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp)) *RegenApp {
Expand Down Expand Up @@ -415,6 +415,8 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
groupConfig,
)

// get skipUpgradeHeights from the app options
skipUpgradeHeights := map[int64]bool{}
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
skipUpgradeHeights[int64(h)] = true
}
Expand Down
12 changes: 4 additions & 8 deletions app/client/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
// main function.
func NewRootCmd() *cobra.Command {
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
tempApp := app.NewRegenApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, nil, 1, simtestutil.NewAppOptionsWithFlagHome(app.DefaultNodeHome))
tempApp := app.NewRegenApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, 1, simtestutil.NewAppOptionsWithFlagHome(app.DefaultNodeHome))
encodingConfig := testutil.TestEncodingConfig{
InterfaceRegistry: tempApp.InterfaceRegistry(),
Codec: tempApp.AppCodec(),
Expand Down Expand Up @@ -231,14 +231,10 @@ func txCommand() *cobra.Command {
}

func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
skipUpgradeHeights := make(map[int64]bool)
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
skipUpgradeHeights[int64(h)] = true
}
baseappOptions := server.DefaultBaseappOptions(appOpts)

return app.NewRegenApp(
logger, db, traceStore, true, skipUpgradeHeights,
logger, db, traceStore, true,
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
appOpts,
baseappOptions...,
Expand Down Expand Up @@ -275,13 +271,13 @@ func appExport(
appOpts = viperAppOpts

if height != -1 {
regenApp = app.NewRegenApp(logger, db, traceStore, false, map[int64]bool{}, 1, appOpts)
regenApp = app.NewRegenApp(logger, db, traceStore, false, 1, appOpts)

if err := regenApp.LoadHeight(height); err != nil {
return servertypes.ExportedApp{}, err
}
} else {
regenApp = app.NewRegenApp(logger, db, traceStore, true, map[int64]bool{}, 1, appOpts)
regenApp = app.NewRegenApp(logger, db, traceStore, true, 1, appOpts)
}

return regenApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)
Expand Down
20 changes: 9 additions & 11 deletions app/testsuite/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,18 @@ var DefaultConsensusParams = &tmproto.ConsensusParams{

// SetupOptions defines arguments that are passed into `Simapp` constructor.
type SetupOptions struct {
Logger log.Logger
DB *dbm.MemDB
InvCheckPeriod uint
SkipUpgradeHeights map[int64]bool
AppOpts types.AppOptions
Logger log.Logger
DB *dbm.MemDB
InvCheckPeriod uint
AppOpts types.AppOptions
}

func DefaultOptions() SetupOptions {
return SetupOptions{
Logger: log.NewNopLogger(),
DB: dbm.NewMemDB(),
InvCheckPeriod: 5,
SkipUpgradeHeights: map[int64]bool{},
AppOpts: EmptyAppOptions{},
Logger: log.NewNopLogger(),
DB: dbm.NewMemDB(),
InvCheckPeriod: 5,
AppOpts: EmptyAppOptions{},
}
}

Expand All @@ -85,7 +83,7 @@ func NewAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptions)
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))),
}

regenApp := app.NewRegenApp(options.Logger, options.DB, nil, true, options.SkipUpgradeHeights, options.InvCheckPeriod, options.AppOpts)
regenApp := app.NewRegenApp(options.Logger, options.DB, nil, true, options.InvCheckPeriod, options.AppOpts)
genesisState := app.NewDefaultGenesisState(regenApp.AppCodec())
genesisState = genesisStateWithValSet(t, regenApp, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)

Expand Down
5 changes: 2 additions & 3 deletions app/testsuite/network_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ func NewTestNetworkFixture() network.TestFixture {
}
defer os.RemoveAll(dir)

a := app.NewRegenApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, map[int64]bool{}, 0,
a := app.NewRegenApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, 0,
simtestutil.NewAppOptionsWithFlagHome(dir))

appCtr := func(val network.ValidatorI) servertypes.Application {
cfg := val.GetAppConfig()
skipUpgrades := map[int64]bool{}

return app.NewRegenApp(
val.GetCtx().Logger, dbm.NewMemDB(), nil, true, skipUpgrades, 0,
val.GetCtx().Logger, dbm.NewMemDB(), nil, true, 0,
simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir),
baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(cfg.Pruning)),
baseapp.SetMinGasPrices(cfg.MinGasPrices),
Expand Down

0 comments on commit 9dee0eb

Please sign in to comment.