chore: remove sender/recipient checks in YieldRollup.sendMessage since they are already in the ETH bridges

This commit is contained in:
Andrea Franz
2025-06-27 14:42:46 +02:00
parent 709cf6fa5b
commit 3464208e46
2 changed files with 1 additions and 90 deletions

View File

@@ -1,19 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.30;
import { IMessageService } from "../messaging/interfaces/IMessageService.sol";
import { L1MessageService } from "../messaging/l1/L1MessageService.sol";
import { LineaRollupBase } from "./LineaRollupBase.sol";
contract YieldRollup is LineaRollupBase {
error YieldRollup__L1ETHBridgeNotSet();
error YieldRollup__L2ETHBridgeNotSet();
error YieldRollup__InvalidValue();
error YieldRollup__InvalidRecipient();
address public l1ETHBridge;
address public l2ETHBridge;
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
@@ -24,23 +17,7 @@ contract YieldRollup is LineaRollupBase {
}
/**
* @notice Sets the L1ETHBridge address.
* @param _l1ETHBridge The new L1ETHBridge address.
*/
function setL1ETHBridge(address _l1ETHBridge) public onlyRole(DEFAULT_ADMIN_ROLE) {
l1ETHBridge = _l1ETHBridge;
}
/**
* @notice Sets the L2ETHBridge address.
* @param _l2ETHBridge The new L2ETHBridge address.
*/
function setL2ETHBridge(address _l2ETHBridge) public onlyRole(DEFAULT_ADMIN_ROLE) {
l2ETHBridge = _l2ETHBridge;
}
/**
* @notice Sends a message. It doesn't allow sending ETH. If the message is sent to the L2ETHBridge, it checks if the sender is the L1ETHBridge.
* @notice Sends a message. It doesn't allow sending ETH.
* @param _to The recipient of the message.
* @param _fee The fee for the message.
* @param _calldata The calldata for the message.
@@ -50,22 +27,10 @@ contract YieldRollup is LineaRollupBase {
uint256 _fee,
bytes calldata _calldata
) internal override {
if (l1ETHBridge == address(0)) {
revert YieldRollup__L1ETHBridgeNotSet();
}
if (l2ETHBridge == address(0)) {
revert YieldRollup__L2ETHBridgeNotSet();
}
if (msg.value > 0) {
revert YieldRollup__InvalidValue();
}
if (_to == l2ETHBridge && msg.sender != l1ETHBridge) {
revert YieldRollup__InvalidRecipient();
}
super._sendMessage(_to, _fee, _calldata);
}
}

View File

@@ -17,12 +17,10 @@ contract YieldRollupTest is Test {
address user1 = makeAddr("user1");
address l1ETHBridge = makeAddr("l1ETHBridge");
address l2ETHBridge = makeAddr("l2ETHBridge");
address operator = makeAddr("operator");
address defaultAdmin = makeAddr("defaultAdmin");
address verifier = makeAddr("verifier");
address nonAuthorizedAccount = makeAddr("nonAuthorizedAccount");
address securityCouncil = defaultAdmin;
address fallbackOperator = makeAddr("fallbackOperator");
bytes32 VERIFIER_SETTER_ROLE;
@@ -65,27 +63,6 @@ contract YieldRollupTest is Test {
assertEq(yieldRollup.hasRole(DEFAULT_ADMIN_ROLE, defaultAdmin), true, "Default admin not set");
assertEq(yieldRollup.hasRole(OPERATOR_ROLE, operator), true, "Operator not set");
vm.startBroadcast(defaultAdmin);
yieldRollup.setL1ETHBridge(l1ETHBridge);
yieldRollup.setL2ETHBridge(l2ETHBridge);
vm.stopBroadcast();
}
function test_RevertsIfL1ETHBridgeIsNotSet() public {
vm.prank(defaultAdmin);
yieldRollup.setL1ETHBridge(address(0));
vm.expectRevert("YieldRollup__L1ETHBridgeNotSet()");
yieldRollup.sendMessage(user1, 0, "");
}
function test_RevertsIfL2ETHBridgeIsNotSet() public {
vm.prank(defaultAdmin);
yieldRollup.setL2ETHBridge(address(0));
vm.expectRevert("YieldRollup__L2ETHBridgeNotSet()");
yieldRollup.sendMessage(user1, 0, "");
}
function test_RevertsIfInvalidValue() public {
@@ -93,37 +70,6 @@ contract YieldRollupTest is Test {
yieldRollup.sendMessage{ value: 1 }(user1, 0, "");
}
function test_RevertsIfInvalidRecipient() public {
vm.expectRevert("YieldRollup__InvalidRecipient()");
yieldRollup.sendMessage(l2ETHBridge, 0, "");
}
function test_OnlyAdminCanSetL1ETHBridge() public {
vm.prank(nonAuthorizedAccount);
vm.expectRevert(
abi.encodePacked(
"AccessControl: account ",
TestUtils._toAsciiString(nonAuthorizedAccount),
" is missing role ",
TestUtils._toHexString(DEFAULT_ADMIN_ROLE)
)
);
yieldRollup.setL1ETHBridge(l1ETHBridge);
}
function test_OnlyAdminCanSetL2ETHBridge() public {
vm.prank(nonAuthorizedAccount);
vm.expectRevert(
abi.encodePacked(
"AccessControl: account ",
TestUtils._toAsciiString(nonAuthorizedAccount),
" is missing role ",
TestUtils._toHexString(DEFAULT_ADMIN_ROLE)
)
);
yieldRollup.setL2ETHBridge(l2ETHBridge);
}
function test_SendsMessage() public {
vm.prank(l1ETHBridge);
vm.expectEmit();