-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Take a look to the following example. An auditor wants to use symbolic execution in order to understand when an invariant can fail:
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
contract Counter {
uint256 public number;
function increment() public {
number++;
}
}
contract CounterSymTest is Test {
Counter public counter;
function setUp () public {
counter = new Counter();
}
function prove_isIncrementFeasible() public {
vm.assume(counter.number() != 2);
counter.increment();
assertTrue(!(counter.number() == 2), "number is 2");
}
}However, hevm allows to run either in symbolic mode or test mode but none of them is useful here. Test mode will verify the property, since the concrete state of the Counter program is preserved and it is impossible to force some storage to be symbolic.
Purely symbolic mode will make everything symbolic, even during contract deployment, but here we only want to make the Counter storage symbolic after setUp deployed the contract.
One possible solution is add a cheatcode that allows to make the complete storage (or even specific slots) for a given address symbolic. I'm usually not pushing to add specific cheatcodes, but in this perhaps it makes sense. What do you think?
h/t @GalloDaSballo