Skip to content
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

Tweak optimizer config #1405

Open
fullkomnun opened this issue Mar 5, 2023 · 0 comments
Open

Tweak optimizer config #1405

fullkomnun opened this issue Mar 5, 2023 · 0 comments

Comments

@fullkomnun
Copy link
Contributor

fullkomnun commented Mar 5, 2023

The solc optimizer config can be tweaked using the following properties:

  • Solidity version (current: 0.8.17, latest: 0.8.19)
  • Optimizer enabled (current: true)
  • Yul IR pipeline enabled (current: false)
  • Runs (current: 1 for truffle, 200 for hardhat, range: 1 - 4_294_967_295)
  • Additional optimizer flags (reference, docs)
  • Marking an inline assmebly block with "memory-safe" where applicable
  • Config may be overidden per contract (reference)

These affect the following metrics:

  • Solc compilation time (time npx hardhat compile --force)
  • Contracts deployment size (npx hardhat size-contracts)
  • Contracts deployment gas costs (npm run test)
  • Transaction execution gas costs (npm run test + 'test-gas' CI job)

General rules of thumb:

  • Lower optimizer runs = favors contract sizes and deployment cost over tx exceution costs (and vice versa)
  • Yul ir pipeline increases the compilation time significantly
  • Yul ir pipeline reduces contract sizes and deployment gas costs
  • Yul ir pipeline mostly seem to slightly increase tx execution gas costs
  • Recent hardhat V2.13.0 release has added better support for yul ir pipeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant