From 4df777a90af5f1b52ce4c225cd85639691eb2db8 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 17 Oct 2024 15:09:57 +0200 Subject: [PATCH] feat(baseapp): Abort OE in PrepareProposal (Upstream dydx) (#22287) Co-authored-by: Teddy Ding (cherry picked from commit 11698aa864f69f7f2e8a79106989dcb32dcc0ac7) --- baseapp/abci.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/baseapp/abci.go b/baseapp/abci.go index 15646e438ab6..979089c5c86d 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -409,6 +409,14 @@ func (app *BaseApp) PrepareProposal(req *abci.PrepareProposalRequest) (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{