Solidity v0.8.7 introduces support for the London upgrade, includes various improvements to Yul to EVM code transformation, the SMTChecker and some bugfixes.

Please note: Unfortunately, the npm package of this version is corrupted. Pulling the solc-js repository directly will work.

Support for London Upgrade

Solidity adds support for the BASEFEE opcode (EIP-3198 and EIP-1559) which exposes the block’s base fee. This can be accessed via the global block.basefee or using basefee() in inline assembly or Yul.

The following contract illustrates an example:

contract Basefee {
    function basefee_global() external view returns (uint) {
        return block.basefee;
    }
    function basefee_inline_assembly() external view returns (uint ret) {
        assembly {
            ret := basefee()
        }
    }
}

SMTChecker

The SMTChecker now bundles all unproved target reports in a single message, decluttering the tool’s output and hopefully making any important information more visible. The command line option --model-checker-show-unproved and the JSON option settings.modelChecker.showUnproved=true can be used to list all the unproved targets.

The SMT encoding of division and modulo operations actually uses an equivalent encoding with multiplication and slack variables for solver performance. However, some non-default solvers work better with the precise encoding for those operations. The command line option --model-checker-div-mod-no-slacks and the JSON option settings.modelChecker.divModNoSlacks allow the user to choose the precise encoding for division and modulo. This option is expected to be useful only when employing other solvers than z3.

Lastly, underflow and overflow targets are not checked by default anymore. This follows the broad use of compiler generated checks which are expected to happen in Solidity >=0.8.0. Underflow and overflow checks can still be performed by selecting them via the command line option --model-checker-targets or the JSON option settings.modelChecker.targets.

Please see the SMTChecker documentation in the Solidity docs for more detailed information about these and other model checker options.

Full Changelog

Language Features:

  • Introduce global block.basefee for retrieving the base fee of the current block.
  • Yul: Introduce builtin basefee() for retrieving the base fee of the current block.

Compiler Features:

  • AssemblyStack: Also run opcode-based optimizer when compiling Yul code.
  • Commandline Interface: option --pretty-json works also with --standard--json.
  • EVM: Set the default EVM version to “London”.
  • SMTChecker: Do not check underflow and overflow by default.
  • SMTChecker: Unproved targets are hidden by default, and the SMTChecker only states how many unproved targets there are. They can be listed using the command line option --model-checker-show-unproved or the JSON option settings.modelChecker.showUnproved.
  • SMTChecker: new setting to enable/disable encoding of division and modulo with slack variables. The command line option is --model-checker-div-mod-slacks and the JSON option is settings.modelChecker.divModWithSlacks.
  • Yul EVM Code Transform: Also pop unused argument slots for functions without return variables (under the same restrictions as for functions with return variables).
  • Yul EVM Code Transform: Do not reuse stack slots that immediately become unreachable.
  • Yul Optimizer: Move function arguments and return variables to memory with the experimental Stack Limit Evader (which is not enabled by default).

Bugfixes:

  • Code Generator: Fix crash when passing an empty string literal to bytes.concat().
  • Code Generator: Fix internal compiler error when calling functions bound to calldata structs and arrays.
  • Code Generator: Fix internal compiler error when passing a 32-byte hex literal or a zero literal to bytes.concat() by disallowing such literals.
  • Commandline Interface: Apply --optimizer-runs option in assembly / yul mode.
  • Commandline Interface: Fix crash when a directory path is passed to --standard-json.
  • Commandline Interface: Read JSON from standard input when --standard-json gets - as a file name.
  • Standard JSON: Include source location for errors in files with empty name.
  • Type Checker: Fix internal error and prevent static calls to unimplemented modifiers.
  • Yul Code Generator: Fix internal compiler error when using a long literal with bitwise negation.
  • Yul Code Generator: Fix source location references for calls to builtin functions.
  • Yul Parser: Fix source location references for if statements.

A big thank you to all contributors who helped make this release possible!

Download the new version of Solidity here.