Skip to content

Commit

Permalink
fix(protocol): check invocation gas limit also in retryMessage (#16660
Browse files Browse the repository at this point in the history
)

Co-authored-by: Keszey Dániel <[email protected]>
Co-authored-by: Daniel Wang <[email protected]>
Co-authored-by: Daniel Wang <[email protected]>
  • Loading branch information
4 people authored Apr 5, 2024
1 parent b341a68 commit 8209a43
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,16 @@ contract Bridge is EssentialContract, IBridge {
revert B_NON_RETRIABLE();
}

// We check gasleft() against _message.gasLimit to make sure we not only need to bridge
// invocation call to succeed, we also need it to succeed with a gas limit no smaller than
// the message's gasLimit.
if (
_message.gasLimit != 0 && msg.sender != _message.destOwner
&& _message.gasLimit > (gasleft() * 63) >> 6
) {
revert B_NOT_ENOUGH_GASLEFT();
}

// Attempt to invoke the messageCall.
if (_invokeMessageCall(_message, msgHash, gasleft())) {
_updateMessageStatus(msgHash, Status.DONE);
Expand Down

0 comments on commit 8209a43

Please sign in to comment.