Skip to content

Commit

Permalink
Merge pull request #174 from OffchainLabs/validator-wallet-fix
Browse files Browse the repository at this point in the history
Properly calculate and configure validator addresses
  • Loading branch information
godzillaba committed Apr 25, 2024
2 parents 6c4da9d + 988618b commit 2e8eeb9
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions scripts/rollupCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export async function createRollup(
rollupCreatorAbi,
signer
)
const validatorWalletCreator = await rollupCreator.validatorWalletCreator()

try {
//// funds for deploying L2 factories
Expand All @@ -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,
Expand Down Expand Up @@ -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 : ''
Expand All @@ -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
Expand Down Expand Up @@ -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,
})
}
}

0 comments on commit 2e8eeb9

Please sign in to comment.