From 46df62995fe29ada7ffe0e6795bb36dcc7a09914 Mon Sep 17 00:00:00 2001 From: Rootul P Date: Tue, 14 May 2024 08:52:46 -0400 Subject: [PATCH] chore: debug statements (#399) * chore: debug statements * Update baseapp/baseapp.go * Update baseapp/baseapp.go --- 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..75e84b9679a5 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) )