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

runCode callback exception attr doc is wrong #70

Closed
chris-martin opened this issue Jun 2, 2016 · 6 comments · Fixed by #71
Closed

runCode callback exception attr doc is wrong #70

chris-martin opened this issue Jun 2, 2016 · 6 comments · Fixed by #71

Comments

@chris-martin
Copy link
Contributor

chris-martin commented Jun 2, 2016

This is what runCode.js looks like now:

exception: err ? 0 : 1

It seems to me that this logic is backwards, and should be

exception: err ? 1 : 0

But I'm also not sure why it isn't a boolean, as the documentation says it should be.

exception: !!err

44d096a fixed this and closed #48, but then it got reverted. I can't tell why.

@chris-martin chris-martin changed the title runCode exception is 1 if there is no exception runCode return value has exception: 1 if there is no exception Jun 2, 2016
@chris-martin chris-martin changed the title runCode return value has exception: 1 if there is no exception runCode return value has exception: 1 iff there is no exception Jun 2, 2016
@chris-martin
Copy link
Contributor Author

This comment may explain the revert: #49 (comment)

@wanderer
Copy link
Member

wanderer commented Jun 2, 2016

exception: err ? 0 : 1
Yeah this is just a weird thing in the Spec. The reason it was reverted was because when a call traps a 1 is supposed to be pushed to the stack. And if the exuction doesn't fail a 0 gets pushed to the stach

@chris-martin
Copy link
Contributor Author

Is this supposed to be like a process exit code, where a nonzero value indicates failure? If so, the readme needs to be fixed, because it says exception is

a boolean, whether or not the contract encountered an exception

@chris-martin chris-martin changed the title runCode return value has exception: 1 iff there is no exception runCode callback value has exception: 1 iff there is no exception Jun 2, 2016
chris-martin added a commit to chris-martin/ethereumjs-vm that referenced this issue Jun 2, 2016
@wanderer
Copy link
Member

wanderer commented Jun 2, 2016

Is this supposed to be like a process exit code, where a nonzero value indicates failure?

yep exactly! Could you update the readme?

@chris-martin
Copy link
Contributor Author

But it's still backwards, right?

when a call traps a 1 is supposed to be pushed to the stack. And if the exuction doesn't fail a 0 gets pushed to the stach

That's not what it does. If it fails, it's 0, and if it doesn't fail, it's 1.

@wanderer
Copy link
Member

wanderer commented Jun 2, 2016

I'm confusing myself here :P so lets look at the yellowpaper

μ'ₛ[0] ≡ x
where x = 0 if the code execution for this operation failed due to an exceptional halting ... x =1 otherwise

μ'ₛ[0] is the item that is placed onto the stack

chris-martin added a commit to chris-martin/ethereumjs-vm that referenced this issue Jun 2, 2016
@chris-martin chris-martin changed the title runCode callback value has exception: 1 iff there is no exception runCode callback exception attr doc is wrong Jun 2, 2016
holgerd77 pushed a commit that referenced this issue Dec 1, 2020
Unit tests for all components
ryanio pushed a commit that referenced this issue Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants