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

solc repeated installation: makes the foundry too slow #5601

Closed
2 tasks done
chen4903 opened this issue Aug 11, 2023 · 9 comments
Closed
2 tasks done

solc repeated installation: makes the foundry too slow #5601

chen4903 opened this issue Aug 11, 2023 · 9 comments
Labels
T-bug Type: bug

Comments

@chen4903
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

0.2.0

What command(s) is the bug in?

forge test --match-path test/04.broker/attackTest.sol -vvvv

Operating System

Windows

Describe the bug

When I run a test for example: forge test --match-path test/04.broker/attackTest.sol -vvvv, the foundry will install sloc again and again although it has install the same sloc version before.

PS E:\BlockChainCTF\Paradigm 2021> forge test --match-path test/04.broker/attackTest.sol -vvvv
[⠊] Compiling...
[⠆] Installing solc version 0.5.12
[⠰] Successfully installed solc 0.5.12
[⠒] Installing solc version 0.4.26
[⠒] Successfully installed solc 0.4.26
[⠒] Compiling 5 files with 0.8.0
[⠘] Solc 0.8.0 finished in 4.83s
Compiler run successful!

Running 1 test for test/04.broker/attackTest.sol:attackTest
[PASS] test_isComplete() (gas: 189)
Traces:
[189] attackTest::test_isComplete()
    └─ ← ()

Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.51ms
Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
PS E:\BlockChainCTF\Paradigm 2021> forge test --match-path test/04.broker/attackTest.sol -vvvv
[⠊] Compiling...
[⠘] Installing solc version 0.4.26
[⠊] Successfully installed solc 0.4.26
[⠒] Installing solc version 0.5.12
[⠢] Successfully installed solc 0.5.12
No files changed, compilation skipped

Running 1 test for test/04.broker/attackTest.sol:attackTest
[PASS] test_isComplete() (gas: 189)
Traces:
[189] attackTest::test_isComplete() 
    └─ ← ()

Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.19ms
Ran 1 test suites: 1 tests passed, 0 failed, 0 skipped (1 total tests)
PS E:\BlockChainCTF\Paradigm 2021> forge --version
forge 0.2.0 (56adbe4 2023-07-16T07:03:29.896803000Z)

In this example, the sloc version 0.4.26 and 0.5.12 install again. Once I run a test, foundry will install the sloc though it has install it before, it makes my foundry too slow.

@chen4903 chen4903 added the T-bug Type: bug label Aug 11, 2023
@gakonst gakonst added this to Foundry Aug 11, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Aug 11, 2023
@mattsse
Copy link
Member

mattsse commented Aug 11, 2023

hmm, can you please run with RUST_LOG=ethers and share the logs?

this could be a checksum issue, can you try nuking the ~/svm folder

@chen4903
Copy link
Author

chen4903 commented Aug 11, 2023

I have tried: deleted ~/svm, but the problem is the same.
sorry, I don't know how to run with RUST_LOG=ethers, the command.

@mattsse
Copy link
Member

mattsse commented Aug 11, 2023

like

RUST_LOG=ethers forge test

or set the RUST_LOG env var

@chen4903
Copy link
Author

chen4903 commented Aug 12, 2023

the result of RUST_LOG is :

PS E:\BlockChainCTF\Paradigm 2021> forge test --match-path test/04.broker/attackTest.sol -vvvvv
[⠃] Compiling...2023-08-12T05:33:53.764976Z TRACE compile: ethers_solc: found 17 sources to compile:         
["E:/BlockChainCTF/Paradigm 2021/src\\01.hello\\Hello.sol", "E:/BlockChainCTF/Paradigm 2021/src\\01.hello\\Setup.sol",     
"E:/BlockChainCTF/Paradigm 2021/src\\02.secure\\Setup.sol", "E:/BlockChainCTF/Paradigm 2021/src\\02.secure\\Wallet.sol",     
"E:/BlockChainCTF/Paradigm 2021/src\\04.broker\\Broker.sol", "E:/BlockChainCTF/Paradigm 2021/src\\04.broker\\Setup.sol", 
"E:/BlockChainCTF/Paradigm 2021/test\\01.hello\\attackTest.sol", "E:/BlockChainCTF/Paradigm     
2021/test\\02.secure\\attackTest.sol", "E:/BlockChainCTF/Paradigm 2021/test\\02.secure\\helper_WETH9.sol", 
"E:/BlockChainCTF/Paradigm 2021/test\\02.secure\\interface.sol", "E:/BlockChainCTF/Paradigm 
2021/test\\04.broker\\attackTest.sol", "E:/BlockChainCTF/Paradigm 2021/test\\04.broker\\helper_WETH9.sol", 
"E:/BlockChainCTF/Paradigm 2021/test\\04.broker\\interface.sol", "E:/BlockChainCTF/Paradigm 
2021/test\\04.broker\\uniswapV2\\erc20.sol", "E:/BlockChainCTF/Paradigm 2021/test\\04.broker\\uniswapV2\\factory.sol", 
"E:/BlockChainCTF/Paradigm 2021/test\\04.broker\\uniswapV2\\pair.sol", "E:/BlockChainCTF/Paradigm 
2021/test\\04.broker\\uniswapV2\\router.sol"]
2023-08-12T05:33:53.765181Z TRACE compile: ethers_solc: using solc auto detection to compile sources
2023-08-12T05:33:53.820217Z TRACE compile: ethers_solc::resolver: resolving input node versions
2023-08-12T05:33:53.821032Z TRACE compile: ethers_solc::resolver: no solc version can satisfy all source files, resolved multiple versions  "[Installed(Version { major: 0, minor: 8, patch: 0 }), Installed(Version { major: 0, minor: 5, patch: 12 }), Installed(Version { major: 0, minor: 4, patch: 26 })]"
2023-08-12T05:33:53.821132Z TRACE compile: ethers_solc::resolver: resolved 3 versions [Installed(Version { major: 0, minor: 8, 
patch: 0 }), Installed(Version { major: 0, minor: 5, patch: 12 }), Installed(Version { major: 0, minor: 4, patch: 26 })]
2023-08-12T05:33:53.821384Z TRACE compile: ethers_solc::resolver: verifying solc checksum for 
C:\Users\ChenQin\.svm\0.4.26\solc-0.4.26
2023-08-12T05:33:53.842706Z TRACE compile: ethers_solc::resolver: corrupted solc version, redownloading  "0.4.26"
2023-08-12T05:33:53.842850Z TRACE compile: ethers_solc::compile: blocking installing solc version "0.4.26"
[⠊] Compiling...
[⠰] Installing solc version 0.4.262023-08-12T05:33:57.548110Z TRACE compile: ethers_solc::resolver: reinstalled solc: "0.4.26"
[⠔] Installing solc version 0.4.26
[⠒] Successfully installed solc 0.4.262023-08-12T05:33:57.565426Z TRACE compile: ethers_solc::resolver: verifying solc checksum for C:\Users\ChenQin\.svm\0.8.0\solc-0.8.0
2023-08-12T05:33:57.599567Z TRACE compile: ethers_solc::resolver: verifying solc checksum for 
C:\Users\ChenQin\.svm\0.5.12\solc-0.5.12
2023-08-12T05:33:57.626641Z TRACE compile: ethers_solc::resolver: corrupted solc version, redownloading  "0.5.12"
2023-08-12T05:33:57.626796Z TRACE compile: ethers_solc::compile: blocking installing solc version "0.5.12"
[⠑] Successfully installed solc 0.4.26
[⠒] Installing solc version 0.5.122023-08-12T05:34:12.631118Z TRACE compile: ethers_solc::resolver: reinstalled solc: "0.5.12"
2023-08-12T05:34:12.646542Z TRACE compile: ethers_solc::compile::project: preprocessing
2023-08-12T05:34:12.646847Z TRACE compile:sol-files-cache::read: ethers_solc::cache: reading solfiles cache at 
E:/BlockChainCTF/Paradigm 2021/cache/solidity-files-cache.json
2023-08-12T05:34:12.647921Z TRACE compile:sol-files-cache::read: ethers_solc::cache: read cache "ethers-rs-sol-cache-3" with 
35 entries
2023-08-12T05:34:12.648112Z TRACE compile: ethers_solc::cache: remove non existing files from cache
2023-08-12T05:34:12.649967Z TRACE compile: ethers_solc::cache: reading artifacts from cache...
[⠑] Installing solc version 0.5.12
[⠒] Successfully installed solc 0.5.122023-08-12T05:34:13.048700Z TRACE compile: ethers_solc::cache: read 56 artifacts from 
cache
2023-08-12T05:34:13.050197Z TRACE compile: ethers_solc::compile::project: Filtering 2 sources for 
0.4.26+commit.4563c3fc.Windows.msvc
2023-08-12T05:34:13.050443Z TRACE compile: ethers_solc::compile::project: Detected 0 dirty sources []
2023-08-12T05:34:13.050611Z TRACE compile: ethers_solc::compile::project: Filtering 2 sources for 
0.5.12+commit.7709ece9.Windows.msvc
2023-08-12T05:34:13.050852Z TRACE compile: ethers_solc::compile::project: Detected 0 dirty sources []
2023-08-12T05:34:13.051025Z TRACE compile: ethers_solc::compile::project: Filtering 31 sources for 
0.8.0+commit.c7dfd78e.Windows.msvc
2023-08-12T05:34:13.052057Z TRACE compile: ethers_solc::compile::project: Detected 0 dirty sources []
2023-08-12T05:34:13.052224Z TRACE compile: ethers_solc::compile::project: compiling
2023-08-12T05:34:13.052387Z TRACE compile: ethers_solc::compile::project: compile 3 sources in parallel using up to 16 solc 
jobs
2023-08-12T05:34:13.052567Z TRACE compile: ethers_solc::compile::project: skip solc C:\Users\ChenQin\.svm\0.4.26\solc- 
0.4.26 0.4.26+commit.4563c3fc.Windows.msvc for empty sources set
2023-08-12T05:34:13.052842Z TRACE compile: ethers_solc::compile::project: skip solc C:\Users\ChenQin\.svm\0.5.12\solc- 
0.5.12 0.5.12+commit.7709ece9.Windows.msvc for empty sources set
2023-08-12T05:34:13.053119Z TRACE compile: ethers_solc::compile::project: skip solc C:\Users\ChenQin\.svm\0.8.0\solc-0.8.0 
0.8.0+commit.c7dfd78e.Windows.msvc for empty sources set
2023-08-12T05:34:13.053917Z TRACE compile:write-artifacts: ethers_solc::compile::project: handling artifact output for 0 
contracts and 0 sources
2023-08-12T05:34:13.054437Z TRACE compile: ethers_solc::compile::project: prepare writing cache file has_error=false 
project.no_artifacts=false skip_write_to_disk=false cache_path="E:/BlockChainCTF/Paradigm 2021/cache/solidity-files- 
cache.json"
2023-08-12T05:34:13.055450Z TRACE compile: ethers_solc::cache: writing cache with 35 entries to json file: 
"E:/BlockChainCTF/Paradigm 2021/cache/solidity-files-cache.json"   
 [⠢] Successfully installed solc 0.5.122023-08-12T05:34:13.226462Z TRACE compile: ethers_solc::cache: cache file located: 
"E:/BlockChainCTF/Paradigm 2021/cache/solidity-files-cache.json"
[⠆] Successfully installed solc 0.5.12
No files changed, compilation skipped

Running 1 test for test/04.broker/attackTest.sol:attackTest
[PASS] test_isComplete() (gas: 202968)

By the way, not only this project, but also the other foundry project which I use has the same problems. It always installs the solc although there is one in ~/.svm. But when I test the demo template the foundry provides me, it doesn't wrong.

@chen4903 chen4903 changed the title sloc repeated installation: makes the foundry too slow solc repeated installation: makes the foundry too slow Aug 12, 2023
@mattsse
Copy link
Member

mattsse commented Aug 12, 2023

2023-08-12T05:33:53.821384Z TRACE compile: ethers_solc::resolver: verifying solc checksum for
C:\Users\ChenQin.svm\0.4.26\solc-0.4.26
2023-08-12T05:33:53.842706Z TRACE compile: ethers_solc::resolver: corrupted solc version, redownloading "0.4.26"

interesting, can you check what's the sha2 of these files?

@chen4903
Copy link
Author

I use this site to hash: https://oktools.net/file-hash

C:\Users\ChenQin.svm\0.4.26\solc-0.4.26

solc-0.4.26	(n/a) - 3892736bytes
MD5	        8de83ca7945828afc9e77f3083eeecfe
SHA1  	b4d642b6a497f7ec5ed4c0404ab276e74d4b290e
SHA256	c2218bfc4ad4dfde9b56cff0a2d53b4c5a540d131394a9c7535390b364afe933

C:\Users\ChenQin.svm\0.5.12\solc-0.5.12

solc-0.5.12	(n/a) - 5783040bytes
MD5	  	1a7e64b2859a03079b840a1b6c9b61be
SHA1		5ed4e6a29d927225046dba870fbc8529678a8ba7
SHA256	c37b19013b3bac6e5ec5e201882332bde26d1b7916a3a784974de3e74013ad08

C:\Users\ChenQin.svm\0.7.0\solc-0.7.0

MD5		6447f140ba80b761a80a1a54c77f0f05
SHA1		372e68a254aa607c5dd70e0d1f17f41a3af7067c
SHA256	08bcfc125791ca7993fa4a9fff1a669792b4a014d59b04f61a154e97fda527cf

C:\Users\ChenQin.svm\0.5.12\solc-0.8.0

MD5		4d1e06259de9b47b6070ab6a0a86a542
SHA1		f6a70b5ab094bd2ad95e4aa92aeffa8ac7276a33
SHA256	ed74a625bd67dbb74f616aec64f771060df3376f38ef068bd17fd5a5fe19d98c

C:\Users\ChenQin.svm\0.4.26\slotest.exe

soltest.exe	(application/x-msdownload) - 13295616bytes
MD5		3333322b1020a8583a4874304b2dae6d
SHA1		304e4a370c851ada13db5af3b11637a8636a14c8
SHA256	9e4b2bfde031cfe03fa408b93f6da91d95ebd77da28ff207e0ea7be0504ea278

the ~.svm:

C:\Users\ChenQin\.svm>tree /f
C:.
│  .global-version
│
├─0.4.26
│      msvcp140.dll
│      msvcp140_1.dll
│      msvcp140_2.dll
│      solc-0.4.26
│      soltest.exe
│
├─0.5.12
│      msvcp140.dll
│      msvcp140_1.dll
│      msvcp140_2.dll
│      solc-0.5.12
│      soltest.exe
│
├─0.7.0
│      msvcp140.dll
│      msvcp140_1.dll
│      msvcp140_2.dll
│      solc-0.7.0
│      soltest.exe
│
└─0.8.0
        solc-0.8.0

@mattsse
Copy link
Member

mattsse commented Aug 12, 2023

ah yikes, on windows this track the hash of the zip file not the actual binary.

will get that fixed, in the meantime you can run with --offline to prevent redownloads

@chen4903
Copy link
Author

I use --offline and it works.
on windows this track the hash of the zip file not the actual binary : Do I need to provide u hash fo another files? Or it is a bug in windows(mine is 11)?

@DaniPopes
Copy link
Member

All releases before 0.7.2 (excluded) hash the zip file instead of the executable file. You can see this in the binaries.soliditylang.org binaries list for windows-amd64 (look for change between .zip and .exe in 0.7.1 and 0.7.2).
This should be fixed in the next nightly release, thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

3 participants