Skip to content

Commit

Permalink
recover action handling panic
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc committed Dec 5, 2024
1 parent 7840b13 commit ba0ca99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions action/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
ErrGasTipOverFeeCap = errors.New("tip cap is greater than fee cap")
ErrMissRequiredField = errors.New("missing required field")
ErrValueVeryHigh = errors.New("value is very high")
ErrPanic = errors.New("panic")
)

// LoadErrorDescription loads corresponding description related to the error
Expand Down
8 changes: 7 additions & 1 deletion state/factory/workingset.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ func withActionCtx(ctx context.Context, selp *action.SealedEnvelope) (context.Co
func (ws *workingSet) runAction(
ctx context.Context,
selp *action.SealedEnvelope,
) (*action.Receipt, error) {
) (receipt *action.Receipt, err error) {
defer func() {
if r := recover(); r != nil {
receipt = nil
err = errors.Wrapf(action.ErrPanic, "panic when running action: %v", r)
}
}()
actCtx := protocol.MustGetActionCtx(ctx)
if protocol.MustGetBlockCtx(ctx).GasLimit < actCtx.IntrinsicGas {
return nil, action.ErrGasLimit
Expand Down

0 comments on commit ba0ca99

Please sign in to comment.