Skip to content

Commit

Permalink
Update rollup creator deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Aug 25, 2023
1 parent 1eaf931 commit 59a6b1a
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 29 deletions.
92 changes: 72 additions & 20 deletions scripts/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { ethers } from 'hardhat'
import { ContractFactory, Contract } from 'ethers'
import '@nomiclabs/hardhat-ethers'
import { run } from 'hardhat'
import {
abi as UpgradeExecutorABI,
bytecode as UpgradeExecutorBytecode,
} from '@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json'

// Define a verification function
async function verifyContract(
Expand Down Expand Up @@ -56,6 +60,16 @@ async function deployContract(
return contract
}

// Deploy upgrade executor from imported bytecode
async function deployUpgradeExecutor(): Promise<Contract> {
const upgradeExecutorFac = await ethers.getContractFactory(
UpgradeExecutorABI,
UpgradeExecutorBytecode
)
const upgradeExecutor = await upgradeExecutorFac.deploy()
return upgradeExecutor
}

// Function to handle all deployments of core contracts using deployContract function
async function deployAllContracts(
signer: any
Expand All @@ -74,7 +88,7 @@ async function deployAllContracts(
const challengeManager = await deployContract('ChallengeManager', signer)
const rollupAdmin = await deployContract('RollupAdminLogic', signer)
const rollupUser = await deployContract('RollupUserLogic', signer)
const upgradeExecutor = await deployContract('UpgradeExecutor', signer)
const upgradeExecutor = await deployUpgradeExecutor()
const validatorUtils = await deployContract('ValidatorUtils', signer)
const validatorWalletCreator = await deployContract(
'ValidatorWalletCreator',
Expand Down Expand Up @@ -119,37 +133,75 @@ async function main() {
)
console.log('Template is set on the Rollup Creator')

const bridgeAddress = await contracts.bridgeCreator.bridgeTemplate()
const sequencerInboxAddress =
await contracts.bridgeCreator.sequencerInboxTemplate()
const inboxAddress = await contracts.bridgeCreator.inboxTemplate()
const outboxAddress = await contracts.bridgeCreator.outboxTemplate()
// get and verify ETH-based bridge contracts
const { bridge, sequencerInbox, inbox, outbox } =
await contracts.bridgeCreator.ethBasedTemplates()

console.log(`"bridge implementation contract" created at address:`, bridge)
await verifyContract('Bridge', bridge, [], 'src/bridge/Bridge.sol:Bridge')
console.log(
`"bridge implementation contract" created at address:`,
bridgeAddress
`"sequencerInbox implementation contract" created at address:`,
sequencerInbox
)
await verifyContract(
'Bridge',
bridgeAddress,
'SequencerInbox',
sequencerInbox,
[],
'src/bridge/Bridge.sol:Bridge'
'src/bridge/SequencerInbox.sol:SequencerInbox'
)
console.log(`"inbox implementation contract" created at address:`, inbox)
await verifyContract('Inbox', inbox, [], 'src/bridge/Inbox.sol:Inbox')
console.log(`"outbox implementation contract" created at address:`, outbox)
await verifyContract('Outbox', outbox, [], 'src/bridge/Outbox.sol:Outbox')

// get and verify ERC20-based bridge contracts
const {
bridge: erc20Bridge,
sequencerInbox: erc20SeqInbox,
inbox: erc20Inbox,
outbox: erc20Outbox,
} = await contracts.bridgeCreator.erc20BasedTemplates()

console.log(
`"sequencerInbox implementation contract" created at address:`,
sequencerInboxAddress
`"erc20 bridge implementation contract" created at address:`,
bridge
)
await verifyContract(
'ERC20Bridge',
erc20Bridge,
[],
'src/bridge/ERC20Bridge.sol:ERC20Bridge'
)
await verifyContract('SequencerInbox', sequencerInboxAddress, [])
console.log(
`"inbox implementation contract" created at address:`,
inboxAddress
`"erc20 sequencerInbox implementation contract" created at address:`,
erc20SeqInbox
)
await verifyContract(
'SequencerInbox',
erc20SeqInbox,
[],
'src/bridge/SequencerInbox.sol:SequencerInbox'
)
console.log(
`"erc20 inbox implementation contract" created at address:`,
inbox
)
await verifyContract(
'ERC20Inbox',
erc20Inbox,
[],
'src/bridge/ERC20Inbox.sol:ERC20Inbox'
)
await verifyContract('Inbox', inboxAddress, [])
console.log(
`"outbox implementation contract" created at address:`,
outboxAddress
`"erc20 outbox implementation contract" created at address:`,
outbox
)
await verifyContract(
'ERC20Outbox',
erc20Outbox,
[],
'src/bridge/ERC20Outbox.sol:ERC20Outbox'
)
await verifyContract('Outbox', outboxAddress, [])
} catch (error) {
console.error(
'Deployment failed:',
Expand Down
20 changes: 11 additions & 9 deletions scripts/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ export const getCustomNetworks = async (
const l1Provider = new JsonRpcProvider(l1Url)
const l2Provider = new JsonRpcProvider(l2Url)
let deploymentData: string
try {
deploymentData = execSync(
'docker exec nitro_sequencer_1 cat /config/deployment.json'
).toString()
} catch (e) {
deploymentData = execSync(
'docker exec nitro-sequencer-1 cat /config/deployment.json'
).toString()
}

let sequencerContainer = execSync(
'docker ps --filter "name=sequencer" --format "{{.Names}}"'
)
.toString()
.trim()

deploymentData = execSync(
`docker exec ${sequencerContainer} cat /config/deployment.json`
).toString()

const parsedDeploymentData = JSON.parse(deploymentData) as {
bridge: string
inbox: string
Expand Down

0 comments on commit 59a6b1a

Please sign in to comment.