1
1
/// 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
10
10
11
11
const fs = require ( 'fs' ) ;
12
12
const path = require ( 'path' ) ;
@@ -25,11 +25,10 @@ const { argv } = require('yargs/yargs')()
25
25
type : 'string' ,
26
26
default : 'contracts' ,
27
27
} ,
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 ,
33
32
} ,
34
33
ir : {
35
34
alias : 'enableIR' ,
@@ -69,9 +68,6 @@ for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
69
68
require ( path . join ( __dirname , 'hardhat' , f ) ) ;
70
69
}
71
70
72
- const withOptimizations = argv . gas || argv . coverage || argv . compileMode === 'production' ;
73
- const allowUnlimitedContractSize = argv . gas || argv . coverage || argv . compileMode === 'development' ;
74
-
75
71
/**
76
72
* @type import('hardhat/config').HardhatUserConfig
77
73
*/
@@ -80,11 +76,11 @@ module.exports = {
80
76
version : argv . compiler ,
81
77
settings : {
82
78
optimizer : {
83
- enabled : withOptimizations ,
84
- runs : 200 ,
79
+ enabled : true ,
80
+ runs : argv . runs ,
85
81
} ,
86
82
evmVersion : argv . evm ,
87
- viaIR : withOptimizations && argv . ir ,
83
+ viaIR : argv . ir ,
88
84
outputSelection : { '*' : { '*' : [ 'storageLayout' ] } } ,
89
85
} ,
90
86
} ,
@@ -94,7 +90,7 @@ module.exports = {
94
90
'initcode-size' : 'off' ,
95
91
} ,
96
92
'*' : {
97
- 'code-size' : withOptimizations ,
93
+ 'code-size' : true ,
98
94
'unused-param' : ! argv . coverage , // coverage causes unused-param warnings
99
95
'transient-storage' : false ,
100
96
default : 'error' ,
@@ -103,7 +99,9 @@ module.exports = {
103
99
networks : {
104
100
hardhat : {
105
101
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 ,
107
105
initialBaseFeePerGas : argv . coverage ? 0 : undefined ,
108
106
} ,
109
107
} ,
0 commit comments