-
Notifications
You must be signed in to change notification settings - Fork 328
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
base: master
Are you sure you want to change the base?
Conversation
state/factory/workingset.go
Outdated
defer func() { | ||
if r := recover(); r != nil { | ||
receipt = nil | ||
err = errors.Wrapf(action.ErrPanic, "panic when running action: %v", r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define a local errPanic
so no need to change action/const.go
state/factory/workingset.go
Outdated
defer func() { | ||
if r := recover(); r != nil { | ||
receipt = nil | ||
err = errors.Wrapf(action.ErrPanic, "panic when running action: %v", r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an error which should be caught and handled appropriately in pickAndRunActions
such that the block mint process can continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to continue minting block, we need to revert to the state after the previous transaction is executed. This may require calling Snapshot()
before transaction execution, which would likely result in a hard fork.
Quality Gate passedIssues Measures |
ap.DeleteAction(caller) | ||
actionIterator.PopAccount() | ||
continue | ||
case action.ErrPanicButReverted: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if panic but reverted, continue when mint and terminate when validate block
sn := ws.Snapshot() | ||
defer func() { | ||
if err != nil { | ||
if e := ws.Revert(sn); e != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the Revert()
will be a hard fork here. We may need run fullsync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some unit test?
defer func() { | ||
if err != nil { | ||
if e := ws.Revert(sn); e != nil { | ||
log.T(ctx).Error("Failed to revert snapshot", zap.Error(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also log err
@@ -207,6 +207,24 @@ func (ws *workingSet) runAction( | |||
return nil, errors.Wrapf(err, "Failed to get hash") | |||
} | |||
defer ws.ResetSnapshots() | |||
sn := ws.Snapshot() | |||
defer func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could these two defer functions been merged which will make it easier to read and maintain
Description
Capture exceptions when processing transactions to prevent the program from exiting abnormally, and instead remove problematic transactions.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: