-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(protocol): fix bridge unpause will delay execution (#16612)
- Loading branch information
Showing
4 changed files
with
34 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ pragma solidity 0.8.24; | |
|
||
import "../common/EssentialContract.sol"; | ||
import "../libs/LibAddress.sol"; | ||
import "../libs/LibMath.sol"; | ||
import "../signal/ISignalService.sol"; | ||
import "./IBridge.sol"; | ||
|
||
|
@@ -13,6 +14,7 @@ import "./IBridge.sol"; | |
/// @custom:security-contact [email protected] | ||
contract Bridge is EssentialContract, IBridge { | ||
using Address for address; | ||
using LibMath for uint256; | ||
using LibAddress for address; | ||
using LibAddress for address payable; | ||
|
||
|
@@ -190,7 +192,7 @@ contract Bridge is EssentialContract, IBridge { | |
} | ||
} | ||
|
||
if (block.timestamp >= invocationDelay + receivedAt) { | ||
if (_isPostInvocationDelay(receivedAt, invocationDelay)) { | ||
delete proofReceipt[msgHash]; | ||
messageStatus[msgHash] = Status.RECALLED; | ||
|
||
|
@@ -262,7 +264,7 @@ contract Bridge is EssentialContract, IBridge { | |
} | ||
} | ||
|
||
if (block.timestamp >= invocationDelay + receivedAt) { | ||
if (_isPostInvocationDelay(receivedAt, invocationDelay)) { | ||
// If the gas limit is set to zero, only the owner can process the message. | ||
if (_message.gasLimit == 0 && msg.sender != _message.destOwner) { | ||
revert B_PERMISSION_DENIED(); | ||
|
@@ -646,4 +648,17 @@ contract Bridge is EssentialContract, IBridge { | |
return false; | ||
} | ||
} | ||
|
||
function _isPostInvocationDelay( | ||
uint256 _receivedAt, | ||
uint256 _invocationDelay | ||
) | ||
private | ||
view | ||
returns (bool) | ||
{ | ||
unchecked { | ||
return block.timestamp >= _receivedAt.max(lastUnpausedAt) + _invocationDelay; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters