7

I found that when I had "Enable optimization" activated while writing a very simple contract with browser Solidity, it reduced a total of two SSTORE opcodes to one. That resulted in 5000 gas saved.

Are these kinds of results typical? Are there any trade offs? Is there any reason not to have "Enable optimization" ticked?

Thanks.

9

The downside is that optimization adds extra complexity, and more complexity means more bugs. See this post for a previous bug in the optimizer: https://blog.ethereum.org/2017/05/03/solidity-optimizer-bug/

Solidity bugs can be rather terrifying: If the EVM is buggy we may be able to upgrade the network to fix it, but it's not clear that there's anything we could do if we discovered that a solc bug had resulted in deployed contracts being insecure. So if your application has a low tolerence of bugs, or the saving made by the optimizer is small, there's a case for leaving it off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.