{"id":18592,"date":"2026-03-24T00:09:06","date_gmt":"2026-03-24T00:09:06","guid":{"rendered":"https:\/\/cryptoted.net\/index.php\/2026\/03\/24\/solidity-optimizer-bug-ethereum-foundation-blog\/"},"modified":"2026-03-24T00:09:06","modified_gmt":"2026-03-24T00:09:06","slug":"solidity-optimizer-bug-ethereum-foundation-blog","status":"publish","type":"post","link":"https:\/\/cryptoted.net\/index.php\/2026\/03\/24\/solidity-optimizer-bug-ethereum-foundation-blog\/","title":{"rendered":"Solidity optimizer bug | Ethereum Foundation Blog"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div id=\"\">\n<p class=\"chakra-text css-gi02ar\">A bug in the Solidity optimizer was reported through the <a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-vezwxf\" href=\"https:\/\/bounty.ethereum.org\/\">Ethereum Foundation Bounty program<\/a>, by Christoph Jentzsch. This bug is patched as of 2017-05-03, with the release of Solidity 0.4.11.<\/p>\n<h3 class=\"chakra-heading group css-xuzltg\" id=\"background\" data-group=\"true\"><a class=\"chakra-link css-128fqrf\" aria-label=\"background permalink\" href=\"#background\"><svg viewbox=\"0 0 24 24\" focusable=\"false\" class=\"chakra-icon css-173jpr1\"><g fill=\"currentColor\"><path d=\"M10.458,18.374,7.721,21.11a2.853,2.853,0,0,1-3.942,0l-.892-.891a2.787,2.787,0,0,1,0-3.941l5.8-5.8a2.789,2.789,0,0,1,3.942,0l.893.892A1,1,0,0,0,14.94,9.952l-.893-.892a4.791,4.791,0,0,0-6.771,0l-5.8,5.8a4.787,4.787,0,0,0,0,6.77l.892.891a4.785,4.785,0,0,0,6.771,0l2.736-2.735a1,1,0,1,0-1.414-1.415Z\"\/><path d=\"M22.526,2.363l-.892-.892a4.8,4.8,0,0,0-6.77,0l-2.905,2.9a1,1,0,0,0,1.414,1.414l2.9-2.9a2.79,2.79,0,0,1,3.941,0l.893.893a2.786,2.786,0,0,1,0,3.942l-5.8,5.8a2.769,2.769,0,0,1-1.971.817h0a2.766,2.766,0,0,1-1.969-.816,1,1,0,1,0-1.415,1.412,4.751,4.751,0,0,0,3.384,1.4h0a4.752,4.752,0,0,0,3.385-1.4l5.8-5.8a4.786,4.786,0,0,0,0-6.771Z\"\/><\/g><\/svg><\/a>Background<\/h3>\n<p class=\"chakra-text css-gi02ar\">The bug in question concerned how the optimizer optimizes on constants in the byte code. By &#8220;byte code constants&#8221;, we mean anything which is <span class=\"chakra-text css-ons8vw\">PUSH<\/span>ed on the stack (not to be confused with Solidity constants). For example, if the value <span class=\"chakra-text css-ons8vw\">0xfffffffffffffffffffffffffffffffffffffffffffffffe<\/span> is <span class=\"chakra-text css-ons8vw\">PUSH<\/span>ed, then the optimizer can either do <span class=\"chakra-text css-ons8vw\">PUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffe<\/span>, or choose to encode this as <span class=\"chakra-text css-ons8vw\">PUSH1 1; NOT;<\/span>.<\/p>\n<p class=\"chakra-text css-gi02ar\">An error in the optimizer made optimizations of byte code constants fail for certain cases by producing a routine that did not properly recreate the original constant.<\/p>\n<p class=\"chakra-text css-gi02ar\">The behavior described in the reported bug was found in a contract in which one method ceased functioning when another &#8211; totally unrelated &#8211; method was added to the contract. After analysis, it was determined that a number of conditions must exist at once for the bug to trigger. Any combination of conditions that would trigger the bug would consistently have the following two conditions:<\/p>\n<ol role=\"list\" class=\"css-vgl4zd\">\n<li class=\"css-0\">The constant needs to start with <span class=\"chakra-text css-ons8vw\">0xFF&#8230;<\/span> and end with a long series of zeroes (or vice versa).<\/li>\n<li class=\"css-0\">The same constant needs to be used in multiple locations, for the optimizer to choose to optimize this particular constant. Alternatively, it needs to be used in the constructor, which optimises for size rather than gas.<\/li>\n<\/ol>\n<p class=\"chakra-text css-gi02ar\">In addition to the two conditions above, there are further, more complicated conditions that are required.<\/p>\n<h2 class=\"chakra-heading group css-1kpzc4q\" id=\"analysis\" data-group=\"true\"><a class=\"chakra-link css-128fqrf\" aria-label=\"analysis permalink\" href=\"#analysis\"><svg viewbox=\"0 0 24 24\" focusable=\"false\" class=\"chakra-icon css-173jpr1\"><g fill=\"currentColor\"><path d=\"M10.458,18.374,7.721,21.11a2.853,2.853,0,0,1-3.942,0l-.892-.891a2.787,2.787,0,0,1,0-3.941l5.8-5.8a2.789,2.789,0,0,1,3.942,0l.893.892A1,1,0,0,0,14.94,9.952l-.893-.892a4.791,4.791,0,0,0-6.771,0l-5.8,5.8a4.787,4.787,0,0,0,0,6.77l.892.891a4.785,4.785,0,0,0,6.771,0l2.736-2.735a1,1,0,1,0-1.414-1.415Z\"\/><path d=\"M22.526,2.363l-.892-.892a4.8,4.8,0,0,0-6.77,0l-2.905,2.9a1,1,0,0,0,1.414,1.414l2.9-2.9a2.79,2.79,0,0,1,3.941,0l.893.893a2.786,2.786,0,0,1,0,3.942l-5.8,5.8a2.769,2.769,0,0,1-1.971.817h0a2.766,2.766,0,0,1-1.969-.816,1,1,0,1,0-1.415,1.412,4.751,4.751,0,0,0,3.384,1.4h0a4.752,4.752,0,0,0,3.385-1.4l5.8-5.8a4.786,4.786,0,0,0,0-6.771Z\"\/><\/g><\/svg><\/a>Analysis<\/h2>\n<p class=\"chakra-text css-gi02ar\">This bug is present in all released versions of Solidity from at least as far back as summer 2015 to the present. Although the bug has been present since 2015, it seems very hard to trigger by \u201crandom\u201d code:<\/p>\n<p class=\"chakra-text css-gi02ar\">We performed a static analysis of all contract code deployed on the blockchain, and found no occurrence of such an invalidly generated routine. Note, the fact that we have not found a bug in all the contract code does not guarantee the absence of such occurrences.<\/p>\n<h2 class=\"chakra-heading group css-1kpzc4q\" id=\"improvements\" data-group=\"true\"><a class=\"chakra-link css-128fqrf\" aria-label=\"improvements permalink\" href=\"#improvements\"><svg viewbox=\"0 0 24 24\" focusable=\"false\" class=\"chakra-icon css-173jpr1\"><g fill=\"currentColor\"><path d=\"M10.458,18.374,7.721,21.11a2.853,2.853,0,0,1-3.942,0l-.892-.891a2.787,2.787,0,0,1,0-3.941l5.8-5.8a2.789,2.789,0,0,1,3.942,0l.893.892A1,1,0,0,0,14.94,9.952l-.893-.892a4.791,4.791,0,0,0-6.771,0l-5.8,5.8a4.787,4.787,0,0,0,0,6.77l.892.891a4.785,4.785,0,0,0,6.771,0l2.736-2.735a1,1,0,1,0-1.414-1.415Z\"\/><path d=\"M22.526,2.363l-.892-.892a4.8,4.8,0,0,0-6.77,0l-2.905,2.9a1,1,0,0,0,1.414,1.414l2.9-2.9a2.79,2.79,0,0,1,3.941,0l.893.893a2.786,2.786,0,0,1,0,3.942l-5.8,5.8a2.769,2.769,0,0,1-1.971.817h0a2.766,2.766,0,0,1-1.969-.816,1,1,0,1,0-1.415,1.412,4.751,4.751,0,0,0,3.384,1.4h0a4.752,4.752,0,0,0,3.385-1.4l5.8-5.8a4.786,4.786,0,0,0,0-6.771Z\"\/><\/g><\/svg><\/a>Improvements<\/h2>\n<p class=\"chakra-text css-gi02ar\">In order to provide better transparency and increased awareness of bugs in Solidity, we have started exporting information about Solidity-related vulnerabilities as JSON-files in the Solidity code repository(<a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-vezwxf\" href=\"https:\/\/github.com\/ethereum\/solidity\/blob\/develop\/docs\/bugs.json\">1<\/a>,<a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-vezwxf\" href=\"https:\/\/github.com\/ethereum\/solidity\/blob\/develop\/docs\/bugs_by_version.json\">2<\/a>). We hope that block explorers will integrate this information along with other contract-related information.<\/p>\n<p class=\"chakra-text css-gi02ar\">Etherscan has already implemented this, which can be seen <a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-vezwxf\" href=\"https:\/\/etherscan.io\/address\/0x83b5c924b74e0dc12386fa110c28faa1efedb07b#code\">here<\/a> and <a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-vezwxf\" href=\"https:\/\/etherscan.io\/contractsVerified\">here<\/a>.<\/p>\n<p class=\"chakra-text css-gi02ar\">Concerning the bug itself, we added a mini-EVM to the optimizer which verifies the correctness of each generated routine at compile time.<\/p>\n<p class=\"chakra-text css-gi02ar\">Furthermore, work has already started on a fully-specified and more high-level intermediate language. Future optimizer routines on this language will be much easier to understand and audit and it will replace the current optimizer.<\/p>\n<\/div>\n<p><br \/>\n<br \/><a href=\"https:\/\/blog.ethereum.org\/en\/2017\/05\/03\/solidity-optimizer-bug\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A bug in the Solidity optimizer was reported through the Ethereum Foundation Bounty program, by Christoph Jentzsch. This bug is patched as of 2017-05-03, with the release of Solidity 0.4.11. Background The bug in question concerned how the optimizer optimizes on constants in the byte code. By &#8220;byte code constants&#8221;, we mean anything which is [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":18498,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"tdm_status":"","tdm_grid_status":"","footnotes":""},"categories":[24],"tags":[],"kronos_expire_date":[],"class_list":["post-18592","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ethereum"],"_links":{"self":[{"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/posts\/18592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/comments?post=18592"}],"version-history":[{"count":0,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/posts\/18592\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/media\/18498"}],"wp:attachment":[{"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/media?parent=18592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/categories?post=18592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/tags?post=18592"},{"taxonomy":"kronos_expire_date","embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/kronos_expire_date?post=18592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}