Skip to content

Commit

Permalink
Merge branch 'develop' into audit-ci-dev, fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
DZGoldman committed Feb 15, 2024
2 parents fac404b + 7fbbdd4 commit 2e5a2cb
Show file tree
Hide file tree
Showing 28 changed files with 856 additions and 210 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/contract-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ jobs:
- name: Test Storage Layouts
run: yarn run test:storage

- name: Test function signatures
run: yarn run test:signatures

- name: Run coverage
run: yarn hardhat coverage --testfiles "test/contract/*.spec.ts"

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ deployments/
/test/prover/proofs/*.json
/test/prover/spec-proofs/*.json
/test/storage/*-old
/test/signatures/*-old
scripts/config.ts
forge-cache/
out/
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arbitrum/nitro-contracts",
"version": "1.2.0",
"version": "1.2.1",
"description": "Layer 2 precompiles and rollup for Arbitrum Nitro",
"author": "Offchain Labs, Inc.",
"license": "BUSL-1.1",
Expand All @@ -11,15 +11,16 @@
"files": [
"src/",
"build/contracts/src",
"build/contracts/@openzeppelin"
"build/contracts/@openzeppelin",
"out/yul/Reader4844.yul/Reader4844.json"
],
"bugs": {
"url": "https://github.com/offchainlabs/nitro-contracts/issues"
},
"scripts": {
"audit:ci": "audit-ci --config ./audit-ci.jsonc",
"audit:fix": "yarn-audit-fix",
"prepublishOnly": "hardhat clean && hardhat compile",
"prepublishOnly": "hardhat clean && forge clean && hardhat compile && yarn build:forge:yul",
"build:all": "yarn build && yarn build:forge",
"build": "hardhat compile",
"build:forge:sol": "forge build --skip *.yul",
Expand All @@ -35,6 +36,7 @@
"test:4844": "DISABLE_GAS_REPORTER=true hardhat --network hardhat test test/contract/*.spec.4844.ts",
"test:compatibility": "yarn run build:0.6 && yarn run build:0.7",
"test:storage": "./test/storage/test.bash",
"test:signatures": "./test/signatures/test-sigs.bash",
"test:e2e": "hardhat test test/e2e/*.ts",
"postinstall": "patch-package",
"deploy-factory": "hardhat run scripts/deployment.ts",
Expand Down
159 changes: 1 addition & 158 deletions scripts/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,163 +1,6 @@
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'
import { maxDataSize } from './config'

// Define a verification function
async function verifyContract(
contractName: string,
contractAddress: string,
constructorArguments: any[] = [],
contractPathAndName?: string // optional
): Promise<void> {
try {
if (process.env.DISABLE_VERIFICATION) return
// Define the verification options with possible 'contract' property
const verificationOptions: {
contract?: string
address: string
constructorArguments: any[]
} = {
address: contractAddress,
constructorArguments: constructorArguments,
}

// if contractPathAndName is provided, add it to the verification options
if (contractPathAndName) {
verificationOptions.contract = contractPathAndName
}

await run('verify:verify', verificationOptions)
console.log(`Verified contract ${contractName} successfully.`)
} catch (error: any) {
if (error.message.includes('Already Verified')) {
console.log(`Contract ${contractName} is already verified.`)
} else {
console.error(
`Verification for ${contractName} failed with the following error: ${error.message}`
)
}
}
}

// Function to handle contract deployment
async function deployContract(
contractName: string,
signer: any,
constructorArgs: any[] = [],
verify: boolean = true
): Promise<Contract> {
const factory: ContractFactory = await ethers.getContractFactory(contractName)
const connectedFactory: ContractFactory = factory.connect(signer)
const contract: Contract = await connectedFactory.deploy(...constructorArgs)
await contract.deployTransaction.wait()
console.log(`New ${contractName} created at address:`, contract.address)

if (verify)
await verifyContract(contractName, contract.address, constructorArgs)

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
): Promise<Record<string, Contract>> {
const ethBridge = await deployContract('Bridge', signer, [])
const ethSequencerInbox = await deployContract('SequencerInbox', signer, [
maxDataSize,
false,
])
const ethInbox = await deployContract('Inbox', signer, [maxDataSize])
const ethRollupEventInbox = await deployContract(
'RollupEventInbox',
signer,
[]
)
const ethOutbox = await deployContract('Outbox', signer, [])

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

const bridgeCreator = await deployContract('BridgeCreator', signer, [
[
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)
const proverHostIo = await deployContract('OneStepProverHostIo', signer)
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)
const upgradeExecutor = await deployUpgradeExecutor()
const validatorUtils = await deployContract('ValidatorUtils', signer)
const validatorWalletCreator = await deployContract(
'ValidatorWalletCreator',
signer
)
const rollupCreator = await deployContract('RollupCreator', signer)
const deployHelper = await deployContract('DeployHelper', signer)
return {
bridgeCreator,
prover0,
proverMem,
proverMath,
proverHostIo,
osp,
challengeManager,
rollupAdmin,
rollupUser,
upgradeExecutor,
validatorUtils,
validatorWalletCreator,
rollupCreator,
deployHelper,
}
}
import { deployAllContracts } from './deploymentUtils'

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

0 comments on commit 2e5a2cb

Please sign in to comment.