Skip to content

Commit

Permalink
move homePath & invCheckPeriod to appOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
colmazia committed Aug 11, 2023
1 parent 3bcd237 commit 91a0fe6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
20 changes: 14 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import (
tmos "github.com/cometbft/cometbft/libs/os"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -200,8 +202,6 @@ type BandApp struct {
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry

invCheckPeriod uint

// keys to access the substores.
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
Expand Down Expand Up @@ -241,9 +241,14 @@ func SetBech32AddressPrefixesAndBip44CoinTypeAndSeal(config *sdk.Config) {

// NewBandApp returns a reference to an initialized BandApp.
func NewBandApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
homePath string, invCheckPeriod uint, appOpts servertypes.AppOptions,
owasmCacheSize uint32, baseAppOptions ...func(*baseapp.BaseApp),
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
skipUpgradeHeights map[int64]bool,
appOpts servertypes.AppOptions,
owasmCacheSize uint32,
baseAppOptions ...func(*baseapp.BaseApp),
) *BandApp {
encodingConfig := MakeEncodingConfig()

Expand Down Expand Up @@ -286,7 +291,6 @@ func NewBandApp(
legacyAmino: legacyAmino,
appCodec: appCodec,
interfaceRegistry: interfaceRegistry,
invCheckPeriod: invCheckPeriod,
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
Expand Down Expand Up @@ -385,6 +389,8 @@ func NewBandApp(
// 0.47 TODO: change to tech council address
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod))
app.CrisisKeeper = crisiskeeper.NewKeeper(
appCodec,
keys[crisistypes.StoreKey],
Expand All @@ -396,6 +402,8 @@ func NewBandApp(
)

app.FeegrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)

homePath := cast.ToString(appOpts.Get(flags.FlagHome))
app.UpgradeKeeper = upgradekeeper.NewKeeper(
skipUpgradeHeights,
keys[upgradetypes.StoreKey],
Expand Down
4 changes: 0 additions & 4 deletions cmd/bandd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ func newApp(

bandApp := band.NewBandApp(
logger, db, traceStore, true, skipUpgradeHeights,
cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
appOpts,
cast.ToUint32(appOpts.Get(flagWithOwasmCacheSize)),
baseappOptions...,
Expand Down Expand Up @@ -219,8 +217,6 @@ func appExport(
traceStore,
loadLatest,
map[int64]bool{},
homePath,
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
appOpts,
cast.ToUint32(appOpts.Get(flagWithOwasmCacheSize)),
)
Expand Down
19 changes: 13 additions & 6 deletions testing/testapp/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import (

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/snapshots"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
Expand Down Expand Up @@ -220,6 +223,10 @@ func NewTestApp(chainID string, logger log.Logger) *TestingApp {
// db := dbm.NewMemDB()
db, _ := dbm.NewGoLevelDB("db", dir)

appOptions := make(simtestutil.AppOptionsMap, 0)
appOptions[flags.FlagHome] = dir
appOptions[server.FlagInvCheckPeriod] = 0

snapshotDir := filepath.Join(dir, "data", "snapshots")
snapshotDB, err := dbm.NewDB("metadata", dbm.GoLevelDBBackend, snapshotDir)
if err != nil {
Expand All @@ -242,9 +249,7 @@ func NewTestApp(chainID string, logger log.Logger) *TestingApp {
nil,
true,
map[int64]bool{},
dir,
0,
EmptyAppOptions{},
appOptions,
100,
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
baseapp.SetChainID(chainID),
Expand Down Expand Up @@ -399,6 +404,10 @@ func setup(withGenesis bool, invCheckPeriod uint, chainID string) (*TestingApp,
}
db := dbm.NewMemDB()

appOptions := make(simtestutil.AppOptionsMap, 0)
appOptions[flags.FlagHome] = dir
appOptions[server.FlagInvCheckPeriod] = 0

snapshotDir := filepath.Join(dir, "data", "snapshots")
snapshotDB, err := dbm.NewDB("metadata", dbm.GoLevelDBBackend, snapshotDir)
if err != nil {
Expand All @@ -421,9 +430,7 @@ func setup(withGenesis bool, invCheckPeriod uint, chainID string) (*TestingApp,
nil,
true,
map[int64]bool{},
dir,
0,
EmptyAppOptions{},
appOptions,
0,
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
baseapp.SetChainID(chainID),
Expand Down

0 comments on commit 91a0fe6

Please sign in to comment.