Skip to content

Commit 5d59591

Browse files
karim-enkiselnolga24912
authored
Implement proxy contract (#66)
* Implement proxy contract * Add check for previous events * Add second solution * Revert naming changes from 331c8bf to make code consistent with mainnet-deployed contracts * Remove second solution for proxy contract. Add necessary functions * Add tests for eth custodian proxy * Remove leftover variables * Remove unused code * Convert SelectivePausable contract to namespaced storage (eip-7201) * Combine withdraw functionality into a single function * Add generic admin method on the proxy * Correct deployment script * Test corrections * Update constant * Fixed event name in tests * update config * add etherscan verififcation * update admin scripts * PAUSED_WITHDRAW -> PAUSED_WITHDRAW_POST_MIGRATION * add fee for backword compatibility * emit Deposited event in Proxy Contract * Add gap for future implementation of ProofKeeper for the proxy * Update gap value * Add `updateAdminLegacy` script * Fix verification * Update hardhat and ethers to v6 * Fix test * Extract block height from proof (#67) * draft getBlockHeightFromProof * debug * fix extract block height from proof * fix tests and contract * separate BlockHeightFromProofExtractor * add new test * fix tests * fix tests * add checkPreMigration flag * add test with switched off preMigration check * add comments about proof structure * add comment for withdraw function * checkPreMigration -> receiptBlockHeight * Add upgrade script --------- Co-authored-by: imherefortech <[email protected]> Co-authored-by: kiseln <[email protected]> Co-authored-by: Olga Kunyavskaya <[email protected]> Co-authored-by: Olga Kunyavskaya <[email protected]>
1 parent 8bf4ae7 commit 5d59591

28 files changed

+7034
-6579
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ After that call: <br />
138138
As a result of the function call you will get the address of the freshly deployed `EthCustodian` that you can put in
139139
your `ethereum-config.json` file in the `ethConnectorAddress` field.
140140

141+
After `ethConnectorAddress` is set, you can run
142+
143+
`$ make eth-deploy-proxy`
144+
145+
to deploy the proxy contract and make it the admin of `EthCustodian`.
146+
141147
### Other scripts
142148

143149
For more advanced usage, please examine the `hardhat.config.js` file which contains a lot of scripts that are performed
+350
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,350 @@
1+
{
2+
"manifestVersion": "3.2",
3+
"proxies": [
4+
{
5+
"address": "0x4C8afA2fD22dB1c6091A96c382e6546529475B5c",
6+
"txHash": "0x5d7ff3f8b6d8b5f1ba7a4948769e35b4221f0ba451be69d66097dab976cd7545",
7+
"kind": "uups"
8+
}
9+
],
10+
"impls": {
11+
"9346696a759d727ad8297a3bc36e68f05c2afa8a33630ff7e9e3a2378b9b093d": {
12+
"address": "0xfCFF3475142cE152930dE7Aa6da85D855c106812",
13+
"txHash": "0xe20ac4395ad7c790b833f3f33281f58e155d30f30c86be4070d761d3511daccf",
14+
"layout": {
15+
"solcVersion": "0.8.20",
16+
"storage": [
17+
{
18+
"label": "__gap",
19+
"offset": 0,
20+
"slot": "0",
21+
"type": "t_array(t_uint256)50_storage",
22+
"contract": "ProofKeeperGap",
23+
"src": "contracts/ProofKeeperGap.sol:7"
24+
},
25+
{
26+
"label": "_pausedFlags",
27+
"offset": 0,
28+
"slot": "50",
29+
"type": "t_uint256",
30+
"contract": "SelectivePausableUpgradable",
31+
"src": "contracts/SelectivePausableUpgradable.sol:37"
32+
},
33+
{
34+
"label": "preMigrationProducerAccount",
35+
"offset": 0,
36+
"slot": "51",
37+
"type": "t_bytes_storage",
38+
"contract": "EthCustodianProxy",
39+
"src": "contracts/EthCustodianProxy.sol:32"
40+
},
41+
{
42+
"label": "migrationBlockHeight",
43+
"offset": 0,
44+
"slot": "52",
45+
"type": "t_uint64",
46+
"contract": "EthCustodianProxy",
47+
"src": "contracts/EthCustodianProxy.sol:33"
48+
},
49+
{
50+
"label": "ethCustodianImpl",
51+
"offset": 8,
52+
"slot": "52",
53+
"type": "t_contract(EthCustodian)2135",
54+
"contract": "EthCustodianProxy",
55+
"src": "contracts/EthCustodianProxy.sol:35"
56+
}
57+
],
58+
"types": {
59+
"t_address": {
60+
"label": "address",
61+
"numberOfBytes": "20"
62+
},
63+
"t_bool": {
64+
"label": "bool",
65+
"numberOfBytes": "1"
66+
},
67+
"t_bytes32": {
68+
"label": "bytes32",
69+
"numberOfBytes": "32"
70+
},
71+
"t_mapping(t_address,t_bool)": {
72+
"label": "mapping(address => bool)",
73+
"numberOfBytes": "32"
74+
},
75+
"t_mapping(t_bytes32,t_struct(RoleData)25_storage)": {
76+
"label": "mapping(bytes32 => struct AccessControlUpgradeable.RoleData)",
77+
"numberOfBytes": "32"
78+
},
79+
"t_struct(AccessControlStorage)35_storage": {
80+
"label": "struct AccessControlUpgradeable.AccessControlStorage",
81+
"members": [
82+
{
83+
"label": "_roles",
84+
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
85+
"offset": 0,
86+
"slot": "0"
87+
}
88+
],
89+
"numberOfBytes": "32"
90+
},
91+
"t_struct(InitializableStorage)95_storage": {
92+
"label": "struct Initializable.InitializableStorage",
93+
"members": [
94+
{
95+
"label": "_initialized",
96+
"type": "t_uint64",
97+
"offset": 0,
98+
"slot": "0"
99+
},
100+
{
101+
"label": "_initializing",
102+
"type": "t_bool",
103+
"offset": 8,
104+
"slot": "0"
105+
}
106+
],
107+
"numberOfBytes": "32"
108+
},
109+
"t_struct(RoleData)25_storage": {
110+
"label": "struct AccessControlUpgradeable.RoleData",
111+
"members": [
112+
{
113+
"label": "hasRole",
114+
"type": "t_mapping(t_address,t_bool)",
115+
"offset": 0,
116+
"slot": "0"
117+
},
118+
{
119+
"label": "adminRole",
120+
"type": "t_bytes32",
121+
"offset": 0,
122+
"slot": "1"
123+
}
124+
],
125+
"numberOfBytes": "64"
126+
},
127+
"t_uint64": {
128+
"label": "uint64",
129+
"numberOfBytes": "8"
130+
},
131+
"t_array(t_uint256)50_storage": {
132+
"label": "uint256[50]",
133+
"numberOfBytes": "1600"
134+
},
135+
"t_bytes_storage": {
136+
"label": "bytes",
137+
"numberOfBytes": "32"
138+
},
139+
"t_contract(EthCustodian)2135": {
140+
"label": "contract EthCustodian",
141+
"numberOfBytes": "20"
142+
},
143+
"t_uint256": {
144+
"label": "uint256",
145+
"numberOfBytes": "32"
146+
}
147+
},
148+
"namespaces": {
149+
"erc7201:openzeppelin.storage.AccessControl": [
150+
{
151+
"contract": "AccessControlUpgradeable",
152+
"label": "_roles",
153+
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
154+
"src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:61",
155+
"offset": 0,
156+
"slot": "0"
157+
}
158+
],
159+
"erc7201:openzeppelin.storage.Initializable": [
160+
{
161+
"contract": "Initializable",
162+
"label": "_initialized",
163+
"type": "t_uint64",
164+
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69",
165+
"offset": 0,
166+
"slot": "0"
167+
},
168+
{
169+
"contract": "Initializable",
170+
"label": "_initializing",
171+
"type": "t_bool",
172+
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73",
173+
"offset": 8,
174+
"slot": "0"
175+
}
176+
]
177+
}
178+
}
179+
},
180+
"11c941e83dcf4b3077416195d38866dd6a19bfa50b4b6f48b442e18bd8d9a69a": {
181+
"address": "0x47996EC1CE791225DcA05fDC7d7eB74e552c05e6",
182+
"txHash": "0x647557339ffd586f4de322a9b23915952cb61c421530a6211fac13e864849db9",
183+
"layout": {
184+
"solcVersion": "0.8.20",
185+
"storage": [
186+
{
187+
"label": "__gap",
188+
"offset": 0,
189+
"slot": "0",
190+
"type": "t_array(t_uint256)50_storage",
191+
"contract": "ProofKeeperGap",
192+
"src": "contracts/ProofKeeperGap.sol:7"
193+
},
194+
{
195+
"label": "_pausedFlags",
196+
"offset": 0,
197+
"slot": "50",
198+
"type": "t_uint256",
199+
"contract": "SelectivePausableUpgradable",
200+
"src": "contracts/SelectivePausableUpgradable.sol:37"
201+
},
202+
{
203+
"label": "preMigrationProducerAccount",
204+
"offset": 0,
205+
"slot": "51",
206+
"type": "t_bytes_storage",
207+
"contract": "EthCustodianProxy",
208+
"src": "contracts/EthCustodianProxy.sol:33"
209+
},
210+
{
211+
"label": "migrationBlockHeight",
212+
"offset": 0,
213+
"slot": "52",
214+
"type": "t_uint64",
215+
"contract": "EthCustodianProxy",
216+
"src": "contracts/EthCustodianProxy.sol:34"
217+
},
218+
{
219+
"label": "ethCustodianImpl",
220+
"offset": 8,
221+
"slot": "52",
222+
"type": "t_contract(EthCustodian)2368",
223+
"contract": "EthCustodianProxy",
224+
"src": "contracts/EthCustodianProxy.sol:36"
225+
}
226+
],
227+
"types": {
228+
"t_address": {
229+
"label": "address",
230+
"numberOfBytes": "20"
231+
},
232+
"t_bool": {
233+
"label": "bool",
234+
"numberOfBytes": "1"
235+
},
236+
"t_bytes32": {
237+
"label": "bytes32",
238+
"numberOfBytes": "32"
239+
},
240+
"t_mapping(t_address,t_bool)": {
241+
"label": "mapping(address => bool)",
242+
"numberOfBytes": "32"
243+
},
244+
"t_mapping(t_bytes32,t_struct(RoleData)25_storage)": {
245+
"label": "mapping(bytes32 => struct AccessControlUpgradeable.RoleData)",
246+
"numberOfBytes": "32"
247+
},
248+
"t_struct(AccessControlStorage)35_storage": {
249+
"label": "struct AccessControlUpgradeable.AccessControlStorage",
250+
"members": [
251+
{
252+
"label": "_roles",
253+
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
254+
"offset": 0,
255+
"slot": "0"
256+
}
257+
],
258+
"numberOfBytes": "32"
259+
},
260+
"t_struct(InitializableStorage)95_storage": {
261+
"label": "struct Initializable.InitializableStorage",
262+
"members": [
263+
{
264+
"label": "_initialized",
265+
"type": "t_uint64",
266+
"offset": 0,
267+
"slot": "0"
268+
},
269+
{
270+
"label": "_initializing",
271+
"type": "t_bool",
272+
"offset": 8,
273+
"slot": "0"
274+
}
275+
],
276+
"numberOfBytes": "32"
277+
},
278+
"t_struct(RoleData)25_storage": {
279+
"label": "struct AccessControlUpgradeable.RoleData",
280+
"members": [
281+
{
282+
"label": "hasRole",
283+
"type": "t_mapping(t_address,t_bool)",
284+
"offset": 0,
285+
"slot": "0"
286+
},
287+
{
288+
"label": "adminRole",
289+
"type": "t_bytes32",
290+
"offset": 0,
291+
"slot": "1"
292+
}
293+
],
294+
"numberOfBytes": "64"
295+
},
296+
"t_uint64": {
297+
"label": "uint64",
298+
"numberOfBytes": "8"
299+
},
300+
"t_array(t_uint256)50_storage": {
301+
"label": "uint256[50]",
302+
"numberOfBytes": "1600"
303+
},
304+
"t_bytes_storage": {
305+
"label": "bytes",
306+
"numberOfBytes": "32"
307+
},
308+
"t_contract(EthCustodian)2368": {
309+
"label": "contract EthCustodian",
310+
"numberOfBytes": "20"
311+
},
312+
"t_uint256": {
313+
"label": "uint256",
314+
"numberOfBytes": "32"
315+
}
316+
},
317+
"namespaces": {
318+
"erc7201:openzeppelin.storage.AccessControl": [
319+
{
320+
"contract": "AccessControlUpgradeable",
321+
"label": "_roles",
322+
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
323+
"src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:61",
324+
"offset": 0,
325+
"slot": "0"
326+
}
327+
],
328+
"erc7201:openzeppelin.storage.Initializable": [
329+
{
330+
"contract": "Initializable",
331+
"label": "_initialized",
332+
"type": "t_uint64",
333+
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69",
334+
"offset": 0,
335+
"slot": "0"
336+
},
337+
{
338+
"contract": "Initializable",
339+
"label": "_initializing",
340+
"type": "t_bool",
341+
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73",
342+
"offset": 8,
343+
"slot": "0"
344+
}
345+
]
346+
}
347+
}
348+
}
349+
}
350+
}

0 commit comments

Comments
 (0)