diff --git a/app/app.go b/app/app.go index d257627b..317a931e 100644 --- a/app/app.go +++ b/app/app.go @@ -38,7 +38,7 @@ var ( ) // Extended ABCI application -type GaiaApp struct { +type App struct { *bam.BaseApp cdc *codec.Codec @@ -71,17 +71,17 @@ type GaiaApp struct { paramsKeeper params.Keeper } -// NewGaiaApp returns a reference to an initialized GaiaApp. -func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, +// NewApp returns a reference to an initialized App. +func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, invCheckPeriod uint, - baseAppOptions ...func(*bam.BaseApp)) *GaiaApp { + baseAppOptions ...func(*bam.BaseApp)) *App { cdc := MakeCodec() bApp := bam.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) - var app = &GaiaApp{ + var app = &App{ BaseApp: bApp, cdc: cdc, invCheckPeriod: invCheckPeriod, @@ -220,7 +220,7 @@ func MakeCodec() *codec.Codec { } // application updates every end block -func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { +func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { // mint new tokens for the previous block mint.BeginBlocker(ctx, app.mintKeeper) @@ -241,7 +241,7 @@ func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) ab // application updates every end block // nolint: unparam -func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { +func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { tags := gov.EndBlocker(ctx, app.govKeeper) validatorUpdates, endBlockerTags := staking.EndBlocker(ctx, app.stakingKeeper) tags = append(tags, endBlockerTags...) @@ -257,7 +257,7 @@ func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.R } // initialize store from a genesis state -func (app *GaiaApp) initFromGenesisState(ctx sdk.Context, genesisState GenesisState) []abci.ValidatorUpdate { +func (app *App) initFromGenesisState(ctx sdk.Context, genesisState GenesisState) []abci.ValidatorUpdate { genesisState.Sanitize() // load the accounts @@ -309,7 +309,7 @@ func (app *GaiaApp) initFromGenesisState(ctx sdk.Context, genesisState GenesisSt } // custom logic for gaia initialization -func (app *GaiaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *App) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { stateJSON := req.AppStateBytes // TODO is this now the whole genesis file? @@ -346,7 +346,7 @@ func (app *GaiaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci } // load a particular height -func (app *GaiaApp) LoadHeight(height int64) error { +func (app *App) LoadHeight(height int64) error { return app.LoadVersion(height, app.keyMain) } diff --git a/app/app_test.go b/app/app_test.go index 95fa0211..9694fcbb 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -22,7 +22,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) -func setGenesis(gapp *GaiaApp, accs ...*auth.BaseAccount) error { +func setGenesis(gapp *App, accs ...*auth.BaseAccount) error { genaccs := make([]GenesisAccount, len(accs)) for i, acc := range accs { genaccs[i] = NewGenesisAccount(acc) @@ -55,11 +55,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, true, 0) + gapp := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0) 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, true, 0) + newGapp := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0) _, _, err := newGapp.ExportAppStateAndValidators(false, []string{}) require.NoError(t, err, "ExportAppStateAndValidators should not have an error") } diff --git a/app/export.go b/app/export.go index 2cb110bf..d8db72e4 100644 --- a/app/export.go +++ b/app/export.go @@ -20,7 +20,7 @@ import ( ) // export the state of gaia for a genesis file -func (app *GaiaApp) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []string) ( +func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []string) ( appState json.RawMessage, validators []tmtypes.GenesisValidator, err error) { // as if they could withdraw from the start of the next block @@ -59,7 +59,7 @@ func (app *GaiaApp) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteLis } // prepare for fresh start at zero height -func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) { +func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []string) { applyWhiteList := false //Check if there is a whitelist diff --git a/app/genesis.go b/app/genesis.go index 997cd131..886c76a2 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -156,7 +156,7 @@ func (ga *GenesisAccount) ToAccount() auth.Account { // Create the core parameters for genesis initialization for gaia // note that the pubkey input is this machines pubkey -func GaiaAppGenState(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []json.RawMessage) ( +func AppGenState(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []json.RawMessage) ( genesisState GenesisState, err error) { if err = cdc.UnmarshalJSON(genDoc.AppState, &genesisState); err != nil { @@ -292,11 +292,11 @@ func validateGenesisStateAccounts(accs []GenesisAccount) error { return nil } -// GaiaAppGenState but with JSON -func GaiaAppGenStateJSON(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []json.RawMessage) ( +// AppGenState but with JSON +func AppGenStateJSON(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []json.RawMessage) ( appState json.RawMessage, err error) { // create the final app state - genesisState, err := GaiaAppGenState(cdc, genDoc, appGenTxs) + genesisState, err := AppGenState(cdc, genDoc, appGenTxs) if err != nil { return nil, err } diff --git a/app/genesis_test.go b/app/genesis_test.go index 300f4afc..2619f9ba 100644 --- a/app/genesis_test.go +++ b/app/genesis_test.go @@ -70,7 +70,7 @@ func TestToAccount(t *testing.T) { require.Equal(t, vacc, acc.(*auth.ContinuousVestingAccount)) } -func TestGaiaAppGenTx(t *testing.T) { +func TestAppGenTx(t *testing.T) { cdc := MakeCodec() _ = cdc @@ -79,13 +79,13 @@ func TestGaiaAppGenTx(t *testing.T) { //TODO test the account created has the correct pubkey } -func TestGaiaAppGenState(t *testing.T) { +func TestAppGenState(t *testing.T) { cdc := MakeCodec() _ = cdc var genDoc tmtypes.GenesisDoc // test unmarshalling error - _, err := GaiaAppGenState(cdc, genDoc, []json.RawMessage{}) + _, err := AppGenState(cdc, genDoc, []json.RawMessage{}) require.Error(t, err) appState := makeGenesisState(t, []auth.StdTx{}) @@ -93,7 +93,7 @@ func TestGaiaAppGenState(t *testing.T) { require.NoError(t, err) // test validation error - _, err = GaiaAppGenState(cdc, genDoc, []json.RawMessage{}) + _, err = AppGenState(cdc, genDoc, []json.RawMessage{}) require.Error(t, err) // TODO test must provide at least genesis transaction diff --git a/app/invariants.go b/app/invariants.go index 899d6bdb..0365dc4d 100644 --- a/app/invariants.go +++ b/app/invariants.go @@ -9,12 +9,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (app *GaiaApp) assertRuntimeInvariants() { +func (app *App) assertRuntimeInvariants() { ctx := app.NewContext(false, abci.Header{Height: app.LastBlockHeight() + 1}) app.assertRuntimeInvariantsOnContext(ctx) } -func (app *GaiaApp) assertRuntimeInvariantsOnContext(ctx sdk.Context) { +func (app *App) assertRuntimeInvariantsOnContext(ctx sdk.Context) { start := time.Now() invarRoutes := app.crisisKeeper.Routes() for _, ir := range invarRoutes { diff --git a/app/sim_test.go b/app/sim_test.go index 28e94e4d..0aee7853 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -61,7 +61,7 @@ func init() { } // helper function for populating input for SimulateFromSeed -func getSimulateFromSeedInput(tb testing.TB, app *GaiaApp) ( +func getSimulateFromSeedInput(tb testing.TB, app *App) ( testing.TB, *baseapp.BaseApp, simulation.AppStateFn, int64, simulation.WeightedOperations, sdk.Invariants, int, int, bool, bool) { @@ -273,7 +273,7 @@ func appStateFn(r *rand.Rand, accs []simulation.Account, genesisTimestamp time.T return appStateRandomizedFn(r, accs, genesisTimestamp) } -func testAndRunTxs(app *GaiaApp) []simulation.WeightedOperation { +func testAndRunTxs(app *App) []simulation.WeightedOperation { return []simulation.WeightedOperation{ {5, authsim.SimulateDeductFee(app.accountKeeper, app.feeCollectionKeeper)}, {100, banksim.SimulateMsgSend(app.accountKeeper, app.bankKeeper)}, @@ -292,7 +292,7 @@ func testAndRunTxs(app *GaiaApp) []simulation.WeightedOperation { } } -func invariants(app *GaiaApp) []sdk.Invariant { +func invariants(app *App) []sdk.Invariant { return []sdk.Invariant{ simulation.PeriodicInvariant(bank.NonnegativeBalanceInvariant(app.accountKeeper), period, 0), simulation.PeriodicInvariant(distr.AllInvariants(app.distrKeeper, app.stakingKeeper), period, 0), @@ -319,7 +319,7 @@ func BenchmarkFullGaiaSimulation(b *testing.B) { db.Close() os.RemoveAll(dir) }() - app := NewGaiaApp(logger, db, nil, true, 0) + app := NewApp(logger, db, nil, true, 0) // Run randomized simulation // TODO parameterize numbers, save for a later PR @@ -354,7 +354,7 @@ func TestFullGaiaSimulation(t *testing.T) { db.Close() os.RemoveAll(dir) }() - app := NewGaiaApp(logger, db, nil, true, 0, fauxMerkleModeOpt) + app := NewApp(logger, db, nil, true, 0, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", app.Name()) // Run randomized simulation @@ -388,7 +388,7 @@ func TestGaiaImportExport(t *testing.T) { db.Close() os.RemoveAll(dir) }() - app := NewGaiaApp(logger, db, nil, true, 0, fauxMerkleModeOpt) + app := NewApp(logger, db, nil, true, 0, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", app.Name()) // Run randomized simulation @@ -415,7 +415,7 @@ func TestGaiaImportExport(t *testing.T) { newDB.Close() os.RemoveAll(newDir) }() - newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, 0, fauxMerkleModeOpt) + newApp := NewApp(log.NewNopLogger(), newDB, nil, true, 0, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", newApp.Name()) var genesisState GenesisState err = app.cdc.UnmarshalJSON(appState, &genesisState) @@ -478,7 +478,7 @@ func TestGaiaSimulationAfterImport(t *testing.T) { db.Close() os.RemoveAll(dir) }() - app := NewGaiaApp(logger, db, nil, true, 0, fauxMerkleModeOpt) + app := NewApp(logger, db, nil, true, 0, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", app.Name()) // Run randomized simulation @@ -514,7 +514,7 @@ func TestGaiaSimulationAfterImport(t *testing.T) { newDB.Close() os.RemoveAll(newDir) }() - newApp := NewGaiaApp(log.NewNopLogger(), newDB, nil, true, 0, fauxMerkleModeOpt) + newApp := NewApp(log.NewNopLogger(), newDB, nil, true, 0, fauxMerkleModeOpt) require.Equal(t, "GaiaApp", newApp.Name()) newApp.InitChain(abci.RequestInitChain{ AppStateBytes: appState, @@ -542,7 +542,7 @@ func TestAppStateDeterminism(t *testing.T) { for j := 0; j < numTimesToRunPerSeed; j++ { logger := log.NewNopLogger() db := dbm.NewMemDB() - app := NewGaiaApp(logger, db, nil, true, 0) + app := NewApp(logger, db, nil, true, 0) // Run randomized simulation simulation.SimulateFromSeed( diff --git a/cmd/gaiad/main.go b/cmd/gaiad/main.go index 228d6595..36fe1b24 100644 --- a/cmd/gaiad/main.go +++ b/cmd/gaiad/main.go @@ -66,7 +66,7 @@ func main() { } func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application { - return app.NewGaiaApp( + return app.NewApp( logger, db, traceStore, true, invCheckPeriod, baseapp.SetPruning(store.NewPruningOptionsFromString(viper.GetString("pruning"))), baseapp.SetMinGasPrices(viper.GetString(server.FlagMinGasPrices)), @@ -78,13 +78,13 @@ func exportAppStateAndTMValidators( ) (json.RawMessage, []tmtypes.GenesisValidator, error) { if height != -1 { - gApp := app.NewGaiaApp(logger, db, traceStore, false, uint(1)) + gApp := app.NewApp(logger, db, traceStore, false, uint(1)) err := gApp.LoadHeight(height) if err != nil { return nil, nil, err } return gApp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList) } - gApp := app.NewGaiaApp(logger, db, traceStore, true, uint(1)) + gApp := app.NewApp(logger, db, traceStore, true, uint(1)) return gApp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList) } diff --git a/init/collect.go b/init/collect.go index 7fadff8e..808b318a 100644 --- a/init/collect.go +++ b/init/collect.go @@ -111,7 +111,7 @@ func genAppStateFromConfig( cfg.WriteConfigFile(filepath.Join(config.RootDir, "config", "config.toml"), config) - appState, err = app.GaiaAppGenStateJSON(cdc, genDoc, genTxs) + appState, err = app.AppGenStateJSON(cdc, genDoc, genTxs) if err != nil { return }