-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathhardhat.config.ts
More file actions
335 lines (323 loc) · 12.4 KB
/
hardhat.config.ts
File metadata and controls
335 lines (323 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
import '@nomicfoundation/hardhat-toolbox';
import 'dotenv/config';
import * as fs from 'fs';
import 'hardhat-dependency-compiler';
import 'hardhat-deploy';
import { HardhatUserConfig, task } from 'hardhat/config';
import {
HARDHAT_NETWORK_MNEMONIC,
defaultHardhatNetworkParams,
defaultLocalhostNetworkParams,
} from 'hardhat/internal/core/config/default-config';
import 'solidity-docgen';
import { cleanupDeployments, copyDeployments } from './scripts/tools/copy-deployments';
import chainConfig from './utils/config';
const isNativeChainType = chainConfig.isNativeChain();
const isLocalFork = process.env.LOCAL_FORK == 'true';
const isFujiFork = process.env.FUJI_FORK == 'true';
const isArbitrumSepoliaFork = process.env.ARBITRUM_SEPOLIA_FORK == 'true';
const isArbitrumFork = process.env.ARBITRUM_FORK == 'true';
const bellecourBlockscoutUrl = 'https://blockscout.bellecour.iex.ec';
/**
* @dev Native mode. As close as possible to the iExec Bellecour blockchain.
* @note Any fresh version of Hardhat uses for its default
* hardhat network a configuration from a recent Ethereum
* fork. EIPs brought by such recent fork are not necessarily
* supported by the iExec Bellecour blockchain.
*/
const bellecourBaseConfig = {
hardfork: 'berlin', // No EIP-1559 before London fork
gasPrice: 0,
blockGasLimit: 6_700_000,
};
// Avalanche Fuji specific configuration
const fujiBaseConfig = {
gasPrice: 25_000_000_000, // 25 Gwei default
blockGasLimit: 8_000_000,
chainId: 43113,
};
// Arbitrum Sepolia specific configuration
const arbitrumSepoliaBaseConfig = {
gasPrice: 100_000_000, // 0.1 Gwei default (Arbitrum has lower gas prices)
blockGasLimit: 30_000_000, // Arbitrum has higher block gas limits
chainId: 421614,
};
// Arbitrum specific configuration
const arbitrumBaseConfig = {
blockGasLimit: 30_000_000,
chainId: 42161,
};
const settings = {
optimizer: {
enabled: true,
runs: 200,
},
outputSelection: { '*': { '*': ['storageLayout'] } },
};
const v8Settings = {
...settings,
/**
* Enable Intermediate Representation (IR) to reduce `Stack too deep` occurrences
* at compile time (e.g.: too many local variables in `matchOrdersBoost`).
* https://hardhat.org/hardhat-runner/docs/reference/solidity-support#support-for-ir-based-codegen
*/
viaIR: true,
optimizer: {
...settings.optimizer,
details: {
yul: true,
yulDetails: {
optimizerSteps: 'u',
},
},
},
};
const config: HardhatUserConfig = {
solidity: {
compilers: [
{ version: '0.8.21', settings: v8Settings }, // PoCo Boost
{ version: '0.6.12', settings }, // PoCo contracts
{ version: '0.4.11', settings }, // RLC contracts
],
},
networks: {
hardhat: {
accounts: {
mnemonic: process.env.MNEMONIC || HARDHAT_NETWORK_MNEMONIC,
},
...((isNativeChainType || isLocalFork) && bellecourBaseConfig),
...(isLocalFork && {
forking: {
url: 'https://bellecour.iex.ec',
},
chainId: 134,
}),
...(isFujiFork && {
forking: {
url: process.env.FUJI_RPC_URL || 'https://api.avax-test.network/ext/bc/C/rpc',
blockNumber: process.env.FUJI_BLOCK_NUMBER
? parseInt(process.env.FUJI_BLOCK_NUMBER)
: undefined,
},
...fujiBaseConfig,
}),
...(isArbitrumSepoliaFork && {
forking: {
url:
process.env.ARBITRUM_SEPOLIA_RPC_URL ||
'https://sepolia-rollup.arbitrum.io/rpc',
blockNumber: process.env.ARBITRUM_SEPOLIA_BLOCK_NUMBER
? parseInt(process.env.ARBITRUM_SEPOLIA_BLOCK_NUMBER)
: undefined,
},
...arbitrumSepoliaBaseConfig,
}),
...(isArbitrumFork && {
forking: {
url: process.env.ARBITRUM_RPC_URL || 'https://arbitrum.gateway.tenderly.co',
},
...arbitrumBaseConfig,
}),
},
'external-hardhat': {
...defaultHardhatNetworkParams,
...defaultLocalhostNetworkParams,
accounts: {
mnemonic: process.env.MNEMONIC || HARDHAT_NETWORK_MNEMONIC,
},
...((isNativeChainType || isLocalFork) && bellecourBaseConfig),
...(isLocalFork && {
accounts: 'remote', // Override defaults accounts for impersonation
chainId: 134,
}),
...(isFujiFork && {
accounts: 'remote', // Override defaults accounts for impersonation
...fujiBaseConfig,
}),
...(isArbitrumSepoliaFork && {
accounts: 'remote', // Override defaults accounts for impersonation
...arbitrumSepoliaBaseConfig,
}),
...(isArbitrumFork && {
accounts: 'remote', // Override defaults accounts for impersonation
...arbitrumBaseConfig,
}),
},
'dev-native': {
chainId: 65535,
url: process.env.DEV_NODE || 'http://localhost:8545',
accounts: {
mnemonic: process.env.MNEMONIC || '',
},
gasPrice: bellecourBaseConfig.gasPrice, // Get closer to Bellecour network
},
'dev-token': {
chainId: 65535,
url: process.env.DEV_NODE || 'http://localhost:8545',
accounts: {
mnemonic: process.env.MNEMONIC || '',
},
// When deploying on a blockchain with EIP-1559 enabled and
// force-sealing disabled, deployment gets stuck if gasPrice is
// not manually set. Other approaches might be considered here.
gasPrice: 8_000_000_000, // 8 Gwei
},
avalancheFujiTestnet: {
url:
process.env.FUJI_RPC_URL || // Used in local development
process.env.RPC_URL || // Defined in Github Actions environments
'https://api.avax-test.network/ext/bc/C/rpc',
accounts: [
process.env.DEPLOYER_PRIVATE_KEY ||
'0x0000000000000000000000000000000000000000000000000000000000000000',
],
...fujiBaseConfig,
},
arbitrum: {
url:
process.env.ARBITRUM_RPC_URL || // Used in local development
process.env.RPC_URL || // Defined in Github Actions environments
'https://arbitrum.gateway.tenderly.co',
accounts: [
process.env.DEPLOYER_PRIVATE_KEY ||
'0x0000000000000000000000000000000000000000000000000000000000000000',
],
...arbitrumBaseConfig,
},
arbitrumSepolia: {
url:
process.env.ARBITRUM_SEPOLIA_RPC_URL || // Used in local development
process.env.RPC_URL || // Defined in Github Actions environments
'https://sepolia-rollup.arbitrum.io/rpc',
accounts: [
process.env.DEPLOYER_PRIVATE_KEY ||
'0x0000000000000000000000000000000000000000000000000000000000000000',
],
...arbitrumSepoliaBaseConfig,
},
bellecour: {
chainId: 134,
url: 'https://bellecour.iex.ec',
accounts: [
process.env.DEPLOYER_PRIVATE_KEY ||
'0x0000000000000000000000000000000000000000000000000000000000000000',
],
...bellecourBaseConfig,
verify: {
etherscan: {
apiUrl: bellecourBlockscoutUrl,
apiKey: '<>',
},
},
},
},
etherscan: {
// TODO migrate to Etherscan V2 API and use process.env.EXPLORER_API_KEY
apiKey: {
arbitrumOne: process.env.ARBISCAN_API_KEY || '', // This name is required by the plugin.
avalancheFujiTestnet: 'nothing', // a non-empty string is needed by the plugin.
arbitrumSepolia: process.env.ARBISCAN_API_KEY || '',
bellecour: 'nothing', // a non-empty string is needed by the plugin.
},
customChains: [
{
network: 'viviani',
chainId: 133,
urls: {
apiURL: 'https://blockscout.viviani.iex.ec/api',
browserURL: 'https://blockscout.viviani.iex.ec/',
},
},
{
network: 'bellecour',
chainId: 134,
urls: {
apiURL: `${bellecourBlockscoutUrl}/api`,
browserURL: bellecourBlockscoutUrl,
},
},
],
},
sourcify: {
enabled: true,
},
typechain: {
outDir: 'typechain',
},
dependencyCompiler: {
paths: [
'rlc-faucet-contract/contracts/RLC.sol',
// ERC-2535 Diamond
'@mudgen/diamond-1/contracts/facets/DiamondCutFacet.sol',
'@mudgen/diamond-1/contracts/facets/DiamondLoupeFacet.sol',
'@mudgen/diamond-1/contracts/facets/OwnershipFacet.sol',
'@mudgen/diamond-1/contracts/libraries/LibDiamond.sol',
'@mudgen/diamond-1/contracts/upgradeInitializers/DiamondInit.sol',
// Used as mock or fake in UTs
'@openzeppelin/contracts-v5/interfaces/IERC1271.sol',
// Used in deployment
'@amxx/factory/contracts/v6/GenericFactory.sol',
'createx/src/ICreateX.sol',
],
keep: true, // Slither requires compiled dependencies
},
docgen: {
outputDir: 'docs/solidity',
templates: 'docs/solidity/templates',
exclude: [
'external',
'facets/FacetBase.sol', // duplicated in FacetBase.v8.sol
'facets/IexecAccessorsABILegacyFacet.sol', // not relevant
// kept for events 'facets/IexecERC20Core.sol', // contains only internal/private
'facets/IexecEscrowTokenSwapFacet.sol', // not relevant
// kept for events 'facets/IexecEscrow.v8.sol', // contains only internal/private
'facets/IexecPocoCommon.sol', // contains only internal/private
'facets/SignatureVerifier.sol', // contains only internal/private
'facets/SignatureVerifier.v8.sol',
'interfaces', // interesting for events but too much doc duplication if enabled
'tools',
'Diamond.sol', // not relevant
'IexecInterfaceNativeABILegacy.sol', // not relevant
'IexecInterfaceTokenABILegacy.sol', // not relevant
],
},
mocha: { timeout: 300000 },
};
/**
* Ignore doc generation of contracts compiled with solc@0.4 (unsupported by docgen).
*/
task('docgen').setAction(async (taskArgs, hre, runSuper) => {
const ignoredSuffix = '.docgen-ignored';
const ignoredPaths: string[] = [];
for (const path of await hre.artifacts.getBuildInfoPaths()) {
const solcVersion: string = JSON.parse(fs.readFileSync(path, 'utf8')).solcVersion;
if (solcVersion.startsWith('0.4')) {
fs.renameSync(path, path + ignoredSuffix); // mark as docgen ignored
ignoredPaths.push(path);
}
}
await runSuper(taskArgs).finally(() => {
for (const path of ignoredPaths) {
fs.renameSync(path + ignoredSuffix, path); // restore build info as before
}
});
});
task('test').setAction(async (taskArgs: any, hre, runSuper) => {
let deploymentsCopied = false;
let networkName = '';
try {
if (process.env.ARBITRUM_SEPOLIA_FORK === 'true') {
networkName = 'arbitrumSepolia';
deploymentsCopied = await copyDeployments(networkName);
} else if (process.env.FUJI_FORK === 'true') {
networkName = 'avalancheFujiTestnet';
deploymentsCopied = await copyDeployments(networkName);
}
await runSuper(taskArgs);
} finally {
if (deploymentsCopied && networkName) {
await cleanupDeployments(networkName);
}
}
});
export default config;