Skip to content

slither-read-storage: add support for constant|immutable variables  #1614

Open
@backulinivan

Description

@backulinivan

Describe the desired feature

It would be nice if slither-read-storage was able to output values of constant and immutable variables. This would save a lot of time by not having to look up these variables on scanners. Please see minimal code and relevant and desired log outputs.

Version

0.9.1

Minimal code to reproduce the issue

pragma solidity ^0.8.0;

contract TestConstant {
    bytes32 public constant BYTES =
        0x1111111111111111111111111111111111111111111111111111111111111111;
    address public immutable someAddress;

    uint256 public someUint256 = 3;

    constructor() {
        someAddress = 0x2222222222222222222222222222222222222222;
    }
}

then slither-read-storage TestConstant.sol --table

Relevant log output

+-------------+-------------+------+------+--------+-------+
|     name    | type_string | slot | size | offset | value |
+-------------+-------------+------+------+--------+-------+
| someUint256 |   uint256   |  0   | 256  |   0    |  None |
+-------------+-------------+------+------+--------+-------+

Suggestion for desired output

Variables' values are contracted.

+-------------+-------------+--------+------+----------+-------+
|     name    | type_string |  slot  | size |  offset  | value |
+-------------+-------------+--------+------+----------+-------+
| BYTES       |   bytes32   |  n/a   | n/a  |   n/a    |  0x1  |
| someAddress |   address   |  n/a   | n/a  |   n/a    |  0x2  |
| someUint256 |   uint256   |  0     | 256  |   0      |  None |
+-------------+-------------+--------+------+----------+-------+

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions