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

Implement discovery of packed encodings #46

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

iamrecursion
Copy link
Contributor

Summary

This commit implements the following features into the analyzer:

  • Discovery and lifting of multiplicative shifts of values that are commonly used by solc when constructing packed encodings.
  • Discovery and lifting of packed encoding structures themselves, taking the form of bitwise disjunctions of masked and shifted values.
  • Care is taken in the lifting pass to ensure that segments of packed encodings that are not used (are direct reads from the slot into which the packed encoding is being written) are ignored, thus ensuring we do not infer types for segments of storage slots that are not really written to.
  • Loads from storage are now wrapped in SLoad nodes, allowing for detailed tracking of when a value was loaded from storage in the value trees.

Details

Please carefully check my logic in all of these changes as they can be quite subtle.

Checklist

  • Code is formatted by Rustfmt.
  • Documentation has been updated if necessary.

@iamrecursion iamrecursion added the enhancement New feature or request label Aug 1, 2023
@iamrecursion iamrecursion self-assigned this Aug 1, 2023
@iamrecursion iamrecursion force-pushed the wip/ara/discover-packed-encodings branch 2 times, most recently from f573167 to c08600f Compare August 1, 2023 20:32
Copy link

@kustosz kustosz left a comment

Choose a reason for hiding this comment

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

Logic looks good, approving. But please make clippy happy – plenty of new warnings in this PR

tests/packed_encodings.rs Outdated Show resolved Hide resolved
@iamrecursion iamrecursion force-pushed the wip/ara/discover-packed-encodings branch 3 times, most recently from 8a121ef to ca1970b Compare August 2, 2023 17:07
This commit implements the following features into the analyzer:

- Discovery and lifting of multiplicative shifts of values that are
  commonly used by solc when constructing packed encodings.
- Discovery and lifting of packed encoding structures themselves, taking
  the form of bitwise disjunctions of masked and shifted values.
- Care is taken in the lifting pass to ensure that segments of packed
  encodings that are _not used_ (are direct reads from the slot into
  which the packed encoding is being written) are ignored, thus ensuring
  we do not infer types for segments of storage slots that are not
  really written to.
- Loads from storage are now wrapped in `SLoad` nodes, allowing for
  detailed tracking of when a value was loaded from storage in the value
  trees.
@iamrecursion iamrecursion force-pushed the wip/ara/discover-packed-encodings branch from ca1970b to f7672dd Compare August 2, 2023 17:12
@iamrecursion iamrecursion merged commit 241f442 into main Aug 2, 2023
5 checks passed
@iamrecursion iamrecursion deleted the wip/ara/discover-packed-encodings branch August 2, 2023 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants