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

Recover from action handling panic #4513

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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)
envestcc marked this conversation as resolved.
Show resolved Hide resolved
envestcc marked this conversation as resolved.
Show resolved Hide resolved
}
}()
actCtx := protocol.MustGetActionCtx(ctx)
if protocol.MustGetBlockCtx(ctx).GasLimit < actCtx.IntrinsicGas {
return nil, action.ErrGasLimit
Expand Down
Loading