perf: precompile contracts for faster test runs #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
IR compilation of the entire project takes a long time. When excluding the test suite however, the time cuts down dramatically. It would be nice to compile just the source contracts via IR and the test suite without. However, there's currently no way (in Foundry) to specify different profiles or different compilation configuration for specific files in a build.
Solution
The approach taken here is inspired by https://github.com/ProjectOpenSea/seaport. I've created a profile
optimized-build
for the purpose of precompiling just the source contracts via IR into the folderout-optimized
. When tests are run under theoptimized-test
oroptimized-test-deep
profiles, the project is built again without IR, but the relevant source contracts are deployed using the optimized bytecode fromout-optimized
so the tests can test against the bytecode that is actually to be deployed.I've updated the CI workflow to remove the lite test in favor of using the optimized test. It should be fast enough now that we don't need the early signal provided by the lite profile.
Please let me know if you see any flaws with this!