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

fix BYTE return value #293

Merged
merged 3 commits into from
Apr 18, 2018
Merged

fix BYTE return value #293

merged 3 commits into from
Apr 18, 2018

Conversation

yann300
Copy link
Contributor

@yann300 yann300 commented Apr 11, 2018

No description provided.

@@ -156,7 +156,7 @@ module.exports = {
return new BN(0)
}

return word.shrn((31 - pos.toNumber()) * 8).andln(0xff)
return new BN(word.shrn((31 - pos.toNumber()) * 8).andln(0xff))
Copy link
Member

Choose a reason for hiding this comment

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

How was this bug not caught?

andln returns a Javascript integer.

@pirapira @winsvega do we have proper state tests for BYTE?

Copy link
Contributor

Choose a reason for hiding this comment

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

it passes the relevant vm tests, fwiw:

ok 171 valid gas usage [file: byte10]
...
ok 297 valid gas usage [file: byte1]
ok 298 valid return value

Copy link
Member

Choose a reason for hiding this comment

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

This PR passes it, master or both pass it?

It may be some combination of instructions which triggered this. @yann what was the actual issue you ran into?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in remix we have to format the stack for each step to be compliant to the geth trace.
Before js vm would return a list of buffer for the stack , but it has been changed to BN.
And we end up by having a mix of BN and integger (due to BYTE)

Copy link
Contributor

Choose a reason for hiding this comment

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

master (unpatched) passes the relevant VM tests. I haven't tried the PR.

Choose a reason for hiding this comment

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

I see. I never thought about how return values from instructions are used afterward.

Choose a reason for hiding this comment

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

I created an issue in tests repo ethereum/tests#448

Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if somehow we could include the hash of memory and the stack in the tests. That should catch a lot of things (but not all) tracing tries to catch.

Copy link
Member

Choose a reason for hiding this comment

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

@yann300 the patch is correct and should be merged. All the stack items should be an instance of BN. Please report if you find any other discrepancy.

Choose a reason for hiding this comment

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

@axic I'm not sure about the checking the stack contents. Implementations are allowed not to compute stack elements that are never used.

@coveralls
Copy link

coveralls commented Apr 11, 2018

Coverage Status

Coverage remained the same at 85.505% when pulling 8f721bb on yann300:patch-2 into 1cbba0a on ethereumjs:master.

@yann300
Copy link
Contributor Author

yann300 commented Apr 16, 2018

@axic @holgerd77 could this be merged and release?

@jwasinger jwasinger merged commit b711bc4 into ethereumjs:master Apr 18, 2018
@axic
Copy link
Member

axic commented Apr 18, 2018

@jwasinger please rebase next time before merging to remove the extra merge commits 😉

mikeseese added a commit to trufflesuite/ganache that referenced this pull request Jun 13, 2018
holgerd77 added a commit that referenced this pull request Mar 11, 2021
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.

7 participants