@@ -30,12 +30,14 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra
30
30
mapping (address relayerAddress = > bool isRelayer ) public relayers;
31
31
/// @dev A transient storage value for forwarding message from source chain to target chains
32
32
bytes32 private finalizeMessageHash;
33
+ /// @dev A transient storage value for represent a valid message claim
34
+ uint256 private claiming;
33
35
/**
34
36
* @dev This empty reserved space is put in place to allow future versions to add new
35
37
* variables without shifting down storage in the inheritance chain.
36
38
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
37
39
*/
38
- uint256 [49 ] private __gap;
40
+ uint256 [48 ] private __gap;
39
41
40
42
/// @notice Primary chain gateway init
41
43
event InitPrimaryChain (IL1Gateway indexed gateway );
@@ -157,9 +159,15 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra
157
159
/// @dev This function is called within the `claimMessageCallback` of L1 gateway
158
160
function receiveMessage (uint256 _value , bytes calldata _callData ) external payable {
159
161
require (msg .value == _value, "Invalid msg value " );
160
- // temporary store message hash for forwarding
161
162
IL1Gateway gateway = IL1Gateway (msg .sender );
162
163
require (gateway == primaryChainGateway || secondaryChainGateways[gateway], "Invalid gateway " );
164
+ uint256 _claiming;
165
+ assembly {
166
+ _claiming := tload (claiming.slot)
167
+ }
168
+ // Ensure claim start from this contract
169
+ require (_claiming == 1 , "Claim not from arbitrator " );
170
+ // Temporary store message hash for forwarding
163
171
bytes32 _finalizeMessageHash = keccak256 (abi.encode (msg .sender , _value, _callData));
164
172
assembly {
165
173
tstore (finalizeMessageHash.slot, _finalizeMessageHash)
@@ -200,6 +208,10 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra
200
208
bytes calldata _receiveCallData ,
201
209
bytes calldata _forwardParams
202
210
) external payable nonReentrant onlyRelayer {
211
+ // Set `claiming` to 1 and check it in `receiveMessage`
212
+ assembly {
213
+ tstore (claiming.slot, 1 )
214
+ }
203
215
// Call the claim interface of source chain message service
204
216
// And it will inner call the `claimMessageCallback` interface of source chain L1Gateway
205
217
// In the `claimMessageCallback` of L1Gateway, it will inner call `receiveMessage` of Arbitrator
0 commit comments