Skip to content

Commit a57cdc2

Browse files
committed
fix(giga): OCC returns panics as error
1 parent c184e04 commit a57cdc2

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

app/app.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,13 +2060,29 @@ func (app *App) executeEVMTxWithGigaExecutor(ctx sdk.Context, msg *evmtypes.MsgE
20602060
// makeGigaDeliverTx returns an OCC-compatible deliverTx callback that captures the given
20612061
// block cache, avoiding mutable state on App for cache lifecycle management.
20622062
func (app *App) makeGigaDeliverTx(cache *gigaBlockCache) func(sdk.Context, abci.RequestDeliverTxV2, sdk.Tx, [32]byte) abci.ResponseDeliverTx {
2063-
return func(ctx sdk.Context, req abci.RequestDeliverTxV2, tx sdk.Tx, checksum [32]byte) abci.ResponseDeliverTx {
2063+
return func(ctx sdk.Context, req abci.RequestDeliverTxV2, tx sdk.Tx, checksum [32]byte) (resp abci.ResponseDeliverTx) {
20642064
defer func() {
20652065
if r := recover(); r != nil {
2066-
// OCC abort panics are expected - the scheduler uses them to detect conflicts
2067-
// and reschedule transactions. Don't log these as errors.
2068-
if _, isOCCAbort := r.(occ.Abort); !isOCCAbort {
2069-
ctx.Logger().Error("benchmark panic in gigaDeliverTx", "panic", r, "stack", string(debug.Stack()))
2066+
// Handle panics as v2 does: ErrOCCAbort, ErrOutOfGas, or ErrPanic
2067+
if abort, isOCCAbort := r.(occ.Abort); isOCCAbort {
2068+
resp = abci.ResponseDeliverTx{
2069+
Code: sdkerrors.ErrOCCAbort.ABCICode(),
2070+
Log: fmt.Sprintf("occ abort occurred with dependent index %d and error: %v", abort.DependentTxIdx, abort.Err),
2071+
}
2072+
return
2073+
}
2074+
if oogErr, isOOG := r.(sdk.ErrorOutOfGas); isOOG {
2075+
resp = abci.ResponseDeliverTx{
2076+
Code: sdkerrors.ErrOutOfGas.ABCICode(),
2077+
Log: fmt.Sprintf("out of gas in location: %v", oogErr.Descriptor),
2078+
}
2079+
return
2080+
}
2081+
// For other panics (e.g., nil deref from malformed protobuf), log and return ErrPanic
2082+
ctx.Logger().Error("panic in gigaDeliverTx", "panic", r, "stack", string(debug.Stack()))
2083+
resp = abci.ResponseDeliverTx{
2084+
Code: sdkerrors.ErrPanic.ABCICode(),
2085+
Log: fmt.Sprintf("recovered: %v\nstack:\n%v", r, string(debug.Stack())),
20702086
}
20712087
}
20722088
}()

0 commit comments

Comments
 (0)