foundry: Bug: `cast storage` displays wrong values for packed slots
Component
Cast
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge 0.2.0 (64b0e8f 2023-11-15T14:06:05.905353479Z)
What command(s) is the bug in?
cast storage
Operating System
Linux
Describe the bug
Repro example (replace it with your Etherscan API key of Optimism).
Run:
cast storage --rpc-url https://mainnet.optimism.io --etherscan-api-key <YOUR_API_KEY> 0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2
which returns:
| Name | Type | Slot | Offset | Bytes | Value | Contract
|
|---------|---------|------|--------|-------|--------------------------------------------------|-----------------------------------------------|
| _owner | address | 0 | 0 | 20 | 486747459873938072359747357390379788195179410093 | contracts/Create2Deployer.sol:Create2Deployer |
| _paused | bool | 0 | 20 | 1 | 486747459873938072359747357390379788195179410093 | contracts/Create2Deployer.sol:Create2Deployer |
The value of _paused is set to the _owner value, which however should be simply 0 in this case.
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 19 (19 by maintainers)
Commits related to this issue
- Add #6319 test — committed to grandizzy/foundry by grandizzy 4 months ago
- issue 6319: copy raw sliced value as tail in new value to be converted (#7194) * issue 6319: copy raw sliced value as tail in new value to be converted * Add #6319 test — committed to foundry-rs/foundry by grandizzy 4 months ago
The https://github.com/foundry-rs/foundry/pull/6370 PR mentions further downstream improvements in a PR. Adding an example for bool offset calculating values as not 0 or 1
reproduce:
what:
Happy to take this
reviewing asap, sorry forgot about it -.-
I see we don’t actually handle the offset of the Storage entry
https://github.com/foundry-rs/foundry/blob/7769cf01ca951d96167d70bb0ba1d81277b66a19/crates/cast/bin/cmd/storage.rs#L215-L216