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

Rework memory expansion/access in opFns #174

Merged
merged 8 commits into from
Dec 14, 2017
Merged

Rework memory expansion/access in opFns #174

merged 8 commits into from
Dec 14, 2017

Conversation

axic
Copy link
Member

@axic axic commented Aug 14, 2017

Fixes #167. Depends on #175, #179, #186 and #188.

@axic axic force-pushed the opfns-memory branch 5 times, most recently from c67eaf0 to 17c7272 Compare August 14, 2017 21:54
@axic
Copy link
Member Author

axic commented Aug 14, 2017

This should work, but the reason it fails in some tests I think is because the VM is actually broken in those aspects, but the exception of bufferToInt masked those with an exceptional abort.

@axic axic force-pushed the opfns-memory branch 2 times, most recently from a867cb3 to 8ad6d0f Compare August 17, 2017 13:15
lib/opFns.js Outdated
const newMemoryWordCount = Math.ceil((offset + length) / 32)

if (newMemoryWordCount <= runState.memoryWordCount) return
const newMemoryWordCount = offset.add(length).divRound(new BN(32))
Copy link
Contributor

@jwasinger jwasinger Aug 19, 2017

Choose a reason for hiding this comment

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

I believe the use of divRound is a problem here because we want to be rounding up to the next full word (i.e. ceil).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review, but divRound is supposed to round up and also had an assertion for comparing the two versions. It might still be wrong, but most of the failures I've found weren't gas related, but plain crashes.

This PR is not finished and have found a lot of other bugs.

Copy link
Contributor

Choose a reason for hiding this comment

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

var BN = require('ethereumjs-util').BN

var x = new BN(20)
var y = new BN(15)
x = x.divRound(y)
console.log(x.toString())

gives

1

So it is clearly rounding down in this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, in that case the comparison was wrong, however if you look at the test results, there are plenty of other failures (number too big). Those I am in progress fixing.

@axic axic changed the title Rework memory expansion/access in opFns [WIP] Rework memory expansion/access in opFns Aug 20, 2017
@axic axic force-pushed the opfns-memory branch 2 times, most recently from 8ae1477 to 384e5fb Compare August 21, 2017 00:46
@axic axic force-pushed the opfns-memory branch 2 times, most recently from 7a7f163 to 0a51469 Compare August 22, 2017 23:22
@axic
Copy link
Member Author

axic commented Aug 23, 2017

Down to these failures:

not ok 22 the state roots should match
not ok 714 the state roots should match
not ok 737 the state roots should match
not ok 753 the state roots should match
not ok 829 the state roots should match
not ok 1151 the state roots should match
not ok 1230 the state roots should match
not ok 1404 the state roots should match
not ok 2133 the state roots should match
not ok 2134 the state roots should match
not ok 2161 the state roots should match

lib/opFns.js Outdated
* @return {String}
*/
function subMemUsage (runState, offset, length) {
// abort if no usage
if (!length) return
Copy link
Member Author

Choose a reason for hiding this comment

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

So apparently this one is the correct behaviour as per the sidenote in the YP in section H.1.

@jwasinger
Copy link
Contributor

Working on this. I was able to bring failures down from 569->526.

@jwasinger
Copy link
Contributor

Down to 2 failures!

@axic
Copy link
Member Author

axic commented Oct 5, 2017

@jwasinger can you let me know when this is near completion? I'd like to squash done some commits (mostly mine).

@jwasinger
Copy link
Contributor

@axic Sure. I'm working on the remaining failures now.

@jwasinger
Copy link
Contributor

jwasinger commented Oct 6, 2017

@axic I think this is ready (other than linting travis failure).

@jwasinger
Copy link
Contributor

@axic can you squash your commits? then I can fix linting and we can get this merged.

@axic
Copy link
Member Author

axic commented Oct 10, 2017

Yep will do.

@axic
Copy link
Member Author

axic commented Oct 28, 2017

Finally this works now, just need to fix lint & squash more things.

@axic axic changed the title [WIP] Rework memory expansion/access in opFns Rework memory expansion/access in opFns Dec 9, 2017
@axic
Copy link
Member Author

axic commented Dec 9, 2017

@jwasinger can you do a review and possibly merge?

@jwasinger jwasinger self-assigned this Dec 11, 2017
@axic
Copy link
Member Author

axic commented Dec 12, 2017

@jwasinger the funny thing is we had the zeroing out, but the state tests pass with and without so who knows..

@jwasinger
Copy link
Contributor

That's a bit unsettling.. I got hung up on how to remove that hack but I think I've got it now.

@jwasinger jwasinger removed their assignment Dec 12, 2017
@jwasinger jwasinger force-pushed the opfns-memory branch 2 times, most recently from 419c505 to ba0dc82 Compare December 13, 2017 21:01
@jwasinger jwasinger merged commit d1ba323 into master Dec 14, 2017
@jwasinger jwasinger deleted the opfns-memory branch December 14, 2017 20:06
holgerd77 pushed a commit that referenced this pull request Dec 1, 2020
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.

VM has a lot of consensus breaking bugs 🐞
5 participants