Skip to content

Commit

Permalink
Merge pull request #6 from EspressoSystems/jh/sync
Browse files Browse the repository at this point in the history
Sync upstream 20240513
  • Loading branch information
ImJeremyHe authored May 14, 2024
2 parents e16b1c4 + 481bcc6 commit 75443b7
Show file tree
Hide file tree
Showing 46 changed files with 2,497 additions and 465 deletions.
8 changes: 7 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ optimizer = true
optimizer_runs = 100
via_ir = false
solc_version = '0.8.9'
remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/',
'forge-std/=lib/forge-std/src/',
'@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/',
'@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/']

[profile.yul]
src = 'yul'
out = 'out/yul'
libs = ['node_modules', 'lib']
cache_path = 'forge-cache/yul'
remappings = []
auto_detect_remappings = false

[fmt]
number_underscore = 'thousands'
line_length = 100
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
"postinstall": "patch-package",
"deploy-factory": "hardhat run scripts/deployment.ts",
"deploy-eth-rollup": "hardhat run scripts/createEthRollup.ts",
"deploy-erc20-rollup": "hardhat run scripts/createERC20Rollup.ts"
"deploy-erc20-rollup": "hardhat run scripts/createERC20Rollup.ts",
"create-rollup-testnode": "hardhat run scripts/local-deployment/deployCreatorAndCreateRollup.ts"
},
"dependencies": {
"@offchainlabs/upgrade-executor": "1.1.0-beta.0",
"@openzeppelin/contracts": "4.5.0",
"@openzeppelin/contracts-upgradeable": "4.5.2",
"patch-package": "^6.4.7"
"patch-package": "^6.4.7",
"solady": "0.0.182"
},
"private": false,
"devDependencies": {
Expand Down
5 changes: 0 additions & 5 deletions remappings.txt

This file was deleted.

3 changes: 2 additions & 1 deletion scripts/config.ts.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ export const config = {
'0x1234123412341234123412341234123412341234',
'0x1234512345123451234512345123451234512345',
],
batchPoster: '0x1234123412341234123412341234123412341234',
batchPosters: ['0x1234123412341234123412341234123412341234'],
batchPosterManager: '0x1234123412341234123412341234123412341234'
}
12 changes: 11 additions & 1 deletion scripts/createERC20Rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ async function main() {
)
}

const rollupCreatorAddress = process.env.ROLLUP_CREATOR_ADDRESS
if (!rollupCreatorAddress) {
throw new Error('ROLLUP_CREATOR_ADDRESS not set')
}

console.log('Creating new rollup with', customFeeTokenAddress, 'as fee token')
await createRollup(customFeeTokenAddress)
await createRollup(
deployer,
false,
rollupCreatorAddress,
customFeeTokenAddress
)
}

main()
Expand Down
11 changes: 10 additions & 1 deletion scripts/createEthRollup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { ethers } from 'hardhat'
import '@nomiclabs/hardhat-ethers'
import { createRollup } from './rollupCreation'

async function main() {
await createRollup()
const feeToken = undefined
const rollupCreatorAddress = process.env.ROLLUP_CREATOR_ADDRESS
if (!rollupCreatorAddress) {
throw new Error('ROLLUP_CREATOR_ADDRESS not set')
}

const [signer] = await ethers.getSigners()

await createRollup(signer, false, rollupCreatorAddress, feeToken)
}

main()
Expand Down
7 changes: 6 additions & 1 deletion scripts/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { ethers } from 'hardhat'
import '@nomiclabs/hardhat-ethers'
import { deployAllContracts } from './deploymentUtils'
import { maxDataSize } from './config'

async function main() {
const [signer] = await ethers.getSigners()

try {
// Deploying all contracts
const contracts = await deployAllContracts(signer)
const contracts = await deployAllContracts(
signer,
ethers.BigNumber.from(maxDataSize),
true
)

// Call setTemplates with the deployed contract addresses
console.log('Waiting for the Template to be set on the Rollup Creator')
Expand Down
159 changes: 106 additions & 53 deletions scripts/deploymentUtils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ethers } from 'hardhat'
import { ContractFactory, Contract, Overrides } from 'ethers'
import { ContractFactory, Contract, Overrides, BigNumber } 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'
import { maxDataSize } from './config'
import { Toolkit4844 } from '../test/contract/toolkit4844'
import { ArbSys__factory } from '../build/types'
import { ARB_SYS_ADDRESS } from '@arbitrum/sdk/dist/lib/dataEntities/constants'
Expand Down Expand Up @@ -88,85 +87,139 @@ export async function deployUpgradeExecutor(signer: any): Promise<Contract> {
// Function to handle all deployments of core contracts using deployContract function
export async function deployAllContracts(
signer: any,
maxDataSize: BigNumber,
verify: boolean = true,
hotshotAddr?: string
): Promise<Record<string, Contract>> {
const isOnArb = await _isRunningOnArbitrum(signer)

const ethBridge = await deployContract('Bridge', signer, [])
const ethBridge = await deployContract('Bridge', signer, [], verify)
const reader4844 = isOnArb
? ethers.constants.AddressZero
: (await Toolkit4844.deployReader4844(signer)).address

const ethSequencerInbox = await deployContract('SequencerInbox', signer, [
maxDataSize,
reader4844,
false,
])
const ethSequencerInbox = await deployContract(
'SequencerInbox',
signer,
[maxDataSize, reader4844, false],
verify
)

const ethInbox = await deployContract('Inbox', signer, [maxDataSize])
const ethInbox = await deployContract('Inbox', signer, [maxDataSize], verify)
const ethRollupEventInbox = await deployContract(
'RollupEventInbox',
signer,
[]
[],
verify
)
const ethOutbox = await deployContract('Outbox', signer, [])
const ethOutbox = await deployContract('Outbox', signer, [], verify)

const erc20Bridge = await deployContract('ERC20Bridge', signer, [])
const erc20SequencerInbox = await deployContract('SequencerInbox', signer, [
maxDataSize,
reader4844,
true,
])
const erc20Inbox = await deployContract('ERC20Inbox', signer, [maxDataSize])
const erc20Bridge = await deployContract('ERC20Bridge', signer, [], verify)
const erc20SequencerInbox = await deployContract(
'SequencerInbox',
signer,
[maxDataSize, reader4844, true],
verify
)
const erc20Inbox = await deployContract(
'ERC20Inbox',
signer,
[maxDataSize],
verify
)
const erc20RollupEventInbox = await deployContract(
'ERC20RollupEventInbox',
signer,
[]
[],
verify
)
const erc20Outbox = await deployContract('ERC20Outbox', signer, [])
const erc20Outbox = await deployContract('ERC20Outbox', signer, [], verify)

const bridgeCreator = await deployContract('BridgeCreator', signer, [
[
ethBridge.address,
ethSequencerInbox.address,
ethInbox.address,
ethRollupEventInbox.address,
ethOutbox.address,
],
const bridgeCreator = await deployContract(
'BridgeCreator',
signer,
[
erc20Bridge.address,
erc20SequencerInbox.address,
erc20Inbox.address,
erc20RollupEventInbox.address,
erc20Outbox.address,
[
ethBridge.address,
ethSequencerInbox.address,
ethInbox.address,
ethRollupEventInbox.address,
ethOutbox.address,
],
[
erc20Bridge.address,
erc20SequencerInbox.address,
erc20Inbox.address,
erc20RollupEventInbox.address,
erc20Outbox.address,
],
],
])
const prover0 = await deployContract('OneStepProver0', signer)
const proverMem = await deployContract('OneStepProverMemory', signer)
const proverMath = await deployContract('OneStepProverMath', signer)
verify
)
const prover0 = await deployContract('OneStepProver0', signer, [], verify)
const proverMem = await deployContract(
'OneStepProverMemory',
signer,
[],
verify
)
const proverMath = await deployContract(
'OneStepProverMath',
signer,
[],
verify
)
const hostIoArg = hotshotAddr ? [hotshotAddr] : []
const proverHostIo = await deployContract(
'OneStepProverHostIo',
signer,
hostIoArg
)
const osp: Contract = await deployContract('OneStepProofEntry', signer, [
prover0.address,
proverMem.address,
proverMath.address,
proverHostIo.address,
])
const challengeManager = await deployContract('ChallengeManager', signer)
const rollupAdmin = await deployContract('RollupAdminLogic', signer)
const rollupUser = await deployContract('RollupUserLogic', signer)
hostIoArg,
verify
)
const osp: Contract = await deployContract(
'OneStepProofEntry',
signer,
[
prover0.address,
proverMem.address,
proverMath.address,
proverHostIo.address,
],
verify
)
const challengeManager = await deployContract(
'ChallengeManager',
signer,
[],
verify
)
const rollupAdmin = await deployContract(
'RollupAdminLogic',
signer,
[],
verify
)
const rollupUser = await deployContract('RollupUserLogic', signer, [], verify)
const upgradeExecutor = await deployUpgradeExecutor(signer)
const validatorUtils = await deployContract('ValidatorUtils', signer)
const validatorUtils = await deployContract(
'ValidatorUtils',
signer,
[],
verify
)
const validatorWalletCreator = await deployContract(
'ValidatorWalletCreator',
signer
signer,
[],
verify
)
const rollupCreator = await deployContract(
'RollupCreator',
signer,
[],
verify
)
const rollupCreator = await deployContract('RollupCreator', signer)
const deployHelper = await deployContract('DeployHelper', signer)
const deployHelper = await deployContract('DeployHelper', signer, [], verify)
return {
bridgeCreator,
prover0,
Expand All @@ -186,7 +239,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
Loading

0 comments on commit 75443b7

Please sign in to comment.