Skip to content

Commit

Permalink
feat: add setL1PricingRewardRecipient
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio-altr committed May 2, 2024
1 parent 43242b0 commit 2268f05
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
4 changes: 3 additions & 1 deletion scripts/createTokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ export const createERC20Bridge = async (
baseChainRpc: string,
baseChainDeployerKey: string,
childChainRpc: string,
rollupAddress: string
rollupAddress: string,
l1PricingRewardRecipient: string
) => {
console.log('Creating token bridge for rollup', rollupAddress)

Expand Down Expand Up @@ -364,6 +365,7 @@ export const createERC20Bridge = async (
minL2BaseFee: config.minL2BaseFee,
networkFeeReceiver: config.networkFeeReceiver,
infrastructureFeeCollector: config.infrastructureFeeCollector,
l1PricingRewardRecipient: l1PricingRewardRecipient,
batchPoster: config.batchPoster,
staker: config.staker,
chainOwner: config.chainOwner,
Expand Down
38 changes: 29 additions & 9 deletions scripts/l3Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export async function l3Configuration(
privateKey: string,
L2_RPC_URL: string,
L3_RPC_URL: string,
setL1Price: boolean
setL1Price: boolean,
l1PricingRewardRecipient: string
) {
if (!privateKey || !L2_RPC_URL || !L3_RPC_URL) {
throw new Error('Required environment variable not found')
Expand Down Expand Up @@ -104,6 +105,25 @@ export async function l3Configuration(
)
}

// Set the L1PricingRewardRecipient
console.log(
'Setting the L1PricingRewardRecipient address for the Orbit chain'
)
const tx4 = await ArbOwner.setL1PricingRewardRecipient(l1PricingRewardRecipient)

// Wait for the transaction to be mined
const receipt4 = await tx4.wait()
console.log(
`L1PricingRewardRecipient address 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(
'Setting Set the L1PricingRewardRecipient transaction failed'
)
}

// Setting L1 basefee on L3
const l2ChainId = (await L2Provider.getNetwork()).chainId
if ((l2ChainId === 421614) || (l2ChainId === 42161)) {
Expand All @@ -124,16 +144,16 @@ export async function l3Configuration(
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)
const tx5 = await ArbOwner.setL1PricePerUnit(totalGasPrice)

// Wait for the transaction to be mined
const receipt4 = await tx4.wait()
const receipt5 = await tx5.wait()
console.log(
`L1 base fee estimate is set on the block number ${await receipt4.blockNumber} on the Orbit chain`
`L1 base fee estimate is set on the block number ${await receipt5.blockNumber} on the Orbit chain`
)

// Check the status of the transaction: 1 is successful, 0 is failure
if (receipt4.status === 0) {
if (receipt5.status === 0) {
throw new Error('Base Fee Setting failed')
}
} else {
Expand All @@ -146,16 +166,16 @@ export async function l3Configuration(
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)
const tx5 = await ArbOwner.setL1PricePerUnit(totalGasPrice)

// Wait for the transaction to be mined
const receipt4 = await tx4.wait()
const receipt5 = await tx5.wait()
console.log(
`L1 base fee is set on the block number ${await receipt4.blockNumber} on the Orbit chain`
`L1 base fee is set on the block number ${await receipt5.blockNumber} on the Orbit chain`
)

// Check the status of the transaction: 1 is successful, 0 is failure
if (receipt4.status === 0) {
if (receipt5.status === 0) {
throw new Error('Base Fee Setting failed')
}
} else {
Expand Down
8 changes: 5 additions & 3 deletions scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ async function main() {
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 != "true"
const l1PricingRewardRecipient = process.env.L1_PRICING_REWARD_RECIPIENT

if (
!privateKey ||
!L2_RPC_URL ||
!L3_RPC_URL ||
!INITIAL_FUND_AMOUNT_CREATOR ||
!INITIAL_FUND_AMOUNT_BATCH_POSTER ||
!INITIAL_FUND_AMOUNT_STAKER
!INITIAL_FUND_AMOUNT_STAKER ||
!l1PricingRewardRecipient
) {
throw new Error('Required environment variable not found')
}
Expand Down Expand Up @@ -173,7 +175,7 @@ async function main() {
console.log(
'Running tokenBridgeDeployment or erc20TokenBridge script to deploy token bridge contracts on parent chain and your Orbit chain πŸŒ‰πŸŒ‰πŸŒ‰πŸŒ‰πŸŒ‰'
)
await createERC20Bridge(L2_RPC_URL, privateKey, L3_RPC_URL, config.rollup)
await createERC20Bridge(L2_RPC_URL, privateKey, L3_RPC_URL, config.rollup, l1PricingRewardRecipient)
rs.tokenBridgeDeployed = true
}
////////////////////////////////
Expand All @@ -183,7 +185,7 @@ async function main() {
console.log(
'Running l3Configuration script to configure your Orbit chain πŸ“πŸ“πŸ“πŸ“πŸ“'
)
await l3Configuration(privateKey, L2_RPC_URL, L3_RPC_URL, setL1Price)
await l3Configuration(privateKey, L2_RPC_URL, L3_RPC_URL, setL1Price, l1PricingRewardRecipient)
rs.l3config = true
}
////////////////////////////////
Expand Down

0 comments on commit 2268f05

Please sign in to comment.