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

Clarify hardhat & foundry configs and enable optimisation by default. #5099

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Jun 26, 2024

Before this PR:

  • Local tests on our machine run in development mode without GAS or COVERAGE (default). This results in:
    • optimization disabled
    • unlimited contract size
  • Non upgradeable tests on the CI set the GAS flag (to produce a report). This results in:
    • optimization enabled
      • code size warning
    • unlimited contract size
  • Coverage tests on the CI set the COVERAGE flag. This results in:
    • optimization enabled
      • code size warning
    • unlimited contract size
    • some additional stuff (unused params, initialBaseFeePerGas)
  • Upgradeable tests do not set any flag. They run in development mode. This results in:
    • optimization disabled
    • unlimited contract size

All this was not necessarily clear. In particular, the fact that by default, out local tests run in a mode that doesnt match the CI (unless we have some .env to override that). Also, setting the IR flag has no effect unless you also enable optimization (either through the production mode, or implicitelly when doing gas or coverage checks)

This PR does the following changes:

  • All compilation is done with optimization. That is what our users should all use in production, so that is what we should test.
  • Make code size unlimited by default. That is what we had previously, but it was "hidden". This PR makes it obvious what is happening here.
  • Gas no longer affect the compiler settings, it only enables/disables the gas module.
  • No changes to the config specific to coverage

Note

  • This PR does not change the compiler settings during CI, so the gas reports continue to be valid.
  • This PR does change the compiler settings when running tests locally.

Copy link

changeset-bot bot commented Jun 26, 2024

⚠️ No Changeset found

Latest commit: 5096311

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Amxx Amxx requested review from frangio, ernestognw and cairoeth June 26, 2024 07:25
Amxx added a commit to Amxx/openzeppelin-contracts that referenced this pull request Jun 26, 2024
Copy link
Member

@ernestognw ernestognw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is way cleaner, thanks! Just left a qustion

hardhat.config.js Show resolved Hide resolved
@cairoeth
Copy link
Contributor

should we also clarify foundry.toml, like the optimizer runs? it has the same default behavior already.

@Amxx Amxx changed the title Clarify hardhat config and enable optimisation by default. Clarify hardhat & foundry configs and enable optimisation by default. Jun 27, 2024
Copy link
Contributor

@cairoeth cairoeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ernestognw ernestognw merged commit 01cae33 into OpenZeppelin:master Jun 27, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants