Giter Site home page Giter Site logo

Failed to generate IR about slither HOT 20 OPEN

AaronLee22 avatar AaronLee22 commented on August 15, 2024
Failed to generate IR

from slither.

Comments (20)

elopez avatar elopez commented on August 15, 2024 2
- name: Build the contracts
  run: |
    cd packages/tokamak/contracts-bedrock
    forge build --build-info --skip '/test/**' '/scripts/**'

I attempted to follow your instructions as provided, yet the error persists as indicated below. Could you please elucidate why this error arises specifically in the presence of the "--ignore-compile" option, whereas it does not manifest in its absence?

Hi! It looks like you're still missing the asterisks at the beginning, please have another look at my message here: #2354 (comment)

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024 1
- name: Build the contracts
  run: |
    cd packages/tokamak/contracts-bedrock
    forge build --build-info --skip '/test/**' '/scripts/**'

I attempted to follow your instructions as provided, yet the error persists as indicated below. Could you please elucidate why this error arises specifically in the presence of the "--ignore-compile" option, whereas it does not manifest in its absence?

Hi! It looks like you're still missing the asterisks at the beginning, please have another look at my message here: #2354 (comment)

Wow it works now!! By the way can you tell me the reason why the [Failed to generate IR] error occurs? I don't really want to except any of the contracts.

Thanks again

from slither.

0xalpharush avatar 0xalpharush commented on August 15, 2024

The filter-paths flag is applied after running the detectors and not during compilation, so it won't skip this script and avoid the error.

However, if you're using a recent version of slither, they way forge is invoked should be skipping the scripts directory at compilation time. What version of slither are you using and can you show the terminal output of the same command without --ignore-compile please?

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024

It says solc-select-1.0.4.
without the --ignore-compile it works as expected but some how my repository has a complex building mechanism and want to use it in mono repo environment.

- name: Run Slither
  uses: crytic/[email protected]
  with:
    target: packages/tokamak/contracts-bedrock
    slither-config: packages/tokamak/contracts-bedrock/slither.config.json
    fail-on: config
    slither-version: dev-triage-db
    slither-args: --triage-database packages/tokamak/contracts-bedrock/slither.db.json
    ignore-compile: true

The install dependencies and building contracts worked fine.

from slither.

0xalpharush avatar 0xalpharush commented on August 15, 2024

If it works without --ignore-compile, could you explain what you're trying to accomplish by using --ignore-compile?There's an example of running a build command as a step in the github action here

from slither.

elopez avatar elopez commented on August 15, 2024

if you want to use ignore-compile and build manually, you can add the --skip argument to your forge build invocation to achieve the same Slither does internally:

forge build --build-info --skip '*/test/**' '*/script/**'

That way test & script won't get built and Slither will then not process that code.

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024

reason i want to use --ignore-compile.
It is not suitable for a monorepo scenario where the dependency's pnpm-lock file exists at the top level of the repository, but the target directory I want to analyze is not located at the top level of the repository.

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024

if you want to use ignore-compile and build manually, you can add the --skip argument to your forge build invocation to achieve the same Slither does internally:

forge build --build-info --skip '/test/**' '/script/**'

That way test & script won't get built and Slither will then not process that code.

let me try this way too

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024

If it works without --ignore-compile, could you explain what you're trying to accomplish by using --ignore-compile?There's an example of running a build command as a step in the github action here

This is exactly what I tried and the error above occurs

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024

if you want to use ignore-compile and build manually, you can add the --skip argument to your forge build invocation to achieve the same Slither does internally:

forge build --build-info --skip '*/test/**' '*/script/**'

That way test & script won't get built and Slither will then not process that code.

I tried forge build --build-info --skip '/test/**' '/script/**' as below
- name: Build the contracts
run: |
pnpm run build
forge build --build-info --skip 'packages/tokamak/contracts-bedrock/scripts' 'packages/contracts-bedrock/test'
still same error occurs as above.

Have I done something wrong?

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024

It says solc-select-1.0.4. without the --ignore-compile it works as expected but some how my repository has a complex building mechanism and want to use it in mono repo environment.

- name: Run Slither
  uses: crytic/[email protected]
  with:
    target: packages/tokamak/contracts-bedrock
    slither-config: packages/tokamak/contracts-bedrock/slither.config.json
    fail-on: config
    slither-version: dev-triage-db
    slither-args: --triage-database packages/tokamak/contracts-bedrock/slither.db.json
    ignore-compile: true

The install dependencies and building contracts worked fine.

slither version is 0.10.0

from slither.

elopez avatar elopez commented on August 15, 2024

if you want to use ignore-compile and build manually, you can add the --skip argument to your forge build invocation to achieve the same Slither does internally:
forge build --build-info --skip '*/test/**' '*/script/**'
That way test & script won't get built and Slither will then not process that code.

I tried forge build --build-info --skip '/test/**' '/script/**' as below - name: Build the contracts run: | pnpm run build forge build --build-info --skip 'packages/tokamak/contracts-bedrock/scripts' 'packages/contracts-bedrock/test' still same error occurs as above.

Have I done something wrong?

please try again, removing pnpm run build and keeping the asterisks on the forge invocation. You're likely running forge from within packages/tokamak/contracts-bedrock so the expanded paths you tried with won't match, and any previous forge runs launched from pnpm may generate artifacts that trigger the issue.

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024

if you want to use ignore-compile and build manually, you can add the --skip argument to your forge build invocation to achieve the same Slither does internally:
forge build --build-info --skip '*/test/**' '*/script/**'
That way test & script won't get built and Slither will then not process that code.

I tried forge build --build-info --skip '/test/**' '/script/**' as below - name: Build the contracts run: | pnpm run build forge build --build-info --skip 'packages/tokamak/contracts-bedrock/scripts' 'packages/contracts-bedrock/test' still same error occurs as above.
Have I done something wrong?

please try again, removing pnpm run build and keeping the asterisks on the forge invocation. You're likely running forge from within packages/tokamak/contracts-bedrock so the expanded paths you tried with won't match, and any previous forge runs launched from pnpm may generate artifacts that trigger the issue.

I appreciate your help!

- name: Build the contracts
  run: |
    cd packages/tokamak/contracts-bedrock
    forge build --build-info --skip '/test/**' '/scripts/**'

I attempted to follow your instructions as provided, yet the error persists as indicated below. Could you please elucidate why this error arises specifically in the presence of the "--ignore-compile" option, whereas it does not manifest in its absence?

--ignore-compile used, if something goes wrong, consider removing the ignore compile flag
ERROR:ContractSolcParsing:Impossible to generate IR for LibSort._toInts (scripts/libraries/LibSort.sol#469-474):
'str' object has no attribute 'type'
ERROR:SlitherSolcParsing:
Failed to generate IR for LivenessGuard_TestInit._initializeSafeTools. Please open an issue https://github.com/crytic/slither/issues.
LivenessGuard_TestInit._initializeSafeTools (test/safe-tools/SafeTestTools.sol#509-513):
singleton = new GnosisSafe()
proxyFactory = new GnosisSafeProxyFactory()
handler = new CompatibilityFallbackHandler()
Traceback (most recent call last):
File "/opt/slither/bin/slither", line 8, in
sys.exit(main())
File "/opt/slither/lib/python3.9/site-packages/slither/main.py", line 735, in main
main_impl(all_detector_classes=detectors, all_printer_classes=printers)
File "/opt/slither/lib/python3.9/site-packages/slither/main.py", line 841, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/opt/slither/lib/python3.9/site-packages/slither/main.py", line 107, in process_all
) = process_single(compilation, args, detector_classes, printer_classes)
File "/opt/slither/lib/python3.9/site-packages/slither/main.py", line 80, in process_single
slither = Slither(target, ast_format=ast, **vars(args))
File "/opt/slither/lib/python3.9/site-packages/slither/slither.py", line 146, in init
self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
File "/opt/slither/lib/python3.9/site-packages/slither/slither.py", line 166, in _init_parsing_and_analyses
raise e
File "/opt/slither/lib/python3.9/site-packages/slither/slither.py", line 162, in _init_parsing_and_analyses
parser.analyze_contracts()
File "/opt/slither/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 539, in analyze_contracts
self._convert_to_slithir()
File "/opt/slither/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 765, in _convert_to_slithir
raise e
File "/opt/slither/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 750, in _convert_to_slithir
func.generate_slithir_and_analyze()
File "/opt/slither/lib/python3.9/site-packages/slither/core/declarations/function.py", line 1772, in generate_slithir_and_analyze
node.slithir_generation()
File "/opt/slither/lib/python3.9/site-packages/slither/core/cfg/node.py", line 716, in slithir_generation
self._irs = convert_expression(expression, self) # type:ignore
File "/opt/slither/lib/python3.9/site-packages/slither/slithir/convert.py", line 118, in convert_expression
result = apply_ir_heuristics(result, node, is_solidity)
File "/opt/slither/lib/python3.9/site-packages/slither/slithir/convert.py", line 2033, in apply_ir_heuristics
irs = propagate_type_and_convert_call(irs, node)
File "/opt/slither/lib/python3.9/site-packages/slither/slithir/convert.py", line 529, in propagate_type_and_convert_call
new_ins = propagate_types(ins, node)
File "/opt/slither/lib/python3.9/site-packages/slither/slithir/convert.py", line 875, in propagate_types
assert contract
AssertionError

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024

this is the log for Build the contracts

Run cd packages/tokamak/contracts-bedrock
cd packages/tokamak/contracts-bedrock
forge build --build-info --skip '/test/' '/scripts/'
shell: /usr/bin/bash -e {0}
installing solc version "0.8.19"
Successfully installed solc 0.8.19
installing solc version "0.8.23"
Successfully installed solc 0.8.23
installing solc version "0.8.15"
Successfully installed solc 0.8.15
installing solc version "0.5.17"
Successfully installed solc 0.5.17
Compiling 1 files with 0.5.17
Compiling 34 files with 0.8.19
Compiling 300 files with 0.8.15
Compiling 114 files with 0.8.23
Solc 0.5.17 finished in 47.42ms
Solc 0.8.19 finished in 4.29s
Solc 0.8.23 finished in 6.91s
Solc 0.8.15 finished in 111.49s
Compiler run successful!

from slither.

elopez avatar elopez commented on August 15, 2024

I don't know what's causing the underlying issue with IR generation here. If your repository is public and you can share a link with us, that might help triage this bug further.

from slither.

AaronLee22 avatar AaronLee22 commented on August 15, 2024

Here are the smart contract links that's having this issue.

https://github.com/tokamak-network/tokamak-titan-canyon/blob/main/packages/tokamak/contracts-bedrock/scripts/libraries/LibSort.sol

https://github.com/tokamak-network/tokamak-titan-canyon/blob/main/packages/tokamak/contracts-bedrock/test/safe-tools/SafeTestTools.sol

Thank you for helping me solve this issue!

from slither.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.