Skip to content

Commit af0ae19

Browse files
TucksonDevgzeoneth0xallangodzillaba
authored
Merge main into develop (#111)
* nits on README add link to LICENSE, replaced dash with semicolon next to Discord * Stable foundry (#106) * use stable foundry * fix * Use template repo's signature and storage test scripts (#107) * use stable foundry * fix * use template scripts * run new scripts --------- Co-authored-by: gzeon <[email protected]> * Bump sdk (#105) * bump sdk * find and replace * write new network format (#109) * chore: isTestnet true * chore: set version to 1.2.4 --------- Co-authored-by: gzeon <[email protected]> Co-authored-by: gzeon <[email protected]> * Add missing nativeToken property to local network (#110) * add missing nativeToken property to local network * do not scale fee amount in test since sdk now handles * chore: bump version to 1.2.5 --------- Co-authored-by: gzeon <[email protected]> --------- Co-authored-by: gzeon <[email protected]> Co-authored-by: Allan <[email protected]> Co-authored-by: Henry <[email protected]> Co-authored-by: gzeon <[email protected]>
1 parent b1dd73d commit af0ae19

File tree

81 files changed

+1923
-855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1923
-855
lines changed

.github/workflows/build-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Install Foundry
1717
uses: foundry-rs/foundry-toolchain@v1
1818
with:
19-
version: nightly
19+
version: stable
2020

2121
- name: Setup node/yarn
2222
uses: actions/setup-node@v3
@@ -77,7 +77,7 @@ jobs:
7777
- name: Install Foundry
7878
uses: foundry-rs/foundry-toolchain@v1
7979
with:
80-
version: nightly
80+
version: stable
8181

8282
- name: Setup node/yarn
8383
uses: actions/setup-node@v3

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ See the [developer documentation](https://developer.arbitrum.io/asset-bridging)
1212

1313
See security audit reports [here](./audits).
1414

15-
This repository is offered under the Apache 2.0 license. See LICENSE for details.
15+
This repository is offered under the Apache 2.0 license. See [LICENSE](https://github.com/OffchainLabs/token-bridge-contracts/blob/main/LICENSE) for details.
1616

1717
## Deployment
1818
Check [this doc](./docs/deployment.md) for instructions on deployment and verification of token bridge.
1919

2020
## Contact
2121

22-
Discord - [Arbitrum](https://discord.com/invite/5KE54JwyTs)
22+
Discord: [Arbitrum](https://discord.com/invite/5KE54JwyTs)
2323

2424
Twitter: [Arbitrum](https://twitter.com/arbitrum)

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@arbitrum/token-bridge-contracts",
3-
"version": "1.2.3",
3+
"version": "1.2.5",
44
"license": "Apache-2.0",
55
"scripts": {
66
"prepublishOnly": "hardhat clean && hardhat compile",
@@ -19,8 +19,8 @@
1919
"test:l2": "hardhat test test/*.l2.ts",
2020
"test:unit": "forge test",
2121
"test:e2e:local-env": "yarn hardhat test test-e2e/*",
22-
"test:storage": "./scripts/storage_layout_test.bash",
23-
"test:signatures": "./scripts/signatures_test.bash",
22+
"test:storage": "./test/storage/test-storage.bash",
23+
"test:signatures": "./test/signatures/test-sigs.bash",
2424
"test:mutation": "ts-node test-mutation/gambitTester.ts",
2525
"test:unused:errors": "./test/unused-errors/find_unused_errors.sh",
2626
"deploy:local:token-bridge": "ts-node ./scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts",
@@ -50,7 +50,7 @@
5050
"@openzeppelin/contracts-upgradeable": "4.8.3"
5151
},
5252
"devDependencies": {
53-
"@arbitrum/sdk": "^3.5.1",
53+
"@arbitrum/sdk": "^4.0.4",
5454
"@nomiclabs/hardhat-ethers": "^2.0.1",
5555
"@nomiclabs/hardhat-etherscan": "^3.1.0",
5656
"@nomiclabs/hardhat-waffle": "^2.0.1",

scripts/atomicTokenBridgeDeployer.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ import {
3333
} from '@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json'
3434
import { JsonRpcProvider } from '@ethersproject/providers'
3535
import {
36-
L1ToL2MessageGasEstimator,
37-
L1ToL2MessageStatus,
38-
L1TransactionReceipt,
36+
ParentToChildMessageGasEstimator,
37+
ParentToChildMessageStatus,
38+
ParentTransactionReceipt,
39+
ParentContractCallTransactionReceipt
3940
} from '@arbitrum/sdk'
4041
import { exit } from 'process'
4142
import { getBaseFee } from '@arbitrum/sdk/dist/lib/utils/lib'
4243
import { RollupAdminLogic__factory } from '@arbitrum/sdk/dist/lib/abi/factories/RollupAdminLogic__factory'
4344
import { ContractVerifier } from './contractVerifier'
4445
import { OmitTyped } from '@arbitrum/sdk/dist/lib/utils/types'
45-
import { L1ToL2MessageGasParams } from '@arbitrum/sdk/dist/lib/message/L1ToL2MessageCreator'
46-
import { L1ContractCallTransactionReceipt } from '@arbitrum/sdk/dist/lib/message/L1Transaction'
4746
import { _getScaledAmount } from './local-deployment/localDeploymentLib'
47+
import { ParentToChildMessageGasParams } from '@arbitrum/sdk/dist/lib/message/ParentToChildMessageCreator'
4848

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

170170
/// wait for execution of both tickets
171-
const l1TxReceipt = new L1TransactionReceipt(receipt)
172-
const messages = await l1TxReceipt.getL1ToL2Messages(l2Provider)
171+
const l1TxReceipt = new ParentTransactionReceipt(receipt)
172+
const messages = await l1TxReceipt.getParentToChildMessages(l2Provider)
173173
const messageResults = await Promise.all(
174174
messages.map(message => message.waitForStatus())
175175
)
176176

177177
// if both tickets are not redeemed log it and exit
178178
if (
179-
messageResults[0].status !== L1ToL2MessageStatus.REDEEMED ||
180-
messageResults[1].status !== L1ToL2MessageStatus.REDEEMED
179+
messageResults[0].status !== ParentToChildMessageStatus.REDEEMED ||
180+
messageResults[1].status !== ParentToChildMessageStatus.REDEEMED
181181
) {
182182
console.log(
183183
`Retryable ticket (ID ${messages[0].retryableCreationId}) status: ${
184-
L1ToL2MessageStatus[messageResults[0].status]
184+
ParentToChildMessageStatus[messageResults[0].status]
185185
}`
186186
)
187187
console.log(
188188
`Retryable ticket (ID ${messages[1].retryableCreationId}) status: ${
189-
L1ToL2MessageStatus[messageResults[1].status]
189+
ParentToChildMessageStatus[messageResults[1].status]
190190
}`
191191
)
192192
exit()
@@ -195,7 +195,7 @@ export const createTokenBridge = async (
195195
/// pick up L2 factory address from 1st ticket
196196
const l2AtomicTokenBridgeFactory =
197197
L2AtomicTokenBridgeFactory__factory.connect(
198-
messageResults[0].l2TxReceipt.contractAddress,
198+
messageResults[0].childTxReceipt.contractAddress,
199199
l2Provider
200200
)
201201
console.log('L2AtomicTokenBridgeFactory', l2AtomicTokenBridgeFactory.address)
@@ -603,7 +603,7 @@ export const registerGateway = async (
603603

604604
const executorAddress = await l1Executor.getAddress()
605605

606-
const buildCall = (params: OmitTyped<L1ToL2MessageGasParams, 'deposit'>) => {
606+
const buildCall = (params: OmitTyped<ParentToChildMessageGasParams, 'deposit'>) => {
607607
const routerCalldata =
608608
L1GatewayRouter__factory.createInterface().encodeFunctionData(
609609
'setGateways',
@@ -628,13 +628,13 @@ export const registerGateway = async (
628628
}
629629
}
630630

631-
const estimator = new L1ToL2MessageGasEstimator(l2Provider)
631+
const estimator = new ParentToChildMessageGasEstimator(l2Provider)
632632
const txRequest = await estimator.populateFunctionParams(
633633
buildCall,
634634
l1Executor.provider!
635635
)
636636

637-
const receipt = new L1ContractCallTransactionReceipt(
637+
const receipt = new ParentContractCallTransactionReceipt(
638638
await (
639639
await l1Executor.sendTransaction({
640640
to: txRequest.to,
@@ -645,12 +645,12 @@ export const registerGateway = async (
645645
)
646646

647647
// wait for execution of ticket
648-
const message = (await receipt.getL1ToL2Messages(l2Provider))[0]
648+
const message = (await receipt.getParentToChildMessages(l2Provider))[0]
649649
const messageResult = await message.waitForStatus()
650-
if (messageResult.status !== L1ToL2MessageStatus.REDEEMED) {
650+
if (messageResult.status !== ParentToChildMessageStatus.REDEEMED) {
651651
console.log(
652652
`Retryable ticket (ID ${message.retryableCreationId}) status: ${
653-
L1ToL2MessageStatus[messageResult.status]
653+
ParentToChildMessageStatus[messageResult.status]
654654
}`
655655
)
656656
exit()
@@ -663,7 +663,7 @@ export const getEstimateForDeployingFactory = async (
663663
) => {
664664
//// run retryable estimate for deploying L2 factory
665665
const l1DeployerAddress = await l1Deployer.getAddress()
666-
const l1ToL2MsgGasEstimate = new L1ToL2MessageGasEstimator(l2Provider)
666+
const l1ToL2MsgGasEstimate = new ParentToChildMessageGasEstimator(l2Provider)
667667
const deployFactoryGasParams = await l1ToL2MsgGasEstimate.estimateAll(
668668
{
669669
from: ethers.Wallet.createRandom().address,

scripts/deployment/createTokenBridge.ts

Lines changed: 26 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { JsonRpcProvider } from '@ethersproject/providers'
2-
import { L1Network, L2Network, addCustomNetwork } from '@arbitrum/sdk'
2+
import { ArbitrumNetwork, registerCustomArbitrumNetwork } from '@arbitrum/sdk'
33
import { RollupAdminLogic__factory } from '@arbitrum/sdk/dist/lib/abi/factories/RollupAdminLogic__factory'
44
import { createTokenBridge, getSigner } from '../atomicTokenBridgeDeployer'
55
import dotenv from 'dotenv'
@@ -51,7 +51,7 @@ export const createTokenBridgeOnTargetChain = async () => {
5151
const l1Deployer = getSigner(l1Provider, envVars.baseChainDeployerKey)
5252
const l2Provider = new JsonRpcProvider(envVars.childChainRpc)
5353

54-
const { l1Network, l2Network: corel2Network } = await registerNetworks(
54+
const { l2Network: corel2Network } = await registerNetworks(
5555
l1Provider,
5656
l2Provider,
5757
envVars.rollupAddress
@@ -72,29 +72,28 @@ export const createTokenBridgeOnTargetChain = async () => {
7272
envVars.rollupOwner
7373
)
7474

75-
const l2Network = {
75+
const l2Network: ArbitrumNetwork = {
7676
...corel2Network,
7777
tokenBridge: {
78-
l1CustomGateway: l1Deployment.customGateway,
79-
l1ERC20Gateway: l1Deployment.standardGateway,
80-
l1GatewayRouter: l1Deployment.router,
81-
l1MultiCall: l1MultiCall,
82-
l1ProxyAdmin: l1ProxyAdmin,
83-
l1Weth: l1Deployment.weth,
84-
l1WethGateway: l1Deployment.wethGateway,
85-
86-
l2CustomGateway: l2Deployment.customGateway,
87-
l2ERC20Gateway: l2Deployment.standardGateway,
88-
l2GatewayRouter: l2Deployment.router,
89-
l2Multicall: l2Deployment.multicall,
90-
l2ProxyAdmin: l2Deployment.proxyAdmin,
91-
l2Weth: l2Deployment.weth,
92-
l2WethGateway: l2Deployment.wethGateway,
78+
parentCustomGateway: l1Deployment.customGateway,
79+
parentErc20Gateway: l1Deployment.standardGateway,
80+
parentGatewayRouter: l1Deployment.router,
81+
parentMultiCall: l1MultiCall,
82+
parentProxyAdmin: l1ProxyAdmin,
83+
parentWeth: l1Deployment.weth,
84+
parentWethGateway: l1Deployment.wethGateway,
85+
86+
childCustomGateway: l2Deployment.customGateway,
87+
childErc20Gateway: l2Deployment.standardGateway,
88+
childGatewayRouter: l2Deployment.router,
89+
childMultiCall: l2Deployment.multicall,
90+
childProxyAdmin: l2Deployment.proxyAdmin,
91+
childWeth: l2Deployment.weth,
92+
childWethGateway: l2Deployment.wethGateway,
9393
},
9494
}
9595

9696
return {
97-
l1Network,
9897
l2Network,
9998
}
10099
}
@@ -104,25 +103,15 @@ const registerNetworks = async (
104103
l2Provider: JsonRpcProvider,
105104
rollupAddress: string
106105
): Promise<{
107-
l1Network: L1Network
108-
l2Network: Omit<L2Network, 'tokenBridge'>
106+
l2Network: ArbitrumNetwork
109107
}> => {
110108
const l1NetworkInfo = await l1Provider.getNetwork()
111109
const l2NetworkInfo = await l2Provider.getNetwork()
112110

113-
const l1Network: L1Network = {
114-
blockTime: 10,
115-
chainID: l1NetworkInfo.chainId,
116-
explorerUrl: '',
117-
isCustom: true,
118-
name: l1NetworkInfo.name,
119-
partnerChainIDs: [l2NetworkInfo.chainId],
120-
isArbitrum: false,
121-
}
122-
123111
const rollup = RollupAdminLogic__factory.connect(rollupAddress, l1Provider)
124-
const l2Network: L2Network = {
125-
chainID: l2NetworkInfo.chainId,
112+
const l2Network: ArbitrumNetwork = {
113+
isTestnet: false,
114+
chainId: l2NetworkInfo.chainId,
126115
confirmPeriodBlocks: (await rollup.confirmPeriodBlocks()).toNumber(),
127116
ethBridge: {
128117
bridge: await rollup.bridge(),
@@ -131,51 +120,26 @@ const registerNetworks = async (
131120
rollup: rollup.address,
132121
sequencerInbox: await rollup.sequencerInbox(),
133122
},
134-
explorerUrl: '',
135-
isArbitrum: true,
136123
isCustom: true,
137124
name: 'OrbitChain',
138-
partnerChainID: l1NetworkInfo.chainId,
125+
parentChainId: l1NetworkInfo.chainId,
139126
retryableLifetimeSeconds: 7 * 24 * 60 * 60,
140-
nitroGenesisBlock: 0,
141-
nitroGenesisL1Block: 0,
142-
depositTimeout: 900000,
143-
tokenBridge: {
144-
l1CustomGateway: '',
145-
l1ERC20Gateway: '',
146-
l1GatewayRouter: '',
147-
l1MultiCall: '',
148-
l1ProxyAdmin: '',
149-
l1Weth: '',
150-
l1WethGateway: '',
151-
l2CustomGateway: '',
152-
l2ERC20Gateway: '',
153-
l2GatewayRouter: '',
154-
l2Multicall: '',
155-
l2ProxyAdmin: '',
156-
l2Weth: '',
157-
l2WethGateway: '',
158-
},
159127
}
160128

161129
// register - needed for retryables
162-
addCustomNetwork({
163-
customL1Network: l1Network,
164-
customL2Network: l2Network,
165-
})
130+
registerCustomArbitrumNetwork(l2Network)
166131

167132
return {
168-
l1Network,
169133
l2Network,
170134
}
171135
}
172136

173137
async function main() {
174-
const { l1Network, l2Network } = await createTokenBridgeOnTargetChain()
138+
const { l2Network } = await createTokenBridgeOnTargetChain()
175139
const NETWORK_FILE = 'network.json'
176140
fs.writeFileSync(
177141
NETWORK_FILE,
178-
JSON.stringify({ l1Network, l2Network }, null, 2)
142+
JSON.stringify({ l2Network }, null, 2)
179143
)
180144
console.log(NETWORK_FILE + ' updated')
181145
}

0 commit comments

Comments
 (0)