Skip to content

Commit 9fb1fe5

Browse files
committed
Merge branch 'main' into add-creator-ci
2 parents f5ac379 + 6dff4c5 commit 9fb1fe5

File tree

9 files changed

+306
-46
lines changed

9 files changed

+306
-46
lines changed

.env-sample

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1+
## RPC endpoint
2+
BASECHAIN_RPC=""
3+
4+
## Deployer key used for deploying creator or creating token bridge
5+
BASECHAIN_DEPLOYER_KEY=""
6+
7+
## WETH address on the basechain. It will be set and used in the TokenBridgeCreator
8+
BASECHAIN_WETH=""
9+
10+
## Gas limit for deploying child chain factory needs to be provided to the TokenBridgeCreator when templates are set.
11+
## If this param is not provided then gas limit will be estimated using SDK from child chain (specified by ORBIT_RPC and ROLLUP_ADDRESS)
12+
GAS_LIMIT_FOR_L2_FACTORY_DEPLOYMENT=6000000
13+
14+
## Contract verification
15+
ARBISCAN_API_KEY=""
16+
17+
### Vars for creating token bridge from existing TokenBridgeCreator
118
## Rollup on top of which token bridge will be created
219
ROLLUP_ADDRESS=""
20+
ORBIT_RPC=""
321
ROLLUP_OWNER=""
422
L1_TOKEN_BRIDGE_CREATOR=""
523
# needed for verification
6-
L1_RETRYABLE_SENDER=""
7-
8-
## RPC endpoints
9-
BASECHAIN_RPC=""
10-
ORBIT_RPC=""
11-
12-
## Deployer key used for deploying creator and creating token bridge
13-
BASECHAIN_DEPLOYER_KEY=""
24+
L1_RETRYABLE_SENDER=""

.env.arb1.sample

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## RPC endpoint
2+
BASECHAIN_RPC="https://arb1.arbitrum.io/rpc"
3+
4+
## Deployer key used for deploying creator or creating token bridge
5+
BASECHAIN_DEPLOYER_KEY=""
6+
7+
## WETH address on the basechain. It will be set and used in the TokenBridgeCreator
8+
BASECHAIN_WETH="0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
9+
10+
## Gas limit for deploying child chain factory needs to be provided to the TokenBridgeCreator when templates are set.
11+
## If this param is not provided then gas limit will be estimated using SDK from child chain (specified by ORBIT_RPC and ROLLUP_ADDRESS)
12+
GAS_LIMIT_FOR_L2_FACTORY_DEPLOYMENT=6000000
13+
14+
## Contract verification
15+
ARBISCAN_API_KEY=""
16+
17+
18+
### Vars for creating token bridge from existing TokenBridgeCreator
19+
## Rollup on top of which token bridge will be created
20+
# ROLLUP_ADDRESS=""
21+
# ORBIT_RPC=""
22+
# ROLLUP_OWNER=""
23+
# L1_TOKEN_BRIDGE_CREATOR=""
24+
# # needed for verification
25+
# L1_RETRYABLE_SENDER=""

contracts/tokenbridge/arbitrum/L2AtomicTokenBridgeFactory.sol

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
2525
contract L2AtomicTokenBridgeFactory {
2626
error L2AtomicTokenBridgeFactory_AlreadyExists();
2727

28+
// In order to avoid having uninitialized logic contracts, `initialize` function will be called
29+
// on all logic contracts which don't have initializers disabled. This dummy non-zero address
30+
// will be provided to those initializers, as values written to the logic contract's storage
31+
// are not used.
32+
address private constant ADDRESS_DEAD = address(0x000000000000000000000000000000000000dEaD);
33+
2834
function deployL2Contracts(
2935
L2RuntimeCode calldata l2Code,
3036
address l1Router,
@@ -86,7 +92,8 @@ contract L2AtomicTokenBridgeFactory {
8692
proxyAdmin, _getL2Salt(OrbitSalts.L2_EXECUTOR), _getL2Salt(OrbitSalts.L2_EXECUTOR_LOGIC)
8793
);
8894

89-
// create UpgradeExecutor logic and upgrade to it
95+
// Create UpgradeExecutor logic and upgrade to it.
96+
// Note: UpgradeExecutor logic has initializer disabled so no need to call it.
9097
address upExecutorLogic = Create2.deploy(
9198
0, _getL2Salt(OrbitSalts.L2_EXECUTOR_LOGIC), _creationCodeFor(runtimeCode)
9299
);
@@ -119,6 +126,9 @@ contract L2AtomicTokenBridgeFactory {
119126
Create2.deploy(0, _getL2Salt(OrbitSalts.L2_ROUTER_LOGIC), _creationCodeFor(runtimeCode));
120127
ProxyAdmin(proxyAdmin).upgrade(ITransparentUpgradeableProxy(canonicalRouter), routerLogic);
121128

129+
// init logic contract with dummy values.
130+
L2GatewayRouter(routerLogic).initialize(ADDRESS_DEAD, ADDRESS_DEAD);
131+
122132
// init
123133
L2GatewayRouter(canonicalRouter).initialize(l1Router, l2StandardGatewayCanonicalAddress);
124134

@@ -147,6 +157,9 @@ contract L2AtomicTokenBridgeFactory {
147157
ITransparentUpgradeableProxy(canonicalStdGateway), stdGatewayLogic
148158
);
149159

160+
// init logic contract with dummy values
161+
L2ERC20Gateway(stdGatewayLogic).initialize(ADDRESS_DEAD, ADDRESS_DEAD, ADDRESS_DEAD);
162+
150163
// create beacon
151164
StandardArbERC20 standardArbERC20 = new StandardArbERC20{
152165
salt: _getL2Salt(OrbitSalts.L2_STANDARD_ERC20)
@@ -189,8 +202,11 @@ contract L2AtomicTokenBridgeFactory {
189202
ITransparentUpgradeableProxy(canonicalCustomGateway), customGatewayLogicAddress
190203
);
191204

205+
// init logic contract with dummy values
206+
L2CustomGateway(customGatewayLogicAddress).initialize(ADDRESS_DEAD, ADDRESS_DEAD);
207+
192208
// init
193-
L2GatewayRouter(canonicalCustomGateway).initialize(l1CustomGateway, router);
209+
L2CustomGateway(canonicalCustomGateway).initialize(l1CustomGateway, router);
194210
}
195211

196212
function _deployWethGateway(
@@ -206,7 +222,7 @@ contract L2AtomicTokenBridgeFactory {
206222
proxyAdmin, _getL2Salt(OrbitSalts.L2_WETH), _getL2Salt(OrbitSalts.L2_WETH_LOGIC)
207223
);
208224

209-
// create L2WETH logic and upgrade
225+
// Create L2WETH logic and upgrade
210226
address l2WethLogic = Create2.deploy(
211227
0, _getL2Salt(OrbitSalts.L2_WETH_LOGIC), _creationCodeFor(aeWethRuntimeCode)
212228
);
@@ -229,11 +245,19 @@ contract L2AtomicTokenBridgeFactory {
229245
ITransparentUpgradeableProxy(canonicalL2WethGateway), l2WethGatewayLogic
230246
);
231247

248+
// init logic contract with dummy values
249+
L2WethGateway(payable(l2WethGatewayLogic)).initialize(
250+
ADDRESS_DEAD, ADDRESS_DEAD, ADDRESS_DEAD, ADDRESS_DEAD
251+
);
252+
232253
// init gateway
233254
L2WethGateway(payable(canonicalL2WethGateway)).initialize(
234255
l1WethGateway, router, l1Weth, address(canonicalL2Weth)
235256
);
236257

258+
// init logic contract with dummy values
259+
aeWETH(payable(l2WethLogic)).initialize("", "", 0, ADDRESS_DEAD, ADDRESS_DEAD);
260+
237261
// init L2Weth
238262
aeWETH(payable(canonicalL2Weth)).initialize(
239263
"WETH", "WETH", 18, canonicalL2WethGateway, l1Weth

docs/deployment.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# How to deploy RollupCreator and TokenBridgeCreator?
2+
3+
## RollupCreator
4+
RollupCreator is in nitro-contracts repo
5+
```
6+
cd nitro-contracts
7+
```
8+
9+
Checkout target code, ie.
10+
```
11+
git checkout v1.1.0
12+
```
13+
14+
Install dependencies and build
15+
```
16+
yarn install
17+
yarn build
18+
```
19+
20+
Populate .env
21+
```
22+
DEVNET_PRIVKEY or MAINNET_PRIVKEY
23+
ARBISCAN_API_KEY
24+
```
25+
26+
Finally deploy it, using `--network` flag to specify network.
27+
28+
Ie. to deploy to Arbitrum Sepolia
29+
```
30+
yarn run deploy-factory --network arbSepolia
31+
```
32+
33+
To deploy to Arbitrum One
34+
```
35+
yarn run deploy-factory --network arb1
36+
```
37+
38+
Script output will contain all deployed addresses.
39+
40+
41+
## TokenBridgeCreator
42+
Checkout target code, install dependencies and build
43+
```
44+
cd token-bridge-contracts
45+
yarn install
46+
yarn build
47+
```
48+
49+
50+
Populate .env
51+
```
52+
BASECHAIN_RPC
53+
BASECHAIN_DEPLOYER_KEY
54+
BASECHAIN_WETH
55+
GAS_LIMIT_FOR_L2_FACTORY_DEPLOYMENT
56+
ARBISCAN_API_KEY
57+
```
58+
59+
Note: Gas limit for deploying child chain factory via retryable needs to be provided to the TokenBridgeCreator when templates are set. This value can be obtained in 2 ways - 1st is to provide `ORBIT_RPC` and `ROLLUP_ADDRESS` env vars, and script will then use Arbitrum SDK to estimate gas needed for deploying L2 factory. Other way to do it is much simpler - provide hardcoded value by setting the `GAS_LIMIT_FOR_L2_FACTORY_DEPLOYMENT`. Previous deployments showed that gas needed is ~5140000. Adding a bit of buffer on top, we can set this value to `GAS_LIMIT_FOR_L2_FACTORY_DEPLOYMENT=6000000`.
60+
61+
62+
Finally, deploy token bridge creator. Target chain is defined by `BASECHAIN_RPC` env var (no need to provide `--network` flag).
63+
```
64+
yarn run deploy:token-bridge-creator
65+
```
66+
67+
Script outputs `L1TokenBridgeCreator` and `L1TokenBridgeRetryableSender` addresses. All deployed addresses can be obtained through `L1TokenBridgeCreator` contract.
68+
69+
70+
## Ownership
71+
These contracts will be owned by deployer:
72+
- RollupCreator (owner can set templates)
73+
- L1AtomicTokenBridgeCreator (owner can set templates)
74+
- ProxyAdmin of L1AtomicTokenBridgeCreator and L1TokenBridgeRetryableSender (owner can do upgrades)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"test:e2e:local-env": "yarn hardhat test test-e2e/*",
2222
"test:storage": "./scripts/storage_layout_test.bash",
2323
"deploy:local:token-bridge": "ts-node ./scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts",
24-
"deploy:goerli:token-bridge-creator": "ts-node ./scripts/goerli-deployment/deployTokenBridgeCreator.ts",
25-
"create:goerli:token-bridge": "ts-node ./scripts/goerli-deployment/createTokenBridge.ts",
24+
"deploy:token-bridge-creator": "ts-node ./scripts/deployment/deployTokenBridgeCreator.ts",
25+
"create:token-bridge": "ts-node ./scripts/deployment/createTokenBridge.ts",
2626
"test:tokenbridge:deployment": "hardhat test test-e2e/tokenBridgeDeploymentTest.ts",
2727
"typechain": "hardhat typechain",
2828
"deploy:tokenbridge": "hardhat run scripts/deploy_token_bridge_l1.ts --network mainnet",

0 commit comments

Comments
 (0)