diff --git a/baseapp/abci.go b/baseapp/abci.go index 3d653e188752b..2eaa0de26a225 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -403,6 +403,14 @@ func (app *BaseApp) PrepareProposal(req *abci.RequestPrepareProposal) (resp *abc return nil, errors.New("PrepareProposal handler not set") } + // Abort any running OE so it cannot overlap with `PrepareProposal`. This could happen if optimistic + // `internalFinalizeBlock` from previous round takes a long time, but consensus has moved on to next round. + // Overlap is undesirable, since `internalFinalizeBlock` and `PrepareProoposal` could share access to + // in-memory structs depending on application implementation. + // No-op if OE is not enabled. + // Similar call to Abort() is done in `ProcessProposal`. + app.optimisticExec.Abort() + // Always reset state given that PrepareProposal can timeout and be called // again in a subsequent round. header := cmtproto.Header{ @@ -415,7 +423,7 @@ func (app *BaseApp) PrepareProposal(req *abci.RequestPrepareProposal) (resp *abc } app.setState(execModePrepareProposal, header) - // CometBFT must never call PrepareProposal with a height of 0. + // CometBFT must never call PrepareProposal with a height of 00. // // Ref: https://github.com/cometbft/cometbft/blob/059798a4f5b0c9f52aa8655fa619054a0154088c/spec/core/state.md?plain=1#L37-L38 if req.Height < 1 {