diff --git a/HARDHAT_README.md b/HARDHAT_README.md index e5d97157..2420f1e7 100644 --- a/HARDHAT_README.md +++ b/HARDHAT_README.md @@ -73,6 +73,7 @@ module.exports = { | onCompileComplete[*][14] | *Function* | | Hook run *after* compilation completes, *before* tests are run. Useful if you have secondary compilation steps or need to modify built artifacts. [More...][23]| | onTestsComplete[*][14] | *Function* | | Hook run *after* the tests complete, *before* Istanbul reports are generated. [More...][23]| | onIstanbulComplete[*][14] | *Function* | | Hook run *after* the Istanbul reports are generated, *before* the ganache server is shut down. Useful if you need to clean resources up. [More...][23]| +| configureYulOptimizer | *Boolean* | false | (Experimental) Setting to `true` should resolve "stack too deep" compiler errrors in large projects using ABIEncoderV2 | [* Advanced use][14] diff --git a/README.md b/README.md index f2e76f1c..2231a8c9 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ module.exports = { | onCompileComplete[*][14] | *Function* | | Hook run *after* compilation completes, *before* tests are run. Useful if you have secondary compilation steps or need to modify built artifacts. [More...][23]| | onTestsComplete[*][14] | *Function* | | Hook run *after* the tests complete, *before* Istanbul reports are generated. [More...][23]| | onIstanbulComplete[*][14] | *Function* | | Hook run *after* the Istanbul reports are generated, *before* the ganache server is shut down. Useful if you need to clean resources up. [More...][23]| +| configureYulOptimizer | *Boolean* | false | (Experimental) Setting to `true` should resolve "stack too deep" compiler errrors in large projects using ABIEncoderV2 | [* Advanced use][14] diff --git a/plugins/hardhat.plugin.js b/plugins/hardhat.plugin.js index c5fe1d30..574e7abf 100644 --- a/plugins/hardhat.plugin.js +++ b/plugins/hardhat.plugin.js @@ -18,6 +18,7 @@ const { // Toggled true for `coverage` task only. let measureCoverage = false; +let configureYulOptimizer = false; let instrumentedSources // UI for the task flags... @@ -58,6 +59,17 @@ subtask(TASK_COMPILE_SOLIDITY_GET_COMPILATION_JOB_FOR_FILE).setAction(async (_, settings.metadata.useLiteralContent = false; // Override optimizer settings for all compilers settings.optimizer.enabled = false; + + // This is fixes a stack too deep bug in ABIEncoderV2 + // Experimental because not sure this works as expected across versions.... + if (configureYulOptimizer) { + settings.optimizer.details = { + yul: true, + yulDetails: { + stackAllocation: true, + }, + } + } } return compilationJob; }); @@ -127,6 +139,7 @@ task("coverage", "Generates a code coverage report for tests") ui.report('compilation', []); config.temp = args.temp; + configureYulOptimizer = api.config.configureYulOptimizer; // With Hardhat >= 2.0.4, everything should automatically recompile // after solidity-coverage corrupts the artifacts. diff --git a/test/integration/projects/solc-7/.solcover.js b/test/integration/projects/solc-7/.solcover.js index 4be0bbdb..fc5a56be 100644 --- a/test/integration/projects/solc-7/.solcover.js +++ b/test/integration/projects/solc-7/.solcover.js @@ -1,5 +1,6 @@ module.exports = { silent: process.env.SILENT ? true : false, skipFiles: ['skipped-folder'], - istanbulReporter: ['json-summary', 'text'] + istanbulReporter: ['json-summary', 'text'], + configureYulOptimizer: true }