You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: abci.go
    path of file: ./repos/cosmos-sdk/baseapp
    
    the code of the file until where you have to start completion: package baseapp

import (
	"context"
	"fmt"
	"sort"
	"strings"
	"time"

	"github.com/cockroachdb/errors"
	abci "github.com/cometbft/cometbft/abci/types"
	cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
	"github.com/cosmos/gogoproto/proto"
	"google.golang.org/grpc/codes"
	grpcstatus "google.golang.org/grpc/status"

	corecomet "cosmossdk.io/core/comet"
	coreheader "cosmossdk.io/core/header"
	errorsmod "cosmossdk.io/errors"
	"cosmossdk.io/store/rootmulti"
	snapshottypes "cosmossdk.io/store/snapshots/types"
	storetypes "cosmossdk.io/store/types"

	"github.com/cosmos/cosmos-sdk/codec"
	"github.com/cosmos/cosmos-sdk/telemetry"
	sdk "github.com/cosmos/cosmos-sdk/types"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// Supported ABCI Query prefixes and paths
const (
	QueryPathApp    = "app"
	QueryPathCustom = "custom"
	QueryPathP2P    = "p2p"
	QueryPathStore  = "store"

	QueryPathBroadcastTx = "/cosmos.tx.v1beta1.Service/BroadcastTx"
)

func (app *Bas
    
func (app *BaseApp) Commit() (*abci.ResponseCommit, error) {
	header := app.finalizeBlockState.Context().BlockHeader()
	retainHeight := app.GetBlockRetentionHeight(header.Height)

	if app.precommiter != nil {
		app.precommiter(app.finalizeBlockState.Context())
	}

	rms, ok := app.cms.(*rootmulti.Store)
	if ok {
		rms.SetCommitHeader(header)
	}

	app.cms.Commit()

	resp := &abci.ResponseCommit{
		RetainHeight: retainHeight,
	}

	abciListeners := app.streamingManager.ABCIListeners
	if len(abciListeners) > 0 {
		ctx := app.finalizeBlockState.Context()
		blockHeight := ctx.BlockHeight()
		changeSet := app.cms.PopStateCache()

		for _, abciListener := range abciListeners {
			if err := abciListener.ListenCommit(ctx, *resp, changeSet); err != nil {
				app.logger.Error("Commit listening hook failed", "height", blockHeight, "err", err)
			}
		}
	}

	// Reset the CheckTx state to the latest committed.
	//
	// NOTE: This is safe because CometBFT holds a lock on the mempool for
	// Commit. Use the header from this latest block.
	app.setState(execModeCheck, header)

	app.finalizeBlockState = nil

	if app.prepareCheckStater != nil {
		app.prepareCheckStater(app.checkState.Context())
	}

	// The SnapshotIfApplicable method will create the snapshot by starting the goroutine
	app.snapshotManager.SnapshotIfApplicable(header.Height)

	return resp, nil
}