Skip to content

”read_storage cannot determine the storage layout of custom type variables within a struct. #2522

Open
@Subway2023

Description

@Subway2023

Describe the issue:

If a structure contains custom types, the read_storage tool cannot determine the storage layout of that struct variable.

Code example to reproduce the issue:

test.py

from slither.tools.read_storage import SlitherReadStorage
srs = SlitherReadStorage([c], 20)
srs.get_all_storage_variables()
srs.get_storage_layout()

error.sol

type MyUint64 is uint64;
contract C {
    struct S {
        MyUint64 y;
        MyUint64 z;
    }
    S s;
}

correct.sol

contract C {
    struct S {
        unit64 y;
        unit64 z;
    }
    S s;
}

Version:

0.10.3

Relevant log output:

When perform test.py for program of error.sol, there is an error

  File "/mnt/sdd1/sbw/slither/slither/tools/read_storage/read_storage.py", line 837, in _all_struct_slots
    info = self.get_storage_slot(
  File "/mnt/sdd1/sbw/slither/slither/tools/read_storage/read_storage.py", line 256, in get_storage_slot
    info, type_to, slot, size, offset = self._find_struct_var_slot(elems, slot, struct_var)
  File "/mnt/sdd1/sbw/slither/slither/tools/read_storage/read_storage.py", line 597, in _find_struct_var_slot
    return info, type_to, slot_as_bytes, size, offset
UnboundLocalError: local variable 'size' referenced before assignment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions