@@ -54,8 +54,7 @@ contract L2AtomicTokenBridgeFactory {
5454 revert L2AtomicTokenBridgeFactory_AlreadyExists ();
5555 }
5656 }
57- address proxyAdmin =
58- address (new ProxyAdmin { salt: _getL2Salt (OrbitSalts.L2_PROXY_ADMIN) }());
57+ address proxyAdmin = address (new ProxyAdmin {salt: _getL2Salt (OrbitSalts.L2_PROXY_ADMIN)}());
5958
6059 // deploy router/gateways/executor
6160 address upgradeExecutor = _deployUpgradeExecutor (
@@ -93,16 +92,15 @@ contract L2AtomicTokenBridgeFactory {
9392 address aliasedL1UpgradeExecutor
9493 ) internal returns (address ) {
9594 // canonical L2 upgrade executor with dummy logic
96- address canonicalUpgradeExecutor = _deploySeedProxy (
97- proxyAdmin, _getL2Salt (OrbitSalts.L2_EXECUTOR), _getL2Salt (OrbitSalts.L2_EXECUTOR_LOGIC)
98- );
95+ address canonicalUpgradeExecutor = _deploySeedProxy (proxyAdmin, OrbitSalts.L2_EXECUTOR);
9996
10097 // Create UpgradeExecutor logic and upgrade to it.
10198 address upExecutorLogic = Create2.deploy (
10299 0 ,
103- _getL2Salt (OrbitSalts.L2_EXECUTOR_LOGIC ),
100+ _getL2Salt (OrbitSalts.L2_EXECUTOR ),
104101 CreationCodeHelper.getCreationCodeFor (runtimeCode)
105102 );
103+
106104 ProxyAdmin (proxyAdmin).upgrade (
107105 ITransparentUpgradeableProxy (canonicalUpgradeExecutor), upExecutorLogic
108106 );
@@ -127,15 +125,11 @@ contract L2AtomicTokenBridgeFactory {
127125 address proxyAdmin
128126 ) internal returns (address ) {
129127 // canonical L2 router with dummy logic
130- address canonicalRouter = _deploySeedProxy (
131- proxyAdmin, _getL2Salt (OrbitSalts.L2_ROUTER), _getL2Salt (OrbitSalts.L2_ROUTER_LOGIC)
132- );
128+ address canonicalRouter = _deploySeedProxy (proxyAdmin, OrbitSalts.L2_ROUTER);
133129
134130 // create L2 router logic and upgrade
135131 address routerLogic = Create2.deploy (
136- 0 ,
137- _getL2Salt (OrbitSalts.L2_ROUTER_LOGIC),
138- CreationCodeHelper.getCreationCodeFor (runtimeCode)
132+ 0 , _getL2Salt (OrbitSalts.L2_ROUTER), CreationCodeHelper.getCreationCodeFor (runtimeCode)
139133 );
140134 ProxyAdmin (proxyAdmin).upgrade (ITransparentUpgradeableProxy (canonicalRouter), routerLogic);
141135
@@ -156,16 +150,12 @@ contract L2AtomicTokenBridgeFactory {
156150 address upgradeExecutor
157151 ) internal {
158152 // canonical L2 standard gateway with dummy logic
159- address canonicalStdGateway = _deploySeedProxy (
160- proxyAdmin,
161- _getL2Salt (OrbitSalts.L2_STANDARD_GATEWAY),
162- _getL2Salt (OrbitSalts.L2_STANDARD_GATEWAY_LOGIC)
163- );
153+ address canonicalStdGateway = _deploySeedProxy (proxyAdmin, OrbitSalts.L2_STANDARD_GATEWAY);
164154
165155 // create L2 standard gateway logic and upgrade
166156 address stdGatewayLogic = Create2.deploy (
167157 0 ,
168- _getL2Salt (OrbitSalts.L2_STANDARD_GATEWAY_LOGIC ),
158+ _getL2Salt (OrbitSalts.L2_STANDARD_GATEWAY ),
169159 CreationCodeHelper.getCreationCodeFor (runtimeCode)
170160 );
171161 ProxyAdmin (proxyAdmin).upgrade (
@@ -176,15 +166,13 @@ contract L2AtomicTokenBridgeFactory {
176166 L2ERC20Gateway (stdGatewayLogic).initialize (ADDRESS_DEAD, ADDRESS_DEAD, ADDRESS_DEAD);
177167
178168 // create beacon
179- StandardArbERC20 standardArbERC20 = new StandardArbERC20 {
180- salt: _getL2Salt (OrbitSalts.L2_STANDARD_ERC20)
181- }();
169+ StandardArbERC20 standardArbERC20 =
170+ new StandardArbERC20 {salt: _getL2Salt (OrbitSalts.BEACON_PROXY_FACTORY)}();
182171 UpgradeableBeacon beacon = new UpgradeableBeacon {
183- salt: _getL2Salt (OrbitSalts.UPGRADEABLE_BEACON)
184- }(address (standardArbERC20));
185- BeaconProxyFactory beaconProxyFactory = new BeaconProxyFactory {
186172 salt: _getL2Salt (OrbitSalts.BEACON_PROXY_FACTORY)
187- }();
173+ }(address (standardArbERC20));
174+ BeaconProxyFactory beaconProxyFactory =
175+ new BeaconProxyFactory {salt: _getL2Salt (OrbitSalts.BEACON_PROXY_FACTORY)}();
188176
189177 // init contracts
190178 beaconProxyFactory.initialize (address (beacon));
@@ -203,16 +191,12 @@ contract L2AtomicTokenBridgeFactory {
203191 address proxyAdmin
204192 ) internal {
205193 // canonical L2 custom gateway with dummy logic
206- address canonicalCustomGateway = _deploySeedProxy (
207- proxyAdmin,
208- _getL2Salt (OrbitSalts.L2_CUSTOM_GATEWAY),
209- _getL2Salt (OrbitSalts.L2_CUSTOM_GATEWAY_LOGIC)
210- );
194+ address canonicalCustomGateway = _deploySeedProxy (proxyAdmin, OrbitSalts.L2_CUSTOM_GATEWAY);
211195
212196 // create L2 custom gateway logic and upgrade
213197 address customGatewayLogicAddress = Create2.deploy (
214198 0 ,
215- _getL2Salt (OrbitSalts.L2_CUSTOM_GATEWAY_LOGIC ),
199+ _getL2Salt (OrbitSalts.L2_CUSTOM_GATEWAY ),
216200 CreationCodeHelper.getCreationCodeFor (runtimeCode)
217201 );
218202 ProxyAdmin (proxyAdmin).upgrade (
@@ -235,29 +219,23 @@ contract L2AtomicTokenBridgeFactory {
235219 address proxyAdmin
236220 ) internal {
237221 // canonical L2 WETH with dummy logic
238- address canonicalL2Weth = _deploySeedProxy (
239- proxyAdmin, _getL2Salt (OrbitSalts.L2_WETH), _getL2Salt (OrbitSalts.L2_WETH_LOGIC)
240- );
222+ address canonicalL2Weth = _deploySeedProxy (proxyAdmin, OrbitSalts.L2_WETH);
241223
242224 // Create L2WETH logic and upgrade
243225 address l2WethLogic = Create2.deploy (
244226 0 ,
245- _getL2Salt (OrbitSalts.L2_WETH_LOGIC ),
227+ _getL2Salt (OrbitSalts.L2_WETH ),
246228 CreationCodeHelper.getCreationCodeFor (aeWethRuntimeCode)
247229 );
248230 ProxyAdmin (proxyAdmin).upgrade (ITransparentUpgradeableProxy (canonicalL2Weth), l2WethLogic);
249231
250232 // canonical L2 WETH gateway with dummy logic
251- address canonicalL2WethGateway = _deploySeedProxy (
252- proxyAdmin,
253- _getL2Salt (OrbitSalts.L2_WETH_GATEWAY),
254- _getL2Salt (OrbitSalts.L2_WETH_GATEWAY_LOGIC)
255- );
233+ address canonicalL2WethGateway = _deploySeedProxy (proxyAdmin, OrbitSalts.L2_WETH_GATEWAY);
256234
257235 // create L2WETH gateway logic and upgrade
258236 address l2WethGatewayLogic = Create2.deploy (
259237 0 ,
260- _getL2Salt (OrbitSalts.L2_WETH_GATEWAY_LOGIC ),
238+ _getL2Salt (OrbitSalts.L2_WETH_GATEWAY ),
261239 CreationCodeHelper.getCreationCodeFor (wethGatewayRuntimeCode)
262240 );
263241 ProxyAdmin (proxyAdmin).upgrade (
@@ -293,27 +271,18 @@ contract L2AtomicTokenBridgeFactory {
293271 }
294272
295273 /**
296- * Deploys a proxy with empty logic contract in order to get deterministic address which does not depend on actual logic contract.
274+ * Deploys a proxy with address(this) as logic in order to get deterministic address
275+ * the proxy is salted using a salt derived from the prefix, the chainId and the sender
297276 */
298- function _deploySeedProxy (address proxyAdmin , bytes32 proxySalt , bytes32 logicSalt )
299- internal
300- returns (address )
301- {
277+ function _deploySeedProxy (address proxyAdmin , bytes memory prefix ) internal returns (address ) {
302278 return address (
303- new TransparentUpgradeableProxy { salt: proxySalt }(
304- address (new CanonicalAddressSeed { salt: logicSalt}()),
305- proxyAdmin,
306- bytes ("" )
279+ new TransparentUpgradeableProxy {salt: _getL2Salt (prefix)}(
280+ address (this ), proxyAdmin, bytes ("" )
307281 )
308282 );
309283 }
310284}
311285
312- /**
313- * Dummy contract used as initial logic contract for proxies, in order to get canonical (CREATE2 based) address. Then we can upgrade to any logic without having canonical addresses impacted.
314- */
315- contract CanonicalAddressSeed {}
316-
317286/**
318287 * Placeholder for bytecode of token bridge contracts which is sent from L1 to L2 through retryable ticket.
319288 */
@@ -329,28 +298,21 @@ struct L2RuntimeCode {
329298
330299/**
331300 * Collection of salts used in CREATE2 deployment of L2 token bridge contracts.
301+ * Logic contracts are deployed using the same salt as the proxy, it's fine as they have different code
332302 */
333303library OrbitSalts {
334- bytes public constant L1_ROUTER = bytes ("OrbitL1GatewayRouterProxy " );
335- bytes public constant L1_STANDARD_GATEWAY = bytes ("OrbitL1StandardGatewayProxy " );
336- bytes public constant L1_CUSTOM_GATEWAY = bytes ("OrbitL1CustomGatewayProxy " );
337- bytes public constant L1_WETH_GATEWAY = bytes ("OrbitL1WethGatewayProxy " );
338-
339- bytes public constant L2_PROXY_ADMIN = bytes ("OrbitL2ProxyAdmin " );
340- bytes public constant L2_ROUTER_LOGIC = bytes ("OrbitL2GatewayRouterLogic " );
341- bytes public constant L2_ROUTER = bytes ("OrbitL2GatewayRouterProxy " );
342- bytes public constant L2_STANDARD_GATEWAY_LOGIC = bytes ("OrbitL2StandardGatewayLogic " );
343- bytes public constant L2_STANDARD_GATEWAY = bytes ("OrbitL2StandardGatewayProxy " );
344- bytes public constant L2_CUSTOM_GATEWAY_LOGIC = bytes ("OrbitL2CustomGatewayLogic " );
345- bytes public constant L2_CUSTOM_GATEWAY = bytes ("OrbitL2CustomGatewayProxy " );
346- bytes public constant L2_WETH_GATEWAY_LOGIC = bytes ("OrbitL2WethGatewayLogic " );
347- bytes public constant L2_WETH_GATEWAY = bytes ("OrbitL2WethGatewayProxy " );
348- bytes public constant L2_WETH_LOGIC = bytes ("OrbitL2WETH " );
349- bytes public constant L2_WETH = bytes ("OrbitL2WETHProxy " );
350- bytes public constant L2_STANDARD_ERC20 = bytes ("OrbitStandardArbERC20 " );
351- bytes public constant UPGRADEABLE_BEACON = bytes ("OrbitUpgradeableBeacon " );
352- bytes public constant BEACON_PROXY_FACTORY = bytes ("OrbitBeaconProxyFactory " );
353- bytes public constant L2_EXECUTOR_LOGIC = bytes ("OrbitL2UpgradeExecutorLogic " );
354- bytes public constant L2_EXECUTOR = bytes ("OrbitL2UpgradeExecutorProxy " );
355- bytes public constant L2_MULTICALL = bytes ("OrbitL2Multicall " );
304+ bytes internal constant L1_ROUTER = bytes ("L1R " );
305+ bytes internal constant L1_STANDARD_GATEWAY = bytes ("L1SGW " );
306+ bytes internal constant L1_CUSTOM_GATEWAY = bytes ("L1CGW " );
307+ bytes internal constant L1_WETH_GATEWAY = bytes ("L1WGW " );
308+
309+ bytes internal constant L2_PROXY_ADMIN = bytes ("L2PA " );
310+ bytes internal constant L2_ROUTER = bytes ("L2R " );
311+ bytes internal constant L2_STANDARD_GATEWAY = bytes ("L2SGW " );
312+ bytes internal constant L2_CUSTOM_GATEWAY = bytes ("L2CGW " );
313+ bytes internal constant L2_WETH_GATEWAY = bytes ("L2WGW " );
314+ bytes internal constant L2_WETH = bytes ("L2W " );
315+ bytes internal constant BEACON_PROXY_FACTORY = bytes ("L2BPF " );
316+ bytes internal constant L2_EXECUTOR = bytes ("L2E " );
317+ bytes internal constant L2_MULTICALL = bytes ("L2MC " );
356318}
0 commit comments