Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: prepare process proposal state #326

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
// initialize the deliver state and check state with a correct header
app.setDeliverState(initHeader)
app.setCheckState(initHeader)
app.chainID = req.ChainId
cmwaters marked this conversation as resolved.
Show resolved Hide resolved

// Store the consensus params in the BaseApp's paramstore. Note, this must be
// done after the deliver state and context have been set as it's persisted
Expand Down
21 changes: 17 additions & 4 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ type BaseApp struct { // nolint: maligned
// abciListeners for hooking into the ABCI message processing of the BaseApp
// and exposing the requests and responses to external consumers
abciListeners []ABCIListener

// chainID is the chainID of the chain that is set upon starting the chain
// via InitChain.
chainID string
}

type appStore struct {
Expand Down Expand Up @@ -221,6 +225,10 @@ func (app *BaseApp) Trace() bool {
return app.trace
}

func (app *BaseApp) GetChainID() string {
return app.chainID
}

// MsgServiceRouter returns the MsgServiceRouter of a BaseApp.
func (app *BaseApp) MsgServiceRouter() *MsgServiceRouter { return app.msgServiceRouter }

Expand Down Expand Up @@ -579,10 +587,15 @@ func (app *BaseApp) getState(mode runTxMode) *state {
return app.checkState
}

// NewProcessProposalContext returns a context with a branched version of the
// DeliverTx state that is safe to query during ProcessProposal.
func (app *BaseApp) NewProcessProposalQueryContext() (sdk.Context, error) {
return app.createQueryContext(app.cms.LatestVersion(), false)
// NewProposalContext returns a context with a branched version of the state
// that is safe to query during ProcessProposal.
func (app *BaseApp) NewProposalContext(header tmproto.Header) sdk.Context {
// use custom query multistore if provided
ms := app.cms.CacheMultiStore()
ctx := sdk.NewContext(ms, header, false, app.logger).WithBlockGasMeter(storetypes.NewInfiniteGasMeter())
ctx = ctx.WithConsensusParams(app.GetConsensusParams(ctx))

return ctx
}

// retrieve the context for the tx w/ txBytes and other memoized values.
Expand Down
Loading