NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.31k stars 1.41k forks source link

Default EVM target is still paris #5267

Closed SKYBITDev3 closed 5 months ago

SKYBITDev3 commented 6 months ago

Version of Hardhat

2.22.4

What happened?

If evmVersion version isn't explicitly set in hardhat config then compilation result is:

Compiled 152 Solidity files successfully (evm target: paris).

After explicitly setting evmVersion to cancun like this:

  solidity: {
    compilers: [
      {
        version: `0.8.26`,
        settings: {
          optimizer: {
            enabled: true,
            runs: 15000
          },
          evmVersion: `cancun`,
        }
      },
    ],
  },

then it says the evm target was cancun as expected:

Compiled 152 Solidity files successfully (evm target: cancun).

Did you guys check that https://github.com/NomicFoundation/hardhat/issues/4851 actually worked?

Minimal reproduction steps

Don't explicitly set evmVersion in hardhat config and run yarn hardhat compile.

Search terms

No response

fvictorio commented 5 months ago

Hi @SKYBITDev3, I think you are mixing up two concepts here.

4851 is about using Cancun as the default hardfork of the Hardhat Network. That means that, for example, that transient storage opcodes are available by default. We did check that it works :slightly_smiling_face:

The EVM target of solc is a different thing. This is what kind of opcodes will be used in the bytecode generated by solc. In this case, a paris target means that solc won't use transient storage opcodes (or any opcode introduced after paris).

The reason for this is that not all chains enable hardforks immediately. This was a problem, for example, when PUSH0 was introduced: if you used the latest version of solc with their default EVM target (which used PUSH0) but then deployed in a chain that didn't have the opcode yet, your contract will not work. So we decided to be conservative about this.

Ideally Hardhat would have a good alignment between the solc EVM target, the local hardhat network hardfork, and the (minimum) hardfork of the chains where you intend to deploy, but we are not there yet.

Now, it's true that paris is kind of an old hardfork now. We might have to upgrade the default EVM target, but we don't really have a policy of how and when to do that (see https://github.com/NomicFoundation/hardhat/issues/4264)