[wip] feat: compilation restrictions #8668
Draft
+194
−56
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.
Closes #6099
Closes #5715
This builds on top of foundry-rs/compilers#170 and allows the following configuration options in foundry.toml:
compilation_restrictions
allows users to configure how we compile individual files or directories. Currently accepted keys aremin_evm_version
,max_evm_version
,min_optimizer_runs
,max_optimizer_runs
,cancun
. Configured restrictions apply to sources importing the restricted file as well.Once we have a set of restrictions, we need to somehow construct settings objects to satisfy them. Right now those should be constructed manually via
additional_compiler_profiles
. It is configured a mapping from profile name to settings overrides. In example above we add a single profile namedvia-ir
, which uses default settings withvia_ir
enabled, making it possible to compile a single contract undersrc/
with via-ir while all other contracts, including tests are compiled with default profile.We need names for all profiles to include them into artifacts names in cases when same source file is compiled with multiple different profiles. Right now such artifacts would be named as
Counter.{profile}.json
.When choosing profile, first profile (starting with default one), satisfying restrictions of the source file and all of its imports will be used.