Skip to content

Commit dda5bd1

Browse files
authored
Merge pull request #12 from OffchainLabs/address-calc-update
Calculate properly canonical address of L1 router
2 parents 280d518 + 76231f5 commit dda5bd1

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

contracts/tokenbridge/arbitrum/L2AtomicTokenBridgeFactory.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ struct L2RuntimeCode {
333333
* Collection of salts used in CREATE2 deployment of L2 token bridge contracts.
334334
*/
335335
library OrbitSalts {
336-
bytes public constant L1_PROXY_ADMIN = bytes("OrbitL1ProxyAdmin");
337336
bytes public constant L1_ROUTER = bytes("OrbitL1GatewayRouterProxy");
338337
bytes public constant L1_STANDARD_GATEWAY = bytes("OrbitL1StandardGatewayProxy");
339338
bytes public constant L1_CUSTOM_GATEWAY = bytes("OrbitL1CustomGatewayProxy");

contracts/tokenbridge/ethereum/L1AtomicTokenBridgeCreator.sol

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,7 @@ contract L1AtomicTokenBridgeCreator is Initializable, OwnableUpgradeable {
518518
}
519519

520520
function getCanonicalL1RouterAddress(address inbox) public view returns (address) {
521-
address expectedL1ProxyAdminAddress = Create2.computeAddress(
522-
_getL1Salt(OrbitSalts.L1_PROXY_ADMIN, inbox),
523-
keccak256(type(ProxyAdmin).creationCode),
524-
address(this)
525-
);
521+
address proxyAdminAddress = IInbox_ProxyAdmin(inbox).getProxyAdmin();
526522

527523
bool isUsingFeeToken = _getFeeToken(inbox) != address(0);
528524
address template = isUsingFeeToken
@@ -534,7 +530,7 @@ contract L1AtomicTokenBridgeCreator is Initializable, OwnableUpgradeable {
534530
keccak256(
535531
abi.encodePacked(
536532
type(TransparentUpgradeableProxy).creationCode,
537-
abi.encode(template, expectedL1ProxyAdminAddress, bytes(""))
533+
abi.encode(template, proxyAdminAddress, bytes(""))
538534
)
539535
),
540536
address(this)

scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ export const setupTokenBridgeInLocalEnv = async () => {
110110

111111
//// run retryable estimate for deploying L2 factory
112112
const deployFactoryGasParams = await getEstimateForDeployingFactory(
113-
l1Deployer,
114-
l2Deployer.provider!
113+
parentDeployer,
114+
childDeployer.provider!
115115
)
116116
const gasLimitForL2FactoryDeployment = deployFactoryGasParams.gasLimit
117117

118118
const { l1TokenBridgeCreator, retryableSender } =
119119
await deployL1TokenBridgeCreator(
120-
l1Deployer,
120+
parentDeployer,
121121
l1Weth,
122122
gasLimitForL2FactoryDeployment
123123
)

test-e2e/tokenBridgeDeploymentTest.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
IInbox__factory,
66
IOwnable__factory,
77
IRollupCore__factory,
8+
L1AtomicTokenBridgeCreator,
89
L1AtomicTokenBridgeCreator__factory,
910
L1CustomGateway,
1011
L1CustomGateway__factory,
@@ -85,10 +86,15 @@ describe('tokenBridge', () => {
8586
l1RetryableSender.toLowerCase()
8687
)
8788

89+
const creator = L1AtomicTokenBridgeCreator__factory.connect(
90+
l1TokenBridgeCreator,
91+
l1Provider
92+
)
8893
await checkL1RouterInitialization(
8994
L1GatewayRouter__factory.connect(l1.router, l1Provider),
9095
l1,
91-
l2
96+
l2,
97+
creator
9298
)
9399

94100
await checkL1StandardGatewayInitialization(
@@ -156,10 +162,15 @@ describe('tokenBridge', () => {
156162
async function checkL1RouterInitialization(
157163
l1Router: L1GatewayRouter,
158164
l1: L1,
159-
l2: L2
165+
l2: L2,
166+
creator: L1AtomicTokenBridgeCreator
160167
) {
161168
console.log('checkL1RouterInitialization')
162169

170+
expect(l1.router.toLowerCase()).to.be.eq(
171+
(await creator.getCanonicalL1RouterAddress(l1.inbox)).toLowerCase()
172+
)
173+
163174
expect((await l1Router.defaultGateway()).toLowerCase()).to.be.eq(
164175
l1.standardGateway.toLowerCase()
165176
)
@@ -379,6 +390,7 @@ async function checkL1Ownership(l1: L1) {
379390
console.log('checkL1Ownership')
380391

381392
// check proxyAdmins
393+
382394
expect(await _getProxyAdmin(l1.router, l1Provider)).to.be.eq(l1.proxyAdmin)
383395
expect(await _getProxyAdmin(l1.standardGateway, l1Provider)).to.be.eq(
384396
l1.proxyAdmin

0 commit comments

Comments
 (0)