Skip to content

Commit 20f486b

Browse files
Transpile 01cae331
1 parent 05dbbff commit 20f486b

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

foundry.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[profile.default]
22
solc_version = '0.8.24'
33
evm_version = 'cancun'
4+
optimizer = true
5+
optimizer-runs = 200
46
src = 'contracts'
57
out = 'out'
68
libs = ['node_modules', 'lib']

hardhat.config.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// ENVVAR
2-
// - COMPILE_VERSION: compiler version (default: 0.8.20)
3-
// - SRC: contracts folder to compile (default: contracts)
4-
// - COMPILE_MODE: production modes enables optimizations (default: development)
5-
// - IR: enable IR compilation (default: false)
6-
// - COVERAGE: enable coverage report
7-
// - ENABLE_GAS_REPORT: enable gas report
8-
// - COINMARKETCAP: coinmarkercat api key for USD value in gas report
9-
// - CI: output gas report to file instead of stdout
2+
// - COMPILER: compiler version (default: 0.8.24)
3+
// - SRC: contracts folder to compile (default: contracts)
4+
// - RUNS: number of optimization runs (default: 200)
5+
// - IR: enable IR compilation (default: false)
6+
// - COVERAGE: enable coverage report (default: false)
7+
// - GAS: enable gas report (default: false)
8+
// - COINMARKETCAP: coinmarketcap api key for USD value in gas report
9+
// - CI: output gas report to file instead of stdout
1010

1111
const fs = require('fs');
1212
const path = require('path');
@@ -25,11 +25,10 @@ const { argv } = require('yargs/yargs')()
2525
type: 'string',
2626
default: 'contracts',
2727
},
28-
mode: {
29-
alias: 'compileMode',
30-
type: 'string',
31-
choices: ['production', 'development'],
32-
default: 'development',
28+
runs: {
29+
alias: 'optimizationRuns',
30+
type: 'number',
31+
default: 200,
3332
},
3433
ir: {
3534
alias: 'enableIR',
@@ -69,9 +68,6 @@ for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
6968
require(path.join(__dirname, 'hardhat', f));
7069
}
7170

72-
const withOptimizations = argv.gas || argv.coverage || argv.compileMode === 'production';
73-
const allowUnlimitedContractSize = argv.gas || argv.coverage || argv.compileMode === 'development';
74-
7571
/**
7672
* @type import('hardhat/config').HardhatUserConfig
7773
*/
@@ -80,11 +76,11 @@ module.exports = {
8076
version: argv.compiler,
8177
settings: {
8278
optimizer: {
83-
enabled: withOptimizations,
84-
runs: 200,
79+
enabled: true,
80+
runs: argv.runs,
8581
},
8682
evmVersion: argv.evm,
87-
viaIR: withOptimizations && argv.ir,
83+
viaIR: argv.ir,
8884
outputSelection: { '*': { '*': ['storageLayout'] } },
8985
},
9086
},
@@ -94,7 +90,7 @@ module.exports = {
9490
'initcode-size': 'off',
9591
},
9692
'*': {
97-
'code-size': withOptimizations,
93+
'code-size': true,
9894
'unused-param': !argv.coverage, // coverage causes unused-param warnings
9995
'transient-storage': false,
10096
default: 'error',
@@ -103,7 +99,9 @@ module.exports = {
10399
networks: {
104100
hardhat: {
105101
hardfork: argv.evm,
106-
allowUnlimitedContractSize,
102+
// Exposed contracts often exceed the maximum contract size. For normal contract,
103+
// we rely on the `code-size` compiler warning, that will cause a compilation error.
104+
allowUnlimitedContractSize: true,
107105
initialBaseFeePerGas: argv.coverage ? 0 : undefined,
108106
},
109107
},

0 commit comments

Comments
 (0)