Solidity v0.8.10 can now report contract invariants and reentrancy properties through the SMTChecker. It also contains some new optimizations with regards to external function calls and enables the new EVM code generator for pure Yul mode.
Notable New Features
New EVM Code Transform for Compilation via Yul IR
With this release, we introduce a new EVM code generation backend that is used for the experimental compilation pipeline of Solidity via Yul (with enabled optimizer), as well as for optimized compilation of Yul input.
While previously any Yul variable had a fixed position on stack during its entire lifetime, the new code transform drops this restriction and attempts to determine a more optimal layout that (1) reduces the required amount of swapping and thereby reduces gas cost and (2) keeps overall stack usage as low as possible to work against stack-too-deep errors.
We simultaneously enable the previously experimental StackLimitEvader for code generated via Yul, which will - under certain conditions - move Yul variables from stack to memory to prevent stack-too-deep errors. However, this transformation is only enabled in the absence of inline assembly for now, since there is no way to indicate that inline assembly will respect Solidity’s memory model, which is a prerequisite for the transformation to be valid.
In our benchmarks, the new code transform has resulted in significant runtime gas savings, although at the cost of a slight increase in code size.
This change will also affect the generation of optimized code with Yul as input, i.e.
solc --strict-assembly --optimize will also use the new code transform.
To enable the StackLimitEvader, Yul code needs to indicate that it respects an area of reserved memory. This can be done with the
memoryguard instruction as described in our documentation: Yul code containing
let ptr := memoryguard(size), where
size is a literal, promises to keep the memory in the range
[size, ptr) untouched at all times, allowing the compiler to use this range for moving stack variables, if necessary.
- Inline Assembly: Support
.selectoron external function pointers to access their address and function selector.
- Code Generator: Skip existence check for external contract if return data is expected. In this case, the ABI decoder will revert if the contract does not exist.
- Commandline Interface: Accept nested brackets in step sequences passed to
- Commandline Interface: Add
--debug-infooption for selecting how much extra debug information should be included in the produced EVM assembly and Yul code.
- Commandline Interface: Support
--ewasm-iroutput selection options in assembler mode.
- Commandline Interface: Use different colors when printing errors, warnings and infos.
- JSON AST: Set absolute paths of imports earlier, in the
- SMTChecker: Output values for
tx.*variables that are present in the called functions.
- SMTChecker: Report contract invariants and reentrancy properties. This can be enabled via the CLI option
--model-checker-invariantsor the Standard JSON option
- Standard JSON: Accept nested brackets in step sequences passed to
- Standard JSON: Add
settings.debug.debugInfooption for selecting how much extra debug information should be included in the produced EVM assembly and Yul code.
- Yul EVM Code Transform: Switch to new optimized code transform when compiling via Yul with enabled optimizer.
- Yul Optimizer: Take control-flow side-effects of user-defined functions into account in various optimizer steps.
- Code Generator: Fix constructor source mappings for immutables.
- Commandline Interface: Disallow
--error-recoveryoption outside of the compiler mode.
- Commandline Interface: Don’t return zero exit code when writing linked files to disk fails.
- Commandline Interface: Fix extra newline character being appended to sources passed through standard input, affecting their hashes.
- Commandline Interface: Report output selection options unsupported by the selected input mode instead of ignoring them.
- Commandline Interface: When linking only accept exact matches for library names passed to the
--librariesoption. Library names not prefixed with a file name used to match any library with that name.
- SMTChecker: Fix internal error in magic type access (
- SMTChecker: Fix internal error in the CHC engine when passing gas in the function options.
- TypeChecker: Fix internal error when using arrays and structs with user defined value types before declaration.
- TypeChecker: Fix internal error when using user defined value types in public library functions.
- TypeChecker: Improved error message for constant variables with (nested) mapping types.
- Yul Assembler: Fix internal error when function names are not unique.
- Yul IR Generator: Do not output empty switches/if-bodies for empty contracts.
Important Bugfixes in Experimental Features:
- Yul IR Generator: Changes to function return variables referenced in modifier invocation arguments were not properly forwarded if there was more than one return variable.
- Pass linker-only emscripten options only when linking.
- Remove obsolete compatibility workaround for emscripten builds.
- Update emscripten to version 2.0.33.
A big thank you to all contributors who helped make this release possible!
Download the new version of Solidity here.