Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to do single-TX deployment of token bridge for fee token based Orbit chains #37

Merged
merged 35 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
902206e
Set correct templates if fee token is used
gvladika Jul 27, 2023
adf7f4b
Add support for fee token based retryables
gvladika Jul 27, 2023
db4a222
Move fee tokens to inbox to pay for retryables
gvladika Jul 27, 2023
a0029a8
Move getter for canonical L1 router address to L1 creator
gvladika Jul 27, 2023
f399dfa
Init retryable sender from init of L1 creator
gvladika Jul 27, 2023
c6ba878
Adjust script for deploying creator
gvladika Jul 27, 2023
9f0ca76
Fix L1 router address calculation
gvladika Jul 28, 2023
43542bb
Send correct bytecode to L2
gvladika Jul 28, 2023
0e9cc76
Update test script
gvladika Jul 28, 2023
46647a9
Remove unnecessary scripts
gvladika Jul 28, 2023
79bf267
Use existing proxy admin
gvladika Aug 4, 2023
f52ae5b
Merge branch 'erc20-based-bridge' into fee-token-deployer
gvladika Aug 4, 2023
cd35fef
Deploy UpgradeExecutor to L2
gvladika Aug 6, 2023
ab468c1
Refactor upgrade executor flow
gvladika Aug 6, 2023
18ec4b6
Rename env vars
gvladika Aug 6, 2023
6f7ad28
Make verifivier script more complete
gvladika Aug 6, 2023
c4c517d
Fix deployment test
gvladika Aug 7, 2023
38083c7
Use lower case in tests
gvladika Aug 7, 2023
3ca96b2
Don't check weth stuff in case of fee token
gvladika Aug 7, 2023
d5998c2
Use upgrade executor from npm package
gvladika Aug 18, 2023
d6b7ff6
Deploy Multicall on L3
gvladika Aug 19, 2023
30cdd75
Decrease contract size by not hashing the salt prefix
gvladika Aug 19, 2023
eeac040
Prepare crosschain hardhat tests for CI
gvladika Aug 25, 2023
db20781
Merge branch 'erc20-based-bridge' into fee-token-deployer
gvladika Aug 25, 2023
14a2311
Merge branch 'fee-token-deployer' into use-executor
gvladika Aug 25, 2023
864fa61
Update address
gvladika Aug 25, 2023
2d77950
Merge branch 'erc20-based-bridge' into fee-token-deployer
gvladika Aug 31, 2023
1525d26
Merge branch 'fee-token-deployer' into use-executor
gvladika Aug 31, 2023
2ecec9a
Update smart contracts and script to reflect latest rollup ownership …
gvladika Sep 1, 2023
09c9715
Merge pull request #38 from OffchainLabs/use-executor
gvladika Sep 7, 2023
1f2121f
Add docs for computeAddress function
gvladika Sep 7, 2023
6cb2060
Verify retyrable sender was not frontrun
gvladika Sep 7, 2023
7606ab6
Use chainId in salt for L2 contracts.
gvladika Sep 8, 2023
ee8c5aa
Merge pull request #41 from OffchainLabs/use-chain-id
gvladika Sep 11, 2023
b408bcf
Merge branch 'erc20-based-bridge' into fee-token-deployer
gvladika Sep 11, 2023
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
62 changes: 44 additions & 18 deletions contracts/tokenbridge/arbitrum/L2AtomicTokenBridgeFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ contract L2AtomicTokenBridgeFactory {
address rollupOwner
) external {
// create proxyAdmin which will be used for all contracts
address proxyAdmin = address(new ProxyAdmin{ salt: _getL2Salt(OrbitSalts.L2_PROXY_ADMIN) }());
address proxyAdmin =
address(new ProxyAdmin{ salt: _getL2Salt(OrbitSalts.L2_PROXY_ADMIN) }());

// deploy router/gateways
address router = _deployRouter(l2Code.router, l1Router, l2StandardGatewayCanonicalAddress, proxyAdmin);
address router =
_deployRouter(l2Code.router, l1Router, l2StandardGatewayCanonicalAddress, proxyAdmin);
_deployStandardGateway(l2Code.standardGateway, l1StandardGateway, router, proxyAdmin);
_deployCustomGateway(l2Code.customGateway, l1CustomGateway, router, proxyAdmin);
_deployWethGateway(l2Code.wethGateway, l2Code.aeWeth, l1WethGateway, l1Weth, router, proxyAdmin);

// fee token based creator will provide address(0) as WETH is not used in ERC20-based chains
if (l1WethGateway != address(0)) {
_deployWethGateway(
l2Code.wethGateway, l2Code.aeWeth, l1WethGateway, l1Weth, router, proxyAdmin
);
}

// transfer ownership to rollup's owner
ProxyAdmin(proxyAdmin).transferOwnership(rollupOwner);
Expand All @@ -61,7 +69,8 @@ contract L2AtomicTokenBridgeFactory {
);

// create L2 router logic and upgrade
address routerLogic = Create2.deploy(0, _getL2Salt(OrbitSalts.L2_ROUTER_LOGIC), _creationCodeFor(runtimeCode));
address routerLogic =
Create2.deploy(0, _getL2Salt(OrbitSalts.L2_ROUTER_LOGIC), _creationCodeFor(runtimeCode));
ProxyAdmin(proxyAdmin).upgrade(ITransparentUpgradeableProxy(canonicalRouter), routerLogic);

// init
Expand Down Expand Up @@ -90,9 +99,12 @@ contract L2AtomicTokenBridgeFactory {
);

// create L2 standard gateway logic and upgrade
address stdGatewayLogic =
Create2.deploy(0, _getL2Salt(OrbitSalts.L2_STANDARD_GATEWAY_LOGIC), _creationCodeFor(runtimeCode));
ProxyAdmin(proxyAdmin).upgrade(ITransparentUpgradeableProxy(canonicalStdGateway), stdGatewayLogic);
address stdGatewayLogic = Create2.deploy(
0, _getL2Salt(OrbitSalts.L2_STANDARD_GATEWAY_LOGIC), _creationCodeFor(runtimeCode)
);
ProxyAdmin(proxyAdmin).upgrade(
ITransparentUpgradeableProxy(canonicalStdGateway), stdGatewayLogic
);

// create beacon
StandardArbERC20 standardArbERC20 = new StandardArbERC20{
Expand All @@ -107,7 +119,9 @@ contract L2AtomicTokenBridgeFactory {

// init contracts
beaconProxyFactory.initialize(address(beacon));
L2ERC20Gateway(canonicalStdGateway).initialize(l1StandardGateway, router, address(beaconProxyFactory));
L2ERC20Gateway(canonicalStdGateway).initialize(
l1StandardGateway, router, address(beaconProxyFactory)
);
}

function _deployCustomGateway(
Expand All @@ -130,9 +144,12 @@ contract L2AtomicTokenBridgeFactory {
);

// create L2 custom gateway logic and upgrade
address customGatewayLogicAddress =
Create2.deploy(0, _getL2Salt(OrbitSalts.L2_CUSTOM_GATEWAY_LOGIC), _creationCodeFor(runtimeCode));
ProxyAdmin(proxyAdmin).upgrade(ITransparentUpgradeableProxy(canonicalCustomGateway), customGatewayLogicAddress);
address customGatewayLogicAddress = Create2.deploy(
0, _getL2Salt(OrbitSalts.L2_CUSTOM_GATEWAY_LOGIC), _creationCodeFor(runtimeCode)
);
ProxyAdmin(proxyAdmin).upgrade(
ITransparentUpgradeableProxy(canonicalCustomGateway), customGatewayLogicAddress
);

// init
L2GatewayRouter(canonicalCustomGateway).initialize(l1CustomGateway, router);
Expand All @@ -156,8 +173,9 @@ contract L2AtomicTokenBridgeFactory {
);

// create L2WETH logic and upgrade
address l2WethLogic =
Create2.deploy(0, _getL2Salt(OrbitSalts.L2_WETH_LOGIC), _creationCodeFor(aeWethRuntimeCode));
address l2WethLogic = Create2.deploy(
0, _getL2Salt(OrbitSalts.L2_WETH_LOGIC), _creationCodeFor(aeWethRuntimeCode)
);
ProxyAdmin(proxyAdmin).upgrade(ITransparentUpgradeableProxy(canonicalL2Weth), l2WethLogic);

// canonical L2 WETH gateway with dummy logic
Expand All @@ -172,17 +190,24 @@ contract L2AtomicTokenBridgeFactory {
);

// create L2WETH gateway logic and upgrade
address l2WethGatewayLogic =
Create2.deploy(0, _getL2Salt(OrbitSalts.L2_WETH_GATEWAY_LOGIC), _creationCodeFor(wethGatewayRuntimeCode));
ProxyAdmin(proxyAdmin).upgrade(ITransparentUpgradeableProxy(canonicalL2WethGateway), l2WethGatewayLogic);
address l2WethGatewayLogic = Create2.deploy(
0,
_getL2Salt(OrbitSalts.L2_WETH_GATEWAY_LOGIC),
_creationCodeFor(wethGatewayRuntimeCode)
);
ProxyAdmin(proxyAdmin).upgrade(
ITransparentUpgradeableProxy(canonicalL2WethGateway), l2WethGatewayLogic
);

// init gateway
L2WethGateway(payable(canonicalL2WethGateway)).initialize(
l1WethGateway, router, l1Weth, address(canonicalL2Weth)
);

// init L2Weth
aeWETH(payable(canonicalL2Weth)).initialize("WETH", "WETH", 18, canonicalL2WethGateway, l1Weth);
aeWETH(payable(canonicalL2Weth)).initialize(
"WETH", "WETH", 18, canonicalL2WethGateway, l1Weth
);
}

function _getL2Salt(bytes32 prefix) internal view returns (bytes32) {
Expand Down Expand Up @@ -240,7 +265,8 @@ library OrbitSalts {
bytes32 public constant L2_PROXY_ADMIN = keccak256(bytes("OrbitL2ProxyAdmin"));
bytes32 public constant L2_ROUTER_LOGIC = keccak256(bytes("OrbitL2GatewayRouterLogic"));
bytes32 public constant L2_ROUTER = keccak256(bytes("OrbitL2GatewayRouterProxy"));
bytes32 public constant L2_STANDARD_GATEWAY_LOGIC = keccak256(bytes("OrbitL2StandardGatewayLogic"));
bytes32 public constant L2_STANDARD_GATEWAY_LOGIC =
keccak256(bytes("OrbitL2StandardGatewayLogic"));
bytes32 public constant L2_STANDARD_GATEWAY = keccak256(bytes("OrbitL2StandardGatewayProxy"));
bytes32 public constant L2_CUSTOM_GATEWAY_LOGIC = keccak256(bytes("OrbitL2CustomGatewayLogic"));
bytes32 public constant L2_CUSTOM_GATEWAY = keccak256(bytes("OrbitL2CustomGatewayProxy"));
Expand Down
Loading