feat: show contract runtime bytecode size in the gas stats table and JSON output#8108
Merged
feat: show contract runtime bytecode size in the gas stats table and JSON output#8108
Conversation
🦋 Changeset detectedLatest commit: 5404ac8 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 |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds contract runtime bytecode size reporting to Hardhat’s gas analytics output, exposing it both in the console gas stats table and the --gas-stats-json output to address #8059.
Changes:
- Plumbs
runtimeSizefrom EDR gas reports into Hardhat gas measurements. - Extends gas stats aggregation + JSON schema to include
deployment.runtimeSize. - Updates the gas stats table rendering and tests to display a “Bytecode size” row under deployment stats.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts | Maps EDR deployment runtimeSize into Hardhat deployment gas measurements. |
| packages/hardhat/src/internal/builtin-plugins/gas-analytics/types.ts | Updates measurement/types and JSON output types to include runtimeSize. |
| packages/hardhat/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts | Aggregates/stores deployment runtime size, renders it in the table, emits it in JSON. |
| packages/hardhat/test/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts | Updates and extends tests for the new runtimeSize behavior and table output. |
| .changeset/cold-beers-knock.md | Declares a patch release note for the new output fields/row. |
ChristopherDedominici
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Capture the runtime size of the first deployment and display it as a new row at the bottom of the gas stats table and in the JSON output:
Note: the original issue shows the "Bytecode size" row spanning the full table width (no trailing
│after2294). This isn't currently possible with the existinghardhat-utilstable helper without modifying it, and that change doesn't seem worth the added complexity for this case.{ "contracts": { "contracts/Calculator.sol:Calculator": { "sourceName": "contracts/Calculator.sol", "contractName": "Calculator", "deployment": { // ... other stats "runtimeSize": 2294 }, "functions": { // ... } } // ... } }Docs: NomicFoundation/hardhat-website#246
Closes #8059