From e8a28d33023a76e34ad0130de82efb93222b29e8 Mon Sep 17 00:00:00 2001 From: Uday Patil Date: Tue, 19 Mar 2024 16:20:06 -0500 Subject: [PATCH] Rework abort handling to not be dependent on extracting codes from delivertx errors (#465) ## Describe your changes and provide context This should appropriately allow for cases where panics are recovered and swallowed earlier because we now simply use the panic to abort execution, and detect that an abort occurred by reading the abort channel as the source of truth ## Testing performed to validate your change Scheduler tests, and need to test alongside atlantic-2 Co-authored-by: Steven Landers --- tasks/scheduler.go | 22 +++++++--------------- tasks/scheduler_test.go | 4 +--- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/tasks/scheduler.go b/tasks/scheduler.go index 22da1696f..2a40993bc 100644 --- a/tasks/scheduler.go +++ b/tasks/scheduler.go @@ -11,7 +11,6 @@ import ( store "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/occ" "github.com/cosmos/cosmos-sdk/utils/tracing" "github.com/tendermint/tendermint/abci/types" @@ -516,21 +515,14 @@ func (s *scheduler) executeTask(task *deliverTxTask) { s.prepareTask(task) resp := s.deliverTx(task.Ctx, task.Request) - - // if an abort occurred, we want to handle that at this level - if resp.Codespace == errors.ErrOCCAbort.Codespace() && resp.Code == errors.ErrOCCAbort.ABCICode() { - // close the abort channel - close(task.AbortCh) - + // close the abort channel + close(task.AbortCh) + abort, ok := <-task.AbortCh + if ok { + // if there is an abort item that means we need to wait on the dependent tx task.SetStatus(statusAborted) - // read the first abort from the channel - abort, ok := <-task.AbortCh - if ok { - // if there is an abort item that means we need to wait on the dependent tx - task.SetStatus(statusAborted) - task.Abort = &abort - task.AppendDependencies([]int{abort.DependentTxIdx}) - } + task.Abort = &abort + task.AppendDependencies([]int{abort.DependentTxIdx}) // write from version store to multiversion stores for _, v := range task.VersionStores { v.WriteEstimatesToMultiVersionStore() diff --git a/tasks/scheduler_test.go b/tasks/scheduler_test.go index 13a9ad496..94abc0e65 100644 --- a/tasks/scheduler_test.go +++ b/tasks/scheduler_test.go @@ -21,7 +21,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/cachemulti" "github.com/cosmos/cosmos-sdk/store/dbadapter" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/occ" "github.com/cosmos/cosmos-sdk/utils/tracing" ) @@ -50,8 +49,7 @@ func abortRecoveryFunc(response *types.ResponseDeliverTx) { if !ok { panic(r) } - response.Code = sdkerrors.ErrOCCAbort.ABCICode() - response.Codespace = sdkerrors.ErrOCCAbort.Codespace() + // empty code and codespace response.Info = "occ abort" } }