Open PaulRBerg opened 1 year ago
supportive of that!
One caveat here is that it's possible the default sequence of optimizer steps will change between solc versions, and if so we'd need to stay on top of that with each solc release and maintain a mapping from version to step sequence. (Or, maybe it's unlikely to change / will never change, not sure)
Yeah, it's possible that the default sequence will change with time. In this case, I suggest maintaining a mapping as you @mds1 suggest, and throwing an error for those versions for which there is no default value available in Foundry.
Why not just omit the option from the JSON passed to the compiler (or from its CLI arguments) when it's set to "default"
? You would not have to keep the mapping. Changes to the sequence aren't rare, especially when we're tweaking the optimizer.
By the way, using specifically "default"
to indicate the default does not seem like a good idea because it's in fact a valid sequence: VarDeclInitializer
, ExpressionInliner
, BlockFlattener
, SSATransform
, UnusedPruner
, CircularReferencesPruner
, StructuralSimplifier
. :)
Component
Forge
Describe the feature you would like
The default Yul optimizer step sequence is quite long-winded - even in the Solidity source code, the default value is split on multiple lines for readability purposes.
My feature request is to make it possible to pass the
default
value to theoptimizerSteps
field in the Foundry config, so that users don't have to manually write it up:This is useful because users may want to disable the default step sequence during development (i.e. in the
default
profile) in order to speed up the compilation time. But then, in a separate profile such asproduction
, users may want to set the step sequence back to the default to get maximum optimization benefits.Additional context
See the conversation here.