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

feat: add a script to set templates #26

Open
wants to merge 1 commit into
base: eigenda-v3.1.2
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion scripts/local-deployment/deployCreatorAndCreateRollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ async function main() {
/// deploy templates and rollup creator
console.log('Deploy RollupCreator')
const contracts = await deployAllContracts(deployerWallet, maxDataSize, false)
/// store deployment address
// chain deployment info
const rollupCreatorContracts =
process.env.ROLLUP_CREATOR_CONTRACTS_INFO !== undefined
? process.env.ROLLUP_CREATOR_CONTRACTS_INFO
: 'rollup_creator_contracts.json'
await fs.writeFile(
rollupCreatorContracts,
JSON.stringify(contracts, null, 2),
'utf8'
)

console.log('Set templates on the Rollup Creator')
await (
Expand All @@ -58,7 +69,7 @@ async function main() {
contracts.validatorUtils.address,
contracts.validatorWalletCreator.address,
contracts.deployHelper.address,
{ gasLimit: BigNumber.from('300000') }
{ gasLimit: BigNumber.from('3000000') }
)
).wait()

Expand Down
107 changes: 107 additions & 0 deletions scripts/local-deployment/setTemplates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { ethers } from 'hardhat'
import '@nomiclabs/hardhat-ethers'
import { deployAllContracts } from '../deploymentUtils'
import { createRollup } from '../rollupCreation'
import { promises as fs } from 'fs'
import { BigNumber } from 'ethers'
import { RollupCreator__factory } from '../../build/types'

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')
}

let parentChainRpc = process.env.PARENT_CHAIN_RPC as string
if (!parentChainRpc) {
throw new Error('PARENT_CHAIN_RPC not set')
}

if (!process.env.PARENT_CHAIN_ID) {
throw new Error('PARENT_CHAIN_ID not set')
}

const deployerWallet = new ethers.Wallet(
deployerPrivKey,
new ethers.providers.JsonRpcProvider(parentChainRpc)
)

const maxDataSize =
process.env.MAX_DATA_SIZE !== undefined
? ethers.BigNumber.from(process.env.MAX_DATA_SIZE)
: ethers.BigNumber.from(117964)

/// get fee token address, if undefined use address(0) to have ETH as fee token
let feeToken = process.env.FEE_TOKEN_ADDRESS as string
if (!feeToken) {
feeToken = ethers.constants.AddressZero
}

/// deploy templates and rollup creator
console.log('Connect to Rollup Creator')

const rollupCreatorFac = (await ethers.getContractFactory(
'RollupCreator'
)) as RollupCreator__factory
const rollupCreator = rollupCreatorFac.attach("0xbcEb6Ac6Aa7a2073813Ad648770b6A5957303BAc").connect(deployerWallet)

console.log('Grab contract addresses')
//TODO: read contracts from a local file such as rollup_creator_contracts.json (assuming it has been stored after deployContracts)
//For now just read from env vars; update when there's an example rollup_creator_contracts.json file to parse
const requiredEnvVars = [
'BRIDGE_CREATOR_ADDRESS',
'OSP_ADDRESS',
'CHALLENGE_MANAGER_ADDRESS',
'ROLLUP_ADMIN_ADDRESS',
'ROLLUP_USER_ADDRESS',
'UPGRADE_EXECUTOR_ADDRESS',
'VALIDATOR_UTILS_ADDRESS',
'VALIDATOR_WALLET_CREATOR_ADDRESS',
'DEPLOY_HELPER_ADDRESS'
]

requiredEnvVars.forEach(varName => {
if (!process.env[varName]) {
throw new Error(`${varName} not set`)
}
})

const bridgeCreator = process.env.BRIDGE_CREATOR_ADDRESS as string
const osp = process.env.OSP_ADDRESS as string
const challengeManager = process.env.CHALLENGE_MANAGER_ADDRESS as string
const rollupAdmin = process.env.ROLLUP_ADMIN_ADDRESS as string
const rollupUser = process.env.ROLLUP_USER_ADDRESS as string
const upgradeExecutor = process.env.UPGRADE_EXECUTOR_ADDRESS as string
const validatorUtils = process.env.VALIDATOR_UTILS_ADDRESS as string
const validatorWalletCreator = process.env.VALIDATOR_WALLET_CREATOR_ADDRESS as string
const deployHelper = process.env.DEPLOY_HELPER_ADDRESS as string

console.log('Set templates on the Rollup Creator')
await (
await rollupCreator.setTemplates(
bridgeCreator,
osp,
challengeManager,
rollupAdmin,
rollupUser,
upgradeExecutor,
validatorUtils,
validatorWalletCreator,
deployHelper,
{ gasLimit: BigNumber.from('30000000') }
)
).wait()
}

main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error)
process.exit(1)
})
Loading