-
Notifications
You must be signed in to change notification settings - Fork 68
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
Support for static storage arrays #82
Comments
On the main branch, we get the following error instead
I think this is related to how static arrays are laid out (flattened to slots 0-2) vs dynamic arrays, and indeed the test passes if you define make v dynamic (
I think this works as expected -- wdyt @daejunpark ? |
@QGarchery Apologies for delayed response! I have been trying to find a good way to support this, but no luck so far (other than major design change for storage encoding scheme). In the current design, each mapping or dynamic array is encoded as a logically separate object (smt-array). To do that, when given a storage slot (usually a hash expression), we need to determine which logical object it belongs to. For that, we use their base slot (i.e., 0, 1, 2, ... assigned to each storage variables in the order they appear in source code), as the slots belong to the same logical object share the same base slot. To identify the base slot, we decode the hash expression. For example, the slot for We might be able to come up with a scheme that works for simple cases, but I'm not sure how robust it would be. I think we may need to re-design the storage encoding scheme, to better handle this case as well as other known limitations. |
ValueError
Thanks for the detailed reponse @daejunpark ! I'll try to rephrase it to make sure I understood it well, please tell me if I'm missing something. In Halmos, when you see a storage access, you try to map it to an object that was already encoded in SMT. You first look at the key to deduce the base slot, and from the base slot you can get the corresponding object. There are 2 patterns of keys that are recognized currently:
The following potential solutions come to mind (I have no idea how applicable they are):
|
@QGarchery yes, your understanding is correct, and thank you for the suggestions! indeed, i've already considered (1) and (2), and i would probably try some combinations of them. a challenge for (1) would be how to distinguish while such forms of expressions may not appear as arguments for the sload and sstore opcode in most cases, i've seen some smart contracts using their own custom storage layout (e.g., solady library) for gas optimization. in that case, the forms so, i think we also need to utilize the storage layout information, like you mentioned in (2), to avoid mis-interpretation. however, the storage layout information is not yet available within halmos, and we need to improve the frontend compilation pipeline to get that information. there are also other issues in the current frontend, so we will have to work on that anyway. regarding (3), it might be doable by using the source mapping information. again, that needs the frontend work. also i'm not sure how precise the source mapping will be. if there are multiple storage variable accesses in the given source mapping range, it would be hard to make it robust. again, thank you for reporting this issue and providing well-thought-out suggestions! please feel free to reach out if you have any other ideas! |
Describe the bug
When trying to use a custom getter of an array of integers in storage, halmos fails with:
ValueError: invalid literal for int() with base 10: 'p_i_uint256'
To Reproduce
Run
halmos
on the following contract:Environment:
The text was updated successfully, but these errors were encountered: