slither icon indicating copy to clipboard operation
slither copied to clipboard

[Bug]: ParsingError: Type not found struct Checkpoints.Trace208 in Slither Analysis

Open roisindowling opened this issue 1 year ago • 6 comments

Describe the issue:

When running Slither on our smart contracts, we encounter a ParsingError indicating that the type Checkpoints.Trace208 cannot be found. This prevents Slither from running as expected. Checkpoints.Trace208 is defined in the code and slither was working fine on smart contracts that were using Checkpoints.Trace208 until we added some new smart contracts and increases the size of our repo.

Code example to reproduce the issue:

https://github.com/vechain/vebetterdao-contracts

Version:

0.10.3

Relevant log output:

roisindowling@Roisins-MacBook-Pro vebetterdao-contracts % slither .
'npx hardhat clean' running (wd: /Users/roisindowling/Desktop/Code/vebetterdao-contracts)
'npx hardhat clean --global' running (wd: /Users/roisindowling/Desktop/Code/vebetterdao-contracts)
'npx hardhat compile --force' running (wd: /Users/roisindowling/Desktop/Code/vebetterdao-contracts)
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/__main__.py", line 888, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/__main__.py", line 113, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/slither.py", line 202, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/slither.py", line 211, in _init_parsing_and_analyses
    raise e
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/slither.py", line 207, in _init_parsing_and_analyses
    parser.parse_contracts()
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 579, in parse_contracts
    self._analyze_second_part(contracts_to_be_analyzed, libraries)
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 667, in _analyze_second_part
    self._analyze_struct_events(contract)
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 740, in _analyze_struct_events
    contract.analyze_structs()
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/declarations/contract.py", line 748, in analyze_structs
    self._analyze_struct(struct)
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/declarations/contract.py", line 743, in _analyze_struct
    struct.analyze()
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/declarations/structure_contract.py", line 55, in analyze
    elem_parser.analyze(self._contract_parser)
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/variables/variable_declaration.py", line 212, in analyze
    self._variable.type = parse_type(self._elem_to_parse, caller_context)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 453, in parse_type
    mappingTo = parse_type(t["valueType"], next_context)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 380, in parse_type
    type_found = _find_from_type_name(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/slither-analyzer/0.10.3_2/libexec/lib/python3.12/site-packages/slither/solc_parsing/solidity_types/type_parsing.py", line 194, in _find_from_type_name
    raise ParsingError("Type not found " + str(name))
slither.solc_parsing.exceptions.ParsingError: Type not found struct Checkpoints.Trace208
ERROR:root:Error:
ERROR:root:Type not found struct Checkpoints.Trace208
ERROR:root:Please report an issue to https://github.com/crytic/slither/issues
roisindowling@Roisins-MacBook-Pro vebetterdao-contracts %

roisindowling avatar Sep 19 '24 13:09 roisindowling

Hi, can you please confirm if this is an issue on the latest version? I see you are using an older Slither release. Thanks!

elopez avatar Sep 19 '24 13:09 elopez

Checked on 0.10.4 and same issue

Hi, can you please confirm if this is an issue on the latest version? I see you are using an older Slither release. Thanks!

Checked with version 0.10.4 and same issue

roisindowling avatar Sep 19 '24 14:09 roisindowling

Hey any update on this? Thanks 😊

roisindowling avatar Oct 03 '24 12:10 roisindowling

As a temporary fix just to make slither works rename this Checkpoints interface to something else. The issue is the same that PR #2167 was trying to fix.

smonicas avatar Oct 03 '24 12:10 smonicas

Leaving this as reference for the future. When we are adding the exported symbols of an imported file here what happens is that the Checkpoints interface symbol is also imported. Then here the scope.contracts["Checkpoints"] will contain the interface instead of the Checkpoint OZ contract because is the last to be written and the type won't be found.

smonicas avatar Oct 03 '24 16:10 smonicas