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

fix: L-02 Unnecessary Legacy Check For Chain Migration #1000

Draft
wants to merge 3 commits into
base: library-fix-review
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
15 changes: 0 additions & 15 deletions l1-contracts/contracts/bridge/interfaces/IL2Bridge.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {TWO_BRIDGES_MAGIC_VALUE, ETH_TOKEN_ADDRESS} from "../../common/Config.so
import {IL1NativeTokenVault} from "../../bridge/ntv/L1NativeTokenVault.sol";
import {L2_NATIVE_TOKEN_VAULT_ADDR} from "../../common/L2ContractAddresses.sol";
import {SafeERC20} from "@openzeppelin/contracts-v4/token/ERC20/utils/SafeERC20.sol";
import {IL2Bridge} from "../../bridge/interfaces/IL2Bridge.sol";
import {IL2SharedBridgeLegacy} from "../../bridge/interfaces/IL2SharedBridgeLegacy.sol";
import {IL2SharedBridgeLegacyFunctions} from "../../bridge/interfaces/IL2SharedBridgeLegacyFunctions.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {ReentrancyGuard} from "../common/ReentrancyGuard.sol";
import {AlreadyWhitelisted, InvalidSelector, NotWhitelisted, ZeroAddress} from "../common/L1ContractErrors.sol";
import {ITransactionFilterer} from "../state-transition/chain-interfaces/ITransactionFilterer.sol";
import {IBridgehub} from "../bridgehub/IBridgehub.sol";
import {IL2Bridge} from "../bridge/interfaces/IL2Bridge.sol";
import {IAssetRouterBase} from "../bridge/asset-router/IAssetRouterBase.sol";

/// @author Matter Labs
Expand Down Expand Up @@ -83,8 +82,7 @@ contract GatewayTransactionFilterer is ITransactionFilterer, ReentrancyGuard, Ow
if (sender == L1_ASSET_ROUTER) {
bytes4 l2TxSelector = bytes4(l2Calldata[:4]);
if (
(IAssetRouterBase.finalizeDeposit.selector != l2TxSelector) &&
(IL2Bridge.finalizeDeposit.selector != l2TxSelector)
(IAssetRouterBase.finalizeDeposit.selector != l2TxSelector)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we run lints? Seems like double () is not needed

Suggested change
(IAssetRouterBase.finalizeDeposit.selector != l2TxSelector)
IAssetRouterBase.finalizeDeposit.selector != l2TxSelector

) {
revert InvalidSelector(l2TxSelector);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ pragma solidity 0.8.24;
import {GatewayTransactionFiltererTest} from "./_GatewayTransactionFilterer_Shared.t.sol";

import {IGetters} from "contracts/state-transition/chain-interfaces/IGetters.sol";
import {IL2Bridge} from "contracts/bridge/interfaces/IL2Bridge.sol";
import {IBridgehub} from "contracts/bridgehub/IBridgehub.sol";
import {IAssetRouterBase} from "contracts/bridge/asset-router/IAssetRouterBase.sol";
import {AlreadyWhitelisted, InvalidSelector, NotWhitelisted} from "contracts/common/L1ContractErrors.sol";

contract CheckTransactionTest is GatewayTransactionFiltererTest {
function test_TransactionAllowedOnlyFromWhitelistedSenderWhichIsNotAssetRouter() public {
bytes memory txCalladata = abi.encodeCall(IL2Bridge.finalizeDeposit, (bytes32("0x12345"), bytes("0x23456")));
bytes memory txCalladata = abi.encodeCall(IAssetRouterBase.finalizeDeposit, (uint256(10), bytes32("0x12345"), bytes("0x23456")));
vm.startPrank(owner);
vm.mockCall(
bridgehub,
Expand Down Expand Up @@ -50,7 +50,7 @@ contract CheckTransactionTest is GatewayTransactionFiltererTest {

function test_TransactionAllowedFromWhitelistedSenderForChainBridging() public {
address stm = address(0x6060606);
bytes memory txCalladata = abi.encodeCall(IL2Bridge.finalizeDeposit, (bytes32("0x12345"), bytes("0x23456")));
bytes memory txCalladata = abi.encodeCall(IAssetRouterBase.finalizeDeposit, (uint256(10), bytes32("0x12345"), bytes("0x23456")));
vm.startPrank(owner);
vm.mockCall(
bridgehub,
Expand All @@ -74,9 +74,9 @@ contract CheckTransactionTest is GatewayTransactionFiltererTest {
}

function test_TransactionFailsWithInvalidSelectorEvenIfTheSenderIsAR() public {
bytes memory txCalladata = abi.encodeCall(IL2Bridge.withdraw, (bytes32("0x12345"), bytes("0x23456")));
bytes memory txCalladata = abi.encodeCall(IAssetRouterBase.setAssetHandlerAddressThisChain, (bytes32("0x12345"), address(0x01234567890123456789)));
vm.prank(owner);
vm.expectRevert(abi.encodeWithSelector(InvalidSelector.selector, IL2Bridge.withdraw.selector));
vm.expectRevert(abi.encodeWithSelector(InvalidSelector.selector, IAssetRouterBase.setAssetHandlerAddressThisChain.selector));
bool isTxAllowed = transactionFiltererProxy.isTransactionAllowed(
assetRouter,
address(0),
Expand Down
Loading