@@ -432,26 +432,38 @@ export const deployL1Contracts = async (
432
432
txHashes . push ( txHash ) ;
433
433
}
434
434
435
- if ( args . initialValidators && args . initialValidators . length > 0 ) {
435
+ const attesters = ( await rollup . read
436
+ . getAttesters ( [ ] )
437
+ . then ( attesters =>
438
+ ( attesters as `0x${string } `[ ] ) . map ( attester => EthAddress . fromString ( attester . toString ( ) ) ) ,
439
+ ) ) as EthAddress [ ] ;
440
+
441
+ logger . debug ( `Existing attesters` , attesters ) ;
442
+
443
+ const newAttesters = ( args . initialValidators ?? [ ] ) . filter ( v => ! attesters . some ( a => a . equals ( v ) ) ) ;
444
+
445
+ if ( newAttesters . length > 0 ) {
436
446
// Mint tokens, approve them, use cheat code to initialise validator set without setting up the epoch.
437
- const stakeNeeded = MINIMUM_STAKE * BigInt ( args . initialValidators . length ) ;
447
+ const stakeNeeded = MINIMUM_STAKE * BigInt ( newAttesters . length ) ;
438
448
await Promise . all (
439
449
[
440
450
await stakingAsset . write . mint ( [ walletClient . account . address , stakeNeeded ] , { } as any ) ,
441
451
await stakingAsset . write . approve ( [ rollupAddress . toString ( ) , stakeNeeded ] , { } as any ) ,
442
452
] . map ( txHash => publicClient . waitForTransactionReceipt ( { hash : txHash } ) ) ,
443
453
) ;
444
454
455
+ logger . info ( `Minted ${ newAttesters . length } validators` ) ;
456
+
445
457
const initiateValidatorSetTxHash = await rollup . write . cheat__InitialiseValidatorSet ( [
446
- args . initialValidators . map ( v => ( {
458
+ newAttesters . map ( v => ( {
447
459
attester : v . toString ( ) ,
448
460
proposer : v . toString ( ) ,
449
461
withdrawer : v . toString ( ) ,
450
462
amount : MINIMUM_STAKE ,
451
463
} ) ) ,
452
464
] ) ;
453
465
txHashes . push ( initiateValidatorSetTxHash ) ;
454
- logger . info ( `Initialized validator set (${ args . initialValidators . join ( ', ' ) } ) in tx ${ initiateValidatorSetTxHash } ` ) ;
466
+ logger . info ( `Initialized validator set (${ newAttesters . join ( ', ' ) } ) in tx ${ initiateValidatorSetTxHash } ` ) ;
455
467
}
456
468
457
469
// @note This value MUST match what is in `constants.nr`. It is currently specified here instead of just importing
@@ -521,6 +533,7 @@ export const deployL1Contracts = async (
521
533
client : walletClient ,
522
534
} ) ;
523
535
if ( ! ( await registryContract . read . isRollupRegistered ( [ getAddress ( rollupAddress . toString ( ) ) ] ) ) ) {
536
+ logger . info ( `Registry ${ registryAddress } is not registered to rollup ${ rollupAddress } ` ) ;
524
537
const upgradeTxHash = await registryContract . write . upgrade ( [ getAddress ( rollupAddress . toString ( ) ) ] , { account } ) ;
525
538
logger . verbose (
526
539
`Upgrading registry contract at ${ registryAddress } to rollup ${ rollupAddress } in tx ${ upgradeTxHash } ` ,
0 commit comments