Skip to content
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

simulation: vanilla simulation tests #71

Merged
merged 13 commits into from
Jul 26, 2022
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BUILDDIR ?= $(CURDIR)/build
HTTPS_GIT := https://github.com/babylonchain/babylon.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
SIMAPP = ./app
SIMAPP = ./simapp

export GO111MODULE = on

Expand Down Expand Up @@ -241,7 +241,7 @@ test-sim-multi-seed-short: runsim

test-sim-benchmark-invariants:
@echo "Running simulation invariant benchmarks..."
@go test -mod=readonly $(SIMAPP) -benchmem -bench=BenchmarkInvariants -run=^$ \
@go test -mod=readonly $(SIMAPP) -benchmem -bench=BenchmarkInvariants \
-Enabled=true -NumBlocks=1000 -BlockSize=200 \
-Period=1 -Commit=true -Seed=57 -v -timeout 24h

Expand All @@ -261,12 +261,12 @@ SIM_COMMIT ?= true

test-sim-benchmark:
@echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
@go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \
@go test -mod=readonly -benchmem $(SIMAPP) -bench=BenchmarkFullAppSimulation \
-Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h

test-sim-profile:
@echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
@go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \
@go test -mod=readonly -benchmem $(SIMAPP) -bench=BenchmarkFullAppSimulation \
-Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h -cpuprofile cpu.out -memprofile mem.out

.PHONY: test-sim-profile test-sim-benchmark
Expand Down
6 changes: 5 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func init() {
panic(err)
}

DefaultNodeHome = filepath.Join(userHomeDir, ".babylonapp")
DefaultNodeHome = filepath.Join(userHomeDir, ".babylond")
}

// NewBabylonApp returns a reference to an initialized BabylonApp.
Expand Down Expand Up @@ -636,6 +636,10 @@ func (app *BabylonApp) RegisterTendermintService(clientCtx client.Context) {
tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry)
}

func (app *BabylonApp) ModuleManager() *module.Manager {
return app.mm
}

// RegisterSwaggerAPI registers swagger route with API Server
func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) {
statikFS, err := fs.New()
Expand Down
12 changes: 6 additions & 6 deletions simapp/sim_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
// /usr/local/go/bin/go test -benchmem -run=^$ github.com/babylonchain/babylon/simapp -bench ^BenchmarkFullAppSimulation$ -Commit=true -cpuprofile cpu.out
func BenchmarkFullAppSimulation(b *testing.B) {
b.ReportAllocs()
config, db, dir, logger, skip, err := sdksimapp.SetupSimulation("goleveldb-app-sim", "Simulation")
config, db, dir, logger, skip, err := SetupSimulation("goleveldb-app-sim", "Simulation")
if err != nil {
b.Fatalf("simulation setup failed: %s", err.Error())
}
Expand All @@ -35,7 +35,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
}
}()

babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, sdksimapp.FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, interBlockCacheOpt())
babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, interBlockCacheOpt())

// run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
Expand All @@ -44,7 +44,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
babylon.BaseApp,
AppStateFn(babylon.AppCodec(), babylon.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
sdksimapp.SimulationOperations(babylon, babylon.AppCodec(), config),
SimulationOperations(babylon, babylon.AppCodec(), config),
babylon.ModuleAccountAddrs(),
config,
babylon.AppCodec(),
Expand All @@ -66,7 +66,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {

func BenchmarkInvariants(b *testing.B) {
b.ReportAllocs()
config, db, dir, logger, skip, err := sdksimapp.SetupSimulation("leveldb-app-invariant-bench", "Simulation")
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-invariant-bench", "Simulation")
if err != nil {
b.Fatalf("simulation setup failed: %s", err.Error())
}
Expand All @@ -85,7 +85,7 @@ func BenchmarkInvariants(b *testing.B) {
}
}()

babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, sdksimapp.FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, interBlockCacheOpt())
babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, interBlockCacheOpt())

// run randomized simulation
_, simParams, simErr := simulation.SimulateFromSeed(
Expand All @@ -94,7 +94,7 @@ func BenchmarkInvariants(b *testing.B) {
babylon.BaseApp,
AppStateFn(babylon.AppCodec(), babylon.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
sdksimapp.SimulationOperations(babylon, babylon.AppCodec(), config),
SimulationOperations(babylon, babylon.AppCodec(), config),
babylon.ModuleAccountAddrs(),
config,
babylon.AppCodec(),
Expand Down
87 changes: 54 additions & 33 deletions simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,34 @@ import (

"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/babylonchain/babylon/app"

btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types"
btclightclienttypes "github.com/babylonchain/babylon/x/btclightclient/types"
checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types"
epochingtypes "github.com/babylonchain/babylon/x/epoching/types"
"github.com/cosmos/cosmos-sdk/baseapp"
sdksimapp "github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/helpers"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/simulation"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
abci "github.com/tendermint/tendermint/abci/types"
)

// Get flags every time the simulator is run
Expand All @@ -46,7 +63,7 @@ func interBlockCacheOpt() func(*baseapp.BaseApp) {
}

func TestFullAppSimulation(t *testing.T) {
config, db, dir, logger, skip, err := sdksimapp.SetupSimulation("leveldb-app-sim", "Simulation")
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation")
if skip {
t.Skip("skipping application simulation")
}
Expand All @@ -57,7 +74,7 @@ func TestFullAppSimulation(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()

babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, sdksimapp.FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
require.Equal(t, "BabylonApp", babylon.Name())

// run randomized simulation
Expand All @@ -67,7 +84,7 @@ func TestFullAppSimulation(t *testing.T) {
babylon.BaseApp,
AppStateFn(babylon.AppCodec(), babylon.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
sdksimapp.SimulationOperations(babylon, babylon.AppCodec(), config),
SimulationOperations(babylon, babylon.AppCodec(), config),
babylon.ModuleAccountAddrs(),
config,
babylon.AppCodec(),
Expand All @@ -83,9 +100,8 @@ func TestFullAppSimulation(t *testing.T) {
}
}

/*
func TestAppImportExport(t *testing.T) {
config, db, dir, logger, skip, err := sdksimapp.SetupSimulation("leveldb-app-sim", "Simulation")
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation")
if skip {
t.Skip("skipping application import/export simulation")
}
Expand All @@ -96,7 +112,7 @@ func TestAppImportExport(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()

babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, sdksimapp.FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
require.Equal(t, "BabylonApp", babylon.Name())

// Run randomized simulation
Expand All @@ -106,7 +122,7 @@ func TestAppImportExport(t *testing.T) {
babylon.BaseApp,
AppStateFn(babylon.AppCodec(), babylon.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
sdksimapp.SimulationOperations(babylon, babylon.AppCodec(), config),
SimulationOperations(babylon, babylon.AppCodec(), config),
babylon.ModuleAccountAddrs(),
config,
babylon.AppCodec(),
Expand All @@ -128,15 +144,15 @@ func TestAppImportExport(t *testing.T) {

fmt.Printf("importing genesis...\n")

_, newDB, newDir, _, _, err := sdksimapp.SetupSimulation("leveldb-app-sim-2", "Simulation-2")
_, newDB, newDir, _, _, err := SetupSimulation("leveldb-app-sim-2", "Simulation-2")
require.NoError(t, err, "simulation setup failed")

defer func() {
newDB.Close()
require.NoError(t, os.RemoveAll(newDir))
}()

newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, sdksimapp.FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
require.Equal(t, "BabylonApp", newBabylon.Name())

var genesisState app.GenesisState
Expand All @@ -145,27 +161,33 @@ func TestAppImportExport(t *testing.T) {

ctxA := babylon.NewContext(true, tmproto.Header{Height: babylon.LastBlockHeight()})
ctxB := newBabylon.NewContext(true, tmproto.Header{Height: babylon.LastBlockHeight()})
newBabylon.mm.InitGenesis(ctxB, babylon.AppCodec(), genesisState)
newBabylon.ModuleManager().InitGenesis(ctxB, babylon.AppCodec(), genesisState)
newBabylon.StoreConsensusParams(ctxB, exported.ConsensusParams)

fmt.Printf("comparing stores...\n")

storeKeysPrefixes := []StoreKeysPrefixes{
{babylon.keys[authtypes.StoreKey], newBabylon.keys[authtypes.StoreKey], [][]byte{}},
{babylon.keys[stakingtypes.StoreKey], newBabylon.keys[stakingtypes.StoreKey],
{babylon.GetKey(authtypes.StoreKey), newBabylon.GetKey(authtypes.StoreKey), [][]byte{}},
{babylon.GetKey(stakingtypes.StoreKey), newBabylon.GetKey(stakingtypes.StoreKey),
[][]byte{
stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey,
stakingtypes.HistoricalInfoKey,
}}, // ordering may change but it doesn't matter
{babylon.keys[slashingtypes.StoreKey], newBabylon.keys[slashingtypes.StoreKey], [][]byte{}},
{babylon.keys[minttypes.StoreKey], newBabylon.keys[minttypes.StoreKey], [][]byte{}},
{babylon.keys[distrtypes.StoreKey], newBabylon.keys[distrtypes.StoreKey], [][]byte{}},
{babylon.keys[banktypes.StoreKey], newBabylon.keys[banktypes.StoreKey], [][]byte{banktypes.BalancesPrefix}},
{babylon.keys[paramtypes.StoreKey], newBabylon.keys[paramtypes.StoreKey], [][]byte{}},
{babylon.keys[govtypes.StoreKey], newBabylon.keys[govtypes.StoreKey], [][]byte{}},
{babylon.keys[evidencetypes.StoreKey], newBabylon.keys[evidencetypes.StoreKey], [][]byte{}},
{babylon.keys[capabilitytypes.StoreKey], newBabylon.keys[capabilitytypes.StoreKey], [][]byte{}},
{babylon.keys[authzkeeper.StoreKey], newBabylon.keys[authzkeeper.StoreKey], [][]byte{}},
{babylon.GetKey(slashingtypes.StoreKey), newBabylon.GetKey(slashingtypes.StoreKey), [][]byte{}},
{babylon.GetKey(minttypes.StoreKey), newBabylon.GetKey(minttypes.StoreKey), [][]byte{}},
{babylon.GetKey(distrtypes.StoreKey), newBabylon.GetKey(distrtypes.StoreKey), [][]byte{}},
{babylon.GetKey(banktypes.StoreKey), newBabylon.GetKey(banktypes.StoreKey), [][]byte{banktypes.BalancesPrefix}},
{babylon.GetKey(paramtypes.StoreKey), newBabylon.GetKey(paramtypes.StoreKey), [][]byte{}},
{babylon.GetKey(govtypes.StoreKey), newBabylon.GetKey(govtypes.StoreKey), [][]byte{}},
{babylon.GetKey(evidencetypes.StoreKey), newBabylon.GetKey(evidencetypes.StoreKey), [][]byte{}},
{babylon.GetKey(capabilitytypes.StoreKey), newBabylon.GetKey(capabilitytypes.StoreKey), [][]byte{}},
{babylon.GetKey(authzkeeper.StoreKey), newBabylon.GetKey(authzkeeper.StoreKey), [][]byte{}},
// TODO: add Babylon module StoreKey and prefix here
{babylon.GetKey(btccheckpointtypes.StoreKey), newBabylon.GetKey(btccheckpointtypes.StoreKey), [][]byte{}},
{babylon.GetKey(btclightclienttypes.StoreKey), newBabylon.GetKey(btclightclienttypes.StoreKey), [][]byte{}},
{babylon.GetKey(checkpointingtypes.StoreKey), newBabylon.GetKey(checkpointingtypes.StoreKey), [][]byte{}},
{babylon.GetKey(epochingtypes.StoreKey), newBabylon.GetKey(epochingtypes.StoreKey),
[][]byte{epochingtypes.SlashedVotingPowerKey, epochingtypes.VotingPowerKey}},
}

for _, skp := range storeKeysPrefixes {
Expand All @@ -181,7 +203,7 @@ func TestAppImportExport(t *testing.T) {
}

func TestAppSimulationAfterImport(t *testing.T) {
config, db, dir, logger, skip, err := sdksimapp.SetupSimulation("leveldb-app-sim", "Simulation")
config, db, dir, logger, skip, err := SetupSimulation("leveldb-app-sim", "Simulation")
if skip {
t.Skip("skipping application simulation after import")
}
Expand All @@ -192,7 +214,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()

babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, sdksimapp.FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
require.Equal(t, "BabylonApp", babylon.Name())

// Run randomized simulation
Expand All @@ -202,7 +224,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
babylon.BaseApp,
AppStateFn(babylon.AppCodec(), babylon.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
sdksimapp.SimulationOperations(babylon, babylon.AppCodec(), config),
SimulationOperations(babylon, babylon.AppCodec(), config),
babylon.ModuleAccountAddrs(),
config,
babylon.AppCodec(),
Expand All @@ -229,15 +251,15 @@ func TestAppSimulationAfterImport(t *testing.T) {

fmt.Printf("importing genesis...\n")

_, newDB, newDir, _, _, err := sdksimapp.SetupSimulation("leveldb-app-sim-2", "Simulation-2")
_, newDB, newDir, _, _, err := SetupSimulation("leveldb-app-sim-2", "Simulation-2")
require.NoError(t, err, "simulation setup failed")

defer func() {
newDB.Close()
require.NoError(t, os.RemoveAll(newDir))
}()

newBabylon := NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, sdksimapp.FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt)
require.Equal(t, "BabylonApp", newBabylon.Name())

newBabylon.InitChain(abci.RequestInitChain{
Expand All @@ -250,23 +272,22 @@ func TestAppSimulationAfterImport(t *testing.T) {
newBabylon.BaseApp,
AppStateFn(babylon.AppCodec(), babylon.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
sdksimapp.SimulationOperations(newBabylon, newBabylon.AppCodec(), config),
SimulationOperations(newBabylon, newBabylon.AppCodec(), config),
babylon.ModuleAccountAddrs(),
config,
babylon.AppCodec(),
)
require.NoError(t, err)
}
*/

// TODO: Make another test for the fuzzer itself, which just has noOp txs
// and doesn't depend on the application.
func TestAppStateDeterminism(t *testing.T) {
if !sdksimapp.FlagEnabledValue {
if !FlagEnabledValue {
t.Skip("skipping application simulation")
}

config := sdksimapp.NewConfigFromFlags()
config := NewConfigFromFlags()
config.InitialBlockHeight = 1
config.ExportParamsPath = ""
config.OnOperation = false
Expand All @@ -282,14 +303,14 @@ func TestAppStateDeterminism(t *testing.T) {

for j := 0; j < numTimesToRunPerSeed; j++ {
var logger log.Logger
if sdksimapp.FlagVerboseValue {
if FlagVerboseValue {
logger = log.TestingLogger()
} else {
logger = log.NewNopLogger()
}

db := dbm.NewMemDB()
babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, sdksimapp.FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, interBlockCacheOpt())
babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), sdksimapp.EmptyAppOptions{}, interBlockCacheOpt())

fmt.Printf(
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",
Expand All @@ -302,7 +323,7 @@ func TestAppStateDeterminism(t *testing.T) {
babylon.BaseApp,
AppStateFn(babylon.AppCodec(), babylon.SimulationManager()),
simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1
sdksimapp.SimulationOperations(babylon, babylon.AppCodec(), config),
SimulationOperations(babylon, babylon.AppCodec(), config),
babylon.ModuleAccountAddrs(),
config,
babylon.AppCodec(),
Expand Down
7 changes: 3 additions & 4 deletions simapp/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdksimapp "github.com/cosmos/cosmos-sdk/simapp"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand All @@ -32,10 +31,10 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty
return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config,
) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) {

if sdksimapp.FlagGenesisTimeValue == 0 {
if FlagGenesisTimeValue == 0 {
genesisTimestamp = simtypes.RandTimestamp(r)
} else {
genesisTimestamp = time.Unix(sdksimapp.FlagGenesisTimeValue, 0)
genesisTimestamp = time.Unix(FlagGenesisTimeValue, 0)
}

chainID = config.ChainID
Expand All @@ -47,7 +46,7 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty
// override the default chain-id from simapp to set it later to the config
genesisDoc, accounts := AppStateFromGenesisFileFn(r, cdc, config.GenesisFile)

if sdksimapp.FlagGenesisTimeValue == 0 {
if FlagGenesisTimeValue == 0 {
// use genesis timestamp if no custom timestamp is provided (i.e no random timestamp)
genesisTimestamp = genesisDoc.GenesisTime
}
Expand Down
Loading