9

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.

Max
  • 636
  • 4
  • 15

1 Answers1

14

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.

Edmund Edgar
  • 16,897
  • 1
  • 29
  • 58