Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(protocol): check invocation gas limit also in retryMessage #16660

Merged
merged 9 commits into from
Apr 5, 2024
12 changes: 12 additions & 0 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,18 @@ contract Bridge is EssentialContract, IBridge {
revert B_NON_RETRIABLE();
}

// We check _message.gasLimit > gasleft() 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 (
(
dantaik marked this conversation as resolved.
Show resolved Hide resolved
_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
Loading