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

document suggestion of "lite" mode for faster compilation #709

Closed
mds1 opened this issue Nov 28, 2022 · 2 comments · Fixed by #719
Closed

document suggestion of "lite" mode for faster compilation #709

mds1 opened this issue Nov 28, 2022 · 2 comments · Fixed by #719

Comments

@mds1
Copy link
Contributor

mds1 commented Nov 28, 2022

I'm not sure what section of the book to put this in, so dropping it in this issue for now, but per foundry-rs/forge-std#225 (comment) we may want to add something like this to the book:


Many projects use the solc optimizer, either directly or with via-ir. A config file may look like this for regular compilation:

[profile.default]
solc-version = "0.8.17"
optimizer = true
optimizer-runs = 10_000_000

Or like this for via-ir:

[profile.default]
solc-version = "0.8.17"
via_ir = true

The optimizer can significantly slow down compilation speeds, so one trick is to have a lite profile that has the optimizer off and use this for development. The updated config file for regular compilation may look like this:

[profile.default]
solc-version = "0.8.17"
optimizer = true
optimizer-runs = 10_000_000

[profile.lite]
optimizer = false

Or like this for via-ir:

[profile.default]
solc-version = "0.8.17"
via_ir = true

[profile.lite.optimizer_details.yulDetails]
optimizerSteps = ''

(note that there are additional optimizer details you can configure, see here for more info)

Running forge build (or test or script) still uses the standard profile, so by default a forge script invocation will deploy your contracts with the production setting. Running FOUNDRY_PROFILE=lite forge build (and again, same for test/script) will use the lite profile to reduce compilation times

@ZeroEkkusu
Copy link
Contributor

ZeroEkkusu commented Nov 29, 2022

what section of the book to put this in

Note: There are already some mentions.

@mds1
Copy link
Contributor Author

mds1 commented Dec 1, 2022

Thanks, the forge build page seems like a good fit. PR coming soon

Repository owner moved this from Todo to Done in Foundry Book Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants