From 0c1ac953b93939db23d1cc3b6eaa8d4df7863552 Mon Sep 17 00:00:00 2001 From: ChristopherDedominici <18092467+ChristopherDedominici@users.noreply.github.com> Date: Thu, 12 Feb 2026 16:04:57 +0000 Subject: [PATCH 1/2] allow multiple parallel downloads of different compilers --- .../solidity/build-system/compiler/downloader.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts b/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts index 191d48ff226..ae4d7014395 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts @@ -153,7 +153,6 @@ export class CompilerDownloaderImplementation implements CompilerDownloader { readonly #compilersDir: string; readonly #downloadFunction: typeof download; - readonly #mutexCompiler = new MultiProcessMutex("compiler-download"); readonly #mutexCompilerList = new MultiProcessMutex("compiler-download-list"); /** @@ -200,11 +199,14 @@ export class CompilerDownloaderImplementation implements CompilerDownloader { } public async downloadCompiler(version: string): Promise { - // Since only one process at a time can acquire the mutex, we avoid the risk of downloading the same compiler multiple times. - // This is because the mutex blocks access until a compiler has been fully downloaded, preventing any new process - // from checking whether that version of the compiler exists. Without mutex it might incorrectly - // return false, indicating that the compiler isn't present, even though it is currently being downloaded. - return this.#mutexCompiler.use(async () => { + // A per-version mutex ensures that only one process at a time can download a given compiler version, + // while still allowing different compiler versions to be downloaded in parallel. + // Without the mutex, a concurrent process might check whether a version exists, incorrectly + // find it missing (because another process is still downloading it), and start a redundant download. + + const mutex = new MultiProcessMutex(`compiler-download-${version}`); + + return mutex.use(async () => { const isCompilerDownloaded = await this.isCompilerDownloaded(version); if (isCompilerDownloaded === true) { From 78af2ed546ad5a0bafa44785e275855d6876530d Mon Sep 17 00:00:00 2001 From: Christopher Dedominici <18092467+ChristopherDedominici@users.noreply.github.com> Date: Thu, 12 Feb 2026 17:08:56 +0100 Subject: [PATCH 2/2] Create sweet-seas-shake.md --- .changeset/sweet-seas-shake.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sweet-seas-shake.md diff --git a/.changeset/sweet-seas-shake.md b/.changeset/sweet-seas-shake.md new file mode 100644 index 00000000000..231659261cc --- /dev/null +++ b/.changeset/sweet-seas-shake.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Allow multiple parallel downloads of different compilers ([7946](https://github.com/NomicFoundation/hardhat/pull/7946)).