From a5c237d9561d6eb9bc3f08119bf5486db3052316 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 24 Oct 2024 15:07:02 -0400 Subject: [PATCH 1/7] remove additional log line when exporting genesis --- app/app.go | 2 -- cmd/zetacored/root.go | 48 +++++++++++++++++++------------------------ 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/app/app.go b/app/app.go index 1e64321f21..3a42d51aff 100644 --- a/app/app.go +++ b/app/app.go @@ -372,8 +372,6 @@ func New( authAddr, ) - logger.Info("bank keeper blocklist addresses", "addresses", app.BlockedAddrs()) - app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, keys[banktypes.StoreKey], diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 440b921bc2..0862536921 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -274,42 +274,36 @@ func (ac appCreator) appExport( appOpts servertypes.AppOptions, modulesToExport []string, ) (servertypes.ExportedApp, error) { - var anApp *app.App + var zetaApp *app.App homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { return servertypes.ExportedApp{}, errors.New("application home not set") } + loadlatest := true if height != -1 { - anApp = app.New( - logger, - db, - traceStore, - false, - map[int64]bool{}, - homePath, - uint(1), - ac.encCfg, - appOpts, - ) - - if err := anApp.LoadHeight(height); err != nil { + loadlatest = false + } + + zetaApp = app.New( + logger, + db, + traceStore, + loadlatest, + map[int64]bool{}, + homePath, + uint(1), + ac.encCfg, + appOpts, + ) + + if height != -1 { + err := zetaApp.LoadHeight(height) + if err != nil { return servertypes.ExportedApp{}, err } - } else { - anApp = app.New( - logger, - db, - traceStore, - true, - map[int64]bool{}, - homePath, - uint(1), - ac.encCfg, - appOpts, - ) } - return anApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) + return zetaApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) } From 33866a594d3ef9dbf2200d5e06d6d2eb286ac9e6 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 24 Oct 2024 15:08:59 -0400 Subject: [PATCH 2/7] modify comments on appExport --- cmd/zetacored/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 0862536921..71c32b2b48 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -268,7 +268,7 @@ func (ac appCreator) newApp( ) } -// appExport creates a new simapp (optionally at a given height) +// appExport is used to export the state of the application for a genesis file. func (ac appCreator) appExport( logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts servertypes.AppOptions, From c6567d800f36d248d4ca84952c2ae6f22fdc3550 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 24 Oct 2024 15:12:20 -0400 Subject: [PATCH 3/7] rename identifiers --- cmd/zetacored/root.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 71c32b2b48..1102001703 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -281,16 +281,16 @@ func (ac appCreator) appExport( return servertypes.ExportedApp{}, errors.New("application home not set") } - loadlatest := true - if height != -1 { - loadlatest = false + loadLatest := false + if height == -1 { + loadLatest = true } zetaApp = app.New( logger, db, traceStore, - loadlatest, + loadLatest, map[int64]bool{}, homePath, uint(1), From 98fba58905b638944911e11f3eaa0da48cf7f16d Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 24 Oct 2024 15:25:54 -0400 Subject: [PATCH 4/7] add comments --- app/export.go | 2 +- cmd/zetacored/root.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/export.go b/app/export.go index 1f1ae26a96..40a3717adf 100644 --- a/app/export.go +++ b/app/export.go @@ -17,7 +17,7 @@ import ( func (app *App) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string, ) (servertypes.ExportedApp, error) { - // as if they could withdraw from the start of the next block + ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) // We export at last height + 1, because that's the height at which diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 1102001703..a78c7aee9e 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -298,6 +298,8 @@ func (ac appCreator) appExport( appOpts, ) + // If height is -1, it means we are using the latest height. + // For all other cases, we load the specified height from the Store if height != -1 { err := zetaApp.LoadHeight(height) if err != nil { From e19205a3684b2b7ca7b5f54195f2af7940a7216c Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 24 Oct 2024 15:29:36 -0400 Subject: [PATCH 5/7] remove unnecessary new line --- app/export.go | 1 - 1 file changed, 1 deletion(-) diff --git a/app/export.go b/app/export.go index 40a3717adf..61bc52659b 100644 --- a/app/export.go +++ b/app/export.go @@ -17,7 +17,6 @@ import ( func (app *App) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string, ) (servertypes.ExportedApp, error) { - ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) // We export at last height + 1, because that's the height at which From d5e14d828360c39e77559cedfe13d5e2c6170c00 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 28 Oct 2024 17:16:57 -0400 Subject: [PATCH 6/7] Update cmd/zetacored/root.go Co-authored-by: Lucas Bertrand --- cmd/zetacored/root.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index a78c7aee9e..a72d4a0cf6 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -301,8 +301,7 @@ func (ac appCreator) appExport( // If height is -1, it means we are using the latest height. // For all other cases, we load the specified height from the Store if height != -1 { - err := zetaApp.LoadHeight(height) - if err != nil { + if err := zetaApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } From 6f8638e32eee1e12abd7c0239353cc5ea659ddd4 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 28 Oct 2024 17:18:52 -0400 Subject: [PATCH 7/7] use loadlatest flag for loading app for height --- cmd/zetacored/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index a72d4a0cf6..3880b12108 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -300,7 +300,7 @@ func (ac appCreator) appExport( // If height is -1, it means we are using the latest height. // For all other cases, we load the specified height from the Store - if height != -1 { + if !loadLatest { if err := zetaApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err }