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]: AssertionError post solc compilation #1932

Closed
potato-cat69 opened this issue May 22, 2023 · 4 comments
Closed

[Bug]: AssertionError post solc compilation #1932

potato-cat69 opened this issue May 22, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@potato-cat69
Copy link

Describe the issue:

Post solc compilation AssertionError

Code example to reproduce the issue:

It's quite a large codebase which is private for now. If I could get some info about the root cause of the error I can try commenting out code which might be triggering the AssertionError to figure out the offending lines and make a minimal example to reproduce the bug

Version:

0.9.3

Relevant log output:

Traceback (most recent call last):
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/__main__.py", line 837, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/__main__.py", line 101, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/__main__.py", line 79, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/slither.py", line 135, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/slither.py", line 155, in _init_parsing_and_analyses
    raise e
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/slither.py", line 151, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 528, in analyze_contracts
    self._convert_to_slithir()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 739, in _convert_to_slithir
    func.generate_slithir_and_analyze()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/core/declarations/function.py", line 1761, in generate_slithir_and_analyze
    node.slithir_generation()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/core/cfg/node.py", line 681, in slithir_generation
    self._find_read_write_call()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/core/cfg/node.py", line 879, in _find_read_write_call
    assert isinstance(ir.function, Function)
AssertionError
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/__main__.py", line 837, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/__main__.py", line 101, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/__main__.py", line 79, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/slither.py", line 135, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/slither.py", line 155, in _init_parsing_and_analyses
    raise e
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/slither.py", line 151, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 528, in analyze_contracts
    self._convert_to_slithir()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 739, in _convert_to_slithir
    func.generate_slithir_and_analyze()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/core/declarations/function.py", line 1761, in generate_slithir_and_analyze
    node.slithir_generation()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/core/cfg/node.py", line 681, in slithir_generation
    self._find_read_write_call()
  File "/home/yangwu/.local/lib/python3.10/site-packages/slither/core/cfg/node.py", line 879, in _find_read_write_call
    assert isinstance(ir.function, Function)
AssertionError
@potato-cat69 potato-cat69 added the bug-candidate Bugs reports that are not yet confirmed label May 22, 2023
@potato-cat69 potato-cat69 changed the title [Bug-Candidate]: [Bug-Candidate]: AssertionError post solc compilation May 22, 2023
@smonicas
Copy link
Collaborator

If you use slither from dev branch you should get more context on where it failed now that #1873 is merged. Take a look at #1622 and see if it's failing for the same reason.

@potato-cat69
Copy link
Author

Here's the traceback. If more context is needed please let us know an account to give access to our repo. Thanks!

ERROR:SlitherSolcParsing:
Failed to generate IR for Collectionstaker.initializeTimeWeightedContributionRewardProgram. Please open an issue https://github.com/crytic/slither/issues.
Collectionstaker.initializeTimeWeightedContributionRewardProgram (contracts/vaults/Collectionstaker.sol#274-286):
        encodedParams = abi.encode(rewardParams,PrivilegedAddresses(vault,msg.sender))
        rewardProgram.initialize(encodedParams)
        TransferLib.batchSafeTransferERC20From(rewardParams.rewardTokens,msg.sender,address(rewardProgram))
        RewardProgramCreated(timeWeightedContributionRewardProgramLogic,rewardProgram,encodedParams)
Traceback (most recent call last):
  File "/home/yangwu/gomu/slither/slither/__main__.py", line 810, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/yangwu/gomu/slither/slither/__main__.py", line 101, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/yangwu/gomu/slither/slither/__main__.py", line 79, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/yangwu/gomu/slither/slither/slither.py", line 135, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/yangwu/gomu/slither/slither/slither.py", line 155, in _init_parsing_and_analyses
    raise e
  File "/home/yangwu/gomu/slither/slither/slither.py", line 151, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/home/yangwu/gomu/slither/slither/solc_parsing/slither_compilation_unit_solc.py", line 525, in analyze_contracts
    self._convert_to_slithir()
  File "/home/yangwu/gomu/slither/slither/solc_parsing/slither_compilation_unit_solc.py", line 751, in _convert_to_slithir
    raise e
  File "/home/yangwu/gomu/slither/slither/solc_parsing/slither_compilation_unit_solc.py", line 736, in _convert_to_slithir
    func.generate_slithir_and_analyze()
  File "/home/yangwu/gomu/slither/slither/core/declarations/function.py", line 1760, in generate_slithir_and_analyze
    node.slithir_generation()
  File "/home/yangwu/gomu/slither/slither/core/cfg/node.py", line 708, in slithir_generation
    self._find_read_write_call()
  File "/home/yangwu/gomu/slither/slither/core/cfg/node.py", line 916, in _find_read_write_call
    assert isinstance(ir.function, Function)
AssertionError
ERROR:root:Error in ../vaults-internal/
ERROR:root:Traceback (most recent call last):
  File "/home/yangwu/gomu/slither/slither/__main__.py", line 810, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/home/yangwu/gomu/slither/slither/__main__.py", line 101, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/home/yangwu/gomu/slither/slither/__main__.py", line 79, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/home/yangwu/gomu/slither/slither/slither.py", line 135, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/home/yangwu/gomu/slither/slither/slither.py", line 155, in _init_parsing_and_analyses
    raise e
  File "/home/yangwu/gomu/slither/slither/slither.py", line 151, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/home/yangwu/gomu/slither/slither/solc_parsing/slither_compilation_unit_solc.py", line 525, in analyze_contracts
    self._convert_to_slithir()
  File "/home/yangwu/gomu/slither/slither/solc_parsing/slither_compilation_unit_solc.py", line 751, in _convert_to_slithir
    raise e
  File "/home/yangwu/gomu/slither/slither/solc_parsing/slither_compilation_unit_solc.py", line 736, in _convert_to_slithir
    func.generate_slithir_and_analyze()
  File "/home/yangwu/gomu/slither/slither/core/declarations/function.py", line 1760, in generate_slithir_and_analyze
    node.slithir_generation()
  File "/home/yangwu/gomu/slither/slither/core/cfg/node.py", line 708, in slithir_generation
    self._find_read_write_call()
  File "/home/yangwu/gomu/slither/slither/core/cfg/node.py", line 916, in _find_read_write_call
    assert isinstance(ir.function, Function)
AssertionError

@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Jun 1, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: AssertionError post solc compilation [Bug]: AssertionError post solc compilation Jun 1, 2023
@0xalpharush
Copy link
Contributor

What type are PrivilegedAddresses and RewardProgramCreated? Off the top of my head, potential workarounds would be to remove any import alias import A as B and make sure that none the identifiers (names of contracts, top level functions, struct, events) are duplicated since sometimes these cases are handled incorrectly.

@0xalpharush
Copy link
Contributor

Tracking in #1622

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