From 80f461d173a4e19da1042e14edc18d07457781fd Mon Sep 17 00:00:00 2001 From: John Kane Date: Mon, 23 Nov 2026 12:51:19 +0000 Subject: [PATCH 1/6] build: upgrade to EDR v0.26.0 --- packages/hardhat/package.json | 2 +- pnpm-lock.yaml | 66 +++++++++++++++++------------------ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/hardhat/package.json b/packages/hardhat/package.json index 0fae935dd85..48413ab5ee7 100644 --- a/packages/hardhat/package.json +++ b/packages/hardhat/package.json @@ -95,7 +95,7 @@ "typescript": "~6.0.3" }, "dependencies": { - "@nomicfoundation/edr": "0.25.1", + "@nomicfoundation/edr": "0.26.0", "@nomicfoundation/hardhat-errors": "workspace:^3.1.3", "@nomicfoundation/hardhat-utils": "workspace:^5.1.1", "@nomicfoundation/hardhat-vendored": "workspace:^3.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a1f5c29bec5..48906417fdf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -329,8 +329,8 @@ importers: packages/hardhat: dependencies: '@nomicfoundation/edr': - specifier: 0.25.1 - version: 0.25.1 + specifier: 0.26.0 + version: 0.26.0 '@nomicfoundation/hardhat-errors': specifier: workspace:^3.1.3 version: link:../hardhat-errors @@ -2961,54 +2961,54 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@nomicfoundation/edr-darwin-arm64@0.25.1': - resolution: {integrity: sha512-ywk18Qzbrr9blWxfP9NGvCMnpqV7hHdHP1GYqNEuImA3550mpTvnmQLPO1r3a2KffHsmuyQPBbf658JLoS57ww==} + '@nomicfoundation/edr-darwin-arm64@0.26.0': + resolution: {integrity: sha512-FgK0BmUtWXX6K16I41hgS6s3MXxFxMRWZIbP1iWbKzYNSP2k5ukYatLiUWZefCBfm2krKBMhm0RKEzBc6+p+jw==} engines: {node: '>= 22'} cpu: [arm64] os: [darwin] - '@nomicfoundation/edr-darwin-x64@0.25.1': - resolution: {integrity: sha512-Wcl2P1U4+UiMKFomEM8ATZeUAIQswcMwrPN0E0fLBdSp2/k5y2l59Y1hqFPS/wwS7kfBpRvUPNBGh1hH6KKOLQ==} + '@nomicfoundation/edr-darwin-x64@0.26.0': + resolution: {integrity: sha512-19JR69RN/ey5ACVG/q88vA2IGRES3pqVNwTjcP78Ekc//AtxfBuxD1kTRKuYv5ikfAGhhGKjzakcCNt5cXQ7lg==} engines: {node: '>= 22'} cpu: [x64] os: [darwin] - '@nomicfoundation/edr-linux-arm64-gnu@0.25.1': - resolution: {integrity: sha512-oss7sbqksybp03RSZLsmv9GEKeA4+OwGdUxXoPsSewztRE66aPWjgMVEANtLpB7291WxWZHpmhQnSoCgO/us9w==} + '@nomicfoundation/edr-linux-arm64-gnu@0.26.0': + resolution: {integrity: sha512-oQAuKsfQEzrQ7pRvCRvr3nb5xTL/z3ODk/T9J6qr6GvCsCX9Kj5OvpyQmCYTGJktWhOSeWdg3V53EDLU6U9BzA==} engines: {node: '>= 22'} cpu: [arm64] os: [linux] libc: [glibc] - '@nomicfoundation/edr-linux-arm64-musl@0.25.1': - resolution: {integrity: sha512-+6r+ykQfLXDCSEaomx56M97QLNxcKoKrWVliN3bpG11hw52ASngi6z31Z0/JBl5GHfsAtuUmVWk8KnUucXhFFw==} + '@nomicfoundation/edr-linux-arm64-musl@0.26.0': + resolution: {integrity: sha512-Dx5SxM4R3UWaSRNZEjS2Q/DzDSThj33tWg3IplJPRsiuONKqUK6puHBzXLFnOJqUjYzI3P6uRy4xWzW8BjBfcw==} engines: {node: '>= 22'} cpu: [arm64] os: [linux] libc: [musl] - '@nomicfoundation/edr-linux-x64-gnu@0.25.1': - resolution: {integrity: sha512-xo3yaYosl66AHs3VoQ+nTybaICiTf5x9TwTwuHkHYbsd6I9HWSp4bAk6JLTDQgV+l3VxQ54s1tElXmT6bUQX+Q==} + '@nomicfoundation/edr-linux-x64-gnu@0.26.0': + resolution: {integrity: sha512-9Mh3Niq/CzVQOebB67z+dVFtlrQTggdvTD0V1hgpyjC1STKDXq06JzIoklbCbDoPXXzXteWa8iUhnwjeB49COw==} engines: {node: '>= 22'} cpu: [x64] os: [linux] libc: [glibc] - '@nomicfoundation/edr-linux-x64-musl@0.25.1': - resolution: {integrity: sha512-gz/FHo8/t4qd2bH21aPh2JPvSwvgMQBQO+6AJ8SufamjyxsUlFxW8fM6lTfwNXYfYT8+82hYl1/HdvgxkutDkA==} + '@nomicfoundation/edr-linux-x64-musl@0.26.0': + resolution: {integrity: sha512-/IX6Dt8YROp0lX8URcLkWrhxdTLMi8eZZTdp1AQf6hFwW1Q72epKCrz86pscfyhVrX33ccYWiDe1PlxRFQAj4Q==} engines: {node: '>= 22'} cpu: [x64] os: [linux] libc: [musl] - '@nomicfoundation/edr-win32-x64-msvc@0.25.1': - resolution: {integrity: sha512-VDVWK4GITq9Udzf7zGLJLw01YJoje3hLC9j8n+0fP4cVIEKYwVtY3/iyQ9zbUDD7p3Gz0cE9rtlYDlyIu5TFwA==} + '@nomicfoundation/edr-win32-x64-msvc@0.26.0': + resolution: {integrity: sha512-Fqnpqf2z4GKyXDWqJfDYUYyDsWkuLCJ0cdJ7t93OT3A5PooNixtpI8um9HM8yHkqxPeel9Ruy8vvcIcBEXgoIw==} engines: {node: '>= 22'} cpu: [x64] os: [win32] - '@nomicfoundation/edr@0.25.1': - resolution: {integrity: sha512-yMCUTiEEdyuWN9na9RvKBD9du+C0fmnZUqVVQaJwATAY6qUyCZ3tkf4abnwEWt8s3oAfMx19HJiODmUnQgVjOQ==} + '@nomicfoundation/edr@0.26.0': + resolution: {integrity: sha512-KRsXuAejPwkOYfuoTYpEJzIvzjbqwXrHcEzUJCKe2I4qz3uZ2/9rY0l25rA+yLf4oGMCKlXfuORKmzZHWsPZAg==} engines: {node: '>= 22'} '@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.2': @@ -8462,36 +8462,36 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.20.1 - '@nomicfoundation/edr-darwin-arm64@0.25.1': + '@nomicfoundation/edr-darwin-arm64@0.26.0': optional: true - '@nomicfoundation/edr-darwin-x64@0.25.1': + '@nomicfoundation/edr-darwin-x64@0.26.0': optional: true - '@nomicfoundation/edr-linux-arm64-gnu@0.25.1': + '@nomicfoundation/edr-linux-arm64-gnu@0.26.0': optional: true - '@nomicfoundation/edr-linux-arm64-musl@0.25.1': + '@nomicfoundation/edr-linux-arm64-musl@0.26.0': optional: true - '@nomicfoundation/edr-linux-x64-gnu@0.25.1': + '@nomicfoundation/edr-linux-x64-gnu@0.26.0': optional: true - '@nomicfoundation/edr-linux-x64-musl@0.25.1': + '@nomicfoundation/edr-linux-x64-musl@0.26.0': optional: true - '@nomicfoundation/edr-win32-x64-msvc@0.25.1': + '@nomicfoundation/edr-win32-x64-msvc@0.26.0': optional: true - '@nomicfoundation/edr@0.25.1': + '@nomicfoundation/edr@0.26.0': optionalDependencies: - '@nomicfoundation/edr-darwin-arm64': 0.25.1 - '@nomicfoundation/edr-darwin-x64': 0.25.1 - '@nomicfoundation/edr-linux-arm64-gnu': 0.25.1 - '@nomicfoundation/edr-linux-arm64-musl': 0.25.1 - '@nomicfoundation/edr-linux-x64-gnu': 0.25.1 - '@nomicfoundation/edr-linux-x64-musl': 0.25.1 - '@nomicfoundation/edr-win32-x64-msvc': 0.25.1 + '@nomicfoundation/edr-darwin-arm64': 0.26.0 + '@nomicfoundation/edr-darwin-x64': 0.26.0 + '@nomicfoundation/edr-linux-arm64-gnu': 0.26.0 + '@nomicfoundation/edr-linux-arm64-musl': 0.26.0 + '@nomicfoundation/edr-linux-x64-gnu': 0.26.0 + '@nomicfoundation/edr-linux-x64-musl': 0.26.0 + '@nomicfoundation/edr-win32-x64-msvc': 0.26.0 '@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.2': optional: true From 130d561d93c8b5a7521248848d982ae80909ddb3 Mon Sep 17 00:00:00 2001 From: John Kane Date: Mon, 23 Nov 2026 12:51:19 +0000 Subject: [PATCH 2/6] chore: add changesets for the EDR v0.26.0 changes --- .changeset/edr-0.26.0.md | 5 +++++ .changeset/edr-estimate-gas-fork-hardfork.md | 5 +++++ .changeset/edr-fork-chain-id-fee-params.md | 5 +++++ .changeset/edr-fuzz-assume-rejects-not-runs.md | 5 +++++ .changeset/edr-fuzz-failing-run-logs.md | 5 +++++ .changeset/edr-fuzz-failure-persist-file-removed.md | 5 +++++ .changeset/edr-fuzz-failure-persistence.md | 5 +++++ .changeset/edr-fuzz-max-test-rejects-zero.md | 5 +++++ .changeset/edr-fuzz-parallel-workers.md | 5 +++++ .changeset/edr-fuzz-vm-random-seed.md | 5 +++++ .changeset/edr-solidity-0.8.38-coverage.md | 5 +++++ 11 files changed, 55 insertions(+) create mode 100644 .changeset/edr-0.26.0.md create mode 100644 .changeset/edr-estimate-gas-fork-hardfork.md create mode 100644 .changeset/edr-fork-chain-id-fee-params.md create mode 100644 .changeset/edr-fuzz-assume-rejects-not-runs.md create mode 100644 .changeset/edr-fuzz-failing-run-logs.md create mode 100644 .changeset/edr-fuzz-failure-persist-file-removed.md create mode 100644 .changeset/edr-fuzz-failure-persistence.md create mode 100644 .changeset/edr-fuzz-max-test-rejects-zero.md create mode 100644 .changeset/edr-fuzz-parallel-workers.md create mode 100644 .changeset/edr-fuzz-vm-random-seed.md create mode 100644 .changeset/edr-solidity-0.8.38-coverage.md diff --git a/.changeset/edr-0.26.0.md b/.changeset/edr-0.26.0.md new file mode 100644 index 00000000000..eaa32b61691 --- /dev/null +++ b/.changeset/edr-0.26.0.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Upgraded EDR to v0.26.0. diff --git a/.changeset/edr-estimate-gas-fork-hardfork.md b/.changeset/edr-estimate-gas-fork-hardfork.md new file mode 100644 index 00000000000..122dcccef80 --- /dev/null +++ b/.changeset/edr-estimate-gas-fork-hardfork.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Thanks @anaPerezGhiglia! Fixed `eth_estimateGas` over-estimating at historical blocks on forked chains whose hardfork differs from the configured one. diff --git a/.changeset/edr-fork-chain-id-fee-params.md b/.changeset/edr-fork-chain-id-fee-params.md new file mode 100644 index 00000000000..2ba9c98b387 --- /dev/null +++ b/.changeset/edr-fork-chain-id-fee-params.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Thanks @anaPerezGhiglia! Fixed blocks mined on a fork using default blob and base fee parameters instead of the forked chain's when the configured `chainId` differs from the remote chain's. diff --git a/.changeset/edr-fuzz-assume-rejects-not-runs.md b/.changeset/edr-fuzz-assume-rejects-not-runs.md new file mode 100644 index 00000000000..5c133cfcfee --- /dev/null +++ b/.changeset/edr-fuzz-assume-rejects-not-runs.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Thanks @popescuoctavian! Changed Solidity fuzz inputs rejected by `vm.assume` to no longer count towards `runs`. diff --git a/.changeset/edr-fuzz-failing-run-logs.md b/.changeset/edr-fuzz-failing-run-logs.md new file mode 100644 index 00000000000..8e21bc17edf --- /dev/null +++ b/.changeset/edr-fuzz-failing-run-logs.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Thanks @popescuoctavian! Changed Solidity fuzz tests to report the logs of the failing run even without `showLogs`. diff --git a/.changeset/edr-fuzz-failure-persist-file-removed.md b/.changeset/edr-fuzz-failure-persist-file-removed.md new file mode 100644 index 00000000000..9f5c55c1d1d --- /dev/null +++ b/.changeset/edr-fuzz-failure-persist-file-removed.md @@ -0,0 +1,5 @@ +--- +"hardhat": minor +--- + +Thanks @popescuoctavian! BREAKING CHANGE: The `failurePersistFile` fuzz option is now ignored; Solidity fuzz failures are always persisted under `failures` in `failurePersistDir`, as in Foundry. diff --git a/.changeset/edr-fuzz-failure-persistence.md b/.changeset/edr-fuzz-failure-persistence.md new file mode 100644 index 00000000000..b76d01235d4 --- /dev/null +++ b/.changeset/edr-fuzz-failure-persistence.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Thanks @popescuoctavian! Changed Solidity fuzz failures to persist as one JSON counterexample per test, which is replayed first on the next run. diff --git a/.changeset/edr-fuzz-max-test-rejects-zero.md b/.changeset/edr-fuzz-max-test-rejects-zero.md new file mode 100644 index 00000000000..5f3b4ed875d --- /dev/null +++ b/.changeset/edr-fuzz-max-test-rejects-zero.md @@ -0,0 +1,5 @@ +--- +"hardhat": minor +--- + +Thanks @popescuoctavian! BREAKING CHANGE: `maxTestRejects: 0` now disables the `vm.assume` reject limit in Solidity fuzz tests, instead of failing on the first rejected input, and requires a fuzz `timeout`. diff --git a/.changeset/edr-fuzz-parallel-workers.md b/.changeset/edr-fuzz-parallel-workers.md new file mode 100644 index 00000000000..116a07366e8 --- /dev/null +++ b/.changeset/edr-fuzz-parallel-workers.md @@ -0,0 +1,5 @@ +--- +"hardhat": minor +--- + +Thanks @popescuoctavian! Added parallel workers to Solidity fuzz tests, which now run on the available threads; inputs for a given fuzz `seed` differ from earlier versions. diff --git a/.changeset/edr-fuzz-vm-random-seed.md b/.changeset/edr-fuzz-vm-random-seed.md new file mode 100644 index 00000000000..dfc22f1ddf3 --- /dev/null +++ b/.changeset/edr-fuzz-vm-random-seed.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Thanks @popescuoctavian! Fixed the `vm.random*` cheatcodes repeating the same sequence in every fuzz run under a fixed `seed`. diff --git a/.changeset/edr-solidity-0.8.38-coverage.md b/.changeset/edr-solidity-0.8.38-coverage.md new file mode 100644 index 00000000000..519cc9cb540 --- /dev/null +++ b/.changeset/edr-solidity-0.8.38-coverage.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Thanks @nebasuke! Added coverage support for Solidity 0.8.36, 0.8.37 and 0.8.38. From 0426c2c1bb29c08474edaa47752a18119ac0cf8d Mon Sep 17 00:00:00 2001 From: John Kane Date: Mon, 23 Nov 2026 13:11:29 +0000 Subject: [PATCH 3/6] Apply suggestion from @kanej --- .changeset/edr-fuzz-failure-persist-file-removed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/edr-fuzz-failure-persist-file-removed.md b/.changeset/edr-fuzz-failure-persist-file-removed.md index 9f5c55c1d1d..34b175bdc63 100644 --- a/.changeset/edr-fuzz-failure-persist-file-removed.md +++ b/.changeset/edr-fuzz-failure-persist-file-removed.md @@ -2,4 +2,4 @@ "hardhat": minor --- -Thanks @popescuoctavian! BREAKING CHANGE: The `failurePersistFile` fuzz option is now ignored; Solidity fuzz failures are always persisted under `failures` in `failurePersistDir`, as in Foundry. +Thanks @popescuoctavian! BREAKING CHANGE: The `failurePersistFile` fuzz option is now ignored; Solidity fuzz failures are always persisted under `failures` in `failurePersistDir`. From be6e9b737fde4a7ba6b5a97edc703c69979b69c5 Mon Sep 17 00:00:00 2001 From: John Kane Date: Wed, 25 Nov 2026 15:14:42 +0000 Subject: [PATCH 4/6] feat: remove the failurePersistFile fuzz option EDR v0.26.0 removed `failurePersistFile`: fuzz failures are now persisted as one JSON counterexample per test under `failures` in `failurePersistDir`, so the option has nothing left to name. We drop it from the user and resolved config types. The fuzz config schema isn't strict, so a config that still set it would have validated and been silently ignored. Setting it is now a config error that points to `failurePersistDir`, in the flat config and in every test profile. --- .../edr-fuzz-failure-persist-file-removed.md | 2 +- .../builtin-plugins/solidity-test/config.ts | 4 +- .../solidity-test/type-extensions.ts | 2 - .../solidity-test/config-validation.ts | 47 +++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/.changeset/edr-fuzz-failure-persist-file-removed.md b/.changeset/edr-fuzz-failure-persist-file-removed.md index 34b175bdc63..e3db294b546 100644 --- a/.changeset/edr-fuzz-failure-persist-file-removed.md +++ b/.changeset/edr-fuzz-failure-persist-file-removed.md @@ -2,4 +2,4 @@ "hardhat": minor --- -Thanks @popescuoctavian! BREAKING CHANGE: The `failurePersistFile` fuzz option is now ignored; Solidity fuzz failures are always persisted under `failures` in `failurePersistDir`. +Thanks @popescuoctavian! BREAKING CHANGE: Removed the `failurePersistFile` Solidity fuzz option, and setting it is now a config error. When `failurePersistDir` is set, failures are persisted under `failures`. diff --git a/packages/hardhat/src/internal/builtin-plugins/solidity-test/config.ts b/packages/hardhat/src/internal/builtin-plugins/solidity-test/config.ts index 877db269266..774b144850c 100644 --- a/packages/hardhat/src/internal/builtin-plugins/solidity-test/config.ts +++ b/packages/hardhat/src/internal/builtin-plugins/solidity-test/config.ts @@ -80,7 +80,9 @@ const solidityTestProfileUserConfigType = z.object({ fuzz: z .object({ failurePersistDir: z.string().optional(), - failurePersistFile: z.string().optional(), + failurePersistFile: incompatibleFieldType( + "This field was removed, as failures are now persisted as one file per test in `failurePersistDir`", + ), runs: z.number().optional(), maxTestRejects: z.number().optional(), seed: z.string().optional(), diff --git a/packages/hardhat/src/internal/builtin-plugins/solidity-test/type-extensions.ts b/packages/hardhat/src/internal/builtin-plugins/solidity-test/type-extensions.ts index 33a8b369aaa..d0557d3d31b 100644 --- a/packages/hardhat/src/internal/builtin-plugins/solidity-test/type-extensions.ts +++ b/packages/hardhat/src/internal/builtin-plugins/solidity-test/type-extensions.ts @@ -38,7 +38,6 @@ declare module "../../../types/test.js" { export interface SolidityTestFuzzUserConfig { failurePersistDir?: string; - failurePersistFile?: string; runs?: number; maxTestRejects?: number; seed?: string; @@ -115,7 +114,6 @@ declare module "../../../types/test.js" { export interface SolidityTestFuzzConfig { failurePersistDir?: string; - failurePersistFile?: string; runs?: number; maxTestRejects?: number; seed: string; diff --git a/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts b/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts index acef32505c0..f946cb1199e 100644 --- a/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts +++ b/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts @@ -207,6 +207,53 @@ describe("config validation", () => { ); }); + it("should reject the removed `fuzz.failurePersistFile` field", async () => { + const userConfig: HardhatUserConfig = { + test: { + solidity: { + /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions + -- intentionally violating the types for the test */ + fuzz: { failurePersistFile: "failures" } as any, + }, + }, + }; + + await assertRejectsWithHardhatError( + createHardhatRuntimeEnvironment(userConfig), + HardhatError.ERRORS.CORE.GENERAL.INVALID_CONFIG, + { + errors: + "\t* Config error in config.test.solidity.fuzz.failurePersistFile: This field was removed, as failures are now persisted as one file per test in `failurePersistDir`", + }, + ); + }); + + it("should reject the removed `fuzz.failurePersistFile` field in a profile", async () => { + const userConfig: HardhatUserConfig = { + test: { + solidity: { + profiles: { + default: {}, + ci: { + /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions + -- intentionally violating the types for the test */ + fuzz: { failurePersistFile: "failures" } as any, + }, + }, + }, + }, + }; + + await assertRejectsWithHardhatError( + createHardhatRuntimeEnvironment(userConfig), + HardhatError.ERRORS.CORE.GENERAL.INVALID_CONFIG, + { + errors: + "\t* Config error in config.test.solidity.profiles.ci.fuzz.failurePersistFile: This field was removed, as failures are now persisted as one file per test in `failurePersistDir`", + }, + ); + }); + it("should reject bigint invariant timeouts that cannot be represented as safe numbers", async () => { const userConfig: HardhatUserConfig = { test: { From f3aa9abeeddc4e97bda0d189a484331a376d3f6c Mon Sep 17 00:00:00 2001 From: John Kane Date: Wed, 25 Nov 2026 15:01:13 +0000 Subject: [PATCH 5/6] feat: add the workers fuzz option EDR v0.26.0 runs each fuzz test on parallel workers and takes a `workers` option, which already reached it untyped through the spread in `resolveFuzzConfig`. We add it to the schema and to the user and resolved fuzz config types. It must be a positive integer, and when it isn't set nothing is passed, so EDR's default (the available threads) applies. --- .changeset/edr-fuzz-parallel-workers.md | 2 +- .../builtin-plugins/solidity-test/config.ts | 1 + .../solidity-test/type-extensions.ts | 2 ++ .../solidity-test/config-resolution.ts | 31 ++++++++++++++++ .../solidity-test/config-validation.ts | 36 +++++++++++++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) diff --git a/.changeset/edr-fuzz-parallel-workers.md b/.changeset/edr-fuzz-parallel-workers.md index 116a07366e8..582b3944af0 100644 --- a/.changeset/edr-fuzz-parallel-workers.md +++ b/.changeset/edr-fuzz-parallel-workers.md @@ -2,4 +2,4 @@ "hardhat": minor --- -Thanks @popescuoctavian! Added parallel workers to Solidity fuzz tests, which now run on the available threads; inputs for a given fuzz `seed` differ from earlier versions. +Thanks @popescuoctavian! Support parallel workers for Solidity fuzz tests. diff --git a/packages/hardhat/src/internal/builtin-plugins/solidity-test/config.ts b/packages/hardhat/src/internal/builtin-plugins/solidity-test/config.ts index 774b144850c..d21734350e0 100644 --- a/packages/hardhat/src/internal/builtin-plugins/solidity-test/config.ts +++ b/packages/hardhat/src/internal/builtin-plugins/solidity-test/config.ts @@ -91,6 +91,7 @@ const solidityTestProfileUserConfigType = z.object({ includePushBytes: z.boolean().optional(), showLogs: z.boolean().optional(), timeout: nonnegativeSafeIntOrSafeBigInt.optional(), + workers: z.number().int().positive().safe().optional(), }) .optional(), forking: z diff --git a/packages/hardhat/src/internal/builtin-plugins/solidity-test/type-extensions.ts b/packages/hardhat/src/internal/builtin-plugins/solidity-test/type-extensions.ts index d0557d3d31b..9d8bcaf236f 100644 --- a/packages/hardhat/src/internal/builtin-plugins/solidity-test/type-extensions.ts +++ b/packages/hardhat/src/internal/builtin-plugins/solidity-test/type-extensions.ts @@ -46,6 +46,7 @@ declare module "../../../types/test.js" { includePushBytes?: boolean; showLogs?: boolean; timeout?: number | bigint; + workers?: number; } export interface SolidityTestForkingUserConfig { @@ -122,6 +123,7 @@ declare module "../../../types/test.js" { includePushBytes?: boolean; showLogs?: boolean; timeout?: number; + workers?: number; } export interface SolidityTestForkingConfig { diff --git a/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-resolution.ts b/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-resolution.ts index d4c57b27500..9cd17b68684 100644 --- a/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-resolution.ts +++ b/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-resolution.ts @@ -54,6 +54,19 @@ describe("config resolution", () => { assert.equal(result.timeout, 30); assert.equal(result.seed, DEFAULT_FUZZ_SEED); }); + + it("should pass `workers` through when it is set", () => { + const result = resolveFuzzConfig({ workers: 1 }); + + assert.deepEqual(result, { seed: DEFAULT_FUZZ_SEED, workers: 1 }); + }); + + it("should leave `workers` out when it isn't set, so EDR's default applies", () => { + const result = resolveFuzzConfig({ runs: 500 }); + + assert.ok(result !== undefined, "result is undefined"); + assert.equal("workers" in result, false); + }); }); describe("resolveInvariantConfig", () => { @@ -182,5 +195,23 @@ describe("config resolution", () => { assert.equal(ci.forking?.blockNumber, 123n); assert.equal(await ci.forking?.url?.get(), "https://example.com/ci"); }); + + it("should resolve `workers` per profile", async () => { + const hre = await createHardhatRuntimeEnvironment({ + test: { + solidity: { + profiles: { + default: { fuzz: { runs: 500 } }, + ci: { fuzz: { workers: 1 } }, + }, + }, + }, + }); + + const { default: defaultProfile, ci } = hre.config.test.solidity.profiles; + + assert.equal(defaultProfile.fuzz.workers, undefined); + assert.equal(ci.fuzz.workers, 1); + }); }); }); diff --git a/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts b/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts index f946cb1199e..6daba22d968 100644 --- a/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts +++ b/packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts @@ -207,6 +207,42 @@ describe("config validation", () => { ); }); + it("should accept a positive integer `fuzz.workers`", async () => { + const hre = await createHardhatRuntimeEnvironment({ + test: { + solidity: { + fuzz: { workers: 1 }, + }, + }, + }); + + assert.equal(hre.config.test.solidity.profiles.default.fuzz.workers, 1); + }); + + it("should reject a `fuzz.workers` that isn't a positive integer", async () => { + for (const [workers, message] of [ + [0, "Number must be greater than 0"], + [-1, "Number must be greater than 0"], + [1.5, "Expected integer, received float"], + ] as const) { + const userConfig: HardhatUserConfig = { + test: { + solidity: { + fuzz: { workers }, + }, + }, + }; + + await assertRejectsWithHardhatError( + createHardhatRuntimeEnvironment(userConfig), + HardhatError.ERRORS.CORE.GENERAL.INVALID_CONFIG, + { + errors: `\t* Config error in config.test.solidity.fuzz.workers: ${message}`, + }, + ); + } + }); + it("should reject the removed `fuzz.failurePersistFile` field", async () => { const userConfig: HardhatUserConfig = { test: { From fe387d7eda3a83688d71c769099f9ba48250bd3f Mon Sep 17 00:00:00 2001 From: John Kane Date: Wed, 25 Nov 2026 18:23:18 +0000 Subject: [PATCH 6/6] chore: link the parallel fuzz workers changeset to its docs --- .changeset/edr-fuzz-parallel-workers.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/edr-fuzz-parallel-workers.md b/.changeset/edr-fuzz-parallel-workers.md index 582b3944af0..515eec82789 100644 --- a/.changeset/edr-fuzz-parallel-workers.md +++ b/.changeset/edr-fuzz-parallel-workers.md @@ -1,4 +1,5 @@ --- +# docs: https://github.com/NomicFoundation/hardhat-website/pull/335 "hardhat": minor ---