Skip to content

[Bug-Candidate]: Slither fails to correctly parse Vyper function parameters in IR #2796

@Subway2023

Description

@Subway2023

Describe the issue:

Slither's parsing of Vyper produces incomplete SlithIR, with function parameters missing (shown in 250907114030.f()). Additionally, it does not support the latest Vyper version (0.4.3); currently, only version 0.3.7 is effectively supported.

Code example to reproduce the issue:

vyper: 0.3.7
@external
@view
def f(_x: Bytes[1024]) -> Bytes[1]:
    return slice(_x, 0, 1)

@external
@view
def g(_x: Bytes[1024]) -> Bytes[1]:
    return slice(_x, 0, 1)

In the SlithIR obtained below, the parameters of the f function are not parsed.

slither attached_public_library_function_accepting_calldata-250907114030.vy --print slithir --compile-force-framework vyper
INFO:Printers:Contract attached_public_library_function_accepting_calldata-250907114030
        Function attached_public_library_function_accepting_calldata-250907114030.f() (*)
                Expression: slice()(_x,0,1)
                IRs:
                        TMP_0(None) = SOLIDITY_CALL slice()(_x,0,1)
                        RETURN TMP_0
        Function attached_public_library_function_accepting_calldata-250907114030.g() (*)
                Expression: slice()(_x,0,1)
                IRs:
                        TMP_1(None) = SOLIDITY_CALL slice()(_x,0,1)
                        RETURN TMP_1
vyper: 0.4.3
Vyper != 0.3.7 support is a best effort and might fail
Traceback (most recent call last):
  File "/root/anaconda3/bin/slither", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/anaconda3/lib/python3.12/site-packages/slither/__main__.py", line 776, in main
    main_impl(all_detector_classes=detectors, all_printer_classes=printers)
  File "/root/anaconda3/lib/python3.12/site-packages/slither/__main__.py", line 882, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/anaconda3/lib/python3.12/site-packages/slither/__main__.py", line 96, in process_all
    compilations = compile_all(target, **vars(args))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/anaconda3/lib/python3.12/site-packages/crytic_compile/crytic_compile.py", line 722, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/anaconda3/lib/python3.12/site-packages/crytic_compile/crytic_compile.py", line 211, in __init__
    self._compile(**kwargs)
  File "/root/anaconda3/lib/python3.12/site-packages/crytic_compile/crytic_compile.py", line 633, in _compile
    self._platform.compile(self, **kwargs)
  File "/root/anaconda3/lib/python3.12/site-packages/crytic_compile/platform/vyper.py", line 101, in compile
    ]["sourceMap"].split(";")
                   ^^^^^
AttributeError: 'dict' object has no attribute 'split'

solc: 0.8.30

library D {
    function f(bytes calldata _x) public pure returns (bytes1) {
        return _x[0];
    }
    function g(bytes memory _x) public pure returns (bytes1) {
        return _x[0];
    }
}

The SlithIR parsed from Solidity below is more complete and includes the function parameters.

slither attached_public_library_function_accepting_calldata.sol.sol --print slithir
INFO:Printers:Contract D
        Function D.f(bytes) (*)
                Expression: _x[0]
                IRs:
                        REF_0(None) -> _x[0]
                        RETURN REF_0
        Function D.g(bytes) (*)
                Expression: _x[0]
                IRs:
                        REF_1(None) -> _x[0]
                        RETURN REF_1

Version:

slither version: 0.11.3

Relevant log output:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-candidateBugs reports that are not yet confirmed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions