Skip to content

Commit

Permalink
fix: deprecate sendL2MessageFromOrigin
Browse files Browse the repository at this point in the history
  • Loading branch information
gzeoneth committed Apr 15, 2024
1 parent b7269fd commit 3a7eec7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 56 deletions.
16 changes: 3 additions & 13 deletions src/bridge/AbsInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pragma solidity ^0.8.4;

import {
DataTooLarge,
Deprecated,
GasLimitTooLarge,
InsufficientValue,
InsufficientSubmissionCost,
Expand Down Expand Up @@ -131,19 +132,8 @@ abstract contract AbsInbox is DelegateCallAware, PausableUpgradeable, IInboxBase
}

/// @inheritdoc IInboxBase
function sendL2MessageFromOrigin(bytes calldata messageData)
external
whenNotPaused
onlyAllowed
returns (uint256)
{
if (_chainIdChanged()) revert L1Forked();
// solhint-disable-next-line avoid-tx-origin
if (msg.sender != tx.origin) revert NotOrigin();
if (messageData.length > maxDataSize) revert DataTooLarge(messageData.length, maxDataSize);
uint256 msgNum = _deliverToBridge(L2_MSG, msg.sender, keccak256(messageData), 0);
emit InboxMessageDeliveredFromOrigin(msgNum);
return msgNum;
function sendL2MessageFromOrigin(bytes calldata) external pure returns (uint256) {
revert Deprecated();
}

/// @inheritdoc IInboxBase
Expand Down
45 changes: 2 additions & 43 deletions test/foundry/AbsInbox.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -187,53 +187,12 @@ abstract contract AbsInboxTest is Test {
inb.initialize(bridge, ISequencerInbox(seqInbox));
}

function test_sendL2MessageFromOrigin() public {
// L2 msg params
bytes memory data = abi.encodePacked("some msg");

// expect event
vm.expectEmit(true, true, true, true);
emit InboxMessageDeliveredFromOrigin(0);

// send L2 msg -> tx.origin == msg.sender
vm.prank(user, user);
uint256 msgNum = inbox.sendL2MessageFromOrigin(data);

//// checks
assertEq(msgNum, 0, "Invalid msgNum");
assertEq(bridge.delayedMessageCount(), 1, "Invalid delayed message count");
}

function test_sendL2MessageFromOrigin_revert_WhenPaused() public {
vm.prank(rollup);
inbox.pause();

vm.expectRevert("Pausable: paused");
function test_sendL2MessageFromOrigin_revert() public {
vm.expectRevert(abi.encodeWithSelector(Deprecated.selector));
vm.prank(user);
inbox.sendL2MessageFromOrigin(abi.encodePacked("some msg"));
}

function test_sendL2MessageFromOrigin_revert_NotAllowed() public {
vm.prank(rollup);
inbox.setAllowListEnabled(true);

vm.expectRevert(abi.encodeWithSelector(NotAllowedOrigin.selector, user));
vm.prank(user, user);
inbox.sendL2MessageFromOrigin(abi.encodePacked("some msg"));
}

function test_sendL2MessageFromOrigin_revert_L1Forked() public {
vm.chainId(10);
vm.expectRevert(abi.encodeWithSelector(L1Forked.selector));
vm.prank(user, user);
inbox.sendL2MessageFromOrigin(abi.encodePacked("some msg"));
}

function test_sendL2MessageFromOrigin_revert_NotOrigin() public {
vm.expectRevert(abi.encodeWithSelector(NotOrigin.selector));
inbox.sendL2MessageFromOrigin(abi.encodePacked("some msg"));
}

function test_sendL2Message() public {
// L2 msg params
bytes memory data = abi.encodePacked("some msg");
Expand Down

0 comments on commit 3a7eec7

Please sign in to comment.