Skip to content

Commit

Permalink
Rework abort handling to not be dependent on extracting codes from de…
Browse files Browse the repository at this point in the history
…livertx 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 <[email protected]>
  • Loading branch information
udpatil and stevenlanders authored Mar 19, 2024
1 parent a0e55f4 commit e8a28d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
22 changes: 7 additions & 15 deletions tasks/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions tasks/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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"
}
}
Expand Down

0 comments on commit e8a28d3

Please sign in to comment.