@@ -133,7 +133,6 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
133
133
/// ///////////////////////////////////
134
134
/// DEPLOY SOVEREIGN CONTRACTS ///
135
135
/// ///////////////////////////////////
136
- const genesisInfo = [ ] ;
137
136
138
137
// Load deployer
139
138
await ethers . provider . send ( 'hardhat_impersonateAccount' , [ timelockOwner ] ) ;
@@ -153,28 +152,12 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
153
152
154
153
const sovereignChainBridgeContract = bridgeDeploymentResult . contract as unknown as BridgeL2SovereignChain ;
155
154
156
- // Get the deployment transaction for bridge
157
- const txDeployBridge = await sovereignChainBridgeContract . deploymentTransaction ( ) ;
158
- const txDeployBridgeHash = txDeployBridge ? txDeployBridge . hash : undefined ;
159
- const tokenWrappedAddress = await sovereignChainBridgeContract . getWrappedTokenBridgeImplementation ( ) ;
160
-
161
- genesisInfo . push ( {
162
- isProxy : true ,
163
- name : GENESIS_CONTRACT_NAMES . SOVEREIGN_BRIDGE ,
164
- address : sovereignChainBridgeContract . target ,
165
- storagesWrites : await getTraceStorageWrites ( txDeployBridgeHash ) ,
166
- deployedAddresses : [
167
- {
168
- name : GENESIS_CONTRACT_NAMES . BYTECODE_STORER ,
169
- address : await sovereignChainBridgeContract . wrappedTokenBytecodeStorer ( ) ,
170
- } ,
171
- {
172
- name : GENESIS_CONTRACT_NAMES . TOKEN_WRAPPED_IMPLEMENTATION ,
173
- address : tokenWrappedAddress ,
174
- } ,
175
- ] ,
176
- } ) ;
177
-
155
+ // Get addresses from bridge deployment
156
+ const bridgeProxyAddress = sovereignChainBridgeContract . target ;
157
+ const bridgeImplAddress = ( await upgrades . erc1967 . getImplementationAddress ( bridgeProxyAddress ) ) . toLocaleLowerCase ( ) ;
158
+ const tokenWrappedAddress = (
159
+ await sovereignChainBridgeContract . getWrappedTokenBridgeImplementation ( )
160
+ ) . toLocaleLowerCase ( ) ;
178
161
// deploy GlobalExitRootManagerL2SovereignChain
179
162
const gerManagerL2SovereignChainFactory = await ethers . getContractFactory (
180
163
GENESIS_CONTRACT_NAMES . GER_L2_SOVEREIGN ,
@@ -189,6 +172,10 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
189
172
190
173
const gerManagerContract = gerDeploymentResult . contract as unknown as GlobalExitRootManagerL2SovereignChain ;
191
174
175
+ // Get addresses from ger deployment
176
+ const gerProxyAddress = gerManagerContract . target ;
177
+ const gerImplAddress = await upgrades . erc1967 . getImplementationAddress ( gerProxyAddress ) ;
178
+
192
179
/// ///////////////////////////////////
193
180
/// DEPLOY AGGORACLE COMMITTEE ////
194
181
/// ///////////////////////////////////
@@ -268,6 +255,8 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
268
255
proxiedTokensManager ,
269
256
) ;
270
257
258
+ const WETHTokenAddress = ( await sovereignChainBridgeContract . WETHToken ( ) ) . toLowerCase ( ) ;
259
+
271
260
logger . info ( 'Initializing GlobalExitRootManagerL2SovereignChain contract...' ) ;
272
261
// Initialize the GlobalExitRootManagerL2SovereignChain contract
273
262
const txInitializeGer = await gerManagerContract . initialize ( globalExitRootUpdater , globalExitRootRemover ) ;
@@ -281,6 +270,7 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
281
270
deployer ,
282
271
ethers . ZeroAddress , // PolygonRollupManager address not needed in L2
283
272
) ;
273
+ const timelockContractAddress = timelockContract . target . toString ( ) . toLowerCase ( ) ;
284
274
285
275
const txDeployTimelock = await timelockContract . deploymentTransaction ( ) ;
286
276
const txDeployTimelockHash = txDeployTimelock ? txDeployTimelock . hash : undefined ;
@@ -302,7 +292,7 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
302
292
) ;
303
293
const txRevokeTimelockAdminRole = await timelockContract . connect ( deployer ) . revokeRole (
304
294
ethers . id ( 'TIMELOCK_ADMIN_ROLE' ) ,
305
- timelockContract . target , // Revoke the role from the deployer
295
+ timelockContractAddress , // Revoke the role from the deployer
306
296
) ;
307
297
308
298
/// /////////////////////////////////
@@ -349,9 +339,8 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
349
339
350
340
// Get storage modifications for Bridge contract
351
341
logger . info ( 'Getting storage modifications for Bridge contract...' ) ;
352
- const bridgeStorageWrites = await getTraceStorageWrites ( txDeployBridgeHash ) ;
353
- const depthBridgeStorageWrites = 1 ;
354
- storageModifications . BridgeL2SovereignChain = bridgeStorageWrites [ depthBridgeStorageWrites ] ;
342
+ const bridgeStorageWrites = await getTraceStorageWrites ( bridgeDeploymentResult . txHashes . proxy , bridgeProxyAddress ) ;
343
+ storageModifications . BridgeL2SovereignChain = bridgeStorageWrites ;
355
344
356
345
// Get storage modifications for Bridge implementation
357
346
if ( bridgeDeploymentResult . txHashes . implementation ) {
@@ -360,14 +349,13 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
360
349
const implTx = await ethers . provider . getTransaction ( bridgeDeploymentResult . txHashes . implementation ) ;
361
350
if ( implTx ) {
362
351
const implStorageWrites = await getTraceStorageWrites ( bridgeDeploymentResult . txHashes . implementation ) ;
363
- const depthBridgeImpl = 1 ;
364
- const depthTokenWrappedImpl = 2 ;
365
- storageModifications . BridgeL2SovereignChain_Implementation = implStorageWrites [ depthBridgeImpl ] ;
352
+ storageModifications . BridgeL2SovereignChain_Implementation = implStorageWrites [ bridgeImplAddress ] ;
366
353
storageModifications . TokenWrappedBridgeUpgradeable_Implementation =
367
- implStorageWrites [ depthTokenWrappedImpl ] ;
354
+ implStorageWrites [ tokenWrappedAddress ] ;
368
355
}
369
356
} catch ( error ) {
370
357
logger . error ( 'Could not get Bridge implementation storage writes:' , error ) ;
358
+ throw new Error ( error )
371
359
}
372
360
}
373
361
// Get storage modifications for Bridge initialization
@@ -377,13 +365,10 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
377
365
const initTx = await ethers . provider . getTransaction ( txInitializeBridge . hash ) ;
378
366
if ( initTx ) {
379
367
const initStorageWrites = await getTraceStorageWrites ( txInitializeBridge . hash ) ;
380
- const depthBridgeInit = 2 ;
381
- const depthTokenWrappedProxy = 3 ;
382
- const depthTokenWrappedInit = 4 ;
383
- storageModifications . BridgeL2SovereignChain_Initialization = initStorageWrites [ depthBridgeInit ] ;
384
- storageModifications . TokenWrappedBridgeUpgradeable = initStorageWrites [ depthTokenWrappedProxy ] ;
368
+ storageModifications . BridgeL2SovereignChain_Initialization = initStorageWrites [ bridgeImplAddress ] ;
369
+ storageModifications . TokenWrappedBridgeUpgradeable = initStorageWrites [ WETHTokenAddress ] ;
385
370
storageModifications . TokenWrappedBridgeUpgradeable_Initialization =
386
- initStorageWrites [ depthTokenWrappedInit ] ;
371
+ initStorageWrites [ tokenWrappedAddress ] ;
387
372
}
388
373
} catch ( error ) {
389
374
logger . error ( 'Could not get Bridge initialization storage writes:' , error ) ;
@@ -400,9 +385,9 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
400
385
if ( implTx ) {
401
386
const implStorageWrites = await getTraceStorageWrites (
402
387
aggOracleCommitteeDeploymentResult . txHashes . implementation ,
388
+ aggOracleImplementationAddress
403
389
) ;
404
- const depthImplStorageWrites = 1 ;
405
- storageModifications . AggOracleCommittee_Implementation = implStorageWrites [ depthImplStorageWrites ] ;
390
+ storageModifications . AggOracleCommittee_Implementation = implStorageWrites ;
406
391
}
407
392
} catch ( error ) {
408
393
logger . error ( 'Could not get Bridge implementation storage writes:' , error ) ;
@@ -415,9 +400,9 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
415
400
if ( implTx ) {
416
401
const implStorageWrites = await getTraceStorageWrites (
417
402
aggOracleCommitteeDeploymentResult . txHashes . proxy ,
403
+ aggOracleCommitteeContract . target ,
418
404
) ;
419
- const depthImplStorageWrites = 1 ;
420
- storageModifications . AggOracleCommittee = implStorageWrites [ depthImplStorageWrites ] ;
405
+ storageModifications . AggOracleCommittee = implStorageWrites ;
421
406
}
422
407
} catch ( error ) {
423
408
logger . error ( 'Could not get Bridge proxy storage writes:' , error ) ;
@@ -428,9 +413,11 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
428
413
try {
429
414
const initTx = await ethers . provider . getTransaction ( txInitializeAggOracleCommittee . hash ) ;
430
415
if ( initTx ) {
431
- const initStorageWrites = await getTraceStorageWrites ( txInitializeAggOracleCommittee . hash ) ;
432
- const depthInitStorageWrites = 2 ;
433
- storageModifications . AggOracleCommittee_Initialization = initStorageWrites [ depthInitStorageWrites ] ;
416
+ const initStorageWrites = await getTraceStorageWrites (
417
+ txInitializeAggOracleCommittee . hash ,
418
+ aggOracleImplementationAddress ,
419
+ ) ;
420
+ storageModifications . AggOracleCommittee_Initialization = initStorageWrites ;
434
421
}
435
422
} catch ( error ) {
436
423
logger . error ( 'Could not get AggOracle initialization storage writes:' , error ) ;
@@ -443,9 +430,11 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
443
430
try {
444
431
const gerProxyTx = await ethers . provider . getTransaction ( gerDeploymentResult . txHashes . proxy ) ;
445
432
if ( gerProxyTx ) {
446
- const gerStorageWrites = await getTraceStorageWrites ( gerDeploymentResult . txHashes . proxy ) ;
447
- const depthGerStorageWrites = 1 ;
448
- storageModifications . GlobalExitRootManagerL2SovereignChain = gerStorageWrites [ depthGerStorageWrites ] ;
433
+ const gerStorageWrites = await getTraceStorageWrites (
434
+ gerDeploymentResult . txHashes . proxy ,
435
+ gerProxyAddress
436
+ ) ;
437
+ storageModifications . GlobalExitRootManagerL2SovereignChain = gerStorageWrites ;
449
438
}
450
439
} catch ( error ) {
451
440
logger . error ( 'Could not get GER proxy storage writes:' , error ) ;
@@ -458,10 +447,11 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
458
447
try {
459
448
const gerImplTx = await ethers . provider . getTransaction ( gerDeploymentResult . txHashes . implementation ) ;
460
449
if ( gerImplTx ) {
461
- const gerImplStorageWrites = await getTraceStorageWrites ( gerDeploymentResult . txHashes . implementation ) ;
462
- const depthGerImplStorageWrites = 1 ;
463
- storageModifications . GlobalExitRootManagerL2SovereignChain_Implementation =
464
- gerImplStorageWrites [ depthGerImplStorageWrites ] ;
450
+ const gerImplStorageWrites = await getTraceStorageWrites (
451
+ gerDeploymentResult . txHashes . implementation ,
452
+ gerImplAddress ,
453
+ ) ;
454
+ storageModifications . GlobalExitRootManagerL2SovereignChain_Implementation = gerImplStorageWrites ;
465
455
}
466
456
} catch ( error ) {
467
457
logger . error ( 'Could not get GER implementation storage writes:' , error ) ;
@@ -474,10 +464,8 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
474
464
try {
475
465
const gerInitTx = await ethers . provider . getTransaction ( txInitializeGer . hash ) ;
476
466
if ( gerInitTx ) {
477
- const gerInitStorageWrites = await getTraceStorageWrites ( txInitializeGer . hash ) ;
478
- const depthGerInitStorageWrites = 2 ;
479
- storageModifications . GlobalExitRootManagerL2SovereignChain_Initialization =
480
- gerInitStorageWrites [ depthGerInitStorageWrites ] ;
467
+ const gerInitStorageWrites = await getTraceStorageWrites ( txInitializeGer . hash , gerImplAddress ) ;
468
+ storageModifications . GlobalExitRootManagerL2SovereignChain_Initialization = gerInitStorageWrites ;
481
469
}
482
470
} catch ( error ) {
483
471
logger . error ( 'Could not get GER initialization storage writes:' , error ) ;
@@ -486,18 +474,20 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
486
474
487
475
// Get storage modifications for Timelock contract
488
476
logger . info ( 'Getting storage modifications for Timelock contract...' ) ;
489
- const timelockStorageWrites = await getTraceStorageWrites ( txDeployTimelockHash ) ;
490
- const depthTimelockStorageWrites = 1 ;
491
- storageModifications . PolygonZkEVMTimelock = timelockStorageWrites [ depthTimelockStorageWrites ] ;
492
- const timelockStorageAdmin = ( await getTraceStorageWrites ( txTimelockAdminRole . hash ) ) [ depthTimelockStorageWrites ] ;
493
- const timelockStorageRevokeAdmin = ( await getTraceStorageWrites ( txRevokeTimelockAdminRole . hash ) ) [ depthTimelockStorageWrites ] ;
477
+ const timelockStorageWrites = await getTraceStorageWrites ( txDeployTimelockHash , timelockContractAddress ) ;
478
+ storageModifications . PolygonZkEVMTimelock = timelockStorageWrites ;
479
+ const timelockStorageAdmin = await getTraceStorageWrites ( txTimelockAdminRole . hash , timelockContractAddress ) ;
480
+ const timelockStorageRevokeAdmin = await getTraceStorageWrites (
481
+ txRevokeTimelockAdminRole . hash ,
482
+ timelockContractAddress ,
483
+ ) ;
494
484
expect ( timelockStorageAdmin [ getStorageTimelockAdminRoleMember ( genesisBaseAddresses . timelockAddress ) ] ) . to . equal (
495
485
'0x0000000000000000000000000000000000000000000000000000000000000001' ,
496
486
) ;
497
- expect ( timelockStorageRevokeAdmin [ getStorageTimelockAdminRoleMember ( timelockContract . target ) ] ) . to . equal (
487
+ expect ( timelockStorageRevokeAdmin [ getStorageTimelockAdminRoleMember ( timelockContractAddress ) ] ) . to . equal (
498
488
'0x0000000000000000000000000000000000000000000000000000000000000000' ,
499
489
) ;
500
- storageModifications . PolygonZkEVMTimelock [ getStorageTimelockAdminRoleMember ( timelockContract . target ) ] =
490
+ storageModifications . PolygonZkEVMTimelock [ getStorageTimelockAdminRoleMember ( timelockContractAddress ) ] =
501
491
'0x0000000000000000000000000000000000000000000000000000000000000000' ;
502
492
storageModifications . PolygonZkEVMTimelock [ getStorageTimelockAdminRoleMember ( genesisBaseAddresses . timelockAddress ) ] =
503
493
'0x0000000000000000000000000000000000000000000000000000000000000001' ;
@@ -578,7 +568,7 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
578
568
expectedStorageModifications . PolygonZkEVMTimelock = getExpectedStoragePolygonZkEVMTimelock (
579
569
timelockMinDelay ,
580
570
genesisBaseAddresses . timelockAddress ,
581
- timelockContract . target ,
571
+ timelockContractAddress ,
582
572
) ;
583
573
584
574
/// //////////////////////////////
@@ -662,7 +652,7 @@ export async function createGenesisHardhat(_genesisBase: any, initializeParams:
662
652
// PolygonZkEVMTimelock
663
653
actualStorage . PolygonZkEVMTimelock = await getActualStorage (
664
654
storageModifications . PolygonZkEVMTimelock ,
665
- timelockContract . target ,
655
+ timelockContractAddress ,
666
656
) ;
667
657
668
658
if ( isDebug ) {
0 commit comments