Skip to content

Add labels to call sequence#1314

Merged
gustavo-grieco merged 2 commits intomasterfrom
dev-labels
Sep 18, 2024
Merged

Add labels to call sequence#1314
gustavo-grieco merged 2 commits intomasterfrom
dev-labels

Conversation

@elopez
Copy link
Copy Markdown
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
Copy Markdown
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 argotorg/hevm#496.

@gustavo-grieco gustavo-grieco merged commit 4ee7099 into master Sep 18, 2024
@gustavo-grieco gustavo-grieco deleted the dev-labels branch September 18, 2024 09:25
datradito pushed a commit to datradito/echidna-mcp that referenced this pull request Dec 29, 2025
* Add labels to call sequence

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.

* Fix hlint warnings
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