Skip to content

Commit e8a28d3

Browse files
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 <steven@seinetwork.io>
1 parent a0e55f4 commit e8a28d3

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

tasks/scheduler.go

+7-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
store "github.com/cosmos/cosmos-sdk/store/types"
1212
"github.com/cosmos/cosmos-sdk/telemetry"
1313
sdk "github.com/cosmos/cosmos-sdk/types"
14-
"github.com/cosmos/cosmos-sdk/types/errors"
1514
"github.com/cosmos/cosmos-sdk/types/occ"
1615
"github.com/cosmos/cosmos-sdk/utils/tracing"
1716
"github.com/tendermint/tendermint/abci/types"
@@ -516,21 +515,14 @@ func (s *scheduler) executeTask(task *deliverTxTask) {
516515
s.prepareTask(task)
517516

518517
resp := s.deliverTx(task.Ctx, task.Request)
519-
520-
// if an abort occurred, we want to handle that at this level
521-
if resp.Codespace == errors.ErrOCCAbort.Codespace() && resp.Code == errors.ErrOCCAbort.ABCICode() {
522-
// close the abort channel
523-
close(task.AbortCh)
524-
518+
// close the abort channel
519+
close(task.AbortCh)
520+
abort, ok := <-task.AbortCh
521+
if ok {
522+
// if there is an abort item that means we need to wait on the dependent tx
525523
task.SetStatus(statusAborted)
526-
// read the first abort from the channel
527-
abort, ok := <-task.AbortCh
528-
if ok {
529-
// if there is an abort item that means we need to wait on the dependent tx
530-
task.SetStatus(statusAborted)
531-
task.Abort = &abort
532-
task.AppendDependencies([]int{abort.DependentTxIdx})
533-
}
524+
task.Abort = &abort
525+
task.AppendDependencies([]int{abort.DependentTxIdx})
534526
// write from version store to multiversion stores
535527
for _, v := range task.VersionStores {
536528
v.WriteEstimatesToMultiVersionStore()

tasks/scheduler_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/cosmos/cosmos-sdk/store/cachemulti"
2222
"github.com/cosmos/cosmos-sdk/store/dbadapter"
2323
sdk "github.com/cosmos/cosmos-sdk/types"
24-
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
2524
"github.com/cosmos/cosmos-sdk/types/occ"
2625
"github.com/cosmos/cosmos-sdk/utils/tracing"
2726
)
@@ -50,8 +49,7 @@ func abortRecoveryFunc(response *types.ResponseDeliverTx) {
5049
if !ok {
5150
panic(r)
5251
}
53-
response.Code = sdkerrors.ErrOCCAbort.ABCICode()
54-
response.Codespace = sdkerrors.ErrOCCAbort.Codespace()
52+
// empty code and codespace
5553
response.Info = "occ abort"
5654
}
5755
}

0 commit comments

Comments
 (0)