-
Notifications
You must be signed in to change notification settings - Fork 477
Fix Option pointer bug #570
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aa72560
Advance ptr, even when 'None'
cmichi 69cd40e
Revert me: Add minimal contract which reproduces bug
cmichi be8f3af
Fix typo: explicitely ➜ explicitly
cmichi 37ed1fc
Add regression test
cmichi 403439f
Improve structure
cmichi e957478
Revert "Revert me: Add minimal contract which reproduces bug"
cmichi 69112ae
Fix clippy error 'result_unit_err'
cmichi ab25124
Fix clippy error 'result_unit_err'
cmichi 9e2828a
Fix typo: sucesful ➜ successful
cmichi 4d52e85
Improve comment
cmichi 15412a7
Remove no-op
cmichi 3bc442e
Remove type aliases for V1/V2
cmichi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The entire test can be heavily simplified. You only need to push a
(Option, i32)tuple with values(None, 1)to the contract storage and then read it again in the next step and assert that the first value isNoneand the second value is1. Done.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.
Or am I missing something?
Uh oh!
There was an error while loading. Please reload this page.
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.
So that's a clever idea, I guess you thought the
1would be written out to the first pointer and on the nextpull_spreadwe would try to read aSome(...)there and fail. It doesn't work unfortunately because of this:push_spreadforOptionwritesself.is_some() as u8in the first ptr slot and increments the pointer. Hence on the nextpull_spreadwe immediately return theNoneand continue pulling thei32. So no failure would occur here.Uh oh!
There was an error while loading. Please reload this page.
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.
Using a tuple also doesn't simplify the test significantly, because for each tuple element the entire
push_spreadrecursion is called. So storage is basically overwritten until I introduceLazyCellinto the tuple. (Note that in my test only theOptionis pushed in step 2).I mean the whole test could also be simplified way more drastically to something like
(I only thought of this now)
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.
Thanks for the elaboration!