Skip to content

Commit

Permalink
chore!: prepare process proposal state (#326)
Browse files Browse the repository at this point in the history
* chore!: replace proposal context creation

* chore!: replace proposal context creation
  • Loading branch information
evan-forbes committed Jun 13, 2023
1 parent 95b3fdc commit dfc04d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
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

// 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

0 comments on commit dfc04d1

Please sign in to comment.