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

Clean up VmError #219

Merged
merged 7 commits into from
Dec 9, 2017
Merged

Clean up VmError #219

merged 7 commits into from
Dec 9, 2017

Conversation

axic
Copy link
Member

@axic axic commented Oct 12, 2017

Pulled from #174.

Copy link
Contributor

@jwasinger jwasinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this running. 45 failing tests. I wonder if the VM is actually broken in those.

lib/runCode.js Outdated
@@ -193,8 +193,7 @@ module.exports = function (opts, cb) {
// run the opcode
var result = opFn.apply(null, args)
} catch (e) {
runState.vmError = e.error
cb()
cb(new VmError(e.error))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually could be cb(e)

@holgerd77
Copy link
Member

This test run falls in the period where we temporarily had the Promise-version for async/await in ethereumjs-testing with the memory overflow problems, might have influenced the results. Have restarted the build, we'll see what comes out of this.

@holgerd77
Copy link
Member

Ah no, still failing. :-/

@axic
Copy link
Member Author

axic commented Oct 24, 2017

Looking at the below more carefully:

   function parseVmResults (err) {
     err = runState.vmError || err

Shows that err must be an error text ("constant") and not an exception object.

@holgerd77
Copy link
Member

Can't investigate further - no time - but here are some results when running one failing test with node tests/tester -s --test='returndatacopy_following_revert' --jsontrace on both branches:

master

{"pc":41,"op":96,"gas":"0x9ffffab10","gasCost":"0x3","stack":["0x20"],"depth":0,"opName":"PUSH1"}
{"pc":43,"op":96,"gas":"0x9ffffab0d","gasCost":"0x3","stack":["0x20","0x0"],"depth":0,"opName":"PUSH1"}
{"pc":45,"op":62,"gas":"0x9ffffab0a","gasCost":"0x3","stack":["0x20","0x0","0x0"],"depth":0,"opName":"RETURNDATACOPY"}
{"pc":46,"op":96,"gas":"0x9ffffab04","gasCost":"0x3","stack":[],"depth":0,"opName":"PUSH1"}
{"pc":48,"op":81,"gas":"0x9ffffab01","gasCost":"0x3","stack":["0x0"],"depth":0,"opName":"MLOAD"}
{"pc":49,"op":96,"gas":"0x9ffffaafb","gasCost":"0x3","stack":["0x111122223333444455556666777788889999aaaabbbbccccddddeeeeffff"],"depth":0,"opName":"PUSH1"}
{"pc":51,"op":85,"gas":"0x9ffffaaf8","gasCost":"0x0","stack":["0x111122223333444455556666777788889999aaaabbbbccccddddeeeeffff","0x0"],"depth":0,"opName":"SSTORE"}
ok 1 the state roots should match

1..1
# tests 1
# pass  1

error-cb

{"pc":41,"op":96,"gas":"0xffffab22","gasCost":"0x3","stack":["0x20"],"depth":0,"opName":"PUSH1"}
{"pc":43,"op":96,"gas":"0xffffab1f","gasCost":"0x3","stack":["0x20","0x0"],"depth":0,"opName":"PUSH1"}
{"pc":45,"op":62,"gas":"0xffffab1c","gasCost":"0x3","stack":["0x20","0x0","0x0"],"depth":0,"opName":"RETURNDATACOPY"}
not ok 1 the state roots should match
  ---
    operator: equal
    expected: |-
      '7021b60fa4ce0fd56ce1b85e9c529345300b005574afb1f51a8363471cefdcd3'
    actual: |-
      'dbcee120f31bca7ddc3ec1d52a1b861c02c63d469e954096ff264858b58df101'
    at: replenish (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-vm/node_modules/async/dist/async.js:946:17)
  ...

1..1
# tests 1
# pass  0
# fail  1

@Silur
Copy link
Contributor

Silur commented Nov 16, 2017

returnDataCopy revert only needed a deepcheck for err.
Currently failing

  • RevertOpcodeCreate
  • RevertOpcodeInCreateReturns
  • RevertOpcodeInInit
    fix in progress

@Silur Silur self-assigned this Nov 16, 2017
lib/runCode.js Outdated
@@ -214,7 +213,7 @@ module.exports = function (opts, cb) {
}

function parseVmResults (err) {
err = runState.vmError || err
err = runState.vmError || (err && (err.error || err))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if the instances not returning an error object would be fixed instead. Do you happen to know which ones?

Copy link
Contributor

@jwasinger jwasinger Dec 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to remove this. now we are back to the failures that @Silur mentioned.

@jwasinger
Copy link
Contributor

Hey, @Silur. My apologies, I forgot you had claimed this issue. Were you able to make any progress on the four failing tests? Or can I try and get this finished?

@Silur
Copy link
Contributor

Silur commented Dec 6, 2017

oh great you found the part where it didn't return with an err!
I put the hackcheck for that, lemme see what breaks now

@@ -193,8 +193,7 @@ module.exports = function (opts, cb) {
// run the opcode
var result = opFn.apply(null, args)
} catch (e) {
runState.vmError = e.error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is where RevertOpcodeCreate breaks, using new VmError(e) or new VmError(e.error) doesn't work, maybe leave the runState error here for e is not in any of the categorized exceptions?

Copy link
Contributor

@jwasinger jwasinger Dec 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not even sure if vmError is used anymore after these changes. Ideally, we could remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vmError is used in the result output object by users of the VM (such as Remix)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. Best to leave it in then :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, double checked remix and it uses exceptionError. Though there might be some other user which uses vmError, so I should add that back it properly

lib/runCode.js Outdated
@@ -193,6 +193,7 @@ module.exports = function (opts, cb) {
// run the opcode
var result = opFn.apply(null, args)
} catch (e) {
runState.vmError = e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any error occurred here does not belong to any of the known exceptions, so excluding them from the runState will break stateroots

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see @axic has incorporated a new type of error INTERNAL_ERROR (https://github.com/ethereumjs/ethereumjs-vm/blob/35e8ddcc71ae47954d5a2599d784b3e63507df6f/lib/constants.js#L9) in #222 .

Maybe we can pull those changes to this PR, and add a new field that allows us to specify a custom error message for INTERNAL_ERRORs .

jwasinger
jwasinger previously approved these changes Dec 8, 2017
Copy link
Contributor

@jwasinger jwasinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

jwasinger
jwasinger previously approved these changes Dec 9, 2017
@axic
Copy link
Member Author

axic commented Dec 9, 2017

@jwasinger didn't know it will dismiss the review :(

@axic
Copy link
Member Author

axic commented Dec 9, 2017

@Silur @jwasinger thanks for fixing this!

@axic
Copy link
Member Author

axic commented Dec 9, 2017

@jwasinger @Silur please review the last commit and merge hopefully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants