Skip to content

Commit

Permalink
If rollupOwner is a contract, alias its address when sending to L2
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika authored and gzeoneth committed Dec 19, 2023
1 parent 4e74ef2 commit bebed61
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
} from "@offchainlabs/upgrade-executor/src/UpgradeExecutor.sol";
import {AddressAliasHelper} from "../libraries/AddressAliasHelper.sol";
import {IInbox, IBridge, IOwnable} from "@arbitrum/nitro-contracts/src/bridge/IInbox.sol";
import {AddressAliasHelper} from "../libraries/AddressAliasHelper.sol";
import {ArbMulticall2} from "../../rpc-utils/MulticallV2.sol";
import {BeaconProxyFactory, ClonableBeaconProxy} from "../libraries/ClonableBeaconProxy.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
Expand Down
15 changes: 13 additions & 2 deletions contracts/tokenbridge/ethereum/L1TokenBridgeRetryableSender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {TransparentUpgradeableProxy} from
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {AddressAliasHelper} from "../libraries/AddressAliasHelper.sol";

/**
* @title Token Bridge Retryable Ticket Sender
Expand Down Expand Up @@ -49,13 +50,23 @@ contract L1TokenBridgeRetryableSender is Initializable, OwnableUpgradeable {
address aliasedL1UpgradeExecutor,
bool isUsingFeeToken
) external payable onlyOwner {
// rollupOwner address is provided to the L2 side so that it can be given the EXECUTOR role on the
// L2 UpgradeExecutor, in addition to alias(L1UpgradeExecutor). rollupOwner can be either EOA or a contract.
// If it is a contract, address needs to be aliased before sending to L2 in order to be usable.
address l2RollupOwner;
if (rollupOwner.code.length == 0) {
l2RollupOwner = rollupOwner;
} else {
l2RollupOwner = AddressAliasHelper.applyL1ToL2Alias(rollupOwner);
}

if (!isUsingFeeToken) {
_sendRetryableUsingEth(
retryableParams,
l2,
l1,
l2StandardGatewayAddress,
rollupOwner,
l2RollupOwner,
deployer,
aliasedL1UpgradeExecutor
);
Expand All @@ -66,7 +77,7 @@ contract L1TokenBridgeRetryableSender is Initializable, OwnableUpgradeable {
l2,
l1,
l2StandardGatewayAddress,
rollupOwner,
l2RollupOwner,
aliasedL1UpgradeExecutor
);
}
Expand Down
12 changes: 10 additions & 2 deletions test-e2e/tokenBridgeDeploymentTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,16 @@ async function checkL2UpgradeExecutorInitialization(
const executorRole = await l2Executor.EXECUTOR_ROLE()

expect(await l2Executor.hasRole(adminRole, l2Executor.address)).to.be.true
expect(await l2Executor.hasRole(executorRole, rollupAddresses.rollupOwner)).to
.be.true

const isL1RollupOwnerContract =
(await l1Provider.getCode(rollupAddresses.rollupOwner)).length >
EMPTY_CODE_LENGTH

const l2RollupOwner = isL1RollupOwnerContract
? applyAlias(rollupAddresses.rollupOwner)
: rollupAddresses.rollupOwner

expect(await l2Executor.hasRole(executorRole, l2RollupOwner)).to.be.true
const aliasedL1Executor = applyAlias(rollupAddresses.upgradeExecutor)
expect(await l2Executor.hasRole(executorRole, aliasedL1Executor)).to.be.true
}
Expand Down

0 comments on commit bebed61

Please sign in to comment.