[Bug]: ParsingError: Type not found struct Checkpoints.Trace208 in Slither Analysis
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 %
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 on
0.10.4and 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
Hey any update on this? Thanks 😊
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.
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.