Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup Chain Deployment Script #149

Merged
merged 9 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/rollup-contracts/config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

### REQUIRED ###
# Mnemonic for the wallet used to deploy the contracts
DEPLOY_MNEMONIC='response fresh afford leader twice silent table exist aisle pelican focus bird'
DEPLOY_MNEMONIC='device frost invest worth exchange need fix accuse action pave head response'

FORCE_INCLUSION_PERIOD=600

# Private key for the Sequencer - note must have some ETH for gas fees
SEQUENCER_PRIVATE_KEY='191c53d1b552bdd3f95a3129b1c5ec93bba1a92d756c1aa690dbe564d4b3ecf0'

# Note: can use any network name. 'local' or leaving it blank will deploy to DEPLOY_LOCAL_URL
DEPLOY_NETWORK='local'
Expand Down
105 changes: 105 additions & 0 deletions packages/rollup-contracts/deploy/rollup-chain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* External Imports */
import { deploy, deployContract } from '@eth-optimism/core-utils'
import { Wallet } from 'ethers'
import { Provider } from 'ethers/providers'

/* Internal Imports */
import * as RollupMerkleUtils from '../build/RollupMerkleUtils.json'
import * as CanonicalTransactionChain from '../build/CanonicalTransactionChain.json'
import * as StateCommitmentChain from '../build/StateCommitmentChain.json'
import * as SequencerBatchSubmitter from '../build/SequencerBatchSubmitter.json'
import * as L1ToL2TransactionPasser from '../build/L1ToL2TransactionPasser.json'

import { resolve } from 'path'

const rollupChainDeploymentFunction = async (
wallet: Wallet
): Promise<string> => {
const provider: Provider = wallet.provider
const sequencer = process.env.SEQUENCER_PRIVATE_KEY
? new Wallet(process.env.SEQUENCER_PRIVATE_KEY, provider)
: wallet
const inclusionPeriod = process.env.FORCE_INCLUSION_PERIOD || 600
const fraudVerifier = wallet // TODO actually deploy Fraud Verifier

console.log(`\nDeploying Rollup Chain!\n`)
console.log(`\nDeploying RollupMerkleUtils...\n`)
const rollupMerkleUtils = await deployContract(RollupMerkleUtils, wallet)

console.log(
`\nDeploying SequencerBatchSubmitter with Sequencer address: ${sequencer.address}...\n`
)
const sequencerBatchSubmitter = await deployContract(
SequencerBatchSubmitter,
wallet,
sequencer.address
)

console.log(`\nDeploying L1ToL2TransactionPasser...\n`)
const l1ToL2TransactionPasser = await deployContract(
L1ToL2TransactionPasser,
wallet
)

console.log(`\nDeploying CanonicalTransactionChain...\n`)
const canonicalTxChain = await deployContract(
CanonicalTransactionChain,
wallet,
rollupMerkleUtils.address,
sequencerBatchSubmitter.address,
l1ToL2TransactionPasser.address,
inclusionPeriod
)
const l1ToL2QueueAddress = await canonicalTxChain.l1ToL2Queue()
const safetyQueueAddress = await canonicalTxChain.safetyQueue()

console.log(`\nDeploying StateCommitmentChain...\n`)
const stateChain = await deployContract(
StateCommitmentChain,
wallet,
rollupMerkleUtils.address,
canonicalTxChain.address,
fraudVerifier.address
)

console.log(
`\nInitializing SequencerBatchSubmitter with chain addresses...\n`
)
await sequencerBatchSubmitter
.connect(sequencer)
.initialize(canonicalTxChain.address, stateChain.address)

console.log(
`\nRollup Merkle Utils deployed to ${rollupMerkleUtils.address}\n`
)
console.log(
`Canonical Transaction Chain deployed to ${canonicalTxChain.address}\n`
)
console.log(
`L1-to-L2 Transaction Passer deployed to ${l1ToL2TransactionPasser.address}\n`
)
console.log(`L1-to-L2 Transaction Queue deployed to ${l1ToL2QueueAddress}\n`)
console.log(`Safety Transaction Queue deployed to ${safetyQueueAddress}\n`)
console.log(`State Commitment Chain deployed to ${stateChain.address}\n`)
console.log(
`Sequencer Batch Submitter deployed to ${sequencerBatchSubmitter.address}\n`
)
return canonicalTxChain.address
}

/**
* Deploys the RollupChain contracts.
*
* @param rootContract Whether or not this is the main contract being deployed (as compared to a dependency).
* @returns The deployed contract's address.
*/
export const deployRollupChain = async (
rootContract: boolean = false
): Promise<string> => {
// Note: Path is from 'build/deploy/<script>.js'
const configDirPath = resolve(__dirname, `../../config/`)

return deploy(rollupChainDeploymentFunction, configDirPath, rootContract)
}

deployRollupChain(true)
3 changes: 2 additions & 1 deletion packages/rollup-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"lint": "tslint --format stylish --project .",
"fix": "prettier --config ../../prettier-config.json --write 'index.ts' '{deploy,test}/**/*.ts'",
"build": "waffle waffle-config.json && tsc -p .",
"clean": "rimraf build/"
"clean": "rimraf build/",
"deploy:rollup-chain": "yarn build && node ./build/deploy/rollup-chain.js"
},
"keywords": [
"optimistic",
Expand Down