-
Notifications
You must be signed in to change notification settings - Fork 782
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
Throw original error and terminate execution on programmatic errors #307
Conversation
@jwasinger Hi Jared, could you also have a look at this, since you also were involved in originally covering this up? The only thing I have here is that the solution seems a bit simple for me for all the discussion we had around this 😄, I tested this nevertheless and I'm not seeing why this shouldn't work (this is actually still more-or-less what you originally proposed, chose a slightly different way, but conceptionally the same). |
…M-internal errors
441ccf4
to
9b1a0d0
Compare
Just rebased this. |
@@ -200,8 +200,12 @@ module.exports = function (opts, cb) { | |||
// run the opcode | |||
var result = opFn.apply(null, args) | |||
} catch (e) { | |||
cb(e) | |||
return | |||
if (e.errorType && e.errorType === 'VmError') { |
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.
I think instead of errorType
you could use something like e is VmError
or typeof(e) === VmError
.
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.
Ah, no, tested this. Even on a VmError is still of common type Error.
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 was my first idea as well)
This solves #191 by throwing all programmatic errors not being internal errors of the VM (like
OUT_OF_GAS
).Behaviour can be tested by introducing a JS runtime error in
opFn.js
, e.g. by adding:as a first line in the
ADD
opcode and then run a state test encompassing this opcode in the stack:node tests/tester.js -s --test='add11'
Behaviour before:
-> Runtime error is implicitly handled, the differing state roots suggest some VM internal error.
Behaviour with PR:
-> Original JS runtime error is thrown, indicating an error in the code