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

bounty: fix slot overwrite bug on packed variables #117

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wei3erHase
Copy link
Member

Bug description:

When variables are declared nearby (sometimes either in other abstract contract, but close on declaration order), using the setVariable method on one, can erase the information about the other variable.

contract Bug {
  address public myAddress;
  bool public myBool;
}
await bug.setVariable('myAddress', randomAddress)
await bug.setVariable('myBool', true)

console.log(await bug.myAddress()) // => 0x0000...

Given that myAddress (that occupies ~uint160) and myBool are stored together, the second setVariable method aims to the entire data slot and overwrites it with 0x0000...1 (true), and when the myAddress slot is fetched, is filled with 0s.

An example contract is added, and a test replicating the descripted bug.

@wei3erHase wei3erHase changed the title Bounty: fix slot overwrite bug on packed variables bounty: fix slot overwrite bug on packed variables Jun 17, 2022
@wei3erHase wei3erHase marked this pull request as draft June 17, 2022 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant