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

StdStorage Slot find does not find storage slot for short strings. #345

Open
rzmahmood opened this issue Apr 11, 2023 · 2 comments
Open

Comments

@rzmahmood
Copy link

rzmahmood commented Apr 11, 2023

Example contract:

contract MyContract {
   // short string as it only has 31 characters
    string public exists = "thequickbrownfoxjumpsoverthelaz";
}

Script:

contract MyScript is Script {
    using stdStorage for StdStorage;

    function run() public {
        uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
        vm.startBroadcast(deployerPrivateKey);

        MyContract s = new MyContract();

        uint256 slot = stdstore.target(address(s)).sig("exists()").find();
        console2.log(slot);
        vm.stopBroadcast();
    }
}

Output:

stdStorage find(StdStorage): Slot(s) not found.
@mds1
Copy link
Collaborator

mds1 commented Apr 11, 2023

This is currently not supported, more discussion in foundry-rs/foundry#3869

@brockelmore has a PR that should fix this in #259, but I'm not sure of the status of it

Edit: Hm actually per foundry-rs/foundry#3869 (comment) maybe this should work, let me try to reproduce

@mds1
Copy link
Collaborator

mds1 commented Apr 11, 2023

Ok I was able to reproduce. Also tried using PR #259 but got [FAIL. Reason: stdStorage find(StdStorage): No storage use detected for target.] as the error. In both cases I did verify that the data was in slot 0 (i.e. solc isn't optimizing away storage into immutables or anything)

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

No branches or pull requests

2 participants