Skip to content

Commit

Permalink
Use upgrade executor from npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Aug 18, 2023
1 parent 3ca96b2 commit d5998c2
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 194 deletions.
4 changes: 2 additions & 2 deletions contracts/tokenbridge/arbitrum/L2AtomicTokenBridgeFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {L2ERC20Gateway} from "./gateway/L2ERC20Gateway.sol";
import {L2CustomGateway} from "./gateway/L2CustomGateway.sol";
import {L2WethGateway} from "./gateway/L2WethGateway.sol";
import {StandardArbERC20} from "./StandardArbERC20.sol";
import {UpgradeExecutor} from "../libraries/UpgradeExecutor.sol";
import {IUpgradeExecutor} from "@offchainlabs/upgrade-executor/src/IUpgradeExecutor.sol";
import {BeaconProxyFactory} from "../libraries/ClonableBeaconProxy.sol";
import {aeWETH} from "../libraries/aeWETH.sol";
import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
Expand Down Expand Up @@ -87,7 +87,7 @@ contract L2AtomicTokenBridgeFactory {
address[] memory executors = new address[](2);
executors[0] = rollupOwner;
executors[1] = aliasedL1UpgradeExecutor;
UpgradeExecutor(canonicalUpgradeExecutor).initialize(canonicalUpgradeExecutor, executors);
IUpgradeExecutor(canonicalUpgradeExecutor).initialize(canonicalUpgradeExecutor, executors);

return canonicalUpgradeExecutor;
}
Expand Down
5 changes: 2 additions & 3 deletions contracts/tokenbridge/ethereum/L1AtomicTokenBridgeCreator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {L1WethGateway} from "./gateway/L1WethGateway.sol";
import {L1OrbitGatewayRouter} from "./gateway/L1OrbitGatewayRouter.sol";
import {L1OrbitERC20Gateway} from "./gateway/L1OrbitERC20Gateway.sol";
import {L1OrbitCustomGateway} from "./gateway/L1OrbitCustomGateway.sol";

import {TransparentUpgradeableProxy} from
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {
Expand All @@ -28,7 +27,7 @@ import {
ProxyAdmin
} from "../arbitrum/L2AtomicTokenBridgeFactory.sol";
import {BytesLib} from "../libraries/BytesLib.sol";
import {UpgradeExecutor} from "../libraries/UpgradeExecutor.sol";
import {IUpgradeExecutor} from "@offchainlabs/upgrade-executor/src/IUpgradeExecutor.sol";
import {AddressAliasHelper} from "../libraries/AddressAliasHelper.sol";
import {IInbox, IBridge, IOwnable} from "@arbitrum/nitro-contracts/src/bridge/IInbox.sol";
import {AddressAliasHelper} from "../libraries/AddressAliasHelper.sol";
Expand Down Expand Up @@ -73,7 +72,7 @@ contract L1AtomicTokenBridgeCreator is Initializable, OwnableUpgradeable {
L1OrbitGatewayRouter feeTokenBasedRouterTemplate;
L1OrbitERC20Gateway feeTokenBasedStandardGatewayTemplate;
L1OrbitCustomGateway feeTokenBasedCustomGatewayTemplate;
UpgradeExecutor upgradeExecutor;
IUpgradeExecutor upgradeExecutor;
}

// non-canonical router registry
Expand Down
57 changes: 0 additions & 57 deletions contracts/tokenbridge/libraries/UpgradeExecutor.sol

This file was deleted.

2 changes: 1 addition & 1 deletion lib/nitro-contracts
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"@arbitrum/nitro-contracts": "^1.0.0-beta.8",
"@arbitrum/sdk": "^3.1.5",
"@openzeppelin/contracts": "4.8.3",
"@openzeppelin/contracts-upgradeable": "4.8.3"
"@openzeppelin/contracts-upgradeable": "4.8.3",
"@offchainlabs/upgrade-executor": "^1.0.0-beta.2"
},
"devDependencies": {
"@arbitrum/sdk": "^3.1.3",
Expand Down
15 changes: 10 additions & 5 deletions scripts/atomicTokenBridgeDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ import {
IInbox__factory,
IERC20Bridge__factory,
IERC20__factory,
UpgradeExecutor__factory,
} from '../build/types'
import {
abi as UpgradeExecutorABI,
bytecode as UpgradeExecutorBytecode,
} from '@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json'
import { JsonRpcProvider } from '@ethersproject/providers'
import {
L1ToL2MessageGasEstimator,
Expand Down Expand Up @@ -75,7 +78,7 @@ export const createTokenBridge = async (
customGateway: L2CustomGateway__factory.bytecode,
wethGateway: L2WethGateway__factory.bytecode,
aeWeth: AeWETH__factory.bytecode,
upgradeExecutor: UpgradeExecutor__factory.bytecode,
upgradeExecutor: UpgradeExecutorBytecode,
}
const gasEstimateToDeployContracts =
await l2FactoryTemplate.estimateGas.deployL2Contracts(
Expand Down Expand Up @@ -304,10 +307,12 @@ export const deployL1TokenBridgeCreator = async (
await new L1OrbitCustomGateway__factory(l1Deployer).deploy()
await feeTokenBasedCustomGatewayTemplate.deployed()

const upgradeExecutor = await new UpgradeExecutor__factory(
const upgradeExecutor = new ethers.ContractFactory(
UpgradeExecutorABI,
UpgradeExecutorBytecode,
l1Deployer
).deploy()
await upgradeExecutor.deployed()
)
await upgradeExecutor.deploy()

const l1Templates = {
routerTemplate: routerTemplate.address,
Expand Down
14 changes: 8 additions & 6 deletions test-e2e/tokenBridgeDeploymentTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import {
L2GatewayRouter__factory,
L2WethGateway,
L2WethGateway__factory,
UpgradeExecutor,
UpgradeExecutor__factory,
} from '../build/types'
import { abi as UpgradeExecutorABI } from '@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json'
import { RollupCore__factory } from '@arbitrum/sdk/dist/lib/abi/factories/RollupCore__factory'
import { applyAlias } from '../test/testhelper'
import path from 'path'
import fs from 'fs'
import { expect } from 'chai'
import { ethers } from 'hardhat'
import { Contract } from 'ethers'

const config = {
l1Url: process.env.BASECHAIN_RPC || 'http://localhost:8545',
Expand Down Expand Up @@ -125,10 +125,12 @@ describe('tokenBridge', () => {
)
}

await checkL2UpgradeExecutorInitialization(
UpgradeExecutor__factory.connect(l2.upgradeExecutor, l2Provider),
l1
const upgExecutor = new ethers.Contract(
l2.upgradeExecutor,
UpgradeExecutorABI,
l2Provider
)
await checkL2UpgradeExecutorInitialization(upgExecutor, l1)

await checkL1Ownership(l1)
await checkL2Ownership(l2)
Expand Down Expand Up @@ -248,7 +250,7 @@ async function checkL1WethGatewayInitialization(
}

async function checkL2UpgradeExecutorInitialization(
l2Executor: UpgradeExecutor,
l2Executor: Contract,
l1: L1
) {
console.log('checkL2UpgradeExecutorInitialization')
Expand Down
Loading

0 comments on commit d5998c2

Please sign in to comment.