[Bug-Candidate]: ParsingError: Missing function Variable not found:
Describe the issue:
Slither breaks due to a parsing error for Uniswap's UniversalRouter. Contract address: 0x66a9893cc07d91d95644aedd05d03f95e1dba8af GitHub repository: https://github.com/Uniswap/universal-router
Code example to reproduce the issue:
Slither gets stuck until forced interruption. The same happens when running slither in this contract's hardhat/foundry project folder.
slither 0x66a9893cc07d91d95644aedd05d03f95e1dba8af --etherscan-apikey <KEY>
ERROR:ContractSolcParsing:Missing function Variable not found: _getLocker() (context Dispatcher src/pkgs/universal-router/contracts/base/Dispatcher.sol#22-300 (1 - 2))
ERROR:ContractSolcParsing:Missing params 'unlock()' src/pkgs/universal-router/contracts/UniversalRouter.sol#14-67 (1 - 2)
cryptic-compile seems to run without issues:
crytic-compile <universal-router-project>
INFO:CryticCompile:'forge clean' running (wd: /home/universal-router)
INFO:CryticCompile:'forge config --json' running
INFO:CryticCompile:'forge build --build-info --skip */test/** */script/** --force' running (wd: /home/universal-router)
Version:
0.11.3
Relevant log output:
Traceback (most recent call last):
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/declarations/contract.py", line 443, in analyze_content_functions
function_parser.analyze_content()
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/declarations/function.py", line 340, in analyze_content
node_parser.analyze_expressions(self)
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/cfg/node.py", line 37, in analyze_expressions
expression = parse_expression(self._unparsed_expression, caller_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 345, in parse_expression
return parse_call(expression, caller_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 154, in parse_call
called = parse_expression(expression["expression"], caller_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/expressions/expression_parsing.py", line 512, in parse_expression
var, was_created = find_variable(value, caller_context, referenced_declaration)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/expressions/find_variable.py", line 509, in find_variable
raise VariableNotFound(
slither.solc_parsing.exceptions.VariableNotFound: Variable not found: _getLocker() (context Dispatcher src/pkgs/universal-router/contracts/base/Dispatcher.sol#22-300 (1 - 2))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/__main__.py", line 882, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/__main__.py", line 107, in process_all
) = process_single(compilation, args, detector_classes, printer_classes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/__main__.py", line 80, in process_single
slither = Slither(target, ast_format=ast, **vars(args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/slither.py", line 202, in __init__
self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/slither.py", line 211, in _init_parsing_and_analyses
raise e
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/slither.py", line 207, in _init_parsing_and_analyses
parser.parse_contracts()
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 583, in parse_contracts
self._analyze_third_part(contracts_to_be_analyzed, libraries)
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 694, in _analyze_third_part
self._analyze_variables_modifiers_functions(contract)
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 801, in _analyze_variables_modifiers_functions
contract.analyze_content_functions()
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/declarations/contract.py", line 445, in analyze_content_functions
self.log_incorrect_parsing(f"Missing function {e}")
File "/home/mokita/.cache/pypoetry/virtualenvs/admin-check-iU3Dt9fh-py3.12/lib/python3.12/site-packages/slither/solc_parsing/declarations/contract.py", line 429, in log_incorrect_parsing
raise ParsingError(error)
slither.solc_parsing.exceptions.ParsingError: Missing function Variable not found: _getLocker() (context Dispatcher src/pkgs/universal-router/contracts/base/Dispatcher.sol#22-300 (1 - 2))
ERROR:root:Error:
ERROR:root:Missing function Variable not found: _getLocker() (context Dispatcher src/pkgs/universal-router/contracts/base/Dispatcher.sol#22-300 (1 - 2))
ERROR:root:Please report an issue to https://github.com/crytic/slither/issues
Leaving the cause as reference. This is due to the Dispatcher contract having the incorrect Lock contract set in the inheritance. Instead of the correct Lock contract it's set to the Lock library universal-router/lib/v4-periphery/lib/v4-core/src/libraries/Lock.sol. The target retrieved is the incorrect Lock. https://github.com/crytic/slither/blob/dac531400a2574b8acfcf11967375727a08f49ad/slither/solc_parsing/slither_compilation_unit_solc.py#L484-L486
I see, thx for the insight @smonicas! Do you have any idea/insight on how to move past this?
At the momoent you can run slither by ranaming the Lock contract to something else