Hardhat version in buildinfo#8123
Conversation
🦋 Changeset detectedLatest commit: 7cd072e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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; |
There was a problem hiding this comment.
Note: We only add this setting to the profiles, and not to every top-level config, as that seems unneeded.
There was a problem hiding this comment.
this was a bad idea, I'm changing it to make it consistent with the other fields.
| * The versions to include in the build info, if any. | ||
| * When present, these versions influence the build id. | ||
| */ | ||
| toolVersions?: ToolVersions; |
There was a problem hiding this comment.
Added this to the CompilationJob because it influences the build info and the build id.
There was a problem hiding this comment.
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/versionsto theSolidityBuildInfotype 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. |
| 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, | ||
| }; |
There was a problem hiding this comment.
I decided to add it to SingleVersionSolidityUserConfig and MultiVersionSolidityUserConfig.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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
toolVersionsInBuildInfoon Solidity build profiles (validated + resolved withproductiondefaulting totrue). - Include
{ hardhat: <version> }inSolidityBuildInfo.versionsand 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. |
There was a problem hiding this comment.
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
toolVersionsInBuildInfoto Solidity user config + build profile schema/types, defaulting totruein theproductionprofile. - Include
{ hardhat: <version> }inSolidityBuildInfo.versionswhen 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; |
There was a problem hiding this comment.
Intentionally optional for backwards compatibility, I'll add a comment
4dd8fed to
455568c
Compare
There was a problem hiding this comment.
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?: booleanacross Solidity config shapes, defaulting totruefor theproductionprofile. - 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. |
schaable
left a comment
There was a problem hiding this comment.
Looks good. I left some minor suggestions. Pre-approving.
| @@ -0,0 +1,7 @@ | |||
| --- | |||
| "hardhat": patch | |||
There was a problem hiding this comment.
This should probably be a minor bump.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Have you considered using toolVersions to match the type and other variables, and to make it more explicit?
There was a problem hiding this comment.
i guess it's a good point
NomicFoundation/hardhat-website#252