foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.33k stars 1.76k forks source link

chisel incorrectly parses the full word from storage when returning uint256 types #9377

Open DrakeEvans opened 11 hours ago

DrakeEvans commented 11 hours ago

Component

Chisel

Have you ensured that all of these are up to date?

What version of Foundry are you on?

chisel 0.2.0 (4817280d96 2024-11-11T17:07:32.412876000Z)

What command(s) is the bug in?

chisel

Operating System

macOS (Apple Silicon)

Describe the bug

When returning the full word from storage for the following code snippet keccak256(abi.encode(uint256(keccak256("AgoraStableSwapStorage.OracleStorage")) - 1)) & ~bytes32(uint256(0xff))

The output is Type: uint256 ├ Hex: 0xa6b316b47a0cd26c1b582ae3dcffbd175283c221c3cb3d1c614e3e47f62a700 ├ Hex (full word): 0xa6b316b47a0cd26c1b582ae3dcffbd175283c221c3cb3d1c614e3e47f62a700 └ Decimal: 4712522199592559686081775781256535485973216673499069812336538043969769219840 You can see that the Hex (full word) only contains 63 characters which is incorrect as words are 256 bits. It should instead read 0x0a6b316b47a0cd26c1b582ae3dcffbd175283c221c3cb3d1c614e3e47f62a700 (missing a 0 in first position