Skip to content

Commit 2070d5d

Browse files
committed
fix: only use wasm on linux arm64
1 parent c7584f9 commit 2070d5d

File tree

2 files changed

+15
-13
lines changed
  • v-next/hardhat
    • src/internal/builtin-plugins/solidity
    • test/internal/builtin-plugins/solidity

2 files changed

+15
-13
lines changed

v-next/hardhat/src/internal/builtin-plugins/solidity/config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import type {
1111
} from "../../../types/config.js";
1212
import type { HardhatUserConfigValidationError } from "../../../types/hooks.js";
1313

14+
import os from "node:os";
15+
1416
import { deepMerge, isObject } from "@nomicfoundation/hardhat-utils/lang";
1517
import { resolveFromRoot } from "@nomicfoundation/hardhat-utils/path";
1618
import {
@@ -288,7 +290,7 @@ function resolveBuildProfileConfig(
288290
compilers: [resolveSolcConfig(solidityConfig, production)],
289291
overrides: {},
290292
isolated: solidityConfig.isolated ?? production,
291-
preferWasm: solidityConfig.preferWasm ?? production,
293+
preferWasm: solidityConfig.preferWasm ?? (production && shouldUseWasm()),
292294
};
293295
}
294296

@@ -305,7 +307,7 @@ function resolveBuildProfileConfig(
305307
),
306308
),
307309
isolated: solidityConfig.isolated ?? production,
308-
preferWasm: solidityConfig.preferWasm ?? production,
310+
preferWasm: solidityConfig.preferWasm ?? (production && shouldUseWasm()),
309311
};
310312
}
311313

@@ -366,3 +368,9 @@ function copyFromDefault(
366368
),
367369
};
368370
}
371+
372+
// We use wasm builds in production to avoid using unofficial builds for deployments
373+
// This should change once https://github.com/ethereum/solidity/issues/11351 gets resolved
374+
export function shouldUseWasm(): boolean {
375+
return os.platform() === "linux" && os.arch() === "arm64";
376+
}

v-next/hardhat/test/internal/builtin-plugins/solidity/config.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { describe, it } from "node:test";
44

55
import {
66
resolveSolidityUserConfig,
7+
shouldUseWasm,
78
validateSolidityUserConfig,
89
} from "../../../../src/internal/builtin-plugins/solidity/config.js";
910

@@ -465,7 +466,7 @@ describe("solidity plugin config resolution", () => {
465466
describe("preferWasm setting resolution", function () {
466467
const otherResolvedConfig = { paths: { root: process.cwd() } } as any;
467468

468-
it("resolves to true when build profile is production and is not specified in the config", async () => {
469+
it("resolves to shouldUseWasm() when build profile is production and is not specified in the config", async () => {
469470
const resolvedConfig = await resolveSolidityUserConfig(
470471
{
471472
solidity: {
@@ -482,11 +483,11 @@ describe("solidity plugin config resolution", () => {
482483

483484
assert.equal(
484485
resolvedConfig.solidity.profiles.production.preferWasm,
485-
true,
486+
shouldUseWasm(),
486487
);
487488
});
488489

489-
it("resolves to true when build profile is production and is specified, but preferWasm is not set", async () => {
490+
it("resolves to shouldUseWasm() when build profile is production and is specified, but preferWasm is not set", async () => {
490491
const resolvedConfig = await resolveSolidityUserConfig(
491492
{
492493
solidity: {
@@ -506,7 +507,7 @@ describe("solidity plugin config resolution", () => {
506507

507508
assert.equal(
508509
resolvedConfig.solidity.profiles.production.preferWasm,
509-
true,
510+
shouldUseWasm(),
510511
);
511512
});
512513

@@ -550,9 +551,6 @@ describe("solidity plugin config resolution", () => {
550551
profile_2: {
551552
version: "0.8.28",
552553
},
553-
production: {
554-
version: "0.8.28",
555-
},
556554
},
557555
},
558556
},
@@ -568,10 +566,6 @@ describe("solidity plugin config resolution", () => {
568566
resolvedConfig.solidity.profiles.profile_2.preferWasm,
569567
false,
570568
);
571-
assert.equal(
572-
resolvedConfig.solidity.profiles.production.preferWasm,
573-
true,
574-
);
575569
});
576570
});
577571
});

0 commit comments

Comments
 (0)