-
Notifications
You must be signed in to change notification settings - Fork 38
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
Address casting #188
Open
zoep
wants to merge
100
commits into
main
Choose a base branch
from
addr-block
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Address casting #188
Conversation
This file contains 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR introduces the ability to cast addresses to contracts. Below are the key components of the new feature:
pointers
for constructor and behaviours. This block allows assumptions about variables of address type pointing to specific contract types. For example:Here, the variable x is assumed to be an address pointing to a contract of type A, and an address pointing to a contract of type B. Subsequently, in the rest of the specification, x and y can be treated as contracts of types A and B, respectively.
The internal Act contract type is removed, contracts are internally treated as integers. The representation is the same as address type.
Field selector and mapping syntax is now available for input variables, not just state variables. This allows for handling calldata variables that are addresses pointing to contracts as contracts.
Handling of state and calldata variables in the AST is unified. A phantom type is added to differentiate between calldata and storage entries. The downside of this is that it requires adding a singleton type which adds complexity. However, this approach allows us to avoid duplicate code while still enforcing that only storage variables are used in specific AST nodes (e.g., storage updates).
The translation to hevm's Expr is modified so that it creates an initial contract state that has all contracts that are assume to be alive when a constructor is called.
After each constructor or behavior state transition, a check ensures that the post-transition contract state is isomorphic to the pre-transition state. This ensures that the contract state shape is invariant in the contract. Without this invariant, equivalence would need to account for every potential contract state shape, which would increase computational complexity.
Several tests that involve casting are added.