Skip to content

Assist with migration to the EVM/L1 default Solidity codegen #943

@hedgar2017

Description

@hedgar2017

Component

Forge

Describe the feature you would like

There is an ongoing migration of the codegen parameter’s default from Yul to EVM assembly.

This has a couple of DevEx and security implications, so it must be handled with care. The implications are described in this warning recently introduced in zksolc.

In order to assist the migration, we must:

  1. Inspect the default hardcoded in Foundry, especially w.r.t. to the solc version specified in the project.
  2. Introduce a warning that will be emitted if codegen if not explicitly set. The warning will be changed in several stages throughout several releases as described below.

NEXT release: our codegen will be changed to EVM assembly:

>>> Please specify the `codegen` parameter explicitly to mitigate security and DevEx issues >>>

<instructions according to our config revamp>

>>> On May 1st (to be discussed), the default codegen will be changed to EVM [legacy] assembly (evmla) if it is not explicitly specified in your project config <<<

Whereas the default codegen for EVM/L1 projects has always been EVM [legacy] assembly (evmla), ZKsync/L2 projects have been using the Yul/IR codegen for historical reasons.

The differences in contracts behavior between codegens are described here:
https://docs.soliditylang.org/en/latest/ir-breaking-changes.html
It is known that 'yul' codegen produces more efficient bytecode, but it is still experimental and less reliable than 'evmla'.
If you are not sure, seek more information and user feedback out there.

To make sure that behavior of your contracts will not change after the migration, follow the recommendations depending on the age of your project and its solc version:
- if you have run your project on ZKsync before and suffered from different contract behavior between ZKsync/L2 and EVM/L1, set codegen to 'evmla' to fix the behavior
- if you have run your project on ZKsync before without issues, set codegen to 'yul' to keep the current behavior of your contracts
- if your project is new, check out the link above before choosing your codegen, or choose 'evmla' to be on the safe side

In 1 month / after N releases: our codegen has been just changed to EVM assembly:

>>> Please specify the `codegen` parameter explicitly to mitigate security and DevEx issues >>>

<instructions according to our config revamp>

>>> The default codegen for ZKsync projects has been changed from Yul to EVM [legacy] assembly (evmla) in Foundry version <x.y.z> <<<

Whereas the default codegen for EVM/L1 projects has always been EVM [legacy] assembly (evmla), ZKsync/L2 projects have been using the Yul/IR codegen for historical reasons.

The differences in contracts behavior between codegens are described here:
https://docs.soliditylang.org/en/latest/ir-breaking-changes.html
It is known that 'yul' codegen produces more efficient bytecode, but it is still experimental and less reliable than 'evmla'.
If you are not sure, seek more information and user feedback out there.

To make sure that behavior of your contracts will not change after the migration, follow the recommendations depending on the age of your project and its solc version:
- if you have run your project on ZKsync before and suffered from different contract behavior between ZKsync/L2 and EVM/L1, set codegen to 'evmla' to fix the behavior
- if you have run your project on ZKsync before without issues, set codegen to 'yul' to keep the current behavior of your contracts
- if your project is new, check out the link above before choosing your codegen, or choose 'evmla' to be on the safe side

In 2 months / after 2*N releases: warning is removed assuming that all projects have had enough time to set the codegen value explicitly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions