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

Add labels to call sequence #1314

Merged
merged 2 commits into from
Sep 18, 2024
Merged

Add labels to call sequence #1314

merged 2 commits into from
Sep 18, 2024

Conversation

elopez
Copy link
Member

@elopez elopez commented Sep 17, 2024

hevm already supports the vm.label(address, string) cheatcode, but Echidna has not made use of the labels so far in its output. This adds some basic support when printing call sequences. When available, it will show the corresponding label next to any from/to address, or next to any address arguments.

image

Test contract:

abstract contract Hevm {
    function label(address addr, string calldata label) external virtual;
}

contract C {
    constructor() public {
        Hevm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D).label(
            address(0x20000),
            "hacker"
        );
    }
    bool hacked;
    function hack() public {
        if (msg.sender == address(0x20000)) hacked = true;
    }

    function hack2(address x) public {
        if (msg.sender == address(0x10000) && x == address(0x20000))
            assert(!hacked);
    }
}

hevm already supports the `vm.label(address, string)` cheatcode, but
Echidna has not made use of the labels so far in its output. This adds
some basic support when printing call sequences. When available, it
will show the corresponding label next to any from/to address, or
next to any address arguments.
Copy link
Member

@arcz arcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, just please fix hlint stuff. For the long term we should re-use trace printing from hevm but this depends on ethereum/hevm#496.

@ggrieco-tob ggrieco-tob merged commit 4ee7099 into master Sep 18, 2024
17 checks passed
@ggrieco-tob ggrieco-tob deleted the dev-labels branch September 18, 2024 09:25
@ggrieco-tob ggrieco-tob mentioned this pull request Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants