From 988618b76bd22824e64a71f9d4940773a80722f6 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Thu, 25 Apr 2024 10:21:07 +0200 Subject: [PATCH] Properly calculate and configure validator addresses --- scripts/rollupCreation.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/rollupCreation.ts b/scripts/rollupCreation.ts index 3e1d300c..752b480a 100644 --- a/scripts/rollupCreation.ts +++ b/scripts/rollupCreation.ts @@ -77,6 +77,7 @@ export async function createRollup( rollupCreatorAbi, signer ) + const validatorWalletCreator = await rollupCreator.validatorWalletCreator() try { //// funds for deploying L2 factories @@ -96,7 +97,7 @@ export async function createRollup( // Call the createRollup function console.log('Calling createRollup to generate a new rollup ...') const deployParams = isDevDeployment - ? await _getDevRollupConfig(feeToken) + ? await _getDevRollupConfig(feeToken, validatorWalletCreator) : { config: config.rollupConfig, validators: config.validators, @@ -223,7 +224,10 @@ export async function createRollup( return null } -async function _getDevRollupConfig(feeToken: string) { +async function _getDevRollupConfig( + feeToken: string, + validatorWalletCreator: string +) { // set up owner address const ownerAddress = process.env.OWNER_ADDRESS !== undefined ? process.env.OWNER_ADDRESS : '' @@ -239,7 +243,7 @@ async function _getDevRollupConfig(feeToken: string) { parseInt(process.env.AUTHORIZE_VALIDATORS as string, 0) || 0 const validators: string[] = [] for (let i = 1; i <= authorizeValidators; i++) { - validators.push(ethers.Wallet.createRandom().address) + validators.push(_createValidatorAddress(validatorWalletCreator, i)) } // get chain config @@ -322,4 +326,15 @@ async function _getDevRollupConfig(feeToken: string) { batchPosters: batchPosters, batchPosterManager: batchPosterManager, } + + function _createValidatorAddress( + deployerAddress: string, + nonce: number + ): string { + const nonceHex = BigNumber.from(nonce).toHexString() + return ethers.utils.getContractAddress({ + from: deployerAddress, + nonce: nonceHex, + }) + } }