acuarica / evm

A Symbolic Ethereum Virtual Machine (EVM) bytecode interpreter, parser and decompiler, along with several other utils for programmatically extracting information from EVM bytecode.
https://acuarica.github.io/evm/
MIT License
46 stars 5 forks source link

Support to decode `revert` selector name #104

Closed acuarica closed 4 months ago

acuarica commented 4 months ago

This PR includes support to display revert selector names, i.e., custom errors as described in https://docs.soliditylang.org/en/latest/control-structures.html#revert.

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;

contract VendingMachine {
    address owner;
    error Unauthorized();
    function withdraw() public {
        if (msg.sender != owner)
            revert Unauthorized();

        payable(msg.sender).transfer(address(this).balance);
    }
}

It solves this by attaching to each Revert Stmt a signature declaration object to be patched after executing is done. Moreover, it includes support to fetch and patch revert signatures in 4byte and 4bytedb.

acuarica commented 4 months ago

Fixes #2.