From 224159e58222d1e7f33d69605e495b24cdd9eed3 Mon Sep 17 00:00:00 2001 From: Luis Schaab Date: Wed, 11 Sep 2024 16:53:35 -0300 Subject: [PATCH 1/3] feat: add support for solc versions 0.8.25, 0.8.26, and 0.8.27 --- .changeset/dull-icons-float.md | 5 ++ .../docs/reference/solidity-support.md | 2 +- docs/src/model/markdown.tsx | 2 +- .../javascript-esm/contracts/Lock.sol | 2 +- .../javascript-esm/hardhat.config.cjs | 2 +- .../javascript/contracts/Lock.sol | 2 +- .../javascript/hardhat.config.js | 2 +- .../typescript-viem/contracts/Lock.sol | 2 +- .../typescript-viem/hardhat.config.ts | 2 +- .../typescript/contracts/Lock.sol | 2 +- .../typescript/hardhat.config.ts | 2 +- .../src/internal/cli/project-creation.ts | 2 +- .../hardhat-network/stack-traces/constants.ts | 2 +- .../internal/solidity/compiler/solc-info.ts | 3 ++ .../contracts/A.sol | 2 +- .../hardhat.config.js | 2 +- .../stack-traces/compilers-list.ts | 46 +++++++++++++++++-- 17 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 .changeset/dull-icons-float.md diff --git a/.changeset/dull-icons-float.md b/.changeset/dull-icons-float.md new file mode 100644 index 0000000000..6de3689ff6 --- /dev/null +++ b/.changeset/dull-icons-float.md @@ -0,0 +1,5 @@ +--- +"hardhat": patch +--- + +Added support for solc versions 0.8.25, 0.8.26, and 0.8.27 diff --git a/docs/src/content/hardhat-runner/docs/reference/solidity-support.md b/docs/src/content/hardhat-runner/docs/reference/solidity-support.md index 109300c335..f89c10f7ad 100644 --- a/docs/src/content/hardhat-runner/docs/reference/solidity-support.md +++ b/docs/src/content/hardhat-runner/docs/reference/solidity-support.md @@ -13,7 +13,7 @@ These are the versions of Solidity that you can expect to fully work with Hardha - Any 0.5.x version starting from 0.5.1 - Any 0.6.x version - Any 0.7.x version -- Any 0.8.x version up to and including 0.8.24 +- Any 0.8.x version up to and including 0.8.27 We recommend against using Hardhat with newer, unsupported versions of Solidity. But if you need to do so; please read on. diff --git a/docs/src/model/markdown.tsx b/docs/src/model/markdown.tsx index e97790d389..e1e1ebe5e3 100644 --- a/docs/src/model/markdown.tsx +++ b/docs/src/model/markdown.tsx @@ -104,7 +104,7 @@ export const withoutComments = (content: string) => { }; export const replacePlaceholders = (content: string) => { - const recommendedSolcVersion = "0.8.24"; + const recommendedSolcVersion = "0.8.27"; const latestPragma = "^0.8.0"; const hardhatPackageJson = fs .readFileSync( diff --git a/packages/hardhat-core/sample-projects/javascript-esm/contracts/Lock.sol b/packages/hardhat-core/sample-projects/javascript-esm/contracts/Lock.sol index 1efbef3f37..0c81557faa 100644 --- a/packages/hardhat-core/sample-projects/javascript-esm/contracts/Lock.sol +++ b/packages/hardhat-core/sample-projects/javascript-esm/contracts/Lock.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; +pragma solidity ^0.8.27; // Uncomment this line to use console.log // import "hardhat/console.sol"; diff --git a/packages/hardhat-core/sample-projects/javascript-esm/hardhat.config.cjs b/packages/hardhat-core/sample-projects/javascript-esm/hardhat.config.cjs index 8ba99bc91c..2cbdac3498 100644 --- a/packages/hardhat-core/sample-projects/javascript-esm/hardhat.config.cjs +++ b/packages/hardhat-core/sample-projects/javascript-esm/hardhat.config.cjs @@ -2,5 +2,5 @@ require("@nomicfoundation/hardhat-toolbox"); /** @type import('hardhat/config').HardhatUserConfig */ module.exports = { - solidity: "0.8.24", + solidity: "0.8.27", }; diff --git a/packages/hardhat-core/sample-projects/javascript/contracts/Lock.sol b/packages/hardhat-core/sample-projects/javascript/contracts/Lock.sol index 1efbef3f37..0c81557faa 100644 --- a/packages/hardhat-core/sample-projects/javascript/contracts/Lock.sol +++ b/packages/hardhat-core/sample-projects/javascript/contracts/Lock.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; +pragma solidity ^0.8.27; // Uncomment this line to use console.log // import "hardhat/console.sol"; diff --git a/packages/hardhat-core/sample-projects/javascript/hardhat.config.js b/packages/hardhat-core/sample-projects/javascript/hardhat.config.js index 8ba99bc91c..2cbdac3498 100644 --- a/packages/hardhat-core/sample-projects/javascript/hardhat.config.js +++ b/packages/hardhat-core/sample-projects/javascript/hardhat.config.js @@ -2,5 +2,5 @@ require("@nomicfoundation/hardhat-toolbox"); /** @type import('hardhat/config').HardhatUserConfig */ module.exports = { - solidity: "0.8.24", + solidity: "0.8.27", }; diff --git a/packages/hardhat-core/sample-projects/typescript-viem/contracts/Lock.sol b/packages/hardhat-core/sample-projects/typescript-viem/contracts/Lock.sol index 1efbef3f37..0c81557faa 100644 --- a/packages/hardhat-core/sample-projects/typescript-viem/contracts/Lock.sol +++ b/packages/hardhat-core/sample-projects/typescript-viem/contracts/Lock.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; +pragma solidity ^0.8.27; // Uncomment this line to use console.log // import "hardhat/console.sol"; diff --git a/packages/hardhat-core/sample-projects/typescript-viem/hardhat.config.ts b/packages/hardhat-core/sample-projects/typescript-viem/hardhat.config.ts index d7ffa558f2..f905c763fb 100644 --- a/packages/hardhat-core/sample-projects/typescript-viem/hardhat.config.ts +++ b/packages/hardhat-core/sample-projects/typescript-viem/hardhat.config.ts @@ -2,7 +2,7 @@ import type { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox-viem"; const config: HardhatUserConfig = { - solidity: "0.8.24", + solidity: "0.8.27", }; export default config; diff --git a/packages/hardhat-core/sample-projects/typescript/contracts/Lock.sol b/packages/hardhat-core/sample-projects/typescript/contracts/Lock.sol index 1efbef3f37..0c81557faa 100644 --- a/packages/hardhat-core/sample-projects/typescript/contracts/Lock.sol +++ b/packages/hardhat-core/sample-projects/typescript/contracts/Lock.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; +pragma solidity ^0.8.27; // Uncomment this line to use console.log // import "hardhat/console.sol"; diff --git a/packages/hardhat-core/sample-projects/typescript/hardhat.config.ts b/packages/hardhat-core/sample-projects/typescript/hardhat.config.ts index 3bd6862e98..72cffac114 100644 --- a/packages/hardhat-core/sample-projects/typescript/hardhat.config.ts +++ b/packages/hardhat-core/sample-projects/typescript/hardhat.config.ts @@ -2,7 +2,7 @@ import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox"; const config: HardhatUserConfig = { - solidity: "0.8.24", + solidity: "0.8.27", }; export default config; diff --git a/packages/hardhat-core/src/internal/cli/project-creation.ts b/packages/hardhat-core/src/internal/cli/project-creation.ts index d3bff56dc4..43ac320bf6 100644 --- a/packages/hardhat-core/src/internal/cli/project-creation.ts +++ b/packages/hardhat-core/src/internal/cli/project-creation.ts @@ -254,7 +254,7 @@ async function printRecommendedDepsInstallationInstructions( // exported so we can test that it uses the latest supported version of solidity export const EMPTY_HARDHAT_CONFIG = `/** @type import('hardhat/config').HardhatUserConfig */ module.exports = { - solidity: "0.8.24", + solidity: "0.8.27", }; `; diff --git a/packages/hardhat-core/src/internal/hardhat-network/stack-traces/constants.ts b/packages/hardhat-core/src/internal/hardhat-network/stack-traces/constants.ts index 4a77fa4647..d451851c0d 100644 --- a/packages/hardhat-core/src/internal/hardhat-network/stack-traces/constants.ts +++ b/packages/hardhat-core/src/internal/hardhat-network/stack-traces/constants.ts @@ -1,2 +1,2 @@ -export const SUPPORTED_SOLIDITY_VERSION_RANGE = "<=0.8.24"; +export const SUPPORTED_SOLIDITY_VERSION_RANGE = "<=0.8.27"; export const FIRST_SOLC_VERSION_SUPPORTED = "0.5.1"; diff --git a/packages/hardhat-core/src/internal/solidity/compiler/solc-info.ts b/packages/hardhat-core/src/internal/solidity/compiler/solc-info.ts index d657184481..c7ced925df 100644 --- a/packages/hardhat-core/src/internal/solidity/compiler/solc-info.ts +++ b/packages/hardhat-core/src/internal/solidity/compiler/solc-info.ts @@ -61,6 +61,9 @@ const defaultEvmTargets: { [key: string]: string } = { "0.8.22": "shanghai", "0.8.23": "shanghai", "0.8.24": "shanghai", + "0.8.25": "cancun", + "0.8.26": "cancun", + "0.8.27": "cancun", }; export function getEvmVersionFromSolcVersion( diff --git a/packages/hardhat-core/test/fixture-projects/compilation-latest-solc-version/contracts/A.sol b/packages/hardhat-core/test/fixture-projects/compilation-latest-solc-version/contracts/A.sol index 5be0c05871..3cdd32a38e 100644 --- a/packages/hardhat-core/test/fixture-projects/compilation-latest-solc-version/contracts/A.sol +++ b/packages/hardhat-core/test/fixture-projects/compilation-latest-solc-version/contracts/A.sol @@ -1,3 +1,3 @@ -pragma solidity ^0.8.24; +pragma solidity ^0.8.27; contract A {} diff --git a/packages/hardhat-core/test/fixture-projects/compilation-latest-solc-version/hardhat.config.js b/packages/hardhat-core/test/fixture-projects/compilation-latest-solc-version/hardhat.config.js index 31b010f16d..9fdde9a93e 100644 --- a/packages/hardhat-core/test/fixture-projects/compilation-latest-solc-version/hardhat.config.js +++ b/packages/hardhat-core/test/fixture-projects/compilation-latest-solc-version/hardhat.config.js @@ -1,3 +1,3 @@ module.exports = { - solidity: "0.8.24", + solidity: "0.8.27", }; diff --git a/packages/hardhat-core/test/internal/hardhat-network/stack-traces/compilers-list.ts b/packages/hardhat-core/test/internal/hardhat-network/stack-traces/compilers-list.ts index 9a74fd4876..0a6f06f0be 100644 --- a/packages/hardhat-core/test/internal/hardhat-network/stack-traces/compilers-list.ts +++ b/packages/hardhat-core/test/internal/hardhat-network/stack-traces/compilers-list.ts @@ -220,7 +220,6 @@ export const solidityCompilers: SolidityCompiler[] = [ { solidityVersion: "0.8.22", compilerPath: "soljson-v0.8.22+commit.4fc1097e.js", - latestSolcVersion: true, }, { solidityVersion: "0.8.22", @@ -229,12 +228,10 @@ export const solidityCompilers: SolidityCompiler[] = [ runs: 200, viaIR: true, }, - latestSolcVersion: true, }, { solidityVersion: "0.8.23", compilerPath: "soljson-v0.8.23+commit.f704f362.js", - latestSolcVersion: true, }, { solidityVersion: "0.8.23", @@ -243,12 +240,10 @@ export const solidityCompilers: SolidityCompiler[] = [ runs: 200, viaIR: true, }, - latestSolcVersion: true, }, { solidityVersion: "0.8.24", compilerPath: "soljson-v0.8.24+commit.e11b9ed9.js", - latestSolcVersion: true, }, { solidityVersion: "0.8.24", @@ -257,6 +252,47 @@ export const solidityCompilers: SolidityCompiler[] = [ runs: 200, viaIR: true, }, + }, + { + solidityVersion: "0.8.25", + compilerPath: "soljson-v0.8.25+commit.b61c2a91.js", + latestSolcVersion: true, + }, + { + solidityVersion: "0.8.25", + compilerPath: "soljson-v0.8.25+commit.b61c2a91.js", + optimizer: { + runs: 200, + viaIR: true, + }, + latestSolcVersion: true, + }, + { + solidityVersion: "0.8.26", + compilerPath: "soljson-v0.8.26+commit.8a97fa7a.js", + latestSolcVersion: true, + }, + { + solidityVersion: "0.8.26", + compilerPath: "soljson-v0.8.26+commit.8a97fa7a.js", + optimizer: { + runs: 200, + viaIR: true, + }, + latestSolcVersion: true, + }, + { + solidityVersion: "0.8.27", + compilerPath: "soljson-v0.8.27+commit.40a35a09.js", + latestSolcVersion: true, + }, + { + solidityVersion: "0.8.27", + compilerPath: "soljson-v0.8.27+commit.40a35a09.js", + optimizer: { + runs: 200, + viaIR: true, + }, latestSolcVersion: true, }, ]; From af56e77a6fae1b0e164599d97d6e1723960ea927 Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Thu, 12 Sep 2024 17:07:52 +0200 Subject: [PATCH 2/3] Use cancun when executing stack traces tests --- .../test/internal/hardhat-network/stack-traces/execution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hardhat-core/test/internal/hardhat-network/stack-traces/execution.ts b/packages/hardhat-core/test/internal/hardhat-network/stack-traces/execution.ts index e5f04af8c2..55e6333361 100644 --- a/packages/hardhat-core/test/internal/hardhat-network/stack-traces/execution.ts +++ b/packages/hardhat-core/test/internal/hardhat-network/stack-traces/execution.ts @@ -31,7 +31,7 @@ export async function instantiateProvider( tracingConfig: TracingConfig ): Promise { const config = { - hardfork: "shanghai", + hardfork: "cancun", chainId: 1, networkId: 1, blockGasLimit: 10_000_000, From ddadd4c13ad4d979d857e8f904a8652cd13bea1a Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Thu, 12 Sep 2024 17:09:00 +0200 Subject: [PATCH 3/3] Improve stack traces test error when transaction reverts --- .../test/internal/hardhat-network/stack-traces/test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/hardhat-core/test/internal/hardhat-network/stack-traces/test.ts b/packages/hardhat-core/test/internal/hardhat-network/stack-traces/test.ts index 1ce26f6ee3..268205c6cc 100644 --- a/packages/hardhat-core/test/internal/hardhat-network/stack-traces/test.ts +++ b/packages/hardhat-core/test/internal/hardhat-network/stack-traces/test.ts @@ -544,8 +544,6 @@ async function runTest( ); } - compareConsoleLogs(logger.lines, tx.consoleLogs); - const vmTraceDecoder = (provider as any)._vmTraceDecoder as VmTraceDecoder; const decodedTrace = vmTraceDecoder.tryToDecodeMessageTrace(trace); @@ -553,7 +551,7 @@ async function runTest( if (tx.stackTrace === undefined) { assert.isFalse( trace.exit.isError(), - `Transaction ${txIndex} shouldn't have failed` + `Transaction ${txIndex} shouldn't have failed (${trace.exit.getReason()})` ); } else { assert.isDefined( @@ -588,6 +586,8 @@ async function runTest( throw err; } } + + compareConsoleLogs(logger.lines, tx.consoleLogs); } }