Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Truffle's default optimizer settings actually have an effect #5441

Open
haltman-at opened this issue Aug 16, 2022 · 0 comments
Open

Truffle's default optimizer settings actually have an effect #5441

haltman-at opened this issue Aug 16, 2022 · 0 comments

Comments

@haltman-at
Copy link
Contributor

haltman-at commented Aug 16, 2022

Issue

When Truffle compiles Solidity, it merges the settings from the Truffle Config into some default settings, those default settings being:

settings: {
  optimizer: {
    enabled: false
    runs: 200
  }
}

Seems harmless, right? Well... turns out that on Solidity versions prior to 0.8.6, having enabled set to false, and having it absent entirely, had different results. Having it set to false, as opposed to absent entirely, actually turned on some optimizations (though evidently not much).

This poses a problem when it comes to contract verification; see discussion on this Blockscout issue. Unfortunately I don't think we can just get rid of this default without potentially breaking things. But we can perhaps discard it in fetch-and-compile specifically. However if we do so, we'll have to update the Etherscan fetcher (and possibly the Sourcify fetcher?) per the linked discussion (like, the Etherscan fetcher will have to convert enabled being absent to it being false; the runs: 200 default may also be necessary).

All of this is basically OK for now, but it will need to be solved if we want to do something about #4779.

Environment

  • Truffle version (truffle version): 5.5.26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant