Skip to content

Commit

Permalink
Merge PR #3148: Fix gaiad export
Browse files Browse the repository at this point in the history
* Add boolean for LoadLatestVersion
* Update PENDING.md
  • Loading branch information
cwgoes committed Dec 19, 2018
1 parent 9aaa1c2 commit b76825e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
2 changes: 2 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion client/lcd/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 6 additions & 4 deletions cmd/gaia/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/gaia/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
14 changes: 7 additions & 7 deletions cmd/gaia/app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions cmd/gaia/cmd/gaiad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
)
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gaia/cmd/gaiareplay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit b76825e

Please sign in to comment.