Skip to content

Commit

Permalink
fixes address alias import in scroll sequencer uptime feed
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-de-leon-cll committed Feb 16, 2024
1 parent 7b671f7 commit a06acfc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {TypeAndVersionInterface} from "../../../interfaces/TypeAndVersionInterfa

import {SimpleReadAccessController} from "../../../shared/access/SimpleReadAccessController.sol";

import {AddressAliasHelper} from "../../../vendor/arb-bridge-eth/v0.8.0-custom/contracts/libraries/AddressAliasHelper.sol";
import {AddressAliasHelper} from "../../../vendor/@scroll-tech/contracts/src/libraries/common/AddressAliasHelper.sol";
import {IL2ScrollMessenger} from "@scroll-tech/contracts/L2/IL2ScrollMessenger.sol";

/// @title ScrollSequencerUptimeFeed - L2 sequencer uptime status aggregator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

// @source: https://github.com/scroll-tech/scroll/blob/develop/contracts/src/libraries/common/AddressAliasHelper.sol
library AddressAliasHelper {
/// @dev The offset added to the address in L1.
uint160 internal constant OFFSET = uint160(0x1111000000000000000000000000000000001111);

/// @notice Utility function that converts the address in the L1 that submitted a tx to
/// the inbox to the msg.sender viewed in the L2
/// @param l1Address the address in the L1 that triggered the tx to L2
/// @return l2Address L2 address as viewed in msg.sender
function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {
unchecked {
l2Address = address(uint160(l1Address) + OFFSET);
}
}

/// @notice Utility function that converts the msg.sender viewed in the L2 to the
/// address in the L1 that submitted a tx to the inbox
/// @param l2Address L2 address as viewed in msg.sender
/// @return l1Address the address in the L1 that triggered the tx to L2
function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) {
unchecked {
l1Address = address(uint160(l2Address) - OFFSET);
}
}
}

0 comments on commit a06acfc

Please sign in to comment.