forge-std icon indicating copy to clipboard operation
forge-std copied to clipboard

bug(StdStorage): unable to find bool slot within map struct

Open spicysquid168 opened this issue 4 years ago • 1 comments

Hey guys,

Seems like stdStorage unable to find bool slot within a map struct variable. I debug and found out that the rdata not return hex"1337" if address.staticcall to the bool slot. The whole bytes32 just become 0000000000000000000000000000000000000000000000000000000000000000 as you can see below: telegram-cloud-photo-size-5-6145377720268337323-y

You can reproduce with this contract: https://github.com/spicysquid168/solidity-playground/blob/main/src/TryStdStorageBool.sol Run by forge script ./src/TryStdStorageBool.sol -vvv

Thanks,

spicysquid168 avatar Jun 15 '22 08:06 spicysquid168

Checked on current master (bf647bd).

Minimal case: mapping(address => struct { uint256 num; bool flag }) with depth(1) for the bool.

forge test --match-path test/oss_contrib/BoolMapStruct.t.sol

Both depth(0) (uint) and depth(1) (bool) find() succeed here. Looks fixed since the original report.

If you still hit this on a current pin, a failing test against master would help. Otherwise this can probably close.

Yonkoo11 avatar Jul 11 '26 21:07 Yonkoo11