Skip to content

Commit

Permalink
chore: debug statements (#399)
Browse files Browse the repository at this point in the history
* chore: debug statements

* Update baseapp/baseapp.go

* Update baseapp/baseapp.go
  • Loading branch information
rootulp authored May 14, 2024
1 parent 2b80623 commit 46df629
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
28 changes: 17 additions & 11 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion baseapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Store struct {
}

var (
// Store implements the CommitMultiStore interface.
_ types.CommitMultiStore = (*Store)(nil)
_ types.Queryable = (*Store)(nil)
)
Expand Down

0 comments on commit 46df629

Please sign in to comment.