Summary
Implement the vm.getStorageSlots cheatcode introduced in foundry-rs/foundry#11537.
Cheatcode Description
vm.getStorageSlots returns the array of storage slots occupied by a named variable in a target contract.
Function signature:
function getStorageSlots(address target, string calldata variableName) external view returns (uint256[] memory slots);
Behavior:
For simple (value-type) variables: returns the single base slot.
For fixed-size arrays: returns consecutive slots starting from the base slot.
For short bytes/string (data fits in 32 bytes): returns the single base slot.
For long bytes/string: returns the base slot plus additional data slots, where data slot positions are computed as keccak256(baseSlot) + i.
Explicitly rejects mappings and dynamic arrays (these cannot be fully enumerated statically).
Requires: the target contract must have been compiled with --extra-output storageLayout; otherwise the cheatcode should revert/error.
Implementation Notes for Kontrol
This cheatcode depends on storage layout metadata (variable name → base slot + encoding type), which is artifact data produced by the Solidity compiler. The K rewrite rule for getStorageSlots would need access to the storage layout of the contract at address target. This information is not part of the standard KEVM state. One approach is to inject the storage layout as a side-loaded map, populated from the compiled artifact at test setup time.
Summary
Implement the
vm.getStorageSlotscheatcode introduced in foundry-rs/foundry#11537.Cheatcode Description
vm.getStorageSlotsreturns the array of storage slots occupied by a named variable in a target contract.Function signature:
Behavior:
For simple (value-type) variables: returns the single base slot.
For fixed-size arrays: returns consecutive slots starting from the base slot.
For short bytes/string (data fits in 32 bytes): returns the single base slot.
For long bytes/string: returns the base slot plus additional data slots, where data slot positions are computed as keccak256(baseSlot) + i.
Explicitly rejects mappings and dynamic arrays (these cannot be fully enumerated statically).
Requires: the target contract must have been compiled with --extra-output storageLayout; otherwise the cheatcode should revert/error.
Implementation Notes for Kontrol
This cheatcode depends on storage layout metadata (variable name → base slot + encoding type), which is artifact data produced by the Solidity compiler. The K rewrite rule for
getStorageSlotswould need access to the storage layout of the contract at address target. This information is not part of the standard KEVM state. One approach is to inject the storage layout as a side-loaded map, populated from the compiled artifact at test setup time.