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

fix(cast/bin) ; correcting the offset of Storage #6370

Merged
merged 4 commits into from
Dec 21, 2023

Conversation

DoTheBestToGetTheBest
Copy link
Contributor

ref #6319

i still didn't get how to make it 0 or 1, actually what i'm having running the command

cast storage --rpc-url https://mainnet.optimism.io --etherscan-api-key <YOUR_API_KEY> 0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2

is 253 for the _paused variable, which should return 0 in our case, i'am totally doing bad thing on how the bytes are being interpreted

crates/cast/bin/cmd/storage.rs Outdated Show resolved Hide resolved
crates/cast/bin/cmd/storage.rs Outdated Show resolved Hide resolved
crates/cast/bin/cmd/storage.rs Outdated Show resolved Hide resolved
@DoTheBestToGetTheBest
Copy link
Contributor Author

_paused | bool | 0 | 20 | 1 | 0 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/Create2Deployer.sol:Create2Deployer |

Ty lot lot @mattsse you're a genius !!!

crates/cast/bin/cmd/storage.rs Outdated Show resolved Hide resolved
@mattsse
Copy link
Member

mattsse commented Dec 4, 2023

@DaniPopes mind giving this a review, there's perhaps a better way to get the range (offset, num bytes)

cast storage --rpc-url https://mainnet.optimism.io --etherscan-api-key T2KRFNUMEN4U8XZQ87YCN82I3AF6XE21NF 0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2
| Name    | Type    | Slot | Offset | Bytes | Value                                            | Hex Value                                                          | Contract                                      |
|---------|---------|------|--------|-------|--------------------------------------------------|--------------------------------------------------------------------|-----------------------------------------------|
| _owner  | address | 0    | 0      | 20    | 486747459873938072359747357390379788195179410093 | 0x000000000000000000000000554282cf65b42fc8fddc6041eb24ce5e8a0632ad | contracts/Create2Deployer.sol:Create2Deployer |
| _paused | bool    | 0    | 20     | 1     | 0                                                | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/Create2Deployer.sol:Create2Deployer |

@pcaversaccio we have value, hex value, I think we don't need an extra column with the raw hex value of the slot?

but I guess value formatting could use some work?
@DaniPopes can we coerce the value somehow

@pcaversaccio
Copy link
Contributor

@pcaversaccio we have value, hex value, I think we don't need an extra column with the raw hex value of the slot?

but I guess value formatting could use some work?

Agreed - having the slot value as a normal number is enough IMO. Re the second comment, fully agree. For example, the value of an address should be a 20-byte hex value itself IMO, while for uint and int types you go for numbers. Generally, value should represent the format, people would expect from the type definition.

@pcaversaccio
Copy link
Contributor

pinging @DaniPopes @mattsse

@Evalir
Copy link
Member

Evalir commented Dec 18, 2023

will prio this myself this week @pcaversaccio

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on this—I think we could try and coerce the value to its corresponding type if it's not a complex type, but I feel this would cause more trouble than it's worth for the more complex cases.

I also believe that we should keep the hex value column coming from the above, as we want the hex representation for things like strings, addresses and etc.

I say let's merge and improve downstream in another PR

@Evalir Evalir merged commit c312c0d into foundry-rs:master Dec 21, 2023
19 checks passed
@plotchy
Copy link
Contributor

plotchy commented Jan 21, 2024

Adding an example for bool offset calculating values as not 0 or 1

cast storage --rpc-url https://mainnet.optimism.io --etherscan-api-key T2KRFNUMEN4U8XZQ87YCN82I3AF6XE21NF 0xB67c152E69217b5aCB85A2e19dF13423351b0E27

isUserCancelEnabled, allowPublicKeeper, allowUserCloseOnly

| Name                          | Type                                                            | Slot | Offset | Bytes | Value                                             | Hex Value                                                          | Contract                                           |
|-------------------------------|-----------------------------------------------------------------|------|--------|-------|---------------------------------------------------|--------------------------------------------------------------------|----------------------------------------------------|
| gov                           | address                                                         | 0    | 0      | 20    | 1352965747418285184211909460723571462248744342032 | 0x000000000000000000000000ecfd15165d994c2766fbe0d6bacdc2e8dedfd210 | contracts/perp/PositionManager.sol:PositionManager |
| _status                       | uint256                                                         | 1    | 0      | 32    | 1                                                 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager |
| admin                         | address                                                         | 2    | 0      | 20    | 1352965747418285184211909460723571462248744342032 | 0x000000000000000000000000ecfd15165d994c2766fbe0d6bacdc2e8dedfd210 | contracts/perp/PositionManager.sol:PositionManager |
| feeCalculator                 | address                                                         | 3    | 0      | 20    | 1297482016264593221714872710065075000476194625473 | 0x000000000000000000000000e3451b170806aab3e24b5cd03a331c1ccdb4d7c1 | contracts/perp/PositionManager.sol:PositionManager |
| oracle                        | address                                                         | 4    | 0      | 20    | 241116142622541106669066767052022920958068430970  | 0x0000000000000000000000002a3c0592dcb58accd346ccee2bb46e3fb744987a | contracts/perp/PositionManager.sol:PositionManager |
| referralStorage               | address                                                         | 5    | 0      | 20    | 1224602325975115131568536406232630666650384091454 | 0x000000000000000000000000d6811146780d50d24bd3475acb23c2118034493e | contracts/perp/PositionManager.sol:PositionManager |
| minExecutionFee               | uint256                                                         | 6    | 0      | 32    | 20000                                             | 0x0000000000000000000000000000000000000000000000000000000000004e20 | contracts/perp/PositionManager.sol:PositionManager |
| minBlockDelayKeeper           | uint256                                                         | 7    | 0      | 32    | 0                                                 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager |
| minTimeExecuteDelayPublic     | uint256                                                         | 8    | 0      | 32    | 180                                               | 0x00000000000000000000000000000000000000000000000000000000000000b4 | contracts/perp/PositionManager.sol:PositionManager |
| minTimeCancelDelayPublic      | uint256                                                         | 9    | 0      | 32    | 180                                               | 0x00000000000000000000000000000000000000000000000000000000000000b4 | contracts/perp/PositionManager.sol:PositionManager |
| maxTimeDelay                  | uint256                                                         | 10   | 0      | 32    | 1800                                              | 0x0000000000000000000000000000000000000000000000000000000000000708 | contracts/perp/PositionManager.sol:PositionManager |
| isUserExecuteEnabled          | bool                                                            | 11   | 0      | 1     | 1                                                 | 0x0000000000000000000000000000000000000000000000000000000000000001 | contracts/perp/PositionManager.sol:PositionManager |
| isUserCancelEnabled           | bool                                                            | 11   | 1      | 1     | 256                                               | 0x0000000000000000000000000000000000000000000000000000000000000100 | contracts/perp/PositionManager.sol:PositionManager |
| allowPublicKeeper             | bool                                                            | 11   | 2      | 1     | 0                                                 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager |
| allowUserCloseOnly            | bool                                                            | 11   | 3      | 1     | 16777216                                          | 0x0000000000000000000000000000000000000000000000000000000001000000 | contracts/perp/PositionManager.sol:PositionManager |
| openPositionRequestKeys       | bytes32[]                                                       | 12   | 0      | 32    | 27359                                             | 0x0000000000000000000000000000000000000000000000000000000000006adf | contracts/perp/PositionManager.sol:PositionManager |
| closePositionRequestKeys      | bytes32[]                                                       | 13   | 0      | 32    | 16981                                             | 0x0000000000000000000000000000000000000000000000000000000000004255 | contracts/perp/PositionManager.sol:PositionManager |
| openPositionRequestKeysStart  | uint256                                                         | 14   | 0      | 32    | 27359                                             | 0x0000000000000000000000000000000000000000000000000000000000006adf | contracts/perp/PositionManager.sol:PositionManager |
| closePositionRequestKeysStart | uint256                                                         | 15   | 0      | 32    | 16981                                             | 0x0000000000000000000000000000000000000000000000000000000000004255 | contracts/perp/PositionManager.sol:PositionManager |
| isPositionKeeper              | mapping(address => bool)                                        | 16   | 0      | 32    | 0                                                 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager |
| openPositionsIndex            | mapping(address => uint256)                                     | 17   | 0      | 32    | 0                                                 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager |
| openPositionRequests          | mapping(bytes32 => struct PositionManager.OpenPositionRequest)  | 18   | 0      | 32    | 0                                                 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager |
| closePositionsIndex           | mapping(address => uint256)                                     | 19   | 0      | 32    | 0                                                 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager |
| closePositionRequests         | mapping(bytes32 => struct PositionManager.ClosePositionRequest) | 20   | 0      | 32    | 0                                                 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager |
| managers                      | mapping(address => bool)                                        | 21   | 0      | 32    | 0                                                 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager |
| approvedManagers              | mapping(address => mapping(address => bool))                    | 22   | 0      | 32    | 0                                                 | 0x0000000000000000000000000000000000000000000000000000000000000000 | contracts/perp/PositionManager.sol:PositionManager |

@mattsse
Copy link
Member

mattsse commented Jan 21, 2024

is this an issue?
please unpack, consider opening an issue

@pcaversaccio
Copy link
Contributor

is this an issue? please unpack, consider opening an issue

See my open issue #6319. @plotchy please comment there accordingly

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

Successfully merging this pull request may close these issues.

6 participants