Skip to content

Commit

Permalink
Add configureYulOptimizer option (#659)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Smythe <jason@smythemail.za.net>
  • Loading branch information
cgewecke and JasoonS authored Aug 27, 2021
1 parent ba94880 commit 593d1e3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions HARDHAT_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module.exports = {
| onCompileComplete[<sup>*</sup>][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[<sup>*</sup>][14] | *Function* | | Hook run *after* the tests complete, *before* Istanbul reports are generated. [More...][23]|
| onIstanbulComplete[<sup>*</sup>][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 |

[<sup>*</sup> Advanced use][14]

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ module.exports = {
| onCompileComplete[<sup>*</sup>][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[<sup>*</sup>][14] | *Function* | | Hook run *after* the tests complete, *before* Istanbul reports are generated. [More...][23]|
| onIstanbulComplete[<sup>*</sup>][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 |

[<sup>*</sup> Advanced use][14]

Expand Down
13 changes: 13 additions & 0 deletions plugins/hardhat.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const {

// Toggled true for `coverage` task only.
let measureCoverage = false;
let configureYulOptimizer = false;
let instrumentedSources

// UI for the task flags...
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion test/integration/projects/solc-7/.solcover.js
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 593d1e3

Please sign in to comment.