Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework abort handling to not be dependent on extracting codes from delivertx errors #465

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading