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

Fail to compile some hardhat projects #422

Open
Xenomega opened this issue Apr 20, 2023 · 5 comments
Open

Fail to compile some hardhat projects #422

Xenomega opened this issue Apr 20, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@Xenomega
Copy link
Member

Xenomega commented Apr 20, 2023

The crytic-compile CI shows a failure to compile some projects: https://github.com/crytic/crytic-compile/actions/runs/4754028647/jobs/8446340120

Output:

Testing hardhat integration of /opt/hostedtoolcache/Python/3.8.16/x64/bin/crytic-compile
npm WARN deprecated [email protected]: ganache-core is now ganache; visit https://trfl.io/g7 for details
npm WARN deprecated [email protected]: ganache-core is now ganache; visit https://trfl.io/g7 for details
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated [email protected]: testrpc has been renamed to ganache-cli, please use this package from now on.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated @ensdomains/[email protected]: Please use @ensdomains/ens-contracts
npm WARN deprecated @ensdomains/[email protected]: Please use @ensdomains/ens-contracts

added 1433 packages, and audited 1437 packages in 38s

127 packages are looking for funding
  run `npm fund` for details

71 vulnerabilities (20 moderate, 27 high, 24 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
INFO:CryticCompile:'npx hardhat clean' running (wd: /home/runner/work/crytic-compile/crytic-compile/tests/hardhat)
INFO:CryticCompile:'npx hardhat clean --global' running (wd: /home/runner/work/crytic-compile/crytic-compile/tests/hardhat)
INFO:CryticCompile:'npx hardhat compile --force' running
INFO:CryticCompile:Downloading compiler 0.7.3

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.[16](https://github.com/crytic/crytic-compile/actions/runs/4754028647/jobs/8446340120#step:9:17)/x64/bin/crytic-compile", line 8, in <module>
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/crytic_compile/__main__.py", line 221, in main
    compilations = compile_all(**vars(args))
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/crytic_compile/crytic_compile.py", line 643, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/crytic_compile/crytic_compile.py", line 131, in __init__
    self._compile(**kwargs)
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/crytic_compile/crytic_compile.py", line 553, in _compile
    self._platform.compile(self, **kwargs)
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/crytic_compile/platform/hardhat.py", line [19](https://github.com/crytic/crytic-compile/actions/runs/4754028647/jobs/8446340120#step:9:20)5, in compile
    hardhat_like_parsing(crytic_compile, self._target, build_directory, hardhat_working_dir)
  File "/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/crytic_compile/platform/hardhat.py", line 49, in hardhat_like_parsing
    os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x))
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/crytic-compile/crytic-compile/tests/hardhat/artifacts/build-info'
Monorepo test failed
Error: Process completed with exit code [25](https://github.com/crytic/crytic-compile/actions/runs/4754028647/jobs/8446340120#step:9:26)5.

Similarly, this is causing medusa's CI to fail.

Output:

--- FAIL: TestCryticDirectoryNoArgs (79.95s)
    crytic_compile_test.go:245: 
        	Error Trace:	/Users/runner/work/medusa/medusa/compilation/platforms/crytic_compile_test.go:245
        	            				/Users/runner/work/medusa/medusa/utils/testutils/test_directory_utils.go:65
        	            				/Users/runner/work/medusa/medusa/compilation/platforms/crytic_compile_test.go:235
        	Error:      	Received unexpected error:
        	            	error while executing crytic-compile:
        	            	OUTPUT:
        	            	INFO:CryticCompile:'npx hardhat clean' running (wd: /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/TestCryticDirectoryNoArgs13356[76](https://github.com/crytic/medusa/actions/runs/4756484891/jobs/8453387494#step:7:77)214/001/medusaTest/basic_project)
        	            	INFO:CryticCompile:'npx hardhat clean --global' running (wd: /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/TestCryticDirectoryNoArgs1335676214/001/medusaTest/basic_project)
        	            	INFO:CryticCompile:'npx hardhat compile --force' running
        	            	INFO:CryticCompile:Downloading compiler 0.8.10
        	            	Downloading compiler 0.7.1
        	            	
        	            	Traceback (most recent call last):
        	            	  File "/Library/Frameworks/Python.framework/Versions/Current/bin/crytic-compile", line 8, in <module>
        	            	    sys.exit(main())
        	            	             ^^^^^^
        	            	  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/crytic_compile/__main__.py", line 221, in main
        	            	    compilations = compile_all(**vars(args))
        	            	                   ^^^^^^^^^^^^^^^^^^^^^^^^^
        	            	  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 643, in compile_all
        	            	    compilations.append(CryticCompile(target, **kwargs))
        	            	                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        	            	  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 131, in __init__
        	            	    self._compile(**kwargs)
        	            	  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 553, in _compile
        	            	    self._platform.compile(self, **kwargs)
        	            	  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/crytic_compile/platform/hardhat.py", line 1[95](https://github.com/crytic/medusa/actions/runs/4756484891/jobs/8453387494#step:7:96), in compile
        	            	    hardhat_like_parsing(crytic_compile, self._target, build_directory, hardhat_working_dir)
        	            	  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/crytic_compile/platform/hardhat.py", line 49, in hardhat_like_parsing
        	            	    os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x))
        	            	    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        	            	FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/TestCryticDirectoryNoArgs1335676214/001/medusaTest/basic_project/artifacts/build-info'
@Xenomega Xenomega added the bug Something isn't working label Apr 20, 2023
@elopez
Copy link
Member

elopez commented May 16, 2023

This is possibly related to NomicFoundation/hardhat#3877 -- see also crytic/slither-action#56

As a workaround, downgrading Node can resolve the failures.

@0xmichalis
Copy link

Note that we are seeing this issue with Node 16 so downgrade may or may not be helpful.

@duckki
Copy link

duckki commented Jun 23, 2023

I encountered the same error with a foundry project.
Source url: https://github.com/code-423n4/2023-01-ondo (commit f3426e5b6b4561e09460b2e6471eb694efdd6c70)

When I ran crytic-compile ., I got this error:

Traceback (most recent call last):
  File "/opt/homebrew/bin/crytic-compile", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/crytic_compile/__main__.py", line 221, in main
    compilations = compile_all(**vars(args))
  File "/opt/homebrew/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 643, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "/opt/homebrew/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 131, in __init__
    self._compile(**kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 553, in _compile
    self._platform.compile(self, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/crytic_compile/platform/foundry.py", line 90, in compile
    hardhat_like_parsing(crytic_compile, self._target, build_directory, self._target)
  File "/opt/homebrew/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 49, in hardhat_like_parsing
    os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x))
FileNotFoundError: [Errno 2] No such file or directory: 'out/build-info'

My crytic-compile version: 0.3.1

forge build --build-info --force runs fine, otherwise.

@elopez
Copy link
Member

elopez commented Jun 23, 2023

Hi @duckki, that error message seems to be unrelated. The repo you linked has a custom out folder name, which crytic-compile cannot autodetect yet: https://github.com/code-423n4/2023-01-ondo/blob/main/foundry.toml#L4

You can either remove that line and use the default foundry out name, or provide the custom name to crytic-compile using the --foundry-out-directory option:

crytic-compile . --foundry-out-directory ./artifactsforge/

@duckki
Copy link

duckki commented Jun 23, 2023

@elopez Thanks for the info!

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

4 participants