Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/NomicFoundation/hardhat int…
Browse files Browse the repository at this point in the history
…o bug/1568-negative-block-number-queried-when-forked-network-block-number-is-near-zero
  • Loading branch information
ChristopherDedominici committed Jul 11, 2023
2 parents 681bd99 + ff0abb3 commit 17e4552
Show file tree
Hide file tree
Showing 18 changed files with 385 additions and 55 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-shrimps-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Fixed an issue in the compilation pipeline where a valid build-info file was mistakenly deleted
2 changes: 0 additions & 2 deletions docs/src/content/hardhat-network-helpers/docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ Parameters:

- `prevRandao`: The new PREVRANDAO value to use.

## Other helpers

### `reset([url], [blockNumber])`

Resets the Hardhat Network. The result of calling this method depends on which arguments are provided:
Expand Down
161 changes: 118 additions & 43 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,18 @@
resolved "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz"
integrity sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==

"@eslint-community/eslint-utils@^4.2.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==
dependencies:
eslint-visitor-keys "^3.3.0"

"@eslint-community/regexpp@^4.4.0":
version "4.5.1"
resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.5.1.tgz#cdd35dce4fa1a89a4fd42b1599eb35b3af408884"
integrity sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==

"@eslint/eslintrc@^1.2.0":
version "1.2.0"
resolved "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.0.tgz"
Expand Down Expand Up @@ -3009,6 +3021,11 @@
resolved "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz"
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==

"@types/semver@^7.3.12":
version "7.5.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.0.tgz#591c1ce3a702c45ee15f47a42ade72c2fd78978a"
integrity sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==

"@types/source-list-map@*":
version "0.1.2"
resolved "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz"
Expand Down Expand Up @@ -3076,19 +3093,20 @@
dependencies:
"@types/yargs-parser" "*"

"@typescript-eslint/eslint-plugin@^5.16.0":
version "5.16.0"
resolved "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.16.0.tgz"
integrity sha512-SJoba1edXvQRMmNI505Uo4XmGbxCK9ARQpkvOd00anxzri9RNQk0DDCxD+LIl+jYhkzOJiOMMKYEHnHEODjdCw==
dependencies:
"@typescript-eslint/scope-manager" "5.16.0"
"@typescript-eslint/type-utils" "5.16.0"
"@typescript-eslint/utils" "5.16.0"
debug "^4.3.2"
functional-red-black-tree "^1.0.1"
ignore "^5.1.8"
regexpp "^3.2.0"
semver "^7.3.5"
"@typescript-eslint/eslint-plugin@5.61.0":
version "5.61.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.61.0.tgz#a1a5290cf33863b4db3fb79350b3c5275a7b1223"
integrity sha512-A5l/eUAug103qtkwccSCxn8ZRwT+7RXWkFECdA4Cvl1dOlDUgTpAOfSEElZn2uSUxhdDpnCdetrf0jvU4qrL+g==
dependencies:
"@eslint-community/regexpp" "^4.4.0"
"@typescript-eslint/scope-manager" "5.61.0"
"@typescript-eslint/type-utils" "5.61.0"
"@typescript-eslint/utils" "5.61.0"
debug "^4.3.4"
graphemer "^1.4.0"
ignore "^5.2.0"
natural-compare-lite "^1.4.0"
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/experimental-utils@^5.3.0":
Expand All @@ -3098,7 +3116,17 @@
dependencies:
"@typescript-eslint/utils" "5.13.0"

"@typescript-eslint/parser@^5.0.0", "@typescript-eslint/parser@^5.16.0":
"@typescript-eslint/parser@5.61.0":
version "5.61.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.61.0.tgz#7fbe3e2951904bb843f8932ebedd6e0635bffb70"
integrity sha512-yGr4Sgyh8uO6fSi9hw3jAFXNBHbCtKKFMdX2IkT3ZqpKmtAq3lHS4ixB/COFuAIJpwl9/AqF7j72ZDWYKmIfvg==
dependencies:
"@typescript-eslint/scope-manager" "5.61.0"
"@typescript-eslint/types" "5.61.0"
"@typescript-eslint/typescript-estree" "5.61.0"
debug "^4.3.4"

"@typescript-eslint/parser@^5.0.0":
version "5.16.0"
resolved "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.16.0.tgz"
integrity sha512-fkDq86F0zl8FicnJtdXakFs4lnuebH6ZADDw6CYQv0UZeIjHvmEw87m9/29nk2Dv5Lmdp0zQ3zDQhiMWQf/GbA==
Expand All @@ -3124,13 +3152,22 @@
"@typescript-eslint/types" "5.16.0"
"@typescript-eslint/visitor-keys" "5.16.0"

"@typescript-eslint/type-utils@5.16.0":
version "5.16.0"
resolved "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.16.0.tgz"
integrity sha512-SKygICv54CCRl1Vq5ewwQUJV/8padIWvPgCxlWPGO/OgQLCijY9G7lDu6H+mqfQtbzDNlVjzVWQmeqbLMBLEwQ==
"@typescript-eslint/scope-manager@5.61.0":
version "5.61.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.61.0.tgz#b670006d069c9abe6415c41f754b1b5d949ef2b2"
integrity sha512-W8VoMjoSg7f7nqAROEmTt6LoBpn81AegP7uKhhW5KzYlehs8VV0ZW0fIDVbcZRcaP3aPSW+JZFua+ysQN+m/Nw==
dependencies:
"@typescript-eslint/utils" "5.16.0"
debug "^4.3.2"
"@typescript-eslint/types" "5.61.0"
"@typescript-eslint/visitor-keys" "5.61.0"

"@typescript-eslint/type-utils@5.61.0":
version "5.61.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.61.0.tgz#e90799eb2045c4435ea8378cb31cd8a9fddca47a"
integrity sha512-kk8u//r+oVK2Aj3ph/26XdH0pbAkC2RiSjUYhKD+PExemG4XSjpGFeyZ/QM8lBOa7O8aGOU+/yEbMJgQv/DnCg==
dependencies:
"@typescript-eslint/typescript-estree" "5.61.0"
"@typescript-eslint/utils" "5.61.0"
debug "^4.3.4"
tsutils "^3.21.0"

"@typescript-eslint/types@5.13.0":
Expand All @@ -3143,6 +3180,11 @@
resolved "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.16.0.tgz"
integrity sha512-oUorOwLj/3/3p/HFwrp6m/J2VfbLC8gjW5X3awpQJ/bSG+YRGFS4dpsvtQ8T2VNveV+LflQHjlLvB6v0R87z4g==

"@typescript-eslint/types@5.61.0":
version "5.61.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.61.0.tgz#e99ff11b5792d791554abab0f0370936d8ca50c0"
integrity sha512-ldyueo58KjngXpzloHUog/h9REmHl59G1b3a5Sng1GfBo14BkS3ZbMEb3693gnP1k//97lh7bKsp6/V/0v1veQ==

"@typescript-eslint/typescript-estree@5.13.0":
version "5.13.0"
resolved "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.13.0.tgz"
Expand All @@ -3169,6 +3211,19 @@
semver "^7.3.5"
tsutils "^3.21.0"

"@typescript-eslint/typescript-estree@5.61.0":
version "5.61.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.61.0.tgz#4c7caca84ce95bb41aa585d46a764bcc050b92f3"
integrity sha512-Fud90PxONnnLZ36oR5ClJBLTLfU4pIWBmnvGwTbEa2cXIqj70AEDEmOmpkFComjBZ/037ueKrOdHuYmSFVD7Rw==
dependencies:
"@typescript-eslint/types" "5.61.0"
"@typescript-eslint/visitor-keys" "5.61.0"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/utils@5.13.0":
version "5.13.0"
resolved "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.13.0.tgz"
Expand All @@ -3181,17 +3236,19 @@
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"

"@typescript-eslint/utils@5.16.0":
version "5.16.0"
resolved "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.16.0.tgz"
integrity sha512-iYej2ER6AwmejLWMWzJIHy3nPJeGDuCqf8Jnb+jAQVoPpmWzwQOfa9hWVB8GIQE5gsCv/rfN4T+AYb/V06WseQ==
"@typescript-eslint/utils@5.61.0":
version "5.61.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.61.0.tgz#5064838a53e91c754fffbddd306adcca3fe0af36"
integrity sha512-mV6O+6VgQmVE6+xzlA91xifndPW9ElFW8vbSF0xCT/czPXVhwDewKila1jOyRwa9AE19zKnrr7Cg5S3pJVrTWQ==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@types/json-schema" "^7.0.9"
"@typescript-eslint/scope-manager" "5.16.0"
"@typescript-eslint/types" "5.16.0"
"@typescript-eslint/typescript-estree" "5.16.0"
"@types/semver" "^7.3.12"
"@typescript-eslint/scope-manager" "5.61.0"
"@typescript-eslint/types" "5.61.0"
"@typescript-eslint/typescript-estree" "5.61.0"
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"
semver "^7.3.7"

"@typescript-eslint/visitor-keys@5.13.0":
version "5.13.0"
Expand All @@ -3209,6 +3266,14 @@
"@typescript-eslint/types" "5.16.0"
eslint-visitor-keys "^3.0.0"

"@typescript-eslint/visitor-keys@5.61.0":
version "5.61.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.61.0.tgz#c79414fa42158fd23bd2bb70952dc5cdbb298140"
integrity sha512-50XQ5VdbWrX06mQXhy93WywSFZZGsv3EOjq+lqp6WC2t+j3mb6A9xYVdrRxafvK88vg9k9u+CT4l6D8PEatjKg==
dependencies:
"@typescript-eslint/types" "5.61.0"
eslint-visitor-keys "^3.3.0"

"@usulpro/react-json-view@^2.0.1":
version "2.0.1"
resolved "https://registry.npmjs.org/@usulpro/react-json-view/-/react-json-view-2.0.1.tgz"
Expand Down Expand Up @@ -5159,7 +5224,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
dependencies:
ms "2.0.0"

debug@4:
debug@4, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
Expand Down Expand Up @@ -6740,7 +6805,7 @@ globalthis@^1.0.0:
dependencies:
define-properties "^1.1.3"

globby@^11.0.2, globby@^11.0.4:
globby@^11.0.2, globby@^11.0.4, globby@^11.1.0:
version "11.1.0"
resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz"
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==
Expand Down Expand Up @@ -6771,6 +6836,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6
resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz"
integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==

graphemer@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6"
integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==

gray-matter@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-4.0.3.tgz#e893c064825de73ea1f5f7d88c7a9f7274288798"
Expand Down Expand Up @@ -7203,7 +7273,7 @@ ignore@^4.0.3, ignore@^4.0.6:
resolved "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==

ignore@^5.1.8, ignore@^5.2.0:
ignore@^5.2.0:
version "5.2.0"
resolved "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz"
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
Expand Down Expand Up @@ -9268,6 +9338,11 @@ nanomatch@^1.2.9:
snapdragon "^0.8.1"
to-regex "^3.0.1"

natural-compare-lite@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4"
integrity sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==

natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
Expand Down Expand Up @@ -11218,24 +11293,24 @@ section-matter@^1.0.0:
kind-of "^6.0.0"

"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.6.0:
version "5.7.1"
resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
version "5.7.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==

semver@7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==

semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0:
version "6.3.0"
resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.3.2, semver@^7.3.4, semver@^7.3.5:
version "7.3.5"
resolved "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz"
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
version "6.3.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"

Expand Down
10 changes: 1 addition & 9 deletions packages/hardhat-core/src/internal/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,6 @@ export class Artifacts implements IArtifacts {
const buildInfoFile = await this._getBuildInfoFromDebugFile(debugFile);
if (buildInfoFile !== undefined) {
return path.resolve(path.dirname(debugFile), buildInfoFile);
} else {
return undefined;
}
})
);
Expand Down Expand Up @@ -859,20 +857,14 @@ Please replace "${contractName}" for the correct contract name wherever you are
}

/**
* Remove the artifact file, its debug file and, if it exists, its build
* info file.
* Remove the artifact file and its debug file.
*/
private async _removeArtifactFiles(artifactPath: string) {
await fsExtra.remove(artifactPath);

const debugFilePath = this._getDebugFilePath(artifactPath);
const buildInfoPath = await this._getBuildInfoFromDebugFile(debugFilePath);

await fsExtra.remove(debugFilePath);

if (buildInfoPath !== undefined) {
await fsExtra.remove(buildInfoPath);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,32 @@ export class ConsoleLogger {
return;
}

return this._decode(parameters, types);
const consoleLogs = this._decode(parameters, types);

this._replaceNumberFormatSpecifiers(consoleLogs);

return consoleLogs;
}

private _replaceNumberFormatSpecifiers(consoleLogs: ConsoleLogs) {
/**
* Replace the occurrences of %d and %i with %s. This is necessary because if the arguments passed are numbers,
* they could be too large to be formatted as a Number or an Integer, so it is safer to use a String.
* %d and %i are replaced only if there is an odd number of % before the d or i.
* If there is an even number of % then it is assumed that the % is escaped and should not be replaced.
* The regex matches a '%d' or an '%i' that has an even number of
* '%' behind it (including 0). This group of pairs of '%' is captured
* and preserved, while the '%[di]' is replaced with '%s'.
* Naively doing (%%)* is not enough; we also have to use the
* (?<!%) negative look-behind to make this work.
* The (?:) is just to avoid capturing that inner group.
*/
if (consoleLogs.length > 0 && typeof consoleLogs[0] === "string") {
consoleLogs[0] = consoleLogs[0].replace(
/((?<!%)(?:%%)*)(%[di])/g,
"$1%s"
);
}
}

private _decode(data: Buffer, types: string[]): ConsoleLogs {
Expand Down
Loading

0 comments on commit 17e4552

Please sign in to comment.