-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic downgrade of default EVM version may not be welcome #4391
Comments
Hi @SKYBITDev3. I think I agree with you. I considered doing a minor and for some reason then I didn't. In retrospect that was a mistake. But I think undoing that change in a new patch an releasing a new minor with the proper change is going to be too noisy now. I think the best we can do now is this:
I really like this idea. With respect to making the
This makes sense, but we do need to make a decision one way or another: we either unnecessarily downgrade the EVM version for some users, or we default to compiling broken bytecode for others. All things considered, I think defaulting to the safer version makes more sense. The cost is that some users will have contracts that could be more optimized but aren't, which seems like a sensible trade-off to me. Wdyt? |
Best practice generally in technology is to use the latest versions. We resort to a downgrade only if necessary, e.g. if something that we need doesn't work. Us developers aren't mindless non-technical end users - when something doesn't work, we ourselves find a way to make it work using our problem-solving skills. In the case of EVM version, if we came across A smarter solution, if possible, would've been to print a message about suggesting to try
It would give certainty, especially amid this flip-flopping of default EVM version. Otherwise a newcomer would naturally think they're using latest versions if they only set |
You could add solidity: {
compilers: [
{
version: `0.8.21`,
settings: {
optimizer: {
enabled: true,
runs: 1000
},
evmVersion: `shanghai`, // downgrade to `paris` if you encounter 'invalid opcode' error
}
},
],
}, |
Adding a mandatory field to the config is a breaking change, so that's not something we are likely to do. In fact, no field in the config is mandatory right now (not even the solidity version), so it would be weird to add only that one.
Some users might realize this only after deploying. This is what we are trying to prevent. The cost here is that users, by default, will have somewhat bigger generated bytecodes. People that care about those optimizations will likely already know how to do it. Again, this is a question of on which side do you want to err on. We decided that "completely preventing people from deploying invalid bytecode" was better than "completely preventing people from unnecessarily wasting a bit of gas during deployment". I do agree with your main point that this should've been a minor version, not a patch. But that's not something we are going to undo now. |
I've just tried to compile without
OK but even without making it mandatory you could still add more to the default hardhat.config.js when a user runs
There's no "after deploying" as the deployment fails if the blockchain doesn't support it. Then as developers we find out why it failed and work around it. Hardhat could have helped by adding some guidance when that "invalid opcode" error appears, e.g. about advising to add
No worries, I wouldn't expect you to undo it, so this issue is more for better future practice. |
Ah, you are right. If the deployment bytecode has a |
Closing this for now. The latest version of Hardhat shows the targeted EVM(s) in the compilation output, which I think should be enough for now, but happy to re-visit this in the future. |
I think the reversion of default EVM version of the Solidity compiler back to
paris
(fromshanghai
, currently the latest) warranted a minor (instead of patch) version number increment (e.g. 2.18.x), as the behavior and outputs have been changed.People who have been developing without issue based on what was default may only find out by surprise after updating and noticing that all of their contracts got recompiled. Others may not even notice it and proceed with deployments. Such an automatic downgrade of EVM version and recompilation may not be welcome.
A version update from 2.17.2 to 2.17.3 appears on the surface to be a bug fix, so most people may not check the change log whenever there are such small patch version number increments.
Also, people who newly install hardhat may want and expect to only use the latest versions of everything and would only accept a downgrade if they must. So such a downgrade would not be welcome for those who use Ethereum or Polygon zkEVM, as the
PUSH0
EVM opcode works fine on those.Maybe there should be a new message about this when users actually do a compile so that they can take action beforehand instead of letting hardhat do an automatic downgrade almost invisibly.
One idea may be to no longer have
evmVersion
optional, so that an error appears, forcing the user to choose which one they really want to use and to add it explicity into hardhat.config.js.Also, it may be good to print the actual solc version and EVM version that is being used when compiling. I show the hardhat solidity settings in my own hardhat-yul repository, e.g.: https://github.com/SKYBITDev3/hardhat-yul/blob/9f842908faef020ed37e36b27edb30a3a5c52e44/src/compilation.ts#L113
The text was updated successfully, but these errors were encountered: