Skip to content

Compile with solc 0.9.0-pre.1 - #6902

Draft
Amxx wants to merge 4 commits into
OpenZeppelin:next-v6.0from
Amxx:chore/solc-0.9.0-pre.1
Draft

Amxx wants to merge 4 commits into
OpenZeppelin:next-v6.0from
Amxx:chore/solc-0.9.0-pre.1

Conversation

@Amxx

@Amxx Amxx commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Warning

This doesn't work as-is. solc 0.9.0-pre.1 can't be used out of the box: Hardhat needs an update before it supports prerelease compilers (NomicFoundation/hardhat#8887), and forge-std needs one before it accepts 0.9 (foundry-rs/forge-std#952). Until then this PR relies on a local binary and a workaround plugin, and the default build expects solc-linux-amd64-v0.9.0-pre.1+commit.91c99213 in PATH, which CI doesn't have.

Moves next-v6.0 to Solidity 0.9, using 0.9.0-pre.1 until 0.9.0 is released.

Changes

  • Pragmas: every ^0.8.x pragma (contracts, mocks, tests, fv harnesses, generator templates, upgradeable aliases) becomes >0.8.999 <0.10.0. solc can't parse a prerelease tag in a pragma and ranks 0.9.0-pre.1 below 0.9.0, so ^0.9.0 rejects the prerelease. >0.8.999 <0.10.0 means "^0.9.0, prereleases included". It should become ^0.9.0 once 0.9.0 is released. >= pragmas on interfaces are unchanged.
  • hardhat.config.ts: the compiler label defaults to 0.9.0. A new --solc option (absolute path or name looked up in PATH, default solc-linux-amd64-v0.9.0-pre.1+commit.91c99213) sets the compiler path. --solc '' goes back to downloading --compiler.
  • foundry.toml: solc_version = '0.9.0-pre.1'. Foundry downloads prereleases through svm, so no local binary is needed there (CI included).
  • hardhat/hardhat-local-solc (new, temporary): Hardhat's local-binary support fails to parse the --version output of prerelease builds. This plugin handles local binaries through the getCompiler hook, and provides a compileBuildInfo helper for the places that recompile outside the build pipeline.
  • hardhat-exposed, hardhat-yul: use that helper, because hre.solidity.compileBuildInfo always downloads the solc version recorded in the build info and ignores path.
  • scripts/solc-versions.js: latest 0.8 is now 0.8.39, and 0.9.0-pre.1 is added. Prereleases are listed as-is instead of being expanded to every patch.
  • Pragma scripts:
    • scripts/solc-versions.js: new toPragma helper. solc can't parse prerelease tags, so a prerelease minimum is written as a range that includes it (^0.9.0-pre.1 becomes >0.8.999 <0.10.0). New minSatisfyingVersion helper, and satisfies with prereleases included, which matches solc.
    • minimize-pragma.js: implementations now default to a minimum of 0.9.0-pre.1, range pragmas are matched when rewriting, and pragmas are built with toPragma.
    • checks/pragma-validity.js: compiles with the lowest known version accepted by the pragma, instead of semver.minVersion (which gives 0.8.1000 for >0.8.999).
    • get-contracts-metadata.js: reads range pragmas (the AST literals join into >0.8.999<0.10.0).
    • package.json: the pragma and test:pragma builds skip the Foundry tests (--no-tests), which they don't use and which forge-std currently blocks.
  • AccessControl.sol: fix a pre-existing import-order lint error (from Remove Context and ERC-2771 #6717) caught by the pre-commit hook.

Current status

  • npx hardhat build --no-tests compiles all 719 files and generates the exposed contracts with 0.9.0-pre.1. Build info records 0.9.0-pre.1+commit.91c99213.
  • A sample of the JS suite passes with npx hardhat test mocha --no-compile (856 tests: AccessManager, Governor, ERC20, Multicall, ECDSA, SimulatedCall).
  • forge build --skip test --skip script compiles all 383 files with 0.9.0-pre.1.
  • npx hardhat build / npx hardhat test without the flags above fail on the Foundry tests, because forge-std pins <0.9.0.

Blockers toward the 0.9.0 transition

  • Library code compiles with 0.9.0-pre.1 (no source change needed beyond pragmas)
  • Pragmas admit 0.9 (>0.8.999 <0.10.0, this PR)
  • Hardhat can build with a local prerelease binary (workaround plugin, this PR)
  • Exposed-contract and Yul generation use the local binary (this PR)
  • Hardhat supports solc prereleases natively: Support solc prerelease compilers (e.g. 0.9.0-pre.1) NomicFoundation/hardhat#8886, Support solc prereleases NomicFoundation/hardhat#8887. Once released, bump Hardhat and drop hardhat/hardhat-local-solc and --solc.
  • forge-std accepts 0.9: foundry-rs/forge-std#952. Once merged, bump lib/forge-std. This unblocks .t.sol compilation in both Hardhat and Foundry. Foundry itself already handles the prerelease.
  • foundry.toml uses 0.9.0-pre.1, downloaded by Foundry itself (this PR)
  • CI: Hardhat needs the compiler provided (install the prerelease binary, or wait for the Hardhat release above). Foundry needs nothing.
  • Full JS + Foundry + Halmos test suites pass on 0.9
  • Certora: fv/ harnesses and prover config run on 0.9
  • scripts/solc-versions.js lists 0.8.39 and 0.9.0-pre.1 (this PR)
  • Pragma tooling supports 0.9 (this PR): npm run pragma writes >0.8.999 <0.10.0 for prerelease minimums, and npm run test:pragma passes (193 implementation files compiled with 0.9.0-pre.1)
  • Docs and README code examples still use ^0.8.x pragmas
  • solc 0.9.0 release: switch pragmas to ^0.9.0 and the compiler config to the released version

@changeset-bot

changeset-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 01f81ef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Major

Not sure what this means? Click here to learn what changesets are.

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

This branch is waiting to be deployed

1 waiting deployment
certora — 01f81efd Waiting Nov 26, 2026 by Amxx via verify #916
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

Successfully merging this pull request may close these issues.

1 participant