diff --git a/PENDING.md b/PENDING.md index 4d87301f0d5b..f70b51ac474d 100644 --- a/PENDING.md +++ b/PENDING.md @@ -47,6 +47,8 @@ BUG FIXES * Gaia + * \#3148 Fix `gaiad export` by adding a boolean to `NewGaiaApp` determining whether or not to load the latest version + * SDK * Tendermint diff --git a/client/lcd/test_helpers.go b/client/lcd/test_helpers.go index 58b8426e5f82..e1272f173806 100644 --- a/client/lcd/test_helpers.go +++ b/client/lcd/test_helpers.go @@ -230,7 +230,7 @@ func InitializeTestLCD( privVal.Reset() db := dbm.NewMemDB() - app := gapp.NewGaiaApp(logger, db, nil) + app := gapp.NewGaiaApp(logger, db, nil, true) cdc = gapp.MakeCodec() genesisFile := config.GenesisFile() diff --git a/cmd/gaia/app/app.go b/cmd/gaia/app/app.go index ebcdc8820d2f..4930f44ef5d0 100644 --- a/cmd/gaia/app/app.go +++ b/cmd/gaia/app/app.go @@ -68,7 +68,7 @@ type GaiaApp struct { } // NewGaiaApp returns a reference to an initialized GaiaApp. -func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptions ...func(*bam.BaseApp)) *GaiaApp { +func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, baseAppOptions ...func(*bam.BaseApp)) *GaiaApp { cdc := MakeCodec() bApp := bam.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...) @@ -167,9 +167,11 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio app.MountStoresTransient(app.tkeyParams, app.tkeyStake, app.tkeyDistr) app.SetEndBlocker(app.EndBlocker) - err := app.LoadLatestVersion(app.keyMain) - if err != nil { - cmn.Exit(err.Error()) + if loadLatest { + err := app.LoadLatestVersion(app.keyMain) + if err != nil { + cmn.Exit(err.Error()) + } } return app diff --git a/cmd/gaia/app/app_test.go b/cmd/gaia/app/app_test.go index 238f2296690b..87b2ec2a9531 100644 --- a/cmd/gaia/app/app_test.go +++ b/cmd/gaia/app/app_test.go @@ -50,11 +50,11 @@ func setGenesis(gapp *GaiaApp, accs ...*auth.BaseAccount) error { func TestGaiadExport(t *testing.T) { db := db.NewMemDB() - gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil) + gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true) setGenesis(gapp) // Making a new app object with the db, so that initchain hasn't been called - newGapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil) + newGapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true) _, _, err := newGapp.ExportAppStateAndValidators(false) require.NoError(t, err, "ExportAppStateAndValidators should not have an error") } diff --git a/cmd/gaia/app/sim_test.go b/cmd/gaia/app/sim_test.go index b4504bdf8a19..67fa05ac5820 100644 --- a/cmd/gaia/app/sim_test.go +++ b/cmd/gaia/app/sim_test.go @@ -215,7 +215,7 @@ func BenchmarkFullGaiaSimulation(b *testing.B) { db.Close() os.RemoveAll(dir) }() - app := NewGaiaApp(logger, db, nil) + app := NewGaiaApp(logger, db, nil, true) // Run randomized simulation // TODO parameterize numbers, save for a later PR @@ -257,7 +257,7 @@ func TestFullGaiaSimulation(t *testing.T) { db.Close() os.RemoveAll(dir) }() - app := NewGaiaApp(logger, db, nil, fauxMerkleModeOpt) + app := NewGaiaApp(logger, db, nil, true, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", app.Name()) // Run randomized simulation @@ -298,7 +298,7 @@ func TestGaiaImportExport(t *testing.T) { db.Close() os.RemoveAll(dir) }() - app := NewGaiaApp(logger, db, nil, fauxMerkleModeOpt) + app := NewGaiaApp(logger, db, nil, true, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", app.Name()) // Run randomized simulation @@ -334,7 +334,7 @@ func TestGaiaImportExport(t *testing.T) { newDB.Close() os.RemoveAll(newDir) }() - newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, fauxMerkleModeOpt) + newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", newApp.Name()) var genesisState GenesisState err = app.cdc.UnmarshalJSON(appState, &genesisState) @@ -394,7 +394,7 @@ func TestGaiaSimulationAfterImport(t *testing.T) { db.Close() os.RemoveAll(dir) }() - app := NewGaiaApp(logger, db, nil, fauxMerkleModeOpt) + app := NewGaiaApp(logger, db, nil, true, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", app.Name()) // Run randomized simulation @@ -436,7 +436,7 @@ func TestGaiaSimulationAfterImport(t *testing.T) { newDB.Close() os.RemoveAll(newDir) }() - newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, fauxMerkleModeOpt) + newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", newApp.Name()) newApp.InitChain(abci.RequestInitChain{ AppStateBytes: appState, @@ -471,7 +471,7 @@ func TestAppStateDeterminism(t *testing.T) { for j := 0; j < numTimesToRunPerSeed; j++ { logger := log.NewNopLogger() db := dbm.NewMemDB() - app := NewGaiaApp(logger, db, nil) + app := NewGaiaApp(logger, db, nil, true) // Run randomized simulation simulation.SimulateFromSeed( diff --git a/cmd/gaia/cmd/gaiad/main.go b/cmd/gaia/cmd/gaiad/main.go index f39ddae8c7d4..2791415c9350 100644 --- a/cmd/gaia/cmd/gaiad/main.go +++ b/cmd/gaia/cmd/gaiad/main.go @@ -55,7 +55,7 @@ func main() { } func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application { - return app.NewGaiaApp(logger, db, traceStore, + return app.NewGaiaApp(logger, db, traceStore, true, baseapp.SetPruning(viper.GetString("pruning")), baseapp.SetMinimumFees(viper.GetString("minimum_fees")), ) @@ -64,7 +64,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application func exportAppStateAndTMValidators( logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, ) (json.RawMessage, []tmtypes.GenesisValidator, error) { - gApp := app.NewGaiaApp(logger, db, traceStore) + gApp := app.NewGaiaApp(logger, db, traceStore, false) if height != -1 { err := gApp.LoadHeight(height) if err != nil { diff --git a/cmd/gaia/cmd/gaiareplay/main.go b/cmd/gaia/cmd/gaiareplay/main.go index cd58640e4b33..7e6392bf1230 100644 --- a/cmd/gaia/cmd/gaiareplay/main.go +++ b/cmd/gaia/cmd/gaiareplay/main.go @@ -105,7 +105,7 @@ func run(rootDir string) { // Application fmt.Println("Creating application") myapp := app.NewGaiaApp( - ctx.Logger, appDB, traceStoreWriter, + ctx.Logger, appDB, traceStoreWriter, true, baseapp.SetPruning("everything"), // nothing )