Skip to content

Commit abb8687

Browse files
committed
feat: null message telling the Fast Bridge to ignore the claim for a ticketID
1 parent 7bc2272 commit abb8687

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

contracts/src/bridge/FastBridgeReceiverOnEthereum.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ contract FastBridgeReceiverOnEthereum is SafeBridgeReceiverOnEthereum, IFastBrid
148148
require(_relay(_messageData), "Failed to call contract"); // Checks-Effects-Interaction
149149
}
150150

151+
function ignoreClaim(uint256 _ticketID) external override {
152+
require(isSentBySafeBridge(), "Access not allowed: SafeBridgeSender only.");
153+
154+
delete tickets[_ticketID]; // nobody gets rewarded for this and the Claimant loses his deposit
155+
}
156+
151157
function withdrawClaimDeposit(uint256 _ticketID) external override {
152158
Ticket storage ticket = tickets[_ticketID];
153159
require(ticket.relayed == true, "Message not relayed yet");

contracts/src/bridge/FastBridgeSenderToEthereum.sol

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ contract FastBridgeSenderToEthereum is SafeBridgeSenderToEthereum, IFastBridgeSe
107107
* @param _receiver The L1 contract address who will receive the calldata
108108
* @param _calldata The receiving domain encoded message data.
109109
*/
110-
function sendSafeFallback(
110+
function sendSafeTicket(
111111
uint256 _ticketID,
112112
address _receiver,
113113
bytes memory _calldata
@@ -132,6 +132,18 @@ contract FastBridgeSenderToEthereum is SafeBridgeSenderToEthereum, IFastBridgeSe
132132
_sendSafe(address(fastBridgeReceiver), safeMessageData);
133133
}
134134

135+
function sendSafeNullTicket(uint256 _ticketID) external payable override {
136+
Ticket storage ticket = tickets[_ticketID];
137+
require(ticket.messageHash == 0, "Ticket does exist.");
138+
139+
// Safe Bridge message envelope
140+
bytes4 methodSelector = IFastBridgeReceiver.ignoreClaim.selector;
141+
bytes memory safeMessageData = abi.encodeWithSelector(methodSelector, _ticketID);
142+
143+
// TODO: how much ETH should be provided for bridging? add an ISafeBridgeSender.bridgingCost() if needed
144+
_sendSafe(address(fastBridgeReceiver), safeMessageData);
145+
}
146+
135147
// ************************ //
136148
// * Governance * //
137149
// ************************ //

contracts/src/bridge/interfaces/IFastBridgeReceiver.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ interface IFastBridgeReceiver {
1919
bytes calldata _messageData
2020
) external;
2121

22+
function ignoreClaim(uint256 _ticketID) external;
23+
2224
function withdrawClaimDeposit(uint256 _ticketID) external;
2325

2426
function withdrawChallengeDeposit(uint256 _ticketID) external;

contracts/src/bridge/interfaces/IFastBridgeSender.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@ interface IFastBridgeSender {
2020
* @param _receiver The L1 contract address who will receive the calldata
2121
* @param _calldata The receiving domain encoded message data.
2222
*/
23-
function sendSafeFallback(
23+
function sendSafeTicket(
2424
uint256 _ticketID,
2525
address _receiver,
2626
bytes memory _calldata
2727
) external payable;
28+
29+
/**
30+
* Sends a special message to the counterparty contract indicating to ignore
31+
* a specific claim about a `ticketID`
32+
*
33+
* @param _ticketID The identifier to provide to sendSafeFallback()
34+
*/
35+
function sendSafeNullTicket(uint256 _ticketID) external payable;
2836
}

0 commit comments

Comments
 (0)