-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(cheatcodes): support access lists and storage slot state manipulation #10101
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
Comments
hey @0xDiscotech so for making storage slots cold / warm is pretty straightforward, to be inline with the other cheatcodes I propose following sigs (have an impl for it in #10112) /// Utility cheatcode to mark specific storage slot as warm, simulating a prior read.
function warm(address target, bytes32 slot) external;
/// Utility cheatcode to mark specific storage slot as cold, simulating no prior read.
function cold(address target, bytes32 slot) external; could you please expand on how the |
Hey @grandizzy! The Regarding the
Those cheatcodes would be very useful for E2E or integration tests. What do you think? |
I think this makes sense, I'd suggest though an |
I really like that approach 👍 |
Doesn't foundry already support a cheatcode for making slots cold again? foundry/crates/cheatcodes/src/evm.rs Lines 577 to 586 in f12f8a2
|
Yep, but that's for all slots / entire account. The new cheatcodes are for specific slots |
Hey @grandizzy! In addition, I've checked this tests and I found that the storage keys are always an empty array, what could lead to an uncovered branch. |
hey @0xDiscotech will check the tests for accessList asap (btw, they should be performed with isolate true to have effect). Re warm/cool slot, the tests I added shows different gas (614 when warm slot vs 2614 when making the slot cool, see https://github.com/foundry-rs/foundry/pull/10112/files#diff-d0ed72756e57739d550012e9ec8643e5a156a9bf7db6ae0542537d4259db652eR18) , mind to explain what's expected? Thanks |
@grandizzy Yes, I tried it on |
Describe the feature you would like:
I propose adding the following cheatcodes to Foundry to facilitate accurate testing of contracts that utilize access lists and logic related to cold or warm storage slots:
vm.accessList
: Enables the inclusion of access lists in subsequent test calls, facilitating accurate testing of contracts utilizing EIP-2930 access lists.vm.makeStorageWarm
: Marks a specific storage slot as warm, simulating a prior read.vm.makeStorageCold
: Marks a specific storage slot as cold, simulating no prior read.Motivation:
Currently, Foundry lacks support for specifying access lists and manipulating storage slot states for testing purposes. This limitation makes it challenging to thoroughly test contract functionalities involving access lists and storage slot access patterns, often requiring complex workarounds that can compromise test quality.
Additional context:
EIP-2930: Optional access lists
Example of a project currently adding access list functionalities to its codebase:
Optimism access list logic on smart contracts
Optimism Design Docs: Add interop access list
Optimism Specs: Interop access-list spec and RPC
The text was updated successfully, but these errors were encountered: