echidna
echidna copied to clipboard
Decode solidity panics e.g. aritmetic overflow
Some solidity panics could be decoded and provided a human-readable error message . For example, mError revert 0x4e487b710000000000000000000000000000000000000000000000000000000000000011
becomes mError revert reason: aritmetic overflow
Idk haskell but this code seems relevant: https://github.com/crytic/echidna/blob/79af6a63e65ae491ddad0a3eae05d28685f53042/lib/Echidna/Exec.hs#L35-L43
Reference list of panics: https://soliditydeveloper.com/solidity-0.8
could you post the whole error message? I'm sort of unfamiliar with the codebase so having some trouble finding the source of it @0xalpharush
@ggrieco-tob I think all that needs to happen is to add a string to this Panic
which indicates what the error code maps back to e.g. arithmetic overflow https://github.com/crytic/echidna/blob/8a265c2e3ed2badc1354fd639641438275dfe144/lib/Echidna/Events.hs#L77
@0xalpharush could you include a minimal example of how to reproduce?
test.sol
pragma solidity ^0.8.0;
contract Test {
function test(uint a) external {
uint x = type(uint).max + a;
}
}
contract Tester {
Test target;
constructor() {
target = new Test();
}
function x() external {
try target.test(1) {
} catch {
assert(false);
}
}
}
echidna-test test.sol --contract Tester --test-mode assertion
Analyzing contract: /Users/alpharush/echidna/test.sol:Tester
x(): failed!💥
Call sequence:
x()
Event sequence: Panic(1), merror Revert 0x4e487b710000000000000000000000000000000000000000000000000000000000000011 from: Test
AssertionFailed(..): fuzzing (29284/50000)
we recently updated hevm and now this error is printed slightly better (from the current master):
x(): failed!💥
Call sequence:
x()
Event sequence: Panic(1), merror Revert Panic(17)
AssertionFailed(..): passed! 🎉
Unique instructions: 340
Unique codehashes: 2
Corpus size: 2
Seed: 5902941968390972108
It would still be nice to decode 17 as arithmetic overflow instead of having to google around for what Panic(17) is