0

The problem is as the title. As we know, foundry is created by rust, it is very fast. But why my foundry is so slow?

my version: forge 0.2.0 (8307d6d 2023-04-19T16:44:52.696636400Z).cast 0.2.0 (8307d6d 2023-04-19T16:44:52.696636400Z). anvil 0.1.0 (8307d6d 2023-04-19T16:54:04.891176400Z). rust version: stable-x86_64-pc-windows-gnu (default)

here is the example, there is only one file in test folder: 900+ ms

PS E:\BlockChainPoC_github\BlockChainPoC> forge test
[⠔] Compiling...
No files changed, compilation skipped

Running 1 test for test/DFX.sol:ContractTest
[PASS] testExploit() (gas: 750212)
Test result: ok. 1 passed; 0 failed; finished in 988.07ms

and another test costs 22 secounds!

PS E:\BlockChainPoC_github\BlockChainPoC> forge test
[⠒] Compiling...
[⠑] Installing solc version 0.6.12
[⠘] Successfully installed solc 0.6.12
[⠰] Installing solc version 0.6.9
[⠔] Successfully installed solc 0.6.9
[⠒] Installing solc version 0.5.16
[⠆] Successfully installed solc 0.5.16
[⠘] Installing solc version 0.6.6
[⠊] Successfully installed solc 0.6.6
No files changed, compilation skipped

Running 1 test for test/bamboo/poc.sol:ContractTest
[PASS] testExp() (gas: 131579220)
Test result: ok. 1 passed; 0 failed; finished in 22.06s

1 Answer 1

1

One of things you can do is follow best practices https://book.getfoundry.sh/tutorials/best-practices

For example changing from

import "src/MyContract.sol"

to

import {MyContract} from "src/MyContract.sol"

Did reduce the compile time for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.