Skip to content

Commit

Permalink
Add missing vars
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Mar 26, 2024
1 parent d0e0f4f commit 2aa74db
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
2 changes: 1 addition & 1 deletion scripts/deploymentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export async function deployAllContracts(
}

// Check if we're deploying to an Arbitrum chain
async function _isRunningOnArbitrum(signer: any): Promise<Boolean> {
export async function _isRunningOnArbitrum(signer: any): Promise<boolean> {
const arbSys = ArbSys__factory.connect(ARB_SYS_ADDRESS, signer)
try {
await arbSys.arbOSVersion()
Expand Down
31 changes: 20 additions & 11 deletions scripts/local-deployment/deployCreatorAndCreateRollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import { promises as fs } from 'fs'
import { BigNumber } from 'ethers'

async function main() {
/// read env vars needed for deployment
let childChainName = process.env.CHILD_CHAIN_NAME as string
if (!childChainName) {
throw new Error('CHILD_CHAIN_NAME not set')
}

let deployerPrivKey = process.env.DEPLOYER_PRIVKEY as string
if (!deployerPrivKey) {
throw new Error('DEPLOYER_PRIVKEY not set')
Expand Down Expand Up @@ -45,7 +51,7 @@ async function main() {
)
).wait()

// Create rollup
/// Create rollup
const chainId = (await deployerWallet.provider.getNetwork()).chainId
const feeToken = undefined

Expand All @@ -55,34 +61,37 @@ async function main() {
'using RollupCreator',
contracts.rollupCreator.address
)
const rollupCreationResult = await createRollup(
const result = await createRollup(
deployerWallet,
true,
contracts.rollupCreator.address,
feeToken
)

if (!rollupCreationResult) {
if (!result) {
throw new Error('Rollup creation failed')
}

const { rollupCreationResult, chainInfo } = result

/// store deployment address
// parent deployment info
const parentDeploymentInfo =
process.env.PARENT_DEPLOYMENT_INFO !== undefined
? process.env.PARENT_DEPLOYMENT_INFO
// chain deployment info
const chainDeploymentInfo =
process.env.CHAIN_DEPLOYMENT_INFO !== undefined
? process.env.CHAIN_DEPLOYMENT_INFO
: 'deploy.json'
await fs.writeFile(
parentDeploymentInfo,
chainDeploymentInfo,
JSON.stringify(rollupCreationResult, null, 2),
'utf8'
)

// get child deployment info
const childDeploymentInfo =
process.env.CHILD_DEPLOYMENT_INFO !== undefined
? process.env.CHILD_DEPLOYMENT_INFO
const childChainInfo =
process.env.CHILD_CHAIN_INFO !== undefined
? process.env.CHILD_CHAIN_INFO
: 'l2_chain_info.json'
await fs.writeFile(childChainInfo, JSON.stringify(chainInfo, null, 2), 'utf8')
}

main()
Expand Down
28 changes: 26 additions & 2 deletions scripts/rollupCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { BigNumber, Signer } from 'ethers'
import { IERC20__factory } from '../build/types'
import { sleep } from './testSetup'
import { promises as fs } from 'fs'
import { Provider } from '@ethersproject/providers'
import { _isRunningOnArbitrum } from './deploymentUtils'

// 1 gwei
const MAX_FER_PER_GAS = BigNumber.from('1000000000')
Expand Down Expand Up @@ -42,12 +44,23 @@ interface RollupCreationResult {
ValidatorWalletCreator: string
}

interface ChainInfo {
ChainName: string
ParentChainId: number
ParentChainIsArbitrum: boolean
ChainConfig: any
RollupAddresses: RollupCreationResult
}

export async function createRollup(
signer: Signer,
isDevDeployment: boolean,
rollupCreatorAddress: string,
feeToken?: string
): Promise<RollupCreationResult | null> {
): Promise<{
rollupCreationResult: RollupCreationResult
chainInfo: ChainInfo
} | null> {
if (!rollupCreatorAbi) {
throw new Error(
'You need to first run <deployment.ts> script to deploy and compile the contracts first'
Expand Down Expand Up @@ -169,7 +182,7 @@ export async function createRollup(
const blockNumber = createRollupReceipt.blockNumber
console.log('All deployed at block number:', blockNumber)

return {
const rollupCreationResult: RollupCreationResult = {
Bridge: bridge,
Inbox: inboxAddress,
SequencerInbox: sequencerInbox,
Expand All @@ -180,6 +193,17 @@ export async function createRollup(
ValidatorUtils: validatorUtils,
ValidatorWalletCreator: validatorWalletCreator,
}


const chainInfo: ChainInfo = {
ChainName: 'dev-chain',
ParentChainId: deployParams.config.chainId.toNumber(),
ParentChainIsArbitrum: await _isRunningOnArbitrum(signer),
ChainConfig: deployParams.config,
RollupAddresses: rollupCreationResult,
}

return { rollupCreationResult, chainInfo }
} else {
console.error('RollupCreated event not found')
}
Expand Down

0 comments on commit 2aa74db

Please sign in to comment.