Browse Source

Update dependency hardhat-gas-reporter to v2 (#4979)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
renovate[bot] 1 year ago
parent
commit
6f4ebf1190
4 changed files with 328 additions and 471 deletions
  1. 1 0
      hardhat.config.js
  2. 309 457
      package-lock.json
  3. 1 1
      package.json
  4. 17 13
      scripts/checks/compareGasReports.js

+ 1 - 0
hardhat.config.js

@@ -107,6 +107,7 @@ module.exports = {
   gasReporter: {
     enabled: argv.gas,
     showMethodSig: true,
+    includeBytecodeInJSON: true,
     currency: 'USD',
     coinmarketcap: argv.coinmarketcap,
   },

File diff suppressed because it is too large
+ 309 - 457
package-lock.json


+ 1 - 1
package.json

@@ -69,7 +69,7 @@
     "graphlib": "^2.1.8",
     "hardhat": "^2.17.4",
     "hardhat-exposed": "^0.3.14-0",
-    "hardhat-gas-reporter": "^1.0.9",
+    "hardhat-gas-reporter": "^2.0.0",
     "hardhat-ignore-warnings": "^0.2.0",
     "lodash.startcase": "^4.4.0",
     "micromatch": "^4.0.2",

+ 17 - 13
scripts/checks/compareGasReports.js

@@ -49,13 +49,17 @@ class Report {
 
   // Compare two reports
   static compare(update, ref, opts = { hideEqual: true, strictTesting: false }) {
-    if (JSON.stringify(update.config.metadata) !== JSON.stringify(ref.config.metadata)) {
-      throw new Error('Reports produced with non matching metadata');
+    if (JSON.stringify(update.options?.solcInfo) !== JSON.stringify(ref.options?.solcInfo)) {
+      console.warn('WARNING: Reports produced with non matching metadata');
     }
 
-    const deployments = update.info.deployments
+    // gasReporter 1.0.0 uses ".info", but 2.0.0 uses ".data"
+    const updateInfo = update.info ?? update.data;
+    const refInfo = ref.info ?? ref.data;
+
+    const deployments = updateInfo.deployments
       .map(contract =>
-        Object.assign(contract, { previousVersion: ref.info.deployments.find(({ name }) => name === contract.name) }),
+        Object.assign(contract, { previousVersion: refInfo.deployments.find(({ name }) => name === contract.name) }),
       )
       .filter(contract => contract.gasData?.length && contract.previousVersion?.gasData?.length)
       .flatMap(contract => [
@@ -75,18 +79,18 @@ class Report {
       ])
       .sort((a, b) => `${a.contract}:${a.method}`.localeCompare(`${b.contract}:${b.method}`));
 
-    const methods = Object.keys(update.info.methods)
-      .filter(key => ref.info.methods[key])
-      .filter(key => update.info.methods[key].numberOfCalls > 0)
+    const methods = Object.keys(updateInfo.methods)
+      .filter(key => refInfo.methods[key])
+      .filter(key => updateInfo.methods[key].numberOfCalls > 0)
       .filter(
-        key => !opts.strictTesting || update.info.methods[key].numberOfCalls === ref.info.methods[key].numberOfCalls,
+        key => !opts.strictTesting || updateInfo.methods[key].numberOfCalls === refInfo.methods[key].numberOfCalls,
       )
       .map(key => ({
-        contract: ref.info.methods[key].contract,
-        method: ref.info.methods[key].fnSig,
-        min: variation(...[update, ref].map(x => Math.min(...x.info.methods[key].gasData)), BASE_TX_COST),
-        max: variation(...[update, ref].map(x => Math.max(...x.info.methods[key].gasData)), BASE_TX_COST),
-        avg: variation(...[update, ref].map(x => Math.round(average(...x.info.methods[key].gasData))), BASE_TX_COST),
+        contract: refInfo.methods[key].contract,
+        method: refInfo.methods[key].fnSig,
+        min: variation(...[updateInfo, refInfo].map(x => Math.min(...x.methods[key].gasData)), BASE_TX_COST),
+        max: variation(...[updateInfo, refInfo].map(x => Math.max(...x.methods[key].gasData)), BASE_TX_COST),
+        avg: variation(...[updateInfo, refInfo].map(x => Math.round(average(...x.methods[key].gasData))), BASE_TX_COST),
       }))
       .sort((a, b) => `${a.contract}:${a.method}`.localeCompare(`${b.contract}:${b.method}`));
 

Some files were not shown because too many files changed in this diff