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 3 years ago
- Comments: 19 (17 by maintainers)
Commits related to this issue
- Add #6319 test — committed to grandizzy/foundry by grandizzy 3 years 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 3 years ago
- update test to use contract relevant to ticket https://github.com/foundry-rs/foundry/issues/6319 — committed to foundry-rs/foundry by zerosnacks 2 years ago
- chore(`cast`): fix `storage_layout` test due to request timeouts w/ Optimism explorer (#9182) * fix failing test * update test to use contract relevant to ticket https://github.com/foundry-rs/foun... — committed to foundry-rs/foundry by zerosnacks 2 years ago
- chore: resolve merge conflicts for upstream-57bb12e (#693) * fix: respect `--auth` in `cast call` and `cast estimate` (#9120) * fix: respect --auth in cast call and cast estimate * access list ... — committed to matter-labs/foundry-zksync by nbaztec 2 years ago
- chore(`cast`): fix `storage_layout` test due to request timeouts w/ Optimism explorer (#9182) * fix failing test * update test to use contract relevant to ticket https://github.com/foundry-rs/foun... — committed to rplusq/foundry by zerosnacks 2 years 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