forge-std icon indicating copy to clipboard operation
forge-std copied to clipboard

Fix long compile times when using `via-ir`

Open Vectorized opened this issue 3 years ago • 2 comments
trafficstars

For #207.

Tested on Solady. Compiles within 2 minutes instead of 30+ minutes.

Vectorized avatar Nov 03 '22 19:11 Vectorized

Thanks! This is a great workaround, minimal UX hit 👌

I just want to see how #207 shakes out before merging this, it's possible there's a solc or svm-rs issue which would mean we can leave things as-is, which would be preferable IMO

mds1 avatar Nov 04 '22 01:11 mds1

We've been suffering wildly long compile times as well, this commit fixes for us too :ok_hand: Seems like maybe a faster way forward than a compiler-level fix? ie might be worth it for dev ex to merge this now and revert if the underlying issue is later resolved in 0.8.18 or something, given forge releases much more often than solc

marktoda avatar Nov 04 '22 17:11 marktoda

In order to restore --via-ir and not hurt the adoption of V1, we can do the following:

  1. Remove the stdChains variable completely (no half-backed features), keep assumeNoPrecompiles (hardcode chain IDs)
  2. Find a solution (#207)
  3. Put stdChains back

Interested if others find this to be a good solution.

Another idea: We can can change stdChains to be a mapping, e.g. stdChains["mainnet"], if that helps with this issue (have not tested). It would also allow users to add custom chains to stdChains.

ZeroEkkusu avatar Nov 07 '22 16:11 ZeroEkkusu

I think the mapping idea so users can add their own chains is interesting—if anyone wants to refactor into the mapping approach to see if that still has the slow compilation time, maybe we go that route if it's performant? otherwise I can try it later this week

mds1 avatar Nov 09 '22 22:11 mds1

Per some discussion in the foundry telegram, let's

  • refactor to mapping approach due to added flexibility (also nice that the keys to access chain data matches the expected keys in the config file)
  • test to make sure that it doesn't have the slow compile time issue
  • if not, merge. if it does, use the struct with the solution in this PR

mds1 avatar Nov 09 '22 23:11 mds1

Thanks for reporting the issue, @Vectorized! We are closing your PR, as we’ve implemented a solution with mappings in #217.

I hope you’ll like Forge-Std 1.1 better!

ZeroEkkusu avatar Nov 11 '22 18:11 ZeroEkkusu