-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Cannot find the storage slot for a public string variable #3869
Comments
@mds1 @ZeroEkkusu ptal |
This makes sense to me: |
multi-slot stuff would be a big unlock but quite painful to accomplish safely. If the string fits in 32 bytes, it works but anything longer won't. I would recommend manually using vm.load if you need to handle multi slot strings |
@brockelmore Is it possible to have a Edit: I thought about it a few months ago but saw that parsing storage layout gets complicated with structs/nesting, as I mentioned. |
We've talked about that a bit in the past, a few considerations that I recall:
|
I agree with all three points. |
Now that i think about it there is a nonzero chance that if we know we are finding a string or bytes we can check for sequentialities in the read slots and match against those actually |
Also need to consider that the data might be in the slot itself, or the slot might just have the encoded length with the data in But yea, for the latter case you can just keep reading adjacent slots until it's empty which should pretty much always be a safe assumption |
@mds1 @rkrasiuk @brockelmore @ZeroEkkusu Thanks for the answers and comments. In the given example, I was thinking that the information at the slot 1 can be read directly to know about the string |
@simontianx can you try the branch of forge-std in the PR i linked above? Should work |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (b28119b 2022-11-23T03:06:50.152811Z)
What command(s) is the bug in?
forge test
Operating System
Windows
Describe the bug
For a simple storage layout given below, it's possible to find the storage slot for
owner
andnumber
by runningstdstore.target(address(test)).sig("owner()").find();
orstdstore.target(address(test)).sig("number()").find();
, but it's failing when runningstdstore.target(address(test)).sig("sentence()").find();
.The text was updated successfully, but these errors were encountered: