Skip to content

Commit f29e3bd

Browse files
committed
fix: claim must start from arbitrator
1 parent 8badb5e commit f29e3bd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

contracts/Arbitrator.sol

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra
3030
mapping(address relayerAddress => bool isRelayer) public relayers;
3131
/// @dev A transient storage value for forwarding message from source chain to target chains
3232
bytes32 private finalizeMessageHash;
33+
/// @dev A transient storage value for represent a valid message claim
34+
uint256 private claiming;
3335
/**
3436
* @dev This empty reserved space is put in place to allow future versions to add new
3537
* variables without shifting down storage in the inheritance chain.
3638
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
3739
*/
38-
uint256[49] private __gap;
40+
uint256[48] private __gap;
3941

4042
/// @notice Primary chain gateway init
4143
event InitPrimaryChain(IL1Gateway indexed gateway);
@@ -157,9 +159,15 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra
157159
/// @dev This function is called within the `claimMessageCallback` of L1 gateway
158160
function receiveMessage(uint256 _value, bytes calldata _callData) external payable {
159161
require(msg.value == _value, "Invalid msg value");
160-
// temporary store message hash for forwarding
161162
IL1Gateway gateway = IL1Gateway(msg.sender);
162163
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
163171
bytes32 _finalizeMessageHash = keccak256(abi.encode(msg.sender, _value, _callData));
164172
assembly {
165173
tstore(finalizeMessageHash.slot, _finalizeMessageHash)
@@ -200,6 +208,10 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra
200208
bytes calldata _receiveCallData,
201209
bytes calldata _forwardParams
202210
) external payable nonReentrant onlyRelayer {
211+
// Set `claiming` to 1 and check it in `receiveMessage`
212+
assembly {
213+
tstore(claiming.slot, 1)
214+
}
203215
// Call the claim interface of source chain message service
204216
// And it will inner call the `claimMessageCallback` interface of source chain L1Gateway
205217
// In the `claimMessageCallback` of L1Gateway, it will inner call `receiveMessage` of Arbitrator

0 commit comments

Comments
 (0)