forked from keep-network/keep-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
210 lines (200 loc) · 6.11 KB
/
hardhat.config.ts
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
import "@nomiclabs/hardhat-etherscan"
import "@keep-network/hardhat-local-networks-config"
import "@keep-network/hardhat-helpers"
import "@nomiclabs/hardhat-ethers"
import "hardhat-deploy"
import "@tenderly/hardhat-tenderly"
import "@nomiclabs/hardhat-waffle"
import "hardhat-gas-reporter"
import "hardhat-contract-sizer"
import "@typechain/hardhat"
import "hardhat-dependency-compiler"
import "./tasks"
import { task } from "hardhat/config"
import type { HardhatUserConfig } from "hardhat/config"
const thresholdSolidityCompilerConfig = {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 10,
},
},
}
// Configuration for testing environment.
export const testConfig = {
// How many accounts we expect to define for non-staking related signers, e.g.
// deployer, thirdParty, governance.
// It is used as an offset for getting accounts for operators and stakes registration.
nonStakingAccountsCount: 10,
// How many roles do we need to define for staking, i.e. stakeOwner, stakingProvider,
// operator, beneficiary, authorizer.
stakingRolesCount: 5,
// Number of operators to register. Should be at least the same as group size.
operatorsCount: 64,
}
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
},
},
},
{
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
},
},
},
],
overrides: {
"@threshold-network/solidity-contracts/contracts/staking/TokenStaking.sol":
thresholdSolidityCompilerConfig,
},
},
paths: {
artifacts: "./build",
},
networks: {
hardhat: {
forking: {
// forking is enabled only if FORKING_URL env is provided
enabled: !!process.env.FORKING_URL,
// URL should point to a node with archival data (Alchemy recommended)
url: process.env.FORKING_URL || "",
// latest block is taken if FORKING_BLOCK env is not provided
blockNumber: process.env.FORKING_BLOCK
? parseInt(process.env.FORKING_BLOCK, 10)
: undefined,
},
accounts: {
// Number of accounts that should be predefined on the testing environment.
count:
testConfig.nonStakingAccountsCount +
testConfig.stakingRolesCount * testConfig.operatorsCount,
},
// we use higher gas price for tests to obtain more realistic results
// for gas refund tests than when the default hardhat ~1 gwei gas price is
// used
gasPrice: 200000000000, // 200 gwei
// Ignore contract size on deployment to hardhat network, to be able to
// deploy stub contracts in tests.
allowUnlimitedContractSize: process.env.TEST_USE_STUBS_BEACON === "true",
tags: ["allowStubs"],
},
development: {
url: "http://localhost:8545",
chainId: 1101,
tags: ["allowStubs"],
},
goerli: {
url: process.env.CHAIN_API_URL || "",
chainId: 5,
accounts: process.env.ACCOUNTS_PRIVATE_KEYS
? process.env.ACCOUNTS_PRIVATE_KEYS.split(",")
: undefined,
tags: ["etherscan", "tenderly"],
},
mainnet: {
url: process.env.CHAIN_API_URL || "",
chainId: 1,
accounts: process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY
? [process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY]
: undefined,
tags: ["etherscan", "tenderly"],
},
},
// // Define local networks configuration file path to load networks from the file.
// localNetworksConfig: "./.hardhat/networks.ts",
tenderly: {
username: "thesis",
project: "",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
namedAccounts: {
deployer: {
default: 1,
goerli: 0,
mainnet: 0, // "0x123694886DBf5Ac94DDA07135349534536D14cAf"
},
governance: {
default: 2,
goerli: 0,
mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", // Threshold Council
},
chaosnetOwner: {
default: 3,
goerli: 0,
mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", // Threshold Council
},
},
external: {
contracts:
process.env.USE_EXTERNAL_DEPLOY === "true"
? [
{
artifacts:
"node_modules/@threshold-network/solidity-contracts/export/artifacts",
deploy:
"node_modules/@threshold-network/solidity-contracts/export/deploy",
},
]
: undefined,
deployments: {
// For hardhat environment we can fork the mainnet, so we need to point it
// to the contract artifacts.
hardhat: process.env.FORKING_URL ? ["./external/mainnet"] : [],
// For development environment we expect the local dependencies to be linked
// with `yarn link` command.
development: [
"node_modules/@threshold-network/solidity-contracts/deployments/development",
],
goerli: ["node_modules/@threshold-network/solidity-contracts/artifacts"],
mainnet: ["./external/mainnet"],
},
},
dependencyCompiler: {
paths: [
"@threshold-network/solidity-contracts/contracts/token/T.sol",
"@threshold-network/solidity-contracts/contracts/staking/TokenStaking.sol",
],
keep: true,
},
contractSizer: {
alphaSort: true,
disambiguatePaths: false,
runOnCompile: true,
strict: true,
except: ["^contracts/test"],
},
mocha: {
timeout: 60000,
},
typechain: {
outDir: "typechain",
},
gasReporter: {
currency: "USD",
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
},
}
task("check-accounts-count", "Checks accounts count").setAction(async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires,global-require
const { constants } = require("./test/fixtures")
if (testConfig.operatorsCount < constants.groupSize) {
throw new Error(
"not enough accounts predefined for configured group size: " +
`expected group size: ${constants.groupSize} ` +
`number of predefined accounts: ${testConfig.operatorsCount}`
)
}
})
export default config