crytic / slither

Static Analyzer for Solidity and Vyper
https://blog.trailofbits.com/2018/10/19/slither-a-solidity-static-analysis-framework/
GNU Affero General Public License v3.0
5.27k stars 964 forks source link

[Bug-Candidate]: ParsingError: Type not found struct Checkpoints.Trace208 in Slither Analysis #2562

Open roisindowling opened 1 week ago

roisindowling commented 1 week ago

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 %
elopez commented 1 week ago

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

roisindowling commented 1 week ago

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