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

Slow compilation with via-ir #321

Closed
zeroknots opened this issue Mar 8, 2023 · 2 comments
Closed

Slow compilation with via-ir #321

zeroknots opened this issue Mar 8, 2023 · 2 comments

Comments

@zeroknots
Copy link

zeroknots commented Mar 8, 2023

Currently trying to integrate Uniswap's universal router. https://github.com/Uniswap/universal-router

Working with this code requires via-ir. Unfortunately I am experiencing extremely slow compile times:

reproduce:

git clone [email protected]:Uniswap/universal-router.git
cd universal-router
forge install
forge build
...
[⠰] Compiling 83 files with 0.8.17
[⠑] Solc 0.8.17 finished in **78.06s** <-- makes me sad

Compiling with hardhat:
pnpm compile --force 19.11s user 0.45s system 105% cpu 18.468 total

Versions:
forge 0.2.0 (28b2ae6 2023-03-06T00:04:30.253422Z)
solc 0.8.17

I assume this might be related to #225

@PaulRBerg
Copy link
Contributor

There's nothing wrong with Forge Std. You just need a set-up that uses via IR only for the contracts in src, and uses non-IR for tests. References:

Here's an example Foundry config:

[profile.default]
  fs_permissions = [{ access = "read", path = "./optimized-out" }]
  libs = ["lib"]
  optimizer = true
  optimizer_runs = 5_000
  out = "out"
  script = "script"
  solc = "0.8.19"
  src = "src"
  test = "test"

# Compile only the production code with IR
[profile.optimized]
  out = "optimized-out"
  test = "src"
  via_ir = true

@mds1
Copy link
Collaborator

mds1 commented Mar 9, 2023

This reproduction case doesn't demonstrate that forge-std is the issue here. It seems to me that forge build is a lot slower because it's compiling many solidity source AND solidity test files with via-ir (which you can workaround using the apporach @PaulRBerg mentioned), whereas hardhat is only compiling source files.

Looking at the recent successful CI runs in this repo, the via-ir builds of forge-std still only take 5 seconds (at the time of #225 it was 30-90 seconds)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants