Skip to content

Commit

Permalink
ARB/OP contract deployment for Light bridge (#1289)
Browse files Browse the repository at this point in the history
* Deployment logic for light bridge updated, preparation for OP/ARB support

* Add RPC envs

* Update packages/boba/contracts/hardhat.config.ts

* Add fallback initialization of contracts for redeploy=false
  • Loading branch information
wsdt authored Nov 20, 2023
1 parent b2026db commit 01877b3
Show file tree
Hide file tree
Showing 33 changed files with 506 additions and 65 deletions.
60 changes: 60 additions & 0 deletions packages/boba/contracts/bin/deploy.lb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Wallet, providers } from 'ethers'
import { getContractFactory } from '@bobanetwork/core_contracts'
import { supportedLocalTestnet } from '@bobanetwork/core_contracts/src/local-network-config'

/* eslint-disable */
require('dotenv').config()

import hre from 'hardhat'

/** @dev Separate deployment file as limited networks or per network deployments for light bridge (e.g. only L2/L1, etc.) not supported with regular deployment config & flow without deploying everyhing else. */
const main = async () => {
console.log('Starting BOBA core contracts deployment for light bridge...')

const network = process.env.NETWORK || 'local'

const l1Provider = new providers.JsonRpcProvider(process.env.L1_NODE_WEB3_URL)
const l2Provider = new providers.JsonRpcProvider(process.env.L2_NODE_WEB3_URL)

const deployer_l1 = new Wallet(process.env.DEPLOYER_PRIVATE_KEY, l1Provider)
const deployer_l2 = new Wallet(process.env.DEPLOYER_PRIVATE_KEY, l2Provider)

const l1ChainId = (await l1Provider.getNetwork()).chainId
const isLocalAltL1 = supportedLocalTestnet[l1ChainId]?.isLocalAltL1

const getAddressManager = (provider: any, addressManagerAddress: any) => {
return getContractFactory('Lib_AddressManager')
.connect(provider)
.attach(addressManagerAddress) as any
}

console.log(
`ADDRESS_MANAGER_ADDRESS was set to ${process.env.ADDRESS_MANAGER_ADDRESS}`
)
const addressManager = getAddressManager(
deployer_l1,
process.env.ADDRESS_MANAGER_ADDRESS
)

await hre.run('deploy', {
isLocalAltL1,
l1Provider,
l2Provider,
deployer_l1,
deployer_l2,
addressManager,
network,
// to ensure only independent networks are deployed
isLightMode: true,
noCompile: process.env.NO_COMPILE ? true : false,
})
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.log(
JSON.stringify({ error: error.message, stack: error.stack }, null, 2)
)
process.exit(1)
})
4 changes: 4 additions & 0 deletions packages/boba/contracts/deploy/000-Messenger.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ require('dotenv').config()
let L1CrossDomainMessengerFast: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
Expand Down
4 changes: 4 additions & 0 deletions packages/boba/contracts/deploy/001-Proxy_Messenger.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ let Factory__Proxy__L1CrossDomainMessengerFast: ContractFactory
let Proxy__L1CrossDomainMessengerFast: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
Expand Down
5 changes: 5 additions & 0 deletions packages/boba/contracts/deploy/002-LiquidityPools.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ let L1LiquidityPool: Contract
let L2LiquidityPool: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 17 in packages/boba/contracts/deploy/002-LiquidityPools.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ let Proxy__L1LiquidityPool: Contract
let Proxy__L2LiquidityPool: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 18 in packages/boba/contracts/deploy/003-Proxy_LiquidityPools.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
5 changes: 5 additions & 0 deletions packages/boba/contracts/deploy/004-L2ERC20.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const initialSupply_8 = utils.parseUnits('10000', 8)
const initialSupply_18 = utils.parseEther('10000000000')

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 28 in packages/boba/contracts/deploy/004-L2ERC20.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const registerLPToken = async (L1TokenAddress, L2TokenAddress) => {
const registerL1LP = await Proxy__L1LiquidityPool.registerPool(
L1TokenAddress,
Expand Down
5 changes: 5 additions & 0 deletions packages/boba/contracts/deploy/005-TokenPool.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import {
let L2TokenPool: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 16 in packages/boba/contracts/deploy/005-TokenPool.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
5 changes: 5 additions & 0 deletions packages/boba/contracts/deploy/006-TestComms.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ let L1Message: Contract
let L2Message: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 17 in packages/boba/contracts/deploy/006-TestComms.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
5 changes: 5 additions & 0 deletions packages/boba/contracts/deploy/007-AtomicSwap.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import {
let AtomicSwap: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 16 in packages/boba/contracts/deploy/007-AtomicSwap.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
5 changes: 5 additions & 0 deletions packages/boba/contracts/deploy/008-NFT.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ const nftName = 'TestNFT'
const nftSymbol = 'TST'

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 20 in packages/boba/contracts/deploy/008-NFT.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
5 changes: 5 additions & 0 deletions packages/boba/contracts/deploy/009-NFTBridges.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ let L1NFTBridge: Contract
let L2NFTBridge: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 17 in packages/boba/contracts/deploy/009-NFTBridges.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const isLocalAltL1 = (hre as any).deployConfig.isLocalAltL1
const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
Expand Down
5 changes: 5 additions & 0 deletions packages/boba/contracts/deploy/010-Proxy_NFTBridges.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ let Proxy__L1NFTBridge: Contract
let Proxy__L2NFTBridge: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 18 in packages/boba/contracts/deploy/010-Proxy_NFTBridges.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
5 changes: 5 additions & 0 deletions packages/boba/contracts/deploy/011-L2ERC721.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ let L1ERC721: Contract
let L2ERC721: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;

Check warning on line 21 in packages/boba/contracts/deploy/011-L2ERC721.deploy.ts

View workflow job for this annotation

GitHub Actions / Linting

Delete `;`
}

const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ require('dotenv').config()
let L1_MultiMessageRelayerFast: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}


const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
Expand Down
4 changes: 4 additions & 0 deletions packages/boba/contracts/deploy/013-BobaDao.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const getTimestamp = async (hre) => {
}

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}
if ((hre as any).deployConfig.isLocalAltL1) {
return
}
Expand Down
4 changes: 4 additions & 0 deletions packages/boba/contracts/deploy/014-BobaTuring.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ let L2Boba: Contract
let BobaTuringHelper: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}
const isLocalAltL1 = (hre as any).deployConfig.isLocalAltL1

const addressManager = getContractFactory('Lib_AddressManager')
Expand Down
4 changes: 4 additions & 0 deletions packages/boba/contracts/deploy/015-ExitFee.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {
let DiscretionaryExitFee: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}
const isLocalAltL1 = (hre as any).deployConfig.isLocalAltL1
const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
Expand Down
4 changes: 4 additions & 0 deletions packages/boba/contracts/deploy/016-BobaSaving.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ let BobaFixedSavings: Contract
let Proxy__BobaFixedSavings: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}
const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
4 changes: 4 additions & 0 deletions packages/boba/contracts/deploy/017-FeedRegistry.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {
let FeedRegistry: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}
const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
4 changes: 4 additions & 0 deletions packages/boba/contracts/deploy/018-PriceFeedOracle.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const address = (id: number) => {
}

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}
const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
.attach(process.env.ADDRESS_MANAGER_ADDRESS) as any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ let DiscretionaryExitFee: Contract
let L2NFTBridgeContract: Contract

const deployFn: DeployFunction = async (hre) => {
if ((hre as any).deployConfig.isLightMode) {
console.log('Skipping deployment function as in light mode..')
return;
}
const isLocalAltL1 = (hre as any).deployConfig.isLocalAltL1
const addressManager = getContractFactory('Lib_AddressManager')
.connect((hre as any).deployConfig.deployer_l1)
Expand Down
Loading

0 comments on commit 01877b3

Please sign in to comment.