Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
roisindowling opened this issue Sep 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@roisindowling
Copy link

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 roisindowling added the bug-candidate Bugs reports that are not yet confirmed label Sep 19, 2024
@elopez
Copy link
Member

elopez commented Sep 19, 2024

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
Copy link
Author

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
Copy link
Author

roisindowling commented Oct 3, 2024

Hey any update on this? Thanks 😊

@smonicas
Copy link
Contributor

smonicas commented Oct 3, 2024

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 smonicas added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Oct 3, 2024
@smonicas smonicas changed the title [Bug-Candidate]: ParsingError: Type not found struct Checkpoints.Trace208 in Slither Analysis [Bug]: ParsingError: Type not found struct Checkpoints.Trace208 in Slither Analysis Oct 3, 2024
@smonicas
Copy link
Contributor

smonicas commented Oct 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants