Skip to content

Commit

Permalink
feat: add option to skip setL1PricePerUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio-altr committed Mar 25, 2024
1 parent 00694ee commit d9f1f74
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 33 deletions.
74 changes: 42 additions & 32 deletions scripts/l3Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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`)
}
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -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
}
////////////////////////////////
Expand Down

0 comments on commit d9f1f74

Please sign in to comment.