Skip to content
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
version: stable

- name: Setup node/yarn
uses: actions/setup-node@v3
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
version: stable

- name: Setup node/yarn
uses: actions/setup-node@v3
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"test:l2": "hardhat test test/*.l2.ts",
"test:unit": "forge test",
"test:e2e:local-env": "yarn hardhat test test-e2e/*",
"test:storage": "./scripts/storage_layout_test.bash",
"test:signatures": "./scripts/signatures_test.bash",
"test:storage": "./test/storage/test-storage.bash",
"test:signatures": "./test/signatures/test-sigs.bash",
"test:mutation": "ts-node test-mutation/gambitTester.ts",
"test:unused:errors": "./test/unused-errors/find_unused_errors.sh",
"deploy:local:token-bridge": "ts-node ./scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts",
Expand Down Expand Up @@ -50,7 +50,7 @@
"@openzeppelin/contracts-upgradeable": "4.8.3"
},
"devDependencies": {
"@arbitrum/sdk": "^3.5.1",
"@arbitrum/sdk": "^4.0.4",
"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-etherscan": "^3.1.0",
"@nomiclabs/hardhat-waffle": "^2.0.1",
Expand Down
38 changes: 19 additions & 19 deletions scripts/atomicTokenBridgeDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ import {
} from '@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json'
import { JsonRpcProvider } from '@ethersproject/providers'
import {
L1ToL2MessageGasEstimator,
L1ToL2MessageStatus,
L1TransactionReceipt,
ParentToChildMessageGasEstimator,
ParentToChildMessageStatus,
ParentTransactionReceipt,
ParentContractCallTransactionReceipt
} from '@arbitrum/sdk'
import { exit } from 'process'
import { getBaseFee } from '@arbitrum/sdk/dist/lib/utils/lib'
import { RollupAdminLogic__factory } from '@arbitrum/sdk/dist/lib/abi/factories/RollupAdminLogic__factory'
import { ContractVerifier } from './contractVerifier'
import { OmitTyped } from '@arbitrum/sdk/dist/lib/utils/types'
import { L1ToL2MessageGasParams } from '@arbitrum/sdk/dist/lib/message/L1ToL2MessageCreator'
import { L1ContractCallTransactionReceipt } from '@arbitrum/sdk/dist/lib/message/L1Transaction'
import { _getScaledAmount } from './local-deployment/localDeploymentLib'
import { ParentToChildMessageGasParams } from '@arbitrum/sdk/dist/lib/message/ParentToChildMessageCreator'

/**
* Dummy non-zero address which is provided to logic contracts initializers
Expand Down Expand Up @@ -168,25 +168,25 @@ export const createTokenBridge = async (
console.log('Deployment TX:', receipt.transactionHash)

/// wait for execution of both tickets
const l1TxReceipt = new L1TransactionReceipt(receipt)
const messages = await l1TxReceipt.getL1ToL2Messages(l2Provider)
const l1TxReceipt = new ParentTransactionReceipt(receipt)
const messages = await l1TxReceipt.getParentToChildMessages(l2Provider)
const messageResults = await Promise.all(
messages.map(message => message.waitForStatus())
)

// if both tickets are not redeemed log it and exit
if (
messageResults[0].status !== L1ToL2MessageStatus.REDEEMED ||
messageResults[1].status !== L1ToL2MessageStatus.REDEEMED
messageResults[0].status !== ParentToChildMessageStatus.REDEEMED ||
messageResults[1].status !== ParentToChildMessageStatus.REDEEMED
) {
console.log(
`Retryable ticket (ID ${messages[0].retryableCreationId}) status: ${
L1ToL2MessageStatus[messageResults[0].status]
ParentToChildMessageStatus[messageResults[0].status]
}`
)
console.log(
`Retryable ticket (ID ${messages[1].retryableCreationId}) status: ${
L1ToL2MessageStatus[messageResults[1].status]
ParentToChildMessageStatus[messageResults[1].status]
}`
)
exit()
Expand All @@ -195,7 +195,7 @@ export const createTokenBridge = async (
/// pick up L2 factory address from 1st ticket
const l2AtomicTokenBridgeFactory =
L2AtomicTokenBridgeFactory__factory.connect(
messageResults[0].l2TxReceipt.contractAddress,
messageResults[0].childTxReceipt.contractAddress,
l2Provider
)
console.log('L2AtomicTokenBridgeFactory', l2AtomicTokenBridgeFactory.address)
Expand Down Expand Up @@ -603,7 +603,7 @@ export const registerGateway = async (

const executorAddress = await l1Executor.getAddress()

const buildCall = (params: OmitTyped<L1ToL2MessageGasParams, 'deposit'>) => {
const buildCall = (params: OmitTyped<ParentToChildMessageGasParams, 'deposit'>) => {
const routerCalldata =
L1GatewayRouter__factory.createInterface().encodeFunctionData(
'setGateways',
Expand All @@ -628,13 +628,13 @@ export const registerGateway = async (
}
}

const estimator = new L1ToL2MessageGasEstimator(l2Provider)
const estimator = new ParentToChildMessageGasEstimator(l2Provider)
const txRequest = await estimator.populateFunctionParams(
buildCall,
l1Executor.provider!
)

const receipt = new L1ContractCallTransactionReceipt(
const receipt = new ParentContractCallTransactionReceipt(
await (
await l1Executor.sendTransaction({
to: txRequest.to,
Expand All @@ -645,12 +645,12 @@ export const registerGateway = async (
)

// wait for execution of ticket
const message = (await receipt.getL1ToL2Messages(l2Provider))[0]
const message = (await receipt.getParentToChildMessages(l2Provider))[0]
const messageResult = await message.waitForStatus()
if (messageResult.status !== L1ToL2MessageStatus.REDEEMED) {
if (messageResult.status !== ParentToChildMessageStatus.REDEEMED) {
console.log(
`Retryable ticket (ID ${message.retryableCreationId}) status: ${
L1ToL2MessageStatus[messageResult.status]
ParentToChildMessageStatus[messageResult.status]
}`
)
exit()
Expand All @@ -663,7 +663,7 @@ export const getEstimateForDeployingFactory = async (
) => {
//// run retryable estimate for deploying L2 factory
const l1DeployerAddress = await l1Deployer.getAddress()
const l1ToL2MsgGasEstimate = new L1ToL2MessageGasEstimator(l2Provider)
const l1ToL2MsgGasEstimate = new ParentToChildMessageGasEstimator(l2Provider)
const deployFactoryGasParams = await l1ToL2MsgGasEstimate.estimateAll(
{
from: ethers.Wallet.createRandom().address,
Expand Down
88 changes: 26 additions & 62 deletions scripts/deployment/createTokenBridge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JsonRpcProvider } from '@ethersproject/providers'
import { L1Network, L2Network, addCustomNetwork } from '@arbitrum/sdk'
import { ArbitrumNetwork, registerCustomArbitrumNetwork } from '@arbitrum/sdk'
import { RollupAdminLogic__factory } from '@arbitrum/sdk/dist/lib/abi/factories/RollupAdminLogic__factory'
import { createTokenBridge, getSigner } from '../atomicTokenBridgeDeployer'
import dotenv from 'dotenv'
Expand Down Expand Up @@ -51,7 +51,7 @@ export const createTokenBridgeOnTargetChain = async () => {
const l1Deployer = getSigner(l1Provider, envVars.baseChainDeployerKey)
const l2Provider = new JsonRpcProvider(envVars.childChainRpc)

const { l1Network, l2Network: corel2Network } = await registerNetworks(
const { l2Network: corel2Network } = await registerNetworks(
l1Provider,
l2Provider,
envVars.rollupAddress
Expand All @@ -72,29 +72,28 @@ export const createTokenBridgeOnTargetChain = async () => {
envVars.rollupOwner
)

const l2Network = {
const l2Network: ArbitrumNetwork = {
...corel2Network,
tokenBridge: {
l1CustomGateway: l1Deployment.customGateway,
l1ERC20Gateway: l1Deployment.standardGateway,
l1GatewayRouter: l1Deployment.router,
l1MultiCall: l1MultiCall,
l1ProxyAdmin: l1ProxyAdmin,
l1Weth: l1Deployment.weth,
l1WethGateway: l1Deployment.wethGateway,

l2CustomGateway: l2Deployment.customGateway,
l2ERC20Gateway: l2Deployment.standardGateway,
l2GatewayRouter: l2Deployment.router,
l2Multicall: l2Deployment.multicall,
l2ProxyAdmin: l2Deployment.proxyAdmin,
l2Weth: l2Deployment.weth,
l2WethGateway: l2Deployment.wethGateway,
parentCustomGateway: l1Deployment.customGateway,
parentErc20Gateway: l1Deployment.standardGateway,
parentGatewayRouter: l1Deployment.router,
parentMultiCall: l1MultiCall,
parentProxyAdmin: l1ProxyAdmin,
parentWeth: l1Deployment.weth,
parentWethGateway: l1Deployment.wethGateway,

childCustomGateway: l2Deployment.customGateway,
childErc20Gateway: l2Deployment.standardGateway,
childGatewayRouter: l2Deployment.router,
childMultiCall: l2Deployment.multicall,
childProxyAdmin: l2Deployment.proxyAdmin,
childWeth: l2Deployment.weth,
childWethGateway: l2Deployment.wethGateway,
},
}

return {
l1Network,
l2Network,
}
}
Expand All @@ -104,25 +103,15 @@ const registerNetworks = async (
l2Provider: JsonRpcProvider,
rollupAddress: string
): Promise<{
l1Network: L1Network
l2Network: Omit<L2Network, 'tokenBridge'>
l2Network: ArbitrumNetwork
}> => {
const l1NetworkInfo = await l1Provider.getNetwork()
const l2NetworkInfo = await l2Provider.getNetwork()

const l1Network: L1Network = {
blockTime: 10,
chainID: l1NetworkInfo.chainId,
explorerUrl: '',
isCustom: true,
name: l1NetworkInfo.name,
partnerChainIDs: [l2NetworkInfo.chainId],
isArbitrum: false,
}

const rollup = RollupAdminLogic__factory.connect(rollupAddress, l1Provider)
const l2Network: L2Network = {
chainID: l2NetworkInfo.chainId,
const l2Network: ArbitrumNetwork = {
isTestnet: false,
chainId: l2NetworkInfo.chainId,
confirmPeriodBlocks: (await rollup.confirmPeriodBlocks()).toNumber(),
ethBridge: {
bridge: await rollup.bridge(),
Expand All @@ -131,51 +120,26 @@ const registerNetworks = async (
rollup: rollup.address,
sequencerInbox: await rollup.sequencerInbox(),
},
explorerUrl: '',
isArbitrum: true,
isCustom: true,
name: 'OrbitChain',
partnerChainID: l1NetworkInfo.chainId,
parentChainId: l1NetworkInfo.chainId,
retryableLifetimeSeconds: 7 * 24 * 60 * 60,
nitroGenesisBlock: 0,
nitroGenesisL1Block: 0,
depositTimeout: 900000,
tokenBridge: {
l1CustomGateway: '',
l1ERC20Gateway: '',
l1GatewayRouter: '',
l1MultiCall: '',
l1ProxyAdmin: '',
l1Weth: '',
l1WethGateway: '',
l2CustomGateway: '',
l2ERC20Gateway: '',
l2GatewayRouter: '',
l2Multicall: '',
l2ProxyAdmin: '',
l2Weth: '',
l2WethGateway: '',
},
}

// register - needed for retryables
addCustomNetwork({
customL1Network: l1Network,
customL2Network: l2Network,
})
registerCustomArbitrumNetwork(l2Network)

return {
l1Network,
l2Network,
}
}

async function main() {
const { l1Network, l2Network } = await createTokenBridgeOnTargetChain()
const { l2Network } = await createTokenBridgeOnTargetChain()
const NETWORK_FILE = 'network.json'
fs.writeFileSync(
NETWORK_FILE,
JSON.stringify({ l1Network, l2Network }, null, 2)
JSON.stringify({ l2Network }, null, 2)
)
console.log(NETWORK_FILE + ' updated')
}
Expand Down
49 changes: 7 additions & 42 deletions scripts/deployment/deployTokenBridgeCreator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JsonRpcProvider } from '@ethersproject/providers'
import { L1Network, L2Network, addCustomNetwork } from '@arbitrum/sdk'
import { ArbitrumNetwork, registerCustomArbitrumNetwork } from '@arbitrum/sdk'
import { RollupAdminLogic__factory } from '@arbitrum/sdk/dist/lib/abi/factories/RollupAdminLogic__factory'
import {
deployL1TokenBridgeCreator,
Expand Down Expand Up @@ -90,25 +90,15 @@ const registerNetworks = async (
l2Provider: JsonRpcProvider,
rollupAddress: string
): Promise<{
l1Network: L1Network
l2Network: Omit<L2Network, 'tokenBridge'>
l2Network: ArbitrumNetwork
}> => {
const l1NetworkInfo = await l1Provider.getNetwork()
const l2NetworkInfo = await l2Provider.getNetwork()

const l1Network: L1Network = {
blockTime: 10,
chainID: l1NetworkInfo.chainId,
explorerUrl: '',
isCustom: true,
name: l1NetworkInfo.name,
partnerChainIDs: [l2NetworkInfo.chainId],
isArbitrum: false,
}

const rollup = RollupAdminLogic__factory.connect(rollupAddress, l1Provider)
const l2Network: L2Network = {
chainID: l2NetworkInfo.chainId,
const l2Network: ArbitrumNetwork = {
isTestnet: false,
chainId: l2NetworkInfo.chainId,
confirmPeriodBlocks: (await rollup.confirmPeriodBlocks()).toNumber(),
ethBridge: {
bridge: await rollup.bridge(),
Expand All @@ -117,41 +107,16 @@ const registerNetworks = async (
rollup: rollup.address,
sequencerInbox: await rollup.sequencerInbox(),
},
explorerUrl: '',
isArbitrum: true,
isCustom: true,
name: 'OrbitChain',
partnerChainID: l1NetworkInfo.chainId,
parentChainId: l1NetworkInfo.chainId,
retryableLifetimeSeconds: 7 * 24 * 60 * 60,
nitroGenesisBlock: 0,
nitroGenesisL1Block: 0,
depositTimeout: 900000,
tokenBridge: {
l1CustomGateway: '',
l1ERC20Gateway: '',
l1GatewayRouter: '',
l1MultiCall: '',
l1ProxyAdmin: '',
l1Weth: '',
l1WethGateway: '',
l2CustomGateway: '',
l2ERC20Gateway: '',
l2GatewayRouter: '',
l2Multicall: '',
l2ProxyAdmin: '',
l2Weth: '',
l2WethGateway: '',
},
}

// register - needed for retryables
addCustomNetwork({
customL1Network: l1Network,
customL2Network: l2Network,
})
registerCustomArbitrumNetwork(l2Network)

return {
l1Network,
l2Network,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { setupTokenBridgeInLocalEnv } from './localDeploymentLib'

async function main() {
const {
l1Network,
l2Network,
l1TokenBridgeCreatorAddress: l1TokenBridgeCreator,
retryableSenderAddress: retryableSender,
Expand All @@ -13,7 +12,7 @@ async function main() {
fs.writeFileSync(
NETWORK_FILE,
JSON.stringify(
{ l1Network, l2Network, l1TokenBridgeCreator, retryableSender },
{ l2Network, l1TokenBridgeCreator, retryableSender },
null,
2
)
Expand Down
Loading