Skip to content

[Bug]: Solidity: _grantRole and grantRole share one node id, so one function vanishes and its calls go to the other #5057

Open

Description

@rohit-jsfreaky

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

In Solidity, _grantRole(bytes32,address) and grantRole(bytes32,address) in the same contract get ONE node id, because the id drops the leading _. One of the two functions disappears from the graph, and the calls made inside it are credited to its twin. So the graph shows calls the function never makes, and calls to the hidden one link nowhere.

OpenZeppelin uses this _name / name pattern everywhere. In OpenZeppelin Contracts v5.4.0 there are 38 such merged pairs. Compared with the solc 0.8.28 AST, they cause 104 wrong calls edges and 158 missed ones. (C# had the same problem, fixed in #4415.)

Steps to reproduce

AccessControl.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract AccessControl {
    event RoleGranted(bytes32 role, address account);
    function hasRole(bytes32 role, address account) public view returns (bool) { return false; }
    function grantRole(bytes32 role, address account) public { _grantRole(role, account); }
    function _grantRole(bytes32 role, address account) internal returns (bool) {
        if (hasRole(role, account)) return false;
        emit RoleGranted(role, account);
        return true;
    }
}

Admin.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {AccessControl} from "./AccessControl.sol";
contract Admin is AccessControl {
    function bootstrap(address a) external { _grantRole(0, a); }
}

Then graphify update .

Error output or graph output

grantRole() -> hasRole()        (wrong: _grantRole makes this call)
grantRole() -> RoleGranted      (wrong: _grantRole emits it)

_grantRole has no node, and bootstrap() has no edge. Expected:

grantRole()  -> _grantRole()
_grantRole() -> hasRole()
_grantRole() -> RoleGranted
bootstrap()  -> _grantRole()

Graphify version

0.9.103

Operating System

Windows

Python Version

3.12

Installation Method

uv tool install (recommended)

Activity

  1. github-actions commented on Nov 6, 2026

    @github-actions

    Thanks for opening this issue, @rohit-jsfreaky. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions