From 2c83dec097b97a460a44246ca0d2b55ab0cce1f5 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Tue, 13 Feb 2024 15:56:13 +0100 Subject: [PATCH 1/2] Properly set seq inbox blob reader --- scripts/deploymentUtils.ts | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/deploymentUtils.ts b/scripts/deploymentUtils.ts index 7ae63e388e..e8aec0b791 100644 --- a/scripts/deploymentUtils.ts +++ b/scripts/deploymentUtils.ts @@ -1,5 +1,4 @@ -import { ethers } from 'hardhat' -import { ContractFactory, Contract, Overrides } from 'ethers' +import { ContractFactory, Contract, Overrides, ethers } from 'ethers' import '@nomiclabs/hardhat-ethers' import { run } from 'hardhat' import { @@ -8,6 +7,8 @@ import { } 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' // Define a verification function export async function verifyContract( @@ -83,11 +84,15 @@ export async function deployUpgradeExecutor(): Promise { export async function deployAllContracts( signer: any ): Promise> { + const isOnArb = await _isRunningOnArbitrum(signer) + const ethBridge = await deployContract('Bridge', signer, []) - const reader4844 = await Toolkit4844.deployReader4844(signer) + const reader4844 = isOnArb + ? (await Toolkit4844.deployReader4844(signer)).address + : ethers.constants.AddressZero const ethSequencerInbox = await deployContract('SequencerInbox', signer, [ maxDataSize, - reader4844.address, + reader4844, false, ]) @@ -102,7 +107,7 @@ export async function deployAllContracts( const erc20Bridge = await deployContract('ERC20Bridge', signer, []) const erc20SequencerInbox = await deployContract('SequencerInbox', signer, [ maxDataSize, - reader4844.address, + reader4844, true, ]) const erc20Inbox = await deployContract('ERC20Inbox', signer, [maxDataSize]) @@ -167,3 +172,14 @@ export async function deployAllContracts( deployHelper, } } + +// Check if we're deploying to an Arbitrum chain +async function _isRunningOnArbitrum(signer: any): Promise { + const arbSys = ArbSys__factory.connect(ARB_SYS_ADDRESS, signer) + try { + await arbSys.arbOSVersion() + return true + } catch (error) { + return false + } +} From 3e1dccab2b1faa2b2556ddbd41613478bbbae37d Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Tue, 13 Feb 2024 17:26:14 +0100 Subject: [PATCH 2/2] Update script to work with latest design --- scripts/deploymentUtils.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/scripts/deploymentUtils.ts b/scripts/deploymentUtils.ts index e8aec0b791..2df51be686 100644 --- a/scripts/deploymentUtils.ts +++ b/scripts/deploymentUtils.ts @@ -1,4 +1,5 @@ -import { ContractFactory, Contract, Overrides, ethers } from 'ethers' +import { ethers } from 'hardhat' +import { ContractFactory, Contract, Overrides } from 'ethers' import '@nomiclabs/hardhat-ethers' import { run } from 'hardhat' import { @@ -57,10 +58,13 @@ export async function deployContract( ): Promise { const factory: ContractFactory = await ethers.getContractFactory(contractName) const connectedFactory: ContractFactory = factory.connect(signer) - const contract: Contract = await connectedFactory.deploy( - ...constructorArgs, - overrides - ) + + let deploymentArgs = [...constructorArgs] + if (overrides) { + deploymentArgs.push(overrides) + } + + const contract: Contract = await connectedFactory.deploy(...deploymentArgs) await contract.deployTransaction.wait() console.log(`New ${contractName} created at address:`, contract.address) @@ -71,12 +75,13 @@ export async function deployContract( } // Deploy upgrade executor from imported bytecode -export async function deployUpgradeExecutor(): Promise { +export async function deployUpgradeExecutor(signer: any): Promise { const upgradeExecutorFac = await ethers.getContractFactory( UpgradeExecutorABI, UpgradeExecutorBytecode ) - const upgradeExecutor = await upgradeExecutorFac.deploy() + const connectedFactory: ContractFactory = upgradeExecutorFac.connect(signer) + const upgradeExecutor = await connectedFactory.deploy() return upgradeExecutor } @@ -88,8 +93,9 @@ export async function deployAllContracts( const ethBridge = await deployContract('Bridge', signer, []) const reader4844 = isOnArb - ? (await Toolkit4844.deployReader4844(signer)).address - : ethers.constants.AddressZero + ? ethers.constants.AddressZero + : (await Toolkit4844.deployReader4844(signer)).address + const ethSequencerInbox = await deployContract('SequencerInbox', signer, [ maxDataSize, reader4844, @@ -147,7 +153,7 @@ export async function deployAllContracts( const challengeManager = await deployContract('ChallengeManager', signer) const rollupAdmin = await deployContract('RollupAdminLogic', signer) const rollupUser = await deployContract('RollupUserLogic', signer) - const upgradeExecutor = await deployUpgradeExecutor() + const upgradeExecutor = await deployUpgradeExecutor(signer) const validatorUtils = await deployContract('ValidatorUtils', signer) const validatorWalletCreator = await deployContract( 'ValidatorWalletCreator',