-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
core/vm: Simplify error handling in interpreter loop #23952
Changes from all commits
07db342
7204435
8fa9c00
1b9c5e3
46fbfd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -259,22 +259,16 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( | |||||
|
||||||
// execute the operation | ||||||
res, err = operation.execute(&pc, in, callContext) | ||||||
// if the operation clears the return data (e.g. it has returning data) | ||||||
// set the last return to the result of the operation. | ||||||
if operation.returns { | ||||||
in.returnData = res | ||||||
} | ||||||
|
||||||
switch { | ||||||
case err != nil: | ||||||
return nil, err | ||||||
case operation.reverts: | ||||||
return res, ErrExecutionReverted | ||||||
case operation.halts: | ||||||
return res, nil | ||||||
case !operation.jumps: | ||||||
pc++ | ||||||
if err != nil { | ||||||
break | ||||||
} | ||||||
pc++ | ||||||
} | ||||||
return nil, nil | ||||||
|
||||||
if err == errStopToken { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more go-idiomatic
Suggested change
But maybe your variant is more performant? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My slight preference is to leave There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to use |
||||||
err = nil // clear stop token error | ||||||
} | ||||||
|
||||||
return res, err | ||||||
} |
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 not covered by tests. Reported in ethereum/tests#993.