Description
Impact
I'd like to report an issue I'm running into when using Echidna with HEVM
When a precompile is the target to a call, HEVM reverts, even when Echidna should not be calling the precompile, but it's just getting the precompile size
POC
The template uses Chimera so you can run any Fuzzer / FV tool
https://github.com/Recon-Fuzz/hevm-precompile-crash-unexpected
Run with Foundry -> Reverts as the compiler protects us from calling the precompile
Run with Echidna -> Crashes HEVM even though I would expect the compiler to prevent the call to the precompile
Call 1
function doACall() public {
uint256 size = address(0x0a).code.length;
size + 1;
}
The crash here is expected, we're calling the precompile directly and it's unimplemented
Call 2
function doACall() public {
uint256 res = IERC20(address(0x0a)).balanceOf(address(this));
res + 1;
}
The crash here is unexpected, shouldn't the compiler inserted check cause a revert before we call the precompile?
Call 3
function doACall() public {
uint256 size = address(0x0a).code.length;
size + 1;
}
Surprisingly, the call here doesn't revert
Conclusion
Maybe I'm missing something, but I would expect the compiler to prevent Echidna from calling the precompile hence prevent the crash, however, that's not the case
What would you advise to allow me to use echidna with a set of contracts that allow arbitrary inputs and calls?