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

Implement symbolicCallData() and assumeBytesLength(bytes,uint256) cheatcodes #301

Open
palinatolmach opened this issue Jan 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@palinatolmach
Copy link
Collaborator

palinatolmach commented Jan 20, 2024

Implement the following cheatcodes that have been factored out from #223:

    // Make calldata symbolic
    function symbolicCalldata() external;
    // Add assumptions about the length of symbolic calldata
    function assumeBytesLength(bytes calldata,uint256) external;
    rule ( selector ( "symbolicCallData()" )                       => 2368578420 )
    rule ( selector ( "assumeBytesLength(bytes,uint256)" )         => 1696199529 )

symbolicCallData — Changes the current calldata after a function selector to a symbolic variable.

function symbolicCallData() external;
    rule [foundry.call.symbolicCallData]:
         <k> #call_foundry SELECTOR _ARGS => . ... </k>
         <callData> CD:Bytes => #range( CD, 0, 4) +Bytes ?CALLDATA </callData>
      requires SELECTOR ==Int selector ( "symbolicCallData()" )

assumeBytesLength — Adds assumptions about the length of a symbolic bytes array.

function assumeBytesLength(bytes, uint256) external;
    rule [foundry.call.assumeBytesArray]:
         <k> #call_foundry SELECTOR ARGS => #assume (lengthBytes(#range(ARGS, 0, 32)) ==Int #asWord(#range(ARGS, 32, 32))) ... </k>
      requires SELECTOR ==Int selector ( "assumeBytesLength(bytes,uint256)" )
@yale-vinson yale-vinson added the enhancement New feature or request label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants