diff --git a/scripts/l3Configuration.ts b/scripts/l3Configuration.ts index f441e49..6f0f92f 100644 --- a/scripts/l3Configuration.ts +++ b/scripts/l3Configuration.ts @@ -7,7 +7,8 @@ import fs from 'fs' export async function l3Configuration( privateKey: string, L2_RPC_URL: string, - L3_RPC_URL: string + L3_RPC_URL: string, + setL1Price: boolean ) { if (!privateKey || !L2_RPC_URL || !L3_RPC_URL) { throw new Error('Required environment variable not found') @@ -116,40 +117,49 @@ export async function l3Configuration( l2signer ) - console.log('Getting L1 base fee estimate') - const l1BaseFeeEstimate = await ArbOGasInfo.getL1BaseFeeEstimate() - console.log(`L1 Base Fee estimate on L2 is ${l1BaseFeeEstimate.toNumber()}`) - const l2Basefee = await L2Provider.getGasPrice() - const totalGasPrice = await l1BaseFeeEstimate.add(l2Basefee) - console.log(`Setting L1 base fee estimate on L3 to ${totalGasPrice}`) - const tx4 = await ArbOwner.setL1PricePerUnit(totalGasPrice) - - // Wait for the transaction to be mined - const receipt4 = await tx4.wait() - console.log( - `L1 base fee estimate is set on the block number ${await receipt4.blockNumber} on the Orbit chain` - ) - - // Check the status of the transaction: 1 is successful, 0 is failure - if (receipt4.status === 0) { - throw new Error('Base Fee Setting failed') + if (setL1Price) { + console.log('Getting L1 base fee estimate') + const l1BaseFeeEstimate = await ArbOGasInfo.getL1BaseFeeEstimate() + console.log(`L1 Base Fee estimate on L2 is ${l1BaseFeeEstimate.toNumber()}`) + const l2Basefee = await L2Provider.getGasPrice() + const totalGasPrice = await l1BaseFeeEstimate.add(l2Basefee) + console.log(`Setting L1 base fee estimate on L3 to ${totalGasPrice}`) + const tx4 = await ArbOwner.setL1PricePerUnit(totalGasPrice) + + // Wait for the transaction to be mined + const receipt4 = await tx4.wait() + console.log( + `L1 base fee estimate is set on the block number ${await receipt4.blockNumber} on the Orbit chain` + ) + + // Check the status of the transaction: 1 is successful, 0 is failure + if (receipt4.status === 0) { + throw new Error('Base Fee Setting failed') + } + } else { + console.log(`Skipping setL1PricePerUnit`) } + } else { console.log(`This is an L2 Orbit`) - console.log('Getting L1 base fee') - const totalGasPrice = await L2Provider.getGasPrice() - console.log(`Setting L1 base fee on L2 to ${totalGasPrice}`) - const tx4 = await ArbOwner.setL1PricePerUnit(totalGasPrice) - - // Wait for the transaction to be mined - const receipt4 = await tx4.wait() - console.log( - `L1 base fee is set on the block number ${await receipt4.blockNumber} on the Orbit chain` - ) - - // Check the status of the transaction: 1 is successful, 0 is failure - if (receipt4.status === 0) { - throw new Error('Base Fee Setting failed') + if (setL1Price) { + console.log('Getting L1 base fee') + const totalGasPrice = await L2Provider.getGasPrice() + console.log(`Setting L1 base fee on L2 to ${totalGasPrice}`) + const tx4 = await ArbOwner.setL1PricePerUnit(totalGasPrice) + + // Wait for the transaction to be mined + const receipt4 = await tx4.wait() + console.log( + `L1 base fee is set on the block number ${await receipt4.blockNumber} on the Orbit chain` + ) + + // Check the status of the transaction: 1 is successful, 0 is failure + if (receipt4.status === 0) { + throw new Error('Base Fee Setting failed') + } + } else { + console.log(`Skipping setL1PricePerUnit`) } } diff --git a/scripts/setup.ts b/scripts/setup.ts index 21d82d5..c7b7d49 100644 --- a/scripts/setup.ts +++ b/scripts/setup.ts @@ -41,6 +41,7 @@ async function main() { const INITIAL_FUND_AMOUNT_BATCH_POSTER = process.env.INITIAL_FUND_AMOUNT_BATCH_POSTER const INITIAL_FUND_AMOUNT_STAKER = process.env.INITIAL_FUND_AMOUNT_STAKER + const setL1Price = !process.env.SKIP_SET_L1_PRICE if ( !privateKey || @@ -182,7 +183,7 @@ async function main() { console.log( 'Running l3Configuration script to configure your Orbit chain 📝📝📝📝📝' ) - await l3Configuration(privateKey, L2_RPC_URL, L3_RPC_URL) + await l3Configuration(privateKey, L2_RPC_URL, L3_RPC_URL, setL1Price) rs.l3config = true } ////////////////////////////////