Skip to content

Hardhat version in buildinfo#8123

Merged
alcuadrado merged 14 commits into
mainfrom
hardhat-version-in-buildinfo
Apr 13, 2026
Merged

Hardhat version in buildinfo#8123
alcuadrado merged 14 commits into
mainfrom
hardhat-version-in-buildinfo

Conversation

@alcuadrado
Copy link
Copy Markdown
Member

@alcuadrado alcuadrado commented Apr 10, 2026

@alcuadrado alcuadrado requested a review from schaable April 10, 2026 19:14
Copilot AI review requested due to automatic review settings April 10, 2026 19:14
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 10, 2026

🦋 Changeset detected

Latest commit: 7cd072e

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

This PR includes changesets to release 1 package
Name Type
hardhat Patch

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

export type SingleVersionBuildProfileUserConfig =
SolidityCompilerUserConfig & {
isolated?: boolean;
toolVersionsInBuildInfo?: boolean;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note: We only add this setting to the profiles, and not to every top-level config, as that seems unneeded.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this was a bad idea, I'm changing it to make it consistent with the other fields.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

* The versions to include in the build info, if any.
* When present, these versions influence the build id.
*/
toolVersions?: ToolVersions;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added this to the CompilationJob because it influences the build info and the build id.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for recording tool versions (currently Hardhat’s version) in Solidity build info files and makes those versions influence the build ID, with a new toolVersionsInBuildInfo build-profile setting (defaulting to true for the production profile and false otherwise).

Changes:

  • Add ToolVersions/versions to the SolidityBuildInfo type and thread optional tool versions through compilation jobs into build info generation.
  • Include tool versions in the compilation job build-id preimage so cache/build IDs differ when versions are present or change.
  • Add config validation + resolution tests for toolVersionsInBuildInfo, plus integration tests verifying build info contents and build-id differences.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/hardhat/test/internal/builtin-plugins/solidity/config.ts Adds validation/resolution coverage for toolVersionsInBuildInfo defaults and type checking.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/integration/tool-versions.ts New integration tests asserting Hardhat version is included/omitted and affects build IDs.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/compilation-job.ts Extends build-id tests to cover presence/changes of tool versions.
packages/hardhat/src/types/solidity/solidity-artifacts.ts Introduces ToolVersions and adds optional versions to SolidityBuildInfo.
packages/hardhat/src/types/solidity/compilation-job.ts Extends CompilationJob with optional toolVersions.
packages/hardhat/src/internal/builtin-plugins/solidity/type-extensions.ts Adds toolVersionsInBuildInfo to build-profile config/user config typings.
packages/hardhat/src/internal/builtin-plugins/solidity/config.ts Validates and resolves toolVersionsInBuildInfo for build profiles with production defaulting to true.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/{build-system.ts,artifacts.ts,compilation-job.ts} Computes Hardhat version when enabled, passes it into jobs, includes it in build-id preimage and emitted build info JSON.

Comment on lines 486 to 500
function resolveBuildProfileConfig(
solidityConfig:
| SingleVersionSolidityUserConfig
| MultiVersionSolidityUserConfig,
production: boolean = false,
toolVersionsInBuildInfo?: boolean,
): SolidityBuildProfileConfig {
if ("version" in solidityConfig) {
return {
compilers: [resolveSolidityCompilerConfig(solidityConfig, production)],
overrides: {},
isolated: solidityConfig.isolated ?? production,
preferWasm: solidityConfig.preferWasm ?? false,
toolVersionsInBuildInfo: toolVersionsInBuildInfo ?? production,
};
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I decided to add it to SingleVersionSolidityUserConfig and MultiVersionSolidityUserConfig.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 10, 2026 19:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for embedding Hardhat’s version into Solidity build-info files, controlled via a new toolVersionsInBuildInfo flag on Solidity build profiles (defaulting to true for the production profile). This integrates into config validation/resolution, build-id derivation, and build-info generation, with accompanying unit + integration tests.

Changes:

  • Introduce toolVersionsInBuildInfo on Solidity build profiles (validated + resolved with production defaulting to true).
  • Include { hardhat: <version> } in SolidityBuildInfo.versions and incorporate it into compilation job build-id derivation when enabled.
  • Add unit/integration tests covering validation, resolution defaults/overrides, build-info contents, and build-id changes.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/hardhat/test/internal/builtin-plugins/solidity/config.ts Adds validation + resolution test coverage for toolVersionsInBuildInfo defaults and overrides.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/integration/tool-versions.ts New integration tests asserting build-info versions presence/absence and build-id differences.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/compilation-job.ts Extends build-id tests to account for presence/changes of tool versions.
packages/hardhat/src/types/solidity/solidity-artifacts.ts Introduces ToolVersions and adds optional versions to SolidityBuildInfo.
packages/hardhat/src/types/solidity/compilation-job.ts Extends the CompilationJob type with optional toolVersions.
packages/hardhat/src/internal/builtin-plugins/solidity/type-extensions.ts Extends build profile user/resolved config typings to include toolVersionsInBuildInfo.
packages/hardhat/src/internal/builtin-plugins/solidity/config.ts Validates toolVersionsInBuildInfo and resolves it with production-profile defaulting behavior.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts Incorporates tool versions into build-id preimage when present.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts Populates tool versions (Hardhat version) for compilation jobs when enabled by the active build profile.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/artifacts.ts Emits versions into build-info JSON when toolVersions is set on the job.
.changeset/metal-garlics-study.md Adds a patch changeset documenting the new setting and its build-id impact.

Copilot AI review requested due to automatic review settings April 10, 2026 20:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a toolVersionsInBuildInfo setting in Solidity config/build profiles to optionally embed tool version metadata (currently Hardhat’s version) into Solidity build-info files, and to make build-info IDs (build IDs) reflect those tool versions when enabled.

Changes:

  • Add toolVersionsInBuildInfo to Solidity user config + build profile schema/types, defaulting to true in the production profile.
  • Include { hardhat: <version> } in SolidityBuildInfo.versions when enabled and incorporate it into the compilation job build-id preimage.
  • Add config validation/resolution tests and a new integration test ensuring versions are written/omitted and that IDs differ accordingly.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/hardhat/test/internal/builtin-plugins/solidity/config.ts Adds validation + resolution tests for toolVersionsInBuildInfo defaults/overrides.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/integration/tool-versions.ts New integration coverage for build-info versions field and build-id differences.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/compilation-job.ts Extends build-id stability tests to cover toolVersions presence/changes/undefined.
packages/hardhat/src/types/solidity/solidity-artifacts.ts Introduces ToolVersions and adds optional versions to SolidityBuildInfo.
packages/hardhat/src/types/solidity/compilation-job.ts Adds optional toolVersions to the CompilationJob type.
packages/hardhat/src/internal/builtin-plugins/solidity/type-extensions.ts Extends config typing to include the new setting across relevant config variants.
packages/hardhat/src/internal/builtin-plugins/solidity/config.ts Validates/parses the new flag and resolves defaults (production defaults to true).
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts Incorporates tool versions into build-id preimage when provided.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts Populates toolVersions (Hardhat version) for a build when enabled by profile.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/artifacts.ts Writes versions into build-info JSON when tool versions are present.
packages/hardhat-solx/src/type-extensions.ts Updates plugin type extension to use CommonSingleVersionSolidityUserConfig.
.peer-bumps.json Records peer-bump rationale for @nomicfoundation/hardhat-solx due to new type.
.changeset/metal-garlics-study.md Documents the new setting + impact on build-info IDs.

export interface SolidityBuildProfileConfig {
isolated: boolean;
preferWasm: boolean;
toolVersionsInBuildInfo?: boolean;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Intentionally optional for backwards compatibility, I'll add a comment

@alcuadrado alcuadrado force-pushed the hardhat-version-in-buildinfo branch from 4dd8fed to 455568c Compare April 10, 2026 20:33
Copilot AI review requested due to automatic review settings April 10, 2026 20:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an opt-in/opt-out mechanism to embed tool version metadata into Solidity Build Info files, and makes this enabled by default for the production build profile to improve build provenance/reproducibility.

Changes:

  • Introduces toolVersionsInBuildInfo?: boolean across Solidity config shapes, defaulting to true for the production profile.
  • Includes Hardhat’s version in Build Info output (and in the build ID preimage when enabled).
  • Adds validation, resolution, unit/integration tests, and updates plugin type extensions + peer bump metadata.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/hardhat/test/internal/builtin-plugins/solidity/config.ts Adds validation + resolution tests for toolVersionsInBuildInfo defaults/overrides.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/integration/tool-versions.ts New integration coverage asserting Build Info versions presence/absence and build id changes.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/compilation-job.ts Extends build-id stability tests to cover tool versions affecting the build id.
packages/hardhat/src/types/solidity/solidity-artifacts.ts Adds ToolVersions type and optional versions field to SolidityBuildInfo.
packages/hardhat/src/types/solidity/compilation-job.ts Extends CompilationJob with optional toolVersions used for build id + build info emission.
packages/hardhat/src/internal/builtin-plugins/solidity/type-extensions.ts Updates config typing, introducing CommonSingleVersionSolidityUserConfig and wiring toolVersionsInBuildInfo.
packages/hardhat/src/internal/builtin-plugins/solidity/config.ts Adds Zod validation and config resolution defaults for toolVersionsInBuildInfo.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts Includes versions in build id preimage when tool versions are provided.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts Computes { hardhat: <version> } once per build when enabled and passes into compilation jobs.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/artifacts.ts Emits versions into the Build Info JSON when present.
packages/hardhat-solx/src/type-extensions.ts Updates plugin config typing to extend the new CommonSingleVersionSolidityUserConfig.
.peer-bumps.json Records a peer bump rationale for @nomicfoundation/hardhat-solx due to the new shared config type.
.changeset/metal-garlics-study.md Documents the new setting and notes the resulting build info id changes.

Copy link
Copy Markdown
Member

@schaable schaable left a comment

Choose a reason for hiding this comment

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

Looks good. I left some minor suggestions. Pre-approving.

@@ -0,0 +1,7 @@
---
"hardhat": patch
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should probably be a minor bump.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. The next release will be a patch because of the split compilation PRs, so I think this one doesn't matter that much though

* Not present if the build profile used to create this build info
* had `toolVersionsInBuildInfo` as `false`.
*/
readonly versions?: ToolVersions;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have you considered using toolVersions to match the type and other variables, and to make it more explicit?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i guess it's a good point

@alcuadrado alcuadrado enabled auto-merge April 13, 2026 20:43
@alcuadrado alcuadrado added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit e409958 Apr 13, 2026
222 checks passed
@alcuadrado alcuadrado deleted the hardhat-version-in-buildinfo branch April 13, 2026 21:00
@github-actions github-actions Bot mentioned this pull request Apr 13, 2026
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.

3 participants