From 0b9c362ddd3cc378aeb7616a0669056e68b10c7e Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sun, 12 May 2024 19:17:00 -0400 Subject: [PATCH 1/3] chore: debug statements --- baseapp/baseapp.go | 28 +++++++++++++++++----------- baseapp/test_helpers.go | 2 +- store/rootmulti/store.go | 1 + 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index e76bb9fd1852..7819ceb8de77 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -74,11 +74,12 @@ type BaseApp struct { // nolint: maligned moduleRouter migrator - // volatile states: - // - // checkState is set on InitChain and reset on Commit - // deliverState is set on InitChain and BeginBlock and set to nil on Commit - checkState *state // for CheckTx + // checkState is used for CheckTx, which is set based on the previous + // block's state. This state is never committed. This state is volatile in + // that it is set on InitChain and every subsequent Commit. + checkState *state + // deliverState is used for DeliverTx. This state is volatile in that it is + // set on InitChain and BeginBlock and set to nil on Commit. deliverState *state // for DeliverTx // paramStore is used to query for ABCI consensus parameters from an @@ -309,6 +310,7 @@ func (app *BaseApp) MountStores(keys ...storetypes.StoreKey) { // BaseApp multistore. func (app *BaseApp) MountKVStores(keys map[string]*storetypes.KVStoreKey) { for _, key := range keys { + app.logger.Debug("Mounting KVStore", key) if !app.fauxMerkleMode { app.MountStore(key, storetypes.StoreTypeIAVL) } else { @@ -341,9 +343,13 @@ func (app *BaseApp) MountStore(key storetypes.StoreKey, typ storetypes.StoreType app.cms.MountStoreWithDB(key, typ, nil) } -// LoadLatestVersion loads the latest application version. It will panic if -// called more than once on a running BaseApp. +// LoadLatestVersion loads the latest version from the commit multi-store. In +// this context version == block height. It will panic if called more than once +// on a running BaseApp. +// +// Side-effect: calls baseapp.Init() func (app *BaseApp) LoadLatestVersion() error { + app.logger.Debug(fmt.Sprintf("Loading latest version %v\n", app.cms.LatestVersion())) err := app.storeLoader(app.cms) if err != nil { return fmt.Errorf("failed to load latest version: %w", err) @@ -464,10 +470,10 @@ func (app *BaseApp) Seal() { app.sealed = true } // IsSealed returns true if the BaseApp is sealed and false otherwise. func (app *BaseApp) IsSealed() bool { return app.sealed } -// setCheckState sets the BaseApp's checkState with a branched multi-store -// (i.e. a CacheMultiStore) and a new Context with the same multi-store branch, -// provided header, and minimum gas prices set. It is set on InitChain and reset -// on Commit. +// setCheckState sets the BaseApp's checkState with a branched multi-store (i.e. +// a CacheMultiStore) and a new Context with the same multi-store branch, +// provided header, and minimum gas prices set. This function should be invoked +// on InitChain and reset every Commit. func (app *BaseApp) setCheckState(header tmproto.Header) { ms := app.cms.CacheMultiStore() app.checkState = &state{ diff --git a/baseapp/test_helpers.go b/baseapp/test_helpers.go index 6489595bc8c1..862e42111845 100644 --- a/baseapp/test_helpers.go +++ b/baseapp/test_helpers.go @@ -36,7 +36,7 @@ func (app *BaseApp) SimDeliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, return gasInfo, result, err } -// Context with current {check, deliver}State of the app used by tests. +// Context with current {check, deliver}State of the app. func (app *BaseApp) NewContext(isCheckTx bool, header tmproto.Header) sdk.Context { if isCheckTx { return sdk.NewContext(app.checkState.ms, header, true, app.logger). diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 7397abd0424e..20e856687c05 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -64,6 +64,7 @@ type Store struct { } var ( + // Store implements the CommitMultiStore interface. _ types.CommitMultiStore = (*Store)(nil) _ types.Queryable = (*Store)(nil) ) From e2a1b5cddecf0f435edb28b7616b740d7583d29f Mon Sep 17 00:00:00 2001 From: Rootul P Date: Mon, 13 May 2024 09:26:57 -0400 Subject: [PATCH 2/3] Update baseapp/baseapp.go --- baseapp/baseapp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 7819ceb8de77..a4803a7b9701 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -310,7 +310,7 @@ func (app *BaseApp) MountStores(keys ...storetypes.StoreKey) { // BaseApp multistore. func (app *BaseApp) MountKVStores(keys map[string]*storetypes.KVStoreKey) { for _, key := range keys { - app.logger.Debug("Mounting KVStore", key) + app.logger.Debug("mounting KVStore", key) if !app.fauxMerkleMode { app.MountStore(key, storetypes.StoreTypeIAVL) } else { From 71baf218f0a7e6aac985abd49df185fea6f69ff8 Mon Sep 17 00:00:00 2001 From: Rootul P Date: Mon, 13 May 2024 09:27:01 -0400 Subject: [PATCH 3/3] Update baseapp/baseapp.go --- baseapp/baseapp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index a4803a7b9701..75e84b9679a5 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -349,7 +349,7 @@ func (app *BaseApp) MountStore(key storetypes.StoreKey, typ storetypes.StoreType // // Side-effect: calls baseapp.Init() func (app *BaseApp) LoadLatestVersion() error { - app.logger.Debug(fmt.Sprintf("Loading latest version %v\n", app.cms.LatestVersion())) + app.logger.Debug(fmt.Sprintf("loading latest version %v\n", app.cms.LatestVersion())) err := app.storeLoader(app.cms) if err != nil { return fmt.Errorf("failed to load latest version: %w", err)