From 6697313abe76e4f33a62448efe066c97ddf56ad0 Mon Sep 17 00:00:00 2001 From: codchen Date: Mon, 27 Feb 2023 08:28:55 -0800 Subject: [PATCH] Wait for optimistic processing to finish (#612) --- app/app.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index d79df9e98f..ba302bcf69 100644 --- a/app/app.go +++ b/app/app.go @@ -982,16 +982,13 @@ func (app *App) FinalizeBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) ctx.Logger().Info(fmt.Sprintf("FinalizeBlock took %dms", duration/time.Millisecond)) }() - if app.optimisticProcessingInfo != nil && !app.optimisticProcessingInfo.Aborted && bytes.Equal(app.optimisticProcessingInfo.Hash, req.Hash) { - select { - case <-app.optimisticProcessingInfo.Completion: + if app.optimisticProcessingInfo != nil { + <-app.optimisticProcessingInfo.Completion + if !app.optimisticProcessingInfo.Aborted && bytes.Equal(app.optimisticProcessingInfo.Hash, req.Hash) { app.SetProcessProposalStateToCommit() appHash := app.WriteStateToCommitAndGetWorkingHash() resp := app.getFinalizeBlockResponse(appHash, app.optimisticProcessingInfo.Events, app.optimisticProcessingInfo.TxRes, app.optimisticProcessingInfo.EndBlockResp) return &resp, nil - case <-time.After(OptimisticProcessingTimeoutInSeconds * time.Second): - ctx.Logger().Info("optimistic processing timed out") - break } } ctx.Logger().Info("optimistic processing ineligible")