diff --git a/packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol b/packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol index 0d7b46080fc93..95af6b00486cd 100644 --- a/packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol +++ b/packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol @@ -10,6 +10,7 @@ import { IL2ToL2CrossDomainMessenger } from "src/L2/interfaces/IL2ToL2CrossDomai import { ISemver } from "src/universal/interfaces/ISemver.sol"; import { SafeCall } from "src/libraries/SafeCall.sol"; import { TransientReentrancyAware } from "src/libraries/TransientContext.sol"; +import { Constants } from "src/libraries/Constants.sol"; /// @notice Thrown when a non-written slot in transient storage is attempted to be read from. error NotEntered(); @@ -92,12 +93,6 @@ contract L2ToL2CrossDomainMessenger is IL2ToL2CrossDomainMessenger, ISemver, Tra /// @param messageHash Hash of the message that was relayed. event RelayedMessage(uint256 indexed source, uint256 indexed messageNonce, bytes32 indexed messageHash); - /// @notice Emitted whenever a message fails to be relayed on this chain. - /// @param source Chain ID of the source chain. - /// @param messageNonce Nonce associated with the messsage sent - /// @param messageHash Hash of the message that failed to be relayed. - event FailedRelayedMessage(uint256 indexed source, uint256 indexed messageNonce, bytes32 indexed messageHash); - /// @notice Retrieves the sender of the current cross domain message. If not entered, reverts. /// @return sender_ Address of the sender of the current cross domain message. function crossDomainMessageSender() external view onlyEntered returns (address sender_) { @@ -204,7 +199,7 @@ contract L2ToL2CrossDomainMessenger is IL2ToL2CrossDomainMessenger, ISemver, Tra successfulMessages[messageHash] = true; emit RelayedMessage(source, nonce, messageHash); } else { - emit FailedRelayedMessage(source, nonce, messageHash); + revert("L2ToL2CrossDomainMessenger: failed to relay message"); } _storeMessageMetadata(0, address(0)); diff --git a/packages/contracts-bedrock/test/L2/L2ToL2CrossDomainMessenger.t.sol b/packages/contracts-bedrock/test/L2/L2ToL2CrossDomainMessenger.t.sol index e0149e8aab781..731511afc40d1 100644 --- a/packages/contracts-bedrock/test/L2/L2ToL2CrossDomainMessenger.t.sol +++ b/packages/contracts-bedrock/test/L2/L2ToL2CrossDomainMessenger.t.sol @@ -402,12 +402,6 @@ contract L2ToL2CrossDomainMessengerTest is Test { address target = address(this); bytes memory message = abi.encodeWithSelector(this.mockTargetReentrant.selector, _source2, _nonce, _sender2); - // Look for correct emitted event - vm.expectEmit(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER); - emit L2ToL2CrossDomainMessenger.FailedRelayedMessage( - _source1, _nonce, keccak256(abi.encode(block.chainid, _source1, _nonce, _sender1, target, message)) - ); - // Ensure the target contract is called with the correct parameters vm.expectCall({ callee: target, msgValue: _value, data: message }); @@ -426,6 +420,7 @@ contract L2ToL2CrossDomainMessengerTest is Test { returnData: "" }); + vm.expectRevert("L2ToL2CrossDomainMessenger: failed to relay message"); hoax(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _value); l2ToL2CrossDomainMessenger.relayMessage{ value: _value }(id, sentMessage); @@ -673,12 +668,6 @@ contract L2ToL2CrossDomainMessengerTest is Test { // Ensure that the target contract reverts vm.mockCallRevert({ callee: _target, msgValue: _value, data: _message, revertData: abi.encode(false) }); - // Look for correct emitted event - vm.expectEmit(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER); - emit L2ToL2CrossDomainMessenger.FailedRelayedMessage( - _source, _nonce, keccak256(abi.encode(block.chainid, _source, _nonce, _sender, _target, _message)) - ); - ICrossL2Inbox.Identifier memory id = ICrossL2Inbox.Identifier(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _blockNum, _logIndex, _time, _source); bytes memory sentMessage = abi.encodePacked( @@ -693,6 +682,7 @@ contract L2ToL2CrossDomainMessengerTest is Test { returnData: "" }); + vm.expectRevert("L2ToL2CrossDomainMessenger: failed to relay message"); hoax(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, _value); l2ToL2CrossDomainMessenger.relayMessage{ value: _value }(id, sentMessage); }