Skip to content

Commit c17b671

Browse files
committed
Merge branch 'relayer-bug-fix' of github.com:OpenZeppelin/minimal-rollup into relayer-bug-fix
2 parents edbe319 + e2e660e commit c17b671

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

src/protocol/IMessageRelayer.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ interface IMessageRelayer {
2727
/// @param ethDeposit The deposit to claim
2828
/// @param height The `height` of the checkpoint on the source chain (i.e. the block number or publicationId)
2929
/// @param proof Proof of the deposit
30-
/// @param tipRecipient Address the relayer will send the tip to (chosen by the relayer)
30+
/// @param tipRecipient Address the relayer will send the tip to (chosen by the relayer) if not specified as part of
31+
/// the ethDeposit
3132
function relayMessage(
3233
IETHBridge.ETHDeposit memory ethDeposit,
3334
uint256 height,

src/protocol/taiko_alethia/MessageRelayer.sol

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {TransientSlot} from "@openzeppelin/contracts/utils/TransientSlot.sol";
66
import {IETHBridge} from "src/protocol/IETHBridge.sol";
77

88
import {IMessageRelayer} from "src/protocol/IMessageRelayer.sol";
9-
import {MessageRelayer} from "src/protocol/taiko_alethia/MessageRelayer.sol";
109

1110
/// @dev Simple implementation of a message relayer.
1211
///
@@ -29,28 +28,26 @@ import {MessageRelayer} from "src/protocol/taiko_alethia/MessageRelayer.sol";
2928
/// IMessageRelayer.receiveMessage,
3029
/// (
3130
/// address(Alice), // to
32-
/// address(tipRecipient) // specified tip recipient
3331
/// 0.1 ether, // tip for the relayer
32+
/// address(tipRecipient) // specified tip recipient
3433
/// 0, // gas limit
3534
/// "" // data (in this case empty)
3635
/// )
3736
/// )
3837
///
3938
/// To relay the message:
40-
/// 1. Anyone is allowed to call `relayMessage` however the tip recipient is determined by one of the two following
41-
/// cases:
42-
/// a) If no tip recipient is specified in the ETHDeposit message the one in temporary storage will be used
43-
/// b) If a tip recipient is specified in the ETHDeposit message it will be used
44-
/// It is up to the relayer to decide whether it is worth to relay this message or not (decided if they control the
45-
/// tipRecipient address or not)
46-
/// 2. This will call claimDeposit on the ETHBridge
47-
/// 3. If the original message was specified correctly, this will call receiveMessage on this contract
48-
/// 4. This will call the message recipient and send the tip to the tip recipient
49-
///
50-
/// The tip recipient will net any tip minus the gas spent on the call to relayMessage.
39+
/// 1. Trigger the relay:
40+
/// a) If the tip recipient is specified in the ETHDeposit, the relayer can call `ETHBridge.claimDeposit` directly.
41+
/// b) Otherwise, anyone can pass a tip recipient to `relayMessage`, which will then call `ETHBridge.claimDeposit`.
42+
/// Note that the provided recipient will be ignored if it already specified.
43+
/// Relayers should ensure the tip they receive is sufficient compensation for the gas spent on this call.
44+
/// 2. If the original message was specified correctly, `claimDeposit` will invoke `receiveMessage` on this contract.
45+
/// 3. This will call the message recipient and send the tip to the tip recipient.
5146
///
52-
/// WARN: There is no relayer protection. In particular:
53-
/// - if the ETHDeposit does not invoke receiveMessage, the tip recipient will not be paid.
47+
/// WARN: There is no relayer protection. In particular
48+
/// - if the ETHDeposit does not invoke `receiveMessage`, the tip recipient will not be paid.
49+
/// - if a relayer calls `claimDeposit` directly (case 1a above) but no recipient is specified, the tip will be sent
50+
/// to whichever address happens to be stored in the `TIP_RECIPIENT_SLOT` (including address(0)).
5451
contract MessageRelayer is ReentrancyGuardTransient, IMessageRelayer {
5552
using TransientSlot for *;
5653

@@ -66,8 +63,7 @@ contract MessageRelayer is ReentrancyGuardTransient, IMessageRelayer {
6663
uint256 private constant BUFFER = 20_000;
6764

6865
/// @inheritdoc IMessageRelayer
69-
/// @dev Only specify a tip recipient if one is not set in the ETHDeposit data field otherwise
70-
/// that one will be used instead
66+
/// @dev `ETHBridge.claimDeposit` should be called instead if the tip recipient is specified in the `ethDeposit`.
7167
function relayMessage(
7268
IETHBridge.ETHDeposit memory ethDeposit,
7369
uint256 height,

0 commit comments

Comments
 (0)