You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IInbox publicimmutable inbox; // The address of the Arbitrum Inbox contract.
34
-
35
26
// ************************************* //
36
27
// * Views * //
37
28
// ************************************* //
@@ -55,291 +46,5 @@ contract FastBridgeReceiverOnEthereumMock is IFastBridgeReceiver, ISafeBridgeRec
55
46
uint256_challengePeriod,
56
47
address_safeBridgeSender,
57
48
address _inbox // Ethereum receiver specific
58
-
) {
59
-
deposit = _deposit;
60
-
epochPeriod = _epochPeriod;
61
-
challengePeriod = _challengePeriod;
62
-
safeBridgeSender = _safeBridgeSender;
63
-
inbox =IInbox(_inbox); // Ethereum receiver specific
64
-
}
65
-
66
-
// ************************************** //
67
-
// * * //
68
-
// * General Receiver * //
69
-
// * * //
70
-
// ************************************** //
71
-
72
-
// ************************************* //
73
-
// * Enums / Structs * //
74
-
// ************************************* //
75
-
76
-
struct Claim {
77
-
bytes32 batchMerkleRoot;
78
-
address bridger;
79
-
uint32 timestamp;
80
-
bool honest;
81
-
bool verificationAttempted;
82
-
bool depositAndRewardWithdrawn;
83
-
}
84
-
85
-
struct Challenge {
86
-
address challenger;
87
-
bool honest;
88
-
bool depositAndRewardWithdrawn;
89
-
}
90
-
91
-
// ************************************* //
92
-
// * Storage * //
93
-
// ************************************* //
94
-
95
-
uint256publicimmutable deposit; // The deposit required to submit a claim or challenge
96
-
uint256publicimmutableoverride epochPeriod; // Epochs mark the period between potential batches of messages.
97
-
uint256publicimmutableoverride challengePeriod; // Epochs mark the period between potential batches of messages.
98
-
addresspublicimmutable safeBridgeSender; // The address of the Safe Bridge Sender on the connecting chain.
99
-
100
-
mapping(uint256=>bytes32) public fastInbox; // epoch => validated batch merkle root(optimistically, or challenged and verified with the safe bridge)
101
-
mapping(uint256=> Claim) public claims; // epoch => claim
102
-
mapping(uint256=> Challenge) public challenges; // epoch => challenge
103
-
mapping(uint256=>mapping(uint256=>bytes32)) public relayed; // epoch => packed replay bitmap
104
-
105
-
// ************************************* //
106
-
// * State Modifiers * //
107
-
// ************************************* //
108
-
109
-
/**
110
-
* @dev Submit a claim about the `_batchMerkleRoot` for the last completed epoch from the Fast Bridge and submit a deposit. The `_batchMerkleRoot` should match the one on the sending side otherwise the sender will lose his deposit.
111
-
* @param _epoch The epoch in which the batch to claim.
112
-
* @param _batchMerkleRoot The batch merkle root claimed for the last completed epoch.
113
-
*/
114
-
function claim(uint256_epoch, bytes32_batchMerkleRoot) externalpayableoverride {
require(claims[_epoch].bridger ==address(0), "Claim already made for most recent finalized epoch.");
122
-
123
-
claims[_epoch] =Claim({
124
-
batchMerkleRoot: _batchMerkleRoot,
125
-
bridger: msg.sender,
126
-
timestamp: uint32(block.timestamp),
127
-
honest: false,
128
-
verificationAttempted: false,
129
-
depositAndRewardWithdrawn: false
130
-
});
131
-
emitClaimReceived(_epoch, _batchMerkleRoot);
132
-
}
133
-
134
-
/**
135
-
* @dev Submit a challenge for the claim of the current epoch's Fast Bridge batch merkleroot state and submit a deposit. The `batchMerkleRoot` in the claim already made for the last finalized epoch should be different from the one on the sending side, otherwise the sender will lose his deposit.
136
-
* @param _epoch The epoch of the claim to challenge.
137
-
*/
138
-
function challenge(uint256_epoch) externalpayableoverride {
require(_checkReplayAndRelay(_epoch, _message), "Failed to call contract"); // Checks-Effects-Interaction
216
-
}
217
-
218
-
/**
219
-
* @dev Sends the deposit back to the Bridger if their claim is not successfully challenged. Includes a portion of the Challenger's deposit if unsuccessfully challenged.
220
-
* @param _epoch The epoch associated with the claim deposit to withraw.
221
-
*/
222
-
function withdrawClaimDeposit(uint256_epoch) externaloverride {
223
-
Claim storage claim = claims[_epoch];
224
-
225
-
require(claim.bridger !=address(0), "Claim does not exist");
226
-
require(claim.honest ==true, "Claim failed.");
227
-
require(claim.depositAndRewardWithdrawn ==false, "Claim deposit and any rewards already withdrawn.");
228
-
229
-
uint256 amount = deposit;
230
-
if (challenges[_epoch].challenger !=address(0) && challenges[_epoch].honest ==false) {
231
-
amount += deposit /2; // half burnt
232
-
}
233
-
234
-
claim.depositAndRewardWithdrawn =true;
235
-
emitClaimDepositWithdrawn(_epoch, claim.bridger);
236
-
237
-
payable(claim.bridger).send(amount); // Use of send to prevent reverting fallback. User is responsibility for accepting ETH.
238
-
// Checks-Effects-Interaction
239
-
}
240
-
241
-
/**
242
-
* @dev Sends the deposit back to the Challenger if their challenge is successful. Includes a portion of the Bridger's deposit.
243
-
* @param _epoch The epoch associated with the challenge deposit to withraw.
244
-
*/
245
-
function withdrawChallengeDeposit(uint256_epoch) externaloverride {
246
-
Challenge storage challenge = challenges[_epoch];
247
-
248
-
require(challenge.challenger !=address(0), "Challenge does not exist");
0 commit comments